23 #if defined (HAVE_CONFIG_H)
31 #include <QNetworkProxy>
32 #include <QLibraryInfo>
33 #include <QMessageBox>
34 #if defined (HAVE_QT5)
35 # include <QStandardPaths>
59 "default-qt-settings";
65 : settings_directory (), settings_file (), settings (0),
68 #if defined (HAVE_QT4)
70 = QDesktopServices::storageLocation (QDesktopServices::HomeLocation);
73 = QStandardPaths::writableLocation (QStandardPaths::HomeLocation);
81 QSettings::IniFormat);
102 QTranslator *qsci_tr,
108 = QLibraryInfo::location (QLibraryInfo::TranslationsPath);
110 QString language =
"SYSTEM";
117 language = settings->value (
"language",
"SYSTEM").toString ();
120 if (language ==
"SYSTEM")
124 loaded = qt_tr->load (
"qt_" + language, qt_trans_dir);
127 qt_tr->load (
"qt_" + language.toLower (), qt_trans_dir);
130 loaded = qsci_tr->load (
"qscintilla_" + language, qt_trans_dir);
133 qsci_tr->load (
"qscintilla_" + language.toLower (), qt_trans_dir);
149 error (
"unable to create resource_manager object!");
189 if (! qt_settings.open (QFile::ReadOnly))
192 QTextStream in (&qt_settings);
193 QString settings_text = in.readAll ();
194 qt_settings.close ();
197 #if defined (HAVE_QFONT_MONOSPACE)
199 fixed_font.setStyleHint (QFont::Monospace);
200 QString default_family = fixed_font.defaultFamily ();
201 #elif defined (Q_WS_X11) || defined (Q_WS_WIN)
202 QString default_family =
"Courier New";
203 #elif defined (Q_WS_MAC)
204 QString default_family =
"Courier";
206 QString default_family =
"courier";
210 #if defined (Q_OS_WIN32)
211 QString custom_editor =
"notepad++ -n%l %f";
213 QString custom_editor =
"emacs +%l %f";
217 settings_text.replace (
"__default_custom_editor__", custom_editor);
218 settings_text.replace (
"__default_font__", default_family);
219 settings_text.replace (
"__default_font_size__",
"10");
223 if (! user_settings.open (QIODevice::WriteOnly))
226 QTextStream out (&user_settings);
228 out << settings_text;
230 user_settings.close ();
240 settings =
new QSettings (file, QSettings::IniFormat);
243 && QFile::exists (
settings->fileName ())
245 &&
settings->status () == QSettings::NoError))
247 QString msg = QString (QT_TR_NOOP (
248 "The settings file\n%1\n"
249 "does not exist and can not be created.\n"
250 "Make sure you have read and write permissions to\n%2\n\n"
251 "Octave GUI must be closed now."));
252 QMessageBox::critical (0, QString (QT_TR_NOOP (
"Octave Critical Error")),
269 QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
271 if (
settings->value (
"useProxyServer",
false).toBool ())
273 QString proxyTypeString =
settings->value (
"proxyType").toString ();
275 if (proxyTypeString ==
"Socks5Proxy")
276 proxyType = QNetworkProxy::Socks5Proxy;
277 else if (proxyTypeString ==
"HttpProxy")
278 proxyType = QNetworkProxy::HttpProxy;
283 proxy.setType (proxyType);
284 proxy.setHostName (
settings->value (
"proxyHostName").toString ());
285 proxy.setPort (
settings->value (
"proxyPort",80).toInt ());
286 proxy.setUser (
settings->value (
"proxyUserName").toString ());
287 proxy.setPassword (
settings->value (
"proxyPassword").toString ());
289 QNetworkProxy::setApplicationProxy (proxy);
325 return QIcon::fromTheme (icon_name,
326 QIcon (
":/actions/icons/" + icon_name +
".png"));
328 return QIcon::fromTheme (icon_name);
336 QList<int> all_mibs = QTextCodec::availableMibs ();
337 QStringList all_codecs;
338 foreach (
int mib, all_mibs)
340 QTextCodec *
c = QTextCodec::codecForMib (mib);
341 all_codecs << c->name ().toUpper ();
343 all_codecs.removeDuplicates ();
347 #if defined (Q_OS_WIN32)
348 QString def_enc =
"SYSTEM";
350 QString def_enc =
"UTF-8";
354 QString enc = current;
357 enc =
settings->value (
"editor/default_encoding",def_enc).toString ();
363 foreach (QString
c, all_codecs)
367 combo->insertSeparator (0);
368 combo->insertItem (0, def_enc);
371 int idx = combo->findText (enc);
373 combo->setCurrentIndex (idx);
375 combo->setCurrentIndex (0);
377 combo->setMaxVisibleItems (12);
void do_combo_encoding(QComboBox *combo, QString current)
static std::string dir_sep_str(void)
static QStringList storage_class_names(void)
static QString default_qt_settings_file(void)
bool do_is_first_run(void) const
For example cd octave end example noindent changes the current working directory to file
void error(const char *fmt,...)
QString fromStdString(const std::string &s)
void do_set_settings(const QString &file)
QString do_get_settings_file(void)
static QString get_gui_translation_dir(void)
static void config_translators(QTranslator *, QTranslator *, QTranslator *)
static QStringList terminal_color_names(void)
QSettings * do_get_settings(void) const
static std::string getenv(const std::string &name)
static QList< QColor > storage_class_default_colors(void)
static QList< QColor > storage_class_default_colors(void)
QSettings * do_get_default_settings(void) const
QSettings * default_settings
QString settings_directory
QString do_get_settings_directory(void)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
static QSettings * get_settings(void)
static QStringList color_names(void)
static QList< QColor > terminal_default_colors(void)
void do_reload_settings(void)
static resource_manager * instance
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values text mode reading and writing automatically converts linefeeds to the appropriate line end character for the system(carriage-return linefeed on Windows, carriage-return on Macintosh).The default when no mode is specified is binary mode.Additionally
static bool instance_ok(void)
QIcon do_icon(const QString &icon, bool fallback)
static QList< QColor > default_colors(void)
static QStringList storage_class_names(void)
std::string Voct_locale_dir
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
void do_update_network_settings(void)