summaryrefslogtreecommitdiff
path: root/muse2/muse/app.cpp
diff options
context:
space:
mode:
authorTim E. Real <termtech@rogers.com>2010-11-21 03:48:35 +0000
committerTim E. Real <termtech@rogers.com>2010-11-21 03:48:35 +0000
commit4c142f6b4483c191c880b23c84199a3b2022ce01 (patch)
treef8d4812fe777e978444c162afdd156d41354ab8f /muse2/muse/app.cpp
parente29c2ba6ed400e54dca62a35ce53edea85d34ddb (diff)
Style sheet support. See ChangeLog.
Diffstat (limited to 'muse2/muse/app.cpp')
-rw-r--r--muse2/muse/app.cpp47
1 files changed, 44 insertions, 3 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index fb36c849..8d15ab08 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -37,6 +37,9 @@
#include <QSplashScreen>
#include <QObject>
#include <QAction>
+#include <QFile>
+#include <QByteArray>
+#include <QtGlobal>
//Added by qt3to4:
#include <QTimerEvent>
#include <Q3CString>
@@ -3546,6 +3549,7 @@ int main(int argc, char* argv[])
stimer->start(6000, true);
}
}
+
int i;
QString optstr("ahvdDmMsP:Y:py");
@@ -3592,6 +3596,21 @@ int main(int argc, char* argv[])
}
}
+ if(!config.styleSheetFile.isEmpty())
+ {
+ if(debugMsg)
+ printf("loading style sheet <%s> \n", qPrintable(config.styleSheetFile));
+ QFile cf(config.styleSheetFile);
+ if (cf.open(QIODevice::ReadOnly)) {
+ QByteArray ss = cf.readAll();
+ QString sheet(QString::fromUtf8(ss.data()));
+ app.setStyleSheet(sheet);
+ cf.close();
+ }
+ else
+ printf("loading style sheet <%s> failed\n", qPrintable(config.styleSheetFile));
+ }
+
AL::initDsp();
if (debugMsg)
@@ -4073,13 +4092,36 @@ void MusE::configAppearance()
// loadTheme
//---------------------------------------------------------
-void MusE::loadTheme(QString s)
+void MusE::loadTheme(const QString& s)
{
if (style()->name() != s)
QApplication::setStyle(s);
}
//---------------------------------------------------------
+// loadStyleSheetFile
+//---------------------------------------------------------
+
+void MusE::loadStyleSheetFile(const QString& s)
+{
+ if(s.isEmpty())
+ {
+ qApp->setStyleSheet(s);
+ return;
+ }
+
+ QFile cf(s);
+ if (cf.open(QIODevice::ReadOnly)) {
+ QByteArray ss = cf.readAll();
+ QString sheet(QString::fromUtf8(ss.data()));
+ qApp->setStyleSheet(sheet);
+ cf.close();
+ }
+ else
+ printf("loading style sheet <%s> failed\n", qPrintable(s));
+}
+
+//---------------------------------------------------------
// configChanged
// - called whenever configuration has changed
// - when configuration has changed by user, call with
@@ -4092,8 +4134,7 @@ void MusE::changeConfig(bool writeFlag)
writeGlobalConfiguration();
loadTheme(config.style);
QApplication::setFont(config.fonts[0], true);
- // Added by Tim. p3.3.6
- //printf("MusE::changeConfig writeFlag:%d emitting configChanged\n", writeFlag);
+ loadStyleSheetFile(config.styleSheetFile);
emit configChanged();
updateConfiguration();