Skip to content

Commit ac2ab9f

Browse files
vkconfig: Add Vulkan SDK release detection
1 parent 0ed717a commit ac2ab9f

7 files changed

+251
-39
lines changed

vkconfig_gui/file_downloader.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2020-2025 Valve Corporation
3+
* Copyright (c) 2020-2025 LunarG, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* Authors:
18+
* - Christophe Riccio <[email protected]>
19+
*/
20+
21+
#include "file_downloader.h"
22+
23+
#include <QNetworkRequest>
24+
25+
FileDownloader::FileDownloader(QUrl url, QObject* parent) : QObject(parent) {
26+
connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)), this, SLOT(fileDownloaded(QNetworkReply*)));
27+
28+
QNetworkRequest request(url);
29+
m_WebCtrl.get(request);
30+
}
31+
32+
FileDownloader::~FileDownloader() {}
33+
34+
void FileDownloader::fileDownloaded(QNetworkReply* pReply) {
35+
m_DownloadedData = pReply->readAll();
36+
// emit a signal
37+
pReply->deleteLater();
38+
emit downloaded();
39+
}
40+
41+
QByteArray FileDownloader::downloadedData() const { return m_DownloadedData; }

vkconfig_gui/file_downloader.h

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2020-2025 Valve Corporation
3+
* Copyright (c) 2020-2025 LunarG, Inc.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
* Authors:
18+
* - Christophe Riccio <[email protected]>
19+
*/
20+
21+
#pragma once
22+
23+
#include <QObject>
24+
#include <QByteArray>
25+
#include <QNetworkAccessManager>
26+
#include <QNetworkReply>
27+
28+
class FileDownloader : public QObject {
29+
Q_OBJECT
30+
31+
public:
32+
explicit FileDownloader(QUrl url, QObject* parent = 0);
33+
virtual ~FileDownloader();
34+
QByteArray downloadedData() const;
35+
36+
signals:
37+
void downloaded();
38+
39+
private slots:
40+
void fileDownloaded(QNetworkReply* pReply);
41+
42+
private:
43+
QNetworkAccessManager m_WebCtrl;
44+
QByteArray m_DownloadedData;
45+
};

vkconfig_gui/mainwindow.cpp

+22-3
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,29 @@ MainWindow::MainWindow(QWidget *parent)
8383

8484
this->InitTray();
8585
this->UpdateUI(UPDATE_REBUILD_UI);
86+
87+
this->_last_release = new FileDownloader(QUrl("https://vulkan.lunarg.com/sdk/latest.json"), this);
88+
this->connect(this->_last_release, SIGNAL(downloaded()), this, SLOT(on_last_release_downloaded()));
8689
}
8790

8891
MainWindow::~MainWindow() {}
8992

93+
void MainWindow::on_last_release_downloaded() {
94+
QJsonParseError parse_error;
95+
QJsonDocument json_doc = QJsonDocument::fromJson(_last_release->downloadedData(), &parse_error);
96+
const QJsonObject &json_root_object = json_doc.object();
97+
std::string new_version = json_root_object.value("windows").toString().toStdString();
98+
99+
QMessageBox alert(this);
100+
alert.setWindowTitle("A new version of the Vulkan SDK is available");
101+
alert.setText(new_version.c_str());
102+
alert.setIcon(QMessageBox::Question);
103+
alert.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
104+
alert.setDefaultButton(QMessageBox::Ok);
105+
alert.setCheckBox(new QCheckBox("Do not show again."));
106+
alert.exec();
107+
}
108+
90109
void MainWindow::commitDataRequest(QSessionManager &manager) {
91110
(void)manager;
92111

@@ -288,9 +307,9 @@ void MainWindow::closeEvent(QCloseEvent *event) {
288307
alert.setDefaultButton(QMessageBox::Ok);
289308
alert.setCheckBox(new QCheckBox("Do not show again."));
290309

291-
QPalette palette, palette_saved = this->ui->settings_keep_running->palette();
310+
QPalette palette, palette_saved = this->ui->preferences_keep_running->palette();
292311
palette.setColor(QPalette::WindowText, QColor(Qt::red));
293-
this->ui->settings_keep_running->setPalette(palette);
312+
this->ui->preferences_keep_running->setPalette(palette);
294313

295314
this->ui->tab_widget->setCurrentIndex(TAB_PREFERENCES);
296315

@@ -299,7 +318,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
299318
configurator.Set(HIDE_MESSAGE_USE_SYSTEM_TRAY);
300319
}
301320

302-
this->ui->settings_keep_running->setPalette(palette_saved);
321+
this->ui->preferences_keep_running->setPalette(palette_saved);
303322

304323
if (ret_val == QMessageBox::Cancel) {
305324
event->ignore(); // Not closing the window

vkconfig_gui/mainwindow.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "../vkconfig_core/type_executable_mode.h"
2525

26+
#include "file_downloader.h"
2627
#include "tab_configurations.h"
2728
#include "tab_layers.h"
2829
#include "tab_applications.h"
@@ -59,18 +60,21 @@ class MainWindow : public QMainWindow {
5960
std::unique_ptr<QDialog> vk_info_dialog;
6061
std::unique_ptr<QDialog> vk_installation_dialog;
6162

62-
QSystemTrayIcon *_tray_icon;
63-
QMenu *_tray_icon_menu;
64-
QAction *_tray_restore_action;
63+
QSystemTrayIcon *_tray_icon = nullptr;
64+
QMenu *_tray_icon_menu = nullptr;
65+
QAction *_tray_restore_action = nullptr;
6566
std::array<QAction *, EXECUTABLE_SCOPE_COUNT> _tray_layers;
66-
QAction *_tray_quit_action;
67+
QAction *_tray_quit_action = nullptr;
68+
FileDownloader *_last_release = nullptr;
6769

6870
private slots:
6971
void trayActionRestore();
7072
void on_tray_none(bool checked);
7173
void on_tray_any(bool checked);
7274
void on_tray_all(bool checked);
7375
void on_tray_per(bool checked);
76+
void on_last_release_downloaded();
77+
7478
void iconActivated(QSystemTrayIcon::ActivationReason reason);
7579

7680
public Q_SLOTS:

0 commit comments

Comments
 (0)