Skip to content

Commit

Permalink
fix: always show menu button
Browse files Browse the repository at this point in the history
Notice that WindowSystemMenuHint not mean user menu, but mean Close
Button, Do not use it in DTitlebar. See blow link for more:

https://doc.qt.io/qt-5/qt.html#WindowType-enum

Change-Id: Ifad262ea190c1fb4778edfd0b525ef0c04e0e4ff
  • Loading branch information
Iceyer committed Apr 23, 2019
1 parent 633617d commit 4612b6f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/widgets/dtitlebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,6 @@ void DTitlebarPrivate::updateButtonsState(Qt::WindowFlags type)
bool showClose = (type.testFlag(Qt::WindowCloseButtonHint) || forceShow) && !forceHide;
closeButton->setVisible(showClose);

bool showOption = (type.testFlag(Qt::WindowSystemMenuHint) || forceShow) && !isFullscreen;
optionButton->setVisible(showOption);

buttonArea->adjustSize();
buttonArea->resize(buttonArea->size());

Expand All @@ -335,8 +332,6 @@ void DTitlebarPrivate::updateButtonsState(Qt::WindowFlags type)

void DTitlebarPrivate::updateButtonsFunc()
{
optionButton->setDisabled(disableFlags.testFlag(Qt::WindowSystemMenuHint));

if (!targetWindowHandle) {
return;
}
Expand Down Expand Up @@ -1014,6 +1009,30 @@ void DTitlebar::resize(const QSize &sz)
DTitlebar::resize(sz.width(), sz.height());
}

bool DTitlebar::menuIsVisible() const
{
D_DC(DTitlebar);
return !d->optionButton->isVisible();
}

void DTitlebar::setMenuVisible(bool visible)
{
D_D(DTitlebar);
d->optionButton->setVisible(visible);
}

bool DTitlebar::menuIsDisabled() const
{
D_DC(DTitlebar);
return !d->optionButton->isEnabled();
}

void DTitlebar::setMenuDisabled(bool disabled)
{
D_D(DTitlebar);
d->optionButton->setDisabled(disabled);
}


/*!
* \~english \brief DTitlebar::setDisableFlags will disable button match flags.
Expand Down
6 changes: 6 additions & 0 deletions src/widgets/dtitlebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ class LIBDTKWIDGETSHARED_EXPORT DTitlebar : public QFrame, public DTK_CORE_NAMES
void resize(int width, int height);
void resize(const QSize &);

bool menuIsVisible() const;
void setMenuVisible(bool visible);

bool menuIsDisabled() const;
void setMenuDisabled(bool disabled);

void setDisableFlags(Qt::WindowFlags flags);
Qt::WindowFlags disableFlags() const;
Q_SIGNALS:
Expand Down

0 comments on commit 4612b6f

Please sign in to comment.