examples/widgets/softkeys/softkeys.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
18:2f34d5167611 19:fcece45ef507
    68 
    68 
    69     toggleButton = new QPushButton(tr("Custom"), this);
    69     toggleButton = new QPushButton(tr("Custom"), this);
    70     toggleButton->setContextMenuPolicy(Qt::NoContextMenu);
    70     toggleButton->setContextMenuPolicy(Qt::NoContextMenu);
    71     toggleButton->setCheckable(true);
    71     toggleButton->setCheckable(true);
    72 
    72 
       
    73     modeButton = new QPushButton(tr("Loop SK window type"), this);
       
    74     modeButton->setContextMenuPolicy(Qt::NoContextMenu);
       
    75 
       
    76     modeLabel = new QLabel(tr("Normal maximized"), this);
       
    77     modeLabel->setContextMenuPolicy(Qt::NoContextMenu);
       
    78 
    73     pushButton = new QPushButton(tr("File Dialog"), this);
    79     pushButton = new QPushButton(tr("File Dialog"), this);
    74     pushButton->setContextMenuPolicy(Qt::NoContextMenu);
    80     pushButton->setContextMenuPolicy(Qt::NoContextMenu);
    75 
    81 
    76     QComboBox* comboBox = new QComboBox(this);
    82     QComboBox* comboBox = new QComboBox(this);
    77     comboBox->setContextMenuPolicy(Qt::NoContextMenu);
    83     comboBox->setContextMenuPolicy(Qt::NoContextMenu);
    85     layout->addWidget(textEditor, 0, 0, 1, 2);
    91     layout->addWidget(textEditor, 0, 0, 1, 2);
    86     layout->addWidget(infoLabel, 1, 0, 1, 2);
    92     layout->addWidget(infoLabel, 1, 0, 1, 2);
    87     layout->addWidget(toggleButton, 2, 0);
    93     layout->addWidget(toggleButton, 2, 0);
    88     layout->addWidget(pushButton, 2, 1);
    94     layout->addWidget(pushButton, 2, 1);
    89     layout->addWidget(comboBox, 3, 0, 1, 2);
    95     layout->addWidget(comboBox, 3, 0, 1, 2);
       
    96     layout->addWidget(modeButton, 4, 0, 1, 2);
       
    97     layout->addWidget(modeLabel, 5, 0, 1, 2);
    90     central->setLayout(layout);
    98     central->setLayout(layout);
    91 
    99 
    92     fileMenu = menuBar()->addMenu(tr("&File"));
   100     fileMenu = menuBar()->addMenu(tr("&File"));
    93     exit = new QAction(tr("&Exit"), this);
   101     exit = new QAction(tr("&Exit"), this);
    94     fileMenu->addAction(exit);
   102     fileMenu->addAction(exit);
    95 
   103 
    96     connect(clear, SIGNAL(triggered()), this, SLOT(clearTextEditor()));
   104     connect(clear, SIGNAL(triggered()), this, SLOT(clearTextEditor()));
    97     connect(pushButton, SIGNAL(clicked()), this, SLOT(openDialog()));
   105     connect(pushButton, SIGNAL(clicked()), this, SLOT(openDialog()));
    98     connect(exit, SIGNAL(triggered()), this, SLOT(exitApplication()));
   106     connect(exit, SIGNAL(triggered()), this, SLOT(exitApplication()));
    99     connect(toggleButton, SIGNAL(clicked()), this, SLOT(setCustomSoftKeys()));
   107     connect(toggleButton, SIGNAL(clicked()), this, SLOT(setCustomSoftKeys()));
       
   108     connect(modeButton, SIGNAL(clicked()), this, SLOT(setMode()));
   100     pushButton->setFocus();
   109     pushButton->setFocus();
   101 }
   110 }
   102 
   111 
   103 MainWindow::~MainWindow()
   112 MainWindow::~MainWindow()
   104 {
   113 {
   131         removeAction(ok);
   140         removeAction(ok);
   132         removeAction(cancel);
   141         removeAction(cancel);
   133     }
   142     }
   134 }
   143 }
   135 
   144 
       
   145 void MainWindow::setMode()
       
   146 {
       
   147     if(isMaximized()) {
       
   148         showFullScreen();
       
   149         modeLabel->setText(tr("Normal Fullscreen"));
       
   150     } else {
       
   151         Qt::WindowFlags flags = windowFlags();
       
   152         if(flags & Qt::WindowSoftkeysRespondHint) {
       
   153             flags |= Qt::WindowSoftkeysVisibleHint;
       
   154             flags &= ~Qt::WindowSoftkeysRespondHint;
       
   155             setWindowFlags(flags); // Hides visible window
       
   156             showFullScreen();
       
   157             modeLabel->setText(tr("Fullscreen with softkeys"));
       
   158         } else if(flags & Qt::WindowSoftkeysVisibleHint) {
       
   159             flags &= ~Qt::WindowSoftkeysVisibleHint;
       
   160             flags &= ~Qt::WindowSoftkeysRespondHint;
       
   161             setWindowFlags(flags); // Hides visible window
       
   162             showMaximized();
       
   163             modeLabel->setText(tr("Normal Maximized"));
       
   164         } else {
       
   165             flags &= ~Qt::WindowSoftkeysVisibleHint;
       
   166             flags |= Qt::WindowSoftkeysRespondHint;
       
   167             setWindowFlags(flags); // Hides visible window
       
   168             showFullScreen();
       
   169             modeLabel->setText(tr("Fullscreen with SK respond"));
       
   170         }
       
   171     }
       
   172 }
       
   173 
   136 void MainWindow::exitApplication()
   174 void MainWindow::exitApplication()
   137 {
   175 {
   138     qApp->exit();
   176     qApp->exit();
   139 }
   177 }
   140 
   178