From ac6e898136d9885e3fadb4f008559b5c4ccfeb11 Mon Sep 17 00:00:00 2001 From: Steffen Baranowsky Date: Tue, 26 Jan 2016 00:08:26 +0100 Subject: [PATCH] Add a new window decoration to MDISubWindows --- data/themes/default/close.png | Bin 0 -> 218 bytes data/themes/default/maximize.png | Bin 0 -> 198 bytes data/themes/default/minimize.png | Bin 0 -> 193 bytes data/themes/default/style.css | 10 ++ include/SubWindow.h | 40 +++++-- src/gui/SubWindow.cpp | 196 ++++++++++++++++++++++++++++++- 6 files changed, 236 insertions(+), 10 deletions(-) create mode 100644 data/themes/default/close.png create mode 100644 data/themes/default/maximize.png create mode 100644 data/themes/default/minimize.png diff --git a/data/themes/default/close.png b/data/themes/default/close.png new file mode 100644 index 0000000000000000000000000000000000000000..a9fbbad79a3f5c864f4e7532976892825d23531f GIT binary patch literal 218 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_r((Aj~*bn@<`j$X?><>&pIsQC2`ga{tv9OQ2A?r;B5V#p&b}2L^VwO9vU*xOg2d zy02p_`0K+H!eC;$M6QdoQ?R6ydD60~n#AKx&U*xPFUT&qc+;ax@devMlZFZ9uO{*o z91xZJ5fjvZl$9?-Pvw;L2{sd-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_r((Aj~*bn@<`j$X?><>&pIsQC2{f_1a<`W1vv5r;B5V#p&b}2L^VwO9vU*xOg2d zy02p_`0K+H!VqHE!rES8%a<>gkdTm}a!r+QNyp{~g-eyiHvTo?o_tW=n!Vu1e+K4G lLqnEeozNmfWz$o_4D1Uy?*$fXJOvuh;OXk;vd$@?2>|r7H%0&e literal 0 HcmV?d00001 diff --git a/data/themes/default/minimize.png b/data/themes/default/minimize.png new file mode 100644 index 0000000000000000000000000000000000000000..b0f6adfa8b2c92ed8dcf63a0e168d1e740789a97 GIT binary patch literal 193 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI z1_r((Aj~*bn@<`j$X?><>&pIsQC2`e=)t|~JAp!eo-U3d7N?U_92nTyE*)fKw6Qa)^IAG8kF})@!A>jx6(f<>V?0@9@pLy1s hm6N(9R|d{wV9>4R`m4ix;vmpu22WQ%mvv4FO#p2aJy`$% literal 0 HcmV?d00001 diff --git a/data/themes/default/style.css b/data/themes/default/style.css index 1516dece1b0..481b20a2079 100644 --- a/data/themes/default/style.css +++ b/data/themes/default/style.css @@ -540,6 +540,16 @@ BBTCOView { qproperty-textColor: rgb( 255, 255, 255 ); } +/* subwindows in MDI-Area */ +SubWindow { + qproperty-activeDecorationColor: rgb(77, 96, 148); + qproperty-inactiveDecorationColor: rgb(119, 119, 119); + qproperty-leftUpperBorderColor: rgb(164,164,164); + qproperty-titelTextColor: rgb(255, 255, 255); + qproperty-windowBorderColor: rgb(0, 0, 0); + qproperty-windowDecorationBorderColor: rgb(57, 57, 57); +} + /* Plugins */ TripleOscillatorView Knob { diff --git a/include/SubWindow.h b/include/SubWindow.h index 821e0a76201..0e947cf5d70 100644 --- a/include/SubWindow.h +++ b/include/SubWindow.h @@ -23,17 +23,14 @@ * Boston, MA 02110-1301 USA. * */ - - #ifndef SUBWINDOW_H #define SUBWINDOW_H - +#include #include -#include #include "export.h" - +#include "PixmapButton.h" class QMoveEvent; class QResizeEvent; @@ -43,16 +40,45 @@ class QWidget; class EXPORT SubWindow : public QMdiSubWindow { Q_OBJECT + Q_PROPERTY(QColor activeDecorationColor READ activeDecorationColor WRITE setActiveDecorationColor) + Q_PROPERTY(QColor inactiveDecorationColor READ inactiveDecorationColor WRITE setInactiveDecorationColor) + Q_PROPERTY(QColor leftUpperBorderColor READ leftUpperBorderColor WRITE setLeftUpperBorderColor) + Q_PROPERTY(QColor titelTextColor READ titelTextColor WRITE setTitelTextColor) + Q_PROPERTY(QColor windowBorderColor READ windowBorderColor WRITE setWindowBorderColor) + Q_PROPERTY(QColor windowDecorationBorderColor READ windowDecorationBorderColor WRITE setWindowDecorationBorderColor) + public: - SubWindow(QWidget *parent=NULL, Qt::WindowFlags windowFlags=0); + SubWindow(QWidget *parent = NULL, Qt::WindowFlags windowFlags = 0); // same as QWidet::normalGeometry, but works properly under X11 (see https://bugreports.qt.io/browse/QTBUG-256) QRect getTrueNormalGeometry() const; + QColor activeDecorationColor() const; + QColor inactiveDecorationColor() const; + QColor leftUpperBorderColor() const; + QColor titelTextColor() const; + QColor windowBorderColor() const; + QColor windowDecorationBorderColor() const; + void setActiveDecorationColor(const QColor& c); + void setInactiveDecorationColor(const QColor &c); + void setLeftUpperBorderColor(const QColor &c); + void setTitelTextColor(const QColor &c); + void setWindowBorderColor(const QColor &c); + void setWindowDecorationBorderColor(const QColor &c); + protected: // hook the QWidget move/resize events to update the tracked geometry virtual void moveEvent(QMoveEvent * event); virtual void resizeEvent(QResizeEvent * event); + void paintEvent(QPaintEvent *); private: + bool m_closeHover; + QColor m_activeDecorationColor; + QColor m_inactivDecorationColor; + QColor m_leftUpperBorderColor; + QColor m_titelTextColor; + QColor m_windowBorderColor; + QColor m_windowDecorationBorderColor; + QPoint m_position; QRect m_trackedNormalGeom; }; -#endif \ No newline at end of file +#endif diff --git a/src/gui/SubWindow.cpp b/src/gui/SubWindow.cpp index cc29962534b..773542731eb 100644 --- a/src/gui/SubWindow.cpp +++ b/src/gui/SubWindow.cpp @@ -26,9 +26,15 @@ #include "SubWindow.h" +#include +#include #include +#include #include #include +#include "embed.h" + + SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags windowFlags) @@ -37,31 +43,215 @@ SubWindow::SubWindow(QWidget *parent, Qt::WindowFlags windowFlags) // initialize the tracked geometry to whatever Qt thinks the normal geometry currently is. // this should always work, since QMdiSubWindows will not start as maximized m_trackedNormalGeom = normalGeometry(); + m_activeDecorationColor = QColor(77,96,148); + m_inactivDecorationColor = QColor(119,119,119); + m_leftUpperBorderColor = QColor(164,164,164); + m_titelTextColor = Qt::white; + m_windowDecorationBorderColor = QColor(57,57,57); + m_windowBorderColor = Qt::black; +} + + + + +void SubWindow::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + QRectF rect(0,0,width()-1,20); + QBrush winDecoBrush; + + winDecoBrush.setStyle(Qt::SolidPattern); + if ( SubWindow::mdiArea()->activeSubWindow() == this ) + { + winDecoBrush.setColor(m_activeDecorationColor); + } + else + { + winDecoBrush.setColor(m_inactivDecorationColor); + } + + painter.fillRect(rect,winDecoBrush); + + //window border + QPen pen; + pen.setColor(m_windowBorderColor); + painter.setPen(pen); + painter.drawRect(0,0,width()-1,height()-1); + + + + pen.setColor(m_windowDecorationBorderColor); + painter.setPen(pen); + painter.drawRect(rect); + painter.drawLine(2,0,0,2); + painter.drawLine(width()-3,0,width()-1,2); + pen.setColor(m_leftUpperBorderColor); + painter.setPen(pen); + painter.drawLine(2,1,width()-3,1); + painter.drawLine(1,2,1,19); + + + + //Text and Button + pen.setColor(Qt::black); + painter.setPen(pen); + painter.drawText(QRect(0,0,rect.width()+1,rect.height()+1), + widget()->windowTitle(),QTextOption(Qt::AlignCenter)); + pen.setColor(m_titelTextColor); + painter.setPen(pen); + painter.drawText(rect, widget()->windowTitle(),QTextOption(Qt::AlignCenter)); + QPixmap winicon(widget()->windowIcon().pixmap(QSize(17,17))); + QPixmap closeBtn(embed::getIconPixmap("close")); + if(windowFlags() & Qt::WindowMinimizeButtonHint) + { + int d = 0; + if (windowFlags() & Qt::WindowMaximizeButtonHint) { d = 18; } + QPixmap minimizeBtn(embed::getIconPixmap("minimize")); + painter.drawPixmap(width()-17-3-1-17-d,3,17,17,minimizeBtn); + } + if(windowFlags() & Qt::WindowMaximizeButtonHint) + { + QPixmap maximizeBtn(embed::getIconPixmap("maximize")); + painter.drawPixmap(width()-17-3-1-17,3,17,17,maximizeBtn); + } + + painter.drawPixmap(3,3,17,17,winicon); + painter.drawPixmap(width()-17-3,3,17,17,closeBtn); } + + + QRect SubWindow::getTrueNormalGeometry() const { return m_trackedNormalGeom; } + + + +QColor SubWindow::activeDecorationColor() const +{ + return m_activeDecorationColor; +} + + + + +QColor SubWindow::inactiveDecorationColor() const +{ + return m_inactivDecorationColor; +} + + + + +QColor SubWindow::leftUpperBorderColor() const +{ + return m_leftUpperBorderColor; +} + + + + +QColor SubWindow::titelTextColor() const +{ + return m_titelTextColor; +} + + + + +QColor SubWindow::windowBorderColor() const +{ + return m_windowBorderColor; +} + + + + +QColor SubWindow::windowDecorationBorderColor() const +{ + return m_windowDecorationBorderColor; +} + + + + +void SubWindow::setActiveDecorationColor(const QColor &c) +{ + m_activeDecorationColor = c; +} + + + + +void SubWindow::setInactiveDecorationColor(const QColor &c) +{ + m_inactivDecorationColor = c; +} + + + + +void SubWindow::setLeftUpperBorderColor(const QColor &c) +{ + m_leftUpperBorderColor = c; +} + + + + +void SubWindow::setTitelTextColor(const QColor &c) +{ + m_titelTextColor = c; +} + + + + +void SubWindow::setWindowBorderColor(const QColor &c) +{ + m_windowBorderColor = c; +} + + + + +void SubWindow::setWindowDecorationBorderColor(const QColor &c) +{ + m_windowDecorationBorderColor = c; +} + + + + void SubWindow::moveEvent(QMoveEvent * event) { QMdiSubWindow::moveEvent(event); // if the window was moved and ISN'T minimized/maximized/fullscreen, // then save the current position - if (!isMaximized() && !isMinimized() && !isFullScreen()) + if(!isMaximized() && !isMinimized() && !isFullScreen()) { m_trackedNormalGeom.moveTopLeft(event->pos()); } } + + + void SubWindow::resizeEvent(QResizeEvent * event) { QMdiSubWindow::resizeEvent(event); // if the window was resized and ISN'T minimized/maximized/fullscreen, // then save the current size - if (!isMaximized() && !isMinimized() && !isFullScreen()) + if(!isMaximized() && !isMinimized() && !isFullScreen()) { m_trackedNormalGeom.setSize(event->size()); } -} \ No newline at end of file +} + +//void SubWindow::mousePressEvent(QMouseEvent *event) +//{ + +//}