Add setting to set style
This commit is contained in:
parent
c9c3fb396a
commit
0ae7c18f1f
11
src/main.cpp
11
src/main.cpp
|
@ -97,6 +97,7 @@
|
|||
# include "core/translations.h"
|
||||
#endif
|
||||
#include "settings/behavioursettingspage.h"
|
||||
#include "settings/appearancesettingspage.h"
|
||||
|
||||
#ifdef HAVE_DBUS
|
||||
# include "osd/osddbus.h"
|
||||
|
@ -197,6 +198,16 @@ int main(int argc, char* argv[]) {
|
|||
// Gnome on Ubuntu has menu icons disabled by default. I think that's a bad idea, and makes some menus in Strawberry look confusing.
|
||||
QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false);
|
||||
|
||||
{
|
||||
QSettings s;
|
||||
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
|
||||
QString style = s.value(AppearanceSettingsPage::kStyle, "default").toString();
|
||||
s.endGroup();
|
||||
if (style != "default") {
|
||||
QApplication::setStyle(style);
|
||||
}
|
||||
}
|
||||
|
||||
// Set the permissions on the config file on Unix - it can contain passwords for internet services so it's important that other users can't read it.
|
||||
// On Windows these are stored in the registry instead.
|
||||
#ifdef Q_OS_UNIX
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QStyleFactory>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
#include <QStringBuilder>
|
||||
|
@ -51,6 +52,9 @@
|
|||
|
||||
const char *AppearanceSettingsPage::kSettingsGroup = "Appearance";
|
||||
|
||||
const char *AppearanceSettingsPage::kStyle = "style";
|
||||
const char *AppearanceSettingsPage::kSystemThemeIcons = "system_icons";
|
||||
|
||||
const char *AppearanceSettingsPage::kUseCustomColorSet = "use-custom-set";
|
||||
const char *AppearanceSettingsPage::kForegroundColor = "foreground-color";
|
||||
const char *AppearanceSettingsPage::kBackgroundColor = "background-color";
|
||||
|
@ -69,8 +73,6 @@ const char *AppearanceSettingsPage::kOpacityLevel = "opacity_level";
|
|||
const int AppearanceSettingsPage::kDefaultBlurRadius = 0;
|
||||
const int AppearanceSettingsPage::kDefaultOpacityLevel = 40;
|
||||
|
||||
const char *AppearanceSettingsPage::kSystemThemeIcons = "system_icons";
|
||||
|
||||
const char *AppearanceSettingsPage::kTabBarSystemColor= "tab_system_color";
|
||||
const char *AppearanceSettingsPage::kTabBarGradient = "tab_gradient";
|
||||
const char *AppearanceSettingsPage::kTabBarColor = "tab_color";
|
||||
|
@ -91,6 +93,11 @@ AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog)
|
|||
ui_->setupUi(this);
|
||||
setWindowIcon(IconLoader::Load("view-media-visualization"));
|
||||
|
||||
ui_->combobox_style->addItem("default", "default");
|
||||
for (const QString &style : QStyleFactory::keys()) {
|
||||
ui_->combobox_style->addItem(style, style);
|
||||
}
|
||||
|
||||
ui_->combobox_backgroundimageposition->setItemData(0, BackgroundImagePosition_UpperLeft);
|
||||
ui_->combobox_backgroundimageposition->setItemData(1, BackgroundImagePosition_UpperRight);
|
||||
ui_->combobox_backgroundimageposition->setItemData(2, BackgroundImagePosition_Middle);
|
||||
|
@ -140,6 +147,12 @@ void AppearanceSettingsPage::Load() {
|
|||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
ComboBoxLoadFromSettings(s, ui_->combobox_style, kStyle, "default");
|
||||
|
||||
#if !defined(Q_OS_MACOS) && !defined(Q_OS_WIN)
|
||||
ui_->checkbox_system_icons->setChecked(s.value(kSystemThemeIcons, false).toBool());
|
||||
#endif
|
||||
|
||||
QPalette p = QApplication::palette();
|
||||
|
||||
// Keep in mind originals colors, in case the user clicks on Cancel, to be able to restore colors
|
||||
|
@ -197,10 +210,6 @@ void AppearanceSettingsPage::Load() {
|
|||
ui_->blur_slider->setValue(s.value(kBlurRadius, kDefaultBlurRadius).toInt());
|
||||
ui_->opacity_slider->setValue(s.value(kOpacityLevel, kDefaultOpacityLevel).toInt());
|
||||
|
||||
#if !defined(Q_OS_MACOS) && !defined(Q_OS_WIN)
|
||||
ui_->checkbox_system_icons->setChecked(s.value(kSystemThemeIcons, false).toBool());
|
||||
#endif
|
||||
|
||||
ui_->checkbox_background_image_keep_aspect_ratio->setEnabled(ui_->checkbox_background_image_stretch->isChecked());
|
||||
ui_->checkbox_background_image_do_not_cut->setEnabled(ui_->checkbox_background_image_stretch->isChecked() && ui_->checkbox_background_image_keep_aspect_ratio->isChecked());
|
||||
|
||||
|
@ -222,8 +231,16 @@ void AppearanceSettingsPage::Load() {
|
|||
void AppearanceSettingsPage::Save() {
|
||||
|
||||
QSettings s;
|
||||
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
s.setValue("style", ui_->combobox_style->currentText());
|
||||
|
||||
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||
s.setValue(kSystemThemeIcons, false);
|
||||
#else
|
||||
s.setValue(kSystemThemeIcons, ui_->checkbox_system_icons->isChecked());
|
||||
#endif
|
||||
|
||||
bool use_a_custom_color_set = ui_->use_a_custom_color_set->isChecked();
|
||||
s.setValue(kUseCustomColorSet, use_a_custom_color_set);
|
||||
if (use_a_custom_color_set) {
|
||||
|
@ -269,12 +286,6 @@ void AppearanceSettingsPage::Save() {
|
|||
s.setValue(kBlurRadius, ui_->blur_slider->value());
|
||||
s.setValue(kOpacityLevel, ui_->opacity_slider->value());
|
||||
|
||||
#if defined(Q_OS_MACOS) || defined(Q_OS_WIN)
|
||||
s.setValue(kSystemThemeIcons, false);
|
||||
#else
|
||||
s.setValue(kSystemThemeIcons, ui_->checkbox_system_icons->isChecked());
|
||||
#endif
|
||||
|
||||
s.setValue(kTabBarSystemColor, ui_->tabbar_system_color->isChecked());
|
||||
s.setValue(kTabBarGradient, ui_->tabbar_gradient->isChecked());
|
||||
s.setValue(kTabBarColor, current_tabbar_bg_color_);
|
||||
|
|
|
@ -44,6 +44,8 @@ class AppearanceSettingsPage : public SettingsPage {
|
|||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
static const char *kStyle;
|
||||
|
||||
static const char *kUseCustomColorSet;
|
||||
static const char *kForegroundColor;
|
||||
static const char *kBackgroundColor;
|
||||
|
|
|
@ -14,6 +14,56 @@
|
|||
<string>Appearance</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layout_appearancesettingspage">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupbox_style">
|
||||
<property name="title">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_style">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_style">
|
||||
<property name="text">
|
||||
<string>Style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="combobox_style"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_style">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_system_icons">
|
||||
<property name="text">
|
||||
<string>Use system theme icons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Settings require restart.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupbox_colors">
|
||||
<property name="title">
|
||||
|
@ -562,13 +612,6 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_system_icons">
|
||||
<property name="text">
|
||||
<string>Use system theme icons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_bottom">
|
||||
<property name="orientation">
|
||||
|
@ -613,7 +656,6 @@
|
|||
<tabstop>spinbox_icon_size_playlist_buttons</tabstop>
|
||||
<tabstop>spinbox_icon_size_left_panel_buttons</tabstop>
|
||||
<tabstop>spinbox_icon_size_configure_buttons</tabstop>
|
||||
<tabstop>checkbox_system_icons</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
|
Loading…
Reference in New Issue