Changeset View
Changeset View
Standalone View
Standalone View
app/mainwindow.cpp
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | |||||
67 | #include <KWayland/Client/connection_thread.h> | 67 | #include <KWayland/Client/connection_thread.h> | ||
68 | #include <KWayland/Client/registry.h> | 68 | #include <KWayland/Client/registry.h> | ||
69 | #include <KWayland/Client/surface.h> | 69 | #include <KWayland/Client/surface.h> | ||
70 | #include <KWayland/Client/plasmashell.h> | 70 | #include <KWayland/Client/plasmashell.h> | ||
71 | #endif | 71 | #endif | ||
72 | 72 | | |||
73 | 73 | | |||
74 | MainWindow::MainWindow(QWidget* parent) | 74 | MainWindow::MainWindow(QWidget* parent) | ||
75 | : QMainWindow(parent, Qt::CustomizeWindowHint | Qt::FramelessWindowHint) | 75 | : KMainWindow(parent, Qt::CustomizeWindowHint | Qt::FramelessWindowHint) | ||
76 | { | 76 | { | ||
77 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/yakuake/window"), this, QDBusConnection::ExportScriptableSlots); | 77 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/yakuake/window"), this, QDBusConnection::ExportScriptableSlots); | ||
78 | 78 | | |||
79 | setAttribute(Qt::WA_TranslucentBackground, true); | 79 | setAttribute(Qt::WA_TranslucentBackground, true); | ||
80 | setAttribute(Qt::WA_DeleteOnClose, false); | ||||
81 | setAttribute(Qt::WA_QuitOnClose, true); | ||||
80 | 82 | | |||
81 | m_skin = new Skin(); | 83 | m_skin = new Skin(); | ||
82 | m_menu = new QMenu(this); | 84 | m_menu = new QMenu(this); | ||
83 | m_helpMenu = new KHelpMenu(this, KAboutData::applicationData()); | 85 | m_helpMenu = new KHelpMenu(this, KAboutData::applicationData()); | ||
84 | m_sessionStack = new SessionStack(this); | 86 | m_sessionStack = new SessionStack(this); | ||
85 | m_tabBar = new TabBar(this); | 87 | m_tabBar = new TabBar(this); | ||
86 | m_titleBar = new TitleBar(this); | 88 | m_titleBar = new TitleBar(this); | ||
87 | m_firstRunDialog = NULL; | 89 | m_firstRunDialog = NULL; | ||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | 210 | { | |||
217 | { | 219 | { | ||
218 | warningMessage = xi18nc("@info", "<warning>There are one or more open sessions that you have locked to prevent closing them accidentally. These will be killed if you continue.</warning>"); | 220 | warningMessage = xi18nc("@info", "<warning>There are one or more open sessions that you have locked to prevent closing them accidentally. These will be killed if you continue.</warning>"); | ||
219 | } | 221 | } | ||
220 | 222 | | |||
221 | int result = KMessageBox::warningContinueCancel(this, | 223 | int result = KMessageBox::warningContinueCancel(this, | ||
222 | warningMessage + QStringLiteral("<br /><br />") + closeQuestion, | 224 | warningMessage + QStringLiteral("<br /><br />") + closeQuestion, | ||
223 | xi18nc("@title:window", "Really Quit?"), KStandardGuiItem::quit(), KStandardGuiItem::cancel()); | 225 | xi18nc("@title:window", "Really Quit?"), KStandardGuiItem::quit(), KStandardGuiItem::cancel()); | ||
224 | 226 | | |||
225 | if (result == KMessageBox::Continue) | 227 | return result != KMessageBox::Cancel; | ||
226 | return true; | | |||
227 | else | | |||
228 | return false; | | |||
229 | } | 228 | } | ||
230 | 229 | | |||
231 | return true; | 230 | return true; | ||
tcanabrava: return result != KMessageBox::Cancel; | |||||
232 | } | 231 | } | ||
233 | 232 | | |||
234 | void MainWindow::setupActions() | 233 | void MainWindow::setupActions() | ||
235 | { | 234 | { | ||
236 | m_actionCollection = new KActionCollection(this); | 235 | m_actionCollection = new KActionCollection(this); | ||
237 | 236 | | |||
238 | KToggleFullScreenAction* fullScreenAction = new KToggleFullScreenAction(this); | 237 | KToggleFullScreenAction* fullScreenAction = new KToggleFullScreenAction(this); | ||
239 | fullScreenAction->setWindow(this); | 238 | fullScreenAction->setWindow(this); | ||
▲ Show 20 Lines • Show All 750 Lines • ▼ Show 20 Line(s) | 978 | { | |||
990 | 989 | | |||
991 | QRect leftBorder(0, 0, m_skin->borderWidth(), height() - m_titleBar->height()); | 990 | QRect leftBorder(0, 0, m_skin->borderWidth(), height() - m_titleBar->height()); | ||
992 | painter.fillRect(leftBorder, m_skin->borderColor()); | 991 | painter.fillRect(leftBorder, m_skin->borderColor()); | ||
993 | 992 | | |||
994 | QRect rightBorder(width() - m_skin->borderWidth(), 0, m_skin->borderWidth(), | 993 | QRect rightBorder(width() - m_skin->borderWidth(), 0, m_skin->borderWidth(), | ||
995 | height() - m_titleBar->height()); | 994 | height() - m_titleBar->height()); | ||
996 | painter.fillRect(rightBorder, m_skin->borderColor()); | 995 | painter.fillRect(rightBorder, m_skin->borderColor()); | ||
997 | 996 | | |||
998 | QMainWindow::paintEvent(event); | 997 | KMainWindow::paintEvent(event); | ||
999 | } | 998 | } | ||
1000 | 999 | | |||
1001 | void MainWindow::moveEvent(QMoveEvent* event) | 1000 | void MainWindow::moveEvent(QMoveEvent* event) | ||
1002 | { | 1001 | { | ||
1003 | if (Settings::screen() && QApplication::desktop()->screenNumber(this) != getScreen()) | 1002 | if (Settings::screen() && QApplication::desktop()->screenNumber(this) != getScreen()) | ||
1004 | { | 1003 | { | ||
1005 | Settings::setScreen(QApplication::desktop()->screenNumber(this)+1); | 1004 | Settings::setScreen(QApplication::desktop()->screenNumber(this)+1); | ||
1006 | 1005 | | |||
1007 | updateScreenMenu(); | 1006 | updateScreenMenu(); | ||
1008 | 1007 | | |||
1009 | applyWindowGeometry(); | 1008 | applyWindowGeometry(); | ||
1010 | } | 1009 | } | ||
1011 | 1010 | | |||
1012 | QMainWindow::moveEvent(event); | 1011 | KMainWindow::moveEvent(event); | ||
1012 | } | ||||
1013 | | ||||
1014 | void MainWindow::closeEvent(QCloseEvent *event) | ||||
1015 | { | ||||
1016 | KMainWindow::closeEvent(event); | ||||
1017 | if (event->isAccepted()) { | ||||
1018 | QApplication::quit(); | ||||
1019 | } | ||||
1013 | } | 1020 | } | ||
1014 | 1021 | | |||
1015 | void MainWindow::wmActiveWindowChanged() | 1022 | void MainWindow::wmActiveWindowChanged() | ||
1016 | { | 1023 | { | ||
1017 | if (m_toggleLock) { | 1024 | if (m_toggleLock) { | ||
1018 | m_toggleLock = false; | 1025 | m_toggleLock = false; | ||
1019 | return; | 1026 | return; | ||
1020 | } | 1027 | } | ||
Show All 27 Lines | 1053 | { | |||
1048 | Settings::setHeight(100); | 1055 | Settings::setHeight(100); | ||
1049 | 1056 | | |||
1050 | applyWindowGeometry(); | 1057 | applyWindowGeometry(); | ||
1051 | 1058 | | |||
1052 | updateWindowWidthMenu(); | 1059 | updateWindowWidthMenu(); | ||
1053 | updateWindowHeightMenu(); | 1060 | updateWindowHeightMenu(); | ||
1054 | } | 1061 | } | ||
1055 | 1062 | | |||
1056 | QMainWindow::changeEvent(event); | 1063 | KMainWindow::changeEvent(event); | ||
1057 | } | 1064 | } | ||
1058 | 1065 | | |||
1059 | bool MainWindow::event(QEvent* event) | 1066 | bool MainWindow::event(QEvent* event) | ||
1060 | { | 1067 | { | ||
1061 | if (event->type() == QEvent::Expose) { | 1068 | if (event->type() == QEvent::Expose) { | ||
1062 | // FIXME TODO: We can remove this once we depend on Qt 5.6.1+. | 1069 | // FIXME TODO: We can remove this once we depend on Qt 5.6.1+. | ||
1063 | // See: https://bugreports.qt.io/browse/QTBUG-26978 | 1070 | // See: https://bugreports.qt.io/browse/QTBUG-26978 | ||
1064 | applyWindowProperties(); | 1071 | applyWindowProperties(); | ||
1065 | #if (QT_VERSION > QT_VERSION_CHECK(5, 5, 0)) | 1072 | #if (QT_VERSION > QT_VERSION_CHECK(5, 5, 0)) | ||
1066 | } else if (event->type() == QEvent::PlatformSurface) { | 1073 | } else if (event->type() == QEvent::PlatformSurface) { | ||
1067 | const QPlatformSurfaceEvent *pSEvent = static_cast<QPlatformSurfaceEvent *>(event); | 1074 | const QPlatformSurfaceEvent *pSEvent = static_cast<QPlatformSurfaceEvent *>(event); | ||
1068 | 1075 | | |||
1069 | if (pSEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) { | 1076 | if (pSEvent->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) { | ||
1070 | applyWindowProperties(); | 1077 | applyWindowProperties(); | ||
1071 | } | 1078 | } | ||
1072 | #endif | 1079 | #endif | ||
1073 | } | 1080 | } | ||
1074 | 1081 | | |||
1075 | return QMainWindow::event(event); | 1082 | return KMainWindow::event(event); | ||
1076 | } | 1083 | } | ||
1077 | 1084 | | |||
1078 | void MainWindow::toggleWindowState() | 1085 | void MainWindow::toggleWindowState() | ||
1079 | { | 1086 | { | ||
1080 | bool visible = isVisible(); | 1087 | bool visible = isVisible(); | ||
1081 | 1088 | | |||
1082 | if (visible && KWindowSystem::activeWindow() != winId() && Settings::keepOpen()) | 1089 | if (visible && KWindowSystem::activeWindow() != winId() && Settings::keepOpen()) | ||
1083 | { | 1090 | { | ||
▲ Show 20 Lines • Show All 451 Lines • Show Last 20 Lines |
return result != KMessageBox::Cancel;