nodeeditor_doxy
src/ExampleApp/windowflagseditor.cpp
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the examples of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:BSD$
00010 ** You may use this file under the terms of the BSD license as follows:
00011 **
00012 ** "Redistribution and use in source and binary forms, with or without
00013 ** modification, are permitted provided that the following conditions are
00014 ** met:
00015 **   * Redistributions of source code must retain the above copyright
00016 **     notice, this list of conditions and the following disclaimer.
00017 **   * Redistributions in binary form must reproduce the above copyright
00018 **     notice, this list of conditions and the following disclaimer in
00019 **     the documentation and/or other materials provided with the
00020 **     distribution.
00021 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
00022 **     the names of its contributors may be used to endorse or promote
00023 **     products derived from this software without specific prior written
00024 **     permission.
00025 **
00026 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00027 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00028 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00029 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00030 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00031 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00032 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00033 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00034 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00035 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00036 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
00037 ** $QT_END_LICENSE$
00038 **
00039 ****************************************************************************/
00040 
00041 #include <QtGui>
00042 
00043 #include "windowflagseditor.h"
00044 
00046 WindowFlagsEditor::WindowFlagsEditor(QWidget *parent)
00047     : QFrame(parent)
00048 {
00049     createTypeGroupBox();
00050     createHintsGroupBox();
00051 
00052         /*
00053     quitButton = new QPushButton(tr("&Close"));
00054     connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
00055         */
00056 
00057     //QVBoxLayout *bottomLayout = new QVBoxLayout;
00058     //bottomLayout->addStretch();
00059     //bottomLayout->addWidget(quitButton);
00060 
00061     QVBoxLayout *mainLayout = new QVBoxLayout;
00062     mainLayout->addWidget(typeGroupBox);
00063     mainLayout->addWidget(hintsGroupBox);
00064     //mainLayout->addLayout(bottomLayout);
00065     setLayout(mainLayout);
00066 
00067     setWindowTitle(tr("Window Flags"));
00068     updateWindowFlags();
00069 }
00071 
00073 void WindowFlagsEditor::updateWindowFlags()
00074 {
00075     Qt::WindowFlags flags = 0;
00076 
00077         if (nullRadioButton->isChecked()) {
00078                 flags = 0;
00079         } else if (windowRadioButton->isChecked()) {
00080         flags = Qt::Window;
00081     } else if (dialogRadioButton->isChecked()) {
00082         flags = Qt::Dialog;
00083     } else if (sheetRadioButton->isChecked()) {
00084         flags = Qt::Sheet;
00085     } else if (drawerRadioButton->isChecked()) {
00086         flags = Qt::Drawer;
00087     } else if (popupRadioButton->isChecked()) {
00088         flags = Qt::Popup;
00089     } else if (toolRadioButton->isChecked()) {
00090         flags = Qt::Tool;
00091     } else if (toolTipRadioButton->isChecked()) {
00092         flags = Qt::ToolTip;
00093     } else if (splashScreenRadioButton->isChecked()) {
00094         flags = Qt::SplashScreen;
00096     }
00098 
00099     if (msWindowsFixedSizeDialogCheckBox->isChecked())
00100         flags |= Qt::MSWindowsFixedSizeDialogHint;
00101     if (x11BypassWindowManagerCheckBox->isChecked())
00102         flags |= Qt::X11BypassWindowManagerHint;
00103     if (framelessWindowCheckBox->isChecked())
00104         flags |= Qt::FramelessWindowHint;
00105     if (windowTitleCheckBox->isChecked())
00106         flags |= Qt::WindowTitleHint;
00107     if (windowSystemMenuCheckBox->isChecked())
00108         flags |= Qt::WindowSystemMenuHint;
00109     if (windowMinimizeButtonCheckBox->isChecked())
00110         flags |= Qt::WindowMinimizeButtonHint;
00111     if (windowMaximizeButtonCheckBox->isChecked())
00112         flags |= Qt::WindowMaximizeButtonHint;
00113     if (windowCloseButtonCheckBox->isChecked())
00114         flags |= Qt::WindowCloseButtonHint;
00115     if (windowContextHelpButtonCheckBox->isChecked())
00116         flags |= Qt::WindowContextHelpButtonHint;
00117     if (windowShadeButtonCheckBox->isChecked())
00118         flags |= Qt::WindowShadeButtonHint;
00119     if (windowStaysOnTopCheckBox->isChecked())
00120         flags |= Qt::WindowStaysOnTopHint;
00121     if (windowStaysOnBottomCheckBox->isChecked())
00122         flags |= Qt::WindowStaysOnBottomHint;
00123     if (customizeWindowHintCheckBox->isChecked())
00124         flags |= Qt::CustomizeWindowHint;
00125 
00126         emit newWindowFlags(flags);
00127 }
00129 
00131 void WindowFlagsEditor::createTypeGroupBox()
00132 {
00133     typeGroupBox = new QGroupBox(tr("Type"));
00134 
00135     windowRadioButton = createRadioButton(tr("Window"));
00136     dialogRadioButton = createRadioButton(tr("Dialog"));
00137     sheetRadioButton = createRadioButton(tr("Sheet"));
00138     drawerRadioButton = createRadioButton(tr("Drawer"));
00139     popupRadioButton = createRadioButton(tr("Popup"));
00140     toolRadioButton = createRadioButton(tr("Tool"));
00141     toolTipRadioButton = createRadioButton(tr("Tooltip"));
00142     splashScreenRadioButton = createRadioButton(tr("Splash screen"));
00143         nullRadioButton = createRadioButton(tr("NULL"));
00144     nullRadioButton->setChecked(true);
00145 
00146     QGridLayout *layout = new QGridLayout;
00147     layout->addWidget(windowRadioButton, 0, 0);
00148     layout->addWidget(dialogRadioButton, 1, 0);
00149     layout->addWidget(sheetRadioButton, 2, 0);
00150     layout->addWidget(drawerRadioButton, 3, 0);
00151     layout->addWidget(popupRadioButton, 0, 1);
00152     layout->addWidget(toolRadioButton, 1, 1);
00153     layout->addWidget(toolTipRadioButton, 2, 1);
00154     layout->addWidget(splashScreenRadioButton, 3, 1);
00155         layout->addWidget(nullRadioButton, 4, 0);
00156     typeGroupBox->setLayout(layout);
00157 }
00159 
00161 void WindowFlagsEditor::createHintsGroupBox()
00162 {
00163     hintsGroupBox = new QGroupBox(tr("Hints"));
00164 
00165     msWindowsFixedSizeDialogCheckBox =
00166             createCheckBox(tr("MS Windows fixed size dialog"));
00167     x11BypassWindowManagerCheckBox =
00168             createCheckBox(tr("X11 bypass window manager"));
00169     framelessWindowCheckBox = createCheckBox(tr("Frameless window"));
00170     windowTitleCheckBox = createCheckBox(tr("Window title"));
00171     windowSystemMenuCheckBox = createCheckBox(tr("Window system menu"));
00172     windowMinimizeButtonCheckBox = createCheckBox(tr("Window minimize button"));
00173     windowMaximizeButtonCheckBox = createCheckBox(tr("Window maximize button"));
00174     windowCloseButtonCheckBox = createCheckBox(tr("Window close button"));
00175     windowContextHelpButtonCheckBox =
00176             createCheckBox(tr("Window context help button"));
00177     windowShadeButtonCheckBox = createCheckBox(tr("Window shade button"));
00178     windowStaysOnTopCheckBox = createCheckBox(tr("Window stays on top"));
00179     windowStaysOnBottomCheckBox = createCheckBox(tr("Window stays on bottom"));
00180     customizeWindowHintCheckBox= createCheckBox(tr("Customize window"));
00181 
00182     QGridLayout *layout = new QGridLayout;
00183     layout->addWidget(msWindowsFixedSizeDialogCheckBox, 0, 0);
00184     layout->addWidget(x11BypassWindowManagerCheckBox, 1, 0);
00185     layout->addWidget(framelessWindowCheckBox, 2, 0);
00186     layout->addWidget(windowTitleCheckBox, 3, 0);
00187     layout->addWidget(windowSystemMenuCheckBox, 4, 0);
00188     layout->addWidget(windowMinimizeButtonCheckBox, 0, 1);
00189     layout->addWidget(windowMaximizeButtonCheckBox, 1, 1);
00190     layout->addWidget(windowCloseButtonCheckBox, 2, 1);
00191     layout->addWidget(windowContextHelpButtonCheckBox, 3, 1);
00192     layout->addWidget(windowShadeButtonCheckBox, 4, 1);
00193     layout->addWidget(windowStaysOnTopCheckBox, 5, 1);
00194     layout->addWidget(windowStaysOnBottomCheckBox, 6, 1);
00195     layout->addWidget(customizeWindowHintCheckBox, 5, 0);
00196     hintsGroupBox->setLayout(layout);
00197 }
00199 
00201 QCheckBox *WindowFlagsEditor::createCheckBox(const QString &text)
00202 {
00203     QCheckBox *checkBox = new QCheckBox(text);
00204     connect(checkBox, SIGNAL(clicked()), this, SLOT(updateWindowFlags()));
00205     return checkBox;
00206 }
00208 
00210 QRadioButton *WindowFlagsEditor::createRadioButton(const QString &text)
00211 {
00212     QRadioButton *button = new QRadioButton(text);
00213     connect(button, SIGNAL(clicked()), this, SLOT(updateWindowFlags()));
00214     return button;
00215 }