diff options
-rw-r--r-- | muse2/ChangeLog | 2 | ||||
-rw-r--r-- | muse2/muse/app.cpp | 47 | ||||
-rw-r--r-- | muse2/muse/app.h | 3 | ||||
-rw-r--r-- | muse2/muse/appearance.cpp | 44 | ||||
-rw-r--r-- | muse2/muse/appearance.h | 2 | ||||
-rw-r--r-- | muse2/muse/conf.cpp | 3 | ||||
-rw-r--r-- | muse2/muse/gconfig.cpp | 1 | ||||
-rw-r--r-- | muse2/muse/gconfig.h | 1 | ||||
-rw-r--r-- | muse2/muse/widgets/appearancebase.ui | 36 | ||||
-rw-r--r-- | muse2/muse/widgets/musewidgetsplug.cpp | 1 |
10 files changed, 131 insertions, 9 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog index b2d4bd33..c506bd1e 100644 --- a/muse2/ChangeLog +++ b/muse2/ChangeLog @@ -5,6 +5,8 @@ shortcutcapturedialogbase, shortcutconfigbase, aboutbox, editsysexdialogbase, editnotedialogbase, editctrlbase (Orcan) - Converted all of editevent.cpp to Qt4 (Orcan) + - Load default compiled-in style-sheet resource :/style.qss in main(). (Tim) + Added style sheet support to Appearance settings, with reset button. 19.11.2010 - Started some conversions of midieditor, pianoroll, drumedit, incl. their QGridLayouts. (Tim) - More icon conversion work (Orcan) 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(); diff --git a/muse2/muse/app.h b/muse2/muse/app.h index 55f81f71..0994f14b 100644 --- a/muse2/muse/app.h +++ b/muse2/muse/app.h @@ -279,7 +279,8 @@ class MusE : public QMainWindow void loadProjectFile(const QString&); void loadProjectFile(const QString&, bool songTemplate, bool loadAll); void toplevelDeleted(unsigned long tl); - void loadTheme(QString); + void loadTheme(const QString&); + void loadStyleSheetFile(const QString&); bool seqRestart(); void loadTemplate(); void showBigtime(bool); diff --git a/muse2/muse/appearance.cpp b/muse2/muse/appearance.cpp index adcc51ba..baf489ea 100644 --- a/muse2/muse/appearance.cpp +++ b/muse2/muse/appearance.cpp @@ -12,6 +12,11 @@ #include <QFontDialog> #include <QStyleFactory> #include <QToolTip> +#include <QByteArray> +#include <QFile> +#include <QFileDialog> +#include <QFileInfo> +#include <QtGlobal> #include "icons.h" #include "appearance.h" @@ -193,6 +198,11 @@ Appearance::Appearance(Arranger* a, QWidget* parent) } */ + openStyleSheet->setIcon(*openIcon); + connect(openStyleSheet, SIGNAL(clicked()), SLOT(browseStyleSheet())); + defaultStyleSheet->setIcon(*openIcon); + connect(defaultStyleSheet, SIGNAL(clicked()), SLOT(setDefaultStyleSheet())); + //--------------------------------------------------- // Fonts //--------------------------------------------------- @@ -228,6 +238,7 @@ Appearance::Appearance(Arranger* a, QWidget* parent) void Appearance::resetValues() { *config = ::config; // init with global config values + styleSheetPath->setText(config->styleSheetFile); updateFonts(); palette0->setPaletteBackgroundColor(config->palette[0]); palette1->setPaletteBackgroundColor(config->palette[1]); @@ -372,13 +383,14 @@ void Appearance::apply() else config->canvasBgPixmap = currentBg; - // Added by Tim. p3.3.9 + config->styleSheetFile = styleSheetPath->text(); + config->fonts[0].setFamily(fontName0->text()); config->fonts[0].setPointSize(fontSize0->value()); config->fonts[0].setItalic(italic0->isChecked()); config->fonts[0].setBold(bold0->isChecked()); - QApplication::setFont(config->fonts[0], true); + QApplication::setFont(config->fonts[0], true); config->fonts[1].setFamily(fontName1->text()); config->fonts[1].setPointSize(fontSize1->value()); @@ -704,6 +716,34 @@ void Appearance::paletteClicked(int id) } //--------------------------------------------------------- +// browseStyleSheet +//--------------------------------------------------------- + +void Appearance::browseStyleSheet() +{ + QString path; + if(!config->styleSheetFile.isEmpty()) + { + QFileInfo info(config->styleSheetFile); + path = info.absolutePath(); + } + + QString file = QFileDialog::getOpenFileName(this, tr("Select style sheet"), path, tr("Qt style sheets (*.qss)")); + styleSheetPath->setText(file); +} + + +//--------------------------------------------------------- +// setDefaultStyleSheet +//--------------------------------------------------------- + +void Appearance::setDefaultStyleSheet() +{ + // Set the style sheet to the default compiled-in resource :/style.qss + styleSheetPath->setText(QString(":/style.qss")); +} + +//--------------------------------------------------------- // browseFont //--------------------------------------------------------- diff --git a/muse2/muse/appearance.h b/muse2/muse/appearance.h index e2755aef..de0ceb31 100644 --- a/muse2/muse/appearance.h +++ b/muse2/muse/appearance.h @@ -32,6 +32,8 @@ class Appearance : public QDialog, public Ui::AppearanceDialogBase { void configBackground(); void clearBackground(); void colorItemSelectionChanged(); + void browseStyleSheet(); + void setDefaultStyleSheet(); void browseFont(int); void browseFont0(); void browseFont1(); diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp index 2f55a4a0..a704e245 100644 --- a/muse2/muse/conf.cpp +++ b/muse2/muse/conf.cpp @@ -508,6 +508,8 @@ void readConfiguration(Xml& xml, bool readOnlySequencer) if (tag == "theme") config.style = xml.parse1(); + else if (tag == "styleSheetFile") + config.styleSheetFile = xml.parse1(); else if (tag == "useOldStyleStopShortCut") config.useOldStyleStopShortCut = xml.parseInt(); else if (tag == "moveArmedCheckBox") @@ -1071,6 +1073,7 @@ void MusE::writeGlobalConfiguration(int level, Xml& xml) const //xml.intTag(level, "txDeviceId", txDeviceId); //xml.intTag(level, "rxDeviceId", rxDeviceId); xml.strTag(level, "theme", config.style); + xml.strTag(level, "styleSheetFile", config.styleSheetFile); xml.strTag(level, "externalWavEditor", config.externalWavEditor); xml.intTag(level, "useOldStyleStopShortCut", config.useOldStyleStopShortCut); xml.intTag(level, "moveArmedCheckBox", config.moveArmedCheckBox); diff --git a/muse2/muse/gconfig.cpp b/muse2/muse/gconfig.cpp index be92b6aa..00b89374 100644 --- a/muse2/muse/gconfig.cpp +++ b/muse2/muse/gconfig.cpp @@ -121,6 +121,7 @@ GlobalConfigValues config = { 5, // canvasShowPartEvent true, // canvasShowGrid; QString(""), // canvasBgPixmap; + QString(":/style.qss"), // default styleSheetFile QString(""), // style QString("sweep"), // externalWavEditor false, // useOldStyleStopShortCut diff --git a/muse2/muse/gconfig.h b/muse2/muse/gconfig.h index 454ed05d..ecef559c 100644 --- a/muse2/muse/gconfig.h +++ b/muse2/muse/gconfig.h @@ -113,6 +113,7 @@ struct GlobalConfigValues { int canvasShowPartEvent; // bool canvasShowGrid; QString canvasBgPixmap; + QString styleSheetFile; QString style; QString externalWavEditor; diff --git a/muse2/muse/widgets/appearancebase.ui b/muse2/muse/widgets/appearancebase.ui index ce046b58..dd0c1960 100644 --- a/muse2/muse/widgets/appearancebase.ui +++ b/muse2/muse/widgets/appearancebase.ui @@ -22,7 +22,7 @@ <verstretch>0</verstretch> </sizepolicy> </property> - <widget class="QWidget" name="tab"> + <widget class="QWidget" name="tab1"> <attribute name="title"> <string>Arranger</string> </attribute> @@ -193,7 +193,7 @@ </item> </layout> </widget> - <widget class="QWidget" name="tab"> + <widget class="QWidget" name="tab2"> <attribute name="title"> <string>Colors</string> </attribute> @@ -740,7 +740,7 @@ </item> </layout> </widget> - <widget class="QWidget" name="tab"> + <widget class="QWidget" name="tab3"> <attribute name="title"> <string>Style/Fonts</string> </attribute> @@ -834,6 +834,34 @@ </layout> </item> <item> + <layout class="QHBoxLayout" > + <item> + <widget class="QLabel" name="label_41" > + <property name="text" > + <string>Style Sheet:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="styleSheetPath" /> + </item> + <item> + <widget class="QToolButton" name="openStyleSheet" > + <property name="text" > + <string>...</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="defaultStyleSheet" > + <property name="text" > + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item> <spacer name="spacer3"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -1417,6 +1445,8 @@ <tabstop>selectBgButton</tabstop> <tabstop>arrGrid</tabstop> <tabstop>themeComboBox</tabstop> + <tabstop>styleSheetPath</tabstop> + <tabstop>openStyleSheet</tabstop> <tabstop>fontName0</tabstop> <tabstop>fontName1</tabstop> <tabstop>fontName2</tabstop> diff --git a/muse2/muse/widgets/musewidgetsplug.cpp b/muse2/muse/widgets/musewidgetsplug.cpp index 78376536..5aea4c81 100644 --- a/muse2/muse/widgets/musewidgetsplug.cpp +++ b/muse2/muse/widgets/musewidgetsplug.cpp @@ -153,6 +153,7 @@ GlobalConfigValues config = { 5, // canvasShowPartEvent false, // canvasShowGrid; QString(""), // canvasBgPixmap; + QString(""), // styleSheetFile QString(""), // style QString(""), // externalWavEditor //this line was missing 2007-01-08 (willyfoobar) false, // useOldStyleStopShortCut |