summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qcombobox.cpp21
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp3
-rw-r--r--src/widgets/widgets/qlineedit.cpp3
-rw-r--r--src/widgets/widgets/qmenu.cpp46
-rw-r--r--src/widgets/widgets/qmenubar.cpp6
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol.cpp49
-rw-r--r--src/widgets/widgets/qwidgetlinecontrol_p.h3
-rw-r--r--src/widgets/widgets/qwidgetresizehandler.cpp2
-rw-r--r--src/widgets/widgets/qwidgettextcontrol.cpp4
-rw-r--r--src/widgets/widgets/qworkspace.cpp11
10 files changed, 75 insertions, 73 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index d6af8d6044..c5f5d6e6e1 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -43,6 +43,7 @@
#ifndef QT_NO_COMBOBOX
#include <qstylepainter.h>
+#include <qplatformtheme_qpa.h>
#include <qlineedit.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
@@ -57,15 +58,13 @@
#include <qtreeview.h>
#include <qheaderview.h>
#include <qmath.h>
+#include <private/qguiapplication_p.h>
#include <private/qapplication_p.h>
#include <private/qcombobox_p.h>
#include <private/qabstractitemmodel_p.h>
#include <private/qabstractscrollarea_p.h>
#include <private/qsoftkeymanager_p.h>
#include <qdebug.h>
-#ifdef Q_WS_X11
-#include <private/qt_x11_p.h>
-#endif
#if defined(Q_WS_MAC) && !defined(QT_NO_EFFECTS) && !defined(QT_NO_STYLE_MAC)
#include <private/qcore_mac_p.h>
#include <QMacStyle>
@@ -219,16 +218,12 @@ void QComboBoxPrivate::_q_modelDestroyed()
//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't
QRect QComboBoxPrivate::popupGeometry(int screen) const
{
-#ifdef Q_WS_WIN
- return QApplication::desktop()->screenGeometry(screen);
-#elif defined Q_WS_X11
- if (X11->desktopEnvironment == DE_KDE)
- return QApplication::desktop()->screenGeometry(screen);
- else
- return QApplication::desktop()->availableGeometry(screen);
-#else
- return QApplication::desktop()->availableGeometry(screen);
-#endif
+ bool useFullScreenForPopupMenu = false;
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
+ useFullScreenForPopupMenu = theme->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool();
+ return useFullScreenForPopupMenu ?
+ QApplication::desktop()->screenGeometry(screen) :
+ QApplication::desktop()->availableGeometry(screen);
}
bool QComboBoxPrivate::updateHoverControl(const QPoint &pos)
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index df083ccbfe..a07ab73ad0 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -3321,7 +3321,8 @@ void QDockAreaLayout::keepSize(QDockWidget *w)
void QDockAreaLayout::styleChangedEvent()
{
sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow);
- fitLayout();
+ if (isValid())
+ fitLayout();
}
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 77d6f5422a..7118881ef2 100644
--- a/src/widgets/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
@@ -75,7 +75,8 @@
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include "qkeysequence.h"
-#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1Char('\t') + QString(QKeySequence(k)) : QString())
+#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \
+ QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
#else
#define ACCEL_KEY(k) QString()
#endif
diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index e619cdf4fc..7ebfdbecae 100644
--- a/src/widgets/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
@@ -70,10 +70,8 @@
#include <private/qpushbutton_p.h>
#include <private/qaction_p.h>
#include <private/qsoftkeymanager_p.h>
-
-#ifdef Q_WS_X11
-# include <private/qt_x11_p.h>
-#endif
+#include <private/qguiapplication_p.h>
+#include <qplatformtheme_qpa.h>
QT_BEGIN_NAMESPACE
@@ -177,31 +175,23 @@ int QMenuPrivate::scrollerHeight() const
//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't
QRect QMenuPrivate::popupGeometry(const QWidget *widget) const
{
-#ifdef Q_WS_WIN
- return QApplication::desktop()->screenGeometry(widget);
-#elif defined Q_WS_X11
- if (X11->desktopEnvironment == DE_KDE)
+ if (QGuiApplicationPrivate::platformTheme() &&
+ QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
return QApplication::desktop()->screenGeometry(widget);
- else
- return QApplication::desktop()->availableGeometry(widget);
-#else
+ } else {
return QApplication::desktop()->availableGeometry(widget);
-#endif
+ }
}
//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't
QRect QMenuPrivate::popupGeometry(int screen) const
{
-#ifdef Q_WS_WIN
- return QApplication::desktop()->screenGeometry(screen);
-#elif defined Q_WS_X11
- if (X11->desktopEnvironment == DE_KDE)
+ if (QGuiApplicationPrivate::platformTheme() &&
+ QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::UseFullScreenForPopupMenu).toBool()) {
return QApplication::desktop()->screenGeometry(screen);
- else
- return QApplication::desktop()->availableGeometry(screen);
-#else
+ } else {
return QApplication::desktop()->availableGeometry(screen);
-#endif
+ }
}
QList<QPointer<QWidget> > QMenuPrivate::calcCausedStack() const
@@ -305,7 +295,7 @@ void QMenuPrivate::updateActionRects(const QRect &screen) const
} else {
QKeySequence seq = action->shortcut();
if (!seq.isEmpty())
- tabWidth = qMax(int(tabWidth), qfm.width(seq));
+ tabWidth = qMax(int(tabWidth), qfm.width(seq.toString(QKeySequence::NativeText)));
#endif
}
sz.setWidth(fm.boundingRect(QRect(), Qt::TextSingleLine | Qt::TextShowMnemonic, s).width());
@@ -1197,7 +1187,7 @@ void QMenu::initStyleOption(QStyleOptionMenuItem *option, const QAction *action)
if (textAndAccel.indexOf(QLatin1Char('\t')) == -1) {
QKeySequence seq = action->shortcut();
if (!seq.isEmpty())
- textAndAccel += QLatin1Char('\t') + QString(seq);
+ textAndAccel += QLatin1Char('\t') + seq.toString(QKeySequence::NativeText);
}
#endif
option->text = textAndAccel;
@@ -1908,13 +1898,21 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if ((pos.x() + menuSize.width() > parentActionRect.left() - subMenuOffset)
&& (pos.x() < parentActionRect.right()))
{
+ pos.rx() = parentActionRect.left() - menuSize.width();
+ if (pos.x() < screen.x())
pos.rx() = parentActionRect.right();
+ if (pos.x() + menuSize.width() > screen.x() + screen.width())
+ pos.rx() = screen.x();
}
} else {
if ((pos.x() < parentActionRect.right() + subMenuOffset)
&& (pos.x() + menuSize.width() > parentActionRect.left()))
{
+ pos.rx() = parentActionRect.right();
+ if (pos.x() + menuSize.width() > screen.x() + screen.width())
pos.rx() = parentActionRect.left() - menuSize.width();
+ if (pos.x() < screen.x())
+ pos.rx() = screen.x() + screen.width() - menuSize.width();
}
}
}
@@ -2261,7 +2259,7 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e)
if (action && action == d->currentAction) {
if (!action->menu()){
-#if defined(Q_WS_WIN)
+#if defined(Q_OS_WIN)
//On Windows only context menus can be activated with the right button
if (e->button() == Qt::LeftButton || d->topCausedWidget() == 0)
#endif
@@ -3000,7 +2998,7 @@ void QMenu::internalDelayedPopup()
*/
void QMenu::setNoReplayFor(QWidget *noReplayFor)
{
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
d_func()->noReplayFor = noReplayFor;
#else
Q_UNUSED(noReplayFor);
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index d797a4e315..16e486e77f 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -1075,7 +1075,7 @@ void QMenuBar::mousePressEvent(QMouseEvent *e)
d->activeMenu = 0;
menu->hide();
}
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
if((d->closePopupMode = style()->styleHint(QStyle::SH_MenuBar_DismissOnSecondClick)))
update(d->actionRect(action));
#endif
@@ -1845,15 +1845,12 @@ void QMenuBar::setDefaultAction(QAction *act)
Q_D(QMenuBar);
if (d->defaultAction == act)
return;
-#ifdef Q_OS_WINCE
if (qt_wince_is_mobile())
if (d->defaultAction) {
disconnect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction()));
disconnect(d->defaultAction, SIGNAL(destroyed()), this, SLOT(_q_updateDefaultAction()));
}
-#endif
d->defaultAction = act;
-#ifdef Q_OS_WINCE
if (qt_wince_is_mobile())
if (d->defaultAction) {
connect(d->defaultAction, SIGNAL(changed()), this, SLOT(_q_updateDefaultAction()));
@@ -1862,7 +1859,6 @@ void QMenuBar::setDefaultAction(QAction *act)
if (d->wce_menubar) {
d->wce_menubar->rebuild();
}
-#endif
}
/*!
diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp
index 2f5793bcba..73c3d14f9b 100644
--- a/src/widgets/widgets/qwidgetlinecontrol.cpp
+++ b/src/widgets/widgets/qwidgetlinecontrol.cpp
@@ -45,6 +45,8 @@
#include "qabstractitemview.h"
#include "qclipboard.h"
+#include <private/qguiapplication_p.h>
+#include <qplatformtheme_qpa.h>
#ifndef QT_NO_ACCESSIBILITY
#include "qaccessible.h"
#endif
@@ -374,6 +376,14 @@ void QWidgetLineControl::init(const QString &txt)
m_text = txt;
updateDisplayText();
m_cursor = m_text.length();
+ if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
+ m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt();
+ // Generalize for X11
+ if (m_keyboardScheme == QPlatformTheme::KdeKeyboardScheme
+ || m_keyboardScheme == QPlatformTheme::GnomeKeyboardScheme
+ || m_keyboardScheme == QPlatformTheme::CdeKeyboardScheme) {
+ m_keyboardScheme = QPlatformTheme::X11KeyboardScheme;
+ }
}
/*!
@@ -1630,10 +1640,11 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
else if (event == QKeySequence::Paste) {
if (!isReadOnly()) {
QClipboard::Mode mode = QClipboard::Clipboard;
-#ifdef Q_WS_X11
- if (event->modifiers() == (Qt::CTRL | Qt::SHIFT) && event->key() == Qt::Key_Insert)
+ if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme
+ && event->modifiers() == (Qt::CTRL | Qt::SHIFT)
+ && event->key() == Qt::Key_Insert) {
mode = QClipboard::Selection;
-#endif
+ }
paste(mode);
}
}
@@ -1664,12 +1675,14 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
end(1);
}
else if (event == QKeySequence::MoveToNextChar) {
-#if !defined(Q_WS_WIN) || defined(QT_NO_COMPLETER)
- if (hasSelectedText()) {
+#if defined(QT_NO_COMPLETER)
+ const bool inlineCompletion = false;
#else
- if (hasSelectedText() && m_completer
- && m_completer->completionMode() == QCompleter::InlineCompletion) {
+ const bool inlineCompletion = m_completer && m_completer->completionMode() == QCompleter::InlineCompletion;
#endif
+ if (hasSelectedText()
+ && (m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme
+ || inlineCompletion)) {
moveCursor(selectionEnd(), false);
} else {
cursorForward(0, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1));
@@ -1679,12 +1692,14 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
cursorForward(1, visual ? 1 : (layoutDirection() == Qt::LeftToRight ? 1 : -1));
}
else if (event == QKeySequence::MoveToPreviousChar) {
-#if !defined(Q_WS_WIN) || defined(QT_NO_COMPLETER)
- if (hasSelectedText()) {
+#if defined(QT_NO_COMPLETER)
+ const bool inlineCompletion = false;
#else
- if (hasSelectedText() && m_completer
- && m_completer->completionMode() == QCompleter::InlineCompletion) {
+ const bool inlineCompletion = m_completer && m_completer->completionMode() == QCompleter::InlineCompletion;
#endif
+ if (hasSelectedText()
+ && (m_keyboardScheme != QPlatformTheme::WindowsKeyboardScheme
+ || inlineCompletion)) {
moveCursor(selectionStart(), false);
} else {
cursorForward(0, visual ? -1 : (layoutDirection() == Qt::LeftToRight ? -1 : 1));
@@ -1737,8 +1752,8 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
#endif // QT_NO_SHORTCUT
else {
bool handled = false;
-#ifdef Q_WS_MAC
- if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down) {
+ if (m_keyboardScheme == QPlatformTheme::MacKeyboardScheme
+ && (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)) {
Qt::KeyboardModifiers myModifiers = (event->modifiers() & ~Qt::KeypadModifier);
if (myModifiers & Qt::ShiftModifier) {
if (myModifiers == (Qt::ControlModifier|Qt::ShiftModifier)
@@ -1756,7 +1771,6 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
}
handled = true;
}
-#endif
if (event->modifiers() & Qt::ControlModifier) {
switch (event->key()) {
case Qt::Key_Backspace:
@@ -1771,13 +1785,13 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
complete(event->key());
break;
#endif
-#if defined(Q_WS_X11)
case Qt::Key_E:
- end(0);
+ if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme)
+ end(0);
break;
case Qt::Key_U:
- if (!isReadOnly()) {
+ if (m_keyboardScheme == QPlatformTheme::X11KeyboardScheme && !isReadOnly()) {
setSelection(0, text().size());
#ifndef QT_NO_CLIPBOARD
copy();
@@ -1785,7 +1799,6 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event)
del();
}
break;
-#endif
default:
if (!handled)
unknown = true;
diff --git a/src/widgets/widgets/qwidgetlinecontrol_p.h b/src/widgets/widgets/qwidgetlinecontrol_p.h
index a0191188a7..72f25e9068 100644
--- a/src/widgets/widgets/qwidgetlinecontrol_p.h
+++ b/src/widgets/widgets/qwidgetlinecontrol_p.h
@@ -100,6 +100,7 @@ public:
, m_threadChecks(false)
, m_textLayoutThread(0)
#endif
+ , m_keyboardScheme(0)
{
init(txt);
}
@@ -527,6 +528,8 @@ private Q_SLOTS:
void _q_clipboardChanged();
void _q_deleteSelected();
+private:
+ int m_keyboardScheme;
};
QT_END_NAMESPACE
diff --git a/src/widgets/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp
index aba0ca58c6..5380fb798c 100644
--- a/src/widgets/widgets/qwidgetresizehandler.cpp
+++ b/src/widgets/widgets/qwidgetresizehandler.cpp
@@ -326,8 +326,6 @@ void QWidgetResizeHandler::mouseMoveEvent(QMouseEvent *e)
else
widget->setGeometry(geom);
}
-
- QApplication::syncX();
}
void QWidgetResizeHandler::setMouseCursor(MousePosition m)
diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp
index a2c7915a5e..9eeffc1231 100644
--- a/src/widgets/widgets/qwidgettextcontrol.cpp
+++ b/src/widgets/widgets/qwidgettextcontrol.cpp
@@ -84,7 +84,9 @@
#include "private/qapplication_p.h"
#include "private/qshortcutmap_p.h"
#include <qkeysequence.h>
-#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1Char('\t') + QString(QKeySequence(k)) : QString())
+#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? \
+ QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
+
#else
#define ACCEL_KEY(k) QString()
#endif
diff --git a/src/widgets/widgets/qworkspace.cpp b/src/widgets/widgets/qworkspace.cpp
index be3f7836d5..5cc8e363f1 100644
--- a/src/widgets/widgets/qworkspace.cpp
+++ b/src/widgets/widgets/qworkspace.cpp
@@ -290,9 +290,6 @@ public:
QWorkspaceTitleBarPrivate()
:
lastControl(QStyle::SC_None),
-#ifndef QT_NO_TOOLTIP
- toolTip(0),
-#endif
act(0), window(0), movable(1), pressed(0), autoraise(0), moving(0)
{
}
@@ -301,9 +298,6 @@ public:
QStyle::SubControl buttonDown;
QStyle::SubControl lastControl;
QPoint moveOffset;
-#ifndef QT_NO_TOOLTIP
- QToolTip *toolTip;
-#endif
bool act :1;
QPointer<QWidget> window;
bool movable :1;
@@ -1085,7 +1079,8 @@ QWorkspacePrivate::init()
actions[QWorkspacePrivate::CloseAct] = new QAction(QIcon(q->style()->standardPixmap(QStyle::SP_TitleBarCloseButton, 0, q)),
QWorkspace::tr("&Close")
#ifndef QT_NO_SHORTCUT
- +QLatin1Char('\t')+(QString)QKeySequence(Qt::CTRL+Qt::Key_F4)
+ + QLatin1Char('\t')
+ + QKeySequence(Qt::CTRL+Qt::Key_F4).toString(QKeySequence::NativeText)
#endif
,q);
QObject::connect(actions[QWorkspacePrivate::CloseAct], SIGNAL(triggered()), q, SLOT(closeActiveWindow()));
@@ -3210,7 +3205,7 @@ QRect QWorkspacePrivate::updateWorkspace()
QWorkspaceChild *child = *it;
++it;
if (!child->isHidden())
- r = r.unite(child->geometry());
+ r = r.united(child->geometry());
}
vbar->blockSignals(true);
hbar->blockSignals(true);