Commit 0c0eb086 authored by Maximilian Schiller's avatar Maximilian Schiller Committed by Eike Hein
Browse files

Use KMainWindow instead of QMainWindow

MainWindow should inherit from KMainWindow and not from QMainWindow
because QMainWindow does not call the queryClose function upon closing.
This disabled the "really quit?" dialog which should come up if more than one session
is currently open.
Furthermore makes Yakuake properly quit when requested via the "Quit" action or the dialog by
making the QApplication quit if the last Window Closes.

BUG:  398425

Test Plan:
1. open yakuake
2. press ctrl + shift + q

without the patch yakuake just hides again (press F12 to confirm) with the patch it properly quits.

1. open yakuake
2. open multiple (>1) sessions (bottom left "+" symbol)
3. press ctrl + shift + q

without the patch yakuake just hides with the patch a dialog comes up and asks "really quit?"
on pressing "quit" yakuake properly quits.

Reviewers: hein, alexeymin, #kde_applications

Reviewed By: hein

Subscribers: tcanabrava

Differential Revision:
parent 8adea8a5
......@@ -72,11 +72,13 @@
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent, Qt::CustomizeWindowHint | Qt::FramelessWindowHint)
: KMainWindow(parent, Qt::CustomizeWindowHint | Qt::FramelessWindowHint)
QDBusConnection::sessionBus().registerObject(QStringLiteral("/yakuake/window"), this, QDBusConnection::ExportScriptableSlots);
setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_DeleteOnClose, false);
setAttribute(Qt::WA_QuitOnClose, true);
m_skin = new Skin();
m_menu = new QMenu(this);
......@@ -222,10 +224,7 @@ bool MainWindow::queryClose()
warningMessage + QStringLiteral("<br /><br />") + closeQuestion,
xi18nc("@title:window", "Really Quit?"), KStandardGuiItem::quit(), KStandardGuiItem::cancel());
if (result == KMessageBox::Continue)
return true;
return false;
return result != KMessageBox::Cancel;
return true;
......@@ -995,7 +994,7 @@ void MainWindow::paintEvent(QPaintEvent* event)
height() - m_titleBar->height());
painter.fillRect(rightBorder, m_skin->borderColor());
void MainWindow::moveEvent(QMoveEvent* event)
......@@ -1009,7 +1008,15 @@ void MainWindow::moveEvent(QMoveEvent* event)
void MainWindow::closeEvent(QCloseEvent *event)
if (event->isAccepted()) {
void MainWindow::wmActiveWindowChanged()
......@@ -1053,7 +1060,7 @@ void MainWindow::changeEvent(QEvent* event)
bool MainWindow::event(QEvent* event)
......@@ -1072,7 +1079,7 @@ bool MainWindow::event(QEvent* event)
return QMainWindow::event(event);
return KMainWindow::event(event);
void MainWindow::toggleWindowState()
......@@ -25,7 +25,7 @@
#include <config-yakuake.h>
#include <QMainWindow>
#include <KMainWindow>
#include <QTimer>
......@@ -49,7 +49,7 @@ namespace KWayland {
class MainWindow : public QMainWindow
class MainWindow : public KMainWindow
Q_CLASSINFO("D-Bus Interface", "org.kde.yakuake")
......@@ -88,12 +88,13 @@ class MainWindow : public QMainWindow
void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
void moveEvent(QMoveEvent*) Q_DECL_OVERRIDE;
void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
bool event(QEvent* event) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent*) override;
void moveEvent(QMoveEvent*) override;
void changeEvent(QEvent* event) override;
void closeEvent(QCloseEvent *event) override;
bool event(QEvent* event) override;
virtual bool queryClose();
virtual bool queryClose() override;
private Q_SLOTS:
......@@ -81,20 +81,20 @@ class TabBar : public QWidget
void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
void wheelEvent(QWheelEvent*) Q_DECL_OVERRIDE;
void keyPressEvent(QKeyEvent*) Q_DECL_OVERRIDE;
void mousePressEvent(QMouseEvent*) Q_DECL_OVERRIDE;
void mouseReleaseEvent(QMouseEvent*) Q_DECL_OVERRIDE;
void mouseMoveEvent(QMouseEvent*) Q_DECL_OVERRIDE;
void dragMoveEvent(QDragMoveEvent*) Q_DECL_OVERRIDE;
void dragEnterEvent(QDragEnterEvent*) Q_DECL_OVERRIDE;
void dragLeaveEvent(QDragLeaveEvent*) Q_DECL_OVERRIDE;
void dropEvent(QDropEvent*) Q_DECL_OVERRIDE;
void mouseDoubleClickEvent(QMouseEvent*) Q_DECL_OVERRIDE;
void contextMenuEvent(QContextMenuEvent*) Q_DECL_OVERRIDE;
void leaveEvent(QEvent*) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent*) override;
void paintEvent(QPaintEvent*) override;
void wheelEvent(QWheelEvent*) override;
void keyPressEvent(QKeyEvent*) override;
void mousePressEvent(QMouseEvent*) override;
void mouseReleaseEvent(QMouseEvent*) override;
void mouseMoveEvent(QMouseEvent*) override;
void dragMoveEvent(QDragMoveEvent*) override;
void dragEnterEvent(QDragEnterEvent*) override;
void dragLeaveEvent(QDragLeaveEvent*) override;
void dropEvent(QDropEvent*) override;
void mouseDoubleClickEvent(QMouseEvent*) override;
void contextMenuEvent(QContextMenuEvent*) override;
void leaveEvent(QEvent*) override;
void setTabTitleInteractive(int sessionId, const QString& newTitle);
......@@ -40,7 +40,7 @@ class Terminal : public QObject
explicit Terminal(QWidget* parent = 0);
bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE;
bool eventFilter(QObject* watched, QEvent* event) override;
int id() { return m_terminalId; }
const QString title() { return m_title; }
......@@ -61,7 +61,7 @@ TitleBar::TitleBar(MainWindow* mainWindow) : QWidget(mainWindow)
m_quitButton->setToolTip(xi18nc("@info:tooltip Quits the application", "Quit"));
m_quitButton->setWhatsThis(xi18nc("@info:whatsthis", "Quits the application."));
connect(m_quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
connect(m_quitButton, SIGNAL(clicked()), mainWindow, SLOT(close()));
......@@ -53,8 +53,8 @@ class TitleBar : public QWidget
void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent*) override;
void paintEvent(QPaintEvent*) override;
......@@ -92,9 +92,9 @@ class VisualEventOverlay : public QWidget
void showEvent(QShowEvent*) Q_DECL_OVERRIDE;
void hideEvent(QHideEvent*) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
void showEvent(QShowEvent*) override;
void hideEvent(QHideEvent*) override;
void paintEvent(QPaintEvent*) override;
private Q_SLOTS:
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