style/preferences: don't set style if it hasn't changed

Improves Preferences dialog's "accept" speed. Before it would try changing the
style no matter what which took a noticeable amount of time to do for no real
purpose if the style didn't change.
This commit is contained in:
itsmattkc
2020-04-21 19:35:04 +10:00
parent 50d336ffb8
commit c84f7fe724
3 changed files with 32 additions and 10 deletions
+21
View File
@@ -28,10 +28,13 @@
#include <QStyleFactory>
#include <QTextStream>
#include "config/config.h"
#include "ui/icons/icons.h"
OLIVE_NAMESPACE_ENTER
QString StyleManager::current_style_;
QList<StyleDescriptor> StyleManager::ListInternal()
{
QList<StyleDescriptor> style_list;
@@ -143,6 +146,22 @@ StyleDescriptor StyleManager::DefaultStyle()
return ListInternal().first();
}
const QString &StyleManager::GetStyle()
{
return current_style_;
}
void StyleManager::SetStyleFromConfig()
{
QString config_style = Config::Current()["Style"].toString();
if (config_style.isEmpty()) {
SetStyle(DefaultStyle());
} else {
SetStyle(config_style);
}
}
void StyleManager::SetStyle(const StyleDescriptor &style)
{
SetStyle(style.path());
@@ -150,6 +169,8 @@ void StyleManager::SetStyle(const StyleDescriptor &style)
void StyleManager::SetStyle(const QString &style_path)
{
current_style_ = style_path;
// Load all icons for this style (icons must be loaded first because the style change below triggers the icon change)
icon::LoadAll(style_path);