(UX) Add open folder button next to combo boxes
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@ -19,17 +19,22 @@
|
||||
#include "ui_ThemeCustomizationWidget.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "DesktopServices.h"
|
||||
#include "ui/themes/ITheme.h"
|
||||
#include "ui/themes/ThemeManager.h"
|
||||
|
||||
ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ThemeCustomizationWidget)
|
||||
ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget* parent) : QWidget(parent), ui(new Ui::ThemeCustomizationWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
loadSettings();
|
||||
|
||||
connect(ui->iconsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyIconTheme);
|
||||
connect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyWidgetTheme);
|
||||
connect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||
&ThemeCustomizationWidget::applyWidgetTheme);
|
||||
connect(ui->backgroundCatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyCatTheme);
|
||||
|
||||
connect(ui->iconsFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getIconThemesFolder().path()); });
|
||||
connect(ui->widgetStyleFolder, &QPushButton::clicked, this, [] { DesktopServices::openDirectory(APPLICATION->themeManager()->getApplicationThemesFolder().path()); });
|
||||
}
|
||||
|
||||
ThemeCustomizationWidget::~ThemeCustomizationWidget()
|
||||
@ -40,7 +45,7 @@ ThemeCustomizationWidget::~ThemeCustomizationWidget()
|
||||
/// <summary>
|
||||
/// The layout was not quite right, so currently this just disables the UI elements, which should be hidden instead
|
||||
/// TODO FIXME
|
||||
///
|
||||
///
|
||||
/// Original Method One:
|
||||
/// ui->iconsComboBox->setVisible(features& ThemeFields::ICONS);
|
||||
/// ui->iconsLabel->setVisible(features& ThemeFields::ICONS);
|
||||
@ -48,7 +53,7 @@ ThemeCustomizationWidget::~ThemeCustomizationWidget()
|
||||
/// ui->widgetThemeLabel->setVisible(features& ThemeFields::WIDGETS);
|
||||
/// ui->backgroundCatComboBox->setVisible(features& ThemeFields::CAT);
|
||||
/// ui->backgroundCatLabel->setVisible(features& ThemeFields::CAT);
|
||||
///
|
||||
///
|
||||
/// original Method Two:
|
||||
/// if (!(features & ThemeFields::ICONS)) {
|
||||
/// ui->formLayout->setRowVisible(0, false);
|
||||
@ -61,40 +66,44 @@ ThemeCustomizationWidget::~ThemeCustomizationWidget()
|
||||
/// }
|
||||
/// </summary>
|
||||
/// <param name="features"></param>
|
||||
void ThemeCustomizationWidget::showFeatures(ThemeFields features) {
|
||||
void ThemeCustomizationWidget::showFeatures(ThemeFields features)
|
||||
{
|
||||
ui->iconsComboBox->setEnabled(features & ThemeFields::ICONS);
|
||||
ui->iconsLabel->setEnabled(features & ThemeFields::ICONS);
|
||||
ui->widgetStyleComboBox->setEnabled(features & ThemeFields::WIDGETS);
|
||||
ui->widgetThemeLabel->setEnabled(features & ThemeFields::WIDGETS);
|
||||
ui->widgetStyleLabel->setEnabled(features & ThemeFields::WIDGETS);
|
||||
ui->backgroundCatComboBox->setEnabled(features & ThemeFields::CAT);
|
||||
ui->backgroundCatLabel->setEnabled(features & ThemeFields::CAT);
|
||||
}
|
||||
|
||||
void ThemeCustomizationWidget::applyIconTheme(int index) {
|
||||
void ThemeCustomizationWidget::applyIconTheme(int index)
|
||||
{
|
||||
auto settings = APPLICATION->settings();
|
||||
auto originalIconTheme = settings->get("IconTheme").toString();
|
||||
auto newIconTheme = ui->iconsComboBox->currentData().toString();
|
||||
if (originalIconTheme != newIconTheme) {
|
||||
settings->set("IconTheme", newIconTheme);
|
||||
APPLICATION->applyCurrentlySelectedTheme();
|
||||
APPLICATION->themeManager()->applyCurrentlySelectedTheme();
|
||||
}
|
||||
|
||||
emit currentIconThemeChanged(index);
|
||||
}
|
||||
|
||||
void ThemeCustomizationWidget::applyWidgetTheme(int index) {
|
||||
void ThemeCustomizationWidget::applyWidgetTheme(int index)
|
||||
{
|
||||
auto settings = APPLICATION->settings();
|
||||
auto originalAppTheme = settings->get("ApplicationTheme").toString();
|
||||
auto newAppTheme = ui->widgetStyleComboBox->currentData().toString();
|
||||
if (originalAppTheme != newAppTheme) {
|
||||
settings->set("ApplicationTheme", newAppTheme);
|
||||
APPLICATION->applyCurrentlySelectedTheme();
|
||||
APPLICATION->themeManager()->applyCurrentlySelectedTheme();
|
||||
}
|
||||
|
||||
emit currentWidgetThemeChanged(index);
|
||||
}
|
||||
|
||||
void ThemeCustomizationWidget::applyCatTheme(int index) {
|
||||
void ThemeCustomizationWidget::applyCatTheme(int index)
|
||||
{
|
||||
auto settings = APPLICATION->settings();
|
||||
settings->set("BackgroundCat", m_catOptions[index].first);
|
||||
|
||||
@ -113,7 +122,7 @@ void ThemeCustomizationWidget::loadSettings()
|
||||
|
||||
{
|
||||
auto currentIconTheme = settings->get("IconTheme").toString();
|
||||
auto iconThemes = APPLICATION->getValidIconThemes();
|
||||
auto iconThemes = APPLICATION->themeManager()->getValidIconThemes();
|
||||
int idx = 0;
|
||||
for (auto iconTheme : iconThemes) {
|
||||
QIcon iconForComboBox = QIcon(iconTheme->path() + "/scalable/settings");
|
||||
@ -127,7 +136,7 @@ void ThemeCustomizationWidget::loadSettings()
|
||||
|
||||
{
|
||||
auto currentTheme = settings->get("ApplicationTheme").toString();
|
||||
auto themes = APPLICATION->getValidApplicationThemes();
|
||||
auto themes = APPLICATION->themeManager()->getValidApplicationThemes();
|
||||
int idx = 0;
|
||||
for (auto& theme : themes) {
|
||||
ui->widgetStyleComboBox->addItem(theme->name(), theme->id());
|
||||
|
@ -40,20 +40,40 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="iconsComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="iconsLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="iconsComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="iconsFolder">
|
||||
<property name="toolTip">
|
||||
<string>View icon themes folder.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="viewfolder"/>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="widgetThemeLabel">
|
||||
<widget class="QLabel" name="widgetStyleLabel">
|
||||
<property name="text">
|
||||
<string>&Widgets</string>
|
||||
</property>
|
||||
@ -63,17 +83,37 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="widgetStyleComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="widgetStyleLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="widgetStyleComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="widgetStyleFolder">
|
||||
<property name="toolTip">
|
||||
<string>View widget themes folder.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="viewfolder"/>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="backgroundCatLabel">
|
||||
@ -89,7 +129,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QHBoxLayout" name="catLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="backgroundCatComboBox">
|
||||
<property name="sizePolicy">
|
||||
@ -127,6 +167,12 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>iconsComboBox</tabstop>
|
||||
<tabstop>widgetStyleComboBox</tabstop>
|
||||
<tabstop>backgroundCatComboBox</tabstop>
|
||||
<tabstop>catInfoLabel</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Reference in New Issue
Block a user