Skip to content

Commit

Permalink
fix: Start/Stop Ollama icon not match.
Browse files Browse the repository at this point in the history
  • Loading branch information
imoize committed Sep 27, 2024
1 parent 977f020 commit fd5e479
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 23 deletions.
14 changes: 2 additions & 12 deletions package/contents/ui/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function endAll() {
}

function checkStat() {
const url = cfg.ollamaUrl + "/api/tags";
const url = cfg.ollamaUrl + "/api/version";

const xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
Expand All @@ -286,28 +286,18 @@ function checkStat() {
getModels();
}
ollamaRunning = true;
updateActionButton("Stop Ollama", Qt.resolvedUrl("icons/stop.svg"), "stopOllama");

// console.log("Ollama Running: " + ollamaRunning + " | Ollama is running");
} else {
endAll();
ollamaRunning = false;
models.clear();
runningModels.clear();
updateActionButton("Start Ollama", Qt.resolvedUrl("icons/start.svg"), "startOllama");

// console.log("Ollama Running: " + ollamaRunning + " | Ollama is not running");
console.error("Error Check Status: " + xhr.status);
}
}
};
xhr.send();
}

function updateActionButton(text, iconName, command) {
if (typeof actionButton !== "undefined") {
actionButton.text = i18n(text);
actionButton.icon.name = iconName;
actionButton.command = command;
}
}
}
15 changes: 4 additions & 11 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,10 @@ PlasmoidItem {
Plasmoid.contextualActions: [
PlasmaCore.Action {
id: actionButton
property string command: "startOllama"
text: i18n("Start Ollama")
icon.name: Qt.resolvedUrl("icons/start.svg")
enabled: cfg.ollamaUrl.startsWith("http://localhost") || cfg.ollamaUrl.startsWith("http://127.0.0.1")
onTriggered: {
if (command === "startOllama") {
Utils.commands["startOllama"].run();
} else if (command === "stopOllama") {
Utils.commands["stopOllama"].run();
}
}
text: ollamaRunning ? i18n("Stop Ollama") : i18n("Start Ollama")
icon.name: ollamaRunning ? Qt.resolvedUrl("icons/oc-stop.svg") : Qt.resolvedUrl("icons/oc-start.svg")
onTriggered: ollamaRunning ? Utils.commands["stopOllama"].run() : Utils.commands["startOllama"].run()
}
]

Expand Down Expand Up @@ -132,7 +125,7 @@ PlasmoidItem {
anchors.fill: parent
active: compact.containsMouse
activeFocusOnTab: true
source: Qt.resolvedUrl("icons/ollama-symbolic.svg")
source: Qt.resolvedUrl("icons/oc-ollama-symbolic.svg")
}
}

Expand Down

0 comments on commit fd5e479

Please sign in to comment.