Browse Source

Improved application style handling

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
e9ad58a373
  1. 6
      src/main.cpp
  2. 11
      src/options_imp.cpp
  3. 13
      src/preferences.h
  4. 8
      src/ui/options.ui

6
src/main.cpp

@ -155,7 +155,7 @@ void sigabrtHandler(int) {
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
void useStyle(QApplication *app, QString style){ void useStyle(QApplication *app, QString style){
if(style != "default") { if(!style.isEmpty()) {
QApplication::setStyle(QStyleFactory::create(style)); QApplication::setStyle(QStyleFactory::create(style));
} }
if(app->style()->objectName() == "cleanlooks") { if(app->style()->objectName() == "cleanlooks") {
@ -163,6 +163,7 @@ void useStyle(QApplication *app, QString style){
qDebug("Forcing our own cleanlooks style"); qDebug("Forcing our own cleanlooks style");
app->setStyle(new QGnomeLookStyle()); app->setStyle(new QGnomeLookStyle());
} }
Preferences::setStyle(app->style()->objectName());
} }
#endif #endif
@ -249,8 +250,7 @@ int main(int argc, char *argv[]){
app = new QApplication(argc, argv); app = new QApplication(argc, argv);
#endif #endif
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
Preferences::setDefaultStyle(app->style()->objectName()); useStyle(app, settings.value("Preferences/General/Style", "").toString());
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) {

11
src/options_imp.cpp

@ -291,11 +291,7 @@ void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous
} }
void options_imp::useStyle() { void options_imp::useStyle() {
if(comboStyle->currentIndex() == 0) {
QApplication::setStyle(Preferences::getDefaultStyle());
} else {
QApplication::setStyle(QStyleFactory::create(comboStyle->itemText(comboStyle->currentIndex()))); QApplication::setStyle(QStyleFactory::create(comboStyle->itemText(comboStyle->currentIndex())));
}
if(QApplication::style()->objectName() == "cleanlooks") { if(QApplication::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");
@ -539,19 +535,14 @@ int options_imp::getHTTPProxyType() const {
} }
QString options_imp::getStyle() const{ QString options_imp::getStyle() const{
if(comboStyle->currentIndex() == 0)
return "default";
else
return comboStyle->itemText(comboStyle->currentIndex()); return comboStyle->itemText(comboStyle->currentIndex());
} }
void options_imp::setStyle(QString style) { void options_imp::setStyle(QString style) {
if(style != "default") { int index = comboStyle->findText(style, Qt::MatchFixedString);
int index = comboStyle->findText(style);
if(index > 0) if(index > 0)
comboStyle->setCurrentIndex(index); comboStyle->setCurrentIndex(index);
} }
}
bool options_imp::isHTTPProxyAuthEnabled() const{ bool options_imp::isHTTPProxyAuthEnabled() const{
return checkProxyAuth_http->isChecked(); return checkProxyAuth_http->isChecked();

13
src/preferences.h

@ -53,19 +53,14 @@ public:
settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale); settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
} }
static QString getDefaultStyle() { static QString getStyle() {
QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/General/DefaultStyle"), "").toString();
}
static void setDefaultStyle(QString style) {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
settings.setValue(QString::fromUtf8("Preferences/General/DefaultStyle"), style); return settings.value(QString::fromUtf8("Preferences/General/Style"), "").toString();
} }
static QString getStyle() { static void setStyle(QString style) {
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
return settings.value(QString::fromUtf8("Preferences/General/Style"), "default").toString(); settings.setValue(QString::fromUtf8("Preferences/General/Style"), style);
} }
static bool confirmOnExit() { static bool confirmOnExit() {

8
src/ui/options.ui

@ -330,13 +330,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QComboBox" name="comboStyle"> <widget class="QComboBox" name="comboStyle"/>
<item>
<property name="text">
<string>System default</string>
</property>
</item>
</widget>
</item> </item>
<item> <item>
<spacer> <spacer>

Loading…
Cancel
Save