summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-09-27 12:52:01 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-27 09:22:19 -0700
commite81bbc1dabc3601876bd7393c73b49d5ff87ee85 (patch)
treeb519596d9f81b089b5e4d2829068fba621b9358c
parentd6293217993a7601b6e1203cbab1062ba2b2523c (diff)
downloadsubsurface-e81bbc1dabc3601876bd7393c73b49d5ff87ee85.tar.gz
Hack to make the subsurface work on Gnome3 shell
The Gtk+ style on the Gnome shell is somewhat broken on Qt for some reason. This hack pokes the system, checks if it's running gnome-shell, and if the current style is gtk+ ( I couldn't just check for gtk+ since it worked on XFCE and other Gtk based enviro ments. so a double check is needed. ) then I changed the Pallete of the affected widgets by hand. not a pretty hack but worked. [Dirk Hohndel: redid the patch to be simpler and more consistent] Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-gui.cpp5
-rw-r--r--qt-ui/maintab.cpp11
-rw-r--r--qt-ui/modeldelegates.cpp12
-rw-r--r--qt-ui/simplewidgets.cpp18
-rw-r--r--qt-ui/simplewidgets.h2
5 files changed, 43 insertions, 5 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp
index cb06bf8d5..41a6617e1 100644
--- a/qt-gui.cpp
+++ b/qt-gui.cpp
@@ -93,11 +93,6 @@ void init_ui(int *argcp, char ***argvp)
// note: on Linux, "system" == "environment variables"
QNetworkProxyFactory::setUseSystemConfiguration(true);
- // the Gtk theme makes things unbearably ugly
- // so switch to Oxygen in this case
- if (application->style()->objectName() == "gtk+")
- application->setStyle("Oxygen");
-
#if QT_VERSION < 0x050000
// ask QString in Qt 4 to interpret all char* as UTF-8,
// like Qt 5 does.
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 98247566a..cc56a58c6 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -96,6 +96,17 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
setMinimumHeight(0);
setMinimumWidth(0);
+
+ // Current display of things on Gnome3 looks like shit, so
+ // let`s fix that.
+ if (isGnome3Session()) {
+ QPalette p;
+ p.setColor(QPalette::Window, QColor(Qt::white));
+ ui->scrollArea->viewport()->setPalette(p);
+ ui->scrollArea_2->viewport()->setPalette(p);
+ ui->scrollArea_3->viewport()->setPalette(p);
+ ui->scrollArea_4->viewport()->setPalette(p);
+ }
}
void MainTab::addDiveStarted()
diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index 5a55cad3c..6141f79fc 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -4,6 +4,7 @@
#include "starwidget.h"
#include "models.h"
#include "diveplanner.h"
+#include "simplewidgets.h"
#include <QtDebug>
#include <QPainter>
@@ -16,6 +17,7 @@
#include <QKeyEvent>
#include <QAbstractItemView>
#include <QStringListModel>
+#include <QApplication>
// Gets the index of the model in the currentRow and column.
// currCombo is defined below.
@@ -100,6 +102,16 @@ QWidget* ComboBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewI
currCombo.comboEditor = comboDelegate;
currCombo.currRow = index.row();
currCombo.model = const_cast<QAbstractItemModel*>(index.model());
+
+ // Current display of things on Gnome3 looks like shit, so
+ // let`s fix that.
+ if (isGnome3Session()) {
+ QPalette p;
+ p.setColor(QPalette::Window, QColor(Qt::white));
+ p.setColor(QPalette::Base, QColor(Qt::white));
+ comboDelegate->lineEdit()->setPalette(p);
+ comboDelegate->setPalette(p);
+ }
return comboDelegate;
}
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index a6e01a724..ce659c6cf 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -8,6 +8,9 @@
#include <QSpinBox>
#include <QButtonGroup>
#include <QDebug>
+#include <QProcess>
+#include <QStringList>
+#include <QDebug>
#include "../dive.h"
@@ -118,3 +121,18 @@ RenumberDialog::RenumberDialog(): QDialog(), ui( new Ui::RenumberDialog())
ui->setupUi(this);
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(buttonClicked(QAbstractButton*)));
}
+
+bool isGnome3Session()
+{
+#if defined(QT_OS_WIW) || defined(QT_OS_MAC)
+ return false;
+#else
+ if (qApp->style()->objectName() != "gtk+")
+ return false;
+ QProcess p;
+ p.start("pidof", QStringList() << "gnome-shell" );
+ p.waitForFinished(-1);
+ QString p_stdout = p.readAllStandardOutput();
+ return !p_stdout.isEmpty();
+#endif
+}
diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h
index ffd415767..cf79d19c7 100644
--- a/qt-ui/simplewidgets.h
+++ b/qt-ui/simplewidgets.h
@@ -43,4 +43,6 @@ private:
Ui::RenumberDialog *ui;
};
+bool isGnome3Session();
+
#endif