diff options
author | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-06-10 10:07:36 (GMT) |
---|---|---|
committer | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-06-10 10:07:36 (GMT) |
commit | 5d924cb69ea03921a9b4bc5f701063cf45ded508 (patch) | |
tree | f2fa5430055c60d207b8f7c12bd856d3aa0fa782 | |
parent | 29189c3112cbfb24d9e5855240e352af18088db9 (diff) | |
download | Qt-5d924cb69ea03921a9b4bc5f701063cf45ded508.zip Qt-5d924cb69ea03921a9b4bc5f701063cf45ded508.tar.gz Qt-5d924cb69ea03921a9b4bc5f701063cf45ded508.tar.bz2 |
Skeleton implementation for softkeys example
-rw-r--r-- | src/gui/softkeys/main.cpp | 108 | ||||
-rw-r--r-- | src/gui/softkeys/softkeys.cpp | 61 | ||||
-rw-r--r-- | src/gui/softkeys/softkeys.h | 79 | ||||
-rw-r--r-- | src/gui/softkeys/softkeys.pro | 4 |
4 files changed, 145 insertions, 107 deletions
diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index a92e2c2..a355f93 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -10,116 +10,12 @@ ****************************************************************************/ #include <QtGui> - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - -private slots: - void context1Slot(); - void context3Slot(); - void softKeySlot(); -public: - - MainWindow(QWidget *parent = 0); - ~MainWindow(); - QMenu *contextMenu; - QAction* context1; - QAction* context2; - QAction* context3; - QSoftKeyAction *action1; - QSoftKeyAction *action2; - QSoftKeyAction *action3; - QSoftKeyAction *action4; - QSoftKeyAction *action5; -}; - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), - contextMenu(0), - context1(0), context2(0), context3(0), - action1(0),action2(0),action3(0),action4(0),action5(0) - -{ - QWidget *central = new QWidget(this); - contextMenu = new QMenu(); - - central->setLayout(new QVBoxLayout); - central->layout()->addWidget(new QPushButton); - central->layout()->addWidget(new QPushButton); - central->layout()->addWidget(new QPushButton); - context1 = new QAction(QString("Context1"), central); - context2 = new QAction(QString("Context2"), central); - - context3 = new QAction(QString("Context3"), contextMenu); - central->addAction(context1); - central->addAction(context2); - QMenuBar* menuBar = new QMenuBar(this); - menuBar->addAction("MyMenuItem1"); - this->setMenuBar(menuBar); - context2->setMenu(contextMenu); - contextMenu->addAction(context3); - - connect(context1, SIGNAL(triggered()), this, SLOT(context1Slot())); - connect(context3, SIGNAL(triggered()), this, SLOT(context3Slot())); - action1 = new QSoftKeyAction(QSoftKeyAction::Ok, QString("Ok"), central); - action2 = new QSoftKeyAction(QSoftKeyAction::Back, QString("Back"), central); - action3 = new QSoftKeyAction(QSoftKeyAction::Cancel, QString("Cancel"), central); - action4 = new QSoftKeyAction(QSoftKeyAction::Menu, QString("Menu"), central); - action5 = new QSoftKeyAction(QSoftKeyAction::ContextMenu,QString("ContextMenu"), central); - - connect(action2, SIGNAL(triggered()), this, SLOT(softKeySlot())); - - QList<QSoftKeyAction*> myActionList; - myActionList.append(action1); - myActionList.append(action2); - myActionList.append(action3); - softKeyStack()->push(myActionList); - softKeyStack()->pop(); - softKeyStack()->push(action1); - softKeyStack()->pop(); - - QList<QSoftKeyAction*> myActionList2; - myActionList2.append(action4); - myActionList2.append(action2); - myActionList2.append(action5); - softKeyStack()->push(myActionList2); - - - setCentralWidget(central); -} -MainWindow::~MainWindow() -{ - delete context1; - delete context2; - delete context3; - delete action1; - delete action2; - delete action3; - delete action4; - delete action5; - delete contextMenu; -} - -void MainWindow::context1Slot() - { - } -void MainWindow::context3Slot() - { - } - -void MainWindow::softKeySlot() -{ - -} +#include "softkeys.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow mw; - mw.show(); + mw.showMaximized(); return app.exec(); } - -#include "main.moc" diff --git a/src/gui/softkeys/softkeys.cpp b/src/gui/softkeys/softkeys.cpp new file mode 100644 index 0000000..edf38b9 --- /dev/null +++ b/src/gui/softkeys/softkeys.cpp @@ -0,0 +1,61 @@ +#include "softkeys.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + fileMenu = menuBar()->addMenu(tr("&File")); + openDialogAct = new QAction(tr("&Open Dialog"), this); + addSoftKeysAct = new QAction(tr("&Add Softkeys"), this); + clearSoftKeysAct = new QAction(tr("&Clear Softkeys"), this); + fileMenu->addAction(openDialogAct); + fileMenu->addAction(addSoftKeysAct); + fileMenu->addAction(clearSoftKeysAct); + connect(openDialogAct, SIGNAL(triggered()), this, SLOT(openDialog())); + connect(addSoftKeysAct, SIGNAL(triggered()), this, SLOT(addSoftKeys())); + connect(clearSoftKeysAct, SIGNAL(triggered()), this, SLOT(clearSoftKeys())); + QWidget *central = new QWidget(this); + central->setLayout(new QVBoxLayout); +// central->setFocus(); + setCentralWidget(central); + QPushButton button1; +// QAction* menuAction = +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::openDialog() +{ + QFileDialog::getOpenFileName(this); +} + +void MainWindow::addSoftKeys() +{ + ok = new QAction(tr("Ok"), this); + ok->setSoftKeyRole(QAction::OkSoftKey); + connect(ok, SIGNAL(triggered()), this, SLOT(okPressed())); + + cancel = new QAction(tr("Cancel"), this); + cancel->setSoftKeyRole(QAction::OkSoftKey); + connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); + + QList<QAction*> softkeys; + softkeys.append(ok); + softkeys.append(cancel); + setSoftKeys(softkeys); + +} + +void MainWindow::clearSoftKeys() +{ + setSoftKey(0); +} + +void MainWindow::okPressed() +{ +} + +void MainWindow::cancelPressed() +{ +} diff --git a/src/gui/softkeys/softkeys.h b/src/gui/softkeys/softkeys.h new file mode 100644 index 0000000..2bc74ba --- /dev/null +++ b/src/gui/softkeys/softkeys.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, 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.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef SOFTKEYS_H +#define SOFTKEYS_H + +#include <QtGui> + +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + +private slots: + void openDialog(); + void addSoftKeys(); + void clearSoftKeys(); + void okPressed(); + void cancelPressed(); +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); +private: + QMenu* fileMenu; + QAction* openDialogAct; + QAction* addSoftKeysAct; + QAction* clearSoftKeysAct; + QAction* ok; + QAction* cancel; +}; + +//! [0] +class SoftKey : public QWidget +{ + Q_OBJECT +public: + SoftKey(QWidget *parent = 0); +}; +//! [0] + +#endif diff --git a/src/gui/softkeys/softkeys.pro b/src/gui/softkeys/softkeys.pro index a16103e..4cb8672 100644 --- a/src/gui/softkeys/softkeys.pro +++ b/src/gui/softkeys/softkeys.pro @@ -1,2 +1,4 @@ +HEADERS = softkeys.h SOURCES += \ - main.cpp + main.cpp \ + softkeys.cpp
\ No newline at end of file |