/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the examples 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$
**
****************************************************************************/#include <QtGui>#include "controllerwindow.h"
ControllerWindow::ControllerWindow()
{
previewWindow =new PreviewWindow(this);
createTypeGroupBox();
createHintsGroupBox();
quitButton =newQPushButton(tr("&Quit"));
connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
QHBoxLayout*bottomLayout =newQHBoxLayout;
bottomLayout->addStretch();
bottomLayout->addWidget(quitButton);
QHBoxLayout*mainLayout =newQHBoxLayout;
mainLayout->addWidget(typeGroupBox);
mainLayout->addWidget(hintsGroupBox);
mainLayout->addLayout(bottomLayout);
setLayout(mainLayout);
setWindowTitle(tr("Window Flags"));
updatePreview();
}
void ControllerWindow::updatePreview()
{
Qt::WindowFlags flags =0;
if (windowRadioButton->isChecked()) {
flags =Qt::Window;
} elseif (dialogRadioButton->isChecked()) {
flags =Qt::Dialog;
} elseif (sheetRadioButton->isChecked()) {
flags =Qt::Sheet;
} elseif (drawerRadioButton->isChecked()) {
flags =Qt::Drawer;
} elseif (popupRadioButton->isChecked()) {
flags =Qt::Popup;
} elseif (toolRadioButton->isChecked()) {
flags =Qt::Tool;
} elseif (toolTipRadioButton->isChecked()) {
flags =Qt::ToolTip;
} elseif (splashScreenRadioButton->isChecked()) {
flags =Qt::SplashScreen;
}
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;
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;
if (customizeWindowHintCheckBox->isChecked())
flags |=Qt::CustomizeWindowHint;
previewWindow->setWindowFlags(flags);
QPoint pos = previewWindow->pos();
if (pos.x() <0)
pos.setX(0);
if (pos.y() <0)
pos.setY(0);
previewWindow->move(pos);
previewWindow->show();
}
void ControllerWindow::createTypeGroupBox()
{
typeGroupBox =newQGroupBox(tr("Type"));
windowRadioButton = createRadioButton(tr("Window"));
dialogRadioButton = createRadioButton(tr("Dialog"));
sheetRadioButton = createRadioButton(tr("Sheet"));
drawerRadioButton = createRadioButton(tr("Drawer"));
popupRadioButton = createRadioButton(tr("Popup"));
toolRadioButton = createRadioButton(tr("Tool"));
toolTipRadioButton = createRadioButton(tr("Tooltip"));
splashScreenRadioButton = createRadioButton(tr("Splash screen"));
windowRadioButton->setChecked(true);
QGridLayout*layout =newQGridLayout;
layout->addWidget(windowRadioButton,0,0);
layout->addWidget(dialogRadioButton,1,0);
layout->addWidget(sheetRadioButton,2,0);
layout->addWidget(drawerRadioButton,3,0);
layout->addWidget(popupRadioButton,0,1);
layout->addWidget(toolRadioButton,1,1);
layout->addWidget(toolTipRadioButton,2,1);
layout->addWidget(splashScreenRadioButton,3,1);
typeGroupBox->setLayout(layout);
}
void ControllerWindow::createHintsGroupBox()
{
hintsGroupBox =newQGroupBox(tr("Hints"));
msWindowsFixedSizeDialogCheckBox =
createCheckBox(tr("MS Windows fixed size dialog"));
x11BypassWindowManagerCheckBox =
createCheckBox(tr("X11 bypass window manager"));
framelessWindowCheckBox = createCheckBox(tr("Frameless window"));
windowTitleCheckBox = createCheckBox(tr("Window title"));
windowSystemMenuCheckBox = createCheckBox(tr("Window system menu"));
windowMinimizeButtonCheckBox = createCheckBox(tr("Window minimize button"));
windowMaximizeButtonCheckBox = createCheckBox(tr("Window maximize button"));
windowCloseButtonCheckBox = createCheckBox(tr("Window close button"));
windowContextHelpButtonCheckBox =
createCheckBox(tr("Window context help button"));
windowShadeButtonCheckBox = createCheckBox(tr("Window shade button"));
windowStaysOnTopCheckBox = createCheckBox(tr("Window stays on top"));
windowStaysOnBottomCheckBox = createCheckBox(tr("Window stays on bottom"));
customizeWindowHintCheckBox= createCheckBox(tr("Customize window"));
QGridLayout*layout =newQGridLayout;
layout->addWidget(msWindowsFixedSizeDialogCheckBox,0,0);
layout->addWidget(x11BypassWindowManagerCheckBox,1,0);
layout->addWidget(framelessWindowCheckBox,2,0);
layout->addWidget(windowTitleCheckBox,3,0);
layout->addWidget(windowSystemMenuCheckBox,4,0);
layout->addWidget(windowMinimizeButtonCheckBox,0,1);
layout->addWidget(windowMaximizeButtonCheckBox,1,1);
layout->addWidget(windowCloseButtonCheckBox,2,1);
layout->addWidget(windowContextHelpButtonCheckBox,3,1);
layout->addWidget(windowShadeButtonCheckBox,4,1);
layout->addWidget(windowStaysOnTopCheckBox,5,1);
layout->addWidget(windowStaysOnBottomCheckBox,6,1);
layout->addWidget(customizeWindowHintCheckBox,5,0);
hintsGroupBox->setLayout(layout);
}
QCheckBox*ControllerWindow::createCheckBox(constQString&text)
{
QCheckBox*checkBox =newQCheckBox(text);
connect(checkBox, SIGNAL(clicked()),this, SLOT(updatePreview()));
return checkBox;
}
QRadioButton*ControllerWindow::createRadioButton(constQString&text)
{
QRadioButton*button =newQRadioButton(text);
connect(button, SIGNAL(clicked()),this, SLOT(updatePreview()));
return button;
}
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter
ou par MP !