diff --git a/utils/dialog/main.cpp b/utils/dialog/main.cpp index 0e2c449..55a7d08 100644 --- a/utils/dialog/main.cpp +++ b/utils/dialog/main.cpp @@ -14,7 +14,7 @@ int main(int argc, char* argv[]) { qputenv("QT_LOGGING_RULES", QByteArray("*.debug=false;qml=false")); QString appTitle; - auto dialog = new CDialog(); + auto dialog = new CDialog(); for (int i = 1; i < argc; ++i) { std::string_view arg = argv[i]; diff --git a/utils/dialog/main.qml b/utils/dialog/main.qml index 055296e..c9b8b32 100644 --- a/utils/dialog/main.qml +++ b/utils/dialog/main.qml @@ -83,6 +83,7 @@ ApplicationWindow { text: dialog.dialogButtons[index] onClicked: (e) => { dialog.onButtonPress(dialog.dialogButtons[index]) + window.close() } } } diff --git a/utils/update-screen/CMakeLists.txt b/utils/update-screen/CMakeLists.txt index abe6da5..17d2096 100644 --- a/utils/update-screen/CMakeLists.txt +++ b/utils/update-screen/CMakeLists.txt @@ -14,13 +14,15 @@ qt_standard_project_setup(REQUIRES 6.5) qt_add_executable(hyprland-update-screen main.cpp + Dialog.cpp + Dialog.hpp UpdateScreen.cpp ) qt_add_qml_module(hyprland-update-screen URI org.hyprland.update-screen VERSION 1.0 - QML_FILES main.qml + QML_FILES main.qml dialogMain.qml ) target_link_libraries(hyprland-update-screen PRIVATE diff --git a/utils/update-screen/UpdateScreen.cpp b/utils/update-screen/UpdateScreen.cpp index fe5904b..170bf9c 100644 --- a/utils/update-screen/UpdateScreen.cpp +++ b/utils/update-screen/UpdateScreen.cpp @@ -1,5 +1,7 @@ #include "UpdateScreen.hpp" + #include + #include #include using namespace Hyprutils::String; @@ -9,9 +11,6 @@ CUpdateScreen::CUpdateScreen(QObject* parent) : QObject(parent) { } void CUpdateScreen::onButtonPress(QString buttonName) { - if (buttonName == "dontshow") { - Hyprutils::OS::CProcess proc("hyprland-dialog", {"--title", "Information", "--text", "If you wish to disable this dialog, set ecosystem:no_update_news to true in your Hyprland config.", "--buttons", "ok"}); - proc.runAsync(); - } else if (buttonName == "quit") + if (buttonName == "quit") exit(0); } diff --git a/utils/update-screen/main.cpp b/utils/update-screen/main.cpp index 45bc5ff..0afec02 100644 --- a/utils/update-screen/main.cpp +++ b/utils/update-screen/main.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "Dialog.hpp" using namespace Hyprutils::String; @@ -46,8 +47,16 @@ int main(int argc, char* argv[]) { if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) QQuickStyle::setStyle("org.kde.desktop"); + // This entire mechanism fucking sucks, + // but I also suck at qml and I want to avoid spawning a new process as it takes a while. + auto popup = new CDialog(); + popup->title = "Information"; + popup->text = "If you wish to disable this dialog, set ecosystem:no_update_news to true in your Hyprland config."; + popup->buttons = {"ok"}; + QQmlApplicationEngine engine; engine.rootContext()->setContextProperty("updateScreen", dialog); + engine.rootContext()->setContextProperty("dialog", popup); engine.load("qrc:/qt/qml/org/hyprland/update-screen/main.qml"); return app.exec(); diff --git a/utils/update-screen/main.qml b/utils/update-screen/main.qml index 3bd4fb0..e0bb96e 100644 --- a/utils/update-screen/main.qml +++ b/utils/update-screen/main.qml @@ -3,6 +3,7 @@ pragma ComponentBehavior: Bound import QtQuick import QtQuick.Controls import QtQuick.Layouts +import './' ApplicationWindow { id: window @@ -81,7 +82,9 @@ ApplicationWindow { Button { text: "Don't show this when I update" onClicked: (e) => { - updateScreen.onButtonPress("dontshow"); + var component = Qt.createComponent("dialogMain.qml") + var newWindow = component.createObject(window) + newWindow.show() } }