mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-25 05:52:50 -05:00
themes: incorporate theme registry, browser, dms URI scheme handling
This commit is contained in:
@@ -63,6 +63,7 @@ Singleton {
|
||||
property alias dankBarRightWidgetsModel: rightWidgetsModel
|
||||
|
||||
property string currentThemeName: "blue"
|
||||
property string currentThemeCategory: "generic"
|
||||
property string customThemeFile: ""
|
||||
property string matugenScheme: "scheme-tonal-spot"
|
||||
property bool runUserMatugenTemplates: true
|
||||
@@ -562,10 +563,12 @@ Singleton {
|
||||
|
||||
function applyStoredTheme() {
|
||||
if (typeof Theme !== "undefined") {
|
||||
Theme.currentThemeCategory = currentThemeCategory;
|
||||
Theme.switchTheme(currentThemeName, false, false);
|
||||
} else {
|
||||
Qt.callLater(function () {
|
||||
if (typeof Theme !== "undefined") {
|
||||
Theme.currentThemeCategory = currentThemeCategory;
|
||||
Theme.switchTheme(currentThemeName, false, false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -474,24 +474,32 @@ Singleton {
|
||||
|
||||
if (themeName === dynamic) {
|
||||
currentTheme = dynamic;
|
||||
currentThemeCategory = dynamic;
|
||||
if (currentThemeCategory !== "registry")
|
||||
currentThemeCategory = dynamic;
|
||||
} else if (themeName === custom) {
|
||||
currentTheme = custom;
|
||||
currentThemeCategory = custom;
|
||||
if (currentThemeCategory !== "registry")
|
||||
currentThemeCategory = custom;
|
||||
if (typeof SettingsData !== "undefined" && SettingsData.customThemeFile) {
|
||||
loadCustomThemeFromFile(SettingsData.customThemeFile);
|
||||
}
|
||||
} else if (themeName === "" && currentThemeCategory === "registry") {
|
||||
// Registry category selected but no theme chosen yet
|
||||
} else {
|
||||
currentTheme = themeName;
|
||||
if (StockThemes.isCatppuccinVariant(themeName)) {
|
||||
currentThemeCategory = "catppuccin";
|
||||
} else {
|
||||
currentThemeCategory = "generic";
|
||||
if (currentThemeCategory !== "registry") {
|
||||
if (StockThemes.isCatppuccinVariant(themeName)) {
|
||||
currentThemeCategory = "catppuccin";
|
||||
} else {
|
||||
currentThemeCategory = "generic";
|
||||
}
|
||||
}
|
||||
}
|
||||
const isGreeterMode = (typeof SessionData !== "undefined" && SessionData.isGreeterMode);
|
||||
if (savePrefs && typeof SettingsData !== "undefined" && !isGreeterMode)
|
||||
if (savePrefs && typeof SettingsData !== "undefined" && !isGreeterMode) {
|
||||
SettingsData.set("currentThemeCategory", currentThemeCategory);
|
||||
SettingsData.set("currentThemeName", currentTheme);
|
||||
}
|
||||
|
||||
if (!isGreeterMode) {
|
||||
generateSystemThemesFromCurrentTheme();
|
||||
|
||||
@@ -7,6 +7,7 @@ function percentToUnit(v) {
|
||||
|
||||
var SPEC = {
|
||||
currentThemeName: { def: "blue", onChange: "applyStoredTheme" },
|
||||
currentThemeCategory: { def: "generic" },
|
||||
customThemeFile: { def: "" },
|
||||
matugenScheme: { def: "scheme-tonal-spot", onChange: "regenSystemThemes" },
|
||||
runUserMatugenTemplates: { def: true, onChange: "regenSystemThemes" },
|
||||
|
||||
@@ -510,6 +510,22 @@ Item {
|
||||
Connections {
|
||||
target: DMSService
|
||||
function onOpenUrlRequested(url) {
|
||||
if (url.startsWith("dms://theme/install/")) {
|
||||
var themeId = url.replace("dms://theme/install/", "").split(/[?#]/)[0];
|
||||
if (themeId) {
|
||||
PopoutService.pendingThemeInstall = themeId;
|
||||
PopoutService.openSettingsWithTab("theme");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (url.startsWith("dms://plugin/install/")) {
|
||||
var pluginId = url.replace("dms://plugin/install/", "").split(/[?#]/)[0];
|
||||
if (pluginId) {
|
||||
PopoutService.pendingPluginInstall = pluginId;
|
||||
PopoutService.openSettingsWithTab("plugins");
|
||||
}
|
||||
return;
|
||||
}
|
||||
browserPickerModal.url = url;
|
||||
browserPickerModal.open();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import qs.Common
|
||||
import qs.Modals.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
@@ -15,6 +16,7 @@ FloatingWindow {
|
||||
property bool keyboardNavigationActive: false
|
||||
property bool isLoading: false
|
||||
property var parentModal: null
|
||||
property bool pendingInstallHandled: false
|
||||
|
||||
function updateFilteredPlugins() {
|
||||
var filtered = [];
|
||||
@@ -61,16 +63,22 @@ FloatingWindow {
|
||||
keyboardNavigationActive = false;
|
||||
}
|
||||
|
||||
function installPlugin(pluginName) {
|
||||
ToastService.showInfo("Installing plugin: " + pluginName);
|
||||
function installPlugin(pluginName, enableAfterInstall) {
|
||||
ToastService.showInfo(I18n.tr("Installing: %1", "installation progress").arg(pluginName));
|
||||
DMSService.install(pluginName, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError("Install failed: " + response.error);
|
||||
ToastService.showError(I18n.tr("Install failed: %1", "installation error").arg(response.error));
|
||||
return;
|
||||
}
|
||||
ToastService.showInfo("Plugin installed: " + pluginName);
|
||||
ToastService.showInfo(I18n.tr("Installed: %1", "installation success").arg(pluginName));
|
||||
PluginService.scanPlugins();
|
||||
refreshPlugins();
|
||||
if (enableAfterInstall) {
|
||||
Qt.callLater(() => {
|
||||
PluginService.enablePlugin(pluginName);
|
||||
hide();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -81,13 +89,27 @@ FloatingWindow {
|
||||
DMSService.listInstalled();
|
||||
}
|
||||
|
||||
function checkPendingInstall() {
|
||||
if (!PopoutService.pendingPluginInstall || pendingInstallHandled)
|
||||
return;
|
||||
pendingInstallHandled = true;
|
||||
var pluginId = PopoutService.pendingPluginInstall;
|
||||
PopoutService.pendingPluginInstall = "";
|
||||
urlInstallConfirm.showWithOptions({
|
||||
title: I18n.tr("Install Plugin", "plugin installation dialog title"),
|
||||
message: I18n.tr("Install plugin '%1' from the DMS registry?", "plugin installation confirmation").arg(pluginId),
|
||||
confirmText: I18n.tr("Install", "install action button"),
|
||||
cancelText: I18n.tr("Cancel"),
|
||||
onConfirm: () => installPlugin(pluginId, true),
|
||||
onCancel: () => hide()
|
||||
});
|
||||
}
|
||||
|
||||
function show() {
|
||||
if (parentModal)
|
||||
parentModal.shouldHaveFocus = false;
|
||||
visible = true;
|
||||
Qt.callLater(() => {
|
||||
browserSearchField.forceActiveFocus();
|
||||
});
|
||||
Qt.callLater(() => browserSearchField.forceActiveFocus());
|
||||
}
|
||||
|
||||
function hide() {
|
||||
@@ -102,7 +124,7 @@ FloatingWindow {
|
||||
}
|
||||
|
||||
objectName: "pluginBrowser"
|
||||
title: I18n.tr("Browse Plugins")
|
||||
title: I18n.tr("Browse Plugins", "plugin browser window title")
|
||||
minimumSize: Qt.size(450, 400)
|
||||
implicitWidth: 600
|
||||
implicitHeight: 650
|
||||
@@ -111,9 +133,11 @@ FloatingWindow {
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
pendingInstallHandled = false;
|
||||
refreshPlugins();
|
||||
Qt.callLater(() => {
|
||||
browserSearchField.forceActiveFocus();
|
||||
checkPendingInstall();
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -125,6 +149,10 @@ FloatingWindow {
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
ConfirmModal {
|
||||
id: urlInstallConfirm
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: browserKeyHandler
|
||||
|
||||
@@ -171,7 +199,7 @@ FloatingWindow {
|
||||
|
||||
StyledText {
|
||||
id: headerText
|
||||
text: I18n.tr("Browse Plugins")
|
||||
text: I18n.tr("Browse Plugins", "plugin browser header")
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
@@ -225,7 +253,7 @@ FloatingWindow {
|
||||
anchors.right: parent.right
|
||||
anchors.top: headerArea.bottom
|
||||
anchors.topMargin: Theme.spacingM
|
||||
text: I18n.tr("Install plugins from the DMS plugin registry")
|
||||
text: I18n.tr("Install plugins from the DMS plugin registry", "plugin browser description")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.outline
|
||||
wrapMode: Text.WordWrap
|
||||
@@ -249,7 +277,7 @@ FloatingWindow {
|
||||
showClearButton: true
|
||||
textColor: Theme.surfaceText
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
placeholderText: I18n.tr("Search plugins...")
|
||||
placeholderText: I18n.tr("Search plugins...", "plugin search placeholder")
|
||||
text: root.searchQuery
|
||||
focus: true
|
||||
ignoreLeftRightKeys: true
|
||||
@@ -293,7 +321,7 @@ FloatingWindow {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Loading plugins...")
|
||||
text: I18n.tr("Loading...", "loading indicator")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
@@ -407,8 +435,8 @@ FloatingWindow {
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
const author = "by " + (modelData.author || "Unknown");
|
||||
const source = modelData.repo ? ` • <a href="${modelData.repo}" style="text-decoration:none; color:${Theme.primary};">source</a>` : "";
|
||||
const author = I18n.tr("by %1", "author attribution").arg(modelData.author || I18n.tr("Unknown", "unknown author"));
|
||||
const source = modelData.repo ? ` • <a href="${modelData.repo}" style="text-decoration:none; color:${Theme.primary};">${I18n.tr("source", "source code link")}</a>` : "";
|
||||
return author + source;
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
@@ -458,7 +486,7 @@ FloatingWindow {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: isInstalled ? "Installed" : "Install"
|
||||
text: isInstalled ? I18n.tr("Installed", "installed status") : I18n.tr("Install", "install action button")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
font.weight: Font.Medium
|
||||
color: isInstalled ? Theme.surfaceText : Theme.surface
|
||||
@@ -474,7 +502,7 @@ FloatingWindow {
|
||||
enabled: !isInstalled
|
||||
onClicked: {
|
||||
if (!isInstalled)
|
||||
root.installPlugin(modelData.name);
|
||||
root.installPlugin(modelData.name, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -521,7 +549,7 @@ FloatingWindow {
|
||||
|
||||
StyledText {
|
||||
anchors.centerIn: listArea
|
||||
text: I18n.tr("No plugins found")
|
||||
text: I18n.tr("No plugins found", "empty plugin list")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
visible: !root.isLoading && root.filteredPlugins.length === 0
|
||||
|
||||
@@ -387,6 +387,16 @@ FocusScope {
|
||||
pluginBrowser.parentModal = pluginsTab.parentModal;
|
||||
if (DMSService.dmsAvailable && DMSService.apiVersion >= 8)
|
||||
DMSService.listInstalled();
|
||||
if (PopoutService.pendingPluginInstall)
|
||||
Qt.callLater(() => pluginBrowser.show());
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: PopoutService
|
||||
function onPendingPluginInstallChanged() {
|
||||
if (PopoutService.pendingPluginInstall)
|
||||
pluginBrowser.show();
|
||||
}
|
||||
}
|
||||
|
||||
PluginBrowser {
|
||||
|
||||
572
quickshell/Modules/Settings/ThemeBrowser.qml
Normal file
572
quickshell/Modules/Settings/ThemeBrowser.qml
Normal file
@@ -0,0 +1,572 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import Quickshell
|
||||
import qs.Common
|
||||
import qs.Modals.Common
|
||||
import qs.Services
|
||||
import qs.Widgets
|
||||
|
||||
FloatingWindow {
|
||||
id: root
|
||||
|
||||
property var allThemes: []
|
||||
property string searchQuery: ""
|
||||
property var filteredThemes: []
|
||||
property int selectedIndex: -1
|
||||
property bool keyboardNavigationActive: false
|
||||
property bool isLoading: false
|
||||
property var parentModal: null
|
||||
property bool pendingInstallHandled: false
|
||||
property string pendingApplyThemeId: ""
|
||||
|
||||
function updateFilteredThemes() {
|
||||
var filtered = [];
|
||||
var query = searchQuery ? searchQuery.toLowerCase() : "";
|
||||
|
||||
for (var i = 0; i < allThemes.length; i++) {
|
||||
var theme = allThemes[i];
|
||||
|
||||
if (query.length === 0) {
|
||||
filtered.push(theme);
|
||||
continue;
|
||||
}
|
||||
|
||||
var name = theme.name ? theme.name.toLowerCase() : "";
|
||||
var description = theme.description ? theme.description.toLowerCase() : "";
|
||||
var author = theme.author ? theme.author.toLowerCase() : "";
|
||||
|
||||
if (name.indexOf(query) !== -1 || description.indexOf(query) !== -1 || author.indexOf(query) !== -1)
|
||||
filtered.push(theme);
|
||||
}
|
||||
|
||||
filteredThemes = filtered;
|
||||
selectedIndex = -1;
|
||||
keyboardNavigationActive = false;
|
||||
}
|
||||
|
||||
function selectNext() {
|
||||
if (filteredThemes.length === 0)
|
||||
return;
|
||||
keyboardNavigationActive = true;
|
||||
selectedIndex = Math.min(selectedIndex + 1, filteredThemes.length - 1);
|
||||
}
|
||||
|
||||
function selectPrevious() {
|
||||
if (filteredThemes.length === 0)
|
||||
return;
|
||||
keyboardNavigationActive = true;
|
||||
selectedIndex = Math.max(selectedIndex - 1, -1);
|
||||
if (selectedIndex === -1)
|
||||
keyboardNavigationActive = false;
|
||||
}
|
||||
|
||||
function installTheme(themeId, themeName, applyAfterInstall) {
|
||||
ToastService.showInfo(I18n.tr("Installing: %1", "installation progress").arg(themeName));
|
||||
DMSService.installTheme(themeId, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Install failed: %1", "installation error").arg(response.error));
|
||||
return;
|
||||
}
|
||||
ToastService.showInfo(I18n.tr("Installed: %1", "installation success").arg(themeName));
|
||||
if (applyAfterInstall)
|
||||
pendingApplyThemeId = themeId;
|
||||
refreshThemes();
|
||||
});
|
||||
}
|
||||
|
||||
function applyInstalledTheme(themeId, installedThemes) {
|
||||
for (var i = 0; i < installedThemes.length; i++) {
|
||||
var theme = installedThemes[i];
|
||||
if (theme.id === themeId) {
|
||||
var sourceDir = theme.sourceDir || theme.id;
|
||||
var themePath = Quickshell.env("HOME") + "/.config/DankMaterialShell/themes/" + sourceDir + "/theme.json";
|
||||
SettingsData.set("customThemeFile", themePath);
|
||||
Theme.switchThemeCategory("registry", "custom");
|
||||
Theme.switchTheme("custom", true, true);
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function uninstallTheme(themeId, themeName) {
|
||||
ToastService.showInfo(I18n.tr("Uninstalling: %1", "uninstallation progress").arg(themeName));
|
||||
DMSService.uninstallTheme(themeId, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Uninstall failed: %1", "uninstallation error").arg(response.error));
|
||||
return;
|
||||
}
|
||||
ToastService.showInfo(I18n.tr("Uninstalled: %1", "uninstallation success").arg(themeName));
|
||||
refreshThemes();
|
||||
});
|
||||
}
|
||||
|
||||
function refreshThemes() {
|
||||
isLoading = true;
|
||||
DMSService.listThemes();
|
||||
DMSService.listInstalledThemes();
|
||||
}
|
||||
|
||||
function checkPendingInstall() {
|
||||
if (!PopoutService.pendingThemeInstall || pendingInstallHandled)
|
||||
return;
|
||||
pendingInstallHandled = true;
|
||||
var themeId = PopoutService.pendingThemeInstall;
|
||||
PopoutService.pendingThemeInstall = "";
|
||||
urlInstallConfirm.showWithOptions({
|
||||
title: I18n.tr("Install Theme", "theme installation dialog title"),
|
||||
message: I18n.tr("Install theme '%1' from the DMS registry?", "theme installation confirmation").arg(themeId),
|
||||
confirmText: I18n.tr("Install", "install action button"),
|
||||
cancelText: I18n.tr("Cancel"),
|
||||
onConfirm: () => installTheme(themeId, themeId, true),
|
||||
onCancel: () => hide()
|
||||
});
|
||||
}
|
||||
|
||||
function show() {
|
||||
if (parentModal)
|
||||
parentModal.shouldHaveFocus = false;
|
||||
visible = true;
|
||||
Qt.callLater(() => browserSearchField.forceActiveFocus());
|
||||
}
|
||||
|
||||
function hide() {
|
||||
visible = false;
|
||||
if (!parentModal)
|
||||
return;
|
||||
parentModal.shouldHaveFocus = Qt.binding(() => parentModal.shouldBeVisible);
|
||||
Qt.callLater(() => {
|
||||
if (parentModal.modalFocusScope)
|
||||
parentModal.modalFocusScope.forceActiveFocus();
|
||||
});
|
||||
}
|
||||
|
||||
objectName: "themeBrowser"
|
||||
title: I18n.tr("Browse Themes", "theme browser window title")
|
||||
minimumSize: Qt.size(550, 450)
|
||||
implicitWidth: 700
|
||||
implicitHeight: 700
|
||||
color: Theme.surfaceContainer
|
||||
visible: false
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
pendingInstallHandled = false;
|
||||
refreshThemes();
|
||||
Qt.callLater(() => {
|
||||
browserSearchField.forceActiveFocus();
|
||||
checkPendingInstall();
|
||||
});
|
||||
return;
|
||||
}
|
||||
allThemes = [];
|
||||
searchQuery = "";
|
||||
filteredThemes = [];
|
||||
selectedIndex = -1;
|
||||
keyboardNavigationActive = false;
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
ConfirmModal {
|
||||
id: urlInstallConfirm
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: DMSService
|
||||
function onThemesListReceived(themes) {
|
||||
isLoading = false;
|
||||
allThemes = themes;
|
||||
updateFilteredThemes();
|
||||
}
|
||||
function onInstalledThemesReceived(themes) {
|
||||
if (!pendingApplyThemeId)
|
||||
return;
|
||||
var themeId = pendingApplyThemeId;
|
||||
pendingApplyThemeId = "";
|
||||
applyInstalledTheme(themeId, themes);
|
||||
}
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: browserKeyHandler
|
||||
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
|
||||
Keys.onPressed: event => {
|
||||
switch (event.key) {
|
||||
case Qt.Key_Escape:
|
||||
root.hide();
|
||||
event.accepted = true;
|
||||
return;
|
||||
case Qt.Key_Down:
|
||||
root.selectNext();
|
||||
event.accepted = true;
|
||||
return;
|
||||
case Qt.Key_Up:
|
||||
root.selectPrevious();
|
||||
event.accepted = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: browserContent
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingL
|
||||
|
||||
Item {
|
||||
id: headerArea
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
height: Math.max(headerIcon.height, headerText.height, refreshButton.height, closeButton.height)
|
||||
|
||||
DankIcon {
|
||||
id: headerIcon
|
||||
name: "palette"
|
||||
size: Theme.iconSize
|
||||
color: Theme.primary
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: headerText
|
||||
text: I18n.tr("Browse Themes", "theme browser header")
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
anchors.left: headerIcon.right
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
DankActionButton {
|
||||
id: refreshButton
|
||||
iconName: "refresh"
|
||||
iconSize: 18
|
||||
iconColor: Theme.primary
|
||||
visible: !root.isLoading
|
||||
onClicked: root.refreshThemes()
|
||||
}
|
||||
|
||||
DankActionButton {
|
||||
id: closeButton
|
||||
iconName: "close"
|
||||
iconSize: Theme.iconSize - 2
|
||||
iconColor: Theme.outline
|
||||
onClicked: root.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: descriptionText
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: headerArea.bottom
|
||||
anchors.topMargin: Theme.spacingM
|
||||
text: I18n.tr("Install color themes from the DMS theme registry", "theme browser description")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.outline
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
|
||||
DankTextField {
|
||||
id: browserSearchField
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: descriptionText.bottom
|
||||
anchors.topMargin: Theme.spacingM
|
||||
height: 48
|
||||
cornerRadius: Theme.cornerRadius
|
||||
backgroundColor: Theme.withAlpha(Theme.surfaceContainerHigh, Theme.popupTransparency)
|
||||
normalBorderColor: Theme.outlineMedium
|
||||
focusedBorderColor: Theme.primary
|
||||
leftIconName: "search"
|
||||
leftIconSize: Theme.iconSize
|
||||
leftIconColor: Theme.surfaceVariantText
|
||||
leftIconFocusedColor: Theme.primary
|
||||
showClearButton: true
|
||||
textColor: Theme.surfaceText
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
placeholderText: I18n.tr("Search themes...", "theme search placeholder")
|
||||
text: root.searchQuery
|
||||
focus: true
|
||||
ignoreLeftRightKeys: true
|
||||
keyForwardTargets: [browserKeyHandler]
|
||||
onTextEdited: {
|
||||
root.searchQuery = text;
|
||||
root.updateFilteredThemes();
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: listArea
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: browserSearchField.bottom
|
||||
anchors.topMargin: Theme.spacingM
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: Theme.spacingM
|
||||
|
||||
Item {
|
||||
anchors.fill: parent
|
||||
visible: root.isLoading
|
||||
|
||||
Column {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingM
|
||||
|
||||
DankIcon {
|
||||
name: "sync"
|
||||
size: 48
|
||||
color: Theme.primary
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
RotationAnimator on rotation {
|
||||
from: 0
|
||||
to: 360
|
||||
duration: 1000
|
||||
loops: Animation.Infinite
|
||||
running: root.isLoading
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Loading...", "loading indicator")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DankListView {
|
||||
id: themeBrowserList
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: Theme.spacingM
|
||||
anchors.rightMargin: Theme.spacingM
|
||||
anchors.topMargin: Theme.spacingS
|
||||
anchors.bottomMargin: Theme.spacingS
|
||||
spacing: Theme.spacingS
|
||||
model: ScriptModel {
|
||||
values: root.filteredThemes
|
||||
}
|
||||
clip: true
|
||||
visible: !root.isLoading
|
||||
|
||||
ScrollBar.vertical: DankScrollbar {
|
||||
id: browserScrollbar
|
||||
}
|
||||
|
||||
delegate: Rectangle {
|
||||
width: themeBrowserList.width
|
||||
height: hasPreview ? 140 : themeDelegateContent.implicitHeight + Theme.spacingM * 2
|
||||
radius: Theme.cornerRadius
|
||||
property bool isSelected: root.keyboardNavigationActive && index === root.selectedIndex
|
||||
property bool isInstalled: modelData.installed || false
|
||||
property bool isFirstParty: modelData.firstParty || false
|
||||
property string previewPath: "/tmp/dankdots-plugin-registry/themes/" + (modelData.sourceDir || modelData.id) + "/preview-" + (Theme.isLightMode ? "light" : "dark") + ".svg"
|
||||
property bool hasPreview: previewImage.status === Image.Ready
|
||||
color: isSelected ? Theme.primarySelected : Qt.rgba(Theme.surfaceVariant.r, Theme.surfaceVariant.g, Theme.surfaceVariant.b, 0.3)
|
||||
border.color: isSelected ? Theme.primary : Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||
border.width: isSelected ? 2 : 1
|
||||
|
||||
Row {
|
||||
id: themeDelegateContent
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingM
|
||||
spacing: Theme.spacingM
|
||||
|
||||
Rectangle {
|
||||
width: hasPreview ? 180 : 0
|
||||
height: parent.height
|
||||
radius: Theme.cornerRadius - 2
|
||||
color: Theme.surfaceContainerHigh
|
||||
visible: hasPreview
|
||||
|
||||
Image {
|
||||
id: previewImage
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
source: "file://" + previewPath
|
||||
fillMode: Image.PreserveAspectFit
|
||||
smooth: true
|
||||
mipmap: true
|
||||
}
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
name: "palette"
|
||||
size: 48
|
||||
color: Theme.primary
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
visible: !hasPreview
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width - (hasPreview ? 180 : 48) - Theme.spacingM - installButton.width - Theme.spacingM
|
||||
spacing: 6
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Row {
|
||||
spacing: Theme.spacingXS
|
||||
width: parent.width
|
||||
|
||||
StyledText {
|
||||
text: modelData.name
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
elide: Text.ElideRight
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
height: 18
|
||||
width: versionText.implicitWidth + Theme.spacingS
|
||||
radius: 9
|
||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.15)
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
StyledText {
|
||||
id: versionText
|
||||
anchors.centerIn: parent
|
||||
text: modelData.version || "1.0.0"
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.outline
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
height: 18
|
||||
width: firstPartyText.implicitWidth + Theme.spacingS
|
||||
radius: 9
|
||||
color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.15)
|
||||
border.color: Qt.rgba(Theme.primary.r, Theme.primary.g, Theme.primary.b, 0.4)
|
||||
border.width: 1
|
||||
visible: isFirstParty
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
StyledText {
|
||||
id: firstPartyText
|
||||
anchors.centerIn: parent
|
||||
text: I18n.tr("official")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.primary
|
||||
font.weight: Font.Medium
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("by %1", "author attribution").arg(modelData.author || I18n.tr("Unknown", "unknown author"))
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.outline
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: modelData.description || ""
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
width: parent.width
|
||||
wrapMode: Text.WordWrap
|
||||
maximumLineCount: 3
|
||||
elide: Text.ElideRight
|
||||
visible: modelData.description && modelData.description.length > 0
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: installButton
|
||||
width: 90
|
||||
height: 36
|
||||
radius: Theme.cornerRadius
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
color: isInstalled ? (uninstallMouseArea.containsMouse ? Theme.error : Theme.surfaceVariant) : Theme.primary
|
||||
opacity: installMouseArea.containsMouse || uninstallMouseArea.containsMouse ? 0.9 : 1
|
||||
border.width: isInstalled ? 1 : 0
|
||||
border.color: isInstalled ? (uninstallMouseArea.containsMouse ? Theme.error : Theme.outline) : "transparent"
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.standardEasing
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Theme.shortDuration
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.centerIn: parent
|
||||
spacing: Theme.spacingXS
|
||||
|
||||
DankIcon {
|
||||
name: isInstalled ? (uninstallMouseArea.containsMouse ? "delete" : "check") : "download"
|
||||
size: 16
|
||||
color: isInstalled ? (uninstallMouseArea.containsMouse ? "white" : Theme.surfaceText) : Theme.surface
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: {
|
||||
if (!isInstalled)
|
||||
return I18n.tr("Install", "install action button");
|
||||
if (uninstallMouseArea.containsMouse)
|
||||
return I18n.tr("Uninstall", "uninstall action button");
|
||||
return I18n.tr("Installed", "installed status");
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
color: isInstalled ? (uninstallMouseArea.containsMouse ? "white" : Theme.surfaceText) : Theme.surface
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: installMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
visible: !isInstalled
|
||||
onClicked: root.installTheme(modelData.id, modelData.name, false)
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: uninstallMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
visible: isInstalled
|
||||
onClicked: root.uninstallTheme(modelData.id, modelData.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
anchors.centerIn: listArea
|
||||
text: I18n.tr("No themes found", "empty theme list")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceVariantText
|
||||
visible: !root.isLoading && root.filteredThemes.length === 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,9 +12,29 @@ Item {
|
||||
|
||||
property var cachedIconThemes: SettingsData.availableIconThemes
|
||||
property var cachedMatugenSchemes: Theme.availableMatugenSchemes.map(option => option.label)
|
||||
property var installedRegistryThemes: []
|
||||
|
||||
Component.onCompleted: {
|
||||
SettingsData.detectAvailableIconThemes();
|
||||
if (DMSService.dmsAvailable)
|
||||
DMSService.listInstalledThemes();
|
||||
if (PopoutService.pendingThemeInstall)
|
||||
Qt.callLater(() => themeBrowser.show());
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: DMSService
|
||||
function onInstalledThemesReceived(themes) {
|
||||
themeColorsTab.installedRegistryThemes = themes;
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: PopoutService
|
||||
function onPendingThemeInstallChanged() {
|
||||
if (PopoutService.pendingThemeInstall)
|
||||
themeBrowser.show();
|
||||
}
|
||||
}
|
||||
|
||||
DankFlickable {
|
||||
@@ -41,12 +61,24 @@ Item {
|
||||
spacing: Theme.spacingS
|
||||
|
||||
StyledText {
|
||||
property string registryThemeName: {
|
||||
if (Theme.currentThemeCategory !== "registry")
|
||||
return "";
|
||||
for (var i = 0; i < themeColorsTab.installedRegistryThemes.length; i++) {
|
||||
var t = themeColorsTab.installedRegistryThemes[i];
|
||||
if (SettingsData.customThemeFile && SettingsData.customThemeFile.endsWith((t.sourceDir || t.id) + "/theme.json"))
|
||||
return t.name;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
text: {
|
||||
if (Theme.currentTheme === Theme.dynamic)
|
||||
return "Current Theme: Dynamic";
|
||||
return I18n.tr("Current Theme: %1", "current theme label").arg(I18n.tr("Dynamic", "dynamic theme name"));
|
||||
if (Theme.currentThemeCategory === "registry" && registryThemeName)
|
||||
return I18n.tr("Current Theme: %1", "current theme label").arg(registryThemeName);
|
||||
if (Theme.currentThemeCategory === "catppuccin")
|
||||
return "Current Theme: Catppuccin " + Theme.getThemeColors(Theme.currentThemeName).name;
|
||||
return "Current Theme: " + Theme.getThemeColors(Theme.currentThemeName).name;
|
||||
return I18n.tr("Current Theme: %1", "current theme label").arg("Catppuccin " + Theme.getThemeColors(Theme.currentThemeName).name);
|
||||
return I18n.tr("Current Theme: %1", "current theme label").arg(Theme.getThemeColors(Theme.currentThemeName).name);
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
color: Theme.surfaceText
|
||||
@@ -57,12 +89,14 @@ Item {
|
||||
StyledText {
|
||||
text: {
|
||||
if (Theme.currentTheme === Theme.dynamic)
|
||||
return "Material colors generated from wallpaper";
|
||||
return I18n.tr("Material colors generated from wallpaper", "dynamic theme description");
|
||||
if (Theme.currentThemeCategory === "registry")
|
||||
return I18n.tr("Color theme from DMS registry", "registry theme description");
|
||||
if (Theme.currentThemeCategory === "catppuccin")
|
||||
return "Soothing pastel theme based on Catppuccin";
|
||||
return I18n.tr("Soothing pastel theme based on Catppuccin", "catppuccin theme description");
|
||||
if (Theme.currentTheme === Theme.custom)
|
||||
return "Custom theme loaded from JSON file";
|
||||
return "Material Design inspired color themes";
|
||||
return I18n.tr("Custom theme loaded from JSON file", "custom theme description");
|
||||
return I18n.tr("Material Design inspired color themes", "generic theme description");
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
@@ -78,7 +112,11 @@ Item {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
|
||||
DankButtonGroup {
|
||||
id: themeCategoryGroup
|
||||
property bool isRegistryTheme: Theme.currentThemeCategory === "registry"
|
||||
property int currentThemeIndex: {
|
||||
if (isRegistryTheme)
|
||||
return 4;
|
||||
if (Theme.currentTheme === Theme.dynamic)
|
||||
return 2;
|
||||
if (Theme.currentThemeName === "custom")
|
||||
@@ -89,7 +127,7 @@ Item {
|
||||
}
|
||||
property int pendingThemeIndex: -1
|
||||
|
||||
model: ["Generic", "Catppuccin", "Auto", "Custom"]
|
||||
model: DMSService.dmsAvailable ? ["Generic", "Catppuccin", "Auto", "Custom", "Registry"] : ["Generic", "Catppuccin", "Auto", "Custom"]
|
||||
currentIndex: currentThemeIndex
|
||||
selectionMode: "single"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
@@ -110,15 +148,17 @@ Item {
|
||||
break;
|
||||
case 2:
|
||||
if (ToastService.wallpaperErrorStatus === "matugen_missing")
|
||||
ToastService.showError("matugen not found - install matugen package for dynamic theming");
|
||||
ToastService.showError(I18n.tr("matugen not found - install matugen package for dynamic theming", "matugen error"));
|
||||
else if (ToastService.wallpaperErrorStatus === "error")
|
||||
ToastService.showError("Wallpaper processing failed - check wallpaper path");
|
||||
ToastService.showError(I18n.tr("Wallpaper processing failed - check wallpaper path", "wallpaper error"));
|
||||
else
|
||||
Theme.switchTheme(Theme.dynamic, true, true);
|
||||
Theme.switchThemeCategory("dynamic", Theme.dynamic);
|
||||
break;
|
||||
case 3:
|
||||
if (Theme.currentThemeName !== "custom")
|
||||
Theme.switchTheme("custom", true, true);
|
||||
Theme.switchThemeCategory("custom", "custom");
|
||||
break;
|
||||
case 4:
|
||||
Theme.switchThemeCategory("registry", "");
|
||||
break;
|
||||
}
|
||||
pendingThemeIndex = -1;
|
||||
@@ -388,7 +428,7 @@ Item {
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
visible: Theme.currentTheme === Theme.dynamic
|
||||
visible: Theme.currentTheme === Theme.dynamic && Theme.currentThemeCategory !== "registry"
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
@@ -450,12 +490,12 @@ Item {
|
||||
StyledText {
|
||||
text: {
|
||||
if (ToastService.wallpaperErrorStatus === "error")
|
||||
return "Wallpaper Error";
|
||||
return I18n.tr("Wallpaper Error", "wallpaper error status");
|
||||
if (ToastService.wallpaperErrorStatus === "matugen_missing")
|
||||
return "Matugen Missing";
|
||||
return I18n.tr("Matugen Missing", "matugen not found status");
|
||||
if (Theme.wallpaperPath)
|
||||
return Theme.wallpaperPath.split('/').pop();
|
||||
return "No wallpaper selected";
|
||||
return I18n.tr("No wallpaper selected", "no wallpaper status");
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Theme.surfaceText
|
||||
@@ -467,12 +507,12 @@ Item {
|
||||
StyledText {
|
||||
text: {
|
||||
if (ToastService.wallpaperErrorStatus === "error")
|
||||
return "Wallpaper processing failed";
|
||||
return I18n.tr("Wallpaper processing failed", "wallpaper processing error");
|
||||
if (ToastService.wallpaperErrorStatus === "matugen_missing")
|
||||
return "Install matugen package for dynamic theming";
|
||||
return I18n.tr("Install matugen package for dynamic theming", "matugen installation hint");
|
||||
if (Theme.wallpaperPath)
|
||||
return Theme.wallpaperPath;
|
||||
return "Dynamic colors from wallpaper";
|
||||
return I18n.tr("Dynamic colors from wallpaper", "dynamic colors description");
|
||||
}
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: (ToastService.wallpaperErrorStatus === "error" || ToastService.wallpaperErrorStatus === "matugen_missing") ? Theme.error : Theme.surfaceVariantText
|
||||
@@ -520,7 +560,7 @@ Item {
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
visible: Theme.currentThemeName === "custom"
|
||||
visible: Theme.currentThemeName === "custom" && Theme.currentThemeCategory !== "registry"
|
||||
|
||||
Row {
|
||||
width: parent.width
|
||||
@@ -541,7 +581,7 @@ Item {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
StyledText {
|
||||
text: SettingsData.customThemeFile ? SettingsData.customThemeFile.split('/').pop() : "No custom theme file"
|
||||
text: SettingsData.customThemeFile ? SettingsData.customThemeFile.split('/').pop() : I18n.tr("No custom theme file", "no custom theme file status")
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
color: Theme.surfaceText
|
||||
elide: Text.ElideMiddle
|
||||
@@ -550,7 +590,7 @@ Item {
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: SettingsData.customThemeFile || "Click to select a custom theme JSON file"
|
||||
text: SettingsData.customThemeFile || I18n.tr("Click to select a custom theme JSON file", "custom theme file hint")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
elide: Text.ElideMiddle
|
||||
@@ -560,6 +600,174 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
id: registrySection
|
||||
width: parent.width
|
||||
spacing: Theme.spacingM
|
||||
visible: Theme.currentThemeCategory === "registry"
|
||||
|
||||
Grid {
|
||||
columns: 3
|
||||
spacing: Theme.spacingS
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
visible: themeColorsTab.installedRegistryThemes.length > 0
|
||||
|
||||
Repeater {
|
||||
model: themeColorsTab.installedRegistryThemes
|
||||
|
||||
Rectangle {
|
||||
id: themeCard
|
||||
property bool isActive: Theme.currentThemeCategory === "registry" && Theme.currentThemeName === "custom" && SettingsData.customThemeFile && SettingsData.customThemeFile.endsWith((modelData.sourceDir || modelData.id) + "/theme.json")
|
||||
property string previewPath: Quickshell.env("HOME") + "/.config/DankMaterialShell/themes/" + (modelData.sourceDir || modelData.id) + "/preview-" + (Theme.isLightMode ? "light" : "dark") + ".svg"
|
||||
width: 140
|
||||
height: 100
|
||||
radius: Theme.cornerRadius
|
||||
color: Theme.surfaceVariant
|
||||
border.color: isActive ? Theme.primary : Theme.outline
|
||||
border.width: isActive ? 2 : 1
|
||||
scale: isActive ? 1.03 : 1
|
||||
|
||||
Behavior on scale {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
easing.type: Theme.emphasizedEasing
|
||||
}
|
||||
}
|
||||
|
||||
Image {
|
||||
id: previewImage
|
||||
anchors.fill: parent
|
||||
anchors.margins: 2
|
||||
source: "file://" + themeCard.previewPath
|
||||
fillMode: Image.PreserveAspectFit
|
||||
smooth: true
|
||||
mipmap: true
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "palette"
|
||||
size: 32
|
||||
color: Theme.primary
|
||||
visible: previewImage.status === Image.Error || previewImage.status === Image.Null
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
height: 24
|
||||
radius: Theme.cornerRadius
|
||||
color: Qt.rgba(0, 0, 0, 0.6)
|
||||
|
||||
StyledText {
|
||||
anchors.centerIn: parent
|
||||
text: modelData.name
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: "white"
|
||||
font.weight: Font.Medium
|
||||
elide: Text.ElideRight
|
||||
width: parent.width - Theme.spacingS * 2
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.margins: 4
|
||||
width: 20
|
||||
height: 20
|
||||
radius: 10
|
||||
color: Theme.primary
|
||||
visible: themeCard.isActive
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "check"
|
||||
size: 14
|
||||
color: Theme.surface
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: cardMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
const themesDir = Quickshell.env("HOME") + "/.config/DankMaterialShell/themes";
|
||||
const themePath = themesDir + "/" + (modelData.sourceDir || modelData.id) + "/theme.json";
|
||||
SettingsData.set("customThemeFile", themePath);
|
||||
Theme.switchTheme("custom", true, true);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: deleteButton
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.margins: 4
|
||||
width: 24
|
||||
height: 24
|
||||
radius: 12
|
||||
color: deleteMouseArea.containsMouse ? Theme.error : Qt.rgba(0, 0, 0, 0.6)
|
||||
opacity: cardMouseArea.containsMouse || deleteMouseArea.containsMouse ? 1 : 0
|
||||
visible: opacity > 0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Theme.shortDuration
|
||||
}
|
||||
}
|
||||
|
||||
DankIcon {
|
||||
anchors.centerIn: parent
|
||||
name: "close"
|
||||
size: 14
|
||||
color: "white"
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: deleteMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
ToastService.showInfo(I18n.tr("Uninstalling: %1", "uninstallation progress").arg(modelData.name));
|
||||
DMSService.uninstallTheme(modelData.id, response => {
|
||||
if (response.error) {
|
||||
ToastService.showError(I18n.tr("Uninstall failed: %1", "uninstallation error").arg(response.error));
|
||||
return;
|
||||
}
|
||||
ToastService.showInfo(I18n.tr("Uninstalled: %1", "uninstallation success").arg(modelData.name));
|
||||
DMSService.listInstalledThemes();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("No themes installed. Browse themes to install from the registry.", "no registry themes installed hint")
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceVariantText
|
||||
wrapMode: Text.WordWrap
|
||||
width: parent.width
|
||||
visible: themeColorsTab.installedRegistryThemes.length === 0
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
|
||||
DankButton {
|
||||
text: I18n.tr("Browse Themes", "browse themes button")
|
||||
iconName: "store"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
onClicked: themeBrowser.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1086,4 +1294,8 @@ Item {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ThemeBrowser {
|
||||
id: themeBrowser
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ Singleton {
|
||||
readonly property int expectedApiVersion: 1
|
||||
property var availablePlugins: []
|
||||
property var installedPlugins: []
|
||||
property var availableThemes: []
|
||||
property var installedThemes: []
|
||||
property bool isConnected: false
|
||||
property bool isConnecting: false
|
||||
property bool subscribeConnected: false
|
||||
@@ -33,6 +35,9 @@ Singleton {
|
||||
signal pluginsListReceived(var plugins)
|
||||
signal installedPluginsReceived(var plugins)
|
||||
signal searchResultsReceived(var plugins)
|
||||
signal themesListReceived(var themes)
|
||||
signal installedThemesReceived(var themes)
|
||||
signal themeSearchResultsReceived(var themes)
|
||||
signal operationSuccess(string message)
|
||||
signal operationError(string error)
|
||||
signal connectionStateChanged
|
||||
@@ -514,6 +519,82 @@ Singleton {
|
||||
});
|
||||
}
|
||||
|
||||
function listThemes(callback) {
|
||||
sendRequest("themes.list", null, response => {
|
||||
if (response.result) {
|
||||
availableThemes = response.result;
|
||||
themesListReceived(response.result);
|
||||
}
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function listInstalledThemes(callback) {
|
||||
sendRequest("themes.listInstalled", null, response => {
|
||||
if (response.result) {
|
||||
installedThemes = response.result;
|
||||
installedThemesReceived(response.result);
|
||||
}
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function searchThemes(query, callback) {
|
||||
sendRequest("themes.search", {
|
||||
"query": query
|
||||
}, response => {
|
||||
if (response.result) {
|
||||
themeSearchResultsReceived(response.result);
|
||||
}
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function installTheme(themeName, callback) {
|
||||
sendRequest("themes.install", {
|
||||
"name": themeName
|
||||
}, response => {
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
if (!response.error) {
|
||||
listInstalledThemes();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function uninstallTheme(themeName, callback) {
|
||||
sendRequest("themes.uninstall", {
|
||||
"name": themeName
|
||||
}, response => {
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
if (!response.error) {
|
||||
listInstalledThemes();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateTheme(themeName, callback) {
|
||||
sendRequest("themes.update", {
|
||||
"name": themeName
|
||||
}, response => {
|
||||
if (callback) {
|
||||
callback(response);
|
||||
}
|
||||
if (!response.error) {
|
||||
listInstalledThemes();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function lockSession(callback) {
|
||||
sendRequest("loginctl.lock", null, callback);
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@ Singleton {
|
||||
|
||||
property var notepadSlideouts: []
|
||||
|
||||
property string pendingThemeInstall: ""
|
||||
property string pendingPluginInstall: ""
|
||||
|
||||
function setPosition(popout, x, y, width, section, screen) {
|
||||
if (popout && popout.setTriggerPosition && arguments.length >= 6) {
|
||||
popout.setTriggerPosition(x, y, width, section, screen);
|
||||
|
||||
@@ -9,8 +9,8 @@ tab_bar_margin_color {{colors.background.default.hex}}
|
||||
|
||||
tab_bar_background {{colors.background.default.hex}}
|
||||
|
||||
active_tab_foreground {{colors.on_primary_container.default.hex}}
|
||||
active_tab_background {{colors.primary_container.default.hex}}
|
||||
active_tab_foreground {{colors.on_primary.default.hex}}
|
||||
active_tab_background {{colors.primary.default.hex}}
|
||||
active_tab_font_style bold
|
||||
|
||||
inactive_tab_foreground {{colors.on_surface_variant.default.hex}}
|
||||
|
||||
@@ -58,8 +58,8 @@
|
||||
//
|
||||
// Lists (files, search results, etc.)
|
||||
//
|
||||
"list.activeSelectionBackground": "{{colors.primary_container.dark.hex}}",
|
||||
"list.activeSelectionForeground": "{{colors.on_primary_container.dark.hex}}",
|
||||
"list.activeSelectionBackground": "{{colors.primary.dark.hex}}",
|
||||
"list.activeSelectionForeground": "{{colors.on_primary.dark.hex}}",
|
||||
"list.inactiveSelectionBackground": "{{colors.surface_container.dark.hex}}",
|
||||
"list.hoverBackground": "{{colors.surface_container.dark.hex}}",
|
||||
"list.hoverForeground": "{{colors.on_surface.dark.hex}}",
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
"tab.activeForeground": "{{colors.on_surface.default.hex}}",
|
||||
"tab.inactiveForeground": "{{colors.outline.default.hex}}",
|
||||
"tab.activeBorderTop": "{{colors.primary.default.hex}}",
|
||||
"list.activeSelectionBackground": "{{colors.primary_container.default.hex}}",
|
||||
"list.activeSelectionForeground": "{{colors.on_primary_container.default.hex}}",
|
||||
"list.activeSelectionBackground": "{{colors.primary.default.hex}}",
|
||||
"list.activeSelectionForeground": "{{colors.on_primary.default.hex}}",
|
||||
"list.inactiveSelectionBackground": "{{colors.surface_container.default.hex}}",
|
||||
"list.hoverBackground": "{{colors.surface_container.default.hex}}",
|
||||
"list.hoverForeground": "{{colors.on_surface.default.hex}}",
|
||||
|
||||
@@ -69,8 +69,8 @@
|
||||
"sideBarTitle.foreground": "{{colors.on_surface.light.hex}}",
|
||||
"sideBarSectionHeader.background": "{{colors.surface_container_low.light.hex}}",
|
||||
"sideBarSectionHeader.foreground": "{{colors.on_surface.light.hex}}",
|
||||
"list.activeSelectionBackground": "{{colors.primary_container.light.hex}}",
|
||||
"list.activeSelectionForeground": "{{colors.on_primary_container.light.hex}}",
|
||||
"list.activeSelectionBackground": "{{colors.primary.light.hex}}",
|
||||
"list.activeSelectionForeground": "{{colors.on_primary.light.hex}}",
|
||||
"list.inactiveSelectionBackground": "{{colors.surface_container.light.hex}}",
|
||||
"list.inactiveSelectionForeground": "{{colors.on_surface.light.hex}}",
|
||||
"list.hoverBackground": "{{colors.surface_container.light.hex}}",
|
||||
|
||||
Reference in New Issue
Block a user