it could be that GPT already found the relevant source:
and adjusted the code in a first step:
#include <QGuiApplication>
#include <QScreen>
#include <QJsonDocument>
#include <QJsonObject>
#include <Plasma/Containment>
#include <Plasma/Corona>
#include <Plasma/Wallpaper>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
if (argc < 2) {
qWarning() << "Usage: plasma-apply-wallpaperimage <path-to-image>";
return 1;
}
QString wallpaperPath = argv[1];
// Zugriff auf Plasma-Shell
Plasma::Corona *plasma = Plasma::Corona::instance();
if (!plasma) {
qWarning() << "Could not access Plasma shell";
return 1;
}
// Über alle Bildschirme iterieren
const auto screens = QGuiApplication::screens();
for (QScreen *screen : screens) {
for (Plasma::Containment *containment : plasma->containments()) {
if (containment->screen() == screen->name()) { // Für alle Bildschirme
QJsonObject config;
config["Image"] = wallpaperPath;
containment->setWallpaper("org.kde.image", QJsonDocument(config).toJson());
qInfo() << "Wallpaper set for screen:" << screen->name();
}
}
}
return 0;
}
so, sadly GPT4 functionality is “empty” now, maybe i try grok or so. if i’m somewhere in the rright direction, then we’d “only” need to make this function (containment to all screens) bound to a checkbox “apply to all screens”…
edit:
it seems GPT3 can handle this as well. i’ll locally mirror the relevant GIT tonight (i don’t really know if i’m saying this correctly) to test if this could work - and if, i’ll let you know. This is, btw, what GPT3 says:
1. Add Checkbox to the GUI
QCheckBox *applyToAllCheckBox = new QCheckBox("Apply to all screens", this);
applyToAllCheckBox->setChecked(false); // Default is unchecked
// Add the checkbox to your layout
layout->addWidget(applyToAllCheckBox);
Step 2: Handle the Checkbox State
bool applyToAll = applyToAllCheckBox->isChecked();
if (applyToAll) {
// Apply wallpaper to all screens
for (const auto &screen : screens) {
applyWallpaperToScreen(screen);
}
} else {
// Apply wallpaper to the current screen
applyWallpaperToScreen(currentScreen);
}
Step 3: Modify the applyWallpaperToScreen
Function
void applyWallpaperToScreen(const Screen &screen) {
// Code to apply the wallpaper to a specific screen
// Use KScreen or other relevant APIs to set wallpaper for a specific screen
}
Step 4: Integrate with KDE’s Wallpaper Configuration Logic
KScreen::applyWallpaperToAllScreens(const QString &wallpaperPath) {
// Iterate through all connected screens and apply wallpaper
for (auto screen : KScreen::getScreens()) {
screen->applyWallpaper(wallpaperPath);
}
}
it maybe a complete wrong attempt, if so, i’d be happy if you could let me know
but it’s fun and worth a try