GlosSIConfig: option to "Auto" restart Steam on close

pull/183/head
Peter Repukat 2 years ago
parent dd3476c303
commit 0c9c30bfb1

@ -275,6 +275,16 @@ void UIModel::enableSteamInputXboxSupport()
} }
} }
bool UIModel::restartSteam()
{
const auto path = getSteamPath();
if (QProcess::execute("taskkill.exe", {"/im", steam_executable_name_, "/f"}) != 0) {
return false;
}
QProcess::startDetached(QString::fromStdWString(path) + "/" + steam_executable_name_);
return true;
}
void UIModel::updateCheck() void UIModel::updateCheck()
{ {
auto manager = new QNetworkAccessManager(); auto manager = new QNetworkAccessManager();

@ -50,16 +50,15 @@ class UIModel : public QObject {
Q_INVOKABLE QVariantMap manualProps(QVariant shortcut); Q_INVOKABLE QVariantMap manualProps(QVariant shortcut);
Q_INVOKABLE void enableSteamInputXboxSupport(); Q_INVOKABLE void enableSteamInputXboxSupport();
Q_INVOKABLE bool restartSteam();
Q_INVOKABLE void updateCheck(); Q_INVOKABLE void updateCheck();
#ifdef _WIN32 #ifdef _WIN32
Q_INVOKABLE QVariantList uwpApps(); Q_INVOKABLE QVariantList uwpApps();
#endif #endif
[[nodiscard]] bool writeShortcutsVDF( [[nodiscard]] bool writeShortcutsVDF(const std::wstring& mode, const std::wstring& name,
const std::wstring& mode, const std::wstring& shortcutspath, bool is_admin_try = false) const;
const std::wstring& name,
const std::wstring& shortcutspath,
bool is_admin_try = false) const;
bool getIsWindows() const; bool getIsWindows() const;
[[nodiscard]] bool hasAcrylicEffect() const; [[nodiscard]] bool hasAcrylicEffect() const;
@ -87,6 +86,7 @@ class UIModel : public QObject {
QString shortcutsfile_ = "/config/shortcuts.vdf"; QString shortcutsfile_ = "/config/shortcuts.vdf";
QString user_config_file_ = "/config/localconfig.vdf"; QString user_config_file_ = "/config/localconfig.vdf";
QString user_data_path_ = "/userdata/"; QString user_data_path_ = "/userdata/";
QString steam_executable_name_ = "steam.exe";
QVariantList targets_; QVariantList targets_;

@ -76,7 +76,34 @@ Window {
InfoDialog { InfoDialog {
id: steamChangedDialog id: steamChangedDialog
titleText: qsTr("Steam shortcuts changed!") titleText: qsTr("Steam shortcuts changed!")
text: qsTr("Please restart Steam to reload your changes") text: qsTr("You have to restart Steam before your changes become visible")
onConfirmed: function (callback) {
callback();
}
}
InfoDialog {
id: steamChangedOnCloseDialog
titleText: qsTr("Steam shortcuts changed!")
text: qsTr("Please restart Steam to reload your changes\nRestart Steam now?")
onConfirmed: function (closeWindow) {
if (uiModel.restartSteam()) {
closeWindow();
} else {
// meh I really should write a dialogUtil or some shit...
failedRestartingSteamDialog.confirmedParam = closeWindow;
failedRestartingSteamDialog.open();
}
}
buttonText: qsTr("Yes")
extraButton: true
extraButtonText: qsTr("No")
}
InfoDialog {
id: failedRestartingSteamDialog
titleText: qsTr("Failed restarting Steam!")
text: qsTr("You have to restart Steam before your changes become visible")
onConfirmed: function (callback) { onConfirmed: function (callback) {
callback(); callback();
} }
@ -86,9 +113,11 @@ Window {
id: newVersionDialog id: newVersionDialog
titleText: qsTr("New version available!") titleText: qsTr("New version available!")
text: qsTr("Would you like to visit the download page now?") text: qsTr("Would you like to visit the download page now?")
onConfirmed: function () { onConfirmed: function (callback) {
callback();
Qt.openUrlExternally(`https://glossi.flatspot.pictures/#downloads-${uiModel.newVersionName}`); Qt.openUrlExternally(`https://glossi.flatspot.pictures/#downloads-${uiModel.newVersionName}`);
} }
buttonText: qsTr("Yes")
extraButton: true extraButton: true
extraButtonText: qsTr("Remind me later") extraButtonText: qsTr("Remind me later")
visible: !!uiModel.newVersionName visible: !!uiModel.newVersionName
@ -136,10 +165,10 @@ Window {
text: "🗙" text: "🗙"
onClicked: steamShortcutsChanged onClicked: steamShortcutsChanged
? (function(){ ? (function(){
steamChangedDialog.confirmedParam = () => { steamChangedOnCloseDialog.confirmedParam = () => {
window.close() window.close()
} }
steamChangedDialog.open() steamChangedOnCloseDialog.open()
})() })()
: window.close() : window.close()
background: Rectangle { background: Rectangle {

Loading…
Cancel
Save