void SettingsDialog::FillGeneralTab() { m_propertyMapper->AddMapping("TorrentTracker", "enabled", SettingsPropertyMapper::BOOL, trackerGroupBox, SettingsPropertyMapper::CHECKABLE_GROUPBOX, false); m_propertyMapper->AddMapping("TorrentTracker", "port", SettingsPropertyMapper::INT, trackerPortEdit, SettingsPropertyMapper::LINE_EDIT, 6996); StyleEngene* styleEngine = StyleEngene::getInstance(); QList<StyleInfo> styleInfos = styleEngine->getAvaliableStyles(); styleComboBox->clear(); for(int i = 0; i < styleInfos.size(); i++) { styleComboBox->addItem(styleInfos[i].DisplayName, styleInfos[i].InternalName); } m_propertyMapper->AddMapping("System", "Style", SettingsPropertyMapper::INT, styleComboBox, SettingsPropertyMapper::COMBOBOX, "CuteTorrent", NULL, NULL, ValueSetters::StyleValueSetter ,ValueGetters::StyleValueGetter); QString curLoc = Application::currentLocale(); int current = 0; QStringList availableLanguages = Application::availableLanguages(); for (int i = 0; i < availableLanguages.size(); i++) { QLocale language = QLocale(availableLanguages[i]); localeComboBox->addItem(QLocale::languageToString(language.language()), availableLanguages[i]); } m_propertyMapper->AddMapping("System", "Lang", SettingsPropertyMapper::INT, localeComboBox, SettingsPropertyMapper::COMBOBOX, "en_US", NULL, NULL, ValueSetters::LanguageValueSetter, ValueGetters::LanguageValueGetter); m_propertyMapper->AddMapping("Notifications", "use_notification_sys", SettingsPropertyMapper::BOOL, useNotificationsCheckBox, SettingsPropertyMapper::CHECKABLE_GROUPBOX, true); m_propertyMapper->AddMapping("Notifications", "report_tracker_errors", SettingsPropertyMapper::BOOL, showTrackerErrorsCheckBox, SettingsPropertyMapper::CHECKBOX); m_propertyMapper->AddMapping("Notifications", "report_disk_errors", SettingsPropertyMapper::BOOL, showDiskErrorsCheckBox, SettingsPropertyMapper::CHECKBOX); m_propertyMapper->AddMapping("Notifications", "report_rss_errors", SettingsPropertyMapper::BOOL, showRssErrorsCheckBox, SettingsPropertyMapper::CHECKBOX); m_propertyMapper->AddMapping("WatchDir", "enabled", SettingsPropertyMapper::BOOL, watchDirEnabledCheckbox, SettingsPropertyMapper::CHECKABLE_GROUPBOX, false); m_propertyMapper->AddMapping("WatchDir", "dir_to_watch", SettingsPropertyMapper::STRING, watchDirPathEdit, SettingsPropertyMapper::LINE_EDIT, ""); m_propertyMapper->AddMapping("WatchDir", "show_doalog_on_new_torrent", SettingsPropertyMapper::BOOL, showDialogRadioButton, SettingsPropertyMapper::RADIOBUTTON, false); m_propertyMapper->AddMapping("WatchDir", "use_torrent_filtering", SettingsPropertyMapper::BOOL, usetTorrentFilteringRadioButton, SettingsPropertyMapper::RADIOBUTTON, false); m_propertyMapper->AddMapping("WatchDir", "use_static_save_path", SettingsPropertyMapper::BOOL, useStaticPathRadioButton, SettingsPropertyMapper::RADIOBUTTON, false); m_propertyMapper->AddMapping("WatchDir", "use_static_save_path", SettingsPropertyMapper::BOOL, useStaticPathRadioButton, SettingsPropertyMapper::RADIOBUTTON, false); m_propertyMapper->AddMapping("WatchDir", "static_save_path", SettingsPropertyMapper::STRING, staticSavePathEdit, SettingsPropertyMapper::LINE_EDIT, ""); m_propertyMapper->AddMapping("System", "open_magent_links", SettingsPropertyMapper::BOOL, magnetAssociationCheckBox, SettingsPropertyMapper::CHECKBOX, QVariant(), NULL, NULL, ValueSetters::MagnetAssociationValueSetter, ValueGetters::MagnetAssociationValueGetter); m_propertyMapper->AddMapping("System", "open_torrent_files", SettingsPropertyMapper::BOOL, asociationCheckBox, SettingsPropertyMapper::CHECKBOX, QVariant(), NULL, NULL, ValueSetters::TorrentAssociationValueSetter, ValueGetters::TorrentAssociationValueGetter); m_propertyMapper->AddMapping("System", "run_on_boot", SettingsPropertyMapper::BOOL, runOnbootCheckBox, SettingsPropertyMapper::CHECKBOX, QVariant(), NULL, NULL, ValueSetters::RunOnBootValueSetter, ValueGetters::RunOnBootValueGetter); m_propertyMapper->AddMapping("Search", "script_debuging_enabled", SettingsPropertyMapper::BOOL, scriptDebugingCheckBox, SettingsPropertyMapper::CHECKBOX, false); //OS_SPECIFICK//// #ifdef Q_WS_WIN m_propertyMapper->AddMapping("System", "run_on_boot_minimaized", SettingsPropertyMapper::BOOL, startMinimizedCheckBox, SettingsPropertyMapper::CHECKBOX, QVariant(), NULL, NULL, ValueSetters::RunOnBootMinimizedValueSetter, ValueGetters::RunOnBootMinimizedValueGetter); m_propertyMapper->AddMapping("System", "win_explorer_integration_enabled", SettingsPropertyMapper::BOOL, winShelItegrationCheckBox, SettingsPropertyMapper::CHECKBOX, QVariant(), NULL, NULL, ValueSetters::WindowsShellValueSetter, ValueGetters::WindowsShellValueGetter); #endif #ifdef Q_WS_X11 winShelItegrationCheckBox->setVisible(false); startMinimizedCheckBox->setVisible(false); #endif //OS_SPECIFICK//// }
QVariant ValueGetters::StyleValueGetter(QString group, QString name, QVariant defaultValue) { StyleEngene* styleEngine = StyleEngene::getInstance(); QList<StyleInfo> styleInfos = styleEngine->getAvaliableStyles(); QString currentStyle = QApplicationSettings::getInstance()->valueString(group, name, defaultValue.toString()); for (int i = 0; i < styleInfos.size(); i++) { if (styleInfos[i].InternalName == currentStyle) { return i; } } return -1; }
void ValueSetters::StyleValueSetter(QString group, QString name, QVariant value) { int styleIndex = value.toInt(); StyleEngene* styleEngene = StyleEngene::getInstance(); QList<StyleInfo> styleInfos = styleEngene->getAvaliableStyles(); if (styleIndex < styleInfos.size() && styleIndex > -1) { QString currentStyle = styleInfos[styleIndex].InternalName; QApplicationSettings::getInstance()->setValue(group, name, currentStyle); if (styleEngene->getCuurentStyle().InternalName.compare(currentStyle) != 0) { styleEngene->setStyle(currentStyle); } } else { qCritical() << "Style index out of bounds"; } }
void SettingsDialog::setupWindowIcons() { StyleEngene* style = StyleEngene::getInstance(); BaseWindow::setupWindowIcons(); RunningLabel->setPixmap(style->getIcon("active").pixmap(32, 32)); listWidget->item(0)->setIcon(style->getIcon("settings_torrent")); listWidget->item(1)->setIcon(style->getIcon("settings_limits")); listWidget->item(2)->setIcon(style->getIcon("settings_network")); listWidget->item(3)->setIcon(style->getIcon("settings_hdd")); listWidget->item(4)->setIcon(style->getIcon("settings_filter")); listWidget->item(5)->setIcon(style->getIcon("settings_dt")); listWidget->item(6)->setIcon(style->getIcon("settings_scheduler")); listWidget->item(7)->setIcon(style->getIcon("settings_web_controll")); listWidget->item(8)->setIcon(style->getIcon("settings_rss")); listWidget->item(9)->setIcon(style->getIcon("settings_hotkeys")); QToolButton* prevMonthBtn = calendarWidget->findChild<QToolButton*> ("qt_calendar_prevmonth"); if(prevMonthBtn != NULL) { prevMonthBtn->setIcon(style->getIcon("calendar_prev")); } QToolButton* nextMonthBtn = calendarWidget->findChild<QToolButton*> ("qt_calendar_nextmonth"); if(nextMonthBtn != NULL) { nextMonthBtn->setIcon(style->getIcon("calendar_next")); } }