MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / selectBackgroundImage

Method selectBackgroundImage

app/src/UI/WindowManager.cpp:1066–1087  ·  view source on GitHub ↗

* @brief Opens a file dialog to allow the user to select a background image. */

Source from the content-addressed store, hash-verified

1064 * @brief Opens a file dialog to allow the user to select a background image.
1065 */
1066void 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.

Callers

nothing calls this directly

Calls 3

isEmptyMethod · 0.80
activeWindowMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected