diff --git a/app/mainwindow.h b/app/mainwindow.h --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -54,6 +54,8 @@ Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.yakuake") + friend class TitleBar; + public: explicit MainWindow(QWidget* parent = 0); ~MainWindow(); diff --git a/app/titlebar.h b/app/titlebar.h --- a/app/titlebar.h +++ b/app/titlebar.h @@ -24,6 +24,7 @@ #include +#include class MainWindow; @@ -55,6 +56,8 @@ protected: void resizeEvent(QResizeEvent*) override; void paintEvent(QPaintEvent*) override; + void mousePressEvent(QMouseEvent*) override; + void mouseReleaseEvent(QMouseEvent*) override; private: diff --git a/app/titlebar.cpp b/app/titlebar.cpp --- a/app/titlebar.cpp +++ b/app/titlebar.cpp @@ -138,6 +138,31 @@ painter.end(); } +void TitleBar::mousePressEvent(QMouseEvent* event) +{ + if(event->buttons() != Qt::LeftButton && event->modifiers() != Qt::NoModifier) + QWidget::mousePressEvent(event); +} + +void TitleBar::mouseReleaseEvent(QMouseEvent* event) +{ + if(event->button() == Qt::LeftButton){ + MainWindow* parent = (MainWindow*)this->parent(); + + int maxHeight = parent->getDesktopGeometry().height(); + int newHeight = event->globalY() / (maxHeight / 100); + + if(newHeight > 100) + newHeight = 100; + if(newHeight < 10) + newHeight = 10; + + parent->setWindowHeight(newHeight); + } else { + QWidget::mouseReleaseEvent(event); + } +} + void TitleBar::updateMask() { const QPixmap& leftCornerImage = m_skin->titleBarLeftCornerImage();