examples/widgets/softkeys/softkeys.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
--- a/examples/widgets/softkeys/softkeys.cpp	Fri Apr 16 15:50:13 2010 +0300
+++ b/examples/widgets/softkeys/softkeys.cpp	Mon May 03 13:17:34 2010 +0300
@@ -70,6 +70,12 @@
     toggleButton->setContextMenuPolicy(Qt::NoContextMenu);
     toggleButton->setCheckable(true);
 
+    modeButton = new QPushButton(tr("Loop SK window type"), this);
+    modeButton->setContextMenuPolicy(Qt::NoContextMenu);
+
+    modeLabel = new QLabel(tr("Normal maximized"), this);
+    modeLabel->setContextMenuPolicy(Qt::NoContextMenu);
+
     pushButton = new QPushButton(tr("File Dialog"), this);
     pushButton->setContextMenuPolicy(Qt::NoContextMenu);
 
@@ -87,6 +93,8 @@
     layout->addWidget(toggleButton, 2, 0);
     layout->addWidget(pushButton, 2, 1);
     layout->addWidget(comboBox, 3, 0, 1, 2);
+    layout->addWidget(modeButton, 4, 0, 1, 2);
+    layout->addWidget(modeLabel, 5, 0, 1, 2);
     central->setLayout(layout);
 
     fileMenu = menuBar()->addMenu(tr("&File"));
@@ -97,6 +105,7 @@
     connect(pushButton, SIGNAL(clicked()), this, SLOT(openDialog()));
     connect(exit, SIGNAL(triggered()), this, SLOT(exitApplication()));
     connect(toggleButton, SIGNAL(clicked()), this, SLOT(setCustomSoftKeys()));
+    connect(modeButton, SIGNAL(clicked()), this, SLOT(setMode()));
     pushButton->setFocus();
 }
 
@@ -133,6 +142,35 @@
     }
 }
 
+void MainWindow::setMode()
+{
+    if(isMaximized()) {
+        showFullScreen();
+        modeLabel->setText(tr("Normal Fullscreen"));
+    } else {
+        Qt::WindowFlags flags = windowFlags();
+        if(flags & Qt::WindowSoftkeysRespondHint) {
+            flags |= Qt::WindowSoftkeysVisibleHint;
+            flags &= ~Qt::WindowSoftkeysRespondHint;
+            setWindowFlags(flags); // Hides visible window
+            showFullScreen();
+            modeLabel->setText(tr("Fullscreen with softkeys"));
+        } else if(flags & Qt::WindowSoftkeysVisibleHint) {
+            flags &= ~Qt::WindowSoftkeysVisibleHint;
+            flags &= ~Qt::WindowSoftkeysRespondHint;
+            setWindowFlags(flags); // Hides visible window
+            showMaximized();
+            modeLabel->setText(tr("Normal Maximized"));
+        } else {
+            flags &= ~Qt::WindowSoftkeysVisibleHint;
+            flags |= Qt::WindowSoftkeysRespondHint;
+            setWindowFlags(flags); // Hides visible window
+            showFullScreen();
+            modeLabel->setText(tr("Fullscreen with SK respond"));
+        }
+    }
+}
+
 void MainWindow::exitApplication()
 {
     qApp->exit();