31 #include <QNetworkProxy>
32 #include <QLibraryInfo>
33 #include <QMessageBox>
57 return QString::fromStdString (dsf);
61 : settings_directory (), settings_file (), settings (0),
64 QDesktopServices desktopServices;
67 = desktopServices.storageLocation (QDesktopServices::HomeLocation);
74 QSettings::IniFormat);
90 return QString::fromStdString (dldir);
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";
206 settings_text.replace (
"__default_font__", default_family);
207 settings_text.replace (
"__default_font_size__",
"10");
211 if (! user_settings.open (QIODevice::WriteOnly))
214 QTextStream out (&user_settings);
216 out << settings_text;
218 user_settings.close ();
228 settings =
new QSettings (file, QSettings::IniFormat);
233 &&
settings->status () == QSettings::NoError))
235 QString msg = QString (QT_TR_NOOP (
"The settings file\n%1\n"
236 "does not exist and can not be created.\n"
237 "Make sure you have read and write permissions to\n%2\n\n"
238 "Octave GUI must be closed now."));
239 QMessageBox::critical (0, QString (QT_TR_NOOP (
"Octave Critical Error")),
256 QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
258 if (
settings->value (
"useProxyServer",
false).toBool ())
260 QString proxyTypeString =
settings->value (
"proxyType").toString ();
262 if (proxyTypeString ==
"Socks5Proxy")
263 proxyType = QNetworkProxy::Socks5Proxy;
264 else if (proxyTypeString ==
"HttpProxy")
265 proxyType = QNetworkProxy::HttpProxy;
270 proxy.setType (proxyType);
271 proxy.setHostName (
settings->value (
"proxyHostName").toString ());
272 proxy.setPort (
settings->value (
"proxyPort",80).toInt ());
273 proxy.setUser (
settings->value (
"proxyUserName").toString ());
274 proxy.setPassword (
settings->value (
"proxyPassword").toString ());
276 QNetworkProxy::setApplicationProxy (proxy);