Skip to content

Commit b824aa6

Browse files
vkconfig: Closing main window exit by default
1 parent 28efb19 commit b824aa6

File tree

2 files changed

+42
-43
lines changed

2 files changed

+42
-43
lines changed

vkconfig/mainwindow.cpp

+39-41
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ MainWindow::MainWindow(QWidget *parent)
121121

122122
connect(ui->launcher_loader_debug, SIGNAL(currentIndexChanged(int)), this, SLOT(OnLauncherLoaderMessageChanged(int)));
123123

124-
ui->check_box_persistent->setToolTip("Keep Vulkan Configurator running in system tray when closing the main window");
125-
126124
Configurator &configurator = Configurator::Get();
127125
Environment &environment = configurator.environment;
128126

@@ -133,6 +131,7 @@ MainWindow::MainWindow(QWidget *parent)
133131
ui->splitter_2->restoreState(environment.Get(VKCONFIG2_LAYOUT_MAIN_SPLITTER2));
134132
ui->splitter_3->restoreState(environment.Get(VKCONFIG2_LAYOUT_MAIN_SPLITTER3));
135133

134+
ui->check_box_persistent->setToolTip("Keep Vulkan Configurator running in system tray when closing the main window");
136135
ui->check_box_persistent->setVisible(QSystemTrayIcon::isSystemTrayAvailable());
137136

138137
LoadConfigurationList();
@@ -550,10 +549,45 @@ void MainWindow::on_check_box_apply_list_clicked() {
550549
}
551550

552551
void MainWindow::on_check_box_persistent_clicked() {
553-
Configurator &configurator = Configurator::Get();
552+
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
553+
return;
554+
}
554555

555-
configurator.environment.SetUseSystemTray(ui->check_box_persistent->isChecked());
556-
this->UpdateTray();
556+
Environment &environment = Configurator::Get().environment;
557+
558+
// Alert the user to the current state of the vulkan configurator and
559+
// give them the option to not shutdown.
560+
QSettings settings;
561+
if (ui->check_box_persistent->isChecked() && !settings.value("vkconfig_system_tray_stay_on_close", false).toBool()) {
562+
const QPalette saved_palette = ui->check_box_persistent->palette();
563+
QPalette modified_palette = saved_palette;
564+
modified_palette.setColor(QPalette::ColorRole::WindowText, QColor(255, 0, 0, 255));
565+
ui->check_box_persistent->setPalette(modified_palette);
566+
567+
const std::string message = "Vulkan Layers will remain controlled by Vulkan Configurator while active in the system tray.";
568+
569+
QMessageBox alert(this);
570+
alert.setWindowTitle("Vulkan Configurator behavior when closing the main window");
571+
alert.setText(message.c_str());
572+
alert.setIcon(QMessageBox::Warning);
573+
alert.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
574+
alert.setDefaultButton(QMessageBox::No);
575+
alert.setCheckBox(new QCheckBox("Do not show again."));
576+
alert.setInformativeText(
577+
"Do you want to keep Vulkan Configurator running in the system tray when closing the main window?");
578+
579+
int ret_val = alert.exec();
580+
settings.setValue("vkconfig_system_tray_stay_on_close", alert.checkBox()->isChecked());
581+
582+
ui->check_box_persistent->setPalette(saved_palette);
583+
584+
if (ret_val == QMessageBox::No) {
585+
ui->check_box_persistent->setChecked(false);
586+
return;
587+
}
588+
}
589+
590+
environment.SetUseSystemTray(ui->check_box_persistent->isChecked());
557591
}
558592

559593
void MainWindow::on_check_box_clear_on_launch_clicked() {
@@ -786,42 +820,6 @@ void MainWindow::OnHelpGPUInfo(bool checked) {
786820
void MainWindow::closeEvent(QCloseEvent *event) {
787821
Environment &environment = Configurator::Get().environment;
788822

789-
// Alert the user to the current state of the vulkan configurator and
790-
// give them the option to not shutdown.
791-
if (QSystemTrayIcon::isSystemTrayAvailable()) {
792-
if (environment.GetUseSystemTray() && environment.GetMode() != LAYERS_MODE_BY_APPLICATIONS) {
793-
QSettings settings;
794-
if (!settings.value("vkconfig_system_tray", false).toBool()) {
795-
const QPalette saved_palette = ui->check_box_persistent->palette();
796-
QPalette modified_palette = saved_palette;
797-
modified_palette.setColor(QPalette::ColorRole::WindowText, QColor(255, 0, 0, 255));
798-
ui->check_box_persistent->setPalette(modified_palette);
799-
800-
const std::string message =
801-
"Vulkan Layers remains controlled by Vulkan Configurator while active in the system tray.";
802-
803-
QMessageBox alert(this);
804-
alert.setWindowTitle("Vulkan Configurator will remain active in the system tray");
805-
alert.setText(message.c_str());
806-
alert.setIcon(QMessageBox::Warning);
807-
alert.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
808-
alert.setDefaultButton(QMessageBox::No);
809-
alert.setCheckBox(new QCheckBox("Do not show again."));
810-
alert.setInformativeText("Are you still ready to move Vulkan Configurator in the system tray?");
811-
812-
int ret_val = alert.exec();
813-
settings.setValue("vkconfig_system_tray", alert.checkBox()->isChecked());
814-
815-
ui->check_box_persistent->setPalette(saved_palette);
816-
817-
if (ret_val == QMessageBox::No) {
818-
event->ignore();
819-
return;
820-
}
821-
}
822-
}
823-
}
824-
825823
// If a child process is still running, destroy it
826824
if (_launch_application) {
827825
ResetLaunchApplication();

vkconfig_core/environment.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ Environment::Environment(PathManager& paths, const Version& api_version)
153153
: api_version(api_version),
154154
loader_message_types(::GetLoaderMessageTypes(qgetenv("VK_LOADER_DEBUG").toStdString())),
155155
paths_manager(paths),
156-
paths(paths_manager) {
156+
paths(paths_manager),
157+
use_system_tray(false) {
157158
const bool result = Load();
158159
assert(result);
159160
}
@@ -171,7 +172,7 @@ void Environment::Reset(ResetMode mode) {
171172
this->vkconfig3_version = Version::VKCONFIG3;
172173
this->layers_mode = LAYERS_MODE_BY_CONFIGURATOR_RUNNING;
173174
this->use_application_list = false;
174-
this->use_system_tray = true;
175+
this->use_system_tray = false;
175176

176177
for (std::size_t i = 0; i < ACTIVE_COUNT; ++i) {
177178
actives[i] = GetActiveDefault(static_cast<Active>(i));

0 commit comments

Comments
 (0)