diff options
author | David Boddie <dboddie@trolltech.com> | 2009-03-26 15:50:37 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2009-03-26 15:50:37 (GMT) |
commit | 0e459b6b5a4a8d900c675cdcb5312535de2fe535 (patch) | |
tree | e94438805d685e4b459f4dd0f4b06d17117bd48b | |
parent | 7fe9bdb1be6b20c351ff0bd34aff2b1cc8b50323 (diff) | |
parent | 6bcf2ca6645409ffa1aaadd1bd302c6e86b5b028 (diff) | |
download | Qt-0e459b6b5a4a8d900c675cdcb5312535de2fe535.zip Qt-0e459b6b5a4a8d900c675cdcb5312535de2fe535.tar.gz Qt-0e459b6b5a4a8d900c675cdcb5312535de2fe535.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt into 4.5
78 files changed, 1648 insertions, 1316 deletions
diff --git a/dist/changes-4.5.1 b/dist/changes-4.5.1 new file mode 100644 index 0000000..4e3fcc7 --- /dev/null +++ b/dist/changes-4.5.1 @@ -0,0 +1,125 @@ +Qt 4.5.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 4.5.0. For more details, +refer to the online documentation included in this distribution. The +documentation is also available online: + + http://doc.trolltech.com/4.5 + +The Qt version 4.5 series is binary compatible with the 4.4.x series. +Applications compiled for 4.4 will continue to run with 4.5. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Task Tracker: + + http://www.qtsoftware.com/developer/task-tracker + +Each of these identifiers can be entered in the task tracker to obtain more +information about a particular change. + +**************************************************************************** +* General * +**************************************************************************** + +General Improvements +-------------------- + +- Documentation and Examples + +Third party components +---------------------- + + +**************************************************************************** +* Library * +**************************************************************************** + +- QSharedPointer + * [246843] Fixed a crash caused by using QSharedPointer in global statics + +**************************************************************************** +* Database Drivers * +**************************************************************************** + + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + +Qt for Linux/X11 +---------------- + + +Qt for Windows +-------------- + + +Qt for Mac OS X +--------------- + + +Qt for Embedded Linux +--------------------- + + +Qt for Windows CE +----------------- + + +**************************************************************************** +* Compiler Specific Changes * +**************************************************************************** + + +**************************************************************************** +* Tools * +**************************************************************************** + +- Build System + +- Assistant + + +- Designer + + +- Linguist + - Linguist GUI + + - lupdate + + - lrelease + + +- rcc + + +- moc + + +- uic + + +- uic3 + + +- qmake + + +- configure + + +- qtconfig + + +- qt3to4 + + +**************************************************************************** +* Plugins * +**************************************************************************** + + +**************************************************************************** +* Important Behavior Changes * +**************************************************************************** + diff --git a/examples/xmlpatterns/trafficinfo/mainwindow.cpp b/examples/xmlpatterns/trafficinfo/mainwindow.cpp index c4ca731..1f754d5 100644 --- a/examples/xmlpatterns/trafficinfo/mainwindow.cpp +++ b/examples/xmlpatterns/trafficinfo/mainwindow.cpp @@ -71,7 +71,7 @@ MainWindow::MainWindow() QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(updateTimeInformation())); - timer->start(1000*60); + timer->start(1000*60*5); const QSettings settings("Qt Software", "trafficinfo"); m_station = StationInformation(settings.value("stationId", "03012130").toString(), diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index af48a6e..da530c8 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - 70604503a0365edaeff82ffad7b71f90641fa592 + 0b6fc217c2b853827926313c09bb3c32f66ffe43 diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 10a3840..3b20751 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,16 @@ +2009-02-06 Dirk Schulze <krit@webkit.org> + + Reviewed by Simon Hausmann. + + Fix bug in clearRect(). Use fillRect() instead of eraseRect() to get + the context transparent. + + [QT] clearRect fill's a given rect with white + https://bugs.webkit.org/show_bug.cgi?id=23728 + + * platform/graphics/qt/GraphicsContextQt.cpp: + (WebCore::GraphicsContext::clearRect): + 2009-03-19 Simon Hausmann <simon.hausmann@nokia.com> Reviewed by Tor Arne Vestbø. diff --git a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp index 80a6390..1830566 100644 --- a/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp +++ b/src/3rdparty/webkit/WebCore/platform/graphics/qt/GraphicsContextQt.cpp @@ -815,7 +815,7 @@ void GraphicsContext::clearRect(const FloatRect& rect) QPainter::CompositionMode currentCompositionMode = p->compositionMode(); if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) p->setCompositionMode(QPainter::CompositionMode_Source); - p->eraseRect(rect); + p->fillRect(rect, Qt::transparent); if (p->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) p->setCompositionMode(currentCompositionMode); } diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp index 5e3c656..636b6e8 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp @@ -533,6 +533,8 @@ void QWebPagePrivate::updateEditorActions() updateAction(QWebPage::ToggleBold); updateAction(QWebPage::ToggleItalic); updateAction(QWebPage::ToggleUnderline); + updateAction(QWebPage::InsertParagraphSeparator); + updateAction(QWebPage::InsertLineSeparator); } void QWebPagePrivate::timerEvent(QTimerEvent *ev) @@ -1792,6 +1794,13 @@ QAction *QWebPage::action(WebAction action) const text = contextMenuItemTagInspectElement(); break; + case InsertParagraphSeparator: + text = tr("Insert a new paragraph"); + break; + case InsertLineSeparator: + text = tr("Insert a new line"); + break; + case NoWebAction: return 0; } @@ -2319,7 +2328,8 @@ QWebPluginFactory *QWebPage::pluginFactory() const \list \o %Platform% and %Subplatform% are expanded to the windowing system and the operation system. \o %Security% expands to U if SSL is enabled, otherwise N. SSL is enabled if QSslSocket::supportsSsl() returns true. - \o %Locale% is replaced with QLocale::name(). + \o %Locale% is replaced with QLocale::name(). The locale is determined from the view of the QWebPage. If no view is set on the QWebPage, + then a default constructed QLocale is used instead. \o %WebKitVersion% currently expands to 527+ \o %AppVersion% expands to QCoreApplication::applicationName()/QCoreApplication::applicationVersion() if they're set; otherwise defaulting to Qt and the current Qt version. \endlist diff --git a/src/3rdparty/webkit/WebKit/qt/ChangeLog b/src/3rdparty/webkit/WebKit/qt/ChangeLog index 0755133..32d27cd 100644 --- a/src/3rdparty/webkit/WebKit/qt/ChangeLog +++ b/src/3rdparty/webkit/WebKit/qt/ChangeLog @@ -1,3 +1,25 @@ +2009-03-26 Simon Hausmann <simon.hausmann@nokia.com> + + Rubber-stamped by Tor Arne Vestbø. + + Fix the documentation of the QLocale usage in userAgentForUrl. + + * Api/qwebpage.cpp: + +2009-03-20 Erik L. Bunce <elbunce@xendom.com> + + Reviewed by Simon Hausmann. + + Fix for InsertParagraphSeparator and InsertLineSeparator so that + QWebPage::action() creates QActions for them. Also make sure they get + updated appropriately. + + * Api/qwebpage.cpp: + (QWebPagePrivate::updateEditorActions): + (QWebPage::action): + * tests/qwebpage/tst_qwebpage.cpp: + (tst_QWebPage::textEditing): + 2009-03-20 Erik L. Bunce <elbunce@xendom.com> Reviewed by Tor Arne Vestbø. diff --git a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp index 54d342e..d85e880 100644 --- a/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp +++ b/src/3rdparty/webkit/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp @@ -956,6 +956,8 @@ void tst_QWebPage::textEditing() QVERIFY(page->action(QWebPage::ToggleBold) != 0); QVERIFY(page->action(QWebPage::ToggleItalic) != 0); QVERIFY(page->action(QWebPage::ToggleUnderline) != 0); + QVERIFY(page->action(QWebPage::InsertParagraphSeparator) != 0); + QVERIFY(page->action(QWebPage::InsertLineSeparator) != 0); // right now they are disabled because contentEditable is false QCOMPARE(page->action(QWebPage::DeleteStartOfWord)->isEnabled(), false); @@ -966,6 +968,8 @@ void tst_QWebPage::textEditing() QCOMPARE(page->action(QWebPage::ToggleBold)->isEnabled(), false); QCOMPARE(page->action(QWebPage::ToggleItalic)->isEnabled(), false); QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), false); + QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), false); // make it editable before navigating the cursor page->setContentEditable(true); @@ -979,6 +983,8 @@ void tst_QWebPage::textEditing() QCOMPARE(page->action(QWebPage::ToggleBold)->isEnabled(), true); QCOMPARE(page->action(QWebPage::ToggleItalic)->isEnabled(), true); QCOMPARE(page->action(QWebPage::ToggleUnderline)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::InsertParagraphSeparator)->isEnabled(), true); + QCOMPARE(page->action(QWebPage::InsertLineSeparator)->isEnabled(), true); delete page; } diff --git a/src/corelib/concurrent/qtconcurrentreducekernel.h b/src/corelib/concurrent/qtconcurrentreducekernel.h index e863b63..2dad519 100644 --- a/src/corelib/concurrent/qtconcurrentreducekernel.h +++ b/src/corelib/concurrent/qtconcurrentreducekernel.h @@ -51,6 +51,7 @@ #include <QtCore/qmap.h> #include <QtCore/qmutex.h> #include <QtCore/qthread.h> +#include <QtCore/qthreadpool.h> #include <QtCore/qvector.h> QT_BEGIN_HEADER @@ -107,7 +108,7 @@ class ReduceKernel const ReduceOptions reduceOptions; QMutex mutex; - int progress, resultsMapSize; + int progress, resultsMapSize, threadCount; ResultsMap resultsMap; bool canReduce(int begin) const @@ -140,7 +141,8 @@ class ReduceKernel public: ReduceKernel(ReduceOptions _reduceOptions) - : reduceOptions(_reduceOptions), progress(0), resultsMapSize(0) + : reduceOptions(_reduceOptions), progress(0), resultsMapSize(0), + threadCount(QThreadPool::globalInstance()->maxThreadCount()) { } void runReduce(ReduceFunctor &reduce, @@ -210,12 +212,12 @@ public: inline bool shouldThrottle() { - return (resultsMapSize > (ReduceQueueThrottleLimit * QThread::idealThreadCount())); + return (resultsMapSize > (ReduceQueueThrottleLimit * threadCount)); } inline bool shouldStartThread() { - return (resultsMapSize <= (ReduceQueueStartLimit * QThread::idealThreadCount())); + return (resultsMapSize <= (ReduceQueueStartLimit * threadCount)); } }; diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index d8a9923..c3a989e 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -842,15 +842,19 @@ QT_BEGIN_NAMESPACE */ void QtSharedPointer::internalSafetyCheckAdd(const volatile void *ptr) { - QMutexLocker lock(&knownPointers()->mutex); + KnownPointers *const kp = knownPointers(); + if (!kp) + return; // end-game: the application is being destroyed already + + QMutexLocker lock(&kp->mutex); void *actual = const_cast<void*>(ptr); - if (knownPointers()->values.contains(actual)) { + if (kp->values.contains(actual)) { printBacktrace(knownPointers()->values.value(actual)); qFatal("QSharedPointerData: internal self-check failed: pointer %p was already tracked " "by another QSharedPointerData object", actual); } - knownPointers()->values.insert(actual, saveBacktrace()); + kp->values.insert(actual, saveBacktrace()); } /*! @@ -858,9 +862,13 @@ void QtSharedPointer::internalSafetyCheckAdd(const volatile void *ptr) */ void QtSharedPointer::internalSafetyCheckRemove(const volatile void *ptr) { - QMutexLocker lock(&knownPointers()->mutex); + KnownPointers *const kp = knownPointers(); + if (!kp) + return; // end-game: the application is being destroyed already + + QMutexLocker lock(&kp->mutex); void *actual = const_cast<void*>(ptr); - knownPointers()->values.remove(actual); + kp->values.remove(actual); } QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index 0ea7692..eaa97ff 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -117,7 +117,7 @@ QGraphicsLayoutItemPrivate::QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *par, */ void QGraphicsLayoutItemPrivate::init() { - sizeHintCacheDirty = true; + sizeHintCacheDirty = true; sizePolicy = QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); } @@ -175,12 +175,12 @@ QSizeF *QGraphicsLayoutItemPrivate::effectiveSizeHints(const QSizeF &constraint) Returns the parent item of this layout, or 0 if this layout is not installed on any widget. - + If this is the item that the layout is installed on, it will return "itself". If the layout is a sub-layout, this function returns the parent widget of the parent layout. - + Note that it will traverse up the layout item hierarchy instead of just calling QGraphicsItem::parentItem(). This is on purpose. @@ -233,7 +233,7 @@ QGraphicsItem *QGraphicsLayoutItemPrivate::parentItem() const position. Calling setGeometry() will always resize and reposition the item immediately. Normally, this function is called by QGraphicsLayout after the layout has been activated, but it can also be called by the item's user - at any time. + at any time. The sizeHint() function returns the item' minimum, preferred and maximum size hints. You can override these properties by calling setMinimumSize(), @@ -360,7 +360,7 @@ void QGraphicsLayoutItem::setSizePolicy(QSizePolicy::Policy hPolicy, } /*! - Returns the current size policy. + Returns the current size policy. \sa setSizePolicy(), QWidget::sizePolicy() */ @@ -626,14 +626,15 @@ void QGraphicsLayoutItem::setMaximumHeight(qreal height) */ /*! - \fn virtual void QGraphicsLayoutItem::setGeometry(const QRectF &rect) = 0 + \fn virtual void QGraphicsLayoutItem::setGeometry(const QRectF &rect) - This pure virtual function sets the geometry of the QGraphicsLayoutItem to + This virtual function sets the geometry of the QGraphicsLayoutItem to \a rect, which is in parent coordinates (e.g., the top-left corner of \a rect is equivalent to the item's position in parent coordinates). - Reimplement this function in a subclass of QGraphicsLayoutItem to enable - your item to receive geometry updates. + You must reimplement this function in a subclass of QGraphicsLayoutItem to + receive geometry updates. The layout will call this function when it does a + rearrangement. If \a rect is outside of the bounds of minimumSize and maximumSize, it will be adjusted to its closest size so that it is within the legal @@ -744,7 +745,7 @@ QSizeF QGraphicsLayoutItem::effectiveSizeHint(Qt::SizeHint which, const QSizeF & \sa effectiveSizeHint() */ void QGraphicsLayoutItem::updateGeometry() -{ +{ Q_D(QGraphicsLayoutItem); d->sizeHintCacheDirty = true; } @@ -768,7 +769,7 @@ QGraphicsLayoutItem *QGraphicsLayoutItem::parentLayoutItem() const \sa parentLayoutItem() */ void QGraphicsLayoutItem::setParentLayoutItem(QGraphicsLayoutItem *parent) -{ +{ d_func()->parent = parent; } @@ -789,12 +790,12 @@ bool QGraphicsLayoutItem::isLayout() const If its true, then the layout will delete it. If its false, then it is assumed that another object has the ownership of it, and the layout won't delete this item. - - If the item inherits both QGraphicsItem and QGraphicsLayoutItem (such - as QGraphicsWidget does) the item is really part of two ownership + + If the item inherits both QGraphicsItem and QGraphicsLayoutItem (such + as QGraphicsWidget does) the item is really part of two ownership hierarchies. This property informs what the layout should do with its child items when it is destructed. In the case of QGraphicsWidget, it - is preferred that when the layout is deleted it won't delete its children + is preferred that when the layout is deleted it won't delete its children (since they are also part of the graphics item hierarchy). By default this value is initialized to false in QGraphicsLayoutItem, @@ -822,9 +823,9 @@ void QGraphicsLayoutItem::setOwnedByLayout(bool ownership) /*! * Returns the QGraphicsItem that this layout item represents. - * For QGraphicsWidget it will return itself. For custom items it can return an - * aggregated value. - * + * For QGraphicsWidget it will return itself. For custom items it can return an + * aggregated value. + * * \sa setGraphicsItem() */ QGraphicsItem *QGraphicsLayoutItem::graphicsItem() const @@ -836,10 +837,10 @@ QGraphicsItem *QGraphicsLayoutItem::graphicsItem() const * If the QGraphicsLayoutItem represents a QGraphicsItem, and it wants to take * advantage of the automatic reparenting capabilities of QGraphicsLayout it * should set this value. - * Note that if you delete \a item and not delete the layout item, you are - * responsible of calling setGraphicsItem(0) in order to avoid having a + * Note that if you delete \a item and not delete the layout item, you are + * responsible of calling setGraphicsItem(0) in order to avoid having a * dangling pointer. - * + * * \sa graphicsItem() */ void QGraphicsLayoutItem::setGraphicsItem(QGraphicsItem *item) @@ -848,5 +849,5 @@ void QGraphicsLayoutItem::setGraphicsItem(QGraphicsItem *item) } QT_END_NAMESPACE - + #endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 7e59fad..c4224ed 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -169,189 +169,174 @@ QApplicationPrivate::~QApplicationPrivate() } /*! - \class QApplication - \brief The QApplication class manages the GUI application's control - flow and main settings. - - \ingroup application - \mainclass - - It 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 and finalization, and - provides session management. It also handles most system-wide and - application-wide settings. - - For any GUI application that uses Qt, there is precisely one - QApplication object, no matter whether the application has 0, 1, 2 - or more windows at any time. For non-GUI Qt applications, use - QCoreApplication instead, which doesn't depend on the \l QtGui - library. - - The QApplication object is accessible through the instance() - function which return a pointer equivalent to the global qApp - pointer. - - QApplication's main areas of responsibility are: - \list - - \o It initializes the application with the user's desktop settings - such as palette(), font() and doubleClickInterval(). It keeps track - of these properties in case the user changes the desktop globally, for - example through some kind of control panel. - - \o It performs event handling, meaning that it receives events - from the underlying window system and dispatches them to the relevant - widgets. By using sendEvent() and postEvent() you can send your own - events to widgets. - - \o It parses common command line arguments and sets its internal - state accordingly. See the \link QApplication::QApplication() - constructor documentation\endlink below for more details about this. - - \o It defines the application's look and feel, which is - encapsulated in a QStyle object. This can be changed at runtime - with setStyle(). - - \o It specifies how the application is to allocate colors. - See setColorSpec() for details. - - \o It provides localization of strings that are visible to the user - via translate(). - - \o It provides some magical objects like the desktop() and the - clipboard(). - - \o It knows about the application's windows. You can ask which - widget is at a certain position using widgetAt(), get a list of - topLevelWidgets() and closeAllWindows(), etc. - - \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 \link - session.html session management \endlink. This makes it possible - for applications to terminate gracefully when the user logs out, to - cancel a shutdown process if termination isn't possible and even to - preserve the entire application's state for a future session. See - isSessionRestored(), sessionId() and commitData() and saveState() - for details. - - \endlist - - Since the QApplication object does so much initialization, it - \e{must} be created before any other objects related to the user - interface are created. - - Since it also deals with common command line arguments, it is - usually a good idea to create it \e before any interpretation or - modification of \c argv is done in the application itself. - - \table - \header \o{2,1} Groups of functions - \row - \o System settings - \o - desktopSettingsAware(), - setDesktopSettingsAware(), - cursorFlashTime(), - setCursorFlashTime(), - doubleClickInterval(), - setDoubleClickInterval(), - setKeyboardInputInterval(), - wheelScrollLines(), - setWheelScrollLines(), - palette(), - setPalette(), - font(), - setFont(), - fontMetrics(). - - \row - \o Event handling - \o - exec(), - processEvents(), - exit(), - quit(). - sendEvent(), - postEvent(), - sendPostedEvents(), - removePostedEvents(), - hasPendingEvents(), - notify(), - macEventFilter(), - qwsEventFilter(), - x11EventFilter(), - x11ProcessEvent(), - winEventFilter(). - - \row - \o GUI Styles - \o - style(), - setStyle(). - - \row - \o Color usage - \o - colorSpec(), - setColorSpec(), - qwsSetCustomColors(). - - \row - \o Text handling - \o - installTranslator(), - removeTranslator() - translate(). - - \row - \o Widgets - \o - allWidgets(), - topLevelWidgets(), - desktop(), - activePopupWidget(), - activeModalWidget(), - clipboard(), - focusWidget(), - winFocus(), - activeWindow(), - widgetAt(). - - \row - \o Advanced cursor handling - \o - overrideCursor(), - setOverrideCursor(), - restoreOverrideCursor(). - - \row - \o X Window System synchronization - \o - flushX(), - syncX(). - - \row - \o Session management - \o - isSessionRestored(), - sessionId(), - commitData(), - saveState(). - - \row - \o Miscellaneous - \o - closeAllWindows(), - startingUp(), - closingDown(), - type(). - \endtable + \class QApplication + \brief The QApplication class manages the GUI application's control + flow and main settings. + + \ingroup application + \mainclass + + 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 and finalization, and provides session + management. In addition, it handles most system-wide and application-wide + settings. + + For any GUI application using Qt, there is precisely 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. + + The QApplication object is accessible through the instance() function that + returns a pointer equivalent to the global qApp pointer. + + QApplication's main areas of responsibility are: + \list + \o It initializes the application with the user's desktop settings + such as palette(), font() and doubleClickInterval(). It keeps + track of these properties in case the user changes the desktop + globally, for example through some kind of control panel. + + \o It performs event handling, meaning that it receives events + from the underlying window system and dispatches them to the + relevant widgets. By using sendEvent() and postEvent() you can + send your own events to widgets. + + \o It parses common command line arguments and sets its internal + state accordingly. See the \l{QApplication::QApplication()} + {constructor documentation} below for more details. + + \o It defines the application's look and feel, which is + encapsulated in a QStyle object. This can be changed at runtime + with setStyle(). + + \o It specifies how the application is to allocate colors. See + setColorSpec() for details. + + \o It provides localization of strings that are visible to the + user via translate(). + + \o It provides some magical objects like the desktop() and the + clipboard(). + + \o It knows about the application's windows. You can ask which + widget is at a certain position using widgetAt(), get a list of + topLevelWidgets() and closeAllWindows(), etc. + + \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 + shutdown process if termination isn't possible and even to + preserve the entire application's state for a future session. + See isSessionRestored(), sessionId() and commitData() and + saveState() for details. + \endlist + + The QApplication object does so much initialization. Hence, it \e{must} be + created before any other objects related to the user interface are created. + Since QApplication also deals with common command line arguments, it is + usually a good idea to create it \e before any interpretation or + modification of \c argv is done in the application itself. + + \table + \header + \o{2,1} Groups of functions + + \row + \o System settings + \o desktopSettingsAware(), + setDesktopSettingsAware(), + cursorFlashTime(), + setCursorFlashTime(), + doubleClickInterval(), + setDoubleClickInterval(), + setKeyboardInputInterval(), + wheelScrollLines(), + setWheelScrollLines(), + palette(), + setPalette(), + font(), + setFont(), + fontMetrics(). + + \row + \o Event handling + \o exec(), + processEvents(), + exit(), + quit(). + sendEvent(), + postEvent(), + sendPostedEvents(), + removePostedEvents(), + hasPendingEvents(), + notify(), + macEventFilter(), + qwsEventFilter(), + x11EventFilter(), + x11ProcessEvent(), + winEventFilter(). + + \row + \o GUI Styles + \o style(), + setStyle(). + + \row + \o Color usage + \o colorSpec(), + setColorSpec(), + qwsSetCustomColors(). + + \row + \o Text handling + \o installTranslator(), + removeTranslator() + translate(). + + \row + \o Widgets + \o allWidgets(), + topLevelWidgets(), + desktop(), + activePopupWidget(), + activeModalWidget(), + clipboard(), + focusWidget(), + activeWindow(), + widgetAt(). + + \row + \o Advanced cursor handling + \o overrideCursor(), + setOverrideCursor(), + restoreOverrideCursor(). + + \row + \o X Window System synchronization + \o flushX(), + syncX(). + + \row + \o Session management + \o isSessionRestored(), + sessionId(), + commitData(), + saveState(). + + \row + \o Miscellaneous + \o closeAllWindows(), + startingUp(), + closingDown(), + type(). + \endtable \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings */ @@ -382,6 +367,7 @@ QApplicationPrivate::~QApplicationPrivate() Returns the top-level widget at the given \a point; returns 0 if there is no such widget. */ + /*! \fn QWidget *QApplication::topLevelAt(int x, int y) @@ -393,8 +379,8 @@ QApplicationPrivate::~QApplicationPrivate() /* - The qt_init() and qt_cleanup() functions are implemented in the - qapplication_xyz.cpp file. + The qt_init() and qt_cleanup() functions are implemented in the + qapplication_xyz.cpp file. */ void qt_init(QApplicationPrivate *priv, int type @@ -580,99 +566,100 @@ void QApplicationPrivate::process_cmdline() } /*! - Initializes the window system and constructs an application object - with \a argc command line arguments in \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. - - The global \c qApp pointer refers to this application object. Only - one application object should be created. - - This application object must be constructed before any \link - QPaintDevice paint devices\endlink (including widgets, pixmaps, bitmaps - etc.). - - Note that \a argc and \a argv might be changed. 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 \link debug.html Debugging Techniques \endlink 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 - are \c motif, \c windows, and \c platinum. If you compiled Qt - with additional styles or have additional styles as plugins these - will be available to the \c -style command line option. - \o -style \e style, is the same as listed above. - \o -stylesheet= \e stylesheet, sets the application \l styleSheet. The value - must be a path to a file that contains the Style Sheet. Note that relative URLs - in the Style Sheet file are relative to the Style Sheet file's path. - \o -stylesheet \e stylesheet, is the same as listed above. - \o -session= \e session, restores the application from an earlier - \link session.html session \endlink. - \o -session \e session, is the same as listed above. - \o -widgetcount, prints debug message at the end about number of widgets left - undestroyed and maximum number of widgets existed at the same time - \o -reverse, sets the application's layout direction to Qt::RightToLeft - \o -graphicssystem, sets the backend to be used for on-screen - widgets and QPixmaps. Available options are \c{raster} and \c{opengl}. - - \endlist - - The Windows version of Qt also support one additional command line - option, if Direct3D support has been compiled into Qt: - \list - \o -direct3d will make the Direct3D paint engine the default widget - paint engine in Qt. \bold {This functionality is experimental.} - \endlist - - The X11 version of Qt also 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. - \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 - - \sa arguments() + Initializes the window system and constructs an application object with + \a argc command line arguments in \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. + + The global \c qApp pointer refers to this application object. Only one + application object should be created. + + This application object must be constructed before any \l{QPaintDevice} + {paint devices} (including widgets, pixmaps, bitmaps etc.). + + \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 + are \c motif, \c windows, and \c platinum. If you compiled Qt with + additional styles or have additional styles as plugins these will + be available to the \c -style command line option. + \o -style \e style, is the same as listed above. + \o -stylesheet= \e stylesheet, sets the application \l styleSheet. The + value must be a path to a file that contains the Style Sheet. + \note Relative URLs in the Style Sheet file are relative to the + Style Sheet file's path. + \o -stylesheet \e stylesheet, is the same as listed above. + \o -session= \e session, restores the application from an earlier + \l{Session Management}{session}. + \o -session \e session, is the same as listed above. + \o -widgetcount, prints debug message at the end about number of + widgets left undestroyed and maximum number of widgets existed at + the same time + \o -reverse, sets the application's layout direction to + Qt::RightToLeft + \o -graphicssystem, sets the backend to be used for on-screen widgets + and QPixmaps. Available options are \c{raster} and \c{opengl}. + \endlist + + The Windows version of Qt supports an additional command line option, if + Direct3D support has been compiled into Qt: + \list + \o -direct3d will make the Direct3D paint engine the default widget + paint engine in Qt. \bold {This functionality is experimental.} + \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. + \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 + + \sa arguments() */ QApplication::QApplication(int &argc, char **argv) @@ -685,26 +672,26 @@ 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. + 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. - \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. + \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. + 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 Macintosh, currently the window system is - always initialized, regardless of the value of GUIenabled. This may - change in future versions of Qt. + 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 Macintosh, 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. + The following example shows how to create an application that uses a + graphical interface when available. \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0 */ @@ -720,17 +707,17 @@ QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _intern /*! - Constructs an application object with \a argc command line arguments - in \a argv. + Constructs an application object with \a argc command line arguments in + \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. + \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. - With Qt for Embedded Linux, passing QApplication::GuiServer for \a type - makes this application the server (equivalent to running with the - \c -qws option). + 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) : QCoreApplication(*new QApplicationPrivate(argc, argv, type)) @@ -778,16 +765,16 @@ static int aargc = 1; static char *aargv[] = { (char*)"unknown", 0 }; /*! - \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap) + \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap) - Create an application, given an already open display \a display. If \a - visual and \a colormap are non-zero, the application will use those as - the default Visual and Colormap contexts. + 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. + \warning Qt only supports TrueColor visuals at depths higher than 8 + bits-per-pixel. - This is available only on X11. + This function is only available on X11. */ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap) : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient)) @@ -809,19 +796,18 @@ QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, } /*! - \fn QApplication::QApplication(Display *display, int &argc, char **argv, - Qt::HANDLE visual, Qt::HANDLE colormap) + \fn QApplication::QApplication(Display *display, int &argc, char **argv, + Qt::HANDLE visual, Qt::HANDLE colormap) - Create 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 as the default Visual - and Colormap contexts. + 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 is available only on X11. + \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) @@ -923,19 +909,18 @@ QApplication::Type QApplication::type() *****************************************************************************/ /*! - Returns the active popup widget. + Returns the active popup widget. - A popup widget is a special top-level widget that sets the \c - Qt::WType_Popup widget flag, e.g. the QMenu widget. When the - application opens a popup widget, all events are sent to the popup. - Normal widgets and modal widgets cannot be accessed before the popup - widget is closed. + A popup widget is a special top-level widget that sets the \c + Qt::WType_Popup widget flag, e.g. the QMenu widget. When the application + opens a popup widget, all events are sent to the popup. Normal widgets and + modal widgets cannot be accessed before the popup widget is closed. - Only other popup widgets may be opened when a popup widget is shown. - The popup widgets are organized in a stack. This function returns - the active popup widget at the top of the stack. + Only other popup widgets may be opened when a popup widget is shown. The + popup widgets are organized in a stack. This function returns the active + popup widget at the top of the stack. - \sa activeModalWidget(), topLevelWidgets() + \sa activeModalWidget(), topLevelWidgets() */ QWidget *QApplication::activePopupWidget() @@ -946,17 +931,17 @@ QWidget *QApplication::activePopupWidget() /*! - Returns the active modal widget. + Returns the active modal widget. - A modal widget is a special top-level widget which is a subclass of - QDialog that specifies the modal parameter of the constructor as - true. A modal widget must be closed before the user can continue - with other parts of the program. + A modal widget is a special top-level widget which is a subclass of QDialog + that specifies the modal parameter of the constructor as true. A modal + widget must be closed before the user can continue with other parts of the + program. - Modal widgets are organized in a stack. This function returns - the active modal widget at the top of the stack. + Modal widgets are organized in a stack. This function returns the active + modal widget at the top of the stack. - \sa activePopupWidget(), topLevelWidgets() + \sa activePopupWidget(), topLevelWidgets() */ QWidget *QApplication::activeModalWidget() @@ -965,8 +950,8 @@ QWidget *QApplication::activeModalWidget() } /*! - Cleans up any window system resources that were allocated by this - application. Sets the global variable \c qApp to 0. + Cleans up any window system resources that were allocated by this + application. Sets the global variable \c qApp to 0. */ QApplication::~QApplication() @@ -1092,8 +1077,8 @@ QApplication::~QApplication() /*! \fn QWidget *QApplication::widgetAt(const QPoint &point) - Returns the widget at global screen position \a point, or 0 if there - is no Qt widget there. + Returns the widget at global screen position \a point, or 0 if there is no + Qt widget there. This function can be slow. @@ -1141,8 +1126,8 @@ QWidget *QApplication::widgetAt(const QPoint &p) \overload - Returns the widget at global screen position (\a x, \a y), or 0 - if there is no Qt widget there. + Returns the widget at global screen position (\a x, \a y), or 0 if there is + no Qt widget there. */ /*! @@ -1211,16 +1196,17 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis \since 4.4 \brief defines a threshold for auto maximizing widgets - The auto maximize threshold is only available - as part of Qt for Windows CE. + The auto maximize threshold is only available as part of Qt for Windows CE. This property defines a threshold for the size of a window as a percentage - of the screen size. If the minimum size hint of a window exceeds the threshold, - calling show() will then cause the window to be maximized automatically. + of the screen size. If the minimum size hint of a window exceeds the + threshold, calling show() will then cause the window to be maximized + automatically. - Setting the threshold to be 100 or greater means that it will cause it to always - be maximized. Setting it to be 50 means that the widget is maximized if the vertical - minimum size hint is at least 50% of the vertical screen size. + Setting the threshold to be 100 or greater means that it will cause it to + always be maximized. Setting it to be 50 means that the widget is maximized + if the vertical minimum size hint is at least 50% of the vertical screen + size. If -1 is specified then this will disable the feature. @@ -1233,12 +1219,11 @@ bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventLis \since 4.5 \brief toggles automatic SIP (software input panel) visibility - The auto SIP property is only available - as part of Qt for Windows CE. + The auto SIP property is only available as part of Qt for Windows CE. Set this property to true to automatically display the SIP when entering - widgets that accept keyboard input. This only affects widgets that have the - attribute WA_InputMethodEnabled set. + widgets that accept keyboard input. This property only affects widgets with + the WA_InputMethodEnabled attribute set. */ #ifdef Q_OS_WINCE @@ -1290,9 +1275,9 @@ void QApplication::setStyleSheet(const QString& styleSheet) #endif // QT_NO_STYLE_STYLESHEET /*! - Returns the application's style object. + Returns the application's style object. - \sa setStyle(), QStyle + \sa setStyle(), QStyle */ QStyle *QApplication::style() { @@ -1375,22 +1360,21 @@ QStyle *QApplication::style() } /*! - Sets the application's GUI style to \a style. Ownership of the style - object is transferred to QApplication, so QApplication will delete - the style object on application exit or when a new style is set and - the old style is still the parent of the application object. + Sets the application's GUI style to \a style. Ownership of the style object + is transferred to QApplication, so QApplication will delete the style + object on application exit or when a new style is set and the old style is + still the parent of the application object. Example usage: \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 1 - When switching application styles, the color palette is set back to - the initial colors or the system defaults. This is necessary since - certain styles have to adapt the color palette to be fully - style-guide compliant. + When switching application styles, the color palette is set back to the + initial colors or the system defaults. This is necessary since certain + styles have to adapt the color palette to be fully style-guide compliant. - Note that setting the style before a palette has been set - (i.e. before creating QApplication) will cause the application to - use QStyle::standardPalette() for the palette. + Setting the style before a palette has been se, i.e., before creating + QApplication, will cause the application to use QStyle::standardPalette() + for the palette. \warning Qt style sheets are currently not supported for custom QStyle subclasses. We plan to address this in some future release. @@ -1493,20 +1477,20 @@ void QApplication::setStyle(QStyle *style) } /*! - \overload + \overload - Requests a QStyle object for \a style from the QStyleFactory. + Requests a QStyle object for \a style from the QStyleFactory. - The string must be one of the QStyleFactory::keys(), typically one - of "windows", "motif", "cde", "plastique", "windowsxp", or - "macintosh". Style names are case insensitive. + The string must be one of the QStyleFactory::keys(), typically one of + "windows", "motif", "cde", "plastique", "windowsxp", or "macintosh". Style + names are case insensitive. - Returns 0 if an unknown \a style is passed, otherwise the QStyle object - returned is set as the application's GUI style. + Returns 0 if an unknown \a style is passed, otherwise the QStyle object + returned is set as the application's GUI style. - \warning To ensure that the application's style is set correctly, it is - best to call this function before the QApplication constructor, if - possible. + \warning To ensure that the application's style is set correctly, it is + best to call this function before the QApplication constructor, if + possible. */ QStyle* QApplication::setStyle(const QString& style) { @@ -1519,20 +1503,19 @@ QStyle* QApplication::setStyle(const QString& style) } /*! - \since 4.5 + \since 4.5 - Sets the default graphics backend to \a system, which will be used - for on-screen widgets and QPixmaps. The available systems are - \c{"native"}, \c{"raster"} and \c{"opengl"}. + Sets the default graphics backend to \a system, which will be used for + on-screen widgets and QPixmaps. The available systems are \c{"native"}, + \c{"raster"} and \c{"opengl"}. - Note that this function call overrides both the application - commandline \c{-graphicssystem} switch and the configure - \c{-graphicssystem} switch. + This function call overrides both the application commandline + \c{-graphicssystem} switch and the configure \c{-graphicssystem} switch. - \warning This function must be called before the QApplication - constructor is called. + \warning This function must be called before the QApplication constructor + is called. - The \c{"opengl"} option is currently considered experimental. + \note The \c{"opengl"} option is currently experimental. */ void QApplication::setGraphicsSystem(const QString &system) @@ -1541,9 +1524,10 @@ void QApplication::setGraphicsSystem(const QString &system) } /*! - Returns the color specification. - \sa QApplication::setColorSpec() - */ + Returns the color specification. + + \sa QApplication::setColorSpec() +*/ int QApplication::colorSpec() { @@ -1551,54 +1535,54 @@ int QApplication::colorSpec() } /*! - Sets the color specification for the application to \a spec. - - The color specification controls how the application allocates colors - when run on a display with a limited amount of colors, e.g. 8 bit / 256 - color displays. - - The color specification must be set before you create the QApplication - object. - - The options are: - \list - \o QApplication::NormalColor. - This is the default color allocation strategy. Use this option if - your application uses buttons, menus, texts and pixmaps with few - colors. With this option, the application uses system global - colors. This works fine for most applications under X11, but on - Windows machines it may cause dithering of non-standard colors. - \o QApplication::CustomColor. - Use this option if your application needs a small number of custom - colors. On X11, this option is the same as NormalColor. On Windows, Qt - creates a Windows palette, and allocates colors to it on demand. - \o QApplication::ManyColor. - Use this option if your application is very color hungry - (e.g. it requires thousands of colors). - Under X11 the effect is: + Sets the color specification for the application to \a spec. + + The color specification controls how the application allocates colors when + run on a display with a limited amount of colors, e.g. 8 bit / 256 color + displays. + + The color specification must be set before you create the QApplication + object. + + The options are: \list - \o For 256-color displays which have at best a 256 color true - color visual, the default visual is used, and colors are - allocated from a color cube. The color cube is the 6x6x6 (216 - color) "Web palette" (the red, green, and blue components - always have one of the following values: 0x00, 0x33, 0x66, - 0x99, 0xCC, or 0xFF), but the number of colors can be changed - by the \e -ncols option. The user can force the application to - use the true color visual with the \link - QApplication::QApplication() -visual \endlink option. - \o For 256-color displays which have a true color visual with more - than 256 colors, use that visual. Silicon Graphics X servers - have this feature, for example. They provide an 8 bit visual - by default but can deliver true color when asked. + \o QApplication::NormalColor. This is the default color allocation + strategy. Use this option if your application uses buttons, menus, + texts and pixmaps with few colors. With this option, the + application uses system global colors. This works fine for most + applications under X11, but on Windows machines it may cause + dithering of non-standard colors. + \o QApplication::CustomColor. Use this option if your application + needs a small number of custom colors. On X11, this option is the + same as NormalColor. On Windows, Qt creates a Windows palette, and + allocates colors to it on demand. + \o QApplication::ManyColor. Use this option if your application is + very color hungry, e.g., it requires thousands of colors. \br + Under X11 the effect is: + \list + \o For 256-color displays which have at best a 256 color true + color visual, the default visual is used, and colors are + allocated from a color cube. The color cube is the 6x6x6 + (216 color) "Web palette" (the red, green, and blue + components always have one of the following values: 0x00, + 0x33, 0x66, 0x99, 0xCC, or 0xFF), but the number of colors + can be changed by the \e -ncols option. The user can force + the application to use the true color visual with the + \l{QApplication::QApplication()}{-visual} option. + \o For 256-color displays which have a true color visual with + more than 256 colors, use that visual. Silicon Graphics X + servers this feature, for example. They provide an 8 bit + visual by default but can deliver true color when asked. + \endlist + On Windows, Qt creates a Windows palette, and fills it with a color + cube. \endlist - On Windows, Qt creates a Windows palette, and fills it with a color cube. - \endlist - Be aware that the CustomColor and ManyColor choices may lead to colormap - flashing: The foreground application gets (most) of the available - colors, while the background windows will look less attractive. + Be aware that the CustomColor and ManyColor choices may lead to colormap + flashing: The foreground application gets (most) of the available colors, + while the background windows will look less attractive. - Example: + Example: \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 2 @@ -1618,10 +1602,9 @@ void QApplication::setColorSpec(int spec) \brief the minimum size that any GUI element that the user can interact with should have - For example, no button should be resized to be smaller than the - global strut size. The strut size should be considered when - reimplementing GUI controls that may be used on touch-screens or - similar I/O devices. + For example, no button should be resized to be smaller than the global + strut size. The strut size should be considered when reimplementing GUI + controls that may be used on touch-screens or similar I/O devices. Example: @@ -1655,12 +1638,11 @@ QPalette QApplication::palette() \fn QPalette QApplication::palette(const QWidget* widget) \overload - If a \a widget is passed, the default palette for the - widget's class is returned. This may or may not be the application - palette. In most cases there isn't a special palette for certain - types of widgets, but one notable exception is the popup menu - under Windows, if the user has defined a special background color - for menus in the display settings. + If a \a widget is passed, the default palette for the widget's class is + returned. This may or may not be the application palette. In most cases + there is no special palette for certain types of widgets, but one notable + exception is the popup menu under Windows, if the user has defined a + special background color for menus in the display settings. \sa setPalette(), QWidget::palette() */ @@ -1754,26 +1736,26 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* } /*! - Changes the default application palette to \a palette. + Changes the default application palette to \a palette. - If \a className is passed, the change applies only to widgets that - inherit \a className (as reported by QObject::inherits()). If - \a className is left 0, the change affects all widgets, thus overriding - any previously set class specific palettes. + If \a className is passed, the change applies only to widgets that inherit + \a className (as reported by QObject::inherits()). If \a className is left + 0, the change affects all widgets, thus overriding any previously set class + specific palettes. - The palette may be changed according to the current GUI style in - QStyle::polish(). + The palette may be changed according to the current GUI style in + QStyle::polish(). - \warning Do not use this function in conjunction with \l{Qt Style Sheets}. - When using style sheets, the palette of a widget can be customized using the "color", - "background-color", "selection-color", "selection-background-color" and - "alternate-background-color". + \warning Do not use this function in conjunction with \l{Qt Style Sheets}. + When using style sheets, the palette of a widget can be customized using + the "color", "background-color", "selection-color", + "selection-background-color" and "alternate-background-color". - Note that some styles do not use the palette for all drawing, - for instance, if they make use of native theme engines. This is - the case for the Windows XP, Windows Vista, and Mac OS X styles. + \note Some styles do not use the palette for all drawing, for instance, if + they make use of native theme engines. This is the case for the Windows XP, + Windows Vista, and Mac OS X styles. - \sa QWidget::setPalette(), palette(), QStyle::polish() + \sa QWidget::setPalette(), palette(), QStyle::polish() */ void QApplication::setPalette(const QPalette &palette, const char* className) @@ -1878,15 +1860,15 @@ QFont QApplication::font(const char *className) /*! - Changes the default application font to \a font. If \a className - is passed, the change applies only to classes that inherit \a - className (as reported by QObject::inherits()). + Changes the default application font to \a font. If \a className is passed, + the change applies only to classes that inherit \a className (as reported + by QObject::inherits()). - On application start-up, the default font depends on the window - system. It can vary depending on both the window system version and - the locale. This function lets you override the default font; but - overriding may be a bad idea because, for example, some locales need - extra large fonts to support their special characters. + On application start-up, the default font depends on the window system. It + can vary depending on both the window system version and the locale. This + function lets you override the default font; but overriding may be a bad + idea because, for example, some locales need extra large fonts to support + their special characters. \warning Do not use this function in conjunction with \l{Qt Style Sheets}. The font of an application can be customized using the "font" style sheet @@ -1988,11 +1970,10 @@ void QApplication::setWindowIcon(const QIcon &icon) } /*! - Returns a list of the top-level widgets (windows) in the - application. + Returns a list of the top-level widgets (windows) in the application. - Note that some of the top-level widgets may be hidden, for - example a tooltip if no tooltip is currently shown. + \note Some of the top-level widgets may be hidden, for example a tooltip if + no tooltip is currently shown. Example: @@ -2018,7 +1999,7 @@ QWidgetList QApplication::topLevelWidgets() The list is empty (QList::isEmpty()) if there are no widgets. - Note that some of the widgets may be hidden. + \note Some of the widgets may be hidden. Example: \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 5 @@ -2037,10 +2018,10 @@ QWidgetList QApplication::allWidgets() } /*! - Returns the application widget that has the keyboard input focus, or - 0 if no widget in this application has the focus. + Returns the application widget that has the keyboard input focus, or 0 if + no widget in this application has the focus. - \sa QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), focusChanged() + \sa QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), focusChanged() */ QWidget *QApplication::focusWidget() @@ -2121,12 +2102,12 @@ void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason) /*! - Returns the application top-level window that has the keyboard input - focus, or 0 if no application window has the focus. Note that - there might be an activeWindow() even if there is no focusWidget(), - for example if no widget in that window accepts key events. + Returns the application top-level window that has the keyboard input focus, + or 0 if no application window has the focus. There might be an + activeWindow() even if there is no focusWidget(), for example if no widget + in that window accepts key events. - \sa QWidget::setFocus(), QWidget::hasFocus(), focusWidget() + \sa QWidget::setFocus(), QWidget::hasFocus(), focusWidget() */ QWidget *QApplication::activeWindow() @@ -2135,9 +2116,9 @@ QWidget *QApplication::activeWindow() } /*! - Returns display (screen) font metrics for the application font. + Returns display (screen) font metrics for the application font. - \sa font(), setFont(), QWidget::fontMetrics(), QPainter::fontMetrics() + \sa font(), setFont(), QWidget::fontMetrics(), QPainter::fontMetrics() */ QFontMetrics QApplication::fontMetrics() @@ -2149,19 +2130,20 @@ QFontMetrics QApplication::fontMetrics() /*! Closes all top-level windows. - This function is particularly useful for applications with many - top-level windows. It could, for example, be connected to a - \gui{Exit} entry in the \gui{File} menu: + This function is particularly useful for applications with many top-level + windows. It could, for example, be connected to a \gui{Exit} entry in the + \gui{File} menu: \snippet examples/mainwindows/mdi/mainwindow.cpp 0 - The windows are closed in random order, until one window does not - accept the close event. The application quits when the last window - was successfully closed; this can be turned off by setting \l - quitOnLastWindowClosed to false. + The windows are closed in random order, until one window does not accept + the close event. The application quits when the last window was + successfully closed; this can be turned off by setting + \l quitOnLastWindowClosed to false. - \sa quitOnLastWindowClosed, lastWindowClosed() QWidget::close(), QWidget::closeEvent(), lastWindowClosed(), - quit(), topLevelWidgets(), QWidget::isWindow() + \sa quitOnLastWindowClosed, lastWindowClosed(), QWidget::close(), + QWidget::closeEvent(), lastWindowClosed(), quit(), topLevelWidgets(), + QWidget::isWindow() */ void QApplication::closeAllWindows() { @@ -2184,11 +2166,11 @@ void QApplication::closeAllWindows() } /*! - Displays a simple message box about Qt. The message includes the - version number of Qt being used by the application. + Displays a simple message box about Qt. The message includes the version + number of Qt being used by the application. - This is useful for inclusion in the \gui Help menu of an application, - as shown in the \l{mainwindows/menus}{Menus} example. + This is useful for inclusion in the \gui Help menu of an application, as + shown in the \l{mainwindows/menus}{Menus} example. This function is a convenience slot for QMessageBox::aboutQt(). */ @@ -2209,22 +2191,20 @@ void QApplication::aboutQt() /*! \fn void QApplication::lastWindowClosed() - This signal is emitted from QApplication::exec() when the last - visible primary window (i.e. window with no parent) with the - Qt::WA_QuitOnClose attribute set is closed. + This signal is emitted from QApplication::exec() when the last visible + primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose + attribute set is closed. By default, \list + \o this attribute is set for all widgets except transient windows such + as splash screens, tool windows, and popup menus - \i this attribute is set for all widgets except transient windows - such as splash screens, tool windows, and popup menus - - \i QApplication implicitly quits when this signal is emitted. - + \o QApplication implicitly quits when this signal is emitted. \endlist - This feature be turned off by setting \l quitOnLastWindowClosed to + This feature can be turned off by setting \l quitOnLastWindowClosed to false. \sa QWidget::close() @@ -2234,15 +2214,15 @@ void QApplication::aboutQt() \since 4.1 \fn void QApplication::focusChanged(QWidget *old, QWidget *now) - This signal is emitted when the widget that has keyboard focus - changed from \a old to \a now, i.e. because the user pressed the - tab-key, clicked into a widget or changed the active window. Note - that both \a old and \a now can be the null-pointer. + This signal is emitted when the widget that has keyboard focus changed from + \a old to \a now, i.e., because the user pressed the tab-key, clicked into + a widget or changed the active window. Both \a old and \a now can be the + null-pointer. - The signal is emitted after both widget have been notified about - the change through QFocusEvent. + The signal is emitted after both widget have been notified about the change + through QFocusEvent. - \sa QWidget::setFocus() QWidget::clearFocus() Qt::FocusReason + \sa QWidget::setFocus(), QWidget::clearFocus(), Qt::FocusReason */ /*! @@ -2251,10 +2231,10 @@ void QApplication::aboutQt() This signal is emitted when application fonts are loaded or removed. - \sa QFontDatabase::addApplicationFont() - \sa QFontDatabase::addApplicationFontFromData() - \sa QFontDatabase::removeAllApplicationFonts() - \sa QFontDatabase::removeApplicationFont() + \sa QFontDatabase::addApplicationFont(), + QFontDatabase::addApplicationFontFromData(), + QFontDatabase::removeAllApplicationFonts(), + QFontDatabase::removeApplicationFont() */ #ifndef QT_NO_TRANSLATION @@ -2351,18 +2331,17 @@ void QApplication::syncX() {} // do nothing \fn void QApplication::setActiveWindow(QWidget* active) Sets the active window to the \a active widget in response to a system - event. The function is called from the platform specific event - handlers. + event. The function is called from the platform specific event handlers. - \warning This function does \e not set the keyboard focus to the - active widget. Call QWidget::activateWindow() instead. + \warning This function does \e not set the keyboard focus to the active + widget. Call QWidget::activateWindow() instead. - It sets the activeWindow() and focusWidget() attributes and sends - proper \l{QEvent::WindowActivate}{WindowActivate}/\l{QEvent::WindowDeactivate}{WindowDeactivate} - and \l{QEvent::FocusIn}{FocusIn}/\l{QEvent::FocusOut}{FocusOut} events - to all appropriate widgets. The window will then be painted in - active state (e.g. cursors in line edits will blink), and it will - have tool tips enabled. + It sets the activeWindow() and focusWidget() attributes and sends proper + \l{QEvent::WindowActivate}{WindowActivate}/\l{QEvent::WindowDeactivate} + {WindowDeactivate} and \l{QEvent::FocusIn}{FocusIn}/\l{QEvent::FocusOut} + {FocusOut} events to all appropriate widgets. The window will then be + painted in active state (e.g. cursors in line edits will blink), and it + will have tool tips enabled. \sa activeWindow(), QWidget::activateWindow() */ @@ -2508,11 +2487,11 @@ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool } /*! - \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) - \internal + \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) + \internal - Creates the proper Enter/Leave event when widget \a enter is entered - and widget \a leave is left. + Creates the proper Enter/Leave event when widget \a enter is entered and + widget \a leave is left. */ #if defined(Q_WS_WIN) extern void qt_win_set_cursor(QWidget *, bool); @@ -3029,11 +3008,11 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) /*! Returns the desktop widget (also called the root window). - Note that the desktop may be composed of multiple screens, so it would be - incorrect, for example, to attempt to \e center some widget in the - desktop's geometry. QDesktopWidget has various functions for obtaining - useful geometries upon the desktop, such as QDesktopWidget::screenGeometry() - and QDesktopWidget::availableGeometry(). + The desktop may be composed of multiple screens, so it would be incorrect, + for example, to attempt to \e center some widget in the desktop's geometry. + QDesktopWidget has various functions for obtaining useful geometries upon + the desktop, such as QDesktopWidget::screenGeometry() and + QDesktopWidget::availableGeometry(). On X11, it is also possible to draw on the desktop. */ @@ -3048,10 +3027,10 @@ QDesktopWidget *QApplication::desktop() #ifndef QT_NO_CLIPBOARD /*! - Returns a pointer to the application global clipboard. + Returns a pointer to the application global clipboard. - \note The QApplication object should already be constructed before - accessing the clipboard. + \note The QApplication object should already be constructed before + accessing the clipboard. */ QClipboard *QApplication::clipboard() { @@ -3067,11 +3046,11 @@ QClipboard *QApplication::clipboard() #endif // QT_NO_CLIPBOARD /*! - Sets whether Qt should use the system's standard colors, fonts, - etc., to \a on. By default, this is true. + Sets whether Qt should use the system's standard colors, fonts, etc., to + \a on. By default, this is true. - This function must be called before creating the QApplication - object, like this: + This function must be called before creating the QApplication object, like + this: \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 6 @@ -3083,8 +3062,8 @@ void QApplication::setDesktopSettingsAware(bool on) } /*! - Returns true if Qt is set to use the system's standard colors, - fonts, etc.; otherwise returns false. The default is true. + Returns true if Qt is set to use the system's standard colors, fonts, etc.; + otherwise returns false. The default is true. \sa setDesktopSettingsAware() */ @@ -3094,17 +3073,17 @@ bool QApplication::desktopSettingsAware() } /*! - Returns the current state of the modifier keys on the keyboard. The - current state is updated sychronously as the event queue is emptied - of events that will spontaneously change the keyboard state - (QEvent::KeyPress and QEvent::KeyRelease events). + Returns the current state of the modifier keys on the keyboard. The current + state is updated sychronously as the event queue is emptied of events that + will spontaneously change the keyboard state (QEvent::KeyPress and + QEvent::KeyRelease events). - It should be noted this may not reflect the actual keys held on the - input device at the time of calling but rather the modifiers as - last reported in one of the above events. If no keys are being held - Qt::NoModifier is returned. + It should be noted this may not reflect the actual keys held on the input + device at the time of calling but rather the modifiers as last reported in + one of the above events. If no keys are being held Qt::NoModifier is + returned. - \sa mouseButtons() + \sa mouseButtons() */ Qt::KeyboardModifiers QApplication::keyboardModifiers() @@ -3113,17 +3092,17 @@ Qt::KeyboardModifiers QApplication::keyboardModifiers() } /*! - Returns the current state of the buttons on the mouse. The current - state is updated syncronously as the event queue is emptied of - events that will spontaneously change the mouse state - (QEvent::MouseButtonPress and QEvent::MouseButtonRelease events). + Returns the current state of the buttons on the mouse. The current state is + updated syncronously as the event queue is emptied of events that will + spontaneously change the mouse state (QEvent::MouseButtonPress and + QEvent::MouseButtonRelease events). - It should be noted this may not reflect the actual buttons held on - theinput device at the time of calling but rather the mouse buttons - as last reported in one of the above events. If no mouse buttons are - being held Qt::NoButton is returned. + It should be noted this may not reflect the actual buttons held on the + input device at the time of calling but rather the mouse buttons as last + reported in one of the above events. If no mouse buttons are being held + Qt::NoButton is returned. - \sa keyboardModifiers() + \sa keyboardModifiers() */ Qt::MouseButtons QApplication::mouseButtons() @@ -3132,43 +3111,40 @@ Qt::MouseButtons QApplication::mouseButtons() } /*! - \fn bool QApplication::isSessionRestored() const + \fn bool QApplication::isSessionRestored() const - Returns true if the application has been restored from an earlier - \link session.html session\endlink; otherwise returns false. + Returns true if the application has been restored from an earlier + \l{Session Management}{session}; otherwise returns false. - \sa sessionId(), commitData(), saveState() + \sa sessionId(), commitData(), saveState() */ /*! - \fn QString QApplication::sessionId() const + \fn QString QApplication::sessionId() const - Returns the current \link session.html session's\endlink identifier. + Returns the current \l{Session Management}{session's} identifier. - If the application has been restored from an earlier session, this - identifier is the same as it was in that previous session. + If the application has been restored from an earlier session, this + identifier is the same as it was in that previous session. The session + identifier is guaranteed to be unique both for different applications + and for different instances of the same application. - The session identifier is guaranteed to be unique both for different - applications and for different instances of the same application. - - \sa isSessionRestored(), sessionKey(), commitData(), saveState() - */ + \sa isSessionRestored(), sessionKey(), commitData(), saveState() +*/ /*! - \fn QString QApplication::sessionKey() const + \fn QString QApplication::sessionKey() const - Returns the session key in the current \link session.html - session\endlink. + Returns the session key in the current \l{Session Management}{session}. - If the application has been restored from an earlier session, this - key is the same as it was when the previous session ended. + If the application has been restored from an earlier session, this key is + the same as it was when the previous session ended. - The session key changes with every call of commitData() or - saveState(). + The session key changes with every call of commitData() or saveState(). - \sa isSessionRestored(), sessionId(), commitData(), saveState() - */ + \sa isSessionRestored(), sessionId(), commitData(), saveState() +*/ #ifndef QT_NO_SESSIONMANAGER bool QApplication::isSessionRestored() const { @@ -3191,59 +3167,57 @@ QString QApplication::sessionKey() const - - /*! - \since 4.2 - \fn void QApplication::commitDataRequest(QSessionManager &manager) + \since 4.2 + \fn void QApplication::commitDataRequest(QSessionManager &manager) - This signal deals with \link session.html session - management\endlink. It is emitted when the QSessionManager wants the - application to commit all its data. + This signal deals with \l{Session Management}{session management}. It is + emitted when the QSessionManager wants the application to commit all its + data. - Usually this means saving all open files, after getting - permission from the user. Furthermore you may want to provide a means - by which the user can cancel the shutdown. + Usually this means saving all open files, after getting permission from + the user. Furthermore you may want to provide a means by which the user + can cancel the shutdown. - Note that you should not exit the application when called. - Instead, the session manager may or may not do this afterwards, - depending on the context. + You should not exit the application within this signal. Instead, + the session manager may or may not do this afterwards, depending on the + context. - \warning Within this signal, no user interaction is possible, \e - unless you ask the \a manager for explicit permission. See - QSessionManager::allowsInteraction() and - QSessionManager::allowsErrorInteraction() for details and example - usage. + \warning Within this signal, no user interaction is possible, \e + unless you ask the \a manager for explicit permission. See + QSessionManager::allowsInteraction() and + QSessionManager::allowsErrorInteraction() for details and example + usage. - Note: You should use Qt::DirectConnection when connecting to this signal. + \note You should use Qt::DirectConnection when connecting to this signal. - \sa isSessionRestored(), sessionId(), saveState(), {Session Management} + \sa isSessionRestored(), sessionId(), saveState(), {Session Management} */ /*! - This function deals with \link session.html session - management\endlink. It is invoked when the QSessionManager wants the - application to commit all its data. + This function deals with \l{Session Management}{session management}. It is + invoked when the QSessionManager wants the application to commit all its + data. - Usually this means saving all open files, after getting - permission from the user. Furthermore you may want to provide a means - by which the user can cancel the shutdown. + Usually this means saving all open files, after getting permission from the + user. Furthermore you may want to provide a means by which the user can + cancel the shutdown. - Note that you should not exit the application within this function. - Instead, the session manager may or may not do this afterwards, - depending on the context. + You should not exit the application within this function. Instead, the + session manager may or may not do this afterwards, depending on the + context. - \warning Within this function, no user interaction is possible, \e - unless you ask the \a manager for explicit permission. See - QSessionManager::allowsInteraction() and - QSessionManager::allowsErrorInteraction() for details and example - usage. + \warning Within this function, no user interaction is possible, \e + unless you ask the \a manager for explicit permission. See + QSessionManager::allowsInteraction() and + QSessionManager::allowsErrorInteraction() for details and example + usage. - The default implementation requests interaction and sends a close - event to all visible top-level widgets. If any event was - rejected, the shutdown is canceled. + The default implementation requests interaction and sends a close event to + all visible top-level widgets. If any event was rejected, the shutdown is + canceled. - \sa isSessionRestored(), sessionId(), saveState(), {Session Management} + \sa isSessionRestored(), sessionId(), saveState(), {Session Management} */ #ifndef QT_NO_SESSIONMANAGER void QApplication::commitData(QSessionManager& manager ) @@ -3269,58 +3243,54 @@ void QApplication::commitData(QSessionManager& manager ) } /*! - \since 4.2 - \fn void QApplication::saveStateRequest(QSessionManager &manager) + \since 4.2 + \fn void QApplication::saveStateRequest(QSessionManager &manager) - This signal deals with \link session.html session - management\endlink. It is invoked when the - \link QSessionManager session manager \endlink wants the application - to preserve its state for a future session. + This signal deals with \l{Session Management}{session management}. It is + invoked when the \l{QSessionManager}{session manager} wants the application + to preserve its state for a future session. - For example, a text editor would create a temporary file that - includes the current contents of its edit buffers, the location of - the cursor and other aspects of the current editing session. + For example, a text editor would create a temporary file that includes the + current contents of its edit buffers, the location of the cursor and other + aspects of the current editing session. - Note that you should never exit the application within this - signal. Instead, the session manager may or may not do this - afterwards, depending on the context. Futhermore, most session - managers will very likely request a saved state immediately after - the application has been started. This permits the session manager - to learn about the application's restart policy. + You should never exit the application within this signal. Instead, the + session manager may or may not do this afterwards, depending on the + context. Futhermore, most session managers will very likely request a saved + state immediately after the application has been started. This permits the + session manager to learn about the application's restart policy. - \warning Within this function, no user interaction is possible, \e - unless you ask the \a manager for explicit permission. See - QSessionManager::allowsInteraction() and - QSessionManager::allowsErrorInteraction() for details. + \warning Within this function, no user interaction is possible, \e + unless you ask the \a manager for explicit permission. See + QSessionManager::allowsInteraction() and + QSessionManager::allowsErrorInteraction() for details. - Note:: You should use Qt::DirectConnection when connecting to this signal. + \note You should use Qt::DirectConnection when connecting to this signal. - \sa isSessionRestored(), sessionId(), commitData(), {Session Management} + \sa isSessionRestored(), sessionId(), commitData(), {Session Management} */ /*! - This function deals with \link session.html session - management\endlink. It is invoked when the - \link QSessionManager session manager \endlink wants the application - to preserve its state for a future session. + This function deals with \l{Session Management}{session management}. It is + invoked when the \l{QSessionManager}{session manager} wants the application + to preserve its state for a future session. - For example, a text editor would create a temporary file that - includes the current contents of its edit buffers, the location of - the cursor and other aspects of the current editing session. + For example, a text editor would create a temporary file that includes the + current contents of its edit buffers, the location of the cursor and other + aspects of the current editing session. - Note that you should never exit the application within this - function. Instead, the session manager may or may not do this - afterwards, depending on the context. Futhermore, most session - managers will very likely request a saved state immediately after - the application has been started. This permits the session manager - to learn about the application's restart policy. + You should never exit the application within this function. Instead, the + session manager may or may not do this afterwards, depending on the + context. Futhermore, most session managers will very likely request a saved + state immediately after the application has been started. This permits the + session manager to learn about the application's restart policy. - \warning Within this function, no user interaction is possible, \e - unless you ask the \a manager for explicit permission. See - QSessionManager::allowsInteraction() and - QSessionManager::allowsErrorInteraction() for details. + \warning Within this function, no user interaction is possible, \e + unless you ask the \a manager for explicit permission. See + QSessionManager::allowsInteraction() and + QSessionManager::allowsErrorInteraction() for details. - \sa isSessionRestored(), sessionId(), commitData(), {Session Management} + \sa isSessionRestored(), sessionId(), commitData(), {Session Management} */ void QApplication::saveState(QSessionManager &manager) @@ -3344,13 +3314,12 @@ void QApplication::setStartDragTime(int ms) \brief the time in milliseconds that a mouse button must be held down before a drag and drop operation will begin - If you support drag and drop in your application, and want to start a - drag and drop operation after the user has held down a mouse button for - a certain amount of time, you should use this property's value as the - delay. + If you support drag and drop in your application, and want to start a drag + and drop operation after the user has held down a mouse button for a + certain amount of time, you should use this property's value as the delay. - Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, - for starting a drag. + Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, for + starting a drag. The default value is 500 ms. @@ -3363,9 +3332,9 @@ int QApplication::startDragTime() } /* - Sets the distance after which a drag should start to \a l pixels. + Sets the distance after which a drag should start to \a l pixels. - \sa startDragDistance() + \sa startDragDistance() */ void QApplication::setStartDragDistance(int l) @@ -3376,15 +3345,14 @@ void QApplication::setStartDragDistance(int l) /*! \property QApplication::startDragDistance - If you support drag and drop in your application, and want to start a - drag and drop operation after the user has moved the cursor a certain - distance with a button held down, you should use this property's value - as the minimum distance required. + If you support drag and drop in your application, and want to start a drag + and drop operation after the user has moved the cursor a certain distance + with a button held down, you should use this property's value as the + minimum distance required. - For example, if the mouse position of the click is stored in \c - startPos and the current position (e.g. in the mouse move event) is - \c currentPos, you can find out if a drag should be started with code - like this: + For example, if the mouse position of the click is stored in \c startPos + and the current position (e.g. in the mouse move event) is \c currentPos, + you can find out if a drag should be started with code like this: \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 7 @@ -3430,14 +3398,14 @@ int QApplication::startDragDistance() \sa layoutDirection(), isRightToLeft() */ -/*! \property QApplication::layoutDirection - - \brief the default layout direction for this application +/*! + \property QApplication::layoutDirection + \brief the default layout direction for this application - On system start-up, the default layout direction depends on the - application's language. + On system start-up, the default layout direction depends on the + application's language. - \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft() + \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft() */ void QApplication::setLayoutDirection(Qt::LayoutDirection direction) @@ -3461,11 +3429,12 @@ Qt::LayoutDirection QApplication::layoutDirection() } -/*! \obsolete +/*! + \obsolete - Strips out vertical alignment flags and transforms an - alignment \a align of Qt::AlignLeft into Qt::AlignLeft or - Qt::AlignRight according to the language used. + Strips out vertical alignment flags and transforms an alignment \a align + of Qt::AlignLeft into Qt::AlignLeft or Qt::AlignRight according to the + language used. */ #ifdef QT3_SUPPORT @@ -3481,8 +3450,8 @@ Qt::Alignment QApplication::horizontalAlignment(Qt::Alignment align) Returns the active application override cursor. - This function returns 0 if no application cursor has been defined - (i.e. the internal cursor stack is empty). + This function returns 0 if no application cursor has been defined (i.e. the + internal cursor stack is empty). \sa setOverrideCursor(), restoreOverrideCursor() */ @@ -3495,9 +3464,10 @@ QCursor *QApplication::overrideCursor() /*! Changes the currently active application override cursor to \a cursor. - This function has no effect if setOverrideCursor() wasn't called. + This function has no effect if setOverrideCursor() was not called. - \sa setOverrideCursor() overrideCursor() restoreOverrideCursor() QWidget::setCursor() + \sa setOverrideCursor(), overrideCursor(), restoreOverrideCursor(), + QWidget::setCursor() */ void QApplication::changeOverrideCursor(const QCursor &cursor) { @@ -3511,8 +3481,8 @@ void QApplication::changeOverrideCursor(const QCursor &cursor) /*! \fn void QApplication::setOverrideCursor(const QCursor &cursor, bool replace) - Use changeOverrideCursor(\a cursor) (if \a replace is true) - or setOverrideCursor(\a cursor) (if \a replace is false). + Use changeOverrideCursor(\a cursor) (if \a replace is true) or + setOverrideCursor(\a cursor) (if \a replace is false). */ /*! @@ -3520,29 +3490,26 @@ void QApplication::changeOverrideCursor(const QCursor &cursor) the value that was set to exit() (which is 0 if exit() is called via quit()). - It is necessary to call this function to start event handling. The - main event loop receives events from the window system and - dispatches these to the application widgets. + It is necessary to call this function to start event handling. The main + event loop receives events from the window system and dispatches these to + the application widgets. + + Generally, no user interaction can take place before calling exec(). As a + special case, modal widgets like QMessageBox can be used before calling + exec(), because modal widgets call exec() to start a local event loop. - Generally speaking, no user interaction can take place before - calling exec(). As a special case, modal widgets like QMessageBox - can be used before calling exec(), because modal widgets call - exec() to start a local event loop. - - To make your application perform idle processing, i.e. executing a - special function whenever there are no pending events, use a - QTimer with 0 timeout. More advanced idle processing schemes can - be achieved using processEvents(). + To make your application perform idle processing, i.e., executing a special + function whenever there are no pending events, use a QTimer with 0 timeout. + More advanced idle processing schemes can be achieved using processEvents(). We recommend that you connect clean-up code to the - \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in - your application's \c{main()} function because on some platforms the - QApplication::exec() call may not return. For example, on Windows - when the user logs off, the system terminates the process after Qt - closes all top-level windows. Hence, there is no guarantee that the - application will have time to exit its event loop and execute code at - the end of the \c{main()} function after the QApplication::exec() - call. + \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your + application's \c{main()} function because on some platforms the + QApplication::exec() call may not return. For example, on Windows when the + user logs off, the system terminates the process after Qt closes all + top-level windows. Hence, there is no guarantee that the application will + have time to exit its event loop and execute code at the end of the + \c{main()} function after the QApplication::exec() call. \sa quitOnLastWindowClosed, quit(), exit(), processEvents(), QCoreApplication::exec() @@ -4090,101 +4057,98 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) /*! - \class QSessionManager - \brief The QSessionManager class provides access to the session manager. - - \ingroup application - \ingroup environment - - A session manager in a desktop environment (in which Qt GUI - applications live) keeps track of a session, which is a group of - running applications, each of which has a particular state. The - state of an application contains (most notably) the documents the - application has open and the position and size of its windows. - - The session manager is used to save the session, e.g. when the - machine is shut down, and to restore a session, e.g. when the - machine is started up. We recommend that you use QSettings to save - an individual application's settings, e.g. window positions, - recently used files, etc. When the application is restarted by the - session manager, you can restore the settings. - - QSessionManager provides an interface between the application - and the session manager so that the program can work well with the - session manager. In Qt, session management requests for action are - handled by the two virtual functions QApplication::commitData() - and QApplication::saveState(). Both provide a reference to a - session manager object as argument, to allow the application to - communicate with the session manager. The session manager can only - be accessed through these functions. - - No user interaction is possible \e unless the application gets - explicit permission from the session manager. You ask for permission - by calling allowsInteraction() or, if it's really urgent, - allowsErrorInteraction(). Qt does not enforce this, but the session - manager may. - - You can try to abort the shutdown process by calling cancel(). The - default commitData() function does this if some top-level window - rejected its closeEvent(). - - For sophisticated session managers provided on Unix/X11, QSessionManager - offers further possibilities to fine-tune an application's session - management behavior: setRestartCommand(), setDiscardCommand(), - setRestartHint(), setProperty(), requestPhase2(). See the respective - function descriptions for further details. - - \sa QApplication, {Session Management} + \class QSessionManager + \brief The QSessionManager class provides access to the session manager. + + \ingroup application + \ingroup environment + + A session manager in a desktop environment (in which Qt GUI applications + live) keeps track of a session, which is a group of running applications, + each of which has a particular state. The state of an application contains + (most notably) the documents the application has open and the position and + size of its windows. + + The session manager is used to save the session, e.g., when the machine is + shut down, and to restore a session, e.g., when the machine is started up. + We recommend that you use QSettings to save an application's settings, + for example, window positions, recently used files, etc. When the + application is restarted by the session manager, you can restore the + settings. + + QSessionManager provides an interface between the application and the + session manager so that the program can work well with the session manager. + In Qt, session management requests for action are handled by the two + virtual functions QApplication::commitData() and QApplication::saveState(). + Both provide a reference to a session manager object as argument, to allow + the application to communicate with the session manager. The session + manager can only be accessed through these functions. + + No user interaction is possible \e unless the application gets explicit + permission from the session manager. You ask for permission by calling + allowsInteraction() or, if it is really urgent, allowsErrorInteraction(). + Qt does not enforce this, but the session manager may. + + You can try to abort the shutdown process by calling cancel(). The default + commitData() function does this if some top-level window rejected its + closeEvent(). + + For sophisticated session managers provided on Unix/X11, QSessionManager + offers further possibilities to fine-tune an application's session + management behavior: setRestartCommand(), setDiscardCommand(), + setRestartHint(), setProperty(), requestPhase2(). See the respective + function descriptions for further details. + + \sa QApplication, {Session Management} */ /*! \enum QSessionManager::RestartHint - This enum type defines the circumstances under which this - application wants to be restarted by the session manager. The - current values are + This enum type defines the circumstances under which this application wants + to be restarted by the session manager. The current values are: - \value RestartIfRunning if the application is still running when - the session is shut down, it wants to be restarted at the start of - the next session. + \value RestartIfRunning If the application is still running when the + session is shut down, it wants to be restarted + at the start of the next session. - \value RestartAnyway the application wants to be started at the - start of the next session, no matter what. (This is useful for - utilities that run just after startup and then quit.) + \value RestartAnyway The application wants to be started at the + start of the next session, no matter what. + (This is useful for utilities that run just + after startup and then quit.) - \value RestartImmediately the application wants to be started - immediately whenever it is not running. + \value RestartImmediately The application wants to be started immediately + whenever it is not running. - \value RestartNever the application does not want to be restarted - automatically. + \value RestartNever The application does not want to be restarted + automatically. - The default hint is \c RestartIfRunning. + The default hint is \c RestartIfRunning. */ /*! - \fn QString QSessionManager::sessionId() const + \fn QString QSessionManager::sessionId() const - Returns the identifier of the current session. + Returns the identifier of the current session. - If the application has been restored from an earlier session, this - identifier is the same as it was in that earlier session. + If the application has been restored from an earlier session, this + identifier is the same as it was in the earlier session. - \sa sessionKey(), QApplication::sessionId() - */ + \sa sessionKey(), QApplication::sessionId() +*/ /*! - \fn QString QSessionManager::sessionKey() const + \fn QString QSessionManager::sessionKey() const - Returns the session key in the current session. + Returns the session key in the current session. - If the application has been restored from an earlier session, this - key is the same as it was when the previous session ended. + If the application has been restored from an earlier session, this key is + the same as it was when the previous session ended. - The session key changes with every call of commitData() or - saveState(). + The session key changes with every call of commitData() or saveState(). - \sa sessionId(), QApplication::sessionKey() - */ + \sa sessionId(), QApplication::sessionKey() +*/ /*! \fn void* QSessionManager::handle() const @@ -4193,120 +4157,116 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) */ /*! - \fn bool QSessionManager::allowsInteraction() + \fn bool QSessionManager::allowsInteraction() - Asks the session manager for permission to interact with the - user. Returns true if interaction is permitted; otherwise - returns false. + Asks the session manager for permission to interact with the user. Returns + true if interaction is permitted; otherwise returns false. - The rationale behind this mechanism is to make it possible to - synchronize user interaction during a shutdown. Advanced session - managers may ask all applications simultaneously to commit their - data, resulting in a much faster shutdown. + The rationale behind this mechanism is to make it possible to synchronize + user interaction during a shutdown. Advanced session managers may ask all + applications simultaneously to commit their data, resulting in a much + faster shutdown. - When the interaction is completed we strongly recommend releasing the - user interaction semaphore with a call to release(). This way, other - applications may get the chance to interact with the user while your - application is still busy saving data. (The semaphore is implicitly - released when the application exits.) + When the interaction is completed we strongly recommend releasing the user + interaction semaphore with a call to release(). This way, other + applications may get the chance to interact with the user while your + application is still busy saving data. (The semaphore is implicitly + released when the application exits.) - If the user decides to cancel the shutdown process during the - interaction phase, you must tell the session manager that this has - happened by calling cancel(). + If the user decides to cancel the shutdown process during the interaction + phase, you must tell the session manager that this has happened by calling + cancel(). - Here's an example of how an application's QApplication::commitData() - might be implemented: + Here's an example of how an application's QApplication::commitData() might + be implemented: - \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 8 + \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 8 - If an error occurred within the application while saving its data, - you may want to try allowsErrorInteraction() instead. + If an error occurred within the application while saving its data, you may + want to try allowsErrorInteraction() instead. - \sa QApplication::commitData(), release(), cancel() + \sa QApplication::commitData(), release(), cancel() */ /*! - \fn bool QSessionManager::allowsErrorInteraction() + \fn bool QSessionManager::allowsErrorInteraction() - Returns true if error interaction is permitted; otherwise returns false. + Returns true if error interaction is permitted; otherwise returns false. - This is similar to allowsInteraction(), but also enables the application - to tell the user about any errors that occur. Session managers - may give error interaction requests higher priority, which means that it - is more likely that an error interaction is permitted. However, you are - still not guaranteed that the session manager will allow interaction. + This is similar to allowsInteraction(), but also enables the application to + tell the user about any errors that occur. Session managers may give error + interaction requests higher priority, which means that it is more likely + that an error interaction is permitted. However, you are still not + guaranteed that the session manager will allow interaction. - \sa allowsInteraction(), release(), cancel() + \sa allowsInteraction(), release(), cancel() */ /*! - \fn void QSessionManager::release() + \fn void QSessionManager::release() - Releases the session manager's interaction semaphore after an - interaction phase. + Releases the session manager's interaction semaphore after an interaction + phase. - \sa allowsInteraction(), allowsErrorInteraction() + \sa allowsInteraction(), allowsErrorInteraction() */ /*! - \fn void QSessionManager::cancel() - - Tells the session manager to cancel the shutdown process. Applications - should not call this function without first asking the user. + \fn void QSessionManager::cancel() - \sa allowsInteraction(), allowsErrorInteraction() + Tells the session manager to cancel the shutdown process. Applications + should not call this function without asking the user first. + \sa allowsInteraction(), allowsErrorInteraction() */ /*! - \fn void QSessionManager::setRestartHint(RestartHint hint) + \fn void QSessionManager::setRestartHint(RestartHint hint) - Sets the application's restart hint to \a hint. On application - startup the hint is set to \c RestartIfRunning. + Sets the application's restart hint to \a hint. On application startup, the + hint is set to \c RestartIfRunning. - Note that these flags are only hints, a session manager may or may - not respect them. + \note These flags are only hints, a session manager may or may not respect + them. - We recommend setting the restart hint in QApplication::saveState() - because most session managers perform a checkpoint shortly after an - application's startup. + We recommend setting the restart hint in QApplication::saveState() because + most session managers perform a checkpoint shortly after an application's + startup. - \sa restartHint() + \sa restartHint() */ /*! - \fn QSessionManager::RestartHint QSessionManager::restartHint() const + \fn QSessionManager::RestartHint QSessionManager::restartHint() const - Returns the application's current restart hint. The default is - \c RestartIfRunning. + Returns the application's current restart hint. The default is + \c RestartIfRunning. - \sa setRestartHint() + \sa setRestartHint() */ /*! - \fn void QSessionManager::setRestartCommand(const QStringList& command) + \fn void QSessionManager::setRestartCommand(const QStringList& command) - If the session manager is capable of restoring sessions it will - execute \a command in order to restore the application. The command - defaults to + If the session manager is capable of restoring sessions it will execute + \a command in order to restore the application. The command defaults to \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 9 - The \c -session option is mandatory; otherwise QApplication cannot - tell whether it has been restored or what the current session - identifier is. See QApplication::isSessionRestored() and - QApplication::sessionId() for details. + The \c -session option is mandatory; otherwise QApplication cannot tell + whether it has been restored or what the current session identifier is. + See QApplication::isSessionRestored() and QApplication::sessionId() for + details. - If your application is very simple, it may be possible to store the - entire application state in additional command line options. This - is usually a very bad idea because command lines are often limited - to a few hundred bytes. Instead, use QSettings, or temporary files - or a database for this purpose. By marking the data with the unique - sessionId(), you will be able to restore the application in a future - session. + If your application is very simple, it may be possible to store the entire + application state in additional command line options. This is usually a + very bad idea because command lines are often limited to a few hundred + bytes. Instead, use QSettings, temporary files, or a database for this + purpose. By marking the data with the unique sessionId(), you will be able + to restore the application in a future session. - \sa restartCommand(), setDiscardCommand(), setRestartHint() + \sa restartCommand(), setDiscardCommand(), setRestartHint() */ /*! @@ -4314,8 +4274,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) Returns the currently set restart command. - To iterate over the list, you can use the \l foreach - pseudo-keyword: + To iterate over the list, you can use the \l foreach pseudo-keyword: \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 10 @@ -4323,11 +4282,11 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) */ /*! - \fn void QSessionManager::setDiscardCommand(const QStringList& list) + \fn void QSessionManager::setDiscardCommand(const QStringList& list) - Sets the discard command to the given \a list. + Sets the discard command to the given \a list. - \sa discardCommand(), setRestartCommand() + \sa discardCommand(), setRestartCommand() */ @@ -4336,8 +4295,7 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) Returns the currently set discard command. - To iterate over the list, you can use the \l foreach - pseudo-keyword: + To iterate over the list, you can use the \l foreach pseudo-keyword: \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 11 @@ -4345,53 +4303,51 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) */ /*! - \fn void QSessionManager::setManagerProperty(const QString &name, const QString &value) - \overload + \fn void QSessionManager::setManagerProperty(const QString &name, const QString &value) + \overload - Low-level write access to the application's identification and state - records are kept in the session manager. + Low-level write access to the application's identification and state + records are kept in the session manager. - The property called \a name has its value set to the string \a value. + The property called \a name has its value set to the string \a value. */ /*! - \fn void QSessionManager::setManagerProperty(const QString& name, - const QStringList& value) + \fn void QSessionManager::setManagerProperty(const QString& name, + const QStringList& value) - Low-level write access to the application's identification and state - record are kept in the session manager. + Low-level write access to the application's identification and state record + are kept in the session manager. - The property called \a name has its value set to the string list \a value. + The property called \a name has its value set to the string list \a value. */ /*! - \fn bool QSessionManager::isPhase2() const + \fn bool QSessionManager::isPhase2() const - Returns true if the session manager is currently performing a second - session management phase; otherwise returns false. + Returns true if the session manager is currently performing a second + session management phase; otherwise returns false. - \sa requestPhase2() + \sa requestPhase2() */ /*! - \fn void QSessionManager::requestPhase2() + \fn void QSessionManager::requestPhase2() - Requests a second session management phase for the application. The - application may then return immediately from the - QApplication::commitData() or QApplication::saveState() function, - and they will be called again once most or all other applications have - finished their session management. + Requests a second session management phase for the application. The + application may then return immediately from the QApplication::commitData() + or QApplication::saveState() function, and they will be called again once + most or all other applications have finished their session management. - The two phases are useful for applications such as the X11 window manager - that need to store information about another application's windows - and therefore have to wait until these applications have completed their - respective session management tasks. + The two phases are useful for applications such as the X11 window manager + that need to store information about another application's windows and + therefore have to wait until these applications have completed their + respective session management tasks. - Note that if another application has requested a second phase it - may get called before, simultaneously with, or after your - application's second phase. + \note If another application has requested a second phase it may get called + before, simultaneously with, or after your application's second phase. - \sa isPhase2() + \sa isPhase2() */ /***************************************************************************** @@ -4584,15 +4540,14 @@ void QSessionManager::requestPhase2() /*! \fn bool QApplication::hasGlobalMouseTracking() - This feature does not exist anymore. This function - always returns true in Qt 4. + This feature does not exist anymore. This function always returns true + in Qt 4. */ /*! \fn void QApplication::setGlobalMouseTracking(bool dummy) - This function does nothing in Qt 4. The \a dummy parameter - is ignored. + This function does nothing in Qt 4. The \a dummy parameter is ignored. */ /*! @@ -4630,15 +4585,14 @@ void QSessionManager::requestPhase2() /*! \fn const QColor &QApplication::winStyleHighlightColor() - Use qApp->palette().color(QPalette::Active, QPalette::Highlight) - instead. + Use qApp->palette().color(QPalette::Active, QPalette::Highlight) instead. */ /*! \fn QWidget *QApplication::widgetAt(int x, int y, bool child) - Use the two-argument widgetAt() overload to get the child widget. - To get the top-level widget do this: + Use the two-argument widgetAt() overload to get the child widget. To get + the top-level widget do this: \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 12 */ @@ -4646,8 +4600,8 @@ void QSessionManager::requestPhase2() /*! \fn QWidget *QApplication::widgetAt(const QPoint &point, bool child) - Use the single-argument widgetAt() overload to get the child widget. - To get the top-level widget do this: + Use the single-argument widgetAt() overload to get the child widget. To get + the top-level widget do this: \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 13 */ @@ -4719,10 +4673,9 @@ void QApplicationPrivate::emitLastWindowClosed() Sets whether Qt should use focus navigation suitable for use with a minimal keypad. - If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to - change focus. + If \a enable is true, Qt::Key_Up and Qt::Key_Down are used to change focus. - This feature is only available in Qt for Embedded Linux. + This feature is available in Qt for Embedded Linux only. \sa keypadNavigationEnabled() */ @@ -4735,7 +4688,8 @@ void QApplication::setKeypadNavigationEnabled(bool enable) Returns true if Qt is set to use keypad navigation; otherwise returns false. The default is false. - This feature is only available in Qt for Embedded Linux. + This feature is available in Qt for Embedded Linux only. + \sa setKeypadNavigationEnabled() */ bool QApplication::keypadNavigationEnabled() @@ -4758,12 +4712,12 @@ bool QApplication::keypadNavigationEnabled() On Mac OS X, this works more at the application level and will cause the application icon to bounce in the dock. - On Windows this causes the window's taskbar entry to flash for a time. If \a - msec is zero, the flashing will stop and the taskbar entry will turn a + On Windows this causes the window's taskbar entry to flash for a time. If + \a msec is zero, the flashing will stop and the taskbar entry will turn a different color (currently orange). - On X11, this will cause the window to be marked as "demands attention", - the window must not be hidden (i.e. not have hide() called on it, but be + On X11, this will cause the window to be marked as "demands attention", the + window must not be hidden (i.e. not have hide() called on it, but be visible in some sort of way) in order for this to work. */ @@ -4771,18 +4725,16 @@ bool QApplication::keypadNavigationEnabled() \property QApplication::cursorFlashTime \brief the text cursor's flash (blink) time in milliseconds - The flash time is the time required to display, invert and - restore the caret display. Usually the text cursor is displayed - for half the cursor flash time, then hidden for the same amount - of time, but this may vary. + The flash time is the time required to display, invert and restore the + caret display. Usually the text cursor is displayed for half the cursor + flash time, then hidden for the same amount of time, but this may vary. - The default value on X11 is 1000 milliseconds. On Windows, the - control panel value is used. Widgets should not cache this value - since it may be changed at any time by the user changing the - global desktop settings. + The default value on X11 is 1000 milliseconds. On Windows, the control + panel value is used. Widgets should not cache this value since it may be + changed at any time by the user changing the global desktop settings. - Note that on Microsoft Windows, setting this property sets the - cursor flash time for all applications. + \note On Microsoft Windows, setting this property sets the cursor flash + time for all applications. */ /*! @@ -4790,11 +4742,11 @@ bool QApplication::keypadNavigationEnabled() \brief the time limit in milliseconds that distinguishes a double click from two consecutive mouse clicks - The default value on X11 is 400 milliseconds. On Windows and Mac - OS X, the operating system's value is used. + The default value on X11 is 400 milliseconds. On Windows and Mac OS X, the + operating system's value is used. - On Microsoft Windows, calling this function sets the - double click interval for all applications. + On Microsoft Windows, calling this function sets the double click interval + for all applications. */ /*! @@ -4812,15 +4764,13 @@ bool QApplication::keypadNavigationEnabled() \brief the number of lines to scroll a widget, when the mouse wheel is rotated. - If the value exceeds the widget's number of visible lines, the - widget should interpret the scroll operation as a single \e{page - up} or \e{page down}. If the widget is an \l{QAbstractItemView} - {item view class}, then the result of scrolling one \e line - depends on the setting of the widget's - \l{QAbstractItemView::verticalScrollMode()} {scroll mode}. Scroll - one \e line can mean \l{QAbstractItemView::ScrollPerItem} {scroll - one item} or \l{QAbstractItemView::ScrollPerPixel} {scroll one - pixel}. + If the value exceeds the widget's number of visible lines, the widget + should interpret the scroll operation as a single \e{page up} or + \e{page down}. If the widget is an \l{QAbstractItemView}{item view class}, + then the result of scrolling one \e line depends on the setting of the + widget's \l{QAbstractItemView::verticalScrollMode()}{scroll mode}. Scroll + one \e line can mean \l{QAbstractItemView::ScrollPerItem}{scroll one item} + or \l{QAbstractItemView::ScrollPerPixel}{scroll one pixel}. By default, this property has a value of 3. */ @@ -4828,11 +4778,11 @@ bool QApplication::keypadNavigationEnabled() /*! \fn void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable) - Enables the UI effect \a effect if \a enable is true, otherwise - the effect will not be used. + Enables the UI effect \a effect if \a enable is true, otherwise the effect + will not be used. - Note: All effects are disabled on screens running at less than - 16-bit color depth. + \note All effects are disabled on screens running at less than 16-bit color + depth. \sa isEffectEnabled(), Qt::UIEffect, setDesktopSettingsAware() */ @@ -4842,11 +4792,11 @@ bool QApplication::keypadNavigationEnabled() Returns true if \a effect is enabled; otherwise returns false. - By default, Qt will try to use the desktop settings. Call - setDesktopSettingsAware(false) to prevent this. + By default, Qt will try to use the desktop settings. To prevent this, call + setDesktopSettingsAware(false). - Note: All effects are disabled on screens running at less than - 16-bit color depth. + \note All effects are disabled on screens running at less than 16-bit color + depth. \sa setEffectEnabled(), Qt::UIEffect */ @@ -4854,8 +4804,7 @@ bool QApplication::keypadNavigationEnabled() /*! \fn QWidget *QApplication::mainWidget() - Returns the main application widget, or 0 if there is no main - widget. + Returns the main application widget, or 0 if there is no main widget. */ /*! @@ -4863,19 +4812,17 @@ bool QApplication::keypadNavigationEnabled() Sets the application's main widget to \a mainWidget. - In most respects the main widget is like any other widget, except - that if it is closed, the application exits. Note that - QApplication does \e not take ownership of the \a mainWidget, so - if you create your main widget on the heap you must delete it - yourself. + In most respects the main widget is like any other widget, except that if + it is closed, the application exits. QApplication does \e not take + ownership of the \a mainWidget, so if you create your main widget on the + heap you must delete it yourself. - You need not have a main widget; connecting lastWindowClosed() to - quit() is an alternative. + You need not have a main widget; connecting lastWindowClosed() to quit() + is an alternative. - For X11, this function also resizes and moves the main widget - according to the \e -geometry command-line option, so you should - set the default geometry (using \l QWidget::setGeometry()) before - calling setMainWidget(). + For X11, this function also resizes and moves the main widget according + to the \e -geometry command-line option, so you should set the default + geometry (using \l QWidget::setGeometry()) before calling setMainWidget(). \sa mainWidget(), exec(), quit() */ @@ -4883,8 +4830,8 @@ bool QApplication::keypadNavigationEnabled() /*! \fn void QApplication::beep() - Sounds the bell, using the default volume and sound. The function - is \e not available in Qt for Embedded Linux. + Sounds the bell, using the default volume and sound. The function is \e not + available in Qt for Embedded Linux. */ /*! @@ -4892,26 +4839,25 @@ bool QApplication::keypadNavigationEnabled() Sets the application override cursor to \a cursor. - Application override cursors are intended for showing the user - that the application is in a special state, for example during an - operation that might take some time. + Application override cursors are intended for showing the user that the + application is in a special state, for example during an operation that + might take some time. - This cursor will be displayed in all the application's widgets - until restoreOverrideCursor() or another setOverrideCursor() is - called. + This cursor will be displayed in all the application's widgets until + restoreOverrideCursor() or another setOverrideCursor() is called. - Application cursors are stored on an internal stack. - setOverrideCursor() pushes the cursor onto the stack, and - restoreOverrideCursor() pops the active cursor off the - stack. changeOverrideCursor() changes the curently active - application override cursor. Every setOverrideCursor() must + Application cursors are stored on an internal stack. setOverrideCursor() + pushes the cursor onto the stack, and restoreOverrideCursor() pops the + active cursor off the stack. changeOverrideCursor() changes the curently + active application override cursor. Every setOverrideCursor() must eventually be followed by a corresponding restoreOverrideCursor(), otherwise the stack will never be emptied. Example: \snippet doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp 0 - \sa overrideCursor() restoreOverrideCursor() changeOverrideCursor() QWidget::setCursor() + \sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(), + QWidget::setCursor() */ /*! @@ -4920,9 +4866,8 @@ bool QApplication::keypadNavigationEnabled() Undoes the last setOverrideCursor(). If setOverrideCursor() has been called twice, calling - restoreOverrideCursor() will activate the first cursor set. - Calling this function a second time restores the original widgets' - cursors. + restoreOverrideCursor() will activate the first cursor set. Calling this + function a second time restores the original widgets' cursors. \sa setOverrideCursor(), overrideCursor() */ @@ -4932,9 +4877,9 @@ bool QApplication::keypadNavigationEnabled() \relates QApplication A global pointer referring to the unique application object. It is - equivalent to the pointer returned by the - QCoreApplication::instance() function except that, in GUI applications, - it is a pointer to a QApplication instance. + equivalent to the pointer returned by the QCoreApplication::instance() + function except that, in GUI applications, it is a pointer to a + QApplication instance. Only one application object can be created. @@ -4946,8 +4891,8 @@ bool QApplication::keypadNavigationEnabled() // ************************************************************************ /*! - This function replaces the QInputContext instance used by the - application with \a inputContext. + This function replaces the QInputContext instance used by the application + with \a inputContext. \sa inputContext() */ diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index 103e97f..582962a 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -399,6 +399,17 @@ int QGtkStyle::pixelMetric(PixelMetric metric, return QCleanlooksStyle::pixelMetric(metric, option, widget); switch (metric) { + case PM_DefaultFrameWidth: + if (qobject_cast<const QFrame*>(widget)) { + if (GtkStyle *style = + QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(), + "*.GtkScrolledWindow", + "*.GtkScrolledWindow", + Q_GTK_TYPE_WINDOW)) + return qMax(style->xthickness, style->ythickness); + } + return 2; + case PM_MenuButtonIndicator: return 20; @@ -635,6 +646,60 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, QGtkPainter gtkPainter(painter); switch (element) { + case PE_Frame: { + // Drawing the entire itemview frame is very expensive, especially on the native X11 engine + // Instead we cheat a bit and draw a border image without the center part, hence only scaling + // thin rectangular images + const int pmSize = 64; + const int border = pixelMetric(PM_DefaultFrameWidth, option, widget); + const QString pmKey = QString(QLS("windowframe %0")).arg(option->state); + + QPixmap pixmap; + QPixmapCache::find(pmKey, pixmap); + QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize)); + + // Only draw through style once + if (pixmap.isNull()) { + pixmap = QPixmap(pmSize, pmSize); + pixmap.fill(Qt::transparent); + QPainter pmPainter(&pixmap); + QGtkPainter gtkFramePainter(&pmPainter); + gtkFramePainter.setUsePixmapCache(false); // Don't cache twice + + GtkShadowType shadow_type = GTK_SHADOW_NONE; + if (option->state & State_Sunken) + shadow_type = GTK_SHADOW_IN; + else if (option->state & State_Raised) + shadow_type = GTK_SHADOW_OUT; + + GtkStyle *style = QGtk::gtk_rc_get_style_by_paths(QGtk::gtk_settings_get_default(), + "*.GtkScrolledWindow", "*.GtkScrolledWindow", Q_GTK_TYPE_WINDOW); + if (style) + gtkFramePainter.paintShadow(QGtk::gtkWidget(QLS("GtkFrame")), "viewport", pmRect, + option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, + shadow_type, style); + QPixmapCache::insert(pmKey, pixmap); + } + + QRect rect = option->rect; + const int rw = rect.width() - border; + const int rh = rect.height() - border; + const int pw = pmRect.width() - border; + const int ph = pmRect.height() - border; + + // Sidelines + painter->drawPixmap(rect.adjusted(border, 0, -border, -rh), pixmap, pmRect.adjusted(border, 0, -border,-ph)); + painter->drawPixmap(rect.adjusted(border, rh, -border, 0), pixmap, pmRect.adjusted(border, ph,-border,0)); + painter->drawPixmap(rect.adjusted(0, border, -rw, -border), pixmap, pmRect.adjusted(0, border, -pw, -border)); + painter->drawPixmap(rect.adjusted(rw, border, 0, -border), pixmap, pmRect.adjusted(pw, border, 0, -border)); + + // Corners + painter->drawPixmap(rect.adjusted(0, 0, -rw, -rh), pixmap, pmRect.adjusted(0, 0, -pw,-ph)); + painter->drawPixmap(rect.adjusted(rw, 0, 0, -rh), pixmap, pmRect.adjusted(pw, 0, 0,-ph)); + painter->drawPixmap(rect.adjusted(0, rh, -rw, 0), pixmap, pmRect.adjusted(0, ph, -pw,0)); + painter->drawPixmap(rect.adjusted(rw, rh, 0, 0), pixmap, pmRect.adjusted(pw, ph, 0,0)); + } + break; case PE_PanelTipLabel: { GtkWidget *gtkWindow = QGtk::gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index a3f5cfe..d598807 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -3854,13 +3854,16 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } break; case CE_TabBarTabShape: - if (const QStyleOptionTabV3 *tabOpt = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) { - if (tabOpt->documentMode) { - p->save(); - QRect tabRect = tabOpt->rect; - drawTabShape(p, tabOpt); - p->restore(); - return; + if (const QStyleOptionTab *tabOpt = qstyleoption_cast<const QStyleOptionTab *>(opt)) { + + if (const QStyleOptionTabV3 *tabOptV3 = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) { + if (tabOptV3->documentMode) { + p->save(); + QRect tabRect = tabOptV3->rect; + drawTabShape(p, tabOptV3); + p->restore(); + return; + } } #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 2558409..f22cd56 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4840,7 +4840,8 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const if (subRule.hasContentsSize()) return subRule.size().height(); else if (subRule.hasBox() || subRule.hasBorder()) { - return subRule.size(QSize(0, opt->fontMetrics.lineSpacing())).height(); + QFontMetrics fm = opt ? opt->fontMetrics : w->fontMetrics(); + return subRule.size(QSize(0, fm.lineSpacing())).height(); } break; } diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index c4dffdf..47fe5c2 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -542,7 +542,7 @@ void QFontEngine::addBitmapFontToPath(qreal x, qreal y, const QGlyphLayout &glyp advanceY += glyphs.advances_y[i]; continue; } - QImage alphaMask = alphaMapForGlyph(glyphs.glyphs[i]); + const QImage alphaMask = alphaMapForGlyph(glyphs.glyphs[i]); const int w = alphaMask.width(); const int h = alphaMask.height(); diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h index c337783..9c3d6c2 100644 --- a/src/gui/text/qtextdocument.h +++ b/src/gui/text/qtextdocument.h @@ -287,6 +287,7 @@ public: private: Q_DISABLE_COPY(QTextDocument) Q_DECLARE_PRIVATE(QTextDocument) + friend class QTextObjectPrivate; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QTextDocument::FindFlags) diff --git a/src/gui/text/qtextdocument_p.cpp b/src/gui/text/qtextdocument_p.cpp index 320ecbf..05ddf47 100644 --- a/src/gui/text/qtextdocument_p.cpp +++ b/src/gui/text/qtextdocument_p.cpp @@ -1484,7 +1484,6 @@ QTextObject *QTextDocumentPrivate::createObject(const QTextFormat &f, int object QTextObject *obj = document()->createObject(f); if (obj) { - obj->d_func()->pieceTable = this; obj->d_func()->objectIndex = objectIndex == -1 ? formats.createObjectIndex(f) : objectIndex; objects[obj->d_func()->objectIndex] = obj; } diff --git a/src/gui/text/qtextlist.cpp b/src/gui/text/qtextlist.cpp index e305027..d1a3361 100644 --- a/src/gui/text/qtextlist.cpp +++ b/src/gui/text/qtextlist.cpp @@ -50,6 +50,11 @@ QT_BEGIN_NAMESPACE class QTextListPrivate : public QTextBlockGroupPrivate { +public: + QTextListPrivate(QTextDocument *doc) + : QTextBlockGroupPrivate(doc) + { + } }; /*! @@ -111,7 +116,7 @@ class QTextListPrivate : public QTextBlockGroupPrivate /*! \internal */ QTextList::QTextList(QTextDocument *doc) - : QTextBlockGroup(*new QTextListPrivate, doc) + : QTextBlockGroup(*new QTextListPrivate(doc), doc) { } diff --git a/src/gui/text/qtextobject.cpp b/src/gui/text/qtextobject.cpp index 1645a21..3f4c8e5 100644 --- a/src/gui/text/qtextobject.cpp +++ b/src/gui/text/qtextobject.cpp @@ -88,7 +88,7 @@ QT_BEGIN_NAMESPACE from QTextDocument::createObject(). */ QTextObject::QTextObject(QTextDocument *doc) - : QObject(*new QTextObjectPrivate, doc) + : QObject(*new QTextObjectPrivate(doc), doc) { } @@ -98,7 +98,7 @@ QTextObject::QTextObject(QTextDocument *doc) \internal */ QTextObject::QTextObject(QTextObjectPrivate &p, QTextDocument *doc) - :QObject(p, doc) + : QObject(p, doc) { } @@ -221,7 +221,7 @@ void QTextBlockGroupPrivate::markBlocksDirty() QTextDocument::createObject(). */ QTextBlockGroup::QTextBlockGroup(QTextDocument *doc) - : QTextObject(*new QTextBlockGroupPrivate, doc) + : QTextObject(*new QTextBlockGroupPrivate(doc), doc) { } @@ -410,7 +410,7 @@ QTextFrameLayoutData::~QTextFrameLayoutData() Creates a new empty frame for the text \a document. */ QTextFrame::QTextFrame(QTextDocument *doc) - : QTextObject(*new QTextFramePrivate, doc) + : QTextObject(*new QTextFramePrivate(doc), doc) { Q_D(QTextFrame); d->fragment_start = 0; diff --git a/src/gui/text/qtextobject_p.h b/src/gui/text/qtextobject_p.h index b00a16a..dd05eb4 100644 --- a/src/gui/text/qtextobject_p.h +++ b/src/gui/text/qtextobject_p.h @@ -55,6 +55,7 @@ #include "QtGui/qtextobject.h" #include "private/qobject_p.h" +#include "QtGui/qtextdocument.h" QT_BEGIN_NAMESPACE @@ -64,6 +65,10 @@ class QTextObjectPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QTextObject) public: + QTextObjectPrivate(QTextDocument *doc) + : pieceTable(doc->d_func()), objectIndex(-1) + { + } QTextDocumentPrivate *pieceTable; int objectIndex; }; @@ -72,7 +77,10 @@ class QTextBlockGroupPrivate : public QTextObjectPrivate { Q_DECLARE_PUBLIC(QTextBlockGroup) public: - + QTextBlockGroupPrivate(QTextDocument *doc) + : QTextObjectPrivate(doc) + { + } typedef QList<QTextBlock> BlockList; BlockList blocks; void markBlocksDirty(); @@ -85,7 +93,10 @@ class QTextFramePrivate : public QTextObjectPrivate friend class QTextDocumentPrivate; Q_DECLARE_PUBLIC(QTextFrame) public: - + QTextFramePrivate(QTextDocument *doc) + : QTextObjectPrivate(doc) + { + } virtual void fragmentAdded(const QChar &type, uint fragment); virtual void fragmentRemoved(const QChar &type, uint fragment); void remove_me(); diff --git a/src/gui/text/qtexttable.cpp b/src/gui/text/qtexttable.cpp index 375bb09..ba1c04f 100644 --- a/src/gui/text/qtexttable.cpp +++ b/src/gui/text/qtexttable.cpp @@ -553,7 +553,7 @@ void QTextTablePrivate::update() const /*! \internal */ QTextTable::QTextTable(QTextDocument *doc) - : QTextFrame(*new QTextTablePrivate, doc) + : QTextFrame(*new QTextTablePrivate(doc), doc) { } diff --git a/src/gui/text/qtexttable_p.h b/src/gui/text/qtexttable_p.h index 1ba3a3f..f2b45b6 100644 --- a/src/gui/text/qtexttable_p.h +++ b/src/gui/text/qtexttable_p.h @@ -62,7 +62,7 @@ class QTextTablePrivate : public QTextFramePrivate { Q_DECLARE_PUBLIC(QTextTable) public: - QTextTablePrivate() : grid(0), nRows(0), dirty(true), blockFragmentUpdates(false) {} + QTextTablePrivate(QTextDocument *document) : QTextFramePrivate(document), grid(0), nRows(0), dirty(true), blockFragmentUpdates(false) {} ~QTextTablePrivate(); static QTextTable *createTable(QTextDocumentPrivate *, int pos, int rows, int cols, const QTextTableFormat &tableFormat); diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp index 8b07163..aeb7e91 100644 --- a/src/gui/util/qcompleter.cpp +++ b/src/gui/util/qcompleter.cpp @@ -824,9 +824,9 @@ void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted) Q_Q(QCompleter); QString completion; - if (!index.isValid()) + if (!index.isValid() || (index.row() >= proxy->engine->matchCount())) { completion = prefix; - else { + } else { QModelIndex si = proxy->mapToSource(index); si = si.sibling(si.row(), column); // for clicked() completion = q->pathFromIndex(si); diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 9a0c404..c7e2590 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -61,6 +61,7 @@ #endif #include <private/qcombobox_p.h> #include <private/qabstractitemmodel_p.h> +#include <private/qabstractscrollarea_p.h> #include <qdebug.h> #ifdef Q_WS_X11 @@ -2273,7 +2274,6 @@ void QComboBox::showPopup() bool boundToScreen = !window()->testAttribute(Qt::WA_DontShowOnScreen); const bool usePopup = style->styleHint(QStyle::SH_ComboBox_Popup, &opt, this); - { int listHeight = 0; int count = 0; @@ -2305,11 +2305,23 @@ void QComboBox::showPopup() listRect.setHeight(listHeight); } - // add the frame size to the height. (+the spacing for the top and the bottom item) - int marginTop, marginBottom; - view()->getContentsMargins(0, &marginTop, 0, &marginBottom); - listRect.setHeight(listRect.height() + 2*container->spacing() - + marginTop + marginBottom); + { + // add the spacing for the grid on the top and the bottom; + int heightMargin = 2*container->spacing(); + + // add the frame of the container + int marginTop, marginBottom; + container->getContentsMargins(0, &marginTop, 0, &marginBottom); + heightMargin += marginTop + marginBottom; + + //add the frame of the view + view()->getContentsMargins(0, &marginTop, 0, &marginBottom); + marginTop += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->top; + marginBottom += static_cast<QAbstractScrollAreaPrivate *>(QObjectPrivate::get(view()))->bottom; + heightMargin += marginTop + marginBottom; + + listRect.setHeight(listRect.height() + heightMargin); + } // Add space for margin at top and bottom if the style wants it. if (usePopup) diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 9261c63..4f0ec1e 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -579,7 +579,7 @@ void QDockAreaLayoutInfo::fitItems() QLayoutStruct &ls = layout_struct_list[j++]; ls.init(); ls.empty = false; - if (gap || (item.flags & QDockAreaLayoutItem::KeepSize)) { + if (item.flags & QDockAreaLayoutItem::KeepSize) { ls.minimumSize = ls.maximumSize = ls.sizeHint = item.size; ls.expansive = false; ls.stretch = 0; diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index 865b19c..a5be5f8 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -406,10 +406,14 @@ int QDockWidgetLayout::minimumTitleWidth() const QSize closeSize(0, 0); QSize floatSize(0, 0); - if (QLayoutItem *item = item_list[CloseButton]) - closeSize = item->sizeHint(); - if (QLayoutItem *item = item_list[FloatButton]) - floatSize = item->sizeHint(); + if (hasFeature(q, QDockWidget::DockWidgetClosable)) { + if (QLayoutItem *item = item_list[CloseButton]) + closeSize = item->widget()->sizeHint(); + } + if (hasFeature(q, QDockWidget::DockWidgetFloatable)) { + if (QLayoutItem *item = item_list[FloatButton]) + floatSize = item->widget()->sizeHint(); + } int titleHeight = this->titleHeight(); diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 768446e..eade633 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1542,8 +1542,8 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) if (!previousPath.isEmpty()) layoutState.remove(previousPath); + pluggingWidget = widget; if (dockOptions & QMainWindow::AnimatedDocks) { - pluggingWidget = widget; QRect globalRect = currentGapRect; globalRect.moveTopLeft(parentWidget()->mapToGlobal(globalRect.topLeft())); #ifndef QT_NO_DOCKWIDGET @@ -1575,6 +1575,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) #endif currentGapPos.clear(); updateGapIndicator(); + pluggingWidget = 0; } return true; diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index fc43369..b225c17 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -435,7 +435,7 @@ void QNetmaskAddress::setPrefixLength(QAbstractSocket::NetworkLayerProtocol prot The class also supports common predefined addresses: \l Null, \l LocalHost, \l LocalHostIPv6, \l Broadcast, and \l Any. - \sa QTcpSocket, QTcpServer, QUdpSocket + \sa QHostInfo, QTcpSocket, QTcpServer, QUdpSocket */ /*! \enum QHostAddress::SpecialAddress diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index 534f7ec..73f6f84 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -884,15 +884,15 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) co if (timeout > 0) { // recalculate the timeout - timeout -= timer.elapsed(); - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout % 1000) * 1000; - - if (timeout < 0) { + int t = timeout - timer.elapsed(); + if (t < 0) { // oops, timeout turned negative? retval = -1; break; } + + tv.tv_sec = t / 1000; + tv.tv_usec = (t % 1000) * 1000; } } while (true); @@ -927,15 +927,15 @@ int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool c if (timeout > 0) { // recalculate the timeout - timeout -= timer.elapsed(); - tv.tv_sec = timeout / 1000; - tv.tv_usec = (timeout % 1000) * 1000; - - if (timeout < 0) { + int t = timeout - timer.elapsed(); + if (t < 0) { // oops, timeout turned negative? ret = -1; break; } + + tv.tv_sec = t / 1000; + tv.tv_usec = (t % 1000) * 1000; } } while (true); if (ret <= 0) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp index 6a41a24..8a30ad4 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp @@ -64,7 +64,6 @@ void QDirectFBPaintDevice::lockDirectFB() { void *mem; int w, h; - int bpl; DFBSurfacePixelFormat format; DFBResult result = dfbSurface->Lock(dfbSurface, DSLF_WRITE, &mem, &bpl); @@ -111,11 +110,15 @@ QImage::Format QDirectFBPaintDevice::format() const int QDirectFBPaintDevice::bytesPerLine() const { - // Can only get the stride when we lock the surface - QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this); - that->lockDirectFB(); - Q_ASSERT(that->lockedImage); - return that->lockedImage->bytesPerLine(); + if (bpl == -1) { + // Can only get the stride when we lock the surface + Q_ASSERT(!lockedImage); + QDirectFBPaintDevice* that = const_cast<QDirectFBPaintDevice*>(this); + that->lockDirectFB(); + Q_ASSERT(bpl != -1); + that->unlockDirectFB(); + } + return bpl; } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h index eaf7537..23fa5d6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h @@ -54,11 +54,6 @@ QT_MODULE(Gui) class QDirectFBPaintDevice : public QCustomRasterPaintDevice { public: - QDirectFBPaintDevice(QDirectFBScreen *scr = QDirectFBScreen::instance()) - : QCustomRasterPaintDevice(0), - dfbSurface(0), - lockedImage(0), - screen(scr) {} ~QDirectFBPaintDevice(); IDirectFBSurface *directFbSurface() const; @@ -74,9 +69,19 @@ public: int metric(QPaintDevice::PaintDeviceMetric metric) const; protected: + // Shouldn't create QDirectFBPaintDevice by itself but only sub-class it: + QDirectFBPaintDevice(QDirectFBScreen *scr = QDirectFBScreen::instance()) + : QCustomRasterPaintDevice(0), + dfbSurface(0), + lockedImage(0), + screen(scr) {} + IDirectFBSurface *dfbSurface; QImage *lockedImage; QDirectFBScreen *screen; + int bpl; +private: + Q_DISABLE_COPY(QDirectFBPaintDevice) }; QT_END_HEADER diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp index fb3ecc9..86357e6 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp @@ -211,7 +211,7 @@ public: inline void setDFBColor(const QColor &color) const; - inline bool lock(); + inline void lock(); inline void unlock(); inline bool dfbCanHandleClip(const QRect &rect) const; @@ -241,7 +241,7 @@ public: void end(); SurfaceCache *surfaceCache; - + QTransform transform; private: // QRegion rectsToClippedRegion(const QRect *rects, int n) const; // QRegion rectsToClippedRegion(const QRectF *rects, int n) const; @@ -252,7 +252,6 @@ private: int fbHeight; quint8 opacity; - QTransform transform; quint32 drawFlags; quint32 blitFlags; @@ -260,6 +259,7 @@ private: bool dirtyFlags; bool dirtyClip; bool dfbHandledClip; + QDirectFBPaintDevice *dfbDevice; QDirectFBPaintEngine *q; }; @@ -268,7 +268,7 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p : surface(0), antialiased(false), simplePen(false), simpleBrush(false), matrixRotShear(false), matrixScale(false), fbWidth(-1), fbHeight(-1), opacity(255), drawFlags(0), blitFlags(0), duffFlags(0), dirtyFlags(false), dirtyClip(true), - dfbHandledClip(false), q(p) + dfbHandledClip(false), dfbDevice(0), q(p) { fb = QDirectFBScreen::instance()->dfb(); surfaceCache = new SurfaceCache; @@ -279,7 +279,6 @@ QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate() { - unlock(); delete surfaceCache; } @@ -306,26 +305,18 @@ void QDirectFBPaintEnginePrivate::setClipDirty() } -bool QDirectFBPaintEnginePrivate::lock() +void QDirectFBPaintEnginePrivate::lock() { // We will potentially get a new pointer to the buffer after a // lock so we need to call the base implementation of prepare so // it updates its rasterBuffer to point to the new buffer address. - if (device->devType() == QInternal::CustomRaster) { - prepare(static_cast<QCustomRasterPaintDevice*>(device)); - return true; - } - return false; + Q_ASSERT(dfbDevice); + prepare(dfbDevice); } void QDirectFBPaintEnginePrivate::unlock() { - QPaintDevice *device = q->paintDevice(); - if (!device) //XXX This should probably be an assert - return; - - Q_ASSERT(device->devType() == QInternal::CustomRaster); - QDirectFBPaintDevice* dfbDevice = static_cast<QDirectFBPaintDevice*>(device); + Q_ASSERT(dfbDevice); dfbDevice->unlockDirectFB(); } @@ -338,16 +329,13 @@ void QDirectFBPaintEnginePrivate::setTransform(const QTransform &m) void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) { - QDirectFBPaintDevice* dfbDevice = 0; - if (device->devType() == QInternal::CustomRaster) dfbDevice = static_cast<QDirectFBPaintDevice*>(device); else if (device->devType() == QInternal::Pixmap) { QPixmapData *data = static_cast<QPixmap*>(device)->pixmapData(); - if (data->classId() == QPixmapData::DirectFBClass) { - QDirectFBPixmapData* dfbPixmapData = static_cast<QDirectFBPixmapData*>(data); - dfbDevice = static_cast<QDirectFBPaintDevice*>(dfbPixmapData); - } + Q_ASSERT(data->classId() == QPixmapData::DirectFBClass); + QDirectFBPixmapData* dfbPixmapData = static_cast<QDirectFBPixmapData*>(data); + dfbDevice = static_cast<QDirectFBPaintDevice*>(dfbPixmapData); } if (dfbDevice) @@ -374,6 +362,7 @@ void QDirectFBPaintEnginePrivate::begin(QPaintDevice *device) void QDirectFBPaintEnginePrivate::end() { + dfbDevice = 0; surface->ReleaseSource(surface); surface->SetClip(surface, NULL); surface = 0; @@ -1191,12 +1180,14 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush) d->updateClip(); if (d->dfbCanHandleClip(rect) && !d->matrixRotShear) { switch (brush.style()) { - case Qt::SolidPattern: + case Qt::SolidPattern: { d->unlock(); d->updateFlags(); d->setDFBColor(brush.color()); - d->fillRects(&rect, 1); - return; + const QRect r = ::mapRect(d->transform, rect); + d->surface->FillRectangle(d->surface, r.x(), r.y(), + r.width(), r.height()); + return; } case Qt::TexturePattern: if (state()->brushOrigin == QPointF() && brush.transform().isIdentity()) { //could handle certain types of brush.transform() E.g. scale @@ -1225,7 +1216,9 @@ void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color) d->unlock(); d->updateFlags(); d->setDFBColor(color); - d->fillRects(&rect, 1); + const QRect r = ::mapRect(d->transform, rect); + d->surface->FillRectangle(d->surface, r.x(), r.y(), + r.width(), r.height()); } } diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp index 0486e40..26c023f 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp @@ -362,50 +362,6 @@ void QDirectFBScreen::setSurfaceColorTable(IDirectFBSurface *surface, palette->Release(palette); } -void QDirectFBScreen::setImageColorTable(QImage *image, IDirectFBSurface *surface) -{ - if (!image || !surface || image->depth() > 8) - return; - - IDirectFBPalette *palette = 0; - unsigned int numColors = 0; - DFBResult result; - do { - result = surface->GetPalette(surface, &palette); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen::setImageColorTable GetPalette", result); - break; - } - - result = palette->GetSize(palette, &numColors); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen::setImageColorTable GetPalette", result); - break; - } - - if (numColors == 0) - break; - - QVarLengthArray<DFBColor> dfbColors(numColors); - result = palette->GetEntries(palette, dfbColors.data(), numColors, 0); - if (result != DFB_OK) { - DirectFBError("QDirectFBScreen::setImageColorTable GetPalette", result); - break; - } - - QVector<QRgb> qtColors(numColors); - for (unsigned int i=0; i<numColors; ++i) { - const DFBColor &col = dfbColors[i]; - qtColors[i] = qRgba(col.r, col.g, col.b, col.a); - } - image->setColorTable(qtColors); - - } while (0); - - if (palette) - palette->Release(palette); -} - #endif // QT_NO_DIRECTFB_PALETTE #if !defined(QT_NO_DIRECTFB_LAYER) && !defined(QT_NO_QWS_CURSOR) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index e9a2f63..35dea0d 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -104,7 +104,6 @@ public: #ifndef QT_NO_DIRECTFB_PALETTE static void setSurfaceColorTable(IDirectFBSurface *surface, const QImage &image); - static void setImageColorTable(QImage *image, IDirectFBSurface *surface); #endif private: diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp index ab1d0f1..ce026ea 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp +++ b/src/plugins/gfxdrivers/directfb/qdirectfbsurface.cpp @@ -126,14 +126,15 @@ void QDirectFBSurface::setGeometry(const QRect &rect, const QRegion &mask) // If we're in a resize, the surface shouldn't be locked Q_ASSERT( (lockedImage == 0) || (isResize == false)); - IDirectFBSurface *s = screen->dfbSurface(); - if (onscreen && s) { + if (onscreen) { if (dfbSurface) dfbSurface->Release(dfbSurface); DFBRectangle r = { rect.x(), rect.y(), rect.width(), rect.height() }; - result = s->GetSubSurface(s, &r, &dfbSurface); + IDirectFBSurface *primarySurface = screen->dfbSurface(); + Q_ASSERT(primarySurface); + result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface); } else { #ifdef QT_NO_DIRECTFB_WM if (isResize) { @@ -337,11 +338,22 @@ void QDirectFBSurface::flush(QWidget *widget, const QRegion ®ion, QWSWindowSurface::flush(widget, region, offset); #ifndef QT_NO_DIRECTFB_WM - const QRect br = region.boundingRect().translated(painterOffset()); - const DFBRegion r = { br.x(), br.y(), - br.x() + br.width(), br.y() + br.height() }; - - dfbSurface->Flip(dfbSurface, &r, DSFLIP_NONE); + if (region.numRects() > 1) { + const QVector<QRect> rects = region.rects(); + for (int i=0; i<rects.size(); ++i) { + const QRect &r = rects.at(i); + const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(), + r.x() + r.width() + offset.x(), + r.y() + r.height() + offset.y() }; + dfbSurface->Flip(dfbSurface, &dfbReg, DSFLIP_ONSYNC); + } + } else { + const QRect r = region.boundingRect(); + const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(), + r.x() + r.width() + offset.x(), + r.y() + r.height() + offset.y() }; + dfbSurface->Flip(dfbSurface, &dfbReg, DSFLIP_ONSYNC); + } #endif } diff --git a/src/script/qscriptengine.cpp b/src/script/qscriptengine.cpp index d4e1923..d8908ed 100644 --- a/src/script/qscriptengine.cpp +++ b/src/script/qscriptengine.cpp @@ -1169,7 +1169,8 @@ bool QScriptEngine::convert(const QScriptValue &value, int type, void *ptr) bool QScriptEngine::convertV2(const QScriptValue &value, int type, void *ptr) { QScriptValueImpl impl = QScriptValuePrivate::valueOf(value); - return QScriptEnginePrivate::convert(impl, type, ptr, /*engine=*/0); + QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(value.engine()); + return QScriptEnginePrivate::convert(impl, type, ptr, eng_p); } /*! diff --git a/tests/auto/qcombobox/tst_qcombobox.cpp b/tests/auto/qcombobox/tst_qcombobox.cpp index 0db9fdf..70059f2 100644 --- a/tests/auto/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/qcombobox/tst_qcombobox.cpp @@ -56,6 +56,7 @@ #include <qlistwidget.h> #include <qtreewidget.h> #include <qtablewidget.h> +#include <qscrollbar.h> #ifdef Q_WS_MAC #include <qmacstyle_mac.h> #elif defined Q_WS_X11 @@ -138,6 +139,8 @@ private slots: void task248169_popupWithMinimalSize(); void task247863_keyBoardSelection(); void setModelColumn(); + void noScrollbar_data(); + void noScrollbar(); protected slots: void onEditTextChanged( const QString &newString ); @@ -2129,7 +2132,7 @@ void tst_QComboBox::task248169_popupWithMinimalSize() QFrame *container = qFindChild<QComboBoxPrivateContainer *>(&comboBox); QVERIFY(container); - QVERIFY(desktop.availableGeometry().contains(container->geometry())); + QVERIFY(desktop.screenGeometry(container).contains(container->geometry())); } void tst_QComboBox::task247863_keyBoardSelection() @@ -2178,5 +2181,56 @@ void tst_QComboBox::setModelColumn() QCOMPARE(box.currentText(), QString("zero")); } +void tst_QComboBox::noScrollbar_data() +{ + QTest::addColumn<QString>("stylesheet"); + + QTest::newRow("normal") << QString(); + QTest::newRow("border") << QString::fromLatin1("QAbstractItemView { border: 12px solid blue;}"); + QTest::newRow("margin") << QString::fromLatin1("QAbstractItemView { margin: 12px 15px 13px 10px; }"); + QTest::newRow("padding") << QString::fromLatin1("QAbstractItemView { padding: 12px 15px 13px 10px;}"); + QTest::newRow("everything") << QString::fromLatin1("QAbstractItemView { border: 12px solid blue; " + " padding: 12px 15px 13px 10px; margin: 12px 15px 13px 10px; }"); + QTest::newRow("everything and more") << QString::fromLatin1("QAbstractItemView { border: 1px 3px 5px 1px solid blue; " + " padding: 2px 5px 3px 1px; margin: 2px 5px 3px 1px; } " + " QAbstractItemView::item { border: 2px solid green; " + " padding: 1px 1px 2px 2px margin: 1px; } " ); +} + +void tst_QComboBox::noScrollbar() +{ + QStringList initialContent; + initialContent << "foo" << "bar" << "foobar" << "moo"; + QFETCH(QString, stylesheet); + + { + QComboBox comboBox; + comboBox.setStyleSheet(stylesheet); + comboBox.addItems(initialContent); + comboBox.show(); + comboBox.resize(200, comboBox.height()); + QTest::qWait(100); + comboBox.showPopup(); + QTest::qWait(100); + QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible()); + QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible()); + } + + { + QTableWidget *table = new QTableWidget(2,2); + QComboBox comboBox; + comboBox.setStyleSheet(stylesheet); + comboBox.setView(table); + comboBox.setModel(table->model()); + comboBox.show(); + QTest::qWait(100); + comboBox.resize(200, comboBox.height()); + comboBox.showPopup(); + QTest::qWait(100); + QVERIFY(!comboBox.view()->horizontalScrollBar()->isVisible()); + QVERIFY(!comboBox.view()->verticalScrollBar()->isVisible()); + } +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp index 6434d49..67b9b67 100644 --- a/tests/auto/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/qcompleter/tst_qcompleter.cpp @@ -140,6 +140,7 @@ private slots: // task-specific tests below me void task178797_activatedOnReturn(); void task189564_omitNonSelectableItems(); + void task246056_setCompletionPrefix(); private: void filter(); @@ -1093,5 +1094,37 @@ void tst_QCompleter::task189564_omitNonSelectableItems() QVERIFY(matches2.isEmpty()); } +class task246056_ComboBox : public QComboBox +{ + Q_OBJECT +public: + task246056_ComboBox() + { + setEditable(true); + setInsertPolicy(NoInsert); + Q_ASSERT(completer()); + completer()->setCompletionMode(QCompleter::PopupCompletion); + completer()->setCompletionRole(Qt::DisplayRole); + connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix())); + } +private slots: + void setCompletionPrefix() { completer()->setCompletionPrefix(lineEdit()->text()); } +}; + +void tst_QCompleter::task246056_setCompletionPrefix() +{ + task246056_ComboBox *comboBox = new task246056_ComboBox; + comboBox->addItem(""); + comboBox->addItem("a1"); + comboBox->addItem("a2"); + comboBox->show(); + comboBox->setFocus(); + QTest::qWait(100); + QTest::keyPress(comboBox, 'a'); + QTest::keyPress(comboBox->completer()->popup(), Qt::Key_Down); + QTest::keyPress(comboBox->completer()->popup(), Qt::Key_Down); + QTest::keyPress(comboBox->completer()->popup(), Qt::Key_Enter); // don't crash! +} + QTEST_MAIN(tst_QCompleter) #include "tst_qcompleter.moc" diff --git a/tests/auto/qdir/testdir/dir/Makefile b/tests/auto/qdir/testdir/dir/Makefile deleted file mode 100644 index e69de29..0000000 --- a/tests/auto/qdir/testdir/dir/Makefile +++ /dev/null diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp index 9995b46..5339fb4 100644 --- a/tests/auto/qscriptengine/tst_qscriptengine.cpp +++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp @@ -1187,6 +1187,16 @@ static void fooFromScriptValue(const QScriptValue &value, Foo &foo) foo.y = value.property("y").toInt32(); } +static QScriptValue fooToScriptValueV2(QScriptEngine *eng, const Foo &foo) +{ + return QScriptValue(eng, foo.x); +} + +static void fooFromScriptValueV2(const QScriptValue &value, Foo &foo) +{ + foo.x = value.toInt32(); +} + Q_DECLARE_METATYPE(QLinkedList<QString>) Q_DECLARE_METATYPE(QList<Foo>) Q_DECLARE_METATYPE(QVector<QChar>) @@ -1427,6 +1437,24 @@ void tst_QScriptEngine::valueConversion() QVERIFY(val.isVariant()); QCOMPARE(val.toVariant(), var); } + + // task 248802 + qScriptRegisterMetaType<Foo>(&eng, fooToScriptValueV2, fooFromScriptValueV2); + { + QScriptValue num(&eng, 123); + Foo foo = qScriptValueToValue<Foo>(num); + QCOMPARE(foo.x, 123); + } + { + QScriptValue num(123); + Foo foo = qScriptValueToValue<Foo>(num); + QCOMPARE(foo.x, -1); + } + { + QScriptValue str(&eng, "123"); + Foo foo = qScriptValueToValue<Foo>(str); + QCOMPARE(foo.x, 123); + } } static QScriptValue __import__(QScriptContext *ctx, QScriptEngine *eng) diff --git a/tests/auto/qtextobject/tst_qtextobject.cpp b/tests/auto/qtextobject/tst_qtextobject.cpp index 4fbc155..4d1d4b2 100644 --- a/tests/auto/qtextobject/tst_qtextobject.cpp +++ b/tests/auto/qtextobject/tst_qtextobject.cpp @@ -62,6 +62,7 @@ public: private slots: void getSetCheck(); + void testStandAloneTextObject(); }; tst_QTextObject::tst_QTextObject() @@ -105,5 +106,23 @@ void tst_QTextObject::getSetCheck() QCOMPARE(INT_MAX, obj2.userState()); } +class TestTextObject : public QTextObject +{ +public: + TestTextObject(QTextDocument *document) : QTextObject(document) {} +}; + +void tst_QTextObject::testStandAloneTextObject() +{ + QTextDocument document; + TestTextObject textObject(&document); + + QCOMPARE(textObject.document(), &document); + // don't crash + textObject.format(); + textObject.formatIndex(); + QCOMPARE(textObject.objectIndex(), -1); +} + QTEST_MAIN(tst_QTextObject) #include "tst_qtextobject.moc" diff --git a/tests/auto/selftests/alive/alive.pro b/tests/auto/selftests/alive/alive.pro index 4a6b788..08cf358 100644 --- a/tests/auto/selftests/alive/alive.pro +++ b/tests/auto/selftests/alive/alive.pro @@ -5,3 +5,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = alive diff --git a/tests/auto/selftests/assert/assert.pro b/tests/auto/selftests/assert/assert.pro index 87513d4..0e48375 100644 --- a/tests/auto/selftests/assert/assert.pro +++ b/tests/auto/selftests/assert/assert.pro @@ -8,3 +8,4 @@ CONFIG -= debug_and_release_target !win32:CONFIG += debug +TARGET = assert diff --git a/tests/auto/selftests/benchlibcallgrind/benchlibcallgrind.pro b/tests/auto/selftests/benchlibcallgrind/benchlibcallgrind.pro index 34a43d0..c9ec7e2 100644 --- a/tests/auto/selftests/benchlibcallgrind/benchlibcallgrind.pro +++ b/tests/auto/selftests/benchlibcallgrind/benchlibcallgrind.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = benchlibcallgrind diff --git a/tests/auto/selftests/benchlibeventcounter/benchlibeventcounter.pro b/tests/auto/selftests/benchlibeventcounter/benchlibeventcounter.pro index 41e090e..44b0295 100644 --- a/tests/auto/selftests/benchlibeventcounter/benchlibeventcounter.pro +++ b/tests/auto/selftests/benchlibeventcounter/benchlibeventcounter.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = benchlibeventcounter diff --git a/tests/auto/selftests/benchliboptions/benchliboptions.pro b/tests/auto/selftests/benchliboptions/benchliboptions.pro index 2f02eef..4dee69f 100644 --- a/tests/auto/selftests/benchliboptions/benchliboptions.pro +++ b/tests/auto/selftests/benchliboptions/benchliboptions.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = benchliboptions diff --git a/tests/auto/selftests/benchlibtickcounter/benchlibtickcounter.pro b/tests/auto/selftests/benchlibtickcounter/benchlibtickcounter.pro index 3d8cbfa..3621449 100644 --- a/tests/auto/selftests/benchlibtickcounter/benchlibtickcounter.pro +++ b/tests/auto/selftests/benchlibtickcounter/benchlibtickcounter.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = benchlibtickcounter diff --git a/tests/auto/selftests/benchlibwalltime/benchlibwalltime.pro b/tests/auto/selftests/benchlibwalltime/benchlibwalltime.pro index 364e80b..f4694b5 100644 --- a/tests/auto/selftests/benchlibwalltime/benchlibwalltime.pro +++ b/tests/auto/selftests/benchlibwalltime/benchlibwalltime.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = benchlibwalltime diff --git a/tests/auto/selftests/cmptest/cmptest.pro b/tests/auto/selftests/cmptest/cmptest.pro index c19a77a..8b2df1c 100644 --- a/tests/auto/selftests/cmptest/cmptest.pro +++ b/tests/auto/selftests/cmptest/cmptest.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = cmptest diff --git a/tests/auto/selftests/commandlinedata/commandlinedata.pro b/tests/auto/selftests/commandlinedata/commandlinedata.pro index c900fc8..96bfa5b 100644 --- a/tests/auto/selftests/commandlinedata/commandlinedata.pro +++ b/tests/auto/selftests/commandlinedata/commandlinedata.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = commandlinedata diff --git a/tests/auto/selftests/crashes/crashes.pro b/tests/auto/selftests/crashes/crashes.pro index 57eb4c7..7eec6ea 100644 --- a/tests/auto/selftests/crashes/crashes.pro +++ b/tests/auto/selftests/crashes/crashes.pro @@ -7,3 +7,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = crashes diff --git a/tests/auto/selftests/datatable/datatable.pro b/tests/auto/selftests/datatable/datatable.pro index 69aed7a..98f04d6 100644 --- a/tests/auto/selftests/datatable/datatable.pro +++ b/tests/auto/selftests/datatable/datatable.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = datatable diff --git a/tests/auto/selftests/datetime/datetime.pro b/tests/auto/selftests/datetime/datetime.pro index 489e5cb..b015661 100644 --- a/tests/auto/selftests/datetime/datetime.pro +++ b/tests/auto/selftests/datetime/datetime.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = datetime diff --git a/tests/auto/selftests/differentexec/differentexec.pro b/tests/auto/selftests/differentexec/differentexec.pro index e789649..c11b0d3 100644 --- a/tests/auto/selftests/differentexec/differentexec.pro +++ b/tests/auto/selftests/differentexec/differentexec.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = differentexec diff --git a/tests/auto/selftests/exception/exception.pro b/tests/auto/selftests/exception/exception.pro index 14d8c7f..65705c6 100644 --- a/tests/auto/selftests/exception/exception.pro +++ b/tests/auto/selftests/exception/exception.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = exception diff --git a/tests/auto/selftests/expectfail/expectfail.pro b/tests/auto/selftests/expectfail/expectfail.pro index c411199..97a3560 100644 --- a/tests/auto/selftests/expectfail/expectfail.pro +++ b/tests/auto/selftests/expectfail/expectfail.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = expectfail diff --git a/tests/auto/selftests/failinit/failinit.pro b/tests/auto/selftests/failinit/failinit.pro index 729cf74..e3d54c8 100644 --- a/tests/auto/selftests/failinit/failinit.pro +++ b/tests/auto/selftests/failinit/failinit.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = failinit diff --git a/tests/auto/selftests/failinitdata/failinitdata.pro b/tests/auto/selftests/failinitdata/failinitdata.pro index 6b48af1..1ff96f7 100644 --- a/tests/auto/selftests/failinitdata/failinitdata.pro +++ b/tests/auto/selftests/failinitdata/failinitdata.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = failinitdata diff --git a/tests/auto/selftests/fetchbogus/fetchbogus.pro b/tests/auto/selftests/fetchbogus/fetchbogus.pro index badb636..3a5d13b 100644 --- a/tests/auto/selftests/fetchbogus/fetchbogus.pro +++ b/tests/auto/selftests/fetchbogus/fetchbogus.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = fetchbogus diff --git a/tests/auto/selftests/globaldata/globaldata.pro b/tests/auto/selftests/globaldata/globaldata.pro index eb3b454..1bdcf07 100644 --- a/tests/auto/selftests/globaldata/globaldata.pro +++ b/tests/auto/selftests/globaldata/globaldata.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = globaldata diff --git a/tests/auto/selftests/maxwarnings/maxwarnings.pro b/tests/auto/selftests/maxwarnings/maxwarnings.pro index b43affe..393a964 100644 --- a/tests/auto/selftests/maxwarnings/maxwarnings.pro +++ b/tests/auto/selftests/maxwarnings/maxwarnings.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = maxwarnings diff --git a/tests/auto/selftests/multiexec/multiexec.pro b/tests/auto/selftests/multiexec/multiexec.pro index 723f56f..639b9b8 100644 --- a/tests/auto/selftests/multiexec/multiexec.pro +++ b/tests/auto/selftests/multiexec/multiexec.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = multiexec diff --git a/tests/auto/selftests/qexecstringlist/qexecstringlist.pro b/tests/auto/selftests/qexecstringlist/qexecstringlist.pro index 27afcb2..73bdaca 100644 --- a/tests/auto/selftests/qexecstringlist/qexecstringlist.pro +++ b/tests/auto/selftests/qexecstringlist/qexecstringlist.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = qexecstringlist diff --git a/tests/auto/selftests/singleskip/singleskip.pro b/tests/auto/selftests/singleskip/singleskip.pro index 0d66f68..9762c97 100644 --- a/tests/auto/selftests/singleskip/singleskip.pro +++ b/tests/auto/selftests/singleskip/singleskip.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = singleskip diff --git a/tests/auto/selftests/skip/skip.pro b/tests/auto/selftests/skip/skip.pro index 545a579..989fdeb 100644 --- a/tests/auto/selftests/skip/skip.pro +++ b/tests/auto/selftests/skip/skip.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = skip diff --git a/tests/auto/selftests/skipglobal/skipglobal.pro b/tests/auto/selftests/skipglobal/skipglobal.pro index 97553c6..0205a88 100644 --- a/tests/auto/selftests/skipglobal/skipglobal.pro +++ b/tests/auto/selftests/skipglobal/skipglobal.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = skipglobal diff --git a/tests/auto/selftests/skipinit/skipinit.pro b/tests/auto/selftests/skipinit/skipinit.pro index d8ee13e..6912183 100644 --- a/tests/auto/selftests/skipinit/skipinit.pro +++ b/tests/auto/selftests/skipinit/skipinit.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = skipinit diff --git a/tests/auto/selftests/skipinitdata/skipinitdata.pro b/tests/auto/selftests/skipinitdata/skipinitdata.pro index 8da653e..206ed11 100644 --- a/tests/auto/selftests/skipinitdata/skipinitdata.pro +++ b/tests/auto/selftests/skipinitdata/skipinitdata.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = skipinitdata diff --git a/tests/auto/selftests/sleep/sleep.pro b/tests/auto/selftests/sleep/sleep.pro index 7b28ccc..0bd3225 100644 --- a/tests/auto/selftests/sleep/sleep.pro +++ b/tests/auto/selftests/sleep/sleep.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = sleep diff --git a/tests/auto/selftests/strcmp/strcmp.pro b/tests/auto/selftests/strcmp/strcmp.pro index 489211c..3121c25 100644 --- a/tests/auto/selftests/strcmp/strcmp.pro +++ b/tests/auto/selftests/strcmp/strcmp.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = strcmp diff --git a/tests/auto/selftests/subtest/subtest.pro b/tests/auto/selftests/subtest/subtest.pro index 4d258ee..fe3cafa 100644 --- a/tests/auto/selftests/subtest/subtest.pro +++ b/tests/auto/selftests/subtest/subtest.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = subtest diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 4243612..103fd79 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -195,7 +195,7 @@ void tst_Selftests::runSubTest() QProcess proc; proc.setEnvironment(QStringList("")); - proc.start(subdir + "/tst_" + subdir, arguments); + proc.start(subdir + "/" + subdir, arguments); QVERIFY(proc.waitForFinished()); const QByteArray out(proc.readAllStandardOutput()); @@ -309,7 +309,7 @@ void tst_Selftests::checkXML() const QProcess proc; proc.setEnvironment(QStringList("")); - proc.start(subdir + "/tst_" + subdir, arguments); + proc.start(subdir + "/" + subdir, arguments); QVERIFY(proc.waitForFinished()); QByteArray out(proc.readAllStandardOutput()); diff --git a/tests/auto/selftests/updateBaselines.sh b/tests/auto/selftests/updateBaselines.sh deleted file mode 100755 index a0f22e6..0000000 --- a/tests/auto/selftests/updateBaselines.sh +++ /dev/null @@ -1,34 +0,0 @@ -# Be *really* sure that your fix is right, before running this script. - -tests=" \ - cmptest \ - cmptest \ - cmptest \ - datatable \ - datetime \ - expectfail \ - expectfail \ - globaldata \ - globaldata \ - maxwarnings \ - multiexec \ - singleskip \ - qexecstringlist \ - differentexec \ - skip \ - skip \ - skipglobal \ - sleep \ - strcmp \ - subtest \ - warnings" - -for test in $tests; do - echo "Updating $test" - cd $test - baseline="../expected_"$test".txt" - p4 edit $baseline - ./tst_$test > ../expected_"$test".txt - p4 revert -a $baseline - cd .. -done diff --git a/tests/auto/selftests/waitwithoutgui/waitwithoutgui.pro b/tests/auto/selftests/waitwithoutgui/waitwithoutgui.pro index 8cdf7cc..cf3098d 100644 --- a/tests/auto/selftests/waitwithoutgui/waitwithoutgui.pro +++ b/tests/auto/selftests/waitwithoutgui/waitwithoutgui.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = waitwithoutgui diff --git a/tests/auto/selftests/warnings/warnings.pro b/tests/auto/selftests/warnings/warnings.pro index 9ae22d3..eaf06b4 100644 --- a/tests/auto/selftests/warnings/warnings.pro +++ b/tests/auto/selftests/warnings/warnings.pro @@ -6,3 +6,4 @@ mac:CONFIG -= app_bundle CONFIG -= debug_and_release_target +TARGET = warnings diff --git a/tools/assistant/tools/assistant/mainwindow.cpp b/tools/assistant/tools/assistant/mainwindow.cpp index 0f246be..df39650 100644 --- a/tools/assistant/tools/assistant/mainwindow.cpp +++ b/tools/assistant/tools/assistant/mainwindow.cpp @@ -186,9 +186,11 @@ MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent) m_helpEngine->setCustomValue(QLatin1String("useAppFont"), false); m_helpEngine->setCustomValue(QLatin1String("useBrowserFont"), false); m_helpEngine->setCustomValue(QLatin1String("appFont"), qApp->font()); - m_helpEngine->setCustomValue(QLatin1String("appWritingSystem"), QFontDatabase::Latin); + m_helpEngine->setCustomValue(QLatin1String("appWritingSystem"), + QFontDatabase::Latin); m_helpEngine->setCustomValue(QLatin1String("browserFont"), qApp->font()); - m_helpEngine->setCustomValue(QLatin1String("browserWritingSystem"), QFontDatabase::Latin); + m_helpEngine->setCustomValue(QLatin1String("browserWritingSystem"), + QFontDatabase::Latin); } else { updateApplicationFont(); } @@ -377,118 +379,107 @@ void MainWindow::insertLastPages() void MainWindow::setupActions() { - QString system = QLatin1String("win"); + QString resourcePath = QLatin1String(":/trolltech/assistant/images/"); #ifdef Q_OS_MAC - system = QLatin1String("mac"); setUnifiedTitleAndToolBarOnMac(true); + resourcePath.append(QLatin1String("mac")); +#else + resourcePath.append(QLatin1String("win")); #endif QMenu *menu = menuBar()->addMenu(tr("&File")); - m_pageSetupAction = menu->addAction(tr("Page Set&up..."), m_centralWidget, SLOT(pageSetup())); - m_printPreviewAction = menu->addAction(tr("Print Preview..."), m_centralWidget, SLOT(printPreview())); + m_pageSetupAction = menu->addAction(tr("Page Set&up..."), m_centralWidget, + SLOT(pageSetup())); + m_printPreviewAction = menu->addAction(tr("Print Preview..."), m_centralWidget, + SLOT(printPreview())); + m_printAction = menu->addAction(tr("&Print..."), m_centralWidget, SLOT(print())); - m_printAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/print.png").arg(system))); - m_printAction->setShortcut(tr("CTRL+P")); + m_printAction->setIcon(QIcon(resourcePath + QLatin1String("/print.png"))); + m_printAction->setShortcut(QKeySequence::Print); menu->addSeparator(); m_newTabAction = menu->addAction(tr("New &Tab"), m_centralWidget, SLOT(newTab())); - m_newTabAction->setShortcut(tr("CTRL+T")); - m_closeTabAction = menu->addAction(tr("&Close Tab"), m_centralWidget, SLOT(closeTab())); - m_closeTabAction->setShortcut(tr("CTRL+W")); + m_newTabAction->setShortcut(QKeySequence::AddTab); + + m_closeTabAction = menu->addAction(tr("&Close Tab"), m_centralWidget, + SLOT(closeTab())); + m_closeTabAction->setShortcuts(QKeySequence::Close); QAction *tmp = menu->addAction(tr("&Quit"), this, SLOT(close())); tmp->setShortcut(tr("CTRL+Q")); tmp->setMenuRole(QAction::QuitRole); menu = menuBar()->addMenu(tr("&Edit")); - m_copyAction = menu->addAction(tr("&Copy selected Text"), - m_centralWidget, SLOT(copySelection())); - m_copyAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/editcopy.png").arg(system))); - m_copyAction->setShortcut(tr("Ctrl+C")); + m_copyAction = menu->addAction(tr("&Copy selected Text"), m_centralWidget, + SLOT(copySelection())); + m_copyAction->setIcon(QIcon(resourcePath + QLatin1String("/editcopy.png"))); + m_copyAction->setShortcuts(QKeySequence::Copy); m_copyAction->setEnabled(false); - m_findAction = menu->addAction(tr("&Find in Text..."), - m_centralWidget, SLOT(showTextSearch())); - m_findAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/find.png").arg(system))); - m_findAction->setShortcut(tr("Ctrl+F")); - m_findAction->setShortcut(QKeySequence::Find); + m_findAction = menu->addAction(tr("&Find in Text..."), m_centralWidget, + SLOT(showTextSearch())); + m_findAction->setIcon(QIcon(resourcePath + QLatin1String("/find.png"))); + m_findAction->setShortcuts(QKeySequence::Find); - QAction *findNextAction = menu->addAction(tr("Find &Next"), - m_centralWidget, SLOT(findNext())); - findNextAction->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("F3")) - << QKeySequence(tr("CTRL+G"))); + QAction *findNextAction = menu->addAction(tr("Find &Next"), m_centralWidget, + SLOT(findNext())); + findNextAction->setShortcuts(QKeySequence::FindNext); QAction *findPreviousAction = menu->addAction(tr("Find &Previous"), m_centralWidget, SLOT(findPrevious())); - findPreviousAction->setShortcuts(QList<QKeySequence>() << - QKeySequence(tr("Shift+F3")) << QKeySequence(tr("CTRL+SHIFT+G"))); + findPreviousAction->setShortcuts(QKeySequence::FindPrevious); menu->addSeparator(); tmp = menu->addAction(tr("Preferences..."), this, SLOT(showPreferences())); tmp->setMenuRole(QAction::PreferencesRole); m_viewMenu = menuBar()->addMenu(tr("&View")); - m_zoomInAction = m_viewMenu->addAction(tr("Zoom &in"), - m_centralWidget, SLOT(zoomIn())); - m_zoomInAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/zoomin.png").arg(system))); - m_zoomInAction->setShortcut(tr("Ctrl++")); - - m_zoomOutAction = m_viewMenu->addAction(tr("Zoom &out"), - m_centralWidget, SLOT(zoomOut())); - m_zoomOutAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/zoomout.png").arg(system))); - m_zoomOutAction->setShortcut(tr("Ctrl+-")); - - m_resetZoomAction = m_viewMenu->addAction(tr("Normal &Size"), - m_centralWidget, SLOT(resetZoom())); - m_resetZoomAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/resetzoom.png").arg(system))); + m_zoomInAction = m_viewMenu->addAction(tr("Zoom &in"), m_centralWidget, + SLOT(zoomIn())); + m_zoomInAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomin.png"))); + m_zoomInAction->setShortcut(QKeySequence::ZoomIn); + + m_zoomOutAction = m_viewMenu->addAction(tr("Zoom &out"), m_centralWidget, + SLOT(zoomOut())); + m_zoomOutAction->setIcon(QIcon(resourcePath + QLatin1String("/zoomout.png"))); + m_zoomOutAction->setShortcut(QKeySequence::ZoomOut); + + m_resetZoomAction = m_viewMenu->addAction(tr("Normal &Size"), m_centralWidget, + SLOT(resetZoom())); + m_resetZoomAction->setIcon(QIcon(resourcePath + QLatin1String("/resetzoom.png"))); m_resetZoomAction->setShortcut(tr("Ctrl+0")); m_viewMenu->addSeparator(); - m_viewMenu->addAction(tr("Contents"), this, - SLOT(showContents()), QKeySequence(tr("ALT+C"))); - m_viewMenu->addAction(tr("Index"), this, - SLOT(showIndex()), QKeySequence(tr("ALT+I"))); - m_viewMenu->addAction(tr("Bookmarks"), this, - SLOT(showBookmarks()), QKeySequence(tr("ALT+O"))); - m_viewMenu->addAction(tr("Search"), this, - SLOT(showSearch()), QKeySequence(tr("ALT+S"))); + m_viewMenu->addAction(tr("Contents"), this, SLOT(showContents()), + QKeySequence(tr("ALT+C"))); + m_viewMenu->addAction(tr("Index"), this, SLOT(showIndex()), + QKeySequence(tr("ALT+I"))); + m_viewMenu->addAction(tr("Bookmarks"), this, SLOT(showBookmarks()), + QKeySequence(tr("ALT+O"))); + m_viewMenu->addAction(tr("Search"), this, SLOT(showSearch()), + QKeySequence(tr("ALT+S"))); menu = menuBar()->addMenu(tr("&Go")); - m_homeAction = menu->addAction(tr("&Home"), - m_centralWidget, SLOT(home())); + m_homeAction = menu->addAction(tr("&Home"), m_centralWidget, SLOT(home())); m_homeAction->setShortcut(tr("Ctrl+Home")); - m_homeAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/home.png").arg(system))); + m_homeAction->setIcon(QIcon(resourcePath + QLatin1String("/home.png"))); - m_backAction = menu->addAction(tr("&Back"), - m_centralWidget, SLOT(backward())); + m_backAction = menu->addAction(tr("&Back"), m_centralWidget, SLOT(backward())); m_backAction->setEnabled(false); - m_backAction->setShortcuts(QList<QKeySequence>() - << QKeySequence(Qt::CTRL|Qt::Key_Left) << QKeySequence::Back); - m_backAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/previous.png").arg(system))); + m_backAction->setShortcuts(QKeySequence::Back); + m_backAction->setIcon(QIcon(resourcePath + QLatin1String("/previous.png"))); - m_nextAction = menu->addAction(tr("&Forward"), - m_centralWidget, SLOT(forward())); + m_nextAction = menu->addAction(tr("&Forward"), m_centralWidget, SLOT(forward())); m_nextAction->setEnabled(false); - m_nextAction->setShortcuts(QList<QKeySequence>() - << QKeySequence(Qt::CTRL|Qt::Key_Right) << QKeySequence::Forward); - m_nextAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/next.png").arg(system))); + m_nextAction->setShortcuts(QKeySequence::Forward); + m_nextAction->setIcon(QIcon(resourcePath + QLatin1String("/next.png"))); - m_syncAction = menu->addAction(tr("Sync with Table of Contents"), - this, SLOT(syncContents())); - m_syncAction->setIcon(QIcon( - QString::fromUtf8(":/trolltech/assistant/images/%1/synctoc.png").arg(system))); + m_syncAction = menu->addAction(tr("Sync with Table of Contents"), this, + SLOT(syncContents())); + m_syncAction->setIcon(QIcon(resourcePath + QLatin1String("/synctoc.png"))); menu->addSeparator(); @@ -496,8 +487,7 @@ void MainWindow::setupActions() tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+Alt+Right")) << QKeySequence(Qt::CTRL + Qt::Key_PageDown)); - tmp = menu->addAction(tr("Previous Page"), - m_centralWidget, SLOT(previousPage())); + tmp = menu->addAction(tr("Previous Page"), m_centralWidget, SLOT(previousPage())); tmp->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+Alt+Left")) << QKeySequence(Qt::CTRL + Qt::Key_PageUp)); @@ -525,53 +515,52 @@ void MainWindow::setupActions() navigationBar->addAction(m_resetZoomAction); QList<QAction*> actionList; - actionList << m_backAction << m_nextAction << m_homeAction; - actionList << sep << m_zoomInAction << m_zoomOutAction; - actionList << sep2 << m_copyAction << m_printAction << m_findAction; + actionList << m_backAction << m_nextAction << m_homeAction << sep + << m_zoomInAction << m_zoomOutAction << sep2 << m_copyAction + << m_printAction << m_findAction; m_centralWidget->setGlobalActions(actionList); #if defined(Q_WS_MAC) QMenu *windowMenu = new QMenu(tr("&Window"), this); menuBar()->insertMenu(menu->menuAction(), windowMenu); - windowMenu->addAction(tr("Minimize"), this, - SLOT(showMinimized()), QKeySequence(tr("Ctrl+M"))); - windowMenu->addAction(tr("Zoom"), this, - SLOT(showMaximized())); + windowMenu->addAction(tr("Zoom"), this, SLOT(showMaximized())); + windowMenu->addAction(tr("Minimize"), this, SLOT(showMinimized()), + QKeySequence(tr("Ctrl+M"))); #endif // content viewer connections - connect(m_centralWidget, SIGNAL(copyAvailable(bool)), - this, SLOT(copyAvailable(bool))); - connect(m_centralWidget, SIGNAL(currentViewerChanged()), - this, SLOT(updateNavigationItems())); - connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), - this, SLOT(updateNavigationItems())); - connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), - this, SLOT(updateNavigationItems())); - connect(m_centralWidget, SIGNAL(highlighted(const QString&)), - statusBar(), SLOT(showMessage(const QString&))); - connect(m_centralWidget, SIGNAL(addNewBookmark(const QString&, - const QString&)), this, SLOT(addNewBookmark(const QString&, const QString&))); + connect(m_centralWidget, SIGNAL(copyAvailable(bool)), this, + SLOT(copyAvailable(bool))); + connect(m_centralWidget, SIGNAL(currentViewerChanged()), this, + SLOT(updateNavigationItems())); + connect(m_centralWidget, SIGNAL(forwardAvailable(bool)), this, + SLOT(updateNavigationItems())); + connect(m_centralWidget, SIGNAL(backwardAvailable(bool)), this, + SLOT(updateNavigationItems())); + connect(m_centralWidget, SIGNAL(highlighted(QString)), statusBar(), + SLOT(showMessage(QString))); + connect(m_centralWidget, SIGNAL(addNewBookmark(QString, QString)), this, + SLOT(addNewBookmark(QString, QString))); // bookmarks - connect(m_bookmarkWidget, SIGNAL(requestShowLink(const QUrl&)), - m_centralWidget, SLOT(setSource(const QUrl&))); - connect(m_bookmarkWidget, SIGNAL(escapePressed()), - this, SLOT(activateCurrentCentralWidgetTab())); + connect(m_bookmarkWidget, SIGNAL(requestShowLink(QUrl)), m_centralWidget, + SLOT(setSource(QUrl))); + connect(m_bookmarkWidget, SIGNAL(escapePressed()), this, + SLOT(activateCurrentCentralWidgetTab())); // index window - connect(m_indexWindow, SIGNAL(linkActivated(const QUrl&)), - m_centralWidget, SLOT(setSource(const QUrl&))); - connect(m_indexWindow, SIGNAL(linksActivated(const QMap<QString, QUrl>&, const QString&)), - this, SLOT(showTopicChooser(const QMap<QString, QUrl>&, const QString&))); - connect(m_indexWindow, SIGNAL(escapePressed()), - this, SLOT(activateCurrentCentralWidgetTab())); + connect(m_indexWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget, + SLOT(setSource(QUrl))); + connect(m_indexWindow, SIGNAL(linksActivated(QMap<QString, QUrl>, QString)), + this, SLOT(showTopicChooser(QMap<QString, QUrl>, QString))); + connect(m_indexWindow, SIGNAL(escapePressed()), this, + SLOT(activateCurrentCentralWidgetTab())); // content window - connect(m_contentWindow, SIGNAL(linkActivated(const QUrl&)), - m_centralWidget, SLOT(setSource(const QUrl&))); - connect(m_contentWindow, SIGNAL(escapePressed()), - this, SLOT(activateCurrentCentralWidgetTab())); + connect(m_contentWindow, SIGNAL(linkActivated(QUrl)), m_centralWidget, + SLOT(setSource(QUrl))); + connect(m_contentWindow, SIGNAL(escapePressed()), this, + SLOT(activateCurrentCentralWidgetTab())); #if defined(QT_NO_PRINTER) m_pageSetupAction->setVisible(false); @@ -601,17 +590,19 @@ void MainWindow::setupFilterToolbar() QToolBar *filterToolBar = addToolBar(tr("Filter Toolbar")); filterToolBar->setObjectName(QLatin1String("FilterToolBar")); - filterToolBar->addWidget(new QLabel(tr("Filtered by:").append(QLatin1String(" ")), this)); + filterToolBar->addWidget(new QLabel(tr("Filtered by:").append(QLatin1Char(' ')), + this)); filterToolBar->addWidget(m_filterCombo); - if (m_helpEngine->customValue(QLatin1String("HideFilterFunctionality"), true).toBool()) + const QLatin1String hideFilter("HideFilterFunctionality"); + if (m_helpEngine->customValue(hideFilter, true).toBool()) filterToolBar->hide(); toolBarMenu()->addAction(filterToolBar->toggleViewAction()); - connect(m_helpEngine, SIGNAL(setupFinished()), - this, SLOT(setupFilterCombo())); - connect(m_filterCombo, SIGNAL(activated(const QString&)), - this, SLOT(filterDocumentation(const QString&))); + connect(m_helpEngine, SIGNAL(setupFinished()), this, + SLOT(setupFilterCombo())); + connect(m_filterCombo, SIGNAL(activated(const QString&)), this, + SLOT(filterDocumentation(const QString&))); setupFilterCombo(); } @@ -626,7 +617,8 @@ void MainWindow::setupAddressToolbar() addressToolBar->setObjectName(QLatin1String("AddressToolBar")); insertToolBarBreak(addressToolBar); - addressToolBar->addWidget(new QLabel(tr("Address:").append(QLatin1String(" ")), this)); + addressToolBar->addWidget(new QLabel(tr("Address:").append(QLatin1String(" ")), + this)); addressToolBar->addWidget(m_addressLineEdit); if (m_helpEngine->customValue(QLatin1String("HideAddressBar"), true).toBool()) @@ -684,7 +676,8 @@ void MainWindow::showNewAddress(const QUrl &url) void MainWindow::addBookmark() { - addNewBookmark(m_centralWidget->currentTitle(), m_centralWidget->currentSource().toString()); + addNewBookmark(m_centralWidget->currentTitle(), + m_centralWidget->currentSource().toString()); } void MainWindow::gotoAddress() @@ -784,7 +777,8 @@ void MainWindow::showAboutDialog() if (!contents.isEmpty()) { iconArray = m_helpEngine->customValue(QLatin1String("AboutIcon"), QByteArray()).toByteArray(); - QByteArray resources = m_helpEngine->customValue(QLatin1String("AboutImages"), + QByteArray resources = + m_helpEngine->customValue(QLatin1String("AboutImages"), QByteArray()).toByteArray(); QPixmap pix; pix.loadFromData(iconArray); @@ -795,13 +789,16 @@ void MainWindow::showAboutDialog() } else { #if QT_EDITION == QT_EDITION_OPENSOURCE QString edition = tr("Open Source Edition"); - QString info = tr("This version of Qt Assistant is part of the Qt Open Source Edition, for use " + QString info = tr("This version of Qt Assistant is part of the Qt Open " + "Source Edition, for use " "in the development of Open Source applications. " "Qt is a comprehensive C++ framework for cross-platform application " "development."); - QString moreInfo = tr("You need a commercial Qt license for development of proprietary (closed " - "source) applications. Please see <a href=\"http://qtsoftware.com/company/about/businessmodel" - "\">http://qtsoftware.com/company/about/businessmodel</a> for an overview of Qt licensing."); + QString moreInfo = tr("You need a commercial Qt license for development " + "of proprietary (closed source) applications. Please see " + "<a href=\"http://qtsoftware.com/company/about/businessmodel" + "\">http://qtsoftware.com/company/about/businessmodel</a> for an " + "overview of Qt licensing."); #else QString edition; QString info; @@ -816,13 +813,14 @@ void MainWindow::showAboutDialog() "<p>Version %2 %3</p></center>" "<p>%4</p>" "<p>%5</p>" - "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).</p>" - "<p>The program is provided AS IS with NO WARRANTY OF ANY KIND," + "<p>Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)" + ".</p><p>The program is provided AS IS with NO WARRANTY OF ANY KIND," " INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A" " PARTICULAR PURPOSE.<p/>") .arg(tr("Qt Assistant")).arg(QLatin1String(QT_VERSION_STR)) .arg(edition).arg(info).arg(moreInfo), resources); - aboutDia.setPixmap(QString::fromLatin1(":/trolltech/assistant/images/assistant-128.png")); + QLatin1String path(":/trolltech/assistant/images/assistant-128.png"); + aboutDia.setPixmap(QString(path)); } if (aboutDia.windowTitle().isEmpty()) aboutDia.setWindowTitle(tr("About %1").arg(windowTitle())); @@ -974,20 +972,19 @@ QWidget* MainWindow::setupBookmarkWidget() QString MainWindow::collectionFileDirectory(bool createDir, const QString &cacheDir) { - QString collectionPath = QDesktopServices::storageLocation(QDesktopServices::DataLocation); + QString collectionPath = + QDesktopServices::storageLocation(QDesktopServices::DataLocation); if (collectionPath.isEmpty()) { if (cacheDir.isEmpty()) collectionPath = QDir::homePath() + QDir::separator() + QLatin1String(".assistant"); else - collectionPath = QDir::homePath() + QLatin1String("/.") - + cacheDir; + collectionPath = QDir::homePath() + QLatin1String("/.") + cacheDir; } else { if (cacheDir.isEmpty()) collectionPath = collectionPath + QLatin1String("/Trolltech/Assistant"); else - collectionPath = collectionPath + QDir::separator() - + cacheDir; + collectionPath = collectionPath + QDir::separator() + cacheDir; } collectionPath = QDir::cleanPath(collectionPath); if (createDir) { @@ -1001,8 +998,8 @@ QString MainWindow::collectionFileDirectory(bool createDir, const QString &cache QString MainWindow::defaultHelpCollectionFileName() { return collectionFileDirectory() + QDir::separator() + - QString(QLatin1String("qthelpcollection_%1.qhc")). - arg(QLatin1String(QT_VERSION_STR)); + QString(QLatin1String("qthelpcollection_%1.qhc")). + arg(QLatin1String(QT_VERSION_STR)); } QT_END_NAMESPACE diff --git a/tools/assistant/tools/assistant/mainwindow.h b/tools/assistant/tools/assistant/mainwindow.h index 8b87b7b..c716b1c 100644 --- a/tools/assistant/tools/assistant/mainwindow.h +++ b/tools/assistant/tools/assistant/mainwindow.h @@ -72,7 +72,7 @@ public: MainWindow(CmdLineParser *cmdLine, QWidget *parent = 0); ~MainWindow(); - static void activateCurrentBrowser(); + static void activateCurrentBrowser(); static QString collectionFileDirectory(bool createDir = false, const QString &cacheDir = QString()); static QString defaultHelpCollectionFileName(); @@ -103,12 +103,12 @@ private slots: void gotoAddress(); void showPreferences(); void showNewAddress(); - void showAboutDialog(); + void showAboutDialog(); void copyAvailable(bool yes); void updateNavigationItems(); void showNewAddress(const QUrl &url); void addNewBookmark(const QString &title, const QString &url); - void showTopicChooser(const QMap<QString, QUrl> &links, const QString &keyword); + void showTopicChooser(const QMap<QString, QUrl> &links, const QString &keyword); void updateApplicationFont(); void filterDocumentation(const QString &customFilter); void setupFilterCombo(); @@ -128,7 +128,7 @@ private: void setupFilterToolbar(); void setupAddressToolbar(); QMenu *toolBarMenu(); - QWidget *setupBookmarkWidget(); + QWidget *setupBookmarkWidget(); QHelpEngine *m_helpEngine; CentralWidget *m_centralWidget; |