parent
70c8b521bd
commit
f5a0640c17
@ -1 +0,0 @@
|
||||
theme-list-enhancements.patch
|
@ -1,109 +0,0 @@
|
||||
From ccc2ede1557523ed396e488f705132f187ab750f Mon Sep 17 00:00:00 2001
|
||||
From: tsujan <tsujan2000@gmail.com>
|
||||
Date: Mon, 16 May 2022 19:05:49 +0430
|
||||
Subject: [PATCH] Small enhancement to theme list in appearance config dialog
|
||||
(#854)
|
||||
|
||||
* Small enhancement to theme list in appearance config dialog
|
||||
|
||||
Themes are always sorted alphabetically, user themes are distinguished, and theme folders can be opened by double clicking or by using context menus.
|
||||
|
||||
Closes https://github.com/lxqt/lxqt-config/issues/852
|
||||
|
||||
* Don't use `WhatsThisRole` for theme path
|
||||
|
||||
`WhatsThisRole` might be needed later for another purpose, and finding the theme path directly has no real cost.
|
||||
---
|
||||
lxqt-config-appearance/lxqtthemeconfig.cpp | 40 ++++++++++++++++++++++
|
||||
lxqt-config-appearance/lxqtthemeconfig.h | 4 +++
|
||||
2 files changed, 44 insertions(+)
|
||||
|
||||
diff --git a/lxqt-config-appearance/lxqtthemeconfig.cpp b/lxqt-config-appearance/lxqtthemeconfig.cpp
|
||||
index 49b65e8b..8bc903f8 100644
|
||||
--- a/lxqt-config-appearance/lxqtthemeconfig.cpp
|
||||
+++ b/lxqt-config-appearance/lxqtthemeconfig.cpp
|
||||
@@ -32,6 +32,11 @@
|
||||
#include <QProcess>
|
||||
#include <QItemDelegate>
|
||||
#include <QPainter>
|
||||
+#include <QMenu>
|
||||
+#include <QDesktopServices>
|
||||
+#include <QUrl>
|
||||
+
|
||||
+#include <XdgDirs>
|
||||
|
||||
/*!
|
||||
* \brief Simple delegate to draw system background color below decoration/icon
|
||||
@@ -84,6 +89,10 @@ LXQtThemeConfig::LXQtThemeConfig(LXQt::Settings *settings, QWidget *parent) :
|
||||
{
|
||||
QString themeName = theme.name();
|
||||
themeName[0] = themeName[0].toTitleCase();
|
||||
+ if (theme.path().contains(XdgDirs::dataHome(false) + QStringLiteral("/")))
|
||||
+ {
|
||||
+ themeName += QStringLiteral(" ") + tr("(User Theme)");
|
||||
+ }
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList(themeName));
|
||||
if (!theme.previewImage().isEmpty())
|
||||
{
|
||||
@@ -93,11 +102,16 @@ LXQtThemeConfig::LXQtThemeConfig(LXQt::Settings *settings, QWidget *parent) :
|
||||
item->setData(0, Qt::UserRole, theme.name());
|
||||
ui->lxqtThemeList->addTopLevelItem(item);
|
||||
}
|
||||
+ ui->lxqtThemeList->sortItems(0, Qt::AscendingOrder);
|
||||
+ ui->lxqtThemeList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
initControls();
|
||||
|
||||
connect(ui->lxqtThemeList, &QTreeWidget::currentItemChanged, this, &LXQtThemeConfig::settingsChanged);
|
||||
connect(ui->wallpaperOverride, &QAbstractButton::clicked, this, &LXQtThemeConfig::settingsChanged);
|
||||
+
|
||||
+ connect(ui->lxqtThemeList, &QTreeWidget::itemDoubleClicked, this, &LXQtThemeConfig::doubleClicked);
|
||||
+ connect(ui->lxqtThemeList, &QWidget::customContextMenuRequested, this, &LXQtThemeConfig::contextMenu);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,3 +159,29 @@ void LXQtThemeConfig::applyLxqtTheme()
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+void LXQtThemeConfig::doubleClicked(QTreeWidgetItem *item, int /*column*/)
|
||||
+{
|
||||
+ if (!item)
|
||||
+ return;
|
||||
+
|
||||
+ LXQt::LXQtTheme theme{item->data(0, Qt::UserRole).toString()};
|
||||
+ if (!theme.isValid())
|
||||
+ return;
|
||||
+
|
||||
+ // first try "qtxdg-mat"; fall back to QDesktopServices if we are not inside an LXQt session
|
||||
+ if (!QProcess::startDetached(QStringLiteral("qtxdg-mat"), QStringList() << QStringLiteral("open") << theme.path()))
|
||||
+ {
|
||||
+ QDesktopServices::openUrl(QUrl(theme.path()));
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void LXQtThemeConfig::contextMenu(const QPoint& p)
|
||||
+{
|
||||
+ QMenu menu;
|
||||
+ QAction *a = menu.addAction(tr("Open theme folder"));
|
||||
+ connect(a, &QAction::triggered, [this, p] {
|
||||
+ doubleClicked(ui->lxqtThemeList->itemAt(p), 0);
|
||||
+ });
|
||||
+ menu.exec(ui->lxqtThemeList->viewport()->mapToGlobal(p));
|
||||
+}
|
||||
diff --git a/lxqt-config-appearance/lxqtthemeconfig.h b/lxqt-config-appearance/lxqtthemeconfig.h
|
||||
index 8846dbbe..1886738c 100644
|
||||
--- a/lxqt-config-appearance/lxqtthemeconfig.h
|
||||
+++ b/lxqt-config-appearance/lxqtthemeconfig.h
|
||||
@@ -53,6 +53,10 @@ public slots:
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
+private slots:
|
||||
+ void doubleClicked(QTreeWidgetItem *item, int column);
|
||||
+ void contextMenu(const QPoint& p);
|
||||
+
|
||||
private:
|
||||
Ui::LXQtThemeConfig *ui;
|
||||
LXQt::Settings *mSettings;
|
Loading…
Reference in new issue