summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarkku Luukkainen <markku.luukkainen@digia.com>2009-05-13 14:25:24 (GMT)
committerMarkku Luukkainen <markku.luukkainen@digia.com>2009-05-13 14:25:24 (GMT)
commita28a4bccad5d885bf3ac5f58a8febb8d59fffe0f (patch)
tree31521af622429d7e5ee3e1ed8ed5ab8dc37a8534 /src
parentaf612206adc919e3c13b7856f9f7c020ef9c3a7b (diff)
downloadQt-a28a4bccad5d885bf3ac5f58a8febb8d59fffe0f.zip
Qt-a28a4bccad5d885bf3ac5f58a8febb8d59fffe0f.tar.gz
Qt-a28a4bccad5d885bf3ac5f58a8febb8d59fffe0f.tar.bz2
Added Methods to set and access QSoftKeyStack from QMainWindow.
Diffstat (limited to 'src')
-rw-r--r--src/gui/softkeys/main.cpp8
-rw-r--r--src/gui/widgets/qmainwindow.cpp47
-rw-r--r--src/gui/widgets/qmainwindow.h11
-rw-r--r--src/gui/widgets/qsoftkeyaction.h1
-rw-r--r--src/gui/widgets/qsoftkeystack_s60.cpp17
5 files changed, 75 insertions, 9 deletions
diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp
index c305d19..6a75c40 100644
--- a/src/gui/softkeys/main.cpp
+++ b/src/gui/softkeys/main.cpp
@@ -30,6 +30,8 @@ MainWindow::MainWindow(QWidget *parent)
this->setMenuBar(menuBar);
QSoftKeyStack *stack = new QSoftKeyStack(central);
+ setSoftKeyStack(stack);
+
QSoftKeyAction action1(central);
action1.setText(QString("Ok"));
action1.setRole(QSoftKeyAction::Ok);
@@ -43,6 +45,11 @@ MainWindow::MainWindow(QWidget *parent)
action4.setText(QString("Menu"));
action4.setRole(QSoftKeyAction::Menu);
+ QSoftKeyAction action5(central);
+ action5.setText(QString("ContextMenu"));
+ action5.setRole(QSoftKeyAction::ContextMenu);
+
+
QList<QSoftKeyAction*> myActionList;
myActionList.append(&action1);
myActionList.append(&action2);
@@ -55,6 +62,7 @@ MainWindow::MainWindow(QWidget *parent)
QList<QSoftKeyAction*> myActionList2;
myActionList2.append(&action4);
myActionList2.append(&action1);
+ myActionList2.append(&action5);
stack->push(myActionList2);
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp
index 502c1e9..43bc098 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/gui/widgets/qmainwindow.cpp
@@ -66,6 +66,10 @@ extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp
QT_END_NAMESPACE
#endif
+#ifndef QT_NO_SOFTKEYSTACK
+#include <QSoftKeyStack.h>
+#endif
+
QT_BEGIN_NAMESPACE
class QMainWindowPrivate : public QWidgetPrivate
@@ -80,6 +84,9 @@ public:
#if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR)
, hasOldCursor(false) , cursorAdjusted(false)
#endif
+#ifndef QT_NO_SOFTKEYSTACK
+ , softKeyStack(0)
+#endif
{ }
QMainWindowLayout *layout;
QSize iconSize;
@@ -99,6 +106,10 @@ public:
uint hasOldCursor : 1;
uint cursorAdjusted : 1;
#endif
+
+#ifndef QT_NO_SOFTKEYSTACK
+ QSoftKeyStack* softKeyStack;
+#endif
};
void QMainWindowPrivate::init()
@@ -514,6 +525,42 @@ void QMainWindow::setMenuWidget(QWidget *menuBar)
}
#endif // QT_NO_MENUBAR
+#ifndef QT_NO_SOFTKEYSTACK
+/*!
+ Returns the softkey stack for the main window. This function creates
+ and returns an empty soft key stack if the stack does not exist.
+
+ \sa softKeyStack()
+*/
+QSoftKeyStack *QMainWindow::softKeyStack() const
+{
+ if (!d_func()->softKeyStack) {
+ QMainWindow *self = const_cast<QMainWindow *>(this);
+ QSoftKeyStack* softKeyStack = new QSoftKeyStack(self);
+ self->setSoftKeyStack(softKeyStack);
+ }
+ return d_func()->softKeyStack;
+}
+
+/*!
+ Sets the softkey stackfor the main window to \a softKeyStack.
+
+ Note: QMainWindow takes ownership of the \a softKeyStack pointer and
+ deletes it at the appropriate time.
+
+ \sa softKeyStack()
+*/
+void QMainWindow::setSoftKeyStack(QSoftKeyStack *softKeyStack)
+{
+ Q_D(QMainWindow);
+ if (d->softKeyStack && d->softKeyStack != softKeyStack) {
+ QSoftKeyStack *oldSoftKeyStack = d->softKeyStack;
+ delete oldSoftKeyStack;
+ }
+ d->softKeyStack = softKeyStack;
+}
+#endif // QT_NO_SOFTKEYSTACK
+
#ifndef QT_NO_STATUSBAR
/*!
Returns the status bar for the main window. This function creates
diff --git a/src/gui/widgets/qmainwindow.h b/src/gui/widgets/qmainwindow.h
index 9983c7a..e2dcd5e 100644
--- a/src/gui/widgets/qmainwindow.h
+++ b/src/gui/widgets/qmainwindow.h
@@ -59,7 +59,9 @@ class QMenuBar;
class QStatusBar;
class QToolBar;
class QMenu;
-
+#ifndef QT_NO_SOFTKEYSTACK
+class QSoftKeyStack;
+#endif
class Q_GUI_EXPORT QMainWindow : public QWidget
{
Q_OBJECT
@@ -129,7 +131,12 @@ public:
QWidget *menuWidget() const;
void setMenuWidget(QWidget *menubar);
#endif
-
+
+#ifndef QT_NO_SOFTKEYSTACK
+ QSoftKeyStack *softKeyStack() const;
+ void setSoftKeyStack(QSoftKeyStack *softKeyStack);
+#endif
+
#ifndef QT_NO_STATUSBAR
QStatusBar *statusBar() const;
void setStatusBar(QStatusBar *statusbar);
diff --git a/src/gui/widgets/qsoftkeyaction.h b/src/gui/widgets/qsoftkeyaction.h
index 26fa601..4ce5c5b 100644
--- a/src/gui/widgets/qsoftkeyaction.h
+++ b/src/gui/widgets/qsoftkeyaction.h
@@ -71,6 +71,7 @@ public:
Deselect,
Finish,
Menu,
+ ContextMenu,
Custom
};
diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp
index ce4f116..35835f6 100644
--- a/src/gui/widgets/qsoftkeystack_s60.cpp
+++ b/src/gui/widgets/qsoftkeystack_s60.cpp
@@ -86,14 +86,17 @@ void QSoftKeyStackPrivate::setNativeSoftKeys()
for (int index = 0; index < top.count(); index++) {
const QSoftKeyAction* softKeyAction = top.at(index);
- HBufC* text = qt_QString2HBufCNewL(softKeyAction->text());
- CleanupStack::PushL(text);
- if (softKeyAction->role() == QSoftKeyAction::Menu) {
- nativeContainer->SetCommandL(softKeyAction->nativePosition(), EAknSoftkeyOptions, *text);
- } else {
- nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART + softKeyAction->qtContextKey(), *text);
+ if (softKeyAction->role() != QSoftKeyAction::ContextMenu) {
+
+ HBufC* text = qt_QString2HBufCNewL(softKeyAction->text());
+ CleanupStack::PushL(text);
+ if (softKeyAction->role() == QSoftKeyAction::Menu) {
+ nativeContainer->SetCommandL(softKeyAction->nativePosition(), EAknSoftkeyOptions, *text);
+ } else {
+ nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART + softKeyAction->qtContextKey(), *text);
+ }
+ CleanupStack::PopAndDestroy();
}
- CleanupStack::PopAndDestroy();
}
}