From 205e71e06e9e3b86ce457650d47ecd65ac8ecfbe Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Wed, 18 Jul 2012 12:41:13 +0100 Subject: [PATCH] GCS- Allow stylesheets to be loaded from files acording to OS. Use "linux.qss", "macos.qss" and "windows.qss" filenames and place them on the app directory. --- ground/openpilotgcs/src/app/main.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/app/main.cpp b/ground/openpilotgcs/src/app/main.cpp index ec2191956..06825b450 100644 --- a/ground/openpilotgcs/src/app/main.cpp +++ b/ground/openpilotgcs/src/app/main.cpp @@ -229,6 +229,30 @@ static void overrideSettings(QSettings &settings, int argc, char **argv){ settings.sync(); } +static inline void loadStyleSheet() { + /* Let's use QFile and point to a resource... */ +#ifdef Q_OS_MAC + QFile data(QCoreApplication::applicationDirPath()+"/macos.qss"); +#elif defined(Q_OS_LINUX) + QFile data(QCoreApplication::applicationDirPath()+"/linux.qss"); +#else + QFile data(QCoreApplication::applicationDirPath()+"/windows.qss"); +#endif + QString style; + /* ...to open the file */ + if(data.open(QFile::ReadOnly)) { + /* QTextStream... */ + QTextStream styleIn(&data); + /* ...read file to a string. */ + style = styleIn.readAll(); + data.close(); + /* We'll use qApp macro to get the QApplication pointer + * and set the style sheet application wide. */ + qApp->setStyleSheet(style); + qDebug()<<"Loaded stylesheet:"<hasError()) { displayError(msgCoreLoadFailure(coreplugin->errorString())); return 1;