@@ -121,8 +121,6 @@ MainWindow::MainWindow(QWidget *parent)
121
121
122
122
connect (ui->launcher_loader_debug , SIGNAL (currentIndexChanged (int )), this , SLOT (OnLauncherLoaderMessageChanged (int )));
123
123
124
- ui->check_box_persistent ->setToolTip (" Keep Vulkan Configurator running in system tray when closing the main window" );
125
-
126
124
Configurator &configurator = Configurator::Get ();
127
125
Environment &environment = configurator.environment ;
128
126
@@ -133,6 +131,7 @@ MainWindow::MainWindow(QWidget *parent)
133
131
ui->splitter_2 ->restoreState (environment.Get (VKCONFIG2_LAYOUT_MAIN_SPLITTER2));
134
132
ui->splitter_3 ->restoreState (environment.Get (VKCONFIG2_LAYOUT_MAIN_SPLITTER3));
135
133
134
+ ui->check_box_persistent ->setToolTip (" Keep Vulkan Configurator running in system tray when closing the main window" );
136
135
ui->check_box_persistent ->setVisible (QSystemTrayIcon::isSystemTrayAvailable ());
137
136
138
137
LoadConfigurationList ();
@@ -550,10 +549,45 @@ void MainWindow::on_check_box_apply_list_clicked() {
550
549
}
551
550
552
551
void MainWindow::on_check_box_persistent_clicked () {
553
- Configurator &configurator = Configurator::Get ();
552
+ if (!QSystemTrayIcon::isSystemTrayAvailable ()) {
553
+ return ;
554
+ }
554
555
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 ());
557
591
}
558
592
559
593
void MainWindow::on_check_box_clear_on_launch_clicked () {
@@ -786,42 +820,6 @@ void MainWindow::OnHelpGPUInfo(bool checked) {
786
820
void MainWindow::closeEvent (QCloseEvent *event) {
787
821
Environment &environment = Configurator::Get ().environment ;
788
822
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
-
825
823
// If a child process is still running, destroy it
826
824
if (_launch_application) {
827
825
ResetLaunchApplication ();
0 commit comments