* @brief Opens a file dialog to allow the user to select a background image. */
| 1064 | * @brief Opens a file dialog to allow the user to select a background image. |
| 1065 | */ |
| 1066 | void UI::WindowManager::selectBackgroundImage() |
| 1067 | { |
| 1068 | auto* dialog = new QFileDialog(qApp->activeWindow(), |
| 1069 | tr("Select Background Image"), |
| 1070 | QStandardPaths::writableLocation(QStandardPaths::PicturesLocation), |
| 1071 | tr("Images (*.png *.jpg *.jpeg *.bmp)")); |
| 1072 | |
| 1073 | dialog->setFileMode(QFileDialog::ExistingFile); |
| 1074 | dialog->setAttribute(Qt::WA_DeleteOnClose); |
| 1075 | |
| 1076 | connect(dialog, &QFileDialog::fileSelected, this, [this](const QString& path) { |
| 1077 | if (path.isEmpty()) |
| 1078 | return; |
| 1079 | |
| 1080 | QMetaObject::invokeMethod( |
| 1081 | this, |
| 1082 | [this, path]() { setBackgroundImage(QUrl::fromLocalFile(path).toString()); }, |
| 1083 | Qt::QueuedConnection); |
| 1084 | }); |
| 1085 | |
| 1086 | dialog->open(); |
| 1087 | } |
| 1088 | |
| 1089 | /** |
| 1090 | * @brief Brings a window to the front by increasing its z-order. |
nothing calls this directly
no test coverage detected