2013-06-27 19:57:23 +02:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QProcess>
|
2013-07-02 18:57:04 +02:00
|
|
|
#include <QNetworkProxy>
|
2013-07-20 21:11:52 +02:00
|
|
|
#include <QColorDialog>
|
2013-06-27 19:57:23 +02:00
|
|
|
|
2013-06-14 22:15:37 +02:00
|
|
|
#include "gui/formsettings.h"
|
2013-08-05 21:31:41 +02:00
|
|
|
#include "gui/iconthemefactory.h"
|
2013-09-20 18:18:49 +02:00
|
|
|
#include "gui/skinfactory.h"
|
2013-06-17 20:17:13 +02:00
|
|
|
#include "gui/systemtrayicon.h"
|
2013-06-20 18:16:23 +02:00
|
|
|
#include "gui/formmain.h"
|
2013-07-30 18:54:36 +02:00
|
|
|
#include "gui/webbrowser.h"
|
2013-06-15 19:48:56 +02:00
|
|
|
#include "core/settings.h"
|
2013-06-17 20:17:13 +02:00
|
|
|
#include "core/defs.h"
|
2013-06-27 19:57:23 +02:00
|
|
|
#include "core/localization.h"
|
2013-06-24 16:18:13 +02:00
|
|
|
#include "core/systemfactory.h"
|
2013-06-30 15:22:44 +02:00
|
|
|
#include "core/dynamicshortcuts.h"
|
2013-07-18 17:44:23 +02:00
|
|
|
#include "core/webbrowsernetworkaccessmanager.h"
|
2013-06-14 22:15:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormSettings) {
|
|
|
|
m_ui->setupUi(this);
|
2013-06-15 19:48:56 +02:00
|
|
|
|
2013-06-26 19:04:38 +02:00
|
|
|
// Set flags and attributes.
|
2013-06-15 19:48:56 +02:00
|
|
|
setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog);
|
2013-08-05 21:31:41 +02:00
|
|
|
setWindowIcon(IconThemeFactory::getInstance()->fromTheme("preferences-system"));
|
2013-06-15 19:48:56 +02:00
|
|
|
|
2013-06-27 19:57:23 +02:00
|
|
|
// Setup behavior.
|
|
|
|
m_ui->m_treeLanguages->setColumnCount(5);
|
|
|
|
m_ui->m_treeLanguages->setHeaderHidden(false);
|
2013-08-30 17:40:17 +02:00
|
|
|
|
|
|
|
#if QT_VERSION >= 0x050000
|
2013-09-20 18:18:49 +02:00
|
|
|
// Setup languages.
|
2013-06-27 19:57:23 +02:00
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
|
2013-09-20 18:18:49 +02:00
|
|
|
|
|
|
|
// Setup skins.
|
|
|
|
m_ui->m_treeSkins->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
|
2013-08-30 17:40:17 +02:00
|
|
|
#else
|
2013-09-20 18:18:49 +02:00
|
|
|
// Setup languages.
|
2013-08-30 17:40:17 +02:00
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(0, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(2, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(3, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeLanguages->header()->setResizeMode(4, QHeaderView::ResizeToContents);
|
2013-09-20 18:18:49 +02:00
|
|
|
|
|
|
|
// Setup skins.
|
|
|
|
m_ui->m_treeSkins->header()->setResizeMode(0, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setResizeMode(1, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setResizeMode(2, QHeaderView::ResizeToContents);
|
|
|
|
m_ui->m_treeSkins->header()->setResizeMode(3, QHeaderView::ResizeToContents);
|
2013-08-30 17:40:17 +02:00
|
|
|
#endif
|
|
|
|
|
2013-06-27 19:57:23 +02:00
|
|
|
m_ui->m_treeLanguages->setHeaderLabels(QStringList()
|
|
|
|
<< tr("Language")
|
|
|
|
<< tr("Code")
|
|
|
|
<< tr("Version")
|
|
|
|
<< tr("Author")
|
|
|
|
<< tr("Email"));
|
|
|
|
|
2013-09-20 18:18:49 +02:00
|
|
|
m_ui->m_treeSkins->setHeaderLabels(QStringList()
|
|
|
|
<< tr("Name")
|
|
|
|
<< tr("Version")
|
|
|
|
<< tr("Author")
|
|
|
|
<< tr("Email"));
|
|
|
|
|
2013-06-15 19:48:56 +02:00
|
|
|
// Establish needed connections.
|
2013-09-20 18:18:49 +02:00
|
|
|
connect(m_ui->m_buttonBox, SIGNAL(accepted()),
|
|
|
|
this, SLOT(saveSettings()));
|
2013-08-30 17:40:17 +02:00
|
|
|
connect(m_ui->m_cmbProxyType, SIGNAL(currentIndexChanged(int)),
|
|
|
|
this, SLOT(onProxyTypeChanged(int)));
|
|
|
|
connect(m_ui->m_checkShowPassword, SIGNAL(stateChanged(int)),
|
|
|
|
this, SLOT(displayProxyPassword(int)));
|
|
|
|
connect(m_ui->m_btnBrowserProgressColor, SIGNAL(clicked()),
|
|
|
|
this, SLOT(changeBrowserProgressColor()));
|
2013-06-15 19:48:56 +02:00
|
|
|
|
|
|
|
// Load all settings.
|
2013-06-24 16:18:13 +02:00
|
|
|
loadGeneral();
|
2013-06-30 15:22:44 +02:00
|
|
|
loadShortcuts();
|
2013-06-15 19:48:56 +02:00
|
|
|
loadInterface();
|
2013-07-02 18:57:04 +02:00
|
|
|
loadProxy();
|
2013-07-24 19:06:09 +02:00
|
|
|
loadBrowser();
|
2013-06-27 19:57:23 +02:00
|
|
|
loadLanguage();
|
2013-06-14 22:15:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FormSettings::~FormSettings() {
|
|
|
|
delete m_ui;
|
|
|
|
}
|
2013-06-15 19:48:56 +02:00
|
|
|
|
2013-07-20 21:11:52 +02:00
|
|
|
void FormSettings::changeBrowserProgressColor() {
|
|
|
|
QColorDialog color_dialog(m_initialSettings.m_webBrowserProgress, this);
|
|
|
|
color_dialog.setWindowTitle(tr("Select color for web browser progress bar"));
|
|
|
|
color_dialog.setOption(QColorDialog::ShowAlphaChannel);
|
|
|
|
color_dialog.exec();
|
|
|
|
|
|
|
|
m_initialSettings.m_webBrowserProgress = color_dialog.selectedColor();
|
|
|
|
}
|
|
|
|
|
2013-07-17 20:42:42 +02:00
|
|
|
void FormSettings::displayProxyPassword(int state) {
|
|
|
|
if (state == Qt::Checked) {
|
|
|
|
m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::Normal);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_ui->m_txtProxyPassword->setEchoMode(QLineEdit::PasswordEchoOnEdit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-20 18:18:49 +02:00
|
|
|
bool FormSettings::doSaveCheck() {
|
|
|
|
bool everything_ok = true;
|
|
|
|
QString resulting_information;
|
|
|
|
|
|
|
|
everything_ok &= m_ui->m_shortcuts->areShortcutsUnique();
|
|
|
|
|
|
|
|
if (!m_ui->m_shortcuts->areShortcutsUnique()) {
|
|
|
|
resulting_information = resulting_information.append(tr("Some keyboard shortcuts are not unique.\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!everything_ok) {
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
tr("Cannot save settings"),
|
|
|
|
resulting_information);
|
|
|
|
}
|
|
|
|
|
|
|
|
return everything_ok;
|
|
|
|
}
|
|
|
|
|
2013-06-15 19:48:56 +02:00
|
|
|
void FormSettings::saveSettings() {
|
2013-09-20 18:18:49 +02:00
|
|
|
// Make sure everything is saveable.
|
|
|
|
if (!doSaveCheck()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-24 16:18:13 +02:00
|
|
|
// Save all settings.
|
|
|
|
saveGeneral();
|
2013-06-30 15:22:44 +02:00
|
|
|
saveShortcuts();
|
2013-06-15 19:48:56 +02:00
|
|
|
saveInterface();
|
2013-07-02 18:57:04 +02:00
|
|
|
saveProxy();
|
2013-07-24 19:06:09 +02:00
|
|
|
saveBrowser();
|
2013-06-27 19:57:23 +02:00
|
|
|
saveLanguage();
|
2013-06-30 19:02:24 +02:00
|
|
|
|
|
|
|
Settings::getInstance()->checkSettings();
|
2013-09-20 18:18:49 +02:00
|
|
|
|
|
|
|
accept();
|
2013-06-27 19:57:23 +02:00
|
|
|
}
|
|
|
|
|
2013-07-02 18:57:04 +02:00
|
|
|
void FormSettings::onProxyTypeChanged(int index) {
|
|
|
|
QNetworkProxy::ProxyType selected_type = static_cast<QNetworkProxy::ProxyType>(m_ui->m_cmbProxyType->itemData(index).toInt());
|
|
|
|
bool is_proxy_selected = selected_type != QNetworkProxy::NoProxy;
|
|
|
|
|
2013-07-07 15:17:25 +02:00
|
|
|
m_ui->m_txtProxyHost->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_txtProxyPassword->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_txtProxyUsername->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_spinProxyPort->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_checkShowPassword->setEnabled(is_proxy_selected);
|
2013-07-23 20:42:06 +02:00
|
|
|
m_ui->m_lblProxyHost->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_lblProxyInfo->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_lblProxyPassword->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_lblProxyPort->setEnabled(is_proxy_selected);
|
|
|
|
m_ui->m_lblProxyUsername->setEnabled(is_proxy_selected);
|
2013-07-02 18:57:04 +02:00
|
|
|
}
|
|
|
|
|
2013-07-24 19:06:09 +02:00
|
|
|
void FormSettings::loadBrowser() {
|
2013-08-30 17:40:17 +02:00
|
|
|
Settings *settings = Settings::getInstance();
|
|
|
|
|
2013-07-24 19:06:09 +02:00
|
|
|
// Load settings of web browser GUI.
|
2013-08-30 17:40:17 +02:00
|
|
|
m_initialSettings.m_webBrowserProgress = settings->value(APP_CFG_BROWSER,
|
|
|
|
"browser_progress_color",
|
|
|
|
QColor(0, 255, 0, 100)).value<QColor>();
|
|
|
|
m_ui->m_checkBrowserProgressColor->setChecked(settings->value(APP_CFG_BROWSER,
|
|
|
|
"browser_colored_progress_enabled",
|
|
|
|
true).toBool());
|
|
|
|
m_ui->m_checkMouseGestures->setChecked(settings->value(APP_CFG_BROWSER,
|
|
|
|
"gestures_enabled",
|
|
|
|
true).toBool());
|
|
|
|
m_ui->m_checkQueueTabs->setChecked(settings->value(APP_CFG_BROWSER,
|
|
|
|
"queue_tabs",
|
|
|
|
true).toBool());
|
2013-07-24 19:06:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveBrowser() {
|
2013-08-30 17:40:17 +02:00
|
|
|
Settings *settings = Settings::getInstance();
|
|
|
|
|
2013-07-24 19:06:09 +02:00
|
|
|
// Save settings of GUI of web browser.
|
2013-08-30 17:40:17 +02:00
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"browser_progress_color",
|
|
|
|
m_initialSettings.m_webBrowserProgress);
|
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"browser_colored_progress_enabled",
|
|
|
|
m_ui->m_checkBrowserProgressColor->isChecked());
|
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"gestures_enabled",
|
|
|
|
m_ui->m_checkMouseGestures->isChecked());
|
|
|
|
settings->setValue(APP_CFG_BROWSER,
|
|
|
|
"queue_tabs",
|
|
|
|
m_ui->m_checkQueueTabs->isChecked());
|
2013-07-24 19:06:09 +02:00
|
|
|
}
|
|
|
|
|
2013-07-02 18:57:04 +02:00
|
|
|
void FormSettings::loadProxy() {
|
|
|
|
m_ui->m_cmbProxyType->addItem(tr("No proxy"), QNetworkProxy::NoProxy);
|
|
|
|
m_ui->m_cmbProxyType->addItem(tr("Socks5"), QNetworkProxy::Socks5Proxy);
|
|
|
|
m_ui->m_cmbProxyType->addItem(tr("Http"), QNetworkProxy::HttpProxy);
|
2013-07-17 20:42:42 +02:00
|
|
|
|
|
|
|
// Load the settings.
|
|
|
|
QNetworkProxy::ProxyType selected_proxy_type = static_cast<QNetworkProxy::ProxyType>(Settings::getInstance()->value(APP_CFG_PROXY,
|
|
|
|
"proxy_type",
|
|
|
|
QNetworkProxy::NoProxy).toInt());
|
2013-08-30 17:40:17 +02:00
|
|
|
Settings *settings = Settings::getInstance();
|
|
|
|
|
2013-07-17 20:42:42 +02:00
|
|
|
m_ui->m_cmbProxyType->setCurrentIndex(m_ui->m_cmbProxyType->findData(selected_proxy_type));
|
2013-08-30 17:40:17 +02:00
|
|
|
m_ui->m_txtProxyHost->setText(settings->value(APP_CFG_PROXY,
|
|
|
|
"host").toString());
|
|
|
|
m_ui->m_txtProxyUsername->setText(settings->value(APP_CFG_PROXY,
|
|
|
|
"username").toString());
|
|
|
|
m_ui->m_txtProxyPassword->setText(settings->value(APP_CFG_PROXY,
|
|
|
|
"password").toString());
|
|
|
|
m_ui->m_spinProxyPort->setValue(settings->value(APP_CFG_PROXY,
|
|
|
|
"port", 80).toInt());
|
2013-07-02 18:57:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveProxy() {
|
2013-08-30 17:40:17 +02:00
|
|
|
Settings *settings = Settings::getInstance();
|
|
|
|
|
|
|
|
settings->setValue(APP_CFG_PROXY, "proxy_type",
|
|
|
|
m_ui->m_cmbProxyType->itemData(m_ui->m_cmbProxyType->currentIndex()));
|
|
|
|
settings->setValue(APP_CFG_PROXY, "host",
|
|
|
|
m_ui->m_txtProxyHost->text());
|
|
|
|
settings->setValue(APP_CFG_PROXY, "username",
|
|
|
|
m_ui->m_txtProxyUsername->text());
|
|
|
|
settings->setValue(APP_CFG_PROXY, "password",
|
|
|
|
m_ui->m_txtProxyPassword->text());
|
|
|
|
settings->setValue(APP_CFG_PROXY, "port",
|
|
|
|
m_ui->m_spinProxyPort->value());
|
2013-07-18 17:44:23 +02:00
|
|
|
|
|
|
|
// Reload settings for all network access managers.
|
|
|
|
WebBrowser::globalNetworkManager()->loadSettings();
|
2013-07-02 18:57:04 +02:00
|
|
|
}
|
|
|
|
|
2013-06-27 19:57:23 +02:00
|
|
|
void FormSettings::loadLanguage() {
|
|
|
|
QList<Language> languages = Localization::getInstalledLanguages();
|
|
|
|
|
|
|
|
foreach (Language lang, languages) {
|
|
|
|
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->m_treeLanguages);
|
|
|
|
item->setText(0, lang.m_name);
|
|
|
|
item->setText(1, lang.m_code);
|
|
|
|
item->setText(2, lang.m_version);
|
|
|
|
item->setText(3, lang.m_author);
|
|
|
|
item->setText(4, lang.m_email);
|
|
|
|
item->setIcon(0, QIcon(APP_FLAGS_PATH + "/" + lang.m_code + ".png"));
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QTreeWidgetItem*> matching_items = m_ui->m_treeLanguages->findItems(Settings::getInstance()->value(APP_CFG_GEN,
|
|
|
|
"language",
|
|
|
|
"en").toString(),
|
|
|
|
Qt::MatchExactly,
|
|
|
|
1);
|
|
|
|
if (!matching_items.isEmpty()) {
|
|
|
|
m_ui->m_treeLanguages->setCurrentItem(matching_items[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveLanguage() {
|
2013-08-30 17:40:17 +02:00
|
|
|
if (m_ui->m_treeLanguages->currentItem() == NULL) {
|
2013-06-29 15:48:15 +02:00
|
|
|
qDebug("No localizations loaded in settings dialog, so no saving for them.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-30 17:40:17 +02:00
|
|
|
Settings *settings = Settings::getInstance();
|
|
|
|
QString actual_lang = settings->value(APP_CFG_GEN,
|
|
|
|
"language",
|
|
|
|
"en").toString();
|
2013-06-27 19:57:23 +02:00
|
|
|
QString new_lang = m_ui->m_treeLanguages->currentItem()->text(1);
|
|
|
|
|
|
|
|
if (new_lang != actual_lang) {
|
2013-08-30 17:40:17 +02:00
|
|
|
settings->setValue(APP_CFG_GEN, "language", new_lang);
|
2013-06-27 19:57:23 +02:00
|
|
|
|
|
|
|
QMessageBox msg_question(this);
|
2013-07-30 18:54:36 +02:00
|
|
|
msg_question.setText(tr("Language of RSS Guard was changed. Note that changes will take effect on next Qonverter start."));
|
2013-06-27 19:57:23 +02:00
|
|
|
msg_question.setInformativeText(tr("Do you want to restart now?"));
|
|
|
|
msg_question.setWindowTitle(tr("Language changed"));
|
|
|
|
msg_question.setIcon(QMessageBox::Question);
|
|
|
|
msg_question.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
|
|
msg_question.setDefaultButton(QMessageBox::Yes);
|
2013-06-15 19:48:56 +02:00
|
|
|
|
2013-06-27 19:57:23 +02:00
|
|
|
if (msg_question.exec() == QMessageBox::Yes) {
|
|
|
|
if (!QProcess::startDetached(qApp->applicationFilePath())) {
|
|
|
|
QMessageBox::warning(this,
|
|
|
|
tr("Problem with RSS Guard restart"),
|
2013-07-30 18:54:36 +02:00
|
|
|
tr("RSS Guard couldn't be restarted, please restart it manually for changes to take effect."));
|
2013-06-27 19:57:23 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
qApp->quit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|
|
|
|
|
2013-06-30 15:22:44 +02:00
|
|
|
void FormSettings::loadShortcuts() {
|
|
|
|
m_ui->m_shortcuts->populate(FormMain::getInstance()->getActions());
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveShortcuts() {
|
|
|
|
// Update the actual shortcuts of some actions.
|
|
|
|
m_ui->m_shortcuts->updateShortcuts();
|
|
|
|
|
|
|
|
// Save new shortcuts to the settings.
|
|
|
|
DynamicShortcuts::save(FormMain::getInstance()->getActions());
|
|
|
|
}
|
|
|
|
|
2013-06-24 16:18:13 +02:00
|
|
|
void FormSettings::loadGeneral() {
|
|
|
|
// Load auto-start status.
|
|
|
|
SystemFactory::AutoStartStatus autostart_status = SystemFactory::getAutoStartStatus();
|
|
|
|
switch (autostart_status) {
|
|
|
|
case SystemFactory::Enabled:
|
|
|
|
m_ui->m_checkAutostart->setChecked(true);
|
|
|
|
break;
|
|
|
|
case SystemFactory::Disabled:
|
|
|
|
m_ui->m_checkAutostart->setChecked(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
m_ui->m_checkAutostart->setEnabled(false);
|
|
|
|
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text() +
|
|
|
|
tr(" (not supported on this platform)"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveGeneral() {
|
2013-06-24 18:40:13 +02:00
|
|
|
// If auto-start feature is available and user wants
|
|
|
|
// to turn it on, then turn it on.
|
|
|
|
if (SystemFactory::getAutoStartStatus() != SystemFactory::Unavailable) {
|
|
|
|
if (m_ui->m_checkAutostart->isChecked()) {
|
|
|
|
SystemFactory::setAutoStartStatus(SystemFactory::Enabled);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SystemFactory::setAutoStartStatus(SystemFactory::Disabled);
|
|
|
|
}
|
2013-06-24 16:18:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-15 19:48:56 +02:00
|
|
|
void FormSettings::loadInterface() {
|
2013-08-30 17:40:17 +02:00
|
|
|
Settings *settings = Settings::getInstance();
|
|
|
|
|
2013-06-17 20:17:13 +02:00
|
|
|
// Load settings of tray icon.
|
|
|
|
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
2013-08-30 17:40:17 +02:00
|
|
|
m_ui->m_radioTrayOff->setChecked(!settings->value(APP_CFG_GUI,
|
|
|
|
"use_tray_icon",
|
|
|
|
true).toBool());
|
|
|
|
m_ui->m_cmbTrayClose->setCurrentIndex(settings->value(APP_CFG_GUI,
|
|
|
|
"close_win_action",
|
|
|
|
0).toInt());
|
|
|
|
m_ui->m_checkHidden->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"start_hidden",
|
|
|
|
false).toBool());
|
2013-06-17 20:17:13 +02:00
|
|
|
}
|
2013-06-19 21:28:26 +02:00
|
|
|
// Tray icon is not supported on this machine.
|
2013-06-17 20:17:13 +02:00
|
|
|
else {
|
2013-07-30 18:54:36 +02:00
|
|
|
m_ui->m_radioTrayOff->setText(tr("Disable (Tray icon is not available.)"));
|
2013-06-17 20:17:13 +02:00
|
|
|
m_ui->m_radioTrayOff->setChecked(true);
|
|
|
|
m_ui->m_grpTray->setDisabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load settings of icon theme.
|
2013-08-05 21:31:41 +02:00
|
|
|
QString current_theme = IconThemeFactory::getInstance()->getCurrentIconTheme();
|
2013-06-15 19:48:56 +02:00
|
|
|
|
2013-08-05 21:31:41 +02:00
|
|
|
foreach (QString icon_theme_name, IconThemeFactory::getInstance()->getInstalledIconThemes()) {
|
2013-07-02 17:30:33 +02:00
|
|
|
if (icon_theme_name == APP_THEME_SYSTEM) {
|
2013-08-03 07:34:41 +02:00
|
|
|
#if defined(Q_OS_LINUX)
|
2013-06-15 19:48:56 +02:00
|
|
|
m_ui->m_cmbIconTheme->addItem(tr("system icon theme (default)"),
|
2013-08-03 07:34:41 +02:00
|
|
|
APP_THEME_SYSTEM);
|
|
|
|
#else
|
|
|
|
m_ui->m_cmbIconTheme->addItem(tr("no icon theme"),
|
|
|
|
APP_THEME_SYSTEM);
|
|
|
|
#endif
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
m_ui->m_cmbIconTheme->addItem(icon_theme_name,
|
|
|
|
icon_theme_name);
|
|
|
|
}
|
2013-08-03 07:34:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mark active theme.
|
|
|
|
if (current_theme == APP_THEME_SYSTEM) {
|
2013-08-30 17:40:17 +02:00
|
|
|
// Because system icon theme lies at the index 0.
|
2013-08-03 07:34:41 +02:00
|
|
|
m_ui->m_cmbIconTheme->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
else {
|
2013-08-30 17:40:17 +02:00
|
|
|
#if QT_VERSION >= 0x050000
|
2013-08-03 07:34:41 +02:00
|
|
|
m_ui->m_cmbIconTheme->setCurrentText(current_theme);
|
2013-08-30 17:40:17 +02:00
|
|
|
#else
|
|
|
|
int theme_index = m_ui->m_cmbIconTheme->findText(current_theme);
|
|
|
|
if (theme_index >= 0) {
|
|
|
|
m_ui->m_cmbIconTheme->setCurrentIndex(theme_index);
|
|
|
|
}
|
|
|
|
#endif
|
2013-09-20 18:18:49 +02:00
|
|
|
|
|
|
|
// Load skin.
|
|
|
|
QList<Skin> installed_skins = SkinFactory::getInstance()->getInstalledSkins();
|
|
|
|
QString active_skin = SkinFactory::getInstance()->getCurrentSkinName();
|
|
|
|
|
|
|
|
foreach (Skin skin, installed_skins) {
|
|
|
|
QTreeWidgetItem *new_item = new QTreeWidgetItem(QStringList() <<
|
|
|
|
skin.m_visibleName <<
|
|
|
|
skin.m_version <<
|
|
|
|
skin.m_author <<
|
|
|
|
skin.m_email);
|
|
|
|
new_item->setData(0, Qt::UserRole, QVariant::fromValue(skin));
|
|
|
|
|
|
|
|
// Add this skin and mark it as active if its active now.
|
|
|
|
m_ui->m_treeSkins->addTopLevelItem(new_item);
|
|
|
|
|
|
|
|
if (skin.m_baseName == active_skin) {
|
|
|
|
m_ui->m_treeSkins->setCurrentItem(new_item);
|
|
|
|
}
|
|
|
|
}
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|
2013-07-30 18:54:36 +02:00
|
|
|
|
|
|
|
// Load tab settings.
|
2013-08-30 17:40:17 +02:00
|
|
|
m_ui->m_checkCloseTabsMiddleClick->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"tab_close_mid_button",
|
|
|
|
true).toBool());
|
|
|
|
m_ui->m_checkCloseTabsDoubleClick->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"tab_close_double_button",
|
|
|
|
true).toBool());
|
|
|
|
m_ui->m_checkNewTabDoubleClick->setChecked(settings->value(APP_CFG_GUI,
|
|
|
|
"tab_new_double_button",
|
|
|
|
true).toBool());
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void FormSettings::saveInterface() {
|
2013-08-30 17:40:17 +02:00
|
|
|
Settings *settings = Settings::getInstance();
|
|
|
|
|
2013-06-17 20:17:13 +02:00
|
|
|
// Save tray icon.
|
|
|
|
if (SystemTrayIcon::isSystemTrayAvailable()) {
|
2013-08-30 17:40:17 +02:00
|
|
|
settings->setValue(APP_CFG_GUI, "use_tray_icon",
|
|
|
|
m_ui->m_radioTrayOn->isChecked());
|
|
|
|
settings->setValue(APP_CFG_GUI, "close_win_action",
|
|
|
|
m_ui->m_cmbTrayClose->currentIndex());
|
|
|
|
settings->setValue(APP_CFG_GUI, "start_hidden",
|
|
|
|
m_ui->m_checkHidden->isChecked());
|
|
|
|
if (settings->value(APP_CFG_GUI, "use_tray_icon", true).toBool()) {
|
2013-06-19 15:48:33 +02:00
|
|
|
SystemTrayIcon::getInstance()->show();
|
|
|
|
}
|
|
|
|
else {
|
2013-06-20 18:16:23 +02:00
|
|
|
FormMain::getInstance()->display();
|
2013-06-19 15:48:33 +02:00
|
|
|
SystemTrayIcon::deleteInstance();
|
|
|
|
}
|
2013-06-17 20:17:13 +02:00
|
|
|
}
|
|
|
|
|
2013-06-15 19:48:56 +02:00
|
|
|
// Save selected icon theme.
|
2013-07-30 18:54:36 +02:00
|
|
|
QString selected_icon_theme = m_ui->m_cmbIconTheme->itemData(m_ui->m_cmbIconTheme->currentIndex()).toString();
|
2013-08-05 21:31:41 +02:00
|
|
|
IconThemeFactory::getInstance()->setCurrentIconTheme(selected_icon_theme);
|
2013-07-30 18:54:36 +02:00
|
|
|
|
2013-09-20 18:18:49 +02:00
|
|
|
// Save and activate new skin.
|
|
|
|
Skin active_skin = m_ui->m_treeSkins->currentItem()->data(0, Qt::UserRole).value<Skin>();
|
|
|
|
SkinFactory::getInstance()->setCurrentSkinName(active_skin.m_baseName);
|
|
|
|
|
2013-07-30 18:54:36 +02:00
|
|
|
// Save tab settings.
|
2013-08-30 17:40:17 +02:00
|
|
|
settings->setValue(APP_CFG_GUI, "tab_close_mid_button",
|
|
|
|
m_ui->m_checkCloseTabsMiddleClick->isChecked());
|
|
|
|
settings->setValue(APP_CFG_GUI, "tab_close_double_button",
|
|
|
|
m_ui->m_checkCloseTabsDoubleClick->isChecked());
|
|
|
|
settings->setValue(APP_CFG_GUI, "tab_new_double_button",
|
|
|
|
m_ui->m_checkNewTabDoubleClick->isChecked());
|
2013-06-15 19:48:56 +02:00
|
|
|
}
|