summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-06-13 09:01:02 +0200
committerLiang Qi <liang.qi@qt.io>2016-06-13 12:46:46 +0200
commit511790fd1af1e2886a0e2e8dd4308099705cd815 (patch)
treeb42aee537a6103cd064f9f41ae2889b09b79fd23 /src/widgets/widgets
parent1542d8881fc5ccbc5918cd4acbe4091ebbd24508 (diff)
parentcbe332405aa22257d432f1797b325f5e57007c20 (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: config_help.txt configure mkspecs/features/uikit/sdk.prf src/corelib/global/qhooks.cpp src/corelib/io/qfilesystemwatcher.cpp src/corelib/io/qlockfile_unix.cpp src/corelib/tools/qalgorithms.h src/gui/kernel/qwindowsysteminterface.h src/gui/text/qtextdocument_p.cpp src/network/access/access.pri src/network/access/qnetworkaccessmanager.cpp src/network/access/qnetworkreplynsurlconnectionimpl.mm src/src.pro src/testlib/qtestcase.cpp src/widgets/kernel/qwidgetbackingstore_p.h src/widgets/styles/qwindowscestyle.cpp src/widgets/styles/qwindowsmobilestyle.cpp tests/auto/corelib/io/qdiriterator/qdiriterator.pro tests/auto/corelib/io/qfileinfo/qfileinfo.pro tests/auto/gui/kernel/qwindow/BLACKLIST tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp tools/configure/configureapp.cpp Change-Id: Ibf7fb9c8cf263a810ade82f821345d0725c57c67
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qmenu.cpp13
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp19
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h5
3 files changed, 22 insertions, 15 deletions
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index c03c96333a..cb99b58d97 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -2744,10 +2744,15 @@ QMenu::event(QEvent *e)
return true;
}
} break;
- case QEvent::ContextMenu:
- if (d->delayState.timer.isActive()) {
- d->delayState.stop();
- internalDelayedPopup();
+ case QEvent::MouseButtonPress:
+ case QEvent::ContextMenu: {
+ bool canPopup = true;
+ if (e->type() == QEvent::MouseButtonPress)
+ canPopup = (static_cast<QMouseEvent*>(e)->button() == Qt::LeftButton);
+ if (canPopup && d->delayState.timer.isActive()) {
+ d->delayState.stop();
+ internalDelayedPopup();
+ }
}
break;
case QEvent::Resize: {
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 23d52b278d..66f17dbe33 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -717,7 +717,7 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e
if (m_transactions.count())
return false;
internalUndo(validateFromState);
- m_history.resize(m_undoState);
+ m_history.erase(m_history.begin() + m_undoState, m_history.end());
if (m_modifiedState > m_undoState)
m_modifiedState = -1;
m_validInput = true;
@@ -796,14 +796,14 @@ void QWidgetLineControl::internalSetText(const QString &txt, int pos, bool edite
*/
void QWidgetLineControl::addCommand(const Command &cmd)
{
- if (m_separator && m_undoState && m_history[m_undoState - 1].type != Separator) {
- m_history.resize(m_undoState + 2);
- m_history[m_undoState++] = Command(Separator, m_cursor, 0, m_selstart, m_selend);
- } else {
- m_history.resize(m_undoState + 1);
- }
+ m_history.erase(m_history.begin() + m_undoState, m_history.end());
+
+ if (m_separator && m_undoState && m_history[m_undoState - 1].type != Separator)
+ m_history.push_back(Command(Separator, m_cursor, 0, m_selstart, m_selend));
+
m_separator = false;
- m_history[m_undoState++] = cmd;
+ m_history.push_back(cmd);
+ m_undoState = int(m_history.size());
}
/*!
@@ -1563,6 +1563,7 @@ void QWidgetLineControl::processShortcutOverrideEvent(QKeyEvent *ke)
if (ke == QKeySequence::Copy
|| ke == QKeySequence::MoveToNextWord
|| ke == QKeySequence::MoveToPreviousWord
+ || ke == QKeySequence::MoveToStartOfLine
|| ke == QKeySequence::MoveToEndOfLine
|| ke == QKeySequence::MoveToStartOfDocument
|| ke == QKeySequence::MoveToEndOfDocument
@@ -1957,7 +1958,7 @@ bool QWidgetLineControl::isRedoAvailable() const
// Same as with undo. Disabled for password modes.
return !m_readOnly
&& m_echoMode == QLineEdit::Normal
- && m_undoState < m_history.size();
+ && m_undoState < int(m_history.size());
}
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index 34d19d1e77..5e52e29a51 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -67,6 +67,8 @@
#include "qplatformdefs.h"
+#include <vector>
+
#ifdef DrawText
# undef DrawText
#endif
@@ -469,7 +471,6 @@ private:
// undo/redo handling
enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection };
struct Command {
- inline Command() {}
inline Command(CommandType t, int p, QChar c, int ss, int se) : type(t),uc(c),pos(p),selStart(ss),selEnd(se) {}
uint type : 4;
QChar uc;
@@ -477,7 +478,7 @@ private:
};
int m_modifiedState;
int m_undoState;
- QVector<Command> m_history;
+ std::vector<Command> m_history;
void addCommand(const Command& cmd);
inline void separate() { m_separator = true; }