From 4c142f6b4483c191c880b23c84199a3b2022ce01 Mon Sep 17 00:00:00 2001 From: "Tim E. Real" Date: Sun, 21 Nov 2010 03:48:35 +0000 Subject: Style sheet support. See ChangeLog. --- muse2/muse/app.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'muse2/muse/app.cpp') 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 #include #include +#include +#include +#include //Added by qt3to4: #include #include @@ -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,12 +4092,35 @@ 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 @@ -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(); -- cgit v1.2.3