Browse Source

Improved application style handling

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
e9ad58a373
  1. 6
      src/main.cpp
  2. 19
      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) { @@ -155,7 +155,7 @@ void sigabrtHandler(int) {
#ifndef DISABLE_GUI
void useStyle(QApplication *app, QString style){
if(style != "default") {
if(!style.isEmpty()) {
QApplication::setStyle(QStyleFactory::create(style));
}
if(app->style()->objectName() == "cleanlooks") {
@ -163,6 +163,7 @@ void useStyle(QApplication *app, QString style){ @@ -163,6 +163,7 @@ void useStyle(QApplication *app, QString style){
qDebug("Forcing our own cleanlooks style");
app->setStyle(new QGnomeLookStyle());
}
Preferences::setStyle(app->style()->objectName());
}
#endif
@ -249,8 +250,7 @@ int main(int argc, char *argv[]){ @@ -249,8 +250,7 @@ int main(int argc, char *argv[]){
app = new QApplication(argc, argv);
#endif
#ifndef DISABLE_GUI
Preferences::setDefaultStyle(app->style()->objectName());
useStyle(app, settings.value("Preferences/General/Style", "default").toString());
useStyle(app, settings.value("Preferences/General/Style", "").toString());
app->setStyleSheet("QStatusBar::item { border-width: 0; }");
QSplashScreen *splash = 0;
if(!no_splash) {

19
src/options_imp.cpp

@ -291,11 +291,7 @@ void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous @@ -291,11 +291,7 @@ void options_imp::changePage(QListWidgetItem *current, QListWidgetItem *previous
}
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") {
// Force our own cleanlooks style
qDebug("Forcing our own cleanlooks style");
@ -539,18 +535,13 @@ int options_imp::getHTTPProxyType() const { @@ -539,18 +535,13 @@ int options_imp::getHTTPProxyType() 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) {
if(style != "default") {
int index = comboStyle->findText(style);
if(index > 0)
comboStyle->setCurrentIndex(index);
}
int index = comboStyle->findText(style, Qt::MatchFixedString);
if(index > 0)
comboStyle->setCurrentIndex(index);
}
bool options_imp::isHTTPProxyAuthEnabled() const{

13
src/preferences.h

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

8
src/ui/options.ui

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

Loading…
Cancel
Save