Remove QWorkspace.

QWorkspace had been called Q3Workspace before Qt4.0 finally released.
In a sense, it is a Qt3 support Widget. And QWorkspace has been
deprecated and replaced by QMdiArea at Qt4.3.

Change-Id: Iea1bf831c9960c23c2b21d51fdc7c13b303642ea
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Debao Zhang 2012-03-20 20:21:30 -07:00 committed by Qt by Nokia
parent f31e614245
commit 2f2b783214
36 changed files with 20 additions and 4558 deletions

View File

@ -1,48 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
//! [0]
MainWindow::MainWindow()
{
workspace = new QWorkspace;
setCentralWidget(workspace);
...
}
//! [0]

View File

@ -159,9 +159,6 @@
#ifndef QT_NO_DATETIMEEDIT
# define QT_NO_DATETIMEEDIT
#endif
#ifndef QT_NO_WORKSPACE
# define QT_NO_WORKSPACE
#endif
#ifndef QT_NO_DIAL
# define QT_NO_DIAL
#endif

View File

@ -242,9 +242,6 @@
#ifndef QT_NO_MENUBAR
# define QT_NO_MENUBAR
#endif
#ifndef QT_NO_WORKSPACE
# define QT_NO_WORKSPACE
#endif
#ifndef QT_NO_PROGRESSBAR
# define QT_NO_PROGRESSBAR
#endif

View File

@ -494,9 +494,6 @@
#ifndef QT_NO_MENUBAR
# define QT_NO_MENUBAR
#endif
#ifndef QT_NO_WORKSPACE
# define QT_NO_WORKSPACE
#endif
#ifndef QT_NO_PROGRESSBAR
# define QT_NO_PROGRESSBAR
#endif

View File

@ -282,9 +282,6 @@
#ifndef QT_NO_MENUBAR
# define QT_NO_MENUBAR
#endif
#ifndef QT_NO_WORKSPACE
# define QT_NO_WORKSPACE
#endif
#ifndef QT_NO_PROGRESSBAR
# define QT_NO_PROGRESSBAR
#endif

View File

@ -652,11 +652,6 @@
#define QT_NO_PRINTPREVIEWWIDGET
#endif
// QWorkSpace
#if !defined(QT_NO_WORKSPACE) && (defined(QT_NO_SCROLLBAR) || defined(QT_NO_MAINWINDOW) || defined(QT_NO_MENUBAR))
#define QT_NO_WORKSPACE
#endif
// QCalendarWidget
#if !defined(QT_NO_CALENDARWIDGET) && (defined(QT_NO_TABLEVIEW) || defined(QT_NO_MENU) || defined(QT_NO_TEXTDATE) || defined(QT_NO_SPINBOX) || defined(QT_NO_TOOLBUTTON))
#define QT_NO_CALENDARWIDGET

View File

@ -407,13 +407,6 @@ Requires: RUBBERBAND MAINWINDOW
Name: QDockwidget
SeeAlso: ???
Feature: WORKSPACE
Description: Supports workspace windows, e.g. used in an MDI application.
Section: Widgets
Requires: SCROLLBAR MAINWINDOW MENUBAR
Name: QWorkSpace
SeeAlso: ???
Feature: MDIAREA
Description: Provides an area in which MDI windows are displayed.
Section: Widgets

View File

@ -116,7 +116,6 @@ QStringList AccessibleFactory::keys() const
list << QLatin1String("QHeaderView");
list << QLatin1String("QTabBar");
list << QLatin1String("QToolBar");
list << QLatin1String("QWorkspaceChild");
list << QLatin1String("QSizeGrip");
list << QLatin1String("QAbstractItemView");
list << QLatin1String("QWidget");
@ -133,7 +132,6 @@ QStringList AccessibleFactory::keys() const
list << QLatin1String("QToolBox");
list << QLatin1String("QMdiArea");
list << QLatin1String("QMdiSubWindow");
list << QLatin1String("QWorkspace");
list << QLatin1String("QDialogButtonBox");
#ifndef QT_NO_DIAL
list << QLatin1String("QDial");
@ -274,8 +272,6 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec
} else if (classname == QLatin1String("QTabBar")) {
iface = new QAccessibleTabBar(widget);
#endif
} else if (classname == QLatin1String("QWorkspaceChild")) {
iface = new QAccessibleWidget(widget, QAccessible::Window);
} else if (classname == QLatin1String("QSizeGrip")) {
iface = new QAccessibleWidget(widget, QAccessible::Grip);
#ifndef QT_NO_SPLITTER
@ -305,10 +301,6 @@ QAccessibleInterface *AccessibleFactory::create(const QString &classname, QObjec
iface = new QAccessibleMdiArea(widget);
} else if (classname == QLatin1String("QMdiSubWindow")) {
iface = new QAccessibleMdiSubWindow(widget);
#endif
#ifndef QT_NO_WORKSPACE
} else if (classname == QLatin1String("QWorkspace")) {
iface = new QAccessibleWorkspace(widget);
#endif
} else if (classname == QLatin1String("QDialogButtonBox")) {
iface = new QAccessibleDialogButtonBox(widget);

View File

@ -54,7 +54,6 @@
#include <QToolBox>
#include <QMdiArea>
#include <QMdiSubWindow>
#include <QWorkspace>
#include <QDialogButtonBox>
#include <limits.h>
#include <QRubberBand>
@ -740,44 +739,6 @@ QMdiSubWindow *QAccessibleMdiSubWindow::mdiSubWindow() const
}
#endif // QT_NO_MDIAREA
// ======================= QAccessibleWorkspace ======================
#ifndef QT_NO_WORKSPACE
QAccessibleWorkspace::QAccessibleWorkspace(QWidget *widget)
: QAccessibleWidget(widget, QAccessible::LayeredPane)
{
Q_ASSERT(qobject_cast<QWorkspace *>(widget));
}
int QAccessibleWorkspace::childCount() const
{
return workspace()->windowList().count();
}
QAccessibleInterface *QAccessibleWorkspace::child(int index) const
{
QWidgetList subWindows = workspace()->windowList();
if (index < 0 || subWindows.isEmpty() || index >= subWindows.count())
return 0;
QObject *targetObject = subWindows.at(index);
return QAccessible::queryAccessibleInterface(targetObject);
}
int QAccessibleWorkspace::indexOfChild(const QAccessibleInterface *child) const
{
if (!child || !child->object() || workspace()->windowList().isEmpty())
return -1;
if (QWidget *window = qobject_cast<QWidget *>(child->object())) {
return workspace()->windowList().indexOf(window);
}
return -1;
}
QWorkspace *QAccessibleWorkspace::workspace() const
{
return static_cast<QWorkspace *>(object());
}
#endif
#ifndef QT_NO_DIALOGBUTTONBOX
// ======================= QAccessibleDialogButtonBox ======================
QAccessibleDialogButtonBox::QAccessibleDialogButtonBox(QWidget *widget)

View File

@ -56,7 +56,6 @@ class QStackedWidget;
class QToolBox;
class QMdiArea;
class QMdiSubWindow;
class QWorkspace;
class QRubberBand;
class QTextBrowser;
class QCalendarWidget;
@ -176,21 +175,6 @@ protected:
};
#endif // QT_NO_MDIAREA
#ifndef QT_NO_WORKSPACE
class QAccessibleWorkspace : public QAccessibleWidget
{
public:
explicit QAccessibleWorkspace(QWidget *widget);
int childCount() const;
QAccessibleInterface *child(int index) const;
int indexOfChild(const QAccessibleInterface *child) const;
protected:
QWorkspace *workspace() const;
};
#endif
class QAccessibleDialogButtonBox : public QAccessibleWidget
{
public:

View File

@ -26,7 +26,6 @@
"QHeaderView",
"QTabBar",
"QToolBar",
"QWorkspaceChild",
"QSizeGrip",
"QAbstractItemView",
"QWidget",
@ -39,7 +38,6 @@
"QToolBox",
"QMdiArea",
"QMdiSubWindow",
"QWorkspace",
"QDialogButtonBox",
"QDial",
"QRubberBand",

View File

@ -733,8 +733,6 @@ void WriteInitialization::acceptWidget(DomWidget *node)
m_output << m_indent << parentWidget << "->addWidget(" << varName << ");\n";
} else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QMdiArea"))) {
m_output << m_indent << parentWidget << "->addSubWindow(" << varName << ");\n";
} else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QWorkspace"))) {
m_output << m_indent << parentWidget << "->addWindow(" << varName << ");\n";
} else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QWizard"))) {
addWizardPage(varName, node, parentWidget);
} else if (m_uic->customWidgetsInfo()->extends(parentClass, QLatin1String("QToolBox"))) {

View File

@ -1015,7 +1015,6 @@ QT_CLASS_LIB(QValidator, QtWidgets, qvalidator.h)
QT_CLASS_LIB(QIntValidator, QtWidgets, qvalidator.h)
QT_CLASS_LIB(QDoubleValidator, QtWidgets, qvalidator.h)
QT_CLASS_LIB(QRegExpValidator, QtWidgets, qvalidator.h)
QT_CLASS_LIB(QWorkspace, QtWidgets, qworkspace.h)
QT_CLASS_LIB(QScriptEngineDebugger, QtScriptTools, qscriptenginedebugger.h)
QT_CLASS_LIB(QDesignerComponents, QtDesigner, qdesigner_components.h)
QT_CLASS_LIB(QExtensionFactory, QtDesigner, default_extensionfactory.h)

View File

@ -369,7 +369,7 @@ void QMessageBoxPrivate::updateSize()
label->setSizePolicy(policy);
}
QFontMetrics fm(QApplication::font("QWorkspaceTitleBar"));
QFontMetrics fm(QApplication::font("QMdiSubWindowTitleBar"));
int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit);
if (windowTitleWidth > width)
width = windowTitleWidth;

View File

@ -335,7 +335,7 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
const int verticalCenter = (btnTop + btnHeight / 2) - 1;
const QString text = wizard->window()->windowTitle();
const QFont font = QApplication::font("QWorkspaceTitleBar");
const QFont font = QApplication::font("QMdiSubWindowTitleBar");
const QFontMetrics fontMetrics(font);
const QRect brect = fontMetrics.boundingRect(text);
int textHeight = brect.height();

View File

@ -2305,7 +2305,7 @@ void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGrap
bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0);
painter->save();
painter->setFont(QApplication::font("QWorkspaceTitleBar"));
painter->setFont(QApplication::font("QMdiSubWindowTitleBar"));
style()->drawComplexControl(QStyle::CC_TitleBar, &bar, painter, widget);
painter->restore();
if (setMask)

View File

@ -325,7 +325,7 @@ void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *optio
option->state &= ~QStyle::State_Active;
option->titleBarState = Qt::WindowNoState;
}
QFont windowTitleFont = QApplication::font("QWorkspaceTitleBar");
QFont windowTitleFont = QApplication::font("QMdiSubWindowTitleBar");
QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0);
option->text = QFontMetrics(windowTitleFont).elidedText(
windowData->windowTitle, Qt::ElideRight, textRect.width());

View File

@ -339,10 +339,8 @@ void QApplicationPrivate::initializeWidgetFontHash()
fontHash->insert(QByteArrayLiteral("QTitleBar"), *font);
if (const QFont *font = theme->font(QPlatformTheme::StatusBarFont))
fontHash->insert(QByteArrayLiteral("QStatusBar"), *font);
if (const QFont *font = theme->font(QPlatformTheme::MdiSubWindowTitleFont)) {
fontHash->insert(QByteArrayLiteral("QWorkspaceTitleBar"), *font);
if (const QFont *font = theme->font(QPlatformTheme::MdiSubWindowTitleFont))
fontHash->insert(QByteArrayLiteral("QMdiSubWindowTitleBar"), *font);
}
if (const QFont *font = theme->font(QPlatformTheme::DockWidgetTitleFont))
fontHash->insert(QByteArrayLiteral("QDockWidgetTitle"), *font);
if (const QFont *font = theme->font(QPlatformTheme::PushButtonFont))

View File

@ -3906,7 +3906,6 @@ void QCleanlooksStyle::polish(QWidget *widget)
#ifndef QT_NO_SPINBOX
|| qobject_cast<QAbstractSpinBox *>(widget)
#endif
|| (widget->inherits("QWorkspaceChild"))
|| (widget->inherits("QDockSeparator"))
|| (widget->inherits("QDockWidgetSeparator"))
) {
@ -3953,7 +3952,6 @@ void QCleanlooksStyle::unpolish(QWidget *widget)
#ifndef QT_NO_SPINBOX
|| qobject_cast<QAbstractSpinBox *>(widget)
#endif
|| (widget->inherits("QWorkspaceChild"))
|| (widget->inherits("QDockSeparator"))
|| (widget->inherits("QDockWidgetSeparator"))
) {

View File

@ -3568,69 +3568,6 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
}
break;
#endif // QT_NO_GROUPBOX
#ifndef QT_NO_WORKSPACE
case CC_MdiControls:
{
QStyleOptionButton btnOpt;
btnOpt.QStyleOption::operator=(*opt);
btnOpt.state &= ~State_MouseOver;
int bsx = 0;
int bsy = 0;
if (opt->subControls & QStyle::SC_MdiCloseButton) {
if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) {
btnOpt.state |= State_Sunken;
btnOpt.state &= ~State_Raised;
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
} else {
btnOpt.state |= State_Raised;
btnOpt.state &= ~State_Sunken;
bsx = 0;
bsy = 0;
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
QPixmap pm = standardIcon(SP_TitleBarCloseButton).pixmap(16, 16);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiNormalButton) {
if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) {
btnOpt.state |= State_Sunken;
btnOpt.state &= ~State_Raised;
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
} else {
btnOpt.state |= State_Raised;
btnOpt.state &= ~State_Sunken;
bsx = 0;
bsy = 0;
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
QPixmap pm = standardIcon(SP_TitleBarNormalButton).pixmap(16, 16);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
if (opt->subControls & QStyle::SC_MdiMinButton) {
if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) {
btnOpt.state |= State_Sunken;
btnOpt.state &= ~State_Raised;
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
} else {
btnOpt.state |= State_Raised;
btnOpt.state &= ~State_Sunken;
bsx = 0;
bsy = 0;
}
btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget);
proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);
QPixmap pm = standardIcon(SP_TitleBarMinButton).pixmap(16, 16);
proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);
}
}
break;
#endif // QT_NO_WORKSPACE
default:
qWarning("QCommonStyle::drawComplexControl: Control %d not handled", cc);
}
@ -4155,50 +4092,6 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
break;
}
#endif // QT_NO_GROUPBOX
#ifndef QT_NO_WORKSPACE
case CC_MdiControls:
{
int numSubControls = 0;
if (opt->subControls & SC_MdiCloseButton)
++numSubControls;
if (opt->subControls & SC_MdiMinButton)
++numSubControls;
if (opt->subControls & SC_MdiNormalButton)
++numSubControls;
if (numSubControls == 0)
break;
int buttonWidth = opt->rect.width()/ numSubControls - 1;
int offset = 0;
switch (sc) {
case SC_MdiCloseButton:
// Only one sub control, no offset needed.
if (numSubControls == 1)
break;
offset += buttonWidth + 2;
//FALL THROUGH
case SC_MdiNormalButton:
// No offset needed if
// 1) There's only one sub control
// 2) We have a close button and a normal button (offset already added in SC_MdiClose)
if (numSubControls == 1 || (numSubControls == 2 && !(opt->subControls & SC_MdiMinButton)))
break;
if (opt->subControls & SC_MdiNormalButton)
offset += buttonWidth;
break;
default:
break;
}
// Subtract one pixel if we only have one sub control. At this point
// buttonWidth is the actual width + 1 pixel margin, but we don't want the
// margin when there are no other controllers.
if (numSubControls == 1)
--buttonWidth;
ret = QRect(offset, 0, buttonWidth, opt->rect.height());
break;
}
#endif // QT_NO_WORKSPACE
default:
qWarning("QCommonStyle::subControlRect: Case %d not handled", cc);
}

View File

@ -2184,8 +2184,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
if (widget && (widget->isWindow() || !widget->parentWidget()
|| (qobject_cast<const QMainWindow*>(widget->parentWidget())
&& static_cast<QMainWindow *>(widget->parentWidget())->centralWidget() == widget))
&& (qobject_cast<const QAbstractScrollArea *>(widget)
|| widget->inherits("QWorkspaceChild")))
&& qobject_cast<const QAbstractScrollArea *>(widget))
ret = 0;
else
#endif
@ -2547,12 +2546,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
ret = Qt::AlignTop;
break;
case SH_ScrollView_FrameOnlyAroundContents:
if (w && (w->isWindow() || !w->parentWidget() || w->parentWidget()->isWindow())
&& (w->inherits("QWorkspaceChild")
))
ret = true;
else
ret = QWindowsStyle::styleHint(sh, opt, w, hret);
ret = QWindowsStyle::styleHint(sh, opt, w, hret);
break;
case SH_Menu_FillScreenWithScroll:
ret = false;

View File

@ -83,7 +83,6 @@ static const int blueFrameWidth = 2; // with of line edit focus frame
#include <qtoolbar.h>
#include <qtoolbox.h>
#include <qtoolbutton.h>
#include <qworkspace.h>
#include <qprocess.h>
#include <qvarlengtharray.h>
#include <limits.h>
@ -5629,8 +5628,7 @@ void QPlastiqueStyle::polish(QWidget *widget)
widget->setAttribute(Qt::WA_Hover);
}
if (widget->inherits("QWorkspaceTitleBar")
|| widget->inherits("QDockSeparator")
if (widget->inherits("QDockSeparator")
|| widget->inherits("QDockWidgetSeparator")) {
widget->setAttribute(Qt::WA_Hover);
}
@ -5684,8 +5682,7 @@ void QPlastiqueStyle::unpolish(QWidget *widget)
widget->setAttribute(Qt::WA_Hover, false);
}
if (widget->inherits("QWorkspaceTitleBar")
|| widget->inherits("QDockSeparator")
if (widget->inherits("QDockSeparator")
|| widget->inherits("QDockWidgetSeparator")) {
widget->setAttribute(Qt::WA_Hover, false);
}

View File

@ -1178,8 +1178,9 @@ void QWindowsXPStyle::polish(QWidget *widget)
|| qobject_cast<QAbstractSpinBox*>(widget)
|| qobject_cast<QSpinBox*>(widget)
#endif // QT_NO_SPINBOX
|| widget->inherits("QWorkspaceChild"))
) {
widget->setAttribute(Qt::WA_Hover);
}
#ifndef QT_NO_RUBBERBAND
if (qobject_cast<QRubberBand*>(widget)) {
@ -1249,8 +1250,9 @@ void QWindowsXPStyle::unpolish(QWidget *widget)
|| qobject_cast<QAbstractSpinBox*>(widget)
|| qobject_cast<QSpinBox*>(widget)
#endif // QT_NO_SPINBOX
|| widget->inherits("QWorkspaceChild"))
) {
widget->setAttribute(Qt::WA_Hover, false);
}
QWindowsStyle::unpolish(widget);
}
@ -3225,63 +3227,6 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo
}
break;
#ifndef QT_NO_WORKSPACE
case CC_MdiControls:
{
QRect buttonRect;
XPThemeData theme(widget, p, QLatin1String("WINDOW"), WP_MDICLOSEBUTTON, CBS_NORMAL);
if (option->subControls & SC_MdiCloseButton) {
buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiCloseButton, widget);
if (theme.isValid()) {
theme.partId = WP_MDICLOSEBUTTON;
theme.rect = buttonRect;
if (!(flags & State_Enabled))
theme.stateId = CBS_INACTIVE;
else if (flags & State_Sunken && (option->activeSubControls & SC_MdiCloseButton))
theme.stateId = CBS_PUSHED;
else if (flags & State_MouseOver && (option->activeSubControls & SC_MdiCloseButton))
theme.stateId = CBS_HOT;
else
theme.stateId = CBS_NORMAL;
d->drawBackground(theme);
}
}
if (option->subControls & SC_MdiNormalButton) {
buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiNormalButton, widget);
if (theme.isValid()) {
theme.partId = WP_MDIRESTOREBUTTON;
theme.rect = buttonRect;
if (!(flags & State_Enabled))
theme.stateId = CBS_INACTIVE;
else if (flags & State_Sunken && (option->activeSubControls & SC_MdiNormalButton))
theme.stateId = CBS_PUSHED;
else if (flags & State_MouseOver && (option->activeSubControls & SC_MdiNormalButton))
theme.stateId = CBS_HOT;
else
theme.stateId = CBS_NORMAL;
d->drawBackground(theme);
}
}
if (option->subControls & QStyle::SC_MdiMinButton) {
buttonRect = proxy()->subControlRect(CC_MdiControls, option, SC_MdiMinButton, widget);
if (theme.isValid()) {
theme.partId = WP_MDIMINBUTTON;
theme.rect = buttonRect;
if (!(flags & State_Enabled))
theme.stateId = CBS_INACTIVE;
else if (flags & State_Sunken && (option->activeSubControls & SC_MdiMinButton))
theme.stateId = CBS_PUSHED;
else if (flags & State_MouseOver && (option->activeSubControls & SC_MdiMinButton))
theme.stateId = CBS_HOT;
else
theme.stateId = CBS_NORMAL;
d->drawBackground(theme);
}
}
}
break;
#endif //QT_NO_WORKSPACE
#ifndef QT_NO_DIAL
case CC_Dial:
if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option))
@ -3667,44 +3612,6 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl
}
}
break;
#ifndef QT_NO_WORKSPACE
case CC_MdiControls:
{
int numSubControls = 0;
if (option->subControls & SC_MdiCloseButton)
++numSubControls;
if (option->subControls & SC_MdiMinButton)
++numSubControls;
if (option->subControls & SC_MdiNormalButton)
++numSubControls;
if (numSubControls == 0)
break;
int buttonWidth = option->rect.width()/ numSubControls;
int offset = 0;
switch (subControl) {
case SC_MdiCloseButton:
// Only one sub control, no offset needed.
if (numSubControls == 1)
break;
offset += buttonWidth;
//FALL THROUGH
case SC_MdiNormalButton:
// No offset needed if
// 1) There's only one sub control
// 2) We have a close button and a normal button (offset already added in SC_MdiClose)
if (numSubControls == 1 || (numSubControls == 2 && !(option->subControls & SC_MdiMinButton)))
break;
if (option->subControls & SC_MdiNormalButton)
offset += buttonWidth;
break;
default:
break;
}
rect = QRect(offset, 0, buttonWidth, option->rect.height());
break;
}
#endif // QT_NO_WORKSPACE
default:
rect = visualRect(option->direction, option->rect,

View File

@ -357,7 +357,7 @@ void SimpleCascader::rearrange(QList<QWidget *> &widgets, const QRect &domain) c
if (qobject_cast<QMacStyle *>(widgets.at(0)->style()))
titleBarHeight -= 4;
#endif
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QWorkspaceTitleBar"));
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar"));
const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
const int n = widgets.size();

View File

@ -336,7 +336,7 @@ void QWidgetResizeHandler::setMouseCursor(MousePosition m)
QObjectList children = widget->children();
for (int i = 0; i < children.size(); ++i) {
if (QWidget *w = qobject_cast<QWidget*>(children.at(i))) {
if (!w->testAttribute(Qt::WA_SetCursor) && !w->inherits("QWorkspaceTitleBar")) {
if (!w->testAttribute(Qt::WA_SetCursor)) {
w->setCursor(Qt::ArrowCursor);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,131 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QWORKSPACE_H
#define QWORKSPACE_H
#include <QtWidgets/qwidget.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
#ifndef QT_NO_WORKSPACE
class QAction;
class QWorkspaceChild;
class QShowEvent;
class QWorkspacePrivate;
class Q_WIDGETS_EXPORT QWorkspace : public QWidget
{
Q_OBJECT
Q_PROPERTY(bool scrollBarsEnabled READ scrollBarsEnabled WRITE setScrollBarsEnabled)
Q_PROPERTY(QBrush background READ background WRITE setBackground)
public:
explicit QWorkspace(QWidget* parent=0);
~QWorkspace();
enum WindowOrder { CreationOrder, StackingOrder };
QWidget* activeWindow() const;
QWidgetList windowList(WindowOrder order = CreationOrder) const;
QWidget * addWindow(QWidget *w, Qt::WindowFlags flags = 0);
QSize sizeHint() const;
bool scrollBarsEnabled() const;
void setScrollBarsEnabled(bool enable);
void setBackground(const QBrush &background);
QBrush background() const;
Q_SIGNALS:
void windowActivated(QWidget* w);
public Q_SLOTS:
void setActiveWindow(QWidget *w);
void cascade();
void tile();
void arrangeIcons();
void closeActiveWindow();
void closeAllWindows();
void activateNextWindow();
void activatePreviousWindow();
protected:
bool event(QEvent *e);
void paintEvent(QPaintEvent *e);
void changeEvent(QEvent *);
void childEvent(QChildEvent *);
void resizeEvent(QResizeEvent *);
bool eventFilter(QObject *, QEvent *);
void showEvent(QShowEvent *e);
void hideEvent(QHideEvent *e);
#ifndef QT_NO_WHEELEVENT
void wheelEvent(QWheelEvent *e);
#endif
private:
Q_DECLARE_PRIVATE(QWorkspace)
Q_DISABLE_COPY(QWorkspace)
Q_PRIVATE_SLOT(d_func(), void _q_normalizeActiveWindow())
Q_PRIVATE_SLOT(d_func(), void _q_minimizeActiveWindow())
Q_PRIVATE_SLOT(d_func(), void _q_showOperationMenu())
Q_PRIVATE_SLOT(d_func(), void _q_popupOperationMenu(const QPoint&))
Q_PRIVATE_SLOT(d_func(), void _q_operationMenuActivated(QAction *))
Q_PRIVATE_SLOT(d_func(), void _q_updateActions())
Q_PRIVATE_SLOT(d_func(), void _q_scrollBarChanged())
friend class QWorkspaceChild;
};
#endif // QT_NO_WORKSPACE
QT_END_NAMESPACE
QT_END_HEADER
#endif // QWORKSPACE_H

View File

@ -73,7 +73,6 @@ HEADERS += \
widgets/qwidgetresizehandler_p.h \
widgets/qfocusframe.h \
widgets/qscrollarea.h \
widgets/qworkspace.h \
widgets/qwidgetanimator_p.h \
widgets/qwidgettextcontrol_p.h \
widgets/qwidgettextcontrol_p_p.h \
@ -135,7 +134,6 @@ SOURCES += \
widgets/qwidgetresizehandler.cpp \
widgets/qfocusframe.cpp \
widgets/qscrollarea.cpp \
widgets/qworkspace.cpp \
widgets/qwidgetanimator.cpp \
widgets/qwidgettextcontrol.cpp \
widgets/qwidgetlinecontrol.cpp \

View File

@ -449,7 +449,6 @@ void tst_ExceptionSafety_Objects::widgets_data()
NEWROW(QToolButton);
NEWROW(QTreeView);
NEWROW(QTreeWidget);
NEWROW(QWorkspace);
}
void tst_ExceptionSafety_Objects::widgets()
@ -486,8 +485,7 @@ void tst_ExceptionSafety_Objects::widgets()
|| tag == QLatin1String("QToolBar")
|| tag == QLatin1String("QToolBox")
|| tag == QLatin1String("QTreeView")
|| tag == QLatin1String("QTreeWidget")
|| tag == QLatin1String("QWorkspace"))
|| tag == QLatin1String("QTreeWidget"))
QSKIP("This type of widget is not currently strongly exception safe");
if (tag == QLatin1String("QWidget"))

View File

@ -252,7 +252,6 @@ private slots:
void mdiAreaTest();
void mdiSubWindowTest();
void lineEditTest();
void workspaceTest();
void dialogButtonBoxTest();
void dialTest();
void rubberBandTest();
@ -587,7 +586,7 @@ static QWidget *createWidgets()
/* Not in the list
* QAbstractItemView, QGraphicsView, QScrollArea,
* QToolButton, QDockWidget, QFocusFrame, QMainWindow, QMenu, QMenuBar, QSizeGrip, QSplashScreen, QSplitterHandle,
* QStatusBar, QSvgWidget, QTabBar, QToolBar, QWorkspace, QSplitter
* QStatusBar, QSvgWidget, QTabBar, QToolBar, QSplitter
*/
return w;
}
@ -1818,32 +1817,6 @@ void tst_QAccessibility::lineEditTest()
QTestAccessibility::clearEvents();
}
void tst_QAccessibility::workspaceTest()
{
{
QWorkspace workspace;
workspace.resize(400,300);
workspace.show();
const int subWindowCount = 3;
for (int i = 0; i < subWindowCount; ++i) {
QWidget *window = workspace.addWindow(new QWidget);
if (i > 0)
window->move(window->x() + 1, window->y());
window->show();
window->resize(70, window->height());
}
QWidgetList subWindows = workspace.windowList();
QCOMPARE(subWindows.count(), subWindowCount);
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&workspace);
QVERIFY(interface);
QCOMPARE(interface->childCount(), subWindowCount);
}
QTestAccessibility::clearEvents();
}
bool accessibleInterfaceLeftOf(const QAccessibleInterface *a1, const QAccessibleInterface *a2)
{
return a1->rect().x() < a2->rect().x();

View File

@ -199,7 +199,7 @@ static bool verifyArrangement(QMdiArea *mdiArea, Arrangement arrangement, const
if (qobject_cast<QMacStyle *>(firstSubWindow->style()))
titleBarHeight -= 4;
#endif
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QWorkspaceTitleBar"));
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar"));
const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
const int dx = 10;
@ -1823,7 +1823,7 @@ void tst_QMdiArea::cascadeAndTileSubWindows()
// ### Remove this after the mac style has been fixed
if (windows.at(1)->style()->inherits("QMacStyle"))
titleBarHeight -= 4;
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QWorkspaceTitleBar"));
const QFontMetrics fontMetrics = QFontMetrics(QApplication::font("QMdiSubWindowTitleBar"));
const int dy = qMax(titleBarHeight - (titleBarHeight - fontMetrics.height()) / 2, 1);
QCOMPARE(windows.at(2)->geometry().top() - windows.at(1)->geometry().top(), dy);

View File

@ -1824,7 +1824,7 @@ void tst_QMdiSubWindow::setFont()
qt_x11_wait_for_window_manager(&mdiArea);
#endif
const QFont originalFont = QApplication::font("QWorkspaceTitleBar");
const QFont originalFont = QApplication::font("QMdiSubWindowTitleBar");
QStyleOptionTitleBar opt;
opt.initFrom(subWindow);
const int titleBarHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &opt);

View File

@ -1 +0,0 @@
tst_qworkspace

View File

@ -1,4 +0,0 @@
CONFIG += testcase
TARGET = tst_qworkspace
QT += widgets testlib
SOURCES += tst_qworkspace.cpp

View File

@ -1,676 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtTest/QtTest>
#include <qapplication.h>
#include <qmainwindow.h>
#include <qmenubar.h>
#include <qworkspace.h>
class tst_QWorkspace : public QObject
{
Q_OBJECT
public:
tst_QWorkspace();
virtual ~tst_QWorkspace();
protected slots:
void activeChanged( QWidget *w );
void accelActivated();
public slots:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
private slots:
void getSetCheck();
void windowActivated_data();
void windowActivated();
void windowActivatedWithMinimize();
void showWindows();
void changeWindowTitle();
void changeModified();
void childSize();
void fixedSize();
#if defined(Q_WS_WIN) || defined(Q_WS_X11)
void nativeSubWindows();
#endif
void task206368();
private:
QWidget *activeWidget;
bool accelPressed;
};
// Testing get/set functions
void tst_QWorkspace::getSetCheck()
{
QWorkspace obj1;
// bool QWorkspace::scrollBarsEnabled()
// void QWorkspace::setScrollBarsEnabled(bool)
obj1.setScrollBarsEnabled(false);
QCOMPARE(false, obj1.scrollBarsEnabled());
obj1.setScrollBarsEnabled(true);
QCOMPARE(true, obj1.scrollBarsEnabled());
}
tst_QWorkspace::tst_QWorkspace()
: activeWidget( 0 )
{
}
tst_QWorkspace::~tst_QWorkspace()
{
}
// initTestCase will be executed once before the first testfunction is executed.
void tst_QWorkspace::initTestCase()
{
}
// cleanupTestCase will be executed once after the last testfunction is executed.
void tst_QWorkspace::cleanupTestCase()
{
}
// init() will be executed immediately before each testfunction is run.
void tst_QWorkspace::init()
{
// TODO: Add testfunction specific initialization code here.
}
// cleanup() will be executed immediately after each testfunction is run.
void tst_QWorkspace::cleanup()
{
// TODO: Add testfunction specific cleanup code here.
}
void tst_QWorkspace::activeChanged( QWidget *w )
{
activeWidget = w;
}
void tst_QWorkspace::windowActivated_data()
{
// define the test elements we're going to use
QTest::addColumn<int>("count");
// create a first testdata instance and fill it with data
QTest::newRow( "data0" ) << 0;
QTest::newRow( "data1" ) << 1;
QTest::newRow( "data2" ) << 2;
}
void tst_QWorkspace::windowActivated()
{
QMainWindow mw(0, Qt::X11BypassWindowManagerHint);
mw.menuBar();
QWorkspace *workspace = new QWorkspace(&mw);
workspace->setObjectName("testWidget");
mw.setCentralWidget(workspace);
QSignalSpy spy(workspace, SIGNAL(windowActivated(QWidget*)));
connect( workspace, SIGNAL(windowActivated(QWidget*)), this, SLOT(activeChanged(QWidget*)) );
mw.show();
qApp->setActiveWindow(&mw);
QFETCH( int, count );
int i;
for ( i = 0; i < count; ++i ) {
QWidget *widget = new QWidget(workspace, 0);
widget->setAttribute(Qt::WA_DeleteOnClose);
workspace->addWindow(widget);
widget->show();
qApp->processEvents();
QVERIFY( activeWidget == workspace->activeWindow() );
QCOMPARE(spy.count(), 1);
spy.clear();
}
QWidgetList windows = workspace->windowList();
QCOMPARE( (int)windows.count(), count );
for ( i = 0; i < count; ++i ) {
QWidget *window = windows.at(i);
window->showMinimized();
qApp->processEvents();
QVERIFY( activeWidget == workspace->activeWindow() );
if ( i == 1 )
QVERIFY( activeWidget == window );
}
for ( i = 0; i < count; ++i ) {
QWidget *window = windows.at(i);
window->showNormal();
qApp->processEvents();
QVERIFY( window == activeWidget );
QVERIFY( activeWidget == workspace->activeWindow() );
}
spy.clear();
while ( workspace->activeWindow() ) {
workspace->activeWindow()->close();
qApp->processEvents();
QVERIFY( activeWidget == workspace->activeWindow() );
QCOMPARE(spy.count(), 1);
spy.clear();
}
QVERIFY(activeWidget == 0);
QVERIFY(workspace->activeWindow() == 0);
QVERIFY(workspace->windowList().count() == 0);
{
workspace->hide();
QWidget *widget = new QWidget(workspace);
widget->setObjectName("normal");
widget->setAttribute(Qt::WA_DeleteOnClose);
workspace->addWindow(widget);
widget->show();
QCOMPARE(spy.count(), 0);
workspace->show();
QCOMPARE(spy.count(), 1);
spy.clear();
QVERIFY( activeWidget == widget );
widget->close();
qApp->processEvents();
QCOMPARE(spy.count(), 1);
spy.clear();
QVERIFY( activeWidget == 0 );
}
{
workspace->hide();
QWidget *widget = new QWidget(workspace);
widget->setObjectName("maximized");
widget->setAttribute(Qt::WA_DeleteOnClose);
workspace->addWindow(widget);
widget->showMaximized();
qApp->sendPostedEvents();
#ifdef Q_OS_MAC
QEXPECT_FAIL("", "This test has never passed on Mac. QWorkspace is obsoleted -> won't fix", Abort);
#endif
QCOMPARE(spy.count(), 0);
spy.clear();
workspace->show();
QCOMPARE(spy.count(), 1);
spy.clear();
QVERIFY( activeWidget == widget );
widget->close();
qApp->processEvents();
QCOMPARE(spy.count(), 1);
spy.clear();
QVERIFY( activeWidget == 0 );
}
{
QWidget *widget = new QWidget(workspace);
widget->setObjectName("minimized");
widget->setAttribute(Qt::WA_DeleteOnClose);
workspace->addWindow(widget);
widget->showMinimized();
QCOMPARE(spy.count(), 1);
spy.clear();
QVERIFY( activeWidget == widget );
QVERIFY(workspace->activeWindow() == widget);
widget->close();
qApp->processEvents();
QCOMPARE(spy.count(), 1);
spy.clear();
QVERIFY(workspace->activeWindow() == 0);
QVERIFY( activeWidget == 0 );
}
}
void tst_QWorkspace::windowActivatedWithMinimize()
{
QMainWindow mw(0, Qt::X11BypassWindowManagerHint) ;
mw.menuBar();
QWorkspace *workspace = new QWorkspace(&mw);
workspace->setObjectName("testWidget");
mw.setCentralWidget(workspace);
QSignalSpy spy(workspace, SIGNAL(windowActivated(QWidget*)));
connect( workspace, SIGNAL(windowActivated(QWidget*)), this, SLOT(activeChanged(QWidget*)) );
mw.show();
qApp->setActiveWindow(&mw);
QWidget *widget = new QWidget(workspace);
widget->setObjectName("minimized1");
widget->setAttribute(Qt::WA_DeleteOnClose);
workspace->addWindow(widget);
QWidget *widget2 = new QWidget(workspace);
widget2->setObjectName("minimized2");
widget2->setAttribute(Qt::WA_DeleteOnClose);
workspace->addWindow(widget2);
widget->showMinimized();
QVERIFY( activeWidget == widget );
widget2->showMinimized();
QVERIFY( activeWidget == widget2 );
widget2->close();
qApp->processEvents();
QVERIFY( activeWidget == widget );
widget->close();
qApp->processEvents();
QVERIFY(workspace->activeWindow() == 0);
QVERIFY( activeWidget == 0 );
QVERIFY( workspace->windowList().count() == 0 );
}
void tst_QWorkspace::accelActivated()
{
accelPressed = true;
}
void tst_QWorkspace::showWindows()
{
QWorkspace *ws = new QWorkspace( 0 );
QWidget *widget = 0;
ws->show();
widget = new QWidget(ws);
widget->setObjectName("plain1");
widget->show();
QVERIFY( widget->isVisible() );
widget = new QWidget(ws);
widget->setObjectName("maximized1");
widget->showMaximized();
QVERIFY( widget->isMaximized() );
widget->showNormal();
QVERIFY( !widget->isMaximized() );
widget = new QWidget(ws);
widget->setObjectName("minimized1");
widget->showMinimized();
QVERIFY( widget->isMinimized() );
widget->showNormal();
QVERIFY( !widget->isMinimized() );
ws->hide();
widget = new QWidget(ws);
widget->setObjectName("plain2");
ws->show();
QVERIFY( widget->isVisible() );
ws->hide();
widget = new QWidget(ws);
widget->setObjectName("maximized2");
widget->showMaximized();
QVERIFY( widget->isMaximized() );
ws->show();
QVERIFY( widget->isVisible() );
QVERIFY( widget->isMaximized() );
ws->hide();
widget = new QWidget(ws);
widget->setObjectName("minimized2");
widget->showMinimized();
ws->show();
QVERIFY( widget->isMinimized() );
ws->hide();
delete ws;
}
//#define USE_SHOW
void tst_QWorkspace::changeWindowTitle()
{
#ifdef Q_OS_WINCE
QSKIP( "Test fails on Windows CE due to QWorkspace state handling");
#endif
const QString mwc( "MainWindow's Caption" );
const QString mwc2( "MainWindow's New Caption" );
const QString wc( "Widget's Caption" );
const QString wc2( "Widget's New Caption" );
QMainWindow *mw = new QMainWindow(0, Qt::X11BypassWindowManagerHint);
mw->setWindowTitle( mwc );
QWorkspace *ws = new QWorkspace( mw );
mw->setCentralWidget( ws );
QWidget *widget = new QWidget( ws );
widget->setWindowTitle( wc );
ws->addWindow(widget);
QCOMPARE( mw->windowTitle(), mwc );
#ifdef USE_SHOW
widget->showMaximized();
#else
widget->setWindowState(Qt::WindowMaximized);
#endif
QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc).arg(wc) );
#ifdef USE_SHOW
widget->showNormal();
#else
widget->setWindowState(Qt::WindowNoState);
#endif
qApp->processEvents();
QCOMPARE( mw->windowTitle(), mwc );
#ifdef USE_SHOW
widget->showMaximized();
#else
widget->setWindowState(Qt::WindowMaximized);
#endif
qApp->processEvents();
QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc).arg(wc) );
widget->setWindowTitle( wc2 );
QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc).arg(wc2) );
mw->setWindowTitle( mwc2 );
QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc2).arg(wc2) );
mw->show();
qApp->setActiveWindow(mw);
#ifdef USE_SHOW
mw->showFullScreen();
#else
mw->setWindowState(Qt::WindowFullScreen);
#endif
qApp->processEvents();
QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc2).arg(wc2) );
#ifdef USE_SHOW
widget->showNormal();
#else
widget->setWindowState(Qt::WindowNoState);
#endif
qApp->processEvents();
QCOMPARE( mw->windowTitle(), mwc2 );
#ifdef USE_SHOW
widget->showMaximized();
#else
widget->setWindowState(Qt::WindowMaximized);
#endif
qApp->processEvents();
QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc2).arg(wc2) );
#ifdef USE_SHOW
mw->showNormal();
#else
mw->setWindowState(Qt::WindowNoState);
#endif
qApp->processEvents();
QCOMPARE( mw->windowTitle(), QString("%1 - [%2]").arg(mwc2).arg(wc2) );
#ifdef USE_SHOW
widget->showNormal();
#else
widget->setWindowState(Qt::WindowNoState);
#endif
QCOMPARE( mw->windowTitle(), mwc2 );
delete mw;
}
void tst_QWorkspace::changeModified()
{
const QString mwc( "MainWindow's Caption" );
const QString wc( "Widget's Caption[*]" );
QMainWindow *mw = new QMainWindow(0, Qt::X11BypassWindowManagerHint);
mw->setWindowTitle( mwc );
QWorkspace *ws = new QWorkspace( mw );
mw->setCentralWidget( ws );
QWidget *widget = new QWidget( ws );
widget->setWindowTitle( wc );
ws->addWindow(widget);
QCOMPARE( mw->isWindowModified(), false);
QCOMPARE( widget->isWindowModified(), false);
widget->setWindowState(Qt::WindowMaximized);
QCOMPARE( mw->isWindowModified(), false);
QCOMPARE( widget->isWindowModified(), false);
widget->setWindowState(Qt::WindowNoState);
QCOMPARE( mw->isWindowModified(), false);
QCOMPARE( widget->isWindowModified(), false);
widget->setWindowModified(true);
QCOMPARE( mw->isWindowModified(), false);
QCOMPARE( widget->isWindowModified(), true);
widget->setWindowState(Qt::WindowMaximized);
QCOMPARE( mw->isWindowModified(), true);
QCOMPARE( widget->isWindowModified(), true);
widget->setWindowState(Qt::WindowNoState);
QCOMPARE( mw->isWindowModified(), false);
QCOMPARE( widget->isWindowModified(), true);
widget->setWindowState(Qt::WindowMaximized);
QCOMPARE( mw->isWindowModified(), true);
QCOMPARE( widget->isWindowModified(), true);
widget->setWindowModified(false);
QCOMPARE( mw->isWindowModified(), false);
QCOMPARE( widget->isWindowModified(), false);
widget->setWindowModified(true);
QCOMPARE( mw->isWindowModified(), true);
QCOMPARE( widget->isWindowModified(), true);
widget->setWindowState(Qt::WindowNoState);
QCOMPARE( mw->isWindowModified(), false);
QCOMPARE( widget->isWindowModified(), true);
delete mw;
}
class MyChild : public QWidget
{
public:
MyChild(QWidget *parent = 0, Qt::WFlags f = 0)
: QWidget(parent, f)
{
}
QSize sizeHint() const
{
return QSize(234, 123);
}
};
void tst_QWorkspace::childSize()
{
QWorkspace ws;
MyChild *child = new MyChild(&ws);
child->show();
QCOMPARE(child->size(), child->sizeHint());
delete child;
child = new MyChild(&ws);
child->setFixedSize(200, 200);
child->show();
QCOMPARE(child->size(), child->minimumSize());
delete child;
child = new MyChild(&ws);
child->resize(150, 150);
child->show();
QCOMPARE(child->size(), QSize(150,150));
delete child;
}
void tst_QWorkspace::fixedSize()
{
QWorkspace *ws = new QWorkspace;
int i;
ws->resize(500, 500);
// ws->show();
QSize fixed(300, 300);
for (i = 0; i < 4; ++i) {
QWidget *child = new QWidget(ws);
child->setFixedSize(fixed);
child->show();
}
QWidgetList windows = ws->windowList();
for (i = 0; i < (int)windows.count(); ++i) {
QWidget *child = windows.at(i);
QCOMPARE(child->size(), fixed);
QCOMPARE(child->visibleRegion().boundingRect().size(), fixed);
}
ws->cascade();
ws->resize(800, 800);
for (i = 0; i < (int)windows.count(); ++i) {
QWidget *child = windows.at(i);
QCOMPARE(child->size(), fixed);
QCOMPARE(child->visibleRegion().boundingRect().size(), fixed);
}
ws->resize(500, 500);
ws->tile();
ws->resize(800, 800);
for (i = 0; i < (int)windows.count(); ++i) {
QWidget *child = windows.at(i);
QCOMPARE(child->size(), fixed);
QCOMPARE(child->visibleRegion().boundingRect().size(), fixed);
}
ws->resize(500, 500);
for (i = 0; i < (int)windows.count(); ++i) {
QWidget *child = windows.at(i);
delete child;
}
delete ws;
}
#if defined(Q_WS_WIN) || defined(Q_WS_X11)
void tst_QWorkspace::nativeSubWindows()
{
{ // Add native widgets after show.
QWorkspace workspace;
workspace.addWindow(new QWidget);
workspace.addWindow(new QWidget);
workspace.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&workspace);
#endif
// No native widgets.
foreach (QWidget *subWindow, workspace.windowList())
QVERIFY(!subWindow->parentWidget()->internalWinId());
QWidget *nativeWidget = new QWidget;
QVERIFY(nativeWidget->winId()); // enforce native window.
workspace.addWindow(nativeWidget);
// All the sub-windows must be native.
foreach (QWidget *subWindow, workspace.windowList())
QVERIFY(subWindow->parentWidget()->internalWinId());
// Add a non-native widget. This should become native.
QWidget *subWindow = workspace.addWindow(new QWidget);
QVERIFY(subWindow->parentWidget()->internalWinId());
}
{ // Add native widgets before show.
QWorkspace workspace;
workspace.addWindow(new QWidget);
QWidget *nativeWidget = new QWidget;
(void)nativeWidget->winId();
workspace.addWindow(nativeWidget);
workspace.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&workspace);
#endif
// All the sub-windows must be native.
foreach (QWidget *subWindow, workspace.windowList())
QVERIFY(subWindow->parentWidget()->internalWinId());
}
{ // Make a sub-window native *after* it's added to the area.
QWorkspace workspace;
workspace.addWindow(new QWidget);
workspace.addWindow(new QWidget);
workspace.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&workspace);
#endif
QWidget *nativeSubWindow = workspace.windowList().last()->parentWidget();
QVERIFY(!nativeSubWindow->internalWinId());
(void)nativeSubWindow->winId();
// All the sub-windows should be native at this point.
foreach (QWidget *subWindow, workspace.windowList())
QVERIFY(subWindow->parentWidget()->internalWinId());
}
}
#endif
void tst_QWorkspace::task206368()
{
// Make sure the internal list of iconified windows doesn't contain dangling pointers.
QWorkspace workspace;
QWidget *child = new QWidget;
QWidget *window = workspace.addWindow(child);
workspace.show();
child->showMinimized();
delete window;
// This shouldn't crash.
workspace.arrangeIcons();
}
QTEST_MAIN(tst_QWorkspace)
#include "tst_qworkspace.moc"

View File

@ -47,7 +47,6 @@ SUBDIRS=\
qtoolbar \
qtoolbox \
qtoolbutton \
qworkspace \
# The following tests depend on private API:
!contains(QT_CONFIG, private_tests): SUBDIRS -= \