Enable RDStyle by default, add style selection in the settings dialog

This commit is contained in:
baldurk
2017-08-16 17:39:37 +01:00
parent b70e897838
commit cfd816d7f3
11 changed files with 291 additions and 26 deletions
@@ -22,9 +22,11 @@
* THE SOFTWARE.
******************************************************************************/
#include <QApplication>
#include <QDebug>
#include <QDir>
#include "Code/QRDUtils.h"
#include "Styles/StyleData.h"
#include "QRDInterface.h"
#define JSON_ID "rdocConfigData"
@@ -220,6 +222,23 @@ void PersistantConfig::AddAndroidHosts()
}
}
bool PersistantConfig::SetStyle()
{
for(int i = 0; i < StyleData::numAvailable; i++)
{
if(UIStyle == StyleData::availStyles[i].styleID)
{
QApplication::setStyle(StyleData::availStyles[i].creator());
return true;
}
}
if(UIStyle != QString())
qCritical() << "Unrecognised UI style" << UIStyle;
return false;
}
PersistantConfig::~PersistantConfig()
{
for(RemoteHost *h : RemoteHosts)
+20 -1
View File
@@ -59,6 +59,8 @@ DECLARE_REFLECTION_STRUCT(SPIRVDisassembler);
// Note that only public properties should be documented.
#define CONFIG_SETTINGS() \
\
CONFIG_SETTING_VAL(public, QString, QString, UIStyle, QString()) \
\
CONFIG_SETTING_VAL(public, QString, QString, LastLogPath, QString()) \
\
CONFIG_SETTING(public, QVariantList, QList<QString>, RecentLogFiles) \
@@ -198,6 +200,12 @@ settings and information that needs to be preserved from one run to the next.
For more information about some of these settings that are user-facing see
:ref:`the documentation for the settings window <settings-window>`.
.. data:: UIStyle
The style to load for the UI. Possible values include 'Native', 'RDLight', 'RDDark'. If empty,
the closest of RDLight and RDDark will be chosen, based on the overall light-on-dark or
dark-on-light theme of the application native style.
.. data:: LastLogPath
The path to the last capture to be opened, which is useful as a default location for browsing.
@@ -420,7 +428,6 @@ public:
DOCUMENT("");
CONFIG_SETTINGS()
public:
PersistantConfig() {}
~PersistantConfig();
@@ -468,6 +475,18 @@ storing custom settings to be persisted without needing to modify code.
)");
QString GetConfigSetting(const QString &name);
DOCUMENT(R"(Sets the UI style to the value in :data:`UIStyle`.
Changing the style after the application has started may not properly update everything, so to be
sure the new style is applied, the application should be restarted.
:param str name: The name of the setting.
:return: ``True`` if the style was set successfully, ``False`` if there was a problem e.g. the value
of :data:`UIStyle` was unrecognised or empty.
:rtype: ``bool``
)");
bool SetStyle();
private:
bool Deserialize(const QString &filename);
bool Serialize(const QString &filename);