diff options
author | Rohan McGovern <rohan.mcgovern@nokia.com> | 2012-02-29 09:18:59 +1000 |
---|---|---|
committer | Rohan McGovern <rohan.mcgovern@nokia.com> | 2012-02-29 09:23:14 +1000 |
commit | 98dd1781d9256f68025d2a2db408f4f5947f3214 (patch) | |
tree | dbe1424abd90014edb5546c920ca585ed62b46e3 /src/widgets | |
parent | 6c1bdc1854a7700c2b3a345b95f6a2fdca84037d (diff) | |
parent | fa1b9070af66edb81b2a3735c1951f78b22bd666 (diff) |
Merge master -> api_changes
Includes fixes for tst_qfiledialog2, tst_qtextedit autotests on mac.
Change-Id: I49cac26894d31291a8339ccc1eb80b6a940f0827
Diffstat (limited to 'src/widgets')
35 files changed, 198 insertions, 812 deletions
diff --git a/src/widgets/Qt5WidgetsConfigExtras.cmake.in b/src/widgets/Qt5WidgetsConfigExtras.cmake.in index baf34b2fbc..93d3c6998a 100644 --- a/src/widgets/Qt5WidgetsConfigExtras.cmake.in +++ b/src/widgets/Qt5WidgetsConfigExtras.cmake.in @@ -1,5 +1,8 @@ get_filename_component(_qt5_widgets_install_prefix ${CMAKE_CURRENT_LIST_DIR}/$${CMAKE_RELATIVE_INSTALL_DIR} ABSOLUTE) -# Not Required by default: -set(QT_UIC_EXECUTABLE \"${_qt5_widgets_install_prefix}/$$CMAKE_BIN_DIR/uic$$CMAKE_BIN_SUFFIX\") +!!IF isEmpty(CMAKE_BIN_DIR_IS_ABSOLUTE) +set(QT_UIC_EXECUTABLE \"${_qt5_widgets_install_prefix}/$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\") +!!ELSE +set(QT_UIC_EXECUTABLE \"$${CMAKE_BIN_DIR}uic$$CMAKE_BIN_SUFFIX\") +!!ENDIF diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index feac42780d..790b51102c 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -128,7 +128,7 @@ QString Q_WIDGETS_EXPORT qt_accHotKey(const QString &text) } if (ac.isNull()) return QString(); - return (QString)QKeySequence(Qt::ALT) + ac.toUpper(); + return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + ac.toUpper(); #else Q_UNUSED(text); return QString(); diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 49b4dd3a23..5ffb5466d6 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -55,6 +55,7 @@ #include "qplatformtheme_qpa.h" #include "private/qdialog_p.h" #include "private/qguiapplication_p.h" +#include "qplatformtheme_qpa.h" #ifndef QT_NO_ACCESSIBILITY #include "qaccessible.h" #endif @@ -790,11 +791,10 @@ void QDialog::showEvent(QShowEvent *event) /*! \internal */ void QDialog::adjustPosition(QWidget* w) { -#ifdef Q_WS_X11 - // if the WM advertises that it will place the windows properly for us, let it do it :) - if (X11->isSupportedByWM(ATOM(_NET_WM_FULL_PLACEMENT))) - return; -#endif + + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + if (theme->themeHint(QPlatformTheme::WindowAutoPlacement).toBool()) + return; QPoint p(0, 0); int extraw = 0, extrah = 0, scrn = 0; if (w) diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 7ea4302a56..0211b2512c 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -1926,12 +1926,10 @@ void QFileSystemModelPrivate::init() q, SIGNAL(directoryLoaded(QString))); q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection); - QHash<int, QByteArray> roles = q->roleNames(); - roles.insertMulti(QFileSystemModel::FileIconRole, "fileIcon"); // == Qt::decoration - roles.insert(QFileSystemModel::FilePathRole, "filePath"); - roles.insert(QFileSystemModel::FileNameRole, "fileName"); - roles.insert(QFileSystemModel::FilePermissions, "filePermissions"); - q->setRoleNames(roles); + roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration + roleNames.insert(QFileSystemModel::FilePathRole, QByteArrayLiteral("filePath")); + roleNames.insert(QFileSystemModel::FileNameRole, QByteArrayLiteral("fileName")); + roleNames.insert(QFileSystemModel::FilePermissions, QByteArrayLiteral("filePermissions")); } /*! diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 634e911cd1..a737584e3f 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1365,13 +1365,13 @@ void QMessageBox::keyPressEvent(QKeyEvent *e) #ifndef QT_NO_SHORTCUT if (!(e->modifiers() & Qt::AltModifier)) { - int key = e->key() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL); + int key = e->key() & ~Qt::MODIFIER_MASK; if (key) { const QList<QAbstractButton *> buttons = d->buttonBox->buttons(); for (int i = 0; i < buttons.count(); ++i) { QAbstractButton *pb = buttons.at(i); - int acc = pb->shortcut() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL); - if (acc == key) { + QKeySequence shortcut = pb->shortcut(); + if (!shortcut.isEmpty() && key == (shortcut[0] & ~Qt::MODIFIER_MASK)) { pb->animateClick(); return; } diff --git a/src/widgets/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp index 5dec62acc2..6758aeb337 100644 --- a/src/widgets/itemviews/qcolumnview.cpp +++ b/src/widgets/itemviews/qcolumnview.cpp @@ -481,7 +481,7 @@ QRegion QColumnView::visualRegionForSelection(const QItemSelection &selection) c QRegion firstRegion = visualRect(firstIdx); QRegion lastRegion = visualRect(lastIdx); - return firstRegion.unite(lastRegion); + return firstRegion.united(lastRegion); } /*! diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 67a16a836d..ee097e5c41 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -1169,11 +1169,9 @@ void QDirModelPrivate::init() root.parent = 0; root.info = QFileInfo(); clear(&root); - QHash<int, QByteArray> roles = q->roleNames(); - roles.insertMulti(QDirModel::FileIconRole, "fileIcon"); // == Qt::decoration - roles.insert(QDirModel::FilePathRole, "filePath"); - roles.insert(QDirModel::FileNameRole, "fileName"); - q->setRoleNames(roles); + roleNames.insertMulti(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration + roleNames.insert(QDirModel::FilePathRole, QByteArrayLiteral("filePath")); + roleNames.insert(QDirModel::FileNameRole, QByteArrayLiteral("fileName")); } QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) const diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 6a1f949258..5d2aceaade 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -1802,9 +1802,8 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent, if (logicalFirst == logicalLast) { // Remove just one index. int l = logicalFirst; int visual = visualIndices.at(l); + Q_ASSERT(sectionCount == logicalIndices.count()); for (int v = 0; v < sectionCount; ++v) { - if (v >= logicalIndices.count()) - continue; // the section doesn't exist if (v > visual) { int logical = logicalIndices.at(v); --(visualIndices[logical]); @@ -2434,20 +2433,15 @@ bool QHeaderView::viewportEvent(QEvent *e) } return true; } #endif // QT_NO_STATUSTIP - case QEvent::Hide: { - d->invalidateCachedSizeHint(); + case QEvent::Hide: + case QEvent::Show: + case QEvent::FontChange: + case QEvent::StyleChange:{ QAbstractScrollArea *parent = qobject_cast<QAbstractScrollArea *>(parentWidget()); if (parent && parent->isVisible()) // Only resize if we have a visible parent resizeSections(); emit geometriesChanged(); break;} - case QEvent::Show: - case QEvent::FontChange: - case QEvent::StyleChange: - d->invalidateCachedSizeHint(); - resizeSections(); - emit geometriesChanged(); - break; case QEvent::ContextMenu: { d->state = QHeaderViewPrivate::NoState; d->pressed = d->section = d->target = -1; @@ -3391,11 +3385,11 @@ int QHeaderViewPrivate::viewSectionSizeHint(int logical) const int QHeaderViewPrivate::adjustedVisualIndex(int visualIndex) const { - if (hiddenSectionSize.count() > 0) { + if (!sectionHidden.isEmpty()) { int adjustedVisualIndex = visualIndex; int currentVisualIndex = 0; for (int i = 0; i < sectionSpans.count(); ++i) { - if (sectionSpans.at(i).size == 0) + if (sectionHidden.testBit(i)) ++adjustedVisualIndex; else ++currentVisualIndex; diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 97fbea6c3d..bb39546ec8 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -75,6 +75,7 @@ QListModel::~QListModel() void QListModel::clear() { + beginResetModel(); for (int i = 0; i < items.count(); ++i) { if (items.at(i)) { items.at(i)->d->theid = -1; @@ -83,7 +84,7 @@ void QListModel::clear() } } items.clear(); - reset(); + endResetModel(); } QListWidgetItem *QListModel::at(int row) const diff --git a/src/widgets/itemviews/qstandarditemmodel.cpp b/src/widgets/itemviews/qstandarditemmodel.cpp index 112b533f4f..5616d76c4a 100644 --- a/src/widgets/itemviews/qstandarditemmodel.cpp +++ b/src/widgets/itemviews/qstandarditemmodel.cpp @@ -2097,13 +2097,14 @@ void QStandardItemModel::setItemRoleNames(const QHash<int,QByteArray> &roleNames void QStandardItemModel::clear() { Q_D(QStandardItemModel); + beginResetModel(); d->root.reset(new QStandardItem); d->root->d_func()->setModel(this); qDeleteAll(d->columnHeaderItems); d->columnHeaderItems.clear(); qDeleteAll(d->rowHeaderItems); d->rowHeaderItems.clear(); - reset(); + endResetModel(); } /*! diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index 82055ad11e..5932f20327 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -755,6 +755,7 @@ void QTableModel::clear() void QTableModel::clearContents() { + beginResetModel(); for (int i = 0; i < tableItems.count(); ++i) { if (tableItems.at(i)) { tableItems.at(i)->view = 0; @@ -762,7 +763,7 @@ void QTableModel::clearContents() tableItems[i] = 0; } } - reset(); + endResetModel(); } void QTableModel::itemChanged(QTableWidgetItem *item) diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index ca8b9c4e09..cec709a816 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -160,6 +160,7 @@ QTreeModel::~QTreeModel() void QTreeModel::clear() { SkipSorting skipSorting(this); + beginResetModel(); for (int i = 0; i < rootItem->childCount(); ++i) { QTreeWidgetItem *item = rootItem->children.at(i); item->par = 0; @@ -168,7 +169,7 @@ void QTreeModel::clear() } rootItem->children.clear(); sortPendingTimer.stop(); - reset(); + endResetModel(); } /*! diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index d3d63a8c7b..f450d13a39 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -1119,7 +1119,7 @@ QAction::event(QEvent *e) "QAction::event", "Received shortcut event from incorrect shortcut"); if (se->isAmbiguous()) - qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", QString(se->key()).toLatin1().constData()); + qWarning("QAction::eventFilter: Ambiguous shortcut overload: %s", se->key().toString(QKeySequence::NativeText).toLatin1().constData()); else activate(Trigger); return true; diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index f7153a0f32..c350223278 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -76,10 +76,6 @@ #include "private/qkeymapper_p.h" -#ifdef Q_WS_X11 -#include <private/qt_x11_p.h> -#endif - #include <qthread.h> #include <private/qthread_p.h> @@ -87,10 +83,6 @@ #include <stdlib.h> -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) -#include <link.h> -#endif - #include "qapplication_p.h" #include "private/qevent_p.h" #include "qwidget_p.h" @@ -114,10 +106,6 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp #include "qdatetime.h" -#ifdef Q_WS_MAC -#include <private/qt_cocoa_helpers_mac_p.h> -#endif - //#define ALIEN_DEBUG static void initResources() @@ -140,6 +128,21 @@ Q_CORE_EXPORT void qt_call_post_routines(); QApplicationPrivate *QApplicationPrivate::self = 0; +static void initSystemPalette() +{ + if (!QApplicationPrivate::sys_pal) + if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) + QApplicationPrivate::setSystemPalette(*themePalette); + if (!QApplicationPrivate::sys_pal && QApplicationPrivate::app_style) + QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); +} + +static void clearSystemPalette() +{ + delete QApplicationPrivate::sys_pal; + QApplicationPrivate::sys_pal = 0; +} + #ifdef Q_OS_WINCE int QApplicationPrivate::autoMaximizeThreshold = -1; bool QApplicationPrivate::autoSipEnabled = false; @@ -156,24 +159,11 @@ QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::T is_session_restored = false; #endif -#if defined(Q_WS_QWS) && !defined(QT_NO_DIRECTPAINTER) - directPainters = 0; -#endif - #ifndef QT_NO_GESTURES gestureManager = 0; gestureWidget = 0; #endif // QT_NO_GESTURES -#if defined(Q_WS_X11) || defined(Q_WS_WIN) - move_cursor = 0; - copy_cursor = 0; - link_cursor = 0; -#endif -#if defined(Q_WS_WIN) - ignore_cursor = 0; -#endif - if (!self) self = this; } @@ -191,16 +181,14 @@ QApplicationPrivate::~QApplicationPrivate() \inmodule QtWidgets - QApplication contains the main event loop, where all events from the window - system and other sources are processed and dispatched. It also handles the - application's initialization, finalization, and provides session - management. In addition, QApplication handles most of the system-wide and - application-wide settings. + QApplication specializes QGuiApplication with some functionality needed + for QWidget-based applications. It handles widget specific initialization, + finalization, and provides session management. For any GUI application using Qt, there is precisely \bold one QApplication object, no matter whether the application has 0, 1, 2 or more windows at - any given time. For non-GUI Qt applications, use QCoreApplication instead, - as it does not depend on the \l QtGui library. + any given time. For non-QWidget based Qt applications, use QGuiApplication instead, + as it does not depend on the \l QtWidgets library. The QApplication object is accessible through the instance() function that returns a pointer equivalent to the global qApp pointer. @@ -241,9 +229,6 @@ QApplicationPrivate::~QApplicationPrivate() \o It manages the application's mouse cursor handling, see setOverrideCursor() - \o On the X window system, it provides functions to flush and sync - the communication stream, see flushX() and syncX(). - \o It provides support for sophisticated \l{Session Management} {session management}. This makes it possible for applications to terminate gracefully when the user logs out, to cancel a @@ -291,12 +276,7 @@ QApplicationPrivate::~QApplicationPrivate() sendPostedEvents(), removePostedEvents(), hasPendingEvents(), - notify(), - macEventFilter(), - qwsEventFilter(), - x11EventFilter(), - x11ProcessEvent(), - winEventFilter(). + notify(). \row \o GUI Styles @@ -306,8 +286,7 @@ QApplicationPrivate::~QApplicationPrivate() \row \o Color usage \o colorSpec(), - setColorSpec(), - qwsSetCustomColors(). + setColorSpec(). \row \o Text handling @@ -334,11 +313,6 @@ QApplicationPrivate::~QApplicationPrivate() restoreOverrideCursor(). \row - \o X Window System synchronization - \o flushX(), - syncX(). - - \row \o Session management \o isSessionRestored(), sessionId(), @@ -391,9 +365,6 @@ QApplicationPrivate::~QApplicationPrivate() */ void qt_init(QApplicationPrivate *priv, int type -#ifdef Q_WS_X11 - , Display *display = 0, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0 -#endif ); void qt_cleanup(); @@ -409,6 +380,7 @@ QString QApplicationPrivate::styleSheet; // default application styles QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0; int QApplicationPrivate::app_cspec = QApplication::NormalColor; + QPalette *QApplicationPrivate::sys_pal = 0; // default system palette QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer @@ -560,19 +532,6 @@ void QApplicationPrivate::process_cmdline() \note \a argc and \a argv might be changed as Qt removes command line arguments that it recognizes. - Qt debugging options (not available if Qt was compiled without the QT_DEBUG - flag defined): - \list - \o -nograb, tells Qt that it must never grab the mouse or the - keyboard. - \o -dograb (only under X11), running under a debugger can cause an - implicit -nograb, use -dograb to override. - \o -sync (only under X11), switches to synchronous mode for - debugging. - \endlist - - See \l{Debugging Techniques} for a more detailed explanation. - All Qt programs automatically support the following command line options: \list \o -style= \e style, sets the application GUI style. Possible values @@ -598,45 +557,6 @@ void QApplicationPrivate::process_cmdline() and will make the application wait until a debugger connects to it. \endlist - The X11 version of Qt supports some traditional X11 command line options: - \list - \o -display \e display, sets the X display (default is $DISPLAY). - \o -geometry \e geometry, sets the client geometry of the first window - that is shown. - \o -fn or \c -font \e font, defines the application font. The font - should be specified using an X logical font description. Note that - this option is ignored when Qt is built with fontconfig support enabled. - \o -bg or \c -background \e color, sets the default background color - and an application palette (light and dark shades are calculated). - \o -fg or \c -foreground \e color, sets the default foreground color. - \o -btn or \c -button \e color, sets the default button color. - \o -name \e name, sets the application name. - \o -title \e title, sets the application title. - \o -visual \c TrueColor, forces the application to use a TrueColor - visual on an 8-bit display. - \o -ncols \e count, limits the number of colors allocated in the color - cube on an 8-bit display, if the application is using the - QApplication::ManyColor color specification. If \e count is 216 - then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green, - and 6 of blue); for other values, a cube approximately proportional - to a 2x3x1 cube is used. - \o -cmap, causes the application to install a private color map on an - 8-bit display. - \o -im, sets the input method server (equivalent to setting the - XMODIFIERS environment variable) - \o -inputstyle, defines how the input is inserted into the given - widget, e.g., \c onTheSpot makes the input appear directly in the - widget, while \c overTheSpot makes the input appear in a box - floating over the widget and is not inserted until the editing is - done. - \endlist - - \section1 X11 Notes - - If QApplication fails to open the X11 display, it will terminate - the process. This behavior is consistent with most X11 - applications. - \sa arguments() */ @@ -651,26 +571,18 @@ QApplication::QApplication(int &argc, char **argv, int _internal) /*! Constructs an application object with \a argc command line arguments in - \a argv. If \a GUIenabled is true, a GUI application is constructed, - otherwise a non-GUI (console) application is created. + \a argv. \warning The data referred to by \a argc and \a argv must stay valid for the entire lifetime of the QApplication object. In addition, \a argc must be greater than zero and \a argv must contain at least one valid character string. - Set \a GUIenabled to false for programs without a graphical user interface - that should be able to run without a window system. - - On X11, the window system is initialized if \a GUIenabled is true. If - \a GUIenabled is false, the application does not connect to the X server. - On Windows and Mac OS, currently the window system is always initialized, - regardless of the value of GUIenabled. This may change in future versions - of Qt. - The following example shows how to create an application that uses a graphical interface when available. + \obsolete + \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0 */ @@ -692,10 +604,6 @@ QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _intern the entire lifetime of the QApplication object. In addition, \a argc must be greater than zero and \a argv must contain at least one valid character string. - - With Qt for Embedded Linux, passing QApplication::GuiServer for \a type - makes this application the server (equivalent to running with the - \c -qws option). */ QApplication::QApplication(int &argc, char **argv, Type type) : QGuiApplication(*new QApplicationPrivate(argc, argv, type, 0x040000)) @@ -705,22 +613,10 @@ QApplication::QApplication(int &argc, char **argv, Type type , int _internal) : QGuiApplication(*new QApplicationPrivate(argc, argv, type, _internal)) { Q_D(QApplication); d->construct(); } -#if defined(Q_WS_X11) && !defined(QT_NO_EGL) -static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data) -{ - const char *name = static_cast<const char *>(data); - return strstr(info->dlpi_name, name) != 0; -} -#endif - /*! \internal */ -void QApplicationPrivate::construct( -#ifdef Q_WS_X11 - Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap -#endif - ) +void QApplicationPrivate::construct() { initResources(); @@ -728,11 +624,7 @@ void QApplicationPrivate::construct( process_cmdline(); // Must be called before initialize() - qt_init(this, application_type -#ifdef Q_WS_X11 - , dpy, visual, cmap -#endif - ); + qt_init(this, application_type); initialize(); eventDispatcher->startingUp(); @@ -759,82 +651,6 @@ void QApplicationPrivate::construct( #endif } -#if defined(Q_WS_X11) -// ### a string literal is a cont char* -// ### using it as a char* is wrong and could lead to segfaults -// ### if aargv is modified someday -// ########## make it work with argc == argv == 0 -static int aargc = 1; -static char *aargv[] = { (char*)"unknown", 0 }; - -/*! - \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap) - - Creates an application, given an already open display \a display. If - \a visual and \a colormap are non-zero, the application will use those - values as the default Visual and Colormap contexts. - - \warning Qt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This function is only available on X11. -*/ -QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap) - : QGuiApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, 0x040000)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); -} - -QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) - : QGuiApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, _internal)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); - QApplicationPrivate::app_compile_version = _internal; -} - -/*! - \fn QApplication::QApplication(Display *display, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap) - - Creates an application, given an already open \a display and using \a argc - command line arguments in \a argv. If \a visual and \a colormap are - non-zero, the application will use those values as the default Visual - and Colormap contexts. - - \warning Qt only supports TrueColor visuals at depths higher than 8 - bits-per-pixel. - - This function is only available on X11. -*/ -QApplication::QApplication(Display *dpy, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap) - : QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); -} - -QApplication::QApplication(Display *dpy, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap, int _internal) - : QGuiApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal)) -{ - if (! dpy) - qWarning("QApplication: Invalid Display* argument"); - Q_D(QApplication); - d->construct(dpy, visual, colormap); - QApplicationPrivate::app_compile_version = _internal; -} - -#endif // Q_WS_X11 - #ifndef QT_NO_STATEMACHINE void qRegisterGuiStateMachine(); void qUnregisterGuiStateMachine(); @@ -981,19 +797,9 @@ QApplication::~QApplication() delete qt_desktopWidget; qt_desktopWidget = 0; -#if defined(Q_WS_X11) || defined(Q_WS_WIN) - delete d->move_cursor; d->move_cursor = 0; - delete d->copy_cursor; d->copy_cursor = 0; - delete d->link_cursor; d->link_cursor = 0; -#endif -#if defined(Q_WS_WIN) - delete d->ignore_cursor; d->ignore_cursor = 0; -#endif - delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; - delete QApplicationPrivate::sys_pal; - QApplicationPrivate::sys_pal = 0; + clearSystemPalette(); delete QApplicationPrivate::set_pal; QApplicationPrivate::set_pal = 0; app_palettes()->clear(); @@ -1293,11 +1099,8 @@ QStyle *QApplication::style() // take ownership of the style QApplicationPrivate::app_style->setParent(qApp); - if (!QApplicationPrivate::sys_pal) - if (const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette()) - QApplicationPrivate::setSystemPalette(*themePalette); - if (!QApplicationPrivate::sys_pal) - QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette()); + initSystemPalette(); + if (QApplicationPrivate::set_pal) // repolish set palette with the new style QApplication::setPalette(*QApplicationPrivate::set_pal); @@ -1731,14 +1534,6 @@ QFont QApplication::font(const QWidget *widget) { FontHash *hash = app_fonts(); -#ifdef Q_WS_MAC - // short circuit for small and mini controls - if (widget->testAttribute(Qt::WA_MacSmallSize)) { - return hash->value("QSmallFont"); - } else if (widget->testAttribute(Qt::WA_MacMiniSize)) { - return hash->value("QMiniFont"); - } -#endif if (widget && hash && hash->size()) { QHash<QByteArray, QFont>::ConstIterator it = hash->constFind(widget->metaObject()->className()); @@ -1877,11 +1672,6 @@ void QApplication::setWindowIcon(const QIcon &icon) QApplicationPrivate::app_icon = new QIcon(); *QApplicationPrivate::app_icon = icon; if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { -#ifdef Q_WS_MAC - void qt_mac_set_app_icon(const QPixmap &); //qapplication_mac.cpp - QSize size = QApplicationPrivate::app_icon->actualSize(QSize(128, 128)); - qt_mac_set_app_icon(QApplicationPrivate::app_icon->pixmap(size)); -#endif QEvent e(QEvent::ApplicationWindowIconChange); QWidgetList all = QApplication::allWidgets(); for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { @@ -2094,13 +1884,7 @@ void QApplication::closeAllWindows() void QApplication::aboutQt() { #ifndef QT_NO_MESSAGEBOX - QMessageBox::aboutQt( -#ifdef Q_WS_MAC - 0 -#else - activeWindow() -#endif // Q_WS_MAC - ); + QMessageBox::aboutQt(activeWindow()); #endif // QT_NO_MESSAGEBOX } @@ -2184,9 +1968,6 @@ bool QApplication::event(QEvent *e) } if(e->type() == QEvent::LanguageChange) { -#ifdef Q_WS_MAC - qt_mac_post_retranslateAppMenu(); -#endif QWidgetList list = topLevelWidgets(); for (int i = 0; i < list.size(); ++i) { QWidget *w = list.at(i); @@ -2198,13 +1979,14 @@ bool QApplication::event(QEvent *e) return QGuiApplication::event(e); } -#if !defined(Q_WS_X11) - -// The doc and X implementation of this function is in qapplication_x11.cpp - -void QApplication::syncX() {} // do nothing - -#endif +/*! + Was used to synchronize with the X server in 4.x, here for source compatibility. + \internal + \obsolete +*/ +void QApplication::syncX() +{ +} void QApplicationPrivate::notifyLayoutDirectionChange() { @@ -2298,13 +2080,6 @@ void QApplication::setActiveWindow(QWidget* act) sendSpontaneousEvent(w, &activationChange); } -#ifdef Q_WS_MAC - // In case the user clicked on a child window, we need to - // reestablish the stacking order of the window so - // it pops in front of other child windows in cocoa: - qt_cocoaStackChildWindowOnTopOfOtherChildren(window); -#endif - for(int i = 0; i < toBeDeactivated.size(); ++i) { QWidget *w = toBeDeactivated.at(i); sendSpontaneousEvent(w, &windowDeactivate); @@ -2455,10 +2230,6 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { for (int i = 0; i < leaveList.size(); ++i) { w = leaveList.at(i); if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) { -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) - if (leaveAfterRelease == w) - leaveAfterRelease = 0; -#endif QApplication::sendEvent(w, &leaveEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { @@ -2511,9 +2282,6 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { if (!parentOfLeavingCursor->window()->graphicsProxyWidget()) #endif { -#if defined(Q_WS_X11) - qt_x11_enforce_cursor(parentOfLeavingCursor,true); -#endif if (enter == QApplication::desktop()) { qt_qpa_set_cursor(enter, true); } else { @@ -2535,13 +2303,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) { } else #endif { -#if defined(Q_WS_WIN) - qt_win_set_cursor(cursorWidget, true); -#elif defined(Q_WS_X11) - qt_x11_enforce_cursor(cursorWidget, true); -#else qt_qpa_set_cursor(cursorWidget, true); -#endif } } #endif @@ -2575,12 +2337,6 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) return false; w = w->parentWidget(); } -#ifdef Q_WS_WIN - if ((widget->testAttribute(Qt::WA_WState_Created) || widget->data->winid) - && (modalWidget->testAttribute(Qt::WA_WState_Created) || modalWidget->data->winid) - && IsChild(modalWidget->data->winid, widget->data->winid)) - return false; -#endif } Qt::WindowModality windowModality = modalWidget->windowModality(); @@ -2708,12 +2464,6 @@ bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop) if (QApplication::activePopupWidget()) return true; -#if defined(Q_WS_MAC) - top = QApplicationPrivate::tryModalHelper_sys(top); - if (rettop) - *rettop = top; -#endif - return !isBlockedByModal(widget->window()); } @@ -3607,8 +3357,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e) } while (w) { - QWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->buttons(), - wheel->modifiers(), wheel->orientation()); + QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), + wheel->modifiers()); we.spont = wheel->spontaneous(); res = d->notify_helper(w, w == receiver ? wheel : &we); eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted(); @@ -3726,16 +3476,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) case QEvent::DragEnter: { QWidget* w = static_cast<QWidget *>(receiver); QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e); -#ifdef Q_WS_MAC - // HIView has a slight difference in how it delivers events to children and parents - // It will not give a leave to a child's parent when it enters a child. - QWidget *currentTarget = QDragManager::self()->currentTarget(); - if (currentTarget) { - // Assume currentTarget did not get a leave - QDragLeaveEvent event; - QApplication::sendEvent(currentTarget, &event); - } -#endif #ifndef QT_NO_GRAPHICSVIEW // QGraphicsProxyWidget handles its own propagation, // and we must not change QDragManagers currentTarget. @@ -3774,20 +3514,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) w = qobject_cast<QWidget *>(QDragManager::self()->currentTarget()); if (!w) { -#ifdef Q_WS_MAC - // HIView has a slight difference in how it delivers events to children and parents - // It will not give an enter to a child's parent when it leaves the child. - if (e->type() == QEvent::DragLeave) - break; - // Assume that w did not get an enter. - QDropEvent *dropEvent = static_cast<QDropEvent *>(e); - QDragEnterEvent dragEnterEvent(dropEvent->pos(), dropEvent->possibleActions(), - dropEvent->mimeData(), dropEvent->mouseButtons(), - dropEvent->keyboardModifiers()); - QApplication::sendEvent(receiver, &dragEnterEvent); - w = QDragManager::self()->currentTarget(); - if (!w) -#endif break; } if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) { @@ -3951,24 +3677,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) break; } #endif // QT_NO_GESTURES -#ifdef Q_WS_MAC - case QEvent::Enter: - if (receiver->isWidgetType()) { - QWidget *w = static_cast<QWidget *>(receiver); - if (w->testAttribute(Qt::WA_AcceptTouchEvents)) - qt_widget_private(w)->registerTouchWindow(true); - } - res = d->notify_helper(receiver, e); - break; - case QEvent::Leave: - if (receiver->isWidgetType()) { - QWidget *w = static_cast<QWidget *>(receiver); - if (w->testAttribute(Qt::WA_AcceptTouchEvents)) - qt_widget_private(w)->registerTouchWindow(false); - } - res = d->notify_helper(receiver, e); - break; -#endif default: res = d->notify_helper(receiver, e); break; @@ -4304,168 +4012,6 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) \sa isPhase2() */ -/***************************************************************************** - Stubbed session management support - *****************************************************************************/ -#ifndef QT_NO_SESSIONMANAGER -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_QWS) - -#if defined(Q_OS_WINCE) -HRESULT qt_CoCreateGuid(GUID* guid) -{ - // We will use the following information to create the GUID - // 1. absolute path to application - wchar_t tempFilename[MAX_PATH]; - if (!GetModuleFileName(0, tempFilename, MAX_PATH)) - return S_FALSE; - unsigned int hash = qHash(QString::fromWCharArray(tempFilename)); - guid->Data1 = hash; - // 2. creation time of file - QFileInfo info(QString::fromWCharArray(tempFilename)); - guid->Data2 = qHash(info.created().toTime_t()); - // 3. current system time - guid->Data3 = qHash(QDateTime::currentDateTime().toTime_t()); - return S_OK; -} -#if !defined(OLE32_MCOMGUID) || defined(QT_WINCE_FORCE_CREATE_GUID) -#define CoCreateGuid qt_CoCreateGuid -#endif - -#endif - -class QSessionManagerPrivate : public QObjectPrivate -{ -public: - QStringList restartCommand; - QStringList discardCommand; - QString sessionId; - QString sessionKey; - QSessionManager::RestartHint restartHint; -}; - -QSessionManager* qt_session_manager_self = 0; -QSessionManager::QSessionManager(QApplication * app, QString &id, QString &key) - : QObject(*new QSessionManagerPrivate, app) -{ - Q_D(QSessionManager); - setObjectName(QLatin1String("qt_sessionmanager")); - qt_session_manager_self = this; -#if defined(Q_WS_WIN) - wchar_t guidstr[40]; - GUID guid; - CoCreateGuid(&guid); - StringFromGUID2(guid, guidstr, 40); - id = QString::fromWCharArray(guidstr); - CoCreateGuid(&guid); - StringFromGUID2(guid, guidstr, 40); - key = QString::fromWCharArray(guidstr); -#endif - d->sessionId = id; - d->sessionKey = key; - d->restartHint = RestartIfRunning; -} - -QSessionManager::~QSessionManager() -{ - qt_session_manager_self = 0; -} - -QString QSessionManager::sessionId() const -{ - Q_D(const QSessionManager); - return d->sessionId; -} - -QString QSessionManager::sessionKey() const -{ - Q_D(const QSessionManager); - return d->sessionKey; -} - - -#if defined(Q_WS_X11) || defined(Q_WS_MAC) -void* QSessionManager::handle() const -{ - return 0; -} -#endif - -#if !defined(Q_WS_WIN) -bool QSessionManager::allowsInteraction() -{ - return true; -} - -bool QSessionManager::allowsErrorInteraction() -{ - return true; -} -void QSessionManager::release() -{ -} - -void QSessionManager::cancel() -{ -} -#endif - - -void QSessionManager::setRestartHint(QSessionManager::RestartHint hint) -{ - Q_D(QSessionManager); - d->restartHint = hint; -} - -QSessionManager::RestartHint QSessionManager::restartHint() const -{ - Q_D(const QSessionManager); - return d->restartHint; -} - -void QSessionManager::setRestartCommand(const QStringList& command) -{ - Q_D(QSessionManager); - d->restartCommand = command; -} - -QStringList QSessionManager::restartCommand() const -{ - Q_D(const QSessionManager); - return d->restartCommand; -} - -void QSessionManager::setDiscardCommand(const QStringList& command) -{ - Q_D(QSessionManager); - d->discardCommand = command; -} - -QStringList QSessionManager::discardCommand() const -{ - Q_D(const QSessionManager); - return d->discardCommand; -} - -void QSessionManager::setManagerProperty(const QString&, const QString&) -{ -} - -void QSessionManager::setManagerProperty(const QString&, const QStringList&) -{ -} - -bool QSessionManager::isPhase2() const -{ - return false; -} - -void QSessionManager::requestPhase2() -{ -} - -#endif -#endif // QT_NO_SESSIONMANAGER - /*! \typedef QApplication::ColorMode \compat @@ -4895,120 +4441,6 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) return true; } -/*! \fn QDecoration &QApplication::qwsDecoration() - Return the QWSDecoration used for decorating windows. - - \warning This method is non-portable. It is only available in - Qt for Embedded Linux. - - \sa QDecoration -*/ - -/*! - \fn void QApplication::qwsSetDecoration(QDecoration *decoration) - - Sets the QDecoration derived class to use for decorating the - windows used by Qt for Embedded Linux to the \a decoration - specified. - - This method is non-portable. It is only available in Qt for Embedded Linux. - - \sa QDecoration -*/ - -/*! \fn QDecoration* QApplication::qwsSetDecoration(const QString &decoration) - \overload - - Requests a QDecoration object for \a decoration from the - QDecorationFactory. - - The string must be one of the QDecorationFactory::keys(). Keys are case - insensitive. - - A later call to the QApplication constructor will override the requested - style when a "-style" option is passed in as a commandline parameter. - - Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object - returned is set as the application's GUI style. -*/ - -/*! - \fn bool QApplication::qwsEventFilter(QWSEvent *event) - - This virtual function is only implemented under Qt for Embedded Linux. - - If you create an application that inherits QApplication and - reimplement this function, you get direct access to all QWS (Q - Window System) events that the are received from the QWS master - process. The events are passed in the \a event parameter. - - Return true if you want to stop the event from being processed. - Return false for normal event dispatching. The default - implementation returns false. -*/ - -/*! \fn void QApplication::qwsSetCustomColors(QRgb *colorTable, int start, int numColors) - Set Qt for Embedded Linux custom color table. - - Qt for Embedded Linux on 8-bpp displays allocates a standard 216 color cube. - The remaining 40 colors may be used by setting a custom color - table in the QWS master process before any clients connect. - - \a colorTable is an array of up to 40 custom colors. \a start is - the starting index (0-39) and \a numColors is the number of colors - to be set (1-40). - - This method is non-portable. It is available \e only in - Qt for Embedded Linux. - - \note The custom colors will not be used by the default screen - driver. To make use of the new colors, implement a custom screen - driver, or use QDirectPainter. -*/ - -/*! \fn int QApplication::qwsProcessEvent(QWSEvent* event) - \internal -*/ - -/*! \fn int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only) - \internal -*/ - -/*! \fn int QApplication::x11ProcessEvent(XEvent* event) - This function does the core processing of individual X - \a{event}s, normally by dispatching Qt events to the right - destination. - - It returns 1 if the event was consumed by special handling, 0 if - the \a event was consumed by normal handling, and -1 if the \a - event was for an unrecognized widget. - - \sa x11EventFilter() -*/ - -/*! - \fn bool QApplication::x11EventFilter(XEvent *event) - - \warning This virtual function is only implemented under X11. - - If you create an application that inherits QApplication and - reimplement this function, you get direct access to all X events - that the are received from the X server. The events are passed in - the \a event parameter. - - Return true if you want to stop the event from being processed. - Return false for normal event dispatching. The default - implementation returns false. - - It is only the directly addressed messages that are filtered. - You must install an event filter directly on the event - dispatcher, which is returned by - QAbstractEventDispatcher::instance(), to handle system wide - messages. - - \sa x11ProcessEvent() -*/ - /*! \fn void QApplication::winFocus(QWidget *widget, bool gotFocus) \internal \since 4.1 @@ -5021,11 +4453,6 @@ bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy) \internal */ -/*! \fn void QApplication::syncX() - Synchronizes with the X server in the X11 implementation. - This normally takes some time. Does nothing on other platforms. -*/ - void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent) { for (int i = 0; i < touchEvent->touchPoints().count(); ++i) { @@ -5216,6 +4643,13 @@ void QApplicationPrivate::translateTouchCancel(QTouchDevice *device, ulong times } } +void QApplicationPrivate::notifyThemeChanged() +{ + QGuiApplicationPrivate::notifyThemeChanged(); + clearSystemPalette(); + initSystemPalette(); +} + #ifndef QT_NO_GESTURES QGestureManager* QGestureManager::instance() { diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 503b36aec6..060765969f 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -98,12 +98,8 @@ public: #ifndef qdoc QApplication(int &argc, char **argv, int = ApplicationFlags); - QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); + QT_DEPRECATED QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags); QApplication(int &argc, char **argv, Type, int = ApplicationFlags); -#if defined(Q_WS_X11) - QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = ApplicationFlags); - QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = ApplicationFlags); -#endif #endif virtual ~QApplication(); @@ -150,7 +146,7 @@ public: static QWidget *topLevelAt(const QPoint &p); static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); } - static void syncX(); + QT_DEPRECATED static void syncX(); static void beep(); static void alert(QWidget *widget, int duration = 0); @@ -182,31 +178,8 @@ public: static bool isEffectEnabled(Qt::UIEffect); static void setEffectEnabled(Qt::UIEffect, bool enable = true); -#if defined(Q_WS_MAC) - virtual bool macEventFilter(EventHandlerCallRef, EventRef); -#endif -#if defined(Q_WS_X11) - virtual bool x11EventFilter(XEvent *); - virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only); - int x11ProcessEvent(XEvent*); -#endif -#if defined(Q_WS_QWS) - virtual bool qwsEventFilter(QWSEvent *); - int qwsProcessEvent(QWSEvent*); - void qwsSetCustomColors(QRgb *colortable, int start, int numColors); -#ifndef QT_NO_QWS_MANAGER - static QDecoration &qwsDecoration(); - static void qwsSetDecoration(QDecoration *); - static QDecoration *qwsSetDecoration(const QString &decoration); -#endif -#endif - static QPlatformNativeInterface *platformNativeInterface(); -#if defined(Q_WS_WIN) - void winFocus(QWidget *, bool); - static void winMouseButtonUp(); -#endif #ifndef QT_NO_SESSIONMANAGER // session management bool isSessionRestored() const; @@ -252,21 +225,14 @@ public Q_SLOTS: static void aboutQt(); protected: -#if defined(Q_WS_QWS) - void setArgs(int, char **); -#endif bool event(QEvent *); bool compressEvent(QEvent *, QObject *receiver, QPostEventList *); #if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc) QApplication(int &argc, char **argv); - QApplication(int &argc, char **argv, bool GUIenabled); + QT_DEPRECATED QApplication(int &argc, char **argv, bool GUIenabled); QApplication(int &argc, char **argv, Type); -#if defined(Q_WS_X11) - QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0); - QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); -#endif #endif private: @@ -291,21 +257,9 @@ private: #endif friend class QAction; -#if defined(Q_WS_QWS) - friend class QWSDirectPainterSurface; - friend class QDirectPainter; - friend class QDirectPainterPrivate; -#endif #ifndef QT_NO_GESTURES friend class QGestureManager; #endif - -#if defined(Q_WS_MAC) || defined(Q_WS_X11) - Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut()) -#endif -#if defined(QT_RX71_MULTITOUCH) - Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents()) -#endif }; QT_END_NAMESPACE diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index e728868182..7a880986bf 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -260,7 +260,9 @@ public: static QPalette *sys_pal; static QPalette *set_pal; -private: +protected: + void notifyThemeChanged(); + public: static QFont *sys_font; static QFont *set_font; diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp index c848dd74f4..97edb4fb0f 100644 --- a/src/widgets/kernel/qicon.cpp +++ b/src/widgets/kernel/qicon.cpp @@ -60,11 +60,6 @@ #include <private/qt_cocoa_helpers_mac_p.h> #endif -#ifdef Q_WS_X11 -#include "private/qt_x11_p.h" -#include "private/qkde_p.h" -#endif - #include "private/qhexstring_p.h" #ifndef QT_NO_ICON diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 978e989a00..b331356e66 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -220,8 +220,6 @@ void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePa if (pe) pe->setSystemClip(QRegion()); - QApplication::syncX(); - #if defined(Q_OS_UNIX) ::usleep(1000 * msec); #endif diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index 72080d9e6b..81847681e4 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -117,7 +117,7 @@ static bool compare(const QVariant::Private *a, const QVariant::Private *b) return false; } -static bool convert(const QVariant::Private *d, QVariant::Type type, void *result, bool *ok) +static bool convert(const QVariant::Private *d, int type, void *result, bool *ok) { Q_UNUSED(d); Q_UNUSED(type); @@ -127,7 +127,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type type, void *resul return false; } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) static void streamDebug(QDebug dbg, const QVariant &v) { QVariant::Private *d = const_cast<QVariant::Private *>(&v.data_ptr()); @@ -141,7 +141,7 @@ static void streamDebug(QDebug dbg, const QVariant &v) dbg.nospace() << *v_cast<QSizePolicy>(d); break; default: - dbg.nospace() << "QVariant::Type(" << d->type << ")"; + dbg.nospace() << "QMetaType::Type(" << d->type << ")"; } } #endif @@ -157,7 +157,7 @@ static const QVariant::Handler widgets_handler = { compare, convert, 0, -#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM) +#if !defined(QT_NO_DEBUG_STREAM) streamDebug #else 0 diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index c04d8a9dc3..4d5e9d5774 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -364,7 +364,7 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) QPoint mapped = widget->mapFrom(m_widget, event->pos()); - QWheelEvent translated(mapped, event->globalPos(), event->delta(), event->buttons(), event->modifiers(), event->orientation()); + QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->pixelDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers()); QGuiApplication::sendSpontaneousEvent(widget, &translated); } diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 75476faeeb..174e94e63d 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -83,12 +83,6 @@ # include "private/qtextengine_p.h" #endif -#ifdef Q_WS_X11 -# include <private/qt_x11_p.h> -#elif defined(Q_WS_MAC) -# include <private/qt_cocoa_helpers_mac_p.h> -#endif - #include <private/qstylehelper_p.h> QT_BEGIN_NAMESPACE @@ -4920,12 +4914,8 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget break; case SH_DialogButtonLayout: ret = QDialogButtonBox::WinLayout; -#ifdef Q_WS_X11 - if (X11->desktopEnvironment == DE_KDE) - ret = QDialogButtonBox::KdeLayout; - else if (X11->desktopEnvironment == DE_GNOME) - ret = QDialogButtonBox::GnomeLayout; -#endif + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + ret = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt(); break; case SH_ComboBox_PopupFrameStyle: ret = QFrame::StyledPanel | QFrame::Plain; @@ -4934,10 +4924,9 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = Qt::LinksAccessibleByMouse; break; case SH_DialogButtonBox_ButtonsHaveIcons: -#ifdef Q_WS_X11 - return true; -#endif ret = 0; + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + ret = theme->themeHint(QPlatformTheme::DialogButtonBoxButtonsHaveIcons).toBool() ? 1 : 0; break; case SH_SpellCheckUnderlineStyle: ret = QTextCharFormat::WaveUnderline; diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 30c6ed5e74..5c0ee254d4 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -860,6 +860,19 @@ static QStyle::StandardPixmap subControlIcon(int pe) return QStyle::SP_CustomBase; } +static inline QIcon cssIconValueToIcon(const QCss::IconValue &iconValue) +{ + if (iconValue.entries.isEmpty()) + return QIcon(); + QIcon icon = QIcon(iconValue.entries.first().uri); + for (int i = 1; i < iconValue.entries.size(); ++i) { + const QCss::IconValue::IconEntry &entry = iconValue.entries.at(i); + icon.addPixmap(entry.uri, static_cast<QIcon::Mode>(entry.mode), + static_cast<QIcon::State>(entry.state)); + } + return icon; +} + QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QWidget *widget) : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { @@ -919,11 +932,11 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QWidget if (v.extractPalette(&fg, &sfg, &sbg, &abg)) pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg); - QIcon icon; alignment = Qt::AlignCenter; QSize size; - if (v.extractImage(&icon, &alignment, &size)) - img = new QStyleSheetImageData(icon, alignment, size); + QCss::IconValue iconValue; + if (v.extractImage(&iconValue, &alignment, &size)) + img = new QStyleSheetImageData(cssIconValueToIcon(iconValue), alignment, size); int adj = -255; hasFont = v.extractFont(&font, &adj); diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 503e5aa596..d416f26f51 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -421,7 +421,8 @@ void QCompletionModel::filter(const QStringList& parts) void QCompletionModel::resetModel() { if (rowCount() == 0) { - reset(); + beginResetModel(); + endResetModel(); return; } diff --git a/src/widgets/util/qscrollerproperties.cpp b/src/widgets/util/qscrollerproperties.cpp index 6a61e4dfd1..8d6ad36014 100644 --- a/src/widgets/util/qscrollerproperties.cpp +++ b/src/widgets/util/qscrollerproperties.cpp @@ -314,7 +314,7 @@ void QScrollerProperties::setScrollMetric(ScrollMetric metric, const QVariant &v \value MousePressEventDelay This is the time a mouse press event is delayed when starting a flick gesture in \c{[s]}. If the gesture is triggered within that time, no mouse press or release is sent to the scrolled object. If it triggers after that delay the delayed - mouse press plus a faked release event at global postion \c{QPoint(-QWIDGETSIZE_MAX, + mouse press plus a faked release event at global position \c{QPoint(-QWIDGETSIZE_MAX, -QWIDGETSIZE_MAX)} is sent. If the gesture is canceled, then both the delayed mouse press plus the real release event are delivered. diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp index 4b09d5fc70..a87e9e0f05 100644 --- a/src/widgets/util/qundoview.cpp +++ b/src/widgets/util/qundoview.cpp @@ -142,7 +142,8 @@ void QUndoModel::stackDestroyed(QObject *obj) void QUndoModel::stackChanged() { - reset(); + beginResetModel(); + endResetModel(); m_sel_model->setCurrentIndex(selectedIndex(), QItemSelectionModel::ClearAndSelect); } 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); |