|
lmms
Cross-platform music production software
|
#include <SubWindow.h>
Public Slots | |
| void | detach () |
| void | attach () |
| void | setVisible (bool visible) override |
Signals | |
| void | focusLost () |
Public Member Functions | |
| SubWindow (QWidget *parent=nullptr, Qt::WindowFlags windowFlags=QFlag(0)) | |
| QRect | getTrueNormalGeometry () const |
| SubWindow::getTrueNormalGeometry. | |
| QBrush | activeColor () const |
| QColor | textShadowColor () const |
| QColor | borderColor () const |
| QMargins | decorationMargins () const |
| void | setActiveColor (const QBrush &b) |
| void | setTextShadowColor (const QColor &c) |
| void | setBorderColor (const QColor &c) |
| int | titleBarHeight () const |
| int | frameWidth () const |
| bool | isDetachable () const |
| void | setDetachable (bool on) |
| bool | isDetached () const |
| void | setDetached (bool on) |
| void | updateTitleBar () |
Protected Member Functions | |
| void | moveEvent (QMoveEvent *event) override |
| void | resizeEvent (QResizeEvent *event) override |
| void | paintEvent (QPaintEvent *pe) override |
| SubWindow::paintEvent. | |
| void | changeEvent (QEvent *event) override |
| Triggers if the window title changes and calls adjustTitleBar(). | |
| void | showEvent (QShowEvent *e) override |
| bool | eventFilter (QObject *obj, QEvent *event) override |
| Override of QMdiSubWindow's event filter. | |
Properties | |
| QBrush | activeColor |
| QColor | textShadowColor |
| QColor | borderColor |
Private Slots | |
| void | focusChanged (QMdiSubWindow *subWindow) |
Private Member Functions | |
| void | adjustTitleBar () |
Static Private Member Functions | |
| static void | elideText (QLabel *label, QString text) |
| Stores the given text into the given label. | |
Private Attributes | |
| const QSize | m_buttonSize |
| const int | m_titleBarHeight |
| QPushButton * | m_closeBtn |
| QPushButton * | m_maximizeBtn |
| QPushButton * | m_restoreBtn |
| QPushButton * | m_detachBtn |
| QBrush | m_activeColor |
| QColor | m_textShadowColor |
| QColor | m_borderColor |
| QPoint | m_position |
| QRect | m_trackedNormalGeom |
| QLabel * | m_windowTitle |
| QGraphicsDropShadowEffect * | m_shadow |
| bool | m_hasFocus |
| bool | m_isDetachable |
The SubWindow class.
Because of a bug in the QMdiSubWindow class to save the right position and size of a subwindow in a project and because of the inability for customizing the title bar appearance, lmms implements its own subwindow class.
| lmms::gui::SubWindow::SubWindow | ( | QWidget * | parent = nullptr, |
| Qt::WindowFlags | windowFlags = QFlag(0) ) |
| QBrush lmms::gui::SubWindow::activeColor | ( | ) | const |
|
private |
Our title bar needs buttons for maximize/restore and close in the right upper corner. We check if the subwindow is maximizable and put the buttons on the right positions. At next we calculate the width of the title label and call elideText() for adding the window title to m_windowTitle (which is a QLabel)
|
slot |
| QColor lmms::gui::SubWindow::borderColor | ( | ) | const |
|
overrideprotected |
Triggers if the window title changes and calls adjustTitleBar().
| QMargins lmms::gui::SubWindow::decorationMargins | ( | ) | const |
|
slot |
|
staticprivate |
Stores the given text into the given label.
Shorts the text if it's too big for the labels width and adds three dots (...)
| label | Holds a pointer to the QLabel |
| text | The text which will be stored (and if needed broken down) into the QLabel. |
|
overrideprotected |
Override of QMdiSubWindow's event filter.
This is not how regular eventFilters work, it is never installed explicitly. Instead, it is installed by Qt and conveniently installs itself onto the child widget. Despite relying on internal implementation details, as of writing this it seems to be the best way to do so as soon as the widget is set.
|
privateslot |
|
signal |
| int lmms::gui::SubWindow::frameWidth | ( | ) | const |
| QRect lmms::gui::SubWindow::getTrueNormalGeometry | ( | ) | const |
SubWindow::getTrueNormalGeometry.
same as QWidet::normalGeometry, but works properly under X11 see https://bugreports.qt.io/browse/QTBUG-256
| bool lmms::gui::SubWindow::isDetachable | ( | ) | const |
| bool lmms::gui::SubWindow::isDetached | ( | ) | const |
|
overrideprotected |
Overrides the QMdiSubWindow::moveEvent() for saving the position of the subwindow into m_trackedNormalGeom. This position will be saved with the project because of an Qt bug which doesn't save the right position.
|
overrideprotected |
This draws our new title bar with custom colors and draws a window icon on the left upper corner.
|
overrideprotected |
At first we give the event to QMdiSubWindow::resizeEvent() which handles the event on its behavior.
On every resize event we have to adjust our title label.
At last we store the current size into m_trackedNormalGeom. This size will be saved with the project because of an Qt bug which doesn't save the right size.
| void lmms::gui::SubWindow::setActiveColor | ( | const QBrush & | b | ) |
| void lmms::gui::SubWindow::setBorderColor | ( | const QColor & | c | ) |
| void lmms::gui::SubWindow::setDetachable | ( | bool | on | ) |
| void lmms::gui::SubWindow::setDetached | ( | bool | on | ) |
| void lmms::gui::SubWindow::setTextShadowColor | ( | const QColor & | c | ) |
|
overrideslot |
|
overrideprotected |
| QColor lmms::gui::SubWindow::textShadowColor | ( | ) | const |
| int lmms::gui::SubWindow::titleBarHeight | ( | ) | const |
| void lmms::gui::SubWindow::updateTitleBar | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
readwrite |
|
readwrite |
|
readwrite |