Browse Source

- COSMETIC: Improved style management

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
09c48539ad
  1. 1
      Changelog
  2. 43
      src/main.cpp
  3. 68
      src/options_imp.cpp
  4. 4
      src/options_imp.h
  5. 14
      src/preferences.h
  6. 20
      src/ui/options.ui

1
Changelog

@ -8,6 +8,7 @@
- FEATURE: User can choose to apply transfer limits on LAN too - FEATURE: User can choose to apply transfer limits on LAN too
- FEATURE: User can choose to include the protocol overhead in transfer limits - FEATURE: User can choose to include the protocol overhead in transfer limits
- FEATURE: Torrents can be automatically rechecked on completion - FEATURE: Torrents can be automatically rechecked on completion
- COSMETIC: Improved style management
* Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0 * Mon Jan 18 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.0
- FEATURE: Graphical User Interface can be disabled at compilation time (headless running) - FEATURE: Graphical User Interface can be disabled at compilation time (headless running)

43
src/main.cpp

@ -35,17 +35,9 @@
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
#include <QApplication> #include <QApplication>
#include <QMessageBox> #include <QMessageBox>
#include <QStyleFactory>
#include <QSplashScreen> #include <QSplashScreen>
#include <QPlastiqueStyle>
#include "qgnomelook.h" #include "qgnomelook.h"
#include <QMotifStyle>
#include <QCDEStyle>
#ifdef Q_WS_WIN
#include <QWindowsXPStyle>
#endif
#ifdef Q_WS_MAC
#include <QMacStyle>
#endif
#include "GUI.h" #include "GUI.h"
#include "ico.h" #include "ico.h"
#else #else
@ -162,37 +154,15 @@ void sigabrtHandler(int) {
#endif #endif
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
void useStyle(QApplication *app, int style){ void useStyle(QApplication *app, QString style){
switch(style) { if(style != "default") {
case 1: QApplication::setStyle(QStyleFactory::create(style));
app->setStyle(new QPlastiqueStyle()); }
break;
case 2:
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") { if(app->style()->objectName() == "cleanlooks") {
// Force our own cleanlooks style // Force our own cleanlooks style
qDebug("Forcing our own cleanlooks style"); qDebug("Forcing our own cleanlooks style");
app->setStyle(new QGnomeLookStyle()); app->setStyle(new QGnomeLookStyle());
} }
}
} }
#endif #endif
@ -279,7 +249,8 @@ int main(int argc, char *argv[]){
app = new QApplication(argc, argv); app = new QApplication(argc, argv);
#endif #endif
#ifndef DISABLE_GUI #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; }"); app->setStyleSheet("QStatusBar::item { border-width: 0; }");
QSplashScreen *splash = 0; QSplashScreen *splash = 0;
if(!no_splash) { if(!no_splash) {

68
src/options_imp.cpp

@ -34,20 +34,11 @@
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QApplication> #include <QApplication>
#include <QSettings> #include <QSettings>
#include <QPlastiqueStyle>
#include "qgnomelook.h" #include "qgnomelook.h"
#include <QMotifStyle>
#include <QCDEStyle>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QCloseEvent> #include <QCloseEvent>
#include <QDesktopWidget> #include <QDesktopWidget>
#ifdef Q_WS_WIN #include <QStyleFactory>
#include <QWindowsXPStyle>
#endif
#ifdef Q_WS_MAC
#include <QMacStyle>
#endif
#include <time.h> #include <time.h>
#include <stdlib.h> #include <stdlib.h>
@ -72,12 +63,7 @@ options_imp::options_imp(QWidget *parent):QDialog(parent){
} }
} }
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(applySettings(QAbstractButton*))); connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(applySettings(QAbstractButton*)));
#ifdef Q_WS_WIN comboStyle->addItems(QStyleFactory::keys());
comboStyle->addItem("Windows XP Style (Windows Only)");
#endif
#ifdef Q_WS_MAC
comboStyle->addItem("MacOS Style (MacOS Only)");
#endif
// Languages supported // Languages supported
comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/united_kingdom.png"))), QString::fromUtf8("English")); comboI18n->addItem((QIcon(QString::fromUtf8(":/Icons/flags/united_kingdom.png"))), QString::fromUtf8("English"));
locales << "en_GB"; locales << "en_GB";
@ -304,31 +290,16 @@ void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous
tabOption->setCurrentIndex(tabSelection->row(current)); tabOption->setCurrentIndex(tabSelection->row(current));
} }
void options_imp::useStyle(){ void options_imp::useStyle() {
int style = getStyle(); if(comboStyle->currentIndex() == 0) {
switch(style) { QApplication::setStyle(Preferences::getDefaultStyle());
case 1: } else {
QApplication::setStyle(new QPlastiqueStyle()); QApplication::setStyle(QStyleFactory::create(comboStyle->itemText(comboStyle->currentIndex())));
break; }
case 2: if(QApplication::style()->objectName() == "cleanlooks") {
// Force our own cleanlooks style
qDebug("Forcing our own cleanlooks style");
QApplication::setStyle(new QGnomeLookStyle()); 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{ QString options_imp::getStyle() const{
return comboStyle->currentIndex(); if(comboStyle->currentIndex() == 0)
return "default";
else
return comboStyle->itemText(comboStyle->currentIndex());
} }
void options_imp::setStyle(int style){ void options_imp::setStyle(QString style) {
if(style >= comboStyle->count() || style < 0) if(style != "default") {
style = 0; int index = comboStyle->findText(style);
comboStyle->setCurrentIndex(style); if(index > 0)
comboStyle->setCurrentIndex(index);
}
} }
bool options_imp::isHTTPProxyAuthEnabled() const{ bool options_imp::isHTTPProxyAuthEnabled() const{

4
src/options_imp.h

@ -65,7 +65,7 @@ protected:
void loadOptions(); void loadOptions();
// General options // General options
QString getLocale() const; QString getLocale() const;
int getStyle() const; QString getStyle() const;
bool confirmOnExit() const; bool confirmOnExit() const;
bool speedInTitleBar() const; bool speedInTitleBar() const;
bool systrayIntegration() const; bool systrayIntegration() const;
@ -154,7 +154,7 @@ protected slots:
void enableDHTPortSettings(bool checked); void enableDHTPortSettings(bool checked);
void enableQueueingSystem(bool checked); void enableQueueingSystem(bool checked);
void enableSpoofingSettings(int index); void enableSpoofingSettings(int index);
void setStyle(int style); void setStyle(QString style);
void on_buttonBox_accepted(); void on_buttonBox_accepted();
void closeEvent(QCloseEvent *e); void closeEvent(QCloseEvent *e);
void on_buttonBox_rejected(); void on_buttonBox_rejected();

14
src/preferences.h

@ -53,9 +53,19 @@ public:
settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale); settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
} }
static int getStyle() { static QString getDefaultStyle() {
QSettings settings("qBittorrent", "qBittorrent"); 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() { static bool confirmOnExit() {

20
src/ui/options.ui

@ -336,26 +336,6 @@
<string>System default</string> <string>System default</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Plastique style (KDE like)</string>
</property>
</item>
<item>
<property name="text">
<string>Cleanlooks style (Gnome like)</string>
</property>
</item>
<item>
<property name="text">
<string>Motif style (Unix like)</string>
</property>
</item>
<item>
<property name="text">
<string>CDE style (Common Desktop Environment like)</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item> <item>

Loading…
Cancel
Save