LMMS
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
52class LMMS_EXPORT SubWindow : public QMdiSubWindow
53{
54 Q_OBJECT
58
59public:
60 SubWindow( QWidget *parent = nullptr, Qt::WindowFlags windowFlags = QFlag(0) );
61 // same as QWidet::normalGeometry, but works properly under X11 (see https://bugreports.qt.io/browse/QTBUG-256)
63 QBrush activeColor() const;
64 QColor textShadowColor() const;
65 QColor borderColor() const;
66 QMargins decorationMargins() const;
67 void setActiveColor( const QBrush & b );
68 void setTextShadowColor( const QColor &c );
69 void setBorderColor( const QColor &c );
71 int frameWidth() const;
72 bool isDetachable() const;
73 void setDetachable(bool on);
74 bool isDetached() const;
75 void setDetached(bool on);
76
77 // TODO Needed to update the title bar when replacing instruments.
78 // Update works automatically if QMdiSubWindows are used.
79 void updateTitleBar();
80
81public slots:
82 void detach();
83 void attach();
84 void setVisible(bool visible) override;
85
86protected:
87 // hook the QWidget move/resize events to update the tracked geometry
88 void moveEvent(QMoveEvent* event) override;
89 void resizeEvent(QResizeEvent* event) override;
90 void paintEvent(QPaintEvent* pe) override;
91 void changeEvent(QEvent* event) override;
92 void showEvent(QShowEvent* e) override;
93 bool eventFilter(QObject* obj, QEvent* event) override;
94
95signals:
96 void focusLost();
97
98private:
101 QPushButton * m_closeBtn;
102 QPushButton * m_maximizeBtn;
103 QPushButton * m_restoreBtn;
104 QPushButton* m_detachBtn;
111 QGraphicsDropShadowEffect * m_shadow;
114
115 static void elideText( QLabel *label, QString text );
116 void adjustTitleBar();
117
118private slots:
119 void focusChanged( QMdiSubWindow * subWindow );
120};
121
122
123
124} // namespace lmms::gui
125
126#endif // LMMS_GUI_SUBWINDOW_H
#define READ(addr)
Definition Ay_Cpu.cpp:92
#define WRITE(addr, data)
Definition Ay_Cpu.cpp:93
#define override
Definition DistrhoDefines.h:73
const int m_titleBarHeight
Definition SubWindow.h:100
void attach()
Definition SubWindow.cpp:327
bool m_isDetachable
Definition SubWindow.h:113
QColor m_borderColor
Definition SubWindow.h:107
void changeEvent(QEvent *event) override
SubWindow::changeEvent.
Definition SubWindow.cpp:157
void setDetached(bool on)
Definition SubWindow.cpp:215
QBrush activeColor
Definition SubWindow.h:55
QPushButton * m_restoreBtn
Definition SubWindow.h:103
QColor textShadowColor
Definition SubWindow.h:56
QPushButton * m_maximizeBtn
Definition SubWindow.h:102
bool eventFilter(QObject *obj, QEvent *event) override
SubWindow::eventFilter.
Definition SubWindow.cpp:597
void resizeEvent(QResizeEvent *event) override
SubWindow::resizeEvent.
Definition SubWindow.cpp:569
QRect m_trackedNormalGeom
Definition SubWindow.h:109
QLabel * m_windowTitle
Definition SubWindow.h:110
void detach()
Definition SubWindow.cpp:307
void setBorderColor(const QColor &c)
Definition SubWindow.cpp:299
void setTextShadowColor(const QColor &c)
Definition SubWindow.cpp:291
bool m_hasFocus
Definition SubWindow.h:112
bool isDetachable() const
Definition SubWindow.cpp:191
QColor m_textShadowColor
Definition SubWindow.h:106
void moveEvent(QMoveEvent *event) override
SubWindow::moveEvent.
Definition SubWindow.cpp:422
SubWindow(QWidget *parent=nullptr, Qt::WindowFlags windowFlags=QFlag(0))
Definition SubWindow.cpp:53
QPushButton * m_detachBtn
Definition SubWindow.h:104
void focusChanged(QMdiSubWindow *subWindow)
Definition SubWindow.cpp:539
QRect getTrueNormalGeometry() const
SubWindow::getTrueNormalGeometry.
Definition SubWindow.cpp:251
void setActiveColor(const QBrush &b)
Definition SubWindow.cpp:283
QGraphicsDropShadowEffect * m_shadow
Definition SubWindow.h:111
QBrush m_activeColor
Definition SubWindow.h:105
QPushButton * m_closeBtn
Definition SubWindow.h:101
void showEvent(QShowEvent *e) override
Definition SubWindow.cpp:179
QMargins decorationMargins() const
Definition SubWindow.cpp:394
void paintEvent(QPaintEvent *pe) override
SubWindow::paintEvent.
Definition SubWindow.cpp:119
int frameWidth() const
Definition SubWindow.cpp:385
QColor borderColor
Definition SubWindow.h:57
void setDetachable(bool on)
Definition SubWindow.cpp:199
bool isDetached() const
Definition SubWindow.cpp:207
const QSize m_buttonSize
Definition SubWindow.h:99
void adjustTitleBar()
SubWindow::adjustTitleBar.
Definition SubWindow.cpp:444
void updateTitleBar()
Definition SubWindow.cpp:407
static void elideText(QLabel *label, QString text)
SubWindow::elideText.
Definition SubWindow.cpp:234
int titleBarHeight() const
Definition SubWindow.cpp:374
QPoint m_position
Definition SubWindow.h:108
void setVisible(bool visible) override
Definition SubWindow.cpp:170
* e
Definition inflate.c:1404
static uintptr_t parent
Definition pugl.h:1644
Definition AudioPortAudio.cpp:223
const char * text
Definition swell-functions.h:167
return c
Definition crypt.c:175
b
Definition crypt.c:628
#define const
Definition zconf.h:137