diff --git a/Changelog b/Changelog index 45110f761..c63268c62 100644 --- a/Changelog +++ b/Changelog @@ -8,6 +8,7 @@ - FEATURE: User can choose to apply transfer limits on LAN too - FEATURE: User can choose to include the protocol overhead in transfer limits - FEATURE: Torrents can be automatically rechecked on completion + - COSMETIC: Improved style management * Mon Jan 18 2010 - Christophe Dumez - v2.1.0 - FEATURE: Graphical User Interface can be disabled at compilation time (headless running) diff --git a/src/main.cpp b/src/main.cpp index 28869f6f1..85e8a9568 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -35,17 +35,9 @@ #ifndef DISABLE_GUI #include #include +#include #include -#include #include "qgnomelook.h" -#include -#include -#ifdef Q_WS_WIN -#include -#endif -#ifdef Q_WS_MAC -#include -#endif #include "GUI.h" #include "ico.h" #else @@ -162,36 +154,14 @@ void sigabrtHandler(int) { #endif #ifndef DISABLE_GUI -void useStyle(QApplication *app, int style){ - switch(style) { - case 1: - app->setStyle(new QPlastiqueStyle()); - break; - case 2: +void useStyle(QApplication *app, QString style){ + if(style != "default") { + QApplication::setStyle(QStyleFactory::create(style)); + } + if(app->style()->objectName() == "cleanlooks") { + // Force our own cleanlooks style + qDebug("Forcing our own cleanlooks style"); app->setStyle(new QGnomeLookStyle()); - break; - case 3: - app->setStyle(new QMotifStyle()); - break; - case 4: - app->setStyle(new QCDEStyle()); - break; -#ifdef Q_WS_MAC - case 5: - app->setStyle(new QMacStyle()); - break; -#endif -#ifdef Q_WS_WIN - case 6: - app->setStyle(new QWindowsXPStyle()); - break; -#endif - default: - if(app->style()->objectName() == "cleanlooks") { - // Force our own cleanlooks style - qDebug("Forcing our own cleanlooks style"); - app->setStyle(new QGnomeLookStyle()); - } } } #endif @@ -279,7 +249,8 @@ int main(int argc, char *argv[]){ app = new QApplication(argc, argv); #endif #ifndef DISABLE_GUI - useStyle(app, settings.value("Preferences/General/Style", 0).toInt()); + Preferences::setDefaultStyle(app->style()->objectName()); + useStyle(app, settings.value("Preferences/General/Style", "default").toString()); app->setStyleSheet("QStatusBar::item { border-width: 0; }"); QSplashScreen *splash = 0; if(!no_splash) { diff --git a/src/options_imp.cpp b/src/options_imp.cpp index 8ed8b6bd3..5b8937f55 100644 --- a/src/options_imp.cpp +++ b/src/options_imp.cpp @@ -34,20 +34,11 @@ #include #include #include -#include #include "qgnomelook.h" -#include -#include #include #include #include -#ifdef Q_WS_WIN -#include -#endif - -#ifdef Q_WS_MAC -#include -#endif +#include #include #include @@ -72,12 +63,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){ } } connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(applySettings(QAbstractButton*))); -#ifdef Q_WS_WIN - comboStyle->addItem("Windows XP Style (Windows Only)"); -#endif -#ifdef Q_WS_MAC - comboStyle->addItem("MacOS Style (MacOS Only)"); -#endif + comboStyle->addItems(QStyleFactory::keys()); // Languages supported comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/united_kingdom.png"))), QString::fromUtf8("English")); locales << "en_GB"; @@ -304,31 +290,16 @@ void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous tabOption->setCurrentIndex(tabSelection->row(current)); } -void options_imp::useStyle(){ - int style = getStyle(); - switch(style) { - case 1: - QApplication::setStyle(new QPlastiqueStyle()); - break; - case 2: +void options_imp::useStyle() { + if(comboStyle->currentIndex() == 0) { + QApplication::setStyle(Preferences::getDefaultStyle()); + } else { + QApplication::setStyle(QStyleFactory::create(comboStyle->itemText(comboStyle->currentIndex()))); + } + if(QApplication::style()->objectName() == "cleanlooks") { + // Force our own cleanlooks style + qDebug("Forcing our own cleanlooks style"); QApplication::setStyle(new QGnomeLookStyle()); - break; - case 3: - QApplication::setStyle(new QMotifStyle()); - break; - case 4: - QApplication::setStyle(new QCDEStyle()); - break; -#ifdef Q_WS_MAC - case 5: - QApplication::setStyle(new QMacStyle()); - break; -#endif -#ifdef Q_WS_WIN - case 6: - QApplication::setStyle(new QWindowsXPStyle()); - break; -#endif } } @@ -567,14 +538,19 @@ int options_imp::getHTTPProxyType() const { } } -int options_imp::getStyle() const{ - return comboStyle->currentIndex(); +QString options_imp::getStyle() const{ + if(comboStyle->currentIndex() == 0) + return "default"; + else + return comboStyle->itemText(comboStyle->currentIndex()); } -void options_imp::setStyle(int style){ - if(style >= comboStyle->count() || style < 0) - style = 0; - comboStyle->setCurrentIndex(style); +void options_imp::setStyle(QString style) { + if(style != "default") { + int index = comboStyle->findText(style); + if(index > 0) + comboStyle->setCurrentIndex(index); + } } bool options_imp::isHTTPProxyAuthEnabled() const{ diff --git a/src/options_imp.h b/src/options_imp.h index a187e72ba..a8bed4e8c 100644 --- a/src/options_imp.h +++ b/src/options_imp.h @@ -65,7 +65,7 @@ protected: void loadOptions(); // General options QString getLocale() const; - int getStyle() const; + QString getStyle() const; bool confirmOnExit() const; bool speedInTitleBar() const; bool systrayIntegration() const; @@ -154,7 +154,7 @@ protected slots: void enableDHTPortSettings(bool checked); void enableQueueingSystem(bool checked); void enableSpoofingSettings(int index); - void setStyle(int style); + void setStyle(QString style); void on_buttonBox_accepted(); void closeEvent(QCloseEvent *e); void on_buttonBox_rejected(); diff --git a/src/preferences.h b/src/preferences.h index 78bcfdff9..94d90858f 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -53,9 +53,19 @@ public: settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale); } - static int getStyle() { + static QString getDefaultStyle() { QSettings settings("qBittorrent", "qBittorrent"); - return settings.value(QString::fromUtf8("Preferences/General/Style"), 0).toInt(); + return settings.value(QString::fromUtf8("Preferences/General/DefaultStyle"), "").toString(); + } + + static void setDefaultStyle(QString style) { + QSettings settings("qBittorrent", "qBittorrent"); + settings.setValue(QString::fromUtf8("Preferences/General/DefaultStyle"), style); + } + + static QString getStyle() { + QSettings settings("qBittorrent", "qBittorrent"); + return settings.value(QString::fromUtf8("Preferences/General/Style"), "default").toString(); } static bool confirmOnExit() { diff --git a/src/ui/options.ui b/src/ui/options.ui index c250fc164..b06e48e13 100644 --- a/src/ui/options.ui +++ b/src/ui/options.ui @@ -336,26 +336,6 @@ System default - - - Plastique style (KDE like) - - - - - Cleanlooks style (Gnome like) - - - - - Motif style (Unix like) - - - - - CDE style (Common Desktop Environment like) - -