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

Use KMainWindow instead of QMainWindow

Summary:
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: https://phabricator.kde.org/D15535
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;
else
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());
QMainWindow::paintEvent(event);
KMainWindow::paintEvent(event);
}
void MainWindow::moveEvent(QMoveEvent* event)
......@@ -1009,7 +1008,15 @@ void MainWindow::moveEvent(QMoveEvent* event)
applyWindowGeometry();
}
QMainWindow::moveEvent(event);
KMainWindow::moveEvent(event);
}
void MainWindow::closeEvent(QCloseEvent *event)
{
KMainWindow::closeEvent(event);
if (event->isAccepted()) {
QApplication::quit();
}
}
void MainWindow::wmActiveWindowChanged()
......@@ -1053,7 +1060,7 @@ void MainWindow::changeEvent(QEvent* event)
updateWindowHeightMenu();
}
QMainWindow::changeEvent(event);
KMainWindow::changeEvent(event);
}
bool MainWindow::event(QEvent* event)
......@@ -1072,7 +1079,7 @@ bool MainWindow::event(QEvent* event)
#endif
}
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 {
}
#endif
class MainWindow : public QMainWindow
class MainWindow : public KMainWindow
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.yakuake")
......@@ -88,12 +88,13 @@ class MainWindow : public QMainWindow
protected:
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
protected:
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);
~Terminal();
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->setFocusPolicy(Qt::NoFocus);
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()));
}
TitleBar::~TitleBar()
......
......@@ -53,8 +53,8 @@ class TitleBar : public QWidget
protected:
void resizeEvent(QResizeEvent*) Q_DECL_OVERRIDE;
void paintEvent(QPaintEvent*) Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent*) override;
void paintEvent(QPaintEvent*) override;
private:
......
......@@ -92,9 +92,9 @@ class VisualEventOverlay : public QWidget
protected:
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