lmms
Cross-platform music production software
Loading...
Searching...
No Matches
SubWindow.h
Go to the documentation of this file.
1/*
2 * SubWindow.h - Implementation of QMdiSubWindow that correctly tracks
3 * the geometry that windows should be restored to.
4 * Workaround for https://bugreports.qt.io/browse/QTBUG-256
5 *
6 * Copyright (c) 2015 Colin Wallace <wallace.colin.a@gmail.com>
7 *
8 * This file is part of LMMS - https://lmms.io
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public
21 * License along with this program (see COPYING); if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301 USA.
24 *
25 */
26
27#ifndef LMMS_GUI_SUBWINDOW_H
28#define LMMS_GUI_SUBWINDOW_H
29
30#include <QMdiSubWindow>
31#include <QString>
32
33#include "lmms_export.h"
34
35class QGraphicsDropShadowEffect;
36class QLabel;
37class QPushButton;
38class QWidget;
39
40namespace lmms::gui
41{
42
43
44
49class LMMS_EXPORT SubWindow : public QMdiSubWindow
50{
51 Q_OBJECT
52 Q_PROPERTY( QBrush activeColor READ activeColor WRITE setActiveColor )
53 Q_PROPERTY( QColor textShadowColor READ textShadowColor WRITE setTextShadowColor )
54 Q_PROPERTY( QColor borderColor READ borderColor WRITE setBorderColor )
55
56public:
57 SubWindow( QWidget *parent = nullptr, Qt::WindowFlags windowFlags = QFlag(0) );
58 // same as QWidet::normalGeometry, but works properly under X11 (see https://bugreports.qt.io/browse/QTBUG-256)
59 QRect getTrueNormalGeometry() const;
60 QBrush activeColor() const;
61 QColor textShadowColor() const;
62 QColor borderColor() const;
63 QMargins decorationMargins() const;
64 void setActiveColor( const QBrush & b );
65 void setTextShadowColor( const QColor &c );
66 void setBorderColor( const QColor &c );
67 int titleBarHeight() const;
68 int frameWidth() const;
69 bool isDetachable() const;
70 void setDetachable(bool on);
71 bool isDetached() const;
72 void setDetached(bool on);
73
74 // TODO Needed to update the title bar when replacing instruments.
75 // Update works automatically if QMdiSubWindows are used.
76 void updateTitleBar();
77
78public slots:
79 void detach();
80 void attach();
81 void setVisible(bool visible) override;
82
83protected:
84 // hook the QWidget move/resize events to update the tracked geometry
85
90 // TODO: @param event
91 void moveEvent(QMoveEvent* event) override;
92
101 // TODO: @param event
102 void resizeEvent(QResizeEvent* event) override;
103
107 void paintEvent(QPaintEvent* pe) override;
108
110 // TODO: @param event
111 void changeEvent(QEvent* event) override;
112
113 void showEvent(QShowEvent* e) override;
114
120 bool eventFilter(QObject* obj, QEvent* event) override;
121
122signals:
123 void focusLost();
124
125private:
126 const QSize m_buttonSize;
128 QPushButton * m_closeBtn;
129 QPushButton * m_maximizeBtn;
130 QPushButton * m_restoreBtn;
131 QPushButton* m_detachBtn;
138 QGraphicsDropShadowEffect * m_shadow;
141
148 static void elideText( QLabel *label, QString text );
149
154 void adjustTitleBar();
155
156private slots:
157 void focusChanged( QMdiSubWindow * subWindow );
158};
159
160
161
162} // namespace lmms::gui
163
164#endif // LMMS_GUI_SUBWINDOW_H
const int m_titleBarHeight
Definition SubWindow.h:127
void attach()
Definition SubWindow.cpp:315
bool m_isDetachable
Definition SubWindow.h:140
QColor m_borderColor
Definition SubWindow.h:134
void changeEvent(QEvent *event) override
Triggers if the window title changes and calls adjustTitleBar().
Definition SubWindow.cpp:145
void setDetached(bool on)
Definition SubWindow.cpp:213
QBrush activeColor
Definition SubWindow.h:52
QPushButton * m_restoreBtn
Definition SubWindow.h:130
QColor textShadowColor
Definition SubWindow.h:53
QPushButton * m_maximizeBtn
Definition SubWindow.h:129
bool eventFilter(QObject *obj, QEvent *event) override
Override of QMdiSubWindow's event filter.
Definition SubWindow.cpp:545
void resizeEvent(QResizeEvent *event) override
Definition SubWindow.cpp:526
QRect m_trackedNormalGeom
Definition SubWindow.h:136
QLabel * m_windowTitle
Definition SubWindow.h:137
void detach()
Definition SubWindow.cpp:295
void setBorderColor(const QColor &c)
Definition SubWindow.cpp:287
void setTextShadowColor(const QColor &c)
Definition SubWindow.cpp:279
bool m_hasFocus
Definition SubWindow.h:139
bool isDetachable() const
Definition SubWindow.cpp:189
QColor m_textShadowColor
Definition SubWindow.h:133
void moveEvent(QMoveEvent *event) override
Definition SubWindow.cpp:401
SubWindow(QWidget *parent=nullptr, Qt::WindowFlags windowFlags=QFlag(0))
Definition SubWindow.cpp:53
QPushButton * m_detachBtn
Definition SubWindow.h:131
void focusChanged(QMdiSubWindow *subWindow)
Definition SubWindow.cpp:510
QRect getTrueNormalGeometry() const
SubWindow::getTrueNormalGeometry.
Definition SubWindow.cpp:239
void setActiveColor(const QBrush &b)
Definition SubWindow.cpp:271
QGraphicsDropShadowEffect * m_shadow
Definition SubWindow.h:138
QBrush m_activeColor
Definition SubWindow.h:132
QPushButton * m_closeBtn
Definition SubWindow.h:128
void showEvent(QShowEvent *e) override
Definition SubWindow.cpp:177
QMargins decorationMargins() const
Definition SubWindow.cpp:382
void paintEvent(QPaintEvent *pe) override
SubWindow::paintEvent.
Definition SubWindow.cpp:113
int frameWidth() const
Definition SubWindow.cpp:373
QColor borderColor
Definition SubWindow.h:54
void setDetachable(bool on)
Definition SubWindow.cpp:197
bool isDetached() const
Definition SubWindow.cpp:205
const QSize m_buttonSize
Definition SubWindow.h:126
void adjustTitleBar()
Definition SubWindow.cpp:415
void updateTitleBar()
Definition SubWindow.cpp:395
static void elideText(QLabel *label, QString text)
Stores the given text into the given label.
Definition SubWindow.cpp:222
int titleBarHeight() const
Definition SubWindow.cpp:362
QPoint m_position
Definition SubWindow.h:135
void setVisible(bool visible) override
Definition SubWindow.cpp:158
Definition AudioPortAudio.cpp:209