Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit f715cc4a authored by Alexander Volkov's avatar Alexander Volkov Committed by Jan Grulich

Set parent window for dialogs

Summary:
This requires fix in Qt to work for standard dialogs:
https://codereview.qt-project.org/#/c/248559/

Reviewers: jgrulich, apol

Reviewed By: apol

Subscribers: graesslin, broulik, apol, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D17659
parent 9f0c704e
......@@ -69,6 +69,7 @@ find_package(KF5 ${KF5_MIN_VERSION} REQUIRED
Notifications
Wayland
WidgetsAddons
WindowSystem
)
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
......
......@@ -20,6 +20,7 @@ set(xdg_desktop_portal_kde_SRCS
screenshot.cpp
screenshotdialog.cpp
settings.cpp
utils.cpp
)
if (SCREENCAST_ENABLED)
......@@ -58,6 +59,7 @@ target_link_libraries(xdg-desktop-portal-kde
KF5::Notifications
KF5::WaylandClient
KF5::WidgetsAddons
KF5::WindowSystem
)
if (SCREENCAST_ENABLED)
......
......@@ -19,6 +19,7 @@
#include "access.h"
#include "accessdialog.h"
#include "utils.h"
#include <QLoggingCategory>
......@@ -54,6 +55,7 @@ uint AccessPortal::AccessDialog(const QDBusObjectPath &handle,
qCDebug(XdgDesktopPortalKdeAccess) << " options: " << options;
auto accessDialog = new ::AccessDialog();
Utils::setParentWindow(accessDialog, parent_window);
accessDialog->setBody(body);
accessDialog->setTitle(title);
accessDialog->setSubtitle(subtitle);
......
......@@ -19,6 +19,7 @@
#include "appchooser.h"
#include "appchooserdialog.h"
#include "utils.h"
#include <QLoggingCategory>
......@@ -57,6 +58,7 @@ uint AppChooserPortal::ChooseApplication(const QDBusObjectPath &handle,
AppChooserDialog *appDialog = new AppChooserDialog(choices, latestChoice, options.value(QLatin1String("filename")).toString());
m_appChooserDialogs.insert(handle.path(), appDialog);
Utils::setParentWindow(appDialog, parent_window);
int result = appDialog->exec();
......
......@@ -19,6 +19,7 @@
*/
#include "filechooser.h"
#include "utils.h"
#include <QDialogButtonBox>
#include <QDBusMetaType>
......@@ -180,6 +181,7 @@ uint FileChooserPortal::OpenFile(const QDBusObjectPath &handle,
}
QScopedPointer<FileDialog, QScopedPointerDeleteLater> fileDialog(new FileDialog());
Utils::setParentWindow(fileDialog.data(), parent_window);
fileDialog->setWindowTitle(title);
fileDialog->setModal(modalDialog);
fileDialog->m_fileWidget->setMode(multipleFiles ? KFile::Mode::File | KFile::Mode::ExistingOnly : KFile::Mode::Files | KFile::Mode::ExistingOnly);
......@@ -270,6 +272,7 @@ uint FileChooserPortal::SaveFile(const QDBusObjectPath &handle,
}
QScopedPointer<FileDialog, QScopedPointerDeleteLater> fileDialog(new FileDialog());
Utils::setParentWindow(fileDialog.data(), parent_window);
fileDialog->setWindowTitle(title);
fileDialog->setModal(modalDialog);
fileDialog->m_fileWidget->setOperationMode(KFileWidget::Saving);
......
......@@ -19,6 +19,7 @@
*/
#include "print.h"
#include "utils.h"
#include <KProcess>
......@@ -599,6 +600,7 @@ uint PrintPortal::PreparePrint(const QDBusObjectPath &handle,
printer->setPageMargins(pageMargins, QPageLayout::Millimeter);
QPrintDialog *printDialog = new QPrintDialog(printer);
Utils::setParentWindow(printDialog, parent_window);
// Process options
......
......@@ -22,6 +22,7 @@
#include "screenchooserdialog.h"
#include "session.h"
#include "waylandintegration.h"
#include "utils.h"
#include <QLoggingCategory>
......@@ -144,6 +145,7 @@ uint ScreenCastPortal::Start(const QDBusObjectPath &handle,
}
QScopedPointer<ScreenChooserDialog, QScopedPointerDeleteLater> screenDialog(new ScreenChooserDialog(app_id, session->multipleSources()));
Utils::setParentWindow(screenDialog.data(), parent_window);
if (screenDialog->exec()) {
WaylandIntegration::WaylandOutput selectedOutput = WaylandIntegration::screens().value(screenDialog->selectedScreens().first());
......
......@@ -20,6 +20,7 @@
#include "screenshot.h"
#include "screenshotdialog.h"
#include "utils.h"
#include <QColorDialog>
#include <QDateTime>
......@@ -99,6 +100,7 @@ uint ScreenshotPortal::Screenshot(const QDBusObjectPath &handle,
qCDebug(XdgDesktopPortalKdeScreenshot) << " options: " << options;
QPointer<ScreenshotDialog> screenshotDialog = new ScreenshotDialog;
Utils::setParentWindow(screenshotDialog, parent_window);
const bool modal = options.value(QLatin1String("modal"), false).toBool();
screenshotDialog->setModal(modal);
......
/*
* Copyright © 2018 Alexander Volkov <a.volkov@rusbitech.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "utils.h"
#include <KWindowSystem>
#include <QString>
#include <QWidget>
#include <QWindow>
void Utils::setParentWindow(QWidget *w, const QString &parent_window)
{
if (parent_window.startsWith(QLatin1String("x11:"))) {
KWindowSystem::setMainWindow(w, parent_window.midRef(4).toULongLong(nullptr, 16));
}
}
/*
* Copyright © 2018 Alexander Volkov <a.volkov@rusbitech.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XDG_DESKTOP_PORTAL_KDE_UTILS_H
#define XDG_DESKTOP_PORTAL_KDE_UTILS_H
class QString;
class QWidget;
class Utils
{
public:
static void setParentWindow(QWidget *w, const QString &parent_window);
};
#endif // XDG_DESKTOP_PORTAL_KDE_UTILS_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment