Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d2f5413

Browse files
committedFeb 12, 2025·
vkconfig: Add Vulkan SDK release detection
1 parent 0ed717a commit d2f5413

File tree

7 files changed

+250
-39
lines changed

7 files changed

+250
-39
lines changed
 

‎vkconfig_core/file_downloader.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 <christophe@lunarg.com>
19+
*/
20+
21+
#include "file_downloader.h"
22+
23+
FileDownloader::FileDownloader(QUrl imageUrl, QObject* parent) : QObject(parent) {
24+
connect(&m_WebCtrl, SIGNAL(finished(QNetworkReply*)), this, SLOT(fileDownloaded(QNetworkReply*)));
25+
26+
QNetworkRequest request(imageUrl);
27+
m_WebCtrl.get(request);
28+
}
29+
30+
FileDownloader::~FileDownloader() {}
31+
32+
void FileDownloader::fileDownloaded(QNetworkReply* pReply) {
33+
m_DownloadedData = pReply->readAll();
34+
// emit a signal
35+
pReply->deleteLater();
36+
emit downloaded();
37+
}
38+
39+
QByteArray FileDownloader::downloadedData() const { return m_DownloadedData; }

‎vkconfig_core/file_downloader.h

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 <christophe@lunarg.com>
19+
*/
20+
21+
#pragma once
22+
23+
#include <QObject>
24+
#include <QByteArray>
25+
#include <QNetworkAccessManager>
26+
#include <QNetworkRequest>
27+
#include <QNetworkReply>
28+
29+
class FileDownloader : public QObject {
30+
Q_OBJECT
31+
32+
public:
33+
explicit FileDownloader(QUrl imageUrl, QObject* parent = 0);
34+
virtual ~FileDownloader();
35+
QByteArray downloadedData() const;
36+
37+
signals:
38+
void downloaded();
39+
40+
private slots:
41+
void fileDownloaded(QNetworkReply* pReply);
42+
43+
private:
44+
QNetworkAccessManager m_WebCtrl;
45+
QByteArray m_DownloadedData;
46+
};

‎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
@@ -22,6 +22,7 @@
2222
#pragma once
2323

2424
#include "../vkconfig_core/type_executable_mode.h"
25+
#include "../vkconfig_core/file_downloader.h"
2526

2627
#include "tab_configurations.h"
2728
#include "tab_layers.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:

‎vkconfig_gui/mainwindow.ui

+109-8
Large diffs are not rendered by default.

‎vkconfig_gui/tab_preferences.cpp

+24-24
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@
2727
#include <QMessageBox>
2828

2929
TabPreferences::TabPreferences(MainWindow &window, std::shared_ptr<Ui::MainWindow> ui) : Tab(TAB_DIAGNOSTIC, window, ui) {
30-
this->ui->settings_reset->setIcon(::Get(::ICON_RESET));
31-
this->ui->settings_vk_home_browse->setIcon(::Get(::ICON_FOLDER_SEARCH));
32-
33-
this->connect(this->ui->settings_keep_running, SIGNAL(toggled(bool)), this, SLOT(on_keep_running_toggled(bool)));
34-
this->connect(this->ui->settings_vk_home_text, SIGNAL(returnPressed()), this, SLOT(on_vk_home_text_pressed()));
35-
this->connect(this->ui->settings_vk_home_browse, SIGNAL(clicked()), this, SLOT(on_vk_home_browse_pressed()));
36-
this->connect(this->ui->settings_reset, SIGNAL(clicked()), this, SLOT(on_reset_hard_pressed()));
37-
this->connect(this->ui->settings_layer_dev_mode, SIGNAL(toggled(bool)), this, SLOT(on_layer_dev_mode_toggled(bool)));
30+
this->ui->preferences_reset->setIcon(::Get(::ICON_RESET));
31+
this->ui->preferences_vk_home_browse->setIcon(::Get(::ICON_FOLDER_SEARCH));
32+
33+
this->connect(this->ui->preferences_keep_running, SIGNAL(toggled(bool)), this, SLOT(on_keep_running_toggled(bool)));
34+
this->connect(this->ui->preferences_vk_home_text, SIGNAL(returnPressed()), this, SLOT(on_vk_home_text_pressed()));
35+
this->connect(this->ui->preferences_vk_home_browse, SIGNAL(clicked()), this, SLOT(on_vk_home_browse_pressed()));
36+
this->connect(this->ui->preferences_reset, SIGNAL(clicked()), this, SLOT(on_reset_hard_pressed()));
37+
this->connect(this->ui->preferences_layer_dev_mode, SIGNAL(toggled(bool)), this, SLOT(on_layer_dev_mode_toggled(bool)));
3838
}
3939

4040
TabPreferences::~TabPreferences() {}
@@ -44,18 +44,18 @@ void TabPreferences::UpdateUI(UpdateUIMode mode) {
4444

4545
Configurator &configurator = Configurator::Get();
4646

47-
this->ui->settings_keep_running->blockSignals(true);
48-
this->ui->settings_keep_running->setChecked(configurator.GetUseSystemTray());
49-
this->ui->settings_keep_running->blockSignals(false);
47+
this->ui->preferences_keep_running->blockSignals(true);
48+
this->ui->preferences_keep_running->setChecked(configurator.GetUseSystemTray());
49+
this->ui->preferences_keep_running->blockSignals(false);
5050

51-
this->ui->settings_vk_home_text->blockSignals(true);
52-
this->ui->settings_vk_home_text->setText(::Path(Path::HOME).RelativePath().c_str());
53-
this->ui->settings_vk_home_text->setToolTip(::Path(Path::HOME).AbsolutePath().c_str());
54-
this->ui->settings_vk_home_text->blockSignals(false);
51+
this->ui->preferences_vk_home_text->blockSignals(true);
52+
this->ui->preferences_vk_home_text->setText(::Path(Path::HOME).RelativePath().c_str());
53+
this->ui->preferences_vk_home_text->setToolTip(::Path(Path::HOME).AbsolutePath().c_str());
54+
this->ui->preferences_vk_home_text->blockSignals(false);
5555

56-
this->ui->settings_layer_dev_mode->blockSignals(true);
57-
this->ui->settings_layer_dev_mode->setChecked(configurator.GetUseLayerDevMode());
58-
this->ui->settings_layer_dev_mode->blockSignals(false);
56+
this->ui->preferences_layer_dev_mode->blockSignals(true);
57+
this->ui->preferences_layer_dev_mode->setChecked(configurator.GetUseLayerDevMode());
58+
this->ui->preferences_layer_dev_mode->blockSignals(false);
5959
}
6060

6161
void TabPreferences::CleanUI() {}
@@ -73,30 +73,30 @@ void TabPreferences::on_keep_running_toggled(bool checked) {
7373
}
7474

7575
void TabPreferences::on_vk_home_text_pressed() {
76-
Path path(this->ui->settings_vk_home_text->text().toStdString());
76+
Path path(this->ui->preferences_vk_home_text->text().toStdString());
7777
if (path.Exists()) {
78-
::SetHomePath(this->ui->settings_vk_home_text->text().toStdString());
78+
::SetHomePath(this->ui->preferences_vk_home_text->text().toStdString());
7979
} else {
8080
QMessageBox message;
8181
message.setIcon(QMessageBox::Critical);
8282
message.setWindowTitle("Invalid ${VK_HOME} path...");
8383
message.setText(
84-
format("'%s' is not a valid, it doesn't exist.", this->ui->settings_vk_home_text->text().toStdString().c_str())
84+
format("'%s' is not a valid, it doesn't exist.", this->ui->preferences_vk_home_text->text().toStdString().c_str())
8585
.c_str());
8686
message.setInformativeText(format("Restoring the previous path '%s'.", ::Path(Path::HOME).AbsolutePath().c_str()).c_str());
8787
message.exec();
8888

89-
this->ui->settings_vk_home_text->setText(::Path(Path::HOME).AbsolutePath().c_str());
89+
this->ui->preferences_vk_home_text->setText(::Path(Path::HOME).AbsolutePath().c_str());
9090
}
9191
}
9292

9393
void TabPreferences::on_vk_home_browse_pressed() {
9494
const QString selected_path = QFileDialog::getExistingDirectory(
95-
this->ui->settings_vk_home_browse, "Select the Vulkan Home Default Working Folder (Set ${VK_HOME} value)...",
95+
this->ui->preferences_vk_home_browse, "Select the Vulkan Home Default Working Folder (Set ${VK_HOME} value)...",
9696
::Path(Path::HOME).AbsolutePath().c_str());
9797

9898
if (!selected_path.isEmpty()) {
99-
this->ui->settings_vk_home_text->setText(selected_path);
99+
this->ui->preferences_vk_home_text->setText(selected_path);
100100

101101
::SetHomePath(selected_path.toStdString());
102102
}

‎vkconfig_gui/vkconfig.pro

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ SOURCES += \
4848
../vkconfig_core/layer.cpp \
4949
../vkconfig_core/layer_manager.cpp \
5050
../vkconfig_core/layer_preset.cpp \
51+
../vkconfig_core/file_downloader.cpp \
5152
../vkconfig_core/parameter.cpp \
5253
../vkconfig_core/path.cpp \
5354
../vkconfig_core/registry.cpp \
@@ -130,6 +131,7 @@ HEADERS += \
130131
../vkconfig_core/layer.h \
131132
../vkconfig_core/layer_manager.h \
132133
../vkconfig_core/layer_preset.h \
134+
../vkconfig_core/file_downloader.h \
133135
../vkconfig_core/parameter.h \
134136
../vkconfig_core/path.h \
135137
../vkconfig_core/registry.h \

0 commit comments

Comments
 (0)
Please sign in to comment.