2014-11-13 19:30:51 +02:00
|
|
|
/*****************************************************************
|
|
|
|
ksmserver - the KDE session management server
|
|
|
|
|
|
|
|
Copyright 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
Copyright 2007 Urs Wolfer <uwolfer @ kde.org>
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
|
|
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include "shutdowndlg.h"
|
2023-09-13 06:39:50 +03:00
|
|
|
#include "kworkspace/kdisplaymanager.h"
|
2014-11-13 19:30:51 +02:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
#include <QX11Info>
|
2014-11-13 19:30:51 +02:00
|
|
|
#include <klocale.h>
|
|
|
|
#include <kwindowsystem.h>
|
2023-09-13 06:39:50 +03:00
|
|
|
#include <kdialog.h>
|
2014-11-13 19:30:51 +02:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xutil.h>
|
2014-11-13 19:30:51 +02:00
|
|
|
|
2023-09-13 15:36:31 +03:00
|
|
|
static const int s_timeout = 10; // 10secs
|
2023-09-13 06:39:50 +03:00
|
|
|
static const QSizeF s_iconsize = QSizeF(64, 64);
|
2023-09-14 10:00:56 +03:00
|
|
|
static const QSizeF s_chooseminumumsize = QSizeF(280, 130);
|
|
|
|
static const QSizeF s_nochooseminumumsize = QSizeF(280, 80);
|
2014-11-13 19:30:51 +02:00
|
|
|
|
2023-09-14 08:08:40 +03:00
|
|
|
static bool kSwitchTitleEvent(QEvent *event)
|
|
|
|
{
|
|
|
|
switch (event->type()) {
|
|
|
|
case QEvent::HoverEnter:
|
|
|
|
case QEvent::GraphicsSceneHoverEnter: {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2014-11-13 19:30:51 +02:00
|
|
|
void KSMShutdownFeedback::start()
|
|
|
|
{
|
2023-09-13 06:39:50 +03:00
|
|
|
if (KWindowSystem::compositingActive()) {
|
2023-08-30 20:12:08 +03:00
|
|
|
// Announce that the user MAY be logging out (Intended for the compositor)
|
2014-11-13 19:30:51 +02:00
|
|
|
Display* dpy = QX11Info::display();
|
2023-08-30 20:12:08 +03:00
|
|
|
Atom announce = XInternAtom(dpy, "_KDE_LOGGING_OUT", False);
|
|
|
|
unsigned char dummy = 0;
|
|
|
|
XChangeProperty(dpy, QX11Info::appRootWindow(), announce, announce, 8, PropModeReplace, &dummy, 1);
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KSMShutdownFeedback::stop()
|
|
|
|
{
|
2023-09-13 06:39:50 +03:00
|
|
|
if (KWindowSystem::compositingActive()) {
|
2023-08-30 20:12:08 +03:00
|
|
|
// No longer logging out, announce (Intended for the compositor)
|
2014-11-13 19:30:51 +02:00
|
|
|
Display* dpy = QX11Info::display();
|
|
|
|
Atom announce = XInternAtom(dpy, "_KDE_LOGGING_OUT", False);
|
|
|
|
XDeleteProperty(QX11Info::display(), QX11Info::appRootWindow(), announce);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
KSMShutdownDlg::KSMShutdownDlg(QWidget* parent,
|
|
|
|
bool maysd, bool choose, KWorkSpace::ShutdownType sdtype)
|
|
|
|
: Plasma::Dialog(parent, Qt::Dialog | Qt::WindowStaysOnTopHint),
|
|
|
|
m_scene(nullptr),
|
|
|
|
m_widget(nullptr),
|
|
|
|
m_layout(nullptr),
|
|
|
|
m_titlelabel(nullptr),
|
|
|
|
m_separator(nullptr),
|
|
|
|
m_logoutwidget(nullptr),
|
|
|
|
m_rebootwidget(nullptr),
|
|
|
|
m_haltwidget(nullptr),
|
|
|
|
m_okbutton(nullptr),
|
|
|
|
m_cancelbutton(nullptr),
|
|
|
|
m_eventloop(nullptr),
|
|
|
|
m_timer(nullptr),
|
|
|
|
m_second(s_timeout),
|
|
|
|
m_shutdownType(sdtype)
|
|
|
|
{
|
|
|
|
// make the screen gray
|
|
|
|
KSMShutdownFeedback::start();
|
|
|
|
|
|
|
|
m_scene = new QGraphicsScene(this);
|
|
|
|
m_widget = new QGraphicsWidget();
|
|
|
|
|
|
|
|
m_layout = new QGraphicsGridLayout(m_widget);
|
|
|
|
m_layout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
m_layout->setSpacing(4);
|
|
|
|
|
|
|
|
if (!choose) {
|
2023-09-14 10:00:56 +03:00
|
|
|
m_widget->setMinimumSize(s_nochooseminumumsize);
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
m_titlelabel = new Plasma::Label(m_widget);
|
|
|
|
m_titlelabel->setAlignment(Qt::AlignCenter);
|
|
|
|
m_titlelabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
m_layout->addItem(m_titlelabel, 0, 0, 1, 2);
|
|
|
|
|
|
|
|
switch (m_shutdownType) {
|
|
|
|
case KWorkSpace::ShutdownTypeReboot: {
|
|
|
|
m_titlelabel->setText(
|
|
|
|
i18np("Restarting computer in 1 second.", "Restarting computer in %1 seconds.", m_second)
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case KWorkSpace::ShutdownTypeHalt: {
|
|
|
|
m_titlelabel->setText(
|
|
|
|
i18np("Turning off computer in 1 second.", "Turning off computer in %1 seconds.", m_second)
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
m_titlelabel->setText(
|
|
|
|
i18np("Logging out in 1 second.", "Logging out in %1 seconds.", m_second)
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_okbutton = new Plasma::PushButton(m_widget);
|
2023-09-13 12:33:58 +03:00
|
|
|
m_okbutton->setText(i18n("&OK"));
|
2023-09-13 06:39:50 +03:00
|
|
|
m_okbutton->setIcon(KIcon("dialog-ok"));
|
2023-09-14 10:00:56 +03:00
|
|
|
m_okbutton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
2023-09-14 07:43:50 +03:00
|
|
|
m_okbutton->installEventFilter(this);
|
2023-09-13 06:39:50 +03:00
|
|
|
connect(
|
|
|
|
m_okbutton, SIGNAL(released()),
|
|
|
|
this, SLOT(slotOk())
|
|
|
|
);
|
|
|
|
m_layout->addItem(m_okbutton, 1, 0, 1, 1);
|
|
|
|
|
|
|
|
m_cancelbutton = new Plasma::PushButton(m_widget);
|
2023-09-13 12:33:58 +03:00
|
|
|
m_cancelbutton->setText(i18n("&Cancel"));
|
2023-09-13 06:39:50 +03:00
|
|
|
m_cancelbutton->setIcon(KIcon("dialog-cancel"));
|
2023-09-14 10:00:56 +03:00
|
|
|
m_cancelbutton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
2023-09-14 07:43:50 +03:00
|
|
|
m_cancelbutton->installEventFilter(this);
|
2023-09-13 06:39:50 +03:00
|
|
|
connect(
|
|
|
|
m_cancelbutton, SIGNAL(released()),
|
|
|
|
this, SLOT(slotCancel())
|
|
|
|
);
|
|
|
|
m_layout->addItem(m_cancelbutton, 1, 1, 1, 1);
|
2023-09-14 10:00:56 +03:00
|
|
|
m_layout->setRowMaximumHeight(1, m_cancelbutton->preferredSize().height() + m_layout->verticalSpacing());
|
2023-09-13 06:39:50 +03:00
|
|
|
|
2023-09-14 11:02:40 +03:00
|
|
|
slotTimeout();
|
2023-09-13 06:39:50 +03:00
|
|
|
m_timer = new QTimer(this);
|
|
|
|
m_timer->setInterval(1000);
|
|
|
|
connect(
|
|
|
|
m_timer, SIGNAL(timeout()),
|
|
|
|
this, SLOT(slotTimeout())
|
|
|
|
);
|
|
|
|
m_timer->start();
|
|
|
|
} else {
|
2023-09-14 10:00:56 +03:00
|
|
|
m_widget->setMinimumSize(s_chooseminumumsize);
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
int buttonscount = 0;
|
|
|
|
|
|
|
|
m_titlelabel = new Plasma::Label(m_widget);
|
|
|
|
m_titlelabel->setAlignment(Qt::AlignCenter);
|
|
|
|
m_titlelabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
m_titlelabel->setText(i18n("Choose"));
|
|
|
|
m_separator = new Plasma::Separator(m_widget);
|
|
|
|
|
|
|
|
m_logoutwidget = new Plasma::IconWidget(m_widget);
|
|
|
|
m_logoutwidget->setPreferredIconSize(s_iconsize);
|
|
|
|
m_logoutwidget->setIcon(KIcon("system-log-out"));
|
2023-09-14 07:43:50 +03:00
|
|
|
m_logoutwidget->installEventFilter(this);
|
2023-09-13 06:39:50 +03:00
|
|
|
connect(
|
|
|
|
m_logoutwidget, SIGNAL(clicked()),
|
|
|
|
this, SLOT(slotLogout())
|
|
|
|
);
|
|
|
|
m_layout->addItem(m_logoutwidget, 2, buttonscount);
|
|
|
|
buttonscount++;
|
|
|
|
|
|
|
|
if (maysd) {
|
|
|
|
m_rebootwidget = new Plasma::IconWidget(m_widget);
|
|
|
|
m_rebootwidget->setPreferredIconSize(s_iconsize);
|
|
|
|
m_rebootwidget->setIcon(KIcon("system-reboot"));
|
2023-09-14 07:43:50 +03:00
|
|
|
m_rebootwidget->installEventFilter(this);
|
2023-09-13 06:39:50 +03:00
|
|
|
connect(
|
|
|
|
m_rebootwidget, SIGNAL(clicked()),
|
|
|
|
this, SLOT(slotReboot())
|
|
|
|
);
|
|
|
|
m_layout->addItem(m_rebootwidget, 2, buttonscount);
|
|
|
|
buttonscount++;
|
|
|
|
|
|
|
|
m_haltwidget = new Plasma::IconWidget(m_widget);
|
|
|
|
m_haltwidget->setPreferredIconSize(s_iconsize);
|
|
|
|
m_haltwidget->setIcon(KIcon("system-shutdown"));
|
2023-09-14 07:43:50 +03:00
|
|
|
m_haltwidget->installEventFilter(this);
|
2023-09-13 06:39:50 +03:00
|
|
|
connect(
|
|
|
|
m_haltwidget, SIGNAL(clicked()),
|
|
|
|
this, SLOT(slotHalt())
|
|
|
|
);
|
|
|
|
m_layout->addItem(m_haltwidget, 2, buttonscount);
|
|
|
|
buttonscount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_cancelbutton = new Plasma::PushButton(m_widget);
|
2023-09-13 12:33:58 +03:00
|
|
|
m_cancelbutton->setText(i18n("&Cancel"));
|
2023-09-13 06:39:50 +03:00
|
|
|
m_cancelbutton->setIcon(KIcon("dialog-cancel"));
|
2023-09-14 07:43:50 +03:00
|
|
|
m_cancelbutton->installEventFilter(this);
|
2023-09-13 06:39:50 +03:00
|
|
|
connect(
|
|
|
|
m_cancelbutton, SIGNAL(released()),
|
|
|
|
this, SLOT(slotCancel())
|
|
|
|
);
|
|
|
|
m_layout->addItem(m_cancelbutton, 3, 0, 1, buttonscount);
|
2023-09-14 10:00:56 +03:00
|
|
|
m_layout->setRowMaximumHeight(3, m_cancelbutton->preferredSize().height() + m_layout->horizontalSpacing());
|
2023-09-13 06:39:50 +03:00
|
|
|
|
|
|
|
m_layout->addItem(m_titlelabel, 0, 0, 1, buttonscount);
|
|
|
|
m_layout->addItem(m_separator, 1, 0, 1, buttonscount);
|
|
|
|
}
|
2014-11-13 19:30:51 +02:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
m_widget->setLayout(m_layout);
|
2014-11-13 19:30:51 +02:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
m_scene->addItem(m_widget);
|
|
|
|
setGraphicsWidget(m_widget);
|
2022-11-20 01:54:00 +02:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
setFocus(Qt::ActiveWindowFocusReason);
|
|
|
|
m_scene->installEventFilter(this);
|
2014-11-13 19:30:51 +02:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
if (!choose) {
|
|
|
|
m_cancelbutton->setFocus();
|
|
|
|
} else if (sdtype == KWorkSpace::ShutdownTypeNone && m_logoutwidget) {
|
|
|
|
m_logoutwidget->setFocus();
|
|
|
|
} else if (sdtype == KWorkSpace::ShutdownTypeReboot && m_rebootwidget) {
|
|
|
|
m_rebootwidget->setFocus();
|
|
|
|
} else if (sdtype == KWorkSpace::ShutdownTypeHalt && m_haltwidget) {
|
|
|
|
m_haltwidget->setFocus();
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
2023-09-13 06:39:50 +03:00
|
|
|
|
2014-11-13 19:30:51 +02:00
|
|
|
adjustSize();
|
2023-09-13 06:39:50 +03:00
|
|
|
KDialog::centerOnScreen(this, -3);
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
KSMShutdownDlg::~KSMShutdownDlg()
|
2014-11-13 19:30:51 +02:00
|
|
|
{
|
2023-09-13 06:39:50 +03:00
|
|
|
// make the screen become normal again
|
|
|
|
KSMShutdownFeedback::stop();
|
|
|
|
// delete m_widget;
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
void KSMShutdownDlg::hideEvent(QHideEvent *event)
|
2014-11-13 19:30:51 +02:00
|
|
|
{
|
2023-09-13 06:39:50 +03:00
|
|
|
interrupt();
|
|
|
|
Plasma::Dialog::hideEvent(event);
|
|
|
|
}
|
2014-11-13 19:30:51 +02:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
bool KSMShutdownDlg::eventFilter(QObject *watched, QEvent *event)
|
|
|
|
{
|
|
|
|
if (watched == m_scene && event->type() == QEvent::WindowDeactivate) {
|
|
|
|
interrupt();
|
2023-09-14 11:38:04 +03:00
|
|
|
} else if (!m_timer && watched == m_logoutwidget && kSwitchTitleEvent(event)) {
|
2023-09-14 07:43:50 +03:00
|
|
|
m_titlelabel->setText(i18n("Logout"));
|
2023-09-14 11:38:04 +03:00
|
|
|
} else if (!m_timer && watched == m_rebootwidget && kSwitchTitleEvent(event)) {
|
2023-09-14 07:43:50 +03:00
|
|
|
m_titlelabel->setText(i18n("Restart Computer"));
|
2023-09-14 11:38:04 +03:00
|
|
|
} else if (!m_timer && watched == m_haltwidget && kSwitchTitleEvent(event)) {
|
2023-09-14 07:43:50 +03:00
|
|
|
m_titlelabel->setText(i18n("Halt Computer"));
|
2023-09-14 11:38:04 +03:00
|
|
|
} else if (!m_timer && watched == m_okbutton && kSwitchTitleEvent(event)) {
|
2023-09-14 07:43:50 +03:00
|
|
|
m_titlelabel->setText(i18n("OK"));
|
2023-09-14 11:38:04 +03:00
|
|
|
} else if (!m_timer && watched == m_cancelbutton && kSwitchTitleEvent(event)) {
|
2023-09-14 07:43:50 +03:00
|
|
|
m_titlelabel->setText(i18n("Cancel"));
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
2023-09-13 06:39:50 +03:00
|
|
|
return Plasma::Dialog::eventFilter(watched, event);
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void KSMShutdownDlg::slotLogout()
|
|
|
|
{
|
|
|
|
m_shutdownType = KWorkSpace::ShutdownTypeNone;
|
2023-09-13 06:39:50 +03:00
|
|
|
m_eventloop->exit(0);
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void KSMShutdownDlg::slotReboot()
|
|
|
|
{
|
|
|
|
m_shutdownType = KWorkSpace::ShutdownTypeReboot;
|
2023-09-13 06:39:50 +03:00
|
|
|
m_eventloop->exit(0);
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
void KSMShutdownDlg::slotHalt()
|
2014-11-13 19:30:51 +02:00
|
|
|
{
|
2023-09-13 06:39:50 +03:00
|
|
|
m_shutdownType = KWorkSpace::ShutdownTypeHalt;
|
|
|
|
m_eventloop->exit(0);
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
void KSMShutdownDlg::slotOk()
|
2014-11-13 19:30:51 +02:00
|
|
|
{
|
2023-09-14 11:38:04 +03:00
|
|
|
m_second = 0;
|
2023-09-13 06:39:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void KSMShutdownDlg::slotCancel()
|
|
|
|
{
|
|
|
|
interrupt();
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
void KSMShutdownDlg::slotTimeout()
|
|
|
|
{
|
|
|
|
switch (m_shutdownType) {
|
|
|
|
case KWorkSpace::ShutdownTypeReboot: {
|
|
|
|
m_titlelabel->setText(
|
|
|
|
i18np("Restarting computer in 1 second.", "Restarting computer in %1 seconds.", m_second)
|
|
|
|
);
|
|
|
|
m_second--;
|
2023-09-14 11:02:40 +03:00
|
|
|
if (m_second <= -1) {
|
2023-09-13 06:39:50 +03:00
|
|
|
slotReboot();
|
|
|
|
}
|
2014-11-13 19:30:51 +02:00
|
|
|
break;
|
2023-09-13 06:39:50 +03:00
|
|
|
}
|
|
|
|
case KWorkSpace::ShutdownTypeHalt: {
|
|
|
|
m_titlelabel->setText(
|
|
|
|
i18np("Turning off computer in 1 second.", "Turning off computer in %1 seconds.", m_second)
|
|
|
|
);
|
|
|
|
m_second--;
|
2023-09-14 11:02:40 +03:00
|
|
|
if (m_second <= -1) {
|
2023-09-13 06:39:50 +03:00
|
|
|
slotHalt();
|
|
|
|
}
|
2014-11-13 19:30:51 +02:00
|
|
|
break;
|
2023-09-13 06:39:50 +03:00
|
|
|
}
|
|
|
|
default: {
|
|
|
|
m_titlelabel->setText(
|
|
|
|
i18np("Logging out in 1 second.", "Logging out in %1 seconds.", m_second)
|
|
|
|
);
|
|
|
|
m_second--;
|
2023-09-14 11:02:40 +03:00
|
|
|
if (m_second <= -1) {
|
2023-09-13 06:39:50 +03:00
|
|
|
slotLogout();
|
|
|
|
}
|
2022-11-30 01:54:45 +02:00
|
|
|
break;
|
2023-09-13 06:39:50 +03:00
|
|
|
}
|
2014-11-13 19:30:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
bool KSMShutdownDlg::execDialog()
|
2022-11-20 01:54:00 +02:00
|
|
|
{
|
2023-09-13 06:39:50 +03:00
|
|
|
KWindowSystem::setState(winId(), NET::SkipPager | NET::SkipTaskbar);
|
2023-09-14 08:24:57 +03:00
|
|
|
animatedShow(Plasma::locationToDirection(Plasma::Location::Desktop));
|
2023-09-13 06:39:50 +03:00
|
|
|
Q_ASSERT(!m_eventloop);
|
|
|
|
m_eventloop = new QEventLoop(this);
|
|
|
|
return (m_eventloop->exec() == 0);
|
2022-11-20 01:54:00 +02:00
|
|
|
}
|
|
|
|
|
2023-09-14 07:43:50 +03:00
|
|
|
void KSMShutdownDlg::interrupt()
|
|
|
|
{
|
|
|
|
if (!m_eventloop) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_eventloop->exit(1);
|
|
|
|
m_eventloop->deleteLater();
|
|
|
|
m_eventloop = nullptr;
|
|
|
|
}
|
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
bool KSMShutdownDlg::confirmShutdown(bool maysd, bool choose, KWorkSpace::ShutdownType &sdtype)
|
2014-11-13 19:30:51 +02:00
|
|
|
{
|
2023-09-13 06:39:50 +03:00
|
|
|
KSMShutdownDlg* dialog = new KSMShutdownDlg(nullptr, maysd, choose, sdtype);
|
|
|
|
|
2022-09-28 11:17:33 +03:00
|
|
|
// NOTE: KWin logout effect expects class hint values to be ksmserver
|
2014-11-13 19:30:51 +02:00
|
|
|
XClassHint classHint;
|
|
|
|
classHint.res_name = const_cast<char*>("ksmserver");
|
|
|
|
classHint.res_class = const_cast<char*>("ksmserver");
|
2023-09-13 06:39:50 +03:00
|
|
|
XSetClassHint(QX11Info::display(), dialog->winId(), &classHint);
|
2022-09-28 11:17:33 +03:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
dialog->setWindowRole("logoutdialog");
|
2022-09-28 11:17:33 +03:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
bool result = dialog->execDialog();
|
|
|
|
sdtype = dialog->m_shutdownType;
|
2014-11-13 19:30:51 +02:00
|
|
|
|
2023-09-13 06:39:50 +03:00
|
|
|
delete dialog;
|
2014-11-13 19:30:51 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2023-09-13 06:39:50 +03:00
|
|
|
|
|
|
|
#include "moc_shutdowndlg.cpp"
|