23 #if defined (HAVE_CONFIG_H) 31 #include <QNetworkProxy> 32 #include <QLibraryInfo> 33 #include <QMessageBox> 34 #if defined (HAVE_QSTANDARDPATHS) 35 # include <QStandardPaths> 63 +
"default-qt-settings");
69 : m_settings_directory (), m_settings_file (), m_settings (nullptr),
70 m_default_settings (nullptr)
72 #if defined (HAVE_QSTANDARDPATHS) 74 = QStandardPaths::writableLocation (QStandardPaths::HomeLocation);
77 = QDesktopServices::storageLocation (QDesktopServices::HomeLocation);
85 QSettings::IniFormat);
104 QTranslator *qsci_tr,
110 = QLibraryInfo::location (QLibraryInfo::TranslationsPath);
112 QString language =
"SYSTEM";
119 language = settings->value (
"language",
"SYSTEM").toString ();
122 if (language ==
"SYSTEM")
126 loaded = qt_tr->load (
"qt_" + language, qt_trans_dir);
129 qt_tr->load (
"qt_" + language.toLower (), qt_trans_dir);
132 loaded = qsci_tr->load (
"qscintilla_" + language, qt_trans_dir);
135 qsci_tr->load (
"qscintilla_" + language.toLower (), qt_trans_dir);
180 error (
"unable to create resource_manager object!");
215 if (! qt_settings.open (QFile::ReadOnly))
218 QTextStream in (&qt_settings);
219 QString settings_text = in.readAll ();
220 qt_settings.close ();
223 #if defined (HAVE_QFONT_MONOSPACE) 225 fixed_font.setStyleHint (QFont::Monospace);
226 QString default_family = fixed_font.defaultFamily ();
227 #elif defined (Q_WS_X11) || defined (Q_WS_WIN) 228 QString default_family =
"Courier New";
229 #elif defined (Q_WS_MAC) 230 QString default_family =
"Courier";
232 QString default_family =
"courier";
236 #if defined (Q_OS_WIN32) 237 QString custom_editor =
"notepad++ -n%l %f";
239 QString custom_editor =
"emacs +%l %f";
243 settings_text.replace (
"__default_custom_editor__", custom_editor);
244 settings_text.replace (
"__default_font__", default_family);
245 settings_text.replace (
"__default_font_size__",
"10");
249 if (! user_settings.open (QIODevice::WriteOnly))
252 QTextStream out (&user_settings);
254 out << settings_text;
256 user_settings.close ();
270 &&
m_settings->status () == QSettings::NoError))
272 QString msg = QString (QT_TR_NOOP (
273 "The settings file\n%1\n" 274 "does not exist and can not be created.\n" 275 "Make sure you have read and write permissions to\n%2\n\n" 276 "Octave GUI must be closed now."));
277 QMessageBox::critical (
nullptr, QString (QT_TR_NOOP (
"Octave Critical Error")),
284 const QString& new_key)
288 QVariant preference =
m_settings->value (old_key);
306 QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
308 if (
m_settings->value (
"useProxyServer",
false).toBool ())
310 QString proxyTypeString =
m_settings->value (
"proxyType").toString ();
312 if (proxyTypeString ==
"Socks5Proxy")
313 proxyType = QNetworkProxy::Socks5Proxy;
314 else if (proxyTypeString ==
"HttpProxy")
315 proxyType = QNetworkProxy::HttpProxy;
320 proxy.setType (proxyType);
321 proxy.setHostName (
m_settings->value (
"proxyHostName").toString ());
322 proxy.setPort (
m_settings->value (
"proxyPort",80).toInt ());
323 proxy.setUser (
m_settings->value (
"proxyUserName").toString ());
324 proxy.setPassword (
m_settings->value (
"proxyPassword").toString ());
326 QNetworkProxy::setApplicationProxy (proxy);
337 return QIcon::fromTheme (icon_name,
338 QIcon (
":/actions/icons/" + icon_name +
".png"));
340 return QIcon::fromTheme (icon_name);
347 QList<int> all_mibs = QTextCodec::availableMibs ();
348 QStringList all_codecs;
349 foreach (
int mib, all_mibs)
351 QTextCodec *
c = QTextCodec::codecForMib (mib);
352 all_codecs <<
c->name ().toUpper ();
354 all_codecs.removeDuplicates ();
358 #if defined (Q_OS_WIN32) 359 QString def_enc =
"SYSTEM";
361 QString def_enc =
"UTF-8";
365 QString enc = current;
368 enc =
m_settings->value (
"editor/default_encoding",def_enc).toString ();
374 foreach (QString
c, all_codecs)
378 combo->insertSeparator (0);
379 combo->insertItem (0, def_enc);
382 int idx = combo->findText (enc);
384 combo->setCurrentIndex (idx);
386 combo->setCurrentIndex (0);
388 combo->setMaxVisibleItems (12);
QSettings * m_default_settings
static QStringList color_names(void)
static QString default_qt_settings_file(void)
For example cd octave end example noindent changes the current working directory to file
static void config_translators(QTranslator *, QTranslator *, QTranslator *)
static QList< QColor > terminal_default_colors(void)
std::string oct_etc_dir(void)
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 of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the system(carriage-return linefeed on Windows). The default when no mode is specified is binary. Additionally
void error(const char *fmt,...)
QString fromStdString(const std::string &s)
bool do_is_first_run(void) const
QSettings * do_get_settings(void) const
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 of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
QString do_get_settings_directory(void)
std::string dir_sep_str(void)
static std::string getenv(const std::string &name)
static QList< QColor > varedit_default_colors(void)
void do_reload_settings(void)
std::string oct_locale_dir(void)
QString do_get_settings_file(void)
QString m_settings_directory
static QList< QColor > default_colors(void)
static QList< QColor > storage_class_default_colors(void)
static QStringList storage_class_names(void)
static resource_manager * instance
static QStringList color_names(void)
static QStringList varedit_color_names(void)
void do_combo_encoding(QComboBox *combo, QString current)
static QList< QColor > storage_class_default_colors(void)
static QStringList storage_class_names(void)
static QList< QColor > default_colors(void)
static QSettings * get_settings(void)
static bool instance_ok(void)
QIcon do_icon(const QString &icon, bool fallback)
QSettings * do_get_default_settings(void) const
void do_update_network_settings(void)
static QStringList terminal_color_names(void)
static QString get_gui_translation_dir(void)
bool do_update_settings_key(const QString &new_key, const QString &old_key)
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_set_settings(const QString &file)