diff --git a/retroshare-gui/src/config/rsharesettings.cpp b/retroshare-gui/src/config/rsharesettings.cpp index 37f7b32b9..bf30b3e8a 100644 --- a/retroshare-gui/src/config/rsharesettings.cpp +++ b/retroshare-gui/src/config/rsharesettings.cpp @@ -38,22 +38,26 @@ #endif -/* Rshare's Settings */ +/* Retroshare's Settings */ #define SETTING_LANGUAGE "LanguageCode" #define SETTING_STYLE "InterfaceStyle" +#define SETTING_SHEETNAME "SheetName" + #define SETTING_DATA_DIRECTORY "DataDirectory" #define SETTING_BWGRAPH_FILTER "StatisticDialog/BWLineFilter" #define SETTING_BWGRAPH_OPACITY "StatisticDialog/Opacity" #define SETTING_BWGRAPH_ALWAYS_ON_TOP "StatisticDialog/AlwaysOnTop" -/* Default Rshare Settings */ +/* Default Retroshare Settings */ #if defined(Q_WS_MAC) #define DEFAULT_STYLE "macintosh (aqua)" #else #define DEFAULT_STYLE "plastique" #endif +#define DEFAULT_SHEETNAME "Default" + #define DEFAULT_LANGUAGE LanguageSupport::defaultLanguageCode() #define DEFAULT_OPACITY 100 @@ -154,6 +158,16 @@ void RshareSettings::setInterfaceStyle(QString styleKey) setValue(SETTING_STYLE, styleKey); } +/** Gets the sheetname.*/ +QString RshareSettings::getSheetName() +{ + return value(SETTING_SHEETNAME, DEFAULT_SHEETNAME).toString(); +} +/** Sets the sheetname.*/ +void RshareSettings::setSheetName(QString sheet) +{ + setValue(SETTING_SHEETNAME, sheet); +} /** Returns the bandwidth line filter. */ uint RshareSettings::getBWGraphFilter() @@ -249,4 +263,3 @@ void RshareSettings::loadWidgetInformation(QMainWindow *widget, QToolBar *toolBa loadWidgetInformation(widget); } - diff --git a/retroshare-gui/src/config/rsharesettings.h b/retroshare-gui/src/config/rsharesettings.h index 732e738fc..1c7ba5162 100644 --- a/retroshare-gui/src/config/rsharesettings.h +++ b/retroshare-gui/src/config/rsharesettings.h @@ -78,6 +78,12 @@ public: /** Sets the interface style key. */ void setInterfaceStyle(QString styleKey); + /** Sets the stylesheet */ + void setSheetName(QString sheet); + /** Gets the stylesheet */ + QString getSheetName(); + + /* Get the destination log file. */ QString getLogFile(); /** Set the destination log file. */ diff --git a/retroshare-gui/src/gui/Preferences/GeneralDialog.cpp b/retroshare-gui/src/gui/Preferences/GeneralDialog.cpp index 5fda858b0..c6738b006 100644 --- a/retroshare-gui/src/gui/Preferences/GeneralDialog.cpp +++ b/retroshare-gui/src/gui/Preferences/GeneralDialog.cpp @@ -47,7 +47,7 @@ GeneralDialog::GeneralDialog(QWidget *parent) } ui.styleSheetCombo->setCurrentIndex(ui.styleSheetCombo->findText("Default")); - loadStyleSheet("Default"); + //loadStyleSheet("Default"); loadqss(); } @@ -68,6 +68,7 @@ GeneralDialog::save(QString &errmsg) _settings->setLanguageCode(languageCode); _settings->setInterfaceStyle(ui.cmboStyle->currentText()); + _settings->setSheetName(ui.styleSheetCombo->currentText()); /* Set to new style */ Rshare::setStyle(ui.cmboStyle->currentText()); @@ -83,6 +84,23 @@ GeneralDialog::load() index = ui.cmboStyle->findData(Rshare::style().toLower()); ui.cmboStyle->setCurrentIndex(index); + + index = ui.styleSheetCombo->findData(Rshare::stylesheet().toLower()); + ui.styleSheetCombo->setCurrentIndex(index); + + //index = ui.styleSheetCombo->findData(_settings->getSheetName()); + //ui.styleSheetCombo->setCurrentIndex(index); + + /* load internal styleSheet */ + //QFile file(":/qss/" + (_settings->getSheetName().toLower()) + ".qss"); + + /** load extern Stylesheets **/ + QFile file(QApplication::applicationDirPath() + "/qss/" + (_settings->getSheetName().toLower()) + ".qss"); + + file.open(QFile::ReadOnly); + QString styleSheet = QLatin1String(file.readAll()); + qApp->setStyleSheet(styleSheet); + } void GeneralDialog::on_styleSheetCombo_activated(const QString &sheetName) @@ -92,8 +110,12 @@ void GeneralDialog::on_styleSheetCombo_activated(const QString &sheetName) void GeneralDialog::loadStyleSheet(const QString &sheetName) { + /** internal Stylesheets **/ //QFile file(":/qss/" + sheetName.toLower() + ".qss"); + + /** extern Stylesheets **/ QFile file(QApplication::applicationDirPath() + "/qss/" + sheetName.toLower() + ".qss"); + file.open(QFile::ReadOnly); QString styleSheet = QLatin1String(file.readAll()); diff --git a/retroshare-gui/src/rshare.cpp b/retroshare-gui/src/rshare.cpp index 7cc82946e..933921f88 100644 --- a/retroshare-gui/src/rshare.cpp +++ b/retroshare-gui/src/rshare.cpp @@ -32,16 +32,18 @@ #include "rshare.h" /* Available command-line arguments. */ -#define ARG_LANGUAGE "lang" /**< Argument specifying language. */ -#define ARG_GUISTYLE "style" /**< Argument specfying GUI style. */ -#define ARG_RESET "reset" /**< Reset Rshare's saved settings. */ -#define ARG_DATADIR "datadir" /**< Directory to use for data files. */ +#define ARG_LANGUAGE "lang" /**< Argument specifying language. */ +#define ARG_GUISTYLE "style" /**< Argument specfying GUI style. */ +#define ARG_GUISTYLESHEET "stylesheet" /**< Argument specfying GUI style. */ +#define ARG_RESET "reset" /**< Reset Rshare's saved settings. */ +#define ARG_DATADIR "datadir" /**< Directory to use for data files. */ /* Static member variables */ QMap Rshare::_args; /**< List of command-line arguments. */ QString Rshare::_style; /**< The current GUI style. */ QString Rshare::_language; /**< The current language. */ +QString Rshare::_stylesheet; /**< The current GUI style. */ bool Rshare::useConfigDir; QString Rshare::configDir; @@ -77,14 +79,16 @@ Rshare::Rshare(QStringList args, int &argc, char **argv, QString dir) /** Set the GUI style appropriately. */ setStyle(_args.value(ARG_GUISTYLE)); + + /** Set the GUI stylesheet appropriately. */ + setSheet(_args.value(ARG_GUISTYLESHEET)); } /** Destructor */ Rshare::~Rshare() { - // delete _help; - //delete _torControl; + } #if defined(Q_OS_WIN) @@ -120,6 +124,7 @@ Rshare::printUsage(QString errmsg) out << "\t-"ARG_RESET"\t\tResets ALL stored Rshare settings." << endl; out << "\t-"ARG_DATADIR"\tSets the directory Rshare uses for data files"<< endl; out << "\t-"ARG_GUISTYLE"\t\tSets Rshare's interface style." << endl; + out << "\t-"ARG_GUISTYLESHEET"\t\tSets Rshare's stylesheet." << endl; out << "\t\t\t[" << QStyleFactory::keys().join("|") << "]" << endl; out << "\t-"ARG_LANGUAGE"\t\tSets Rshare's language." << endl; out << "\t\t\t[" << LanguageSupport::languageCodes().join("|") << "]" << endl; @@ -130,6 +135,7 @@ bool Rshare::argNeedsValue(QString argName) { return (argName == ARG_GUISTYLE || + argName == ARG_GUISTYLESHEET || argName == ARG_LANGUAGE || argName == ARG_DATADIR); @@ -169,7 +175,7 @@ Rshare::validateArguments(QString &errmsg) if (_args.contains(ARG_HELP)) { return false; }*/ - /* Check for a language that Rshare recognizes. */ + /* Check for a language that Retroshare recognizes. */ if (_args.contains(ARG_LANGUAGE) && !LanguageSupport::isValidLanguageCode(_args.value(ARG_LANGUAGE))) { errmsg = tr("Invalid language code specified: ") + _args.value(ARG_LANGUAGE); @@ -185,7 +191,7 @@ Rshare::validateArguments(QString &errmsg) return true; } -/** Sets the translation Rshare will use. If one was specified on the +/** Sets the translation RetroShare will use. If one was specified on the * command-line, we will use that. Otherwise, we'll check to see if one was * saved previously. If not, we'll default to one appropriate for the system * locale. */ @@ -205,7 +211,7 @@ Rshare::setLanguage(QString languageCode) return false; } -/** Sets the GUI style Rshare will use. If one was specified on the +/** Sets the GUI style RetroShare will use. If one was specified on the * command-line, we will use that. Otherwise, we'll check to see if one was * saved previously. If not, we'll default to one appropriate for the * operating system. */ @@ -225,6 +231,24 @@ Rshare::setStyle(QString styleKey) return false; } +bool +Rshare::setSheet(QString sheet) +{ + /* If no stylesheet was specified, use the previously-saved setting */ + if (sheet.isEmpty()) { + RshareSettings settings; + sheet = settings.getSheetName(); + } + /* Apply the specified GUI stylesheet */ + /*if (QApplication::setSheet(sheet)) {*/ + _stylesheet = sheet; + return true; + /*} + return false;*/ + +} + + /** Displays the help page associated with the specified topic. If no topic is * specified, then the default help page will be displayed. */ /**void diff --git a/retroshare-gui/src/rshare.h b/retroshare-gui/src/rshare.h index a7dfc81e0..59b0dbc85 100644 --- a/retroshare-gui/src/rshare.h +++ b/retroshare-gui/src/rshare.h @@ -60,6 +60,8 @@ public: static bool setLanguage(QString languageCode = QString()); /** Sets the current GUI style. */ static bool setStyle(QString styleKey = QString()); + /** Sets the current GUI stylesheet. */ + static bool setSheet(QString sheet = QString()); /** Shows the specified help topic, or the default if empty. */ //static void help(QString topic = QString()); @@ -67,11 +69,11 @@ public: static QString language() { return _language; } /** Returns the current GUI style. */ static QString style() { return _style; } + /** Returns the current GUI stylesheet. */ + static QString stylesheet() { return _stylesheet; } /** Returns Rshare's application version. */ static QString version() { return RSHARE_VERSION; } - /** Returns Rshare's main TorControl object. */ -// static TorControl* torControl() { return _torControl; } /** Returns the location Rshare uses for its data files. */ static QString dataDirectory(); @@ -101,6 +103,7 @@ private: static QMap _args; /**< List of command-line arguments. */ static QString _style; /**< The current GUI style. */ + static QString _stylesheet; /**< The current GUI stylesheet. */ static QString _language; /**< The current language. */ static bool useConfigDir;