2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
2024-02-02 13:36:10 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2012-04-20 11:54:52 +00:00
|
|
|
|
Mark all of Qt as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses in this and some other modules is still
extremely high, too high for anyone to tackle in a short amount of
time. Even if they're not concentrated in just a few TUs, we need to
make progress on a global QT_NO_FOREACH default, so grab the nettle
and stick to our strategy:
Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from
creeping in, and whitelist the affected TUs by #undef'ing
QT_NO_FOREACH locally, at the top of each file. For TUs that are part
of a larger executable, this requires these files to be compiled
separately, so add them to NO_PCH_SOURCES (which implies
NO_UNITY_BUILD_SOURCES, too).
In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the
#undef QT_NO_FOREACH to indicate that these actually test the macro.
Task-number: QTBUG-115839
Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-08-07 15:59:46 +00:00
|
|
|
#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
|
|
|
|
|
2012-04-20 11:54:52 +00:00
|
|
|
#include "controls.h"
|
|
|
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QButtonGroup>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
HintControl::HintControl(QWidget *parent)
|
|
|
|
: QGroupBox(tr("Hints"), parent)
|
|
|
|
, msWindowsFixedSizeDialogCheckBox(new QCheckBox(tr("MS Windows fixed size dialog")))
|
|
|
|
, x11BypassWindowManagerCheckBox(new QCheckBox(tr("X11 bypass window manager")))
|
|
|
|
, framelessWindowCheckBox(new QCheckBox(tr("Frameless window")))
|
|
|
|
, windowTitleCheckBox(new QCheckBox(tr("Window title")))
|
|
|
|
, windowSystemMenuCheckBox(new QCheckBox(tr("Window system menu")))
|
|
|
|
, windowMinimizeButtonCheckBox(new QCheckBox(tr("Window minimize button")))
|
|
|
|
, windowMaximizeButtonCheckBox(new QCheckBox(tr("Window maximize button")))
|
2012-11-28 18:46:04 +00:00
|
|
|
, windowFullscreenButtonCheckBox(new QCheckBox(tr("Window fullscreen button")))
|
2012-04-20 11:54:52 +00:00
|
|
|
, windowCloseButtonCheckBox(new QCheckBox(tr("Window close button")))
|
|
|
|
, windowContextHelpButtonCheckBox(new QCheckBox(tr("Window context help button")))
|
|
|
|
, windowShadeButtonCheckBox(new QCheckBox(tr("Window shade button")))
|
|
|
|
, windowStaysOnTopCheckBox(new QCheckBox(tr("Window stays on top")))
|
|
|
|
, windowStaysOnBottomCheckBox(new QCheckBox(tr("Window stays on bottom")))
|
2024-11-12 10:54:10 +00:00
|
|
|
, customizeWindowGroup(new QGroupBox(tr("Customize window title bar controls")))
|
2012-06-07 09:00:31 +00:00
|
|
|
, transparentForInputCheckBox(new QCheckBox(tr("Transparent for input")))
|
2022-09-19 18:09:04 +00:00
|
|
|
, noDropShadowCheckBox(new QCheckBox(tr("No drop shadow")))
|
Introduce Qt::ExpandedClientAreaHint
The hint requests that the window's client area is expanded to fill
parts of the window that might be (partially) covered by, or
conflicting with, other (system) UI elements, such as the window's
title bar, resize controls, or a status bar.
The safe area margins of the window will reflect any areas that
may have conflicting UI elements.
If the client area is expanded into the area previously covered
by the frame margins, the frame margins are reduced accordingly,
as the frame margins represent the non-client-area parts of the
window.
This new flag replaces, and overlaps in value, with the existing
Qt::MaximizeUsingFullscreenGeometryHint, as the latter was added
to cover this exact use-case for mobile platforms. Now that we
have the use-case on desktop platforms as well we want to use a
more generic flag, so the old flag has been deprecated.
Semantically, on iOS and Android, without the flags set, the
window can be seen as being maximized to take up the entire
screen, but with a frameMargin() that reflects the system
status bar and resize controls. That's not technically how
we implement things right now, but this is an implementation
detail that will be changed in a follow-up.
On macOS the flag maps to NSWindowStyleMaskFullSizeContentView,
and on Windows we have an implementation cooking that uses the
DwmExtendFrameIntoClientArea function.
Task-number: QTBUG-127634
Change-Id: I9b6863b1550ccc056c16bce235d87b26a7d239b9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2024-11-11 21:55:36 +00:00
|
|
|
, expandedClientAreaCheckBox(new QCheckBox(tr("Expanded client area")))
|
2024-11-12 13:35:17 +00:00
|
|
|
, noTitleBarBackgroundCheckBox(new QCheckBox(tr("No titlebar background")))
|
2012-04-20 11:54:52 +00:00
|
|
|
{
|
|
|
|
connect(msWindowsFixedSizeDialogCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(x11BypassWindowManagerCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(framelessWindowCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(windowTitleCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(windowSystemMenuCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(windowMinimizeButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(windowMaximizeButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
2012-11-28 18:46:04 +00:00
|
|
|
connect(windowFullscreenButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
2012-04-20 11:54:52 +00:00
|
|
|
connect(windowCloseButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(windowContextHelpButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(windowShadeButtonCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(windowStaysOnTopCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
|
|
|
connect(windowStaysOnBottomCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
2024-11-12 10:54:10 +00:00
|
|
|
connect(customizeWindowGroup, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
2012-06-07 09:00:31 +00:00
|
|
|
connect(transparentForInputCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
2022-09-19 18:09:04 +00:00
|
|
|
connect(noDropShadowCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
Introduce Qt::ExpandedClientAreaHint
The hint requests that the window's client area is expanded to fill
parts of the window that might be (partially) covered by, or
conflicting with, other (system) UI elements, such as the window's
title bar, resize controls, or a status bar.
The safe area margins of the window will reflect any areas that
may have conflicting UI elements.
If the client area is expanded into the area previously covered
by the frame margins, the frame margins are reduced accordingly,
as the frame margins represent the non-client-area parts of the
window.
This new flag replaces, and overlaps in value, with the existing
Qt::MaximizeUsingFullscreenGeometryHint, as the latter was added
to cover this exact use-case for mobile platforms. Now that we
have the use-case on desktop platforms as well we want to use a
more generic flag, so the old flag has been deprecated.
Semantically, on iOS and Android, without the flags set, the
window can be seen as being maximized to take up the entire
screen, but with a frameMargin() that reflects the system
status bar and resize controls. That's not technically how
we implement things right now, but this is an implementation
detail that will be changed in a follow-up.
On macOS the flag maps to NSWindowStyleMaskFullSizeContentView,
and on Windows we have an implementation cooking that uses the
DwmExtendFrameIntoClientArea function.
Task-number: QTBUG-127634
Change-Id: I9b6863b1550ccc056c16bce235d87b26a7d239b9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2024-11-11 21:55:36 +00:00
|
|
|
connect(expandedClientAreaCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
2024-11-12 13:35:17 +00:00
|
|
|
connect(noTitleBarBackgroundCheckBox, SIGNAL(clicked()), this, SLOT(slotCheckBoxChanged()));
|
Introduce Qt::ExpandedClientAreaHint
The hint requests that the window's client area is expanded to fill
parts of the window that might be (partially) covered by, or
conflicting with, other (system) UI elements, such as the window's
title bar, resize controls, or a status bar.
The safe area margins of the window will reflect any areas that
may have conflicting UI elements.
If the client area is expanded into the area previously covered
by the frame margins, the frame margins are reduced accordingly,
as the frame margins represent the non-client-area parts of the
window.
This new flag replaces, and overlaps in value, with the existing
Qt::MaximizeUsingFullscreenGeometryHint, as the latter was added
to cover this exact use-case for mobile platforms. Now that we
have the use-case on desktop platforms as well we want to use a
more generic flag, so the old flag has been deprecated.
Semantically, on iOS and Android, without the flags set, the
window can be seen as being maximized to take up the entire
screen, but with a frameMargin() that reflects the system
status bar and resize controls. That's not technically how
we implement things right now, but this is an implementation
detail that will be changed in a follow-up.
On macOS the flag maps to NSWindowStyleMaskFullSizeContentView,
and on Windows we have an implementation cooking that uses the
DwmExtendFrameIntoClientArea function.
Task-number: QTBUG-127634
Change-Id: I9b6863b1550ccc056c16bce235d87b26a7d239b9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2024-11-11 21:55:36 +00:00
|
|
|
|
2024-11-12 10:54:10 +00:00
|
|
|
auto *layout = new QHBoxLayout(this);
|
2012-04-20 11:54:52 +00:00
|
|
|
layout->setSpacing(0);
|
2020-07-23 11:54:47 +00:00
|
|
|
layout->setContentsMargins(ControlLayoutMargin, ControlLayoutMargin,
|
|
|
|
ControlLayoutMargin, ControlLayoutMargin);
|
2024-11-12 10:54:10 +00:00
|
|
|
|
|
|
|
auto *basicHintsLayout = new QVBoxLayout;
|
|
|
|
basicHintsLayout->setSpacing(0);
|
|
|
|
basicHintsLayout->setContentsMargins(ControlLayoutMargin, ControlLayoutMargin,
|
|
|
|
ControlLayoutMargin, ControlLayoutMargin);
|
|
|
|
|
|
|
|
basicHintsLayout->addWidget(framelessWindowCheckBox);
|
|
|
|
basicHintsLayout->addWidget(noDropShadowCheckBox);
|
|
|
|
basicHintsLayout->addWidget(windowStaysOnTopCheckBox);
|
|
|
|
basicHintsLayout->addWidget(windowStaysOnBottomCheckBox);
|
|
|
|
basicHintsLayout->addWidget(transparentForInputCheckBox);
|
|
|
|
basicHintsLayout->addWidget(msWindowsFixedSizeDialogCheckBox);
|
|
|
|
basicHintsLayout->addWidget(x11BypassWindowManagerCheckBox);
|
Introduce Qt::ExpandedClientAreaHint
The hint requests that the window's client area is expanded to fill
parts of the window that might be (partially) covered by, or
conflicting with, other (system) UI elements, such as the window's
title bar, resize controls, or a status bar.
The safe area margins of the window will reflect any areas that
may have conflicting UI elements.
If the client area is expanded into the area previously covered
by the frame margins, the frame margins are reduced accordingly,
as the frame margins represent the non-client-area parts of the
window.
This new flag replaces, and overlaps in value, with the existing
Qt::MaximizeUsingFullscreenGeometryHint, as the latter was added
to cover this exact use-case for mobile platforms. Now that we
have the use-case on desktop platforms as well we want to use a
more generic flag, so the old flag has been deprecated.
Semantically, on iOS and Android, without the flags set, the
window can be seen as being maximized to take up the entire
screen, but with a frameMargin() that reflects the system
status bar and resize controls. That's not technically how
we implement things right now, but this is an implementation
detail that will be changed in a follow-up.
On macOS the flag maps to NSWindowStyleMaskFullSizeContentView,
and on Windows we have an implementation cooking that uses the
DwmExtendFrameIntoClientArea function.
Task-number: QTBUG-127634
Change-Id: I9b6863b1550ccc056c16bce235d87b26a7d239b9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2024-11-11 21:55:36 +00:00
|
|
|
basicHintsLayout->addWidget(expandedClientAreaCheckBox);
|
2024-11-12 13:35:17 +00:00
|
|
|
basicHintsLayout->addWidget(noTitleBarBackgroundCheckBox);
|
2024-11-12 10:54:10 +00:00
|
|
|
layout->addLayout(basicHintsLayout);
|
|
|
|
|
|
|
|
customizeWindowGroup->setCheckable(true);
|
|
|
|
customizeWindowGroup->setChecked(false);
|
|
|
|
auto *customizeWindowLayout = new QVBoxLayout(customizeWindowGroup);
|
|
|
|
customizeWindowLayout->setSpacing(0);
|
|
|
|
customizeWindowLayout->setContentsMargins(ControlLayoutMargin, ControlLayoutMargin,
|
|
|
|
ControlLayoutMargin, ControlLayoutMargin);
|
|
|
|
|
|
|
|
customizeWindowLayout->addWidget(windowTitleCheckBox);
|
|
|
|
customizeWindowLayout->addWidget(windowSystemMenuCheckBox);
|
|
|
|
customizeWindowLayout->addWidget(windowMinimizeButtonCheckBox);
|
|
|
|
customizeWindowLayout->addWidget(windowShadeButtonCheckBox);
|
|
|
|
customizeWindowLayout->addWidget(windowMaximizeButtonCheckBox);
|
|
|
|
customizeWindowLayout->addWidget(windowFullscreenButtonCheckBox);
|
|
|
|
customizeWindowLayout->addWidget(windowCloseButtonCheckBox);
|
|
|
|
customizeWindowLayout->addWidget(windowContextHelpButtonCheckBox);
|
|
|
|
|
|
|
|
layout->addWidget(customizeWindowGroup);
|
2012-04-20 11:54:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Qt::WindowFlags HintControl::hints() const
|
|
|
|
{
|
2019-11-18 16:01:26 +00:00
|
|
|
Qt::WindowFlags flags;
|
2012-04-20 11:54:52 +00:00
|
|
|
if (msWindowsFixedSizeDialogCheckBox->isChecked())
|
|
|
|
flags |= Qt::MSWindowsFixedSizeDialogHint;
|
|
|
|
if (x11BypassWindowManagerCheckBox->isChecked())
|
|
|
|
flags |= Qt::X11BypassWindowManagerHint;
|
|
|
|
if (framelessWindowCheckBox->isChecked())
|
|
|
|
flags |= Qt::FramelessWindowHint;
|
|
|
|
if (windowTitleCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowTitleHint;
|
|
|
|
if (windowSystemMenuCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowSystemMenuHint;
|
|
|
|
if (windowMinimizeButtonCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowMinimizeButtonHint;
|
|
|
|
if (windowMaximizeButtonCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowMaximizeButtonHint;
|
2012-11-28 18:46:04 +00:00
|
|
|
if (windowFullscreenButtonCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowFullscreenButtonHint;
|
2012-04-20 11:54:52 +00:00
|
|
|
if (windowCloseButtonCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowCloseButtonHint;
|
|
|
|
if (windowContextHelpButtonCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowContextHelpButtonHint;
|
|
|
|
if (windowShadeButtonCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowShadeButtonHint;
|
|
|
|
if (windowStaysOnTopCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowStaysOnTopHint;
|
|
|
|
if (windowStaysOnBottomCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowStaysOnBottomHint;
|
2024-11-12 10:54:10 +00:00
|
|
|
if (customizeWindowGroup->isChecked())
|
2012-04-20 11:54:52 +00:00
|
|
|
flags |= Qt::CustomizeWindowHint;
|
2012-06-07 09:00:31 +00:00
|
|
|
if (transparentForInputCheckBox->isChecked())
|
|
|
|
flags |= Qt::WindowTransparentForInput;
|
2022-09-19 18:09:04 +00:00
|
|
|
if (noDropShadowCheckBox->isChecked())
|
|
|
|
flags |= Qt::NoDropShadowWindowHint;
|
Introduce Qt::ExpandedClientAreaHint
The hint requests that the window's client area is expanded to fill
parts of the window that might be (partially) covered by, or
conflicting with, other (system) UI elements, such as the window's
title bar, resize controls, or a status bar.
The safe area margins of the window will reflect any areas that
may have conflicting UI elements.
If the client area is expanded into the area previously covered
by the frame margins, the frame margins are reduced accordingly,
as the frame margins represent the non-client-area parts of the
window.
This new flag replaces, and overlaps in value, with the existing
Qt::MaximizeUsingFullscreenGeometryHint, as the latter was added
to cover this exact use-case for mobile platforms. Now that we
have the use-case on desktop platforms as well we want to use a
more generic flag, so the old flag has been deprecated.
Semantically, on iOS and Android, without the flags set, the
window can be seen as being maximized to take up the entire
screen, but with a frameMargin() that reflects the system
status bar and resize controls. That's not technically how
we implement things right now, but this is an implementation
detail that will be changed in a follow-up.
On macOS the flag maps to NSWindowStyleMaskFullSizeContentView,
and on Windows we have an implementation cooking that uses the
DwmExtendFrameIntoClientArea function.
Task-number: QTBUG-127634
Change-Id: I9b6863b1550ccc056c16bce235d87b26a7d239b9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2024-11-11 21:55:36 +00:00
|
|
|
if (expandedClientAreaCheckBox->isChecked())
|
|
|
|
flags |= Qt::ExpandedClientAreaHint;
|
2024-11-12 13:35:17 +00:00
|
|
|
if (noTitleBarBackgroundCheckBox->isChecked())
|
|
|
|
flags |= Qt::NoTitleBarBackgroundHint;
|
2012-04-20 11:54:52 +00:00
|
|
|
return flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
void HintControl::setHints(Qt::WindowFlags flags)
|
|
|
|
{
|
|
|
|
msWindowsFixedSizeDialogCheckBox->setChecked(flags & Qt::MSWindowsFixedSizeDialogHint);
|
|
|
|
x11BypassWindowManagerCheckBox->setChecked(flags & Qt::X11BypassWindowManagerHint);
|
|
|
|
framelessWindowCheckBox->setChecked(flags & Qt::FramelessWindowHint);
|
|
|
|
windowTitleCheckBox->setChecked(flags & Qt::WindowTitleHint);
|
|
|
|
windowSystemMenuCheckBox->setChecked(flags & Qt::WindowSystemMenuHint);
|
|
|
|
windowMinimizeButtonCheckBox->setChecked(flags & Qt::WindowMinimizeButtonHint);
|
|
|
|
windowMaximizeButtonCheckBox->setChecked(flags & Qt::WindowMaximizeButtonHint);
|
2012-11-28 18:46:04 +00:00
|
|
|
windowFullscreenButtonCheckBox->setChecked(flags & Qt::WindowFullscreenButtonHint);
|
2012-04-20 11:54:52 +00:00
|
|
|
windowCloseButtonCheckBox->setChecked(flags & Qt::WindowCloseButtonHint);
|
|
|
|
windowContextHelpButtonCheckBox->setChecked(flags & Qt::WindowContextHelpButtonHint);
|
|
|
|
windowShadeButtonCheckBox->setChecked(flags & Qt::WindowShadeButtonHint);
|
|
|
|
windowStaysOnTopCheckBox->setChecked(flags & Qt::WindowStaysOnTopHint);
|
|
|
|
windowStaysOnBottomCheckBox->setChecked(flags & Qt::WindowStaysOnBottomHint);
|
2024-11-12 10:54:10 +00:00
|
|
|
customizeWindowGroup->setChecked(flags & Qt::CustomizeWindowHint);
|
2012-06-07 09:00:31 +00:00
|
|
|
transparentForInputCheckBox->setChecked(flags & Qt::WindowTransparentForInput);
|
2022-09-19 18:09:04 +00:00
|
|
|
noDropShadowCheckBox->setChecked(flags & Qt::NoDropShadowWindowHint);
|
Introduce Qt::ExpandedClientAreaHint
The hint requests that the window's client area is expanded to fill
parts of the window that might be (partially) covered by, or
conflicting with, other (system) UI elements, such as the window's
title bar, resize controls, or a status bar.
The safe area margins of the window will reflect any areas that
may have conflicting UI elements.
If the client area is expanded into the area previously covered
by the frame margins, the frame margins are reduced accordingly,
as the frame margins represent the non-client-area parts of the
window.
This new flag replaces, and overlaps in value, with the existing
Qt::MaximizeUsingFullscreenGeometryHint, as the latter was added
to cover this exact use-case for mobile platforms. Now that we
have the use-case on desktop platforms as well we want to use a
more generic flag, so the old flag has been deprecated.
Semantically, on iOS and Android, without the flags set, the
window can be seen as being maximized to take up the entire
screen, but with a frameMargin() that reflects the system
status bar and resize controls. That's not technically how
we implement things right now, but this is an implementation
detail that will be changed in a follow-up.
On macOS the flag maps to NSWindowStyleMaskFullSizeContentView,
and on Windows we have an implementation cooking that uses the
DwmExtendFrameIntoClientArea function.
Task-number: QTBUG-127634
Change-Id: I9b6863b1550ccc056c16bce235d87b26a7d239b9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io>
2024-11-11 21:55:36 +00:00
|
|
|
expandedClientAreaCheckBox->setChecked(flags & Qt::ExpandedClientAreaHint);
|
2024-11-12 13:35:17 +00:00
|
|
|
noTitleBarBackgroundCheckBox->setChecked(flags & Qt::NoTitleBarBackgroundHint);
|
2012-04-20 11:54:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HintControl::slotCheckBoxChanged()
|
|
|
|
{
|
|
|
|
emit changed(hints());
|
|
|
|
}
|
|
|
|
|
2017-02-03 14:55:49 +00:00
|
|
|
WindowStateControl::WindowStateControl(QWidget *parent)
|
2012-04-20 11:54:52 +00:00
|
|
|
: QWidget(parent)
|
|
|
|
, group(new QButtonGroup)
|
2017-02-03 14:55:49 +00:00
|
|
|
, restoreButton(new QCheckBox(tr("Normal")))
|
|
|
|
, minimizeButton(new QCheckBox(tr("Minimized")))
|
|
|
|
, maximizeButton(new QCheckBox(tr("Maximized")))
|
|
|
|
, fullscreenButton(new QCheckBox(tr("Fullscreen")))
|
2012-04-20 11:54:52 +00:00
|
|
|
{
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
2017-02-03 14:55:49 +00:00
|
|
|
group->setExclusive(false);
|
2020-07-23 11:54:47 +00:00
|
|
|
layout->setContentsMargins(ControlLayoutMargin, ControlLayoutMargin,
|
|
|
|
ControlLayoutMargin, ControlLayoutMargin);
|
2012-04-20 11:54:52 +00:00
|
|
|
group->addButton(restoreButton, Qt::WindowNoState);
|
2017-02-03 14:55:49 +00:00
|
|
|
restoreButton->setEnabled(false);
|
2012-04-20 11:54:52 +00:00
|
|
|
layout->addWidget(restoreButton);
|
2017-02-03 14:55:49 +00:00
|
|
|
group->addButton(minimizeButton, Qt::WindowMinimized);
|
|
|
|
layout->addWidget(minimizeButton);
|
2012-04-20 11:54:52 +00:00
|
|
|
group->addButton(maximizeButton, Qt::WindowMaximized);
|
|
|
|
layout->addWidget(maximizeButton);
|
|
|
|
group->addButton(fullscreenButton, Qt::WindowFullScreen);
|
|
|
|
layout->addWidget(fullscreenButton);
|
2020-09-25 07:49:47 +00:00
|
|
|
connect(group, &QButtonGroup::idReleased, this, &WindowStateControl::stateChanged);
|
2012-04-20 11:54:52 +00:00
|
|
|
}
|
|
|
|
|
2017-02-03 14:55:49 +00:00
|
|
|
Qt::WindowStates WindowStateControl::state() const
|
2012-04-20 11:54:52 +00:00
|
|
|
{
|
2017-02-03 14:55:49 +00:00
|
|
|
Qt::WindowStates states;
|
|
|
|
foreach (QAbstractButton *button, group->buttons()) {
|
|
|
|
if (button->isChecked())
|
|
|
|
states |= Qt::WindowState(group->id(button));
|
|
|
|
}
|
|
|
|
return states;
|
2012-04-20 11:54:52 +00:00
|
|
|
}
|
|
|
|
|
2017-02-03 14:55:49 +00:00
|
|
|
void WindowStateControl::setState(Qt::WindowStates s)
|
2012-04-20 11:54:52 +00:00
|
|
|
{
|
|
|
|
group->blockSignals(true);
|
2017-02-03 14:55:49 +00:00
|
|
|
foreach (QAbstractButton *button, group->buttons())
|
|
|
|
button->setChecked(s & Qt::WindowState(group->id(button)));
|
2012-04-20 11:54:52 +00:00
|
|
|
|
2017-02-03 14:55:49 +00:00
|
|
|
if (!(s & (Qt::WindowMaximized | Qt::WindowFullScreen)))
|
|
|
|
restoreButton->setChecked(true);
|
2012-04-20 11:54:52 +00:00
|
|
|
|
2017-02-03 14:55:49 +00:00
|
|
|
group->blockSignals(false);
|
2012-04-20 11:54:52 +00:00
|
|
|
}
|
|
|
|
|
2017-02-03 14:55:49 +00:00
|
|
|
WindowStatesControl::WindowStatesControl(QWidget *parent)
|
2012-04-20 11:54:52 +00:00
|
|
|
: QGroupBox(tr("States"), parent)
|
2017-02-03 14:55:49 +00:00
|
|
|
, visibleCheckBox(new QCheckBox(tr("Visible")))
|
|
|
|
, activeCheckBox(new QCheckBox(tr("Active")))
|
|
|
|
, stateControl(new WindowStateControl)
|
2012-04-20 11:54:52 +00:00
|
|
|
{
|
|
|
|
QHBoxLayout *layout = new QHBoxLayout(this);
|
|
|
|
layout->setSpacing(0);
|
2020-07-23 11:54:47 +00:00
|
|
|
layout->setContentsMargins(ControlLayoutMargin, ControlLayoutMargin,
|
|
|
|
ControlLayoutMargin, ControlLayoutMargin);
|
2017-02-03 14:55:49 +00:00
|
|
|
connect(visibleCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
|
|
|
|
layout->addWidget(visibleCheckBox);
|
|
|
|
connect(activeCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
|
|
|
|
layout->addWidget(activeCheckBox);
|
2012-04-20 11:54:52 +00:00
|
|
|
layout->addWidget(stateControl);
|
2017-02-03 14:55:49 +00:00
|
|
|
connect(stateControl, SIGNAL(stateChanged(int)), this, SIGNAL(changed()));
|
2012-04-20 11:54:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Qt::WindowStates WindowStatesControl::states() const
|
|
|
|
{
|
|
|
|
Qt::WindowStates s = stateControl->state();
|
2012-07-11 13:12:26 +00:00
|
|
|
if (activeValue())
|
|
|
|
s |= Qt::WindowActive;
|
2012-04-20 11:54:52 +00:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowStatesControl::setStates(Qt::WindowStates s)
|
|
|
|
{
|
2017-02-03 14:55:49 +00:00
|
|
|
stateControl->setState(s);
|
2012-07-11 13:12:26 +00:00
|
|
|
setActiveValue(s & Qt::WindowActive);
|
2012-04-20 11:54:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool WindowStatesControl::visibleValue() const
|
|
|
|
{
|
|
|
|
return visibleCheckBox && visibleCheckBox->isChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowStatesControl::setVisibleValue(bool v)
|
|
|
|
{
|
|
|
|
if (visibleCheckBox) {
|
|
|
|
visibleCheckBox->blockSignals(true);
|
|
|
|
visibleCheckBox->setChecked(v);
|
|
|
|
visibleCheckBox->blockSignals(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-11 13:12:26 +00:00
|
|
|
bool WindowStatesControl::activeValue() const
|
|
|
|
{
|
|
|
|
return activeCheckBox && activeCheckBox->isChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowStatesControl::setActiveValue(bool v)
|
|
|
|
{
|
|
|
|
if (activeCheckBox) {
|
|
|
|
activeCheckBox->blockSignals(true);
|
|
|
|
activeCheckBox->setChecked(v);
|
|
|
|
activeCheckBox->blockSignals(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-20 11:54:52 +00:00
|
|
|
TypeControl::TypeControl(QWidget *parent)
|
|
|
|
: QGroupBox(tr("Type"), parent)
|
|
|
|
, group(new QButtonGroup)
|
|
|
|
, windowRadioButton(new QRadioButton(tr("Window")))
|
|
|
|
, dialogRadioButton(new QRadioButton(tr("Dialog")))
|
|
|
|
, sheetRadioButton(new QRadioButton(tr("Sheet")))
|
|
|
|
, drawerRadioButton(new QRadioButton(tr("Drawer")))
|
|
|
|
, popupRadioButton(new QRadioButton(tr("Popup")))
|
|
|
|
, toolRadioButton(new QRadioButton(tr("Tool")))
|
|
|
|
, toolTipRadioButton(new QRadioButton(tr("Tooltip")))
|
|
|
|
, splashScreenRadioButton(new QRadioButton(tr("Splash screen")))
|
|
|
|
{
|
|
|
|
group->setExclusive(true);
|
|
|
|
QGridLayout *layout = new QGridLayout(this);
|
|
|
|
layout->setSpacing(0);
|
2020-07-23 11:54:47 +00:00
|
|
|
layout->setContentsMargins(ControlLayoutMargin, ControlLayoutMargin,
|
|
|
|
ControlLayoutMargin, ControlLayoutMargin);
|
2012-04-20 11:54:52 +00:00
|
|
|
group->addButton(windowRadioButton, Qt::Window);
|
|
|
|
layout->addWidget(windowRadioButton, 0, 0);
|
|
|
|
group->addButton(dialogRadioButton, Qt::Dialog);
|
|
|
|
layout->addWidget(dialogRadioButton, 1, 0);
|
|
|
|
group->addButton(sheetRadioButton, Qt::Sheet);
|
|
|
|
layout->addWidget(sheetRadioButton, 2, 0);
|
|
|
|
group->addButton(drawerRadioButton, Qt::Drawer);
|
|
|
|
layout->addWidget(drawerRadioButton, 3, 0);
|
|
|
|
group->addButton(popupRadioButton, Qt::Popup);
|
|
|
|
layout->addWidget(popupRadioButton, 0, 1);
|
|
|
|
group->addButton(toolRadioButton, Qt::Tool);
|
|
|
|
layout->addWidget(toolRadioButton, 1, 1);
|
|
|
|
group->addButton(toolTipRadioButton, Qt::ToolTip);
|
|
|
|
layout->addWidget(toolTipRadioButton, 2, 1);
|
|
|
|
group->addButton(splashScreenRadioButton, Qt::SplashScreen);
|
|
|
|
layout->addWidget(splashScreenRadioButton, 3, 1);
|
2020-09-25 07:49:47 +00:00
|
|
|
connect(group, &QButtonGroup::idReleased, this, &TypeControl::slotChanged);
|
2012-04-20 11:54:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Qt::WindowFlags TypeControl::type() const
|
|
|
|
{
|
|
|
|
return Qt::WindowFlags(group->checkedId());
|
|
|
|
}
|
|
|
|
|
|
|
|
void TypeControl::setType(Qt::WindowFlags s)
|
|
|
|
{
|
|
|
|
if (QAbstractButton *b = group->button(s & Qt::WindowType_Mask))
|
|
|
|
b->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TypeControl::slotChanged()
|
|
|
|
{
|
|
|
|
emit changed(type());
|
|
|
|
}
|