31 #include <QNetworkProxy>
32 #include <QLibraryInfo>
33 #include <QMessageBox>
61 : settings_directory (), settings_file (), settings (0),
64 QDesktopServices desktopServices;
67 = desktopServices.storageLocation (QDesktopServices::HomeLocation);
74 QSettings::IniFormat);
101 = QLibraryInfo::location (QLibraryInfo::TranslationsPath);
103 QString language =
"SYSTEM";
110 language = settings->value (
"language",
"SYSTEM").toString ();
113 if (language ==
"SYSTEM")
114 language = QLocale::system ().name ();
117 loaded = qt_tr->load (
"qt_" + language, qt_trans_dir);
120 qt_tr->load (
"qt_" + language.toLower (), qt_trans_dir);
123 loaded = qsci_tr->load (
"qscintilla_" + language, qt_trans_dir);
126 qsci_tr->load (
"qscintilla_" + language.toLower (), qt_trans_dir);
147 ::error (
"unable to create resource_manager object!");
187 if (!qt_settings.open (QFile::ReadOnly))
190 QTextStream in (&qt_settings);
191 QString settings_text = in.readAll ();
192 qt_settings.close ();
195 #if defined (HAVE_QFONT_MONOSPACE)
197 fixed_font.setStyleHint (QFont::Monospace);
198 QString default_family = fixed_font.defaultFamily ();
199 #elif defined (Q_WS_X11) || defined (Q_WS_WIN)
200 QString default_family =
"Courier New";
201 #elif defined (Q_WS_MAC)
202 QString default_family =
"Courier";
204 QString default_family =
"courier";
208 #if defined (Q_OS_WIN32)
209 QString custom_editor =
"notepad++ -n%l %f";
211 QString custom_editor =
"emacs +%l %f";
215 settings_text.replace (
"__default_custom_editor__", custom_editor);
216 settings_text.replace (
"__default_font__", default_family);
217 settings_text.replace (
"__default_font_size__",
"10");
221 if (! user_settings.open (QIODevice::WriteOnly))
224 QTextStream out (&user_settings);
226 out << settings_text;
228 user_settings.close ();
238 settings =
new QSettings (file, QSettings::IniFormat);
241 && QFile::exists (
settings->fileName ())
243 &&
settings->status () == QSettings::NoError))
245 QString msg = QString (QT_TR_NOOP (
246 "The settings file\n%1\n"
247 "does not exist and can not be created.\n"
248 "Make sure you have read and write permissions to\n%2\n\n"
249 "Octave GUI must be closed now."));
250 QMessageBox::critical (0, QString (QT_TR_NOOP (
"Octave Critical Error")),
267 QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
269 if (
settings->value (
"useProxyServer",
false).toBool ())
271 QString proxyTypeString =
settings->value (
"proxyType").toString ();
273 if (proxyTypeString ==
"Socks5Proxy")
274 proxyType = QNetworkProxy::Socks5Proxy;
275 else if (proxyTypeString ==
"HttpProxy")
276 proxyType = QNetworkProxy::HttpProxy;
281 proxy.setType (proxyType);
282 proxy.setHostName (
settings->value (
"proxyHostName").toString ());
283 proxy.setPort (
settings->value (
"proxyPort",80).toInt ());
284 proxy.setUser (
settings->value (
"proxyUserName").toString ());
285 proxy.setPassword (
settings->value (
"proxyPassword").toString ());
287 QNetworkProxy::setApplicationProxy (proxy);
323 return QIcon::fromTheme (icon_name,
324 QIcon (
":/actions/icons/" + icon_name +
".png"));
326 return QIcon::fromTheme (icon_name);
static QStringList storage_class_names(void)
static QString default_qt_settings_file(void)
bool do_is_first_run(void) const
static void cleanup_instance(void)
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 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
static std::string getenv(const std::string &name)
QString settings_directory
QString do_get_settings_directory(void)
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
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)
static std::string dir_sep_str(void)
std::string Voct_locale_dir
void do_update_network_settings(void)