summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qsoftkeystack.cpp54
-rw-r--r--src/gui/widgets/qsoftkeystack.h2
-rw-r--r--src/gui/widgets/qsoftkeystack_p.h2
3 files changed, 55 insertions, 3 deletions
diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp
index 05fe397..a7fa3f1 100644
--- a/src/gui/widgets/qsoftkeystack.cpp
+++ b/src/gui/widgets/qsoftkeystack.cpp
@@ -44,6 +44,22 @@
#include "qapplication.h"
#include "qmainwindow.h"
+static bool isSame(const QSoftkeySet& a, const QSoftkeySet& b)
+{
+ bool isSame=true;
+ if ( a.count() != b.count())
+ return false;
+ int index=0;
+ while (index<a.count()) {
+ if (a.at(index)->role() != b.at(index)->role())
+ return false;
+ if (a.at(index)->text().compare(b.at(index)->text())!=0)
+ return false;
+ index++;
+ }
+ return true;
+}
+
QSoftKeyStackPrivate::QSoftKeyStackPrivate()
{
@@ -75,6 +91,25 @@ void QSoftKeyStackPrivate::pop()
setNativeSoftKeys();
}
+void QSoftKeyStackPrivate::popandPush(QSoftKeyAction *softKey)
+{
+ QSoftkeySet oldSoftKeySet = softKeyStack.pop();
+ QSoftkeySet newSoftKeySet;
+ newSoftKeySet.append(newSoftKeySet);
+ softKeyStack.push(newSoftKeySet);
+ if( !isSame(oldSoftKeySet, newSoftKeySet))
+ setNativeSoftKeys();
+}
+
+void QSoftKeyStackPrivate::popandPush(const QList<QSoftKeyAction*> &softkeys)
+{
+ QSoftkeySet oldSoftKeySet = softKeyStack.pop();
+ QSoftkeySet newSoftKeySet(softkeys);
+ softKeyStack.push(newSoftKeySet);
+ if( !isSame(oldSoftKeySet, newSoftKeySet))
+ setNativeSoftKeys();
+}
+
const QSoftkeySet& QSoftKeyStackPrivate::top()
{
return softKeyStack.top();
@@ -108,6 +143,18 @@ void QSoftKeyStack::pop()
d->pop();
}
+void QSoftKeyStack::popandPush(QSoftKeyAction *softKey)
+{
+ Q_D(QSoftKeyStack);
+ d->popandPush(softKey);
+}
+
+void QSoftKeyStack::popandPush(const QList<QSoftKeyAction*> &softkeys)
+{
+ Q_D(QSoftKeyStack);
+ d->popandPush(softkeys);
+}
+
const QSoftkeySet& QSoftKeyStack::top()
{
Q_D(QSoftKeyStack);
@@ -123,8 +170,6 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now)
if( !mainWindow)
return;
QSoftKeyStack* softKeyStack = mainWindow->softKeyStack();
- if (old)
- softKeyStack->pop();
Qt::ContextMenuPolicy policy = now->contextMenuPolicy();
if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) {
@@ -133,7 +178,10 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now)
QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString::fromLatin1("ContextMenu"), now);
actionList.append(menu);
actionList.append(contextMenu);
- softKeyStack->push(actionList);
+ if (old)
+ softKeyStack->popandPush(actionList);
+ else
+ softKeyStack->push(actionList);
}
}
diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h
index 2a63ab8..10d9153 100644
--- a/src/gui/widgets/qsoftkeystack.h
+++ b/src/gui/widgets/qsoftkeystack.h
@@ -66,6 +66,8 @@ public:
void push(QSoftKeyAction *softKey);
void push(const QList<QSoftKeyAction*> &softkeys);
void pop();
+ void popandPush(QSoftKeyAction *softKey);
+ void popandPush(const QList<QSoftKeyAction*> &softkeys);
const QSoftkeySet& top();
void handleSoftKeyPress(int command);
diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h
index 2469648..57475bd 100644
--- a/src/gui/widgets/qsoftkeystack_p.h
+++ b/src/gui/widgets/qsoftkeystack_p.h
@@ -77,6 +77,8 @@ public:
void push(QSoftKeyAction *softKey);
void push(const QList<QSoftKeyAction*> &softKeys);
void pop();
+ void popandPush(QSoftKeyAction *softKey);
+ void popandPush(const QList<QSoftKeyAction*> &softkeys);
const QSoftkeySet& top();
void handleSoftKeyPress(int command);