Commit 81ffd780 authored by Carson Black's avatar Carson Black

Add system tray icon display, white <-> black icon conversion

parent 7f9b0704
......@@ -27,6 +27,14 @@ Kirigami.ApplicationWindow {
property var symIcons: ["checkbox", "go-previous", "edit-clear-list", "edit-find", "games-achievements", "go-down-search", "process-stop", "draw-brush"]
property string fromIconTemplate: ""
QNative.SystemTrayIcon {
id: sysTray
visible: false
icon.source: imageSource
}
onClosing: {
sysTray.visible = false
}
Shortcut {
sequence: StandardKey.Open
onActivated: picker.open()
......@@ -196,7 +204,6 @@ Kirigami.ApplicationWindow {
IconManipulator {
id: manipulator
}
title: qsTr("Ikona Design Companion")
color: Kirigami.Theme.backgroundColor
Kirigami.GlobalDrawer {
......@@ -341,7 +348,7 @@ Kirigami.ApplicationWindow {
text: "Convert Icon Colors to Classes"
onTriggered: {
if (manipulator.classIcon(imageSource)) {
root.showPassiveNotification("Your icon has been converted. You should inject stylesheets if they have not already been injected..")
root.showPassiveNotification("Your icon has been converted. You should inject stylesheets if they have not already been injected.")
} else {
root.showPassiveNotification("Something went wrong converting your icon.")
}
......@@ -358,6 +365,28 @@ Kirigami.ApplicationWindow {
}
}
}
Kirigami.Action {
iconSource: "color-picker-black"
text: "Change Icon to Light Mode"
onTriggered: {
if (manipulator.toDark(imageSource)) {
root.showPassiveNotification("Your icon has been converted.")
} else {
root.showPassiveNotification("Something went wrong converting your icon.")
}
}
}
Kirigami.Action {
iconSource: "color-picker-white"
text: "Change Icon to Dark Mode"
onTriggered: {
if (manipulator.toLight(imageSource)) {
root.showPassiveNotification("Your icon has been converted.")
} else {
root.showPassiveNotification("Something went wrong converting your icon.")
}
}
}
},
Kirigami.Action {
iconSource: "palette-symbolic"
......@@ -420,8 +449,12 @@ Kirigami.ApplicationWindow {
iconName: hud.visible ? "view-hidden" : "view-visible"
text: hud.visible ? "Close HUD" : "Open HUD"
onTriggered: hud.visible = !hud.visible
},
Kirigami.Action {
iconName: sysTray.visible ? "view-hidden" : "view-visible"
text: sysTray.visible ? "Hide Icon in Tray" : "Show Icon in Tray"
onTriggered: sysTray.visible = !sysTray.visible
}
]
}
function shuffle(a) {
......
......@@ -73,6 +73,60 @@ bool IconManipulator::classIcon(QString inputPath)
}
return false;
}
bool IconManipulator::toDark(QString inputPath)
{
QString path;
if (inputPath.startsWith("file://")) {
path = inputPath.replace("file://", "");
}
QFile icon(path);
if (icon.open( QFile::ReadWrite ))
{
QByteArray iconData = icon.readAll();
QString text(iconData);
text.replace("fill=\"#232629\"", "fill=\"#eff0f1\"");
text.replace("fill=\"#eff0f1\"", "fill=\"#31363b\"");
text.replace("fill=\"#fcfcfc\"", "fill=\"#232629\"");
text.replace("color:#232629", "color:#eff0f1");
text.replace("color:#eff0f1", "color:#31363b");
text.replace("color:#fcfcfc", "color:#232629");
icon.seek(0);
icon.write(text.toUtf8());
icon.close();
return true;
}
return false;
}
bool IconManipulator::toLight(QString inputPath)
{
QString path;
if (inputPath.startsWith("file://")) {
path = inputPath.replace("file://", "");
}
QFile icon(path);
if (icon.open( QFile::ReadWrite ))
{
QByteArray iconData = icon.readAll();
QString text(iconData);
text.replace("fill=\"#eff0f1\"", "fill=\"#232629\"");
text.replace("fill=\"#31363b\"", "fill=\"#eff0f1\"");
text.replace("fill=\"#232629\"", "fill=\"#fcfcfc\"");
text.replace("color:#eff0f1", "color:#232629");
text.replace("color:#31363b", "color:#eff0f1");
text.replace("color:#232629", "color:#fcfcfc");
icon.seek(0);
icon.write(text.toUtf8());
icon.close();
return true;
}
return false;
}
bool IconManipulator::injectStylesheet(QString inputPath)
{
QString path;
......
......@@ -8,6 +8,8 @@ public:
Q_INVOKABLE bool tidyIcon(QString inputPath);
Q_INVOKABLE bool classIcon(QString inputPath);
Q_INVOKABLE bool injectStylesheet(QString inputPath);
Q_INVOKABLE bool toDark(QString inputPath);
Q_INVOKABLE bool toLight(QString inputPath);
signals:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment