LMMS
Loading...
Searching...
No Matches
lmms::gui::SubWindow Class Reference

The SubWindow class. More...

#include <SubWindow.h>

Inheritance diagram for lmms::gui::SubWindow:
lmms::gui::CarlaParamsSubWindow lmms::gui::vstSubWin

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
 SubWindow::moveEvent.
void resizeEvent (QResizeEvent *event) override
 SubWindow::resizeEvent.
void paintEvent (QPaintEvent *pe) override
 SubWindow::paintEvent.
void changeEvent (QEvent *event) override
 SubWindow::changeEvent.
void showEvent (QShowEvent *e) override
bool eventFilter (QObject *obj, QEvent *event) override
 SubWindow::eventFilter.

Properties

QBrush activeColor
QColor textShadowColor
QColor borderColor

Private Slots

void focusChanged (QMdiSubWindow *subWindow)

Private Member Functions

void adjustTitleBar ()
 SubWindow::adjustTitleBar.

Static Private Member Functions

static void elideText (QLabel *label, QString text)
 SubWindow::elideText.

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

Detailed Description

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.

Constructor & Destructor Documentation

◆ SubWindow()

lmms::gui::SubWindow::SubWindow ( QWidget * parent = nullptr,
Qt::WindowFlags windowFlags = QFlag(0) )

Member Function Documentation

◆ activeColor()

QBrush lmms::gui::SubWindow::activeColor ( ) const

◆ adjustTitleBar()

void lmms::gui::SubWindow::adjustTitleBar ( )
private

SubWindow::adjustTitleBar.

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)

◆ attach

void lmms::gui::SubWindow::attach ( )
slot

◆ borderColor()

QColor lmms::gui::SubWindow::borderColor ( ) const

◆ changeEvent()

void lmms::gui::SubWindow::changeEvent ( QEvent * event)
overrideprotected

SubWindow::changeEvent.

Triggers if the window title changes and calls adjustTitleBar().

Parameters
Event

◆ decorationMargins()

QMargins lmms::gui::SubWindow::decorationMargins ( ) const

◆ detach

void lmms::gui::SubWindow::detach ( )
slot

◆ elideText()

void lmms::gui::SubWindow::elideText ( QLabel * label,
QString text )
staticprivate

SubWindow::elideText.

Stores the given text into the given label. Shorts the text if it's too big for the labels width and adds three dots (...)

Parameters
label- holds a pointer to the QLabel
text- the text which will be stored (and if needed broken down) into the QLabel.

◆ eventFilter()

bool lmms::gui::SubWindow::eventFilter ( QObject * obj,
QEvent * event )
overrideprotected

SubWindow::eventFilter.

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.

◆ focusChanged

void lmms::gui::SubWindow::focusChanged ( QMdiSubWindow * subWindow)
privateslot

◆ focusLost

void lmms::gui::SubWindow::focusLost ( )
signal

◆ frameWidth()

int lmms::gui::SubWindow::frameWidth ( ) const

◆ getTrueNormalGeometry()

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

◆ isDetachable()

bool lmms::gui::SubWindow::isDetachable ( ) const

◆ isDetached()

bool lmms::gui::SubWindow::isDetached ( ) const

◆ moveEvent()

void lmms::gui::SubWindow::moveEvent ( QMoveEvent * event)
overrideprotected

SubWindow::moveEvent.

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. look at: https://bugreports.qt.io/browse/QTBUG-256

Parameters
Event

◆ paintEvent()

void lmms::gui::SubWindow::paintEvent ( QPaintEvent * pe)
overrideprotected

SubWindow::paintEvent.

This draws our new title bar with custom colors and draws a window icon on the left upper corner.

◆ resizeEvent()

void lmms::gui::SubWindow::resizeEvent ( QResizeEvent * event)
overrideprotected

SubWindow::resizeEvent.

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. look at: https://bugreports.qt.io/browse/QTBUG-256

Parameters
Event

◆ setActiveColor()

void lmms::gui::SubWindow::setActiveColor ( const QBrush & b)

◆ setBorderColor()

void lmms::gui::SubWindow::setBorderColor ( const QColor & c)

◆ setDetachable()

void lmms::gui::SubWindow::setDetachable ( bool on)

◆ setDetached()

void lmms::gui::SubWindow::setDetached ( bool on)

◆ setTextShadowColor()

void lmms::gui::SubWindow::setTextShadowColor ( const QColor & c)

◆ setVisible

void lmms::gui::SubWindow::setVisible ( bool visible)
overrideslot

◆ showEvent()

void lmms::gui::SubWindow::showEvent ( QShowEvent * e)
overrideprotected

◆ textShadowColor()

QColor lmms::gui::SubWindow::textShadowColor ( ) const

◆ titleBarHeight()

int lmms::gui::SubWindow::titleBarHeight ( ) const

◆ updateTitleBar()

void lmms::gui::SubWindow::updateTitleBar ( )

Member Data Documentation

◆ m_activeColor

QBrush lmms::gui::SubWindow::m_activeColor
private

◆ m_borderColor

QColor lmms::gui::SubWindow::m_borderColor
private

◆ m_buttonSize

const QSize lmms::gui::SubWindow::m_buttonSize
private

◆ m_closeBtn

QPushButton* lmms::gui::SubWindow::m_closeBtn
private

◆ m_detachBtn

QPushButton* lmms::gui::SubWindow::m_detachBtn
private

◆ m_hasFocus

bool lmms::gui::SubWindow::m_hasFocus
private

◆ m_isDetachable

bool lmms::gui::SubWindow::m_isDetachable
private

◆ m_maximizeBtn

QPushButton* lmms::gui::SubWindow::m_maximizeBtn
private

◆ m_position

QPoint lmms::gui::SubWindow::m_position
private

◆ m_restoreBtn

QPushButton* lmms::gui::SubWindow::m_restoreBtn
private

◆ m_shadow

QGraphicsDropShadowEffect* lmms::gui::SubWindow::m_shadow
private

◆ m_textShadowColor

QColor lmms::gui::SubWindow::m_textShadowColor
private

◆ m_titleBarHeight

const int lmms::gui::SubWindow::m_titleBarHeight
private

◆ m_trackedNormalGeom

QRect lmms::gui::SubWindow::m_trackedNormalGeom
private

◆ m_windowTitle

QLabel* lmms::gui::SubWindow::m_windowTitle
private

Property Documentation

◆ activeColor

QBrush lmms::gui::SubWindow::activeColor
readwrite

◆ borderColor

QColor lmms::gui::SubWindow::borderColor
readwrite

◆ textShadowColor

QColor lmms::gui::SubWindow::textShadowColor
readwrite

The documentation for this class was generated from the following files: