-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat: added more options for customising the user's light/dark appear…
…ance preferences
- Loading branch information
1 parent
fc061a7
commit 23907e7
Showing
5 changed files
with
199 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
package/contents/ui/components/ConfigAppearanceComboBox.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import QtQml | ||
import QtQuick | ||
import QtQuick.Controls | ||
import QtQuick.Layouts | ||
|
||
|
||
ComboBox { | ||
property bool isChangeAvailable: false | ||
property string lastText: "" | ||
|
||
Layout.column: 1 | ||
Layout.minimumWidth: 300 | ||
|
||
onCurrentTextChanged: { | ||
if (!isChangeAvailable) | ||
return; | ||
|
||
lastText = currentText; | ||
} | ||
|
||
// Functions // | ||
|
||
function configure(model) { | ||
this.model = model | ||
|
||
this.currentIndex = this.find(lastText); | ||
this.isChangeAvailable = true | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
package/contents/ui/components/ConfigAppearanceDataSource.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import QtQuick | ||
import org.kde.plasma.plasma5support as PlasmaCore | ||
|
||
|
||
PlasmaCore.DataSource { | ||
engine: "executable" | ||
connectedSources: [] | ||
|
||
enum ItemType { | ||
Unknown, | ||
ColourThemes, | ||
PlasmaThemes | ||
} | ||
|
||
property int lastItemType: ConfigAppearanceDataSource.ItemType.Unknown | ||
property var typesToFetch: [] | ||
|
||
signal itemsReady(var items, var itemType) | ||
|
||
onNewData: (sourceName, data) => { | ||
disconnectSource(sourceName); // cmd finished | ||
|
||
if (lastItemType == ConfigAppearanceDataSource.ItemType.Unknown) | ||
return; | ||
|
||
itemsReady(parseCommandOutput(data), lastItemType); | ||
processNextFetchRequest(); | ||
} | ||
|
||
// Functions // | ||
|
||
function getItems() { | ||
// TODO: Find a better way of doing this | ||
typesToFetch = [ | ||
ConfigAppearanceDataSource.ItemType.ColourThemes, | ||
ConfigAppearanceDataSource.ItemType.PlasmaThemes | ||
]; | ||
|
||
processNextFetchRequest(); | ||
} | ||
|
||
function getItemsForType(itemType) { | ||
if (itemType == ConfigAppearanceDataSource.ItemType.Unknown) { | ||
processNextFetchRequest(); | ||
return; | ||
} | ||
|
||
this.lastItemType = itemType; | ||
|
||
switch (itemType) { | ||
case ConfigAppearanceDataSource.ItemType.ColourThemes: | ||
connectSource("plasma-apply-colorscheme --list-schemes | tail --lines=+2"); | ||
break; | ||
|
||
case ConfigAppearanceDataSource.ItemType.PlasmaThemes: | ||
connectSource("plasma-apply-desktoptheme --list-themes | tail --lines=+2"); | ||
break; | ||
} | ||
} | ||
|
||
function processNextFetchRequest() { | ||
if (typesToFetch.length < 1) | ||
return; | ||
|
||
getItemsForType(typesToFetch.pop()); | ||
} | ||
|
||
function parseCommandOutput(data) { | ||
var items = data["stdout"].split("\n"); | ||
|
||
for (var i = 0; i < items.length; i++) { | ||
items[i] = items[i] | ||
.substring(3) | ||
.split(" ")[0]; | ||
} | ||
|
||
return items; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters