From 3e03276736d89e1ab214b50d57bf2ba6f6d560f7 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 1 Mar 2010 11:43:09 +0100 Subject: Introduce optional qdoc_bootstrapped qmake flag This allows building documentation even when cross-compiling. Note that for official documentation, you should always use your host's qdoc3 binary. This qmake option is for testing whether you introduced new qdoc warnings even if you don't have a native build around. --- tools/qdoc3/codeparser.cpp | 1 - tools/qdoc3/command.cpp | 9 +++++++++ tools/qdoc3/config.cpp | 6 +++++- tools/qdoc3/cppcodeparser.cpp | 1 - tools/qdoc3/doc.h | 1 + tools/qdoc3/generator.cpp | 1 - tools/qdoc3/helpprojectwriter.cpp | 1 - tools/qdoc3/jambiapiparser.cpp | 2 -- tools/qdoc3/main.cpp | 17 ++++++++++++++--- tools/qdoc3/node.cpp | 4 ++-- tools/qdoc3/pagegenerator.cpp | 3 +-- tools/qdoc3/qdoc3.pro | 16 ++++++++++++---- tools/qdoc3/tree.cpp | 3 ++- tools/qdoc3/webxmlgenerator.cpp | 4 ++-- tools/qdoc3/webxmlgenerator.h | 5 +++++ 15 files changed, 53 insertions(+), 21 deletions(-) diff --git a/tools/qdoc3/codeparser.cpp b/tools/qdoc3/codeparser.cpp index 5ae63ac..042378e 100644 --- a/tools/qdoc3/codeparser.cpp +++ b/tools/qdoc3/codeparser.cpp @@ -43,7 +43,6 @@ codeparser.cpp */ -#include #include "codeparser.h" #include "node.h" #include "tree.h" diff --git a/tools/qdoc3/command.cpp b/tools/qdoc3/command.cpp index 76b483c..b78ad07 100644 --- a/tools/qdoc3/command.cpp +++ b/tools/qdoc3/command.cpp @@ -47,6 +47,8 @@ #include "command.h" +#include + QT_BEGIN_NAMESPACE void executeCommand(const Location& location, @@ -69,6 +71,12 @@ void executeCommand(const Location& location, if (space != -1) toolName.truncate(space); +#ifdef QT_BOOTSTRAPPED + int status = system(qPrintable(actualCommand)); + int exitCode = WEXITSTATUS(status); + if (status == -1 || exitCode != EXIT_SUCCESS) + location.fatal(QString("Error executing '$1': $2").arg(toolName).arg(exitCode)); +#else QProcess process; process.start(QLatin1String("sh"), QStringList() << QLatin1String("-c") << actualCommand); @@ -89,6 +97,7 @@ void executeCommand(const Location& location, tr("The tool was invoked like this:\n%1\n" "It emitted these errors:\n%2") .arg(actualCommand).arg(errors)); +#endif } QT_END_NAMESPACE diff --git a/tools/qdoc3/config.cpp b/tools/qdoc3/config.cpp index acb1576..3150f28 100644 --- a/tools/qdoc3/config.cpp +++ b/tools/qdoc3/config.cpp @@ -43,7 +43,11 @@ config.cpp */ -#include +#include +#include +#include +#include +#include #include "archiveextractor.h" #include "config.h" diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index 021d64a..e144a74 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -43,7 +43,6 @@ cppcodeparser.cpp */ -#include #include #include diff --git a/tools/qdoc3/doc.h b/tools/qdoc3/doc.h index e98bb26..3e76456 100644 --- a/tools/qdoc3/doc.h +++ b/tools/qdoc3/doc.h @@ -48,6 +48,7 @@ #include #include +#include #include "location.h" diff --git a/tools/qdoc3/generator.cpp b/tools/qdoc3/generator.cpp index 6a8899a..200a0e7 100644 --- a/tools/qdoc3/generator.cpp +++ b/tools/qdoc3/generator.cpp @@ -42,7 +42,6 @@ /* generator.cpp */ -#include #include #include #include "codemarker.h" diff --git a/tools/qdoc3/helpprojectwriter.cpp b/tools/qdoc3/helpprojectwriter.cpp index 2189e02..71810e4 100644 --- a/tools/qdoc3/helpprojectwriter.cpp +++ b/tools/qdoc3/helpprojectwriter.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include #include #include diff --git a/tools/qdoc3/jambiapiparser.cpp b/tools/qdoc3/jambiapiparser.cpp index 3aba1b0..23f2716 100644 --- a/tools/qdoc3/jambiapiparser.cpp +++ b/tools/qdoc3/jambiapiparser.cpp @@ -43,8 +43,6 @@ jambiapiparser.cpp */ -#include - #include "cppcodeparser.h" #include "jambiapiparser.h" #include "node.h" diff --git a/tools/qdoc3/main.cpp b/tools/qdoc3/main.cpp index 57823fb..ea843ba 100644 --- a/tools/qdoc3/main.cpp +++ b/tools/qdoc3/main.cpp @@ -44,7 +44,6 @@ */ #include -#include #include #include "apigenerator.h" #include "codemarker.h" @@ -72,6 +71,11 @@ #include "tokenizer.h" #include "tree.h" +#include "qtranslator.h" +#ifndef QT_BOOTSTRAPPED +# include "qcoreapplication.h" +#endif + QT_BEGIN_NAMESPACE /* @@ -151,7 +155,9 @@ static void printVersion() */ static void processQdocconfFile(const QString &fileName) { +#ifndef QT_NO_TRANSLATION QList translators; +#endif /* The Config instance represents the configuration data for qdoc. @@ -207,6 +213,7 @@ static void processQdocconfFile(const QString &fileName) CodeParser::initialize(config); Generator::initialize(config); +#ifndef QT_NO_TRANSLATION /* Load the language translators, if the configuration specifies any. */ @@ -221,6 +228,7 @@ static void processQdocconfFile(const QString &fileName) translators.append(translator); ++fn; } +#endif //QSet outputLanguages = config.getStringSet(CONFIG_OUTPUTLANGUAGES); @@ -351,8 +359,9 @@ static void processQdocconfFile(const QString &fileName) Location::terminate(); QDir::setCurrent(prevCurrentDir); - foreach (QTranslator *translator, translators) - delete translator; +#ifndef QT_NO_TRANSLATION + qDeleteAll(translators); +#endif delete tree; } @@ -362,7 +371,9 @@ int main(int argc, char **argv) { QT_USE_NAMESPACE +#ifndef QT_BOOTSTRAPPED QCoreApplication app(argc, argv); +#endif QString cf = "qsauncompress \1 \2"; PolyArchiveExtractor qsaExtractor(QStringList() << "qsa",cf); cf = "tar -C \2 -xf \1"; diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index 4ddcfb1..694f499 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -43,7 +43,6 @@ node.cpp */ -#include #include "node.h" QT_BEGIN_NAMESPACE @@ -1161,7 +1160,8 @@ QString FunctionNode::signature(bool values) const */ void FunctionNode::debug() const { - qDebug() << "QML METHOD" << name() << "rt" << rt << "pp" << pp; + qDebug("QML METHOD %s rt %s pp %s", + qPrintable(name()), qPrintable(rt), qPrintable(pp.join(" "))); } /*! diff --git a/tools/qdoc3/pagegenerator.cpp b/tools/qdoc3/pagegenerator.cpp index 2cad9ed..f0f14fe 100644 --- a/tools/qdoc3/pagegenerator.cpp +++ b/tools/qdoc3/pagegenerator.cpp @@ -43,7 +43,6 @@ pagegenerator.cpp */ -#include #include #include @@ -212,7 +211,7 @@ void PageGenerator::generateInnerNode(const InnerNode *node, #endif if (fakeNode->subType() == Node::Page) { if (node->count() > 0) - qDebug() << "PAGE" << fakeNode->title() << "HAS CHILDREN"; + qDebug("PAGE %s HAS CHILDREN", qPrintable(fakeNode->title())); } } diff --git a/tools/qdoc3/qdoc3.pro b/tools/qdoc3/qdoc3.pro index 7705692..e394799 100644 --- a/tools/qdoc3/qdoc3.pro +++ b/tools/qdoc3/qdoc3.pro @@ -4,9 +4,16 @@ DEFINES += QT_NO_CAST_TO_ASCII #DEFINES += QT_USE_FAST_OPERATOR_PLUS #DEFINES += QT_USE_FAST_CONCATENATION -QT = core xml -CONFIG += console -CONFIG -= debug_and_release_target +qdoc_bootstrapped { + include(../../src/tools/bootstrap/bootstrap.pri) + DEFINES -= QT_NO_CAST_FROM_ASCII + DEFINES += QT_NO_TRANSLATION +} else { + QT = core xml + CONFIG += console + CONFIG -= debug_and_release_target +} + !isEmpty(QT_BUILD_TREE):DESTDIR = $$QT_BUILD_TREE/bin #CONFIG += debug build_all:!build_pass { @@ -14,7 +21,8 @@ build_all:!build_pass { CONFIG += release # CONFIG += debug } -mac:CONFIG -= app_bundle + +CONFIG -= app_bundle HEADERS += apigenerator.h \ archiveextractor.h \ atom.h \ diff --git a/tools/qdoc3/tree.cpp b/tools/qdoc3/tree.cpp index 6c2502d..922c23e 100644 --- a/tools/qdoc3/tree.cpp +++ b/tools/qdoc3/tree.cpp @@ -43,7 +43,6 @@ tree.cpp */ -#include #include #include "atom.h" @@ -54,6 +53,8 @@ #include "text.h" #include "tree.h" +#include + QT_BEGIN_NAMESPACE struct InheritanceBound diff --git a/tools/qdoc3/webxmlgenerator.cpp b/tools/qdoc3/webxmlgenerator.cpp index 205bc8c..6020b1b 100644 --- a/tools/qdoc3/webxmlgenerator.cpp +++ b/tools/qdoc3/webxmlgenerator.cpp @@ -43,8 +43,6 @@ webxmlgenerator.cpp */ -#include - #include "codemarker.h" #include "pagegenerator.h" #include "webxmlgenerator.h" @@ -52,6 +50,8 @@ #include "separator.h" #include "tree.h" +#include + QT_BEGIN_NAMESPACE #define COMMAND_VERSION Doc::alias("version") diff --git a/tools/qdoc3/webxmlgenerator.h b/tools/qdoc3/webxmlgenerator.h index cadf176..071896a 100644 --- a/tools/qdoc3/webxmlgenerator.h +++ b/tools/qdoc3/webxmlgenerator.h @@ -46,12 +46,17 @@ #ifndef WEBXMLGENERATOR_H #define WEBXMLGENERATOR_H +#include + #include "codemarker.h" #include "config.h" #include "pagegenerator.h" QT_BEGIN_NAMESPACE +class QXmlStreamReader; +class QXmlStreamWriter; + class WebXMLGenerator : public PageGenerator { public: -- cgit v0.12 From 9fe43ff4e313220a1ecb02a990324cb6b768e585 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 25 Feb 2010 16:48:33 +0100 Subject: Fixed coordinate system conversion for gestures. When converting hotspot position (which is in global coordinates) to graphics scene coordinates we should use the viewport because the mapToScene() takes a position in a viewport. Task-number: related to QTBUG-6876 Reviewed-by: Thomas Zander --- src/gui/graphicsview/qgraphicsscene.cpp | 8 +++--- tests/auto/gestures/tst_gestures.cpp | 45 ++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 365afdd..a72761a 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -5972,12 +5972,12 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) QList allGestures = event->gestures(); DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" - << "Delivering gestures:" << allGestures; + << "Gestures:" << allGestures; QSet startedGestures; - QPoint delta = graphicsView->mapFromGlobal(QPoint()); - QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y()) - * graphicsView->viewportTransform().inverted(); + QPoint delta = viewport->mapFromGlobal(QPoint()); + QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y()) + * graphicsView->viewportTransform().inverted(); foreach (QGesture *gesture, allGestures) { // cache scene coordinates of the hot spot if (gesture->hasHotSpot()) { diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index a2058cd..a1afa0a 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -58,7 +58,7 @@ static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view) { - return view->mapToGlobal(view->mapFromScene(item->mapToScene(pt))); + return view->viewport()->mapToGlobal(view->mapFromScene(item->mapToScene(pt))); } class CustomGesture : public QGesture @@ -353,6 +353,7 @@ private slots: void deleteGestureTargetWidget(); void deleteGestureTargetItem_data(); void deleteGestureTargetItem(); + void viewportCoordinates(); }; tst_Gestures::tst_Gestures() @@ -742,7 +743,6 @@ public: ignoredFinishedGestures.clear(); } -protected: QRectF boundingRect() const { return size; @@ -1771,7 +1771,6 @@ void tst_Gestures::panelStacksBehindParent() void tst_Gestures::deleteGestureTargetWidget() { - } void tst_Gestures::deleteGestureTargetItem_data() @@ -1857,5 +1856,45 @@ void tst_Gestures::deleteGestureTargetItem() sendCustomGesture(&event, item1, &scene); } +class GraphicsView : public QGraphicsView +{ +public: + GraphicsView(QGraphicsScene *scene, QWidget *parent = 0) + : QGraphicsView(scene, parent) + { + } + + using QGraphicsView::setViewportMargins; +}; + +// just making sure that even if the graphicsview has margins hotspot still +// works properly. It should use viewport for converting global coordinates to +// scene coordinates. +void tst_Gestures::viewportCoordinates() +{ + QGraphicsScene scene; + GraphicsView view(&scene); + view.setViewportMargins(10,20,15,25); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); + + GestureItem *item1 = new GestureItem("item1"); + item1->grabGesture(CustomGesture::GestureType); + item1->size = QRectF(0, 0, 3, 3); + item1->setZValue(2); + scene.addItem(item1); + + view.show(); + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); + + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); + + CustomEvent event; + event.hotSpot = mapToGlobal(item1->boundingRect().center(), item1, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item1, &scene); + QVERIFY(item1->gestureEventsReceived != 0); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 82e224ee5e5388e8b5be186db6a60339e7b8fba3 Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 1 Mar 2010 14:13:45 +0100 Subject: Fix compilation with namespace. --- src/corelib/tools/qsimd_p.h | 4 ++-- src/declarative/qml/qdeclarativebinding_p.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 44c1798..53593aa 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -117,10 +117,10 @@ enum CPUFeatures { }; +Q_CORE_EXPORT uint qDetectCPUFeatures(); + QT_END_NAMESPACE QT_END_HEADER -Q_CORE_EXPORT uint qDetectCPUFeatures(); - #endif // QSIMD_P_H diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h index f66b9c7..ec5809d 100644 --- a/src/declarative/qml/qdeclarativebinding_p.h +++ b/src/declarative/qml/qdeclarativebinding_p.h @@ -130,8 +130,9 @@ protected: private: Q_DECLARE_PRIVATE(QDeclarativeBinding) }; -Q_DECLARE_METATYPE(QDeclarativeBinding*); QT_END_NAMESPACE +Q_DECLARE_METATYPE(QDeclarativeBinding*); + #endif // QDECLARATIVEBINDING_P_H -- cgit v0.12 From 51bfbc326be268f552650dc30408479150a36744 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 1 Mar 2010 15:21:32 +0100 Subject: Extended gesture autotest. Make sure partial gestures do not propagate further if an item that expects partial gestures received it. Task-number: resulted from QTBUG-6876 Reviewed-by: trustme --- src/gui/graphicsview/qgraphicsscene.cpp | 7 ++++- tests/auto/gestures/tst_gestures.cpp | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a72761a..6bc02cc 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -6003,7 +6003,8 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) cachedTargetItems = cachedItemGestures.keys(); qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst); DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" - << "Conflicting gestures:" << conflictedGestures; + << "Normal gestures:" << normalGestures + << "Conflicting gestures:" << conflictedGestures; // deliver conflicted gestures as override events AND remember // initial gesture targets @@ -6080,6 +6081,10 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) const Qt::GestureFlags flags = d->gestureContext.value(gesture->gestureType()); if (flags & Qt::IgnoredGesturesPropagateToParent) parentPropagatedGestures.insert(gesture); + } else { + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "no target for" << gesture << "at" + << gesture->hotSpot() << gesture->d_func()->sceneHotSpot; } } qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst); diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index a1afa0a..f8ecca3 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -354,6 +354,7 @@ private slots: void deleteGestureTargetItem_data(); void deleteGestureTargetItem(); void viewportCoordinates(); + void partialGesturePropagation(); }; tst_Gestures::tst_Gestures() @@ -1896,5 +1897,57 @@ void tst_Gestures::viewportCoordinates() QVERIFY(item1->gestureEventsReceived != 0); } +void tst_Gestures::partialGesturePropagation() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); + + GestureItem *item1 = new GestureItem("item1"); + item1->grabGesture(CustomGesture::GestureType); + item1->setZValue(8); + scene.addItem(item1); + + GestureItem *item2 = new GestureItem("item2[partial]"); + item2->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures); + item2->setZValue(6); + scene.addItem(item2); + + GestureItem *item3 = new GestureItem("item3"); + item3->grabGesture(CustomGesture::GestureType); + item3->setZValue(4); + scene.addItem(item3); + + GestureItem *item4 = new GestureItem("item4[partial]"); + item4->grabGesture(CustomGesture::GestureType, Qt::ReceivePartialGestures); + item4->setZValue(2); + scene.addItem(item4); + + view.show(); + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); + + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren); + + item1->ignoredUpdatedGestures << CustomGesture::GestureType; + + CustomEvent event; + event.hotSpot = mapToGlobal(QPointF(5, 5), item1, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item1, &scene); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + + QCOMPARE(item1->gestureOverrideEventsReceived, 1); + QCOMPARE(item2->gestureOverrideEventsReceived, 1); + QCOMPARE(item3->gestureOverrideEventsReceived, 1); + QCOMPARE(item4->gestureOverrideEventsReceived, 1); + + QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount-2); // except for started and finished + QCOMPARE(item3->gestureEventsReceived, 0); + QCOMPARE(item4->gestureEventsReceived, 0); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 7afc26c45ba19ba1fa077629e388be32ea1664bc Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 1 Mar 2010 15:39:17 +0100 Subject: compile --- src/multimedia/qml/qsoundeffect_pulse_p.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/multimedia/qml/qsoundeffect_pulse_p.cpp b/src/multimedia/qml/qsoundeffect_pulse_p.cpp index ec851aa..f7870c2 100644 --- a/src/multimedia/qml/qsoundeffect_pulse_p.cpp +++ b/src/multimedia/qml/qsoundeffect_pulse_p.cpp @@ -63,7 +63,7 @@ #include "qsoundeffect_pulse_p.h" -#if(Q_WS_MAEMO_5) +#if defined(Q_WS_MAEMO_5) #include #endif @@ -155,7 +155,7 @@ private: lock(); m_context = pa_context_new(m_mainLoopApi, QString(QLatin1String("QtPulseAudio:%1")).arg(::getpid()).toAscii().constData()); -#if(Q_WS_MAEMO_5) +#if defined(Q_WS_MAEMO_5) pa_context_set_state_callback(m_context, context_state_callback, this); #endif if (m_context == 0) { @@ -183,7 +183,7 @@ private: m_prepared = false; } -#if(Q_WS_MAEMO_5) +#if defined(Q_WS_MAEMO_5) static void context_state_callback(pa_context *c, void *userdata) { PulseDaemon *self = reinterpret_cast(userdata); @@ -299,7 +299,7 @@ void QSoundEffectPrivate::play() pa_volume_t m_vol = PA_VOLUME_NORM; daemon()->lock(); -#if(Q_WS_MAEMO_5) +#if defined(Q_WS_MAEMO_5) m_vol = PA_VOLUME_NORM/100*((daemon()->volume()+m_vol)/2); #endif pa_operation_unref( -- cgit v0.12 From 340eb4f20a5976be77ee66bbfc2ef16c97b033d2 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 1 Mar 2010 14:43:24 +0100 Subject: replace temporary disconnection with a very simple statemachine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this also fixes an issue with non-constant ordering of connections to document's contentsChange() signal Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer --- src/gui/text/qsyntaxhighlighter.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 6750c09..9b3671d 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -59,23 +59,24 @@ class QSyntaxHighlighterPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QSyntaxHighlighter) public: - inline QSyntaxHighlighterPrivate() : rehighlightPending(false) {} + inline QSyntaxHighlighterPrivate() + : rehighlightPending(false), inReformatBlocks(false) + {} QPointer doc; void _q_reformatBlocks(int from, int charsRemoved, int charsAdded); + void reformatBlocks(int from, int charsRemoved, int charsAdded); void reformatBlock(QTextBlock block); inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) { - QObject::disconnect(doc, SIGNAL(contentsChange(int,int,int)), - q_func(), SLOT(_q_reformatBlocks(int,int,int))); + inReformatBlocks = true; cursor.beginEditBlock(); int from = cursor.position(); cursor.movePosition(operation); - _q_reformatBlocks(from, 0, cursor.position() - from); + reformatBlocks(from, 0, cursor.position() - from); cursor.endEditBlock(); - QObject::connect(doc, SIGNAL(contentsChange(int,int,int)), - q_func(), SLOT(_q_reformatBlocks(int,int,int))); + inReformatBlocks = false; } inline void _q_delayedRehighlight() { @@ -90,6 +91,7 @@ public: QVector formatChanges; QTextBlock currentBlock; bool rehighlightPending; + bool inReformatBlocks; }; void QSyntaxHighlighterPrivate::applyFormatChanges() @@ -162,6 +164,12 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, int charsAdded) { + if (!inReformatBlocks) + reformatBlocks(from, charsRemoved, charsAdded); +} + +void QSyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int charsAdded) +{ Q_UNUSED(charsRemoved); rehighlightPending = false; -- cgit v0.12 From 6d51c7b9d1f6700564ec9e3c3f7b41b6b94a74da Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 1 Mar 2010 14:43:26 +0100 Subject: don't cancel the scheduled complete rehighlight from rehighlightBlock() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit if rehighlightBlock() is called just after setDocument() then it is possible that reformatBlocks() will be called just before q_delayedRehighlight() and thus will prevent previously scheduled complete rehighlighting. Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer --- src/gui/text/qsyntaxhighlighter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 9b3671d..b5a7aa1 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -402,8 +402,13 @@ void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block) if (!d->doc) return; + const bool rehighlightPending = d->rehighlightPending; + QTextCursor cursor(block); d->rehighlight(cursor, QTextCursor::EndOfBlock); + + if (rehighlightPending) + d->rehighlightPending = rehighlightPending; } /*! -- cgit v0.12 From 667ef5950bc16ff8582ac32f5150fc9f45a09682 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 1 Mar 2010 14:43:28 +0100 Subject: don't even try to rehighlight invalid or alien block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer --- src/gui/text/qsyntaxhighlighter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index b5a7aa1..de16ca5 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -399,7 +399,7 @@ void QSyntaxHighlighter::rehighlight() void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block) { Q_D(QSyntaxHighlighter); - if (!d->doc) + if (!d->doc || !block.isValid() || block.document() != d->doc) return; const bool rehighlightPending = d->rehighlightPending; -- cgit v0.12 From 24c5bc6c0c5c23d808f055dabefd15a551cb0902 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 1 Mar 2010 14:43:30 +0100 Subject: minor clean-ups and styling fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer --- src/gui/text/qsyntaxhighlighter.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index de16ca5..02dabbb 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -67,8 +67,8 @@ public: void _q_reformatBlocks(int from, int charsRemoved, int charsAdded); void reformatBlocks(int from, int charsRemoved, int charsAdded); - void reformatBlock(QTextBlock block); - + void reformatBlock(const QTextBlock &block); + inline void rehighlight(QTextCursor &cursor, QTextCursor::MoveOperation operation) { inReformatBlocks = true; cursor.beginEditBlock(); @@ -84,7 +84,6 @@ public: return; rehighlightPending = false; q_func()->rehighlight(); - return; } void applyFormatChanges(); @@ -106,10 +105,11 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() QList::Iterator it = ranges.begin(); while (it != ranges.end()) { if (it->start >= preeditAreaStart - && it->start + it->length <= preeditAreaStart + preeditAreaLength) + && it->start + it->length <= preeditAreaStart + preeditAreaLength) { ++it; - else + } else { it = ranges.erase(it); + } } QTextCharFormat emptyFormat; @@ -137,11 +137,10 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() r.length = i - r.start; - if (r.start >= preeditAreaStart) { + if (r.start >= preeditAreaStart) r.start += preeditAreaLength; - } else if (r.start + r.length >= preeditAreaStart) { + else if (r.start + r.length >= preeditAreaStart) r.length += preeditAreaLength; - } ranges << r; r.start = r.length = -1; @@ -150,11 +149,10 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() if (r.start != -1) { r.length = formatChanges.count() - r.start; - if (r.start >= preeditAreaStart) { + if (r.start >= preeditAreaStart) r.start += preeditAreaLength; - } else if (r.start + r.length >= preeditAreaStart) { + else if (r.start + r.length >= preeditAreaStart) r.length += preeditAreaLength; - } ranges << r; } @@ -170,7 +168,6 @@ void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, in void QSyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int charsAdded) { - Q_UNUSED(charsRemoved); rehighlightPending = false; QTextBlock block = doc->findBlock(from); @@ -199,7 +196,7 @@ void QSyntaxHighlighterPrivate::reformatBlocks(int from, int charsRemoved, int c formatChanges.clear(); } -void QSyntaxHighlighterPrivate::reformatBlock(QTextBlock block) +void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block) { Q_Q(QSyntaxHighlighter); @@ -357,8 +354,8 @@ void QSyntaxHighlighter::setDocument(QTextDocument *doc) if (d->doc) { connect(d->doc, SIGNAL(contentsChange(int,int,int)), this, SLOT(_q_reformatBlocks(int,int,int))); - QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight())); d->rehighlightPending = true; + QTimer::singleShot(0, this, SLOT(_q_delayedRehighlight())); } } @@ -473,7 +470,6 @@ void QSyntaxHighlighter::rehighlightBlock(const QTextBlock &block) void QSyntaxHighlighter::setFormat(int start, int count, const QTextCharFormat &format) { Q_D(QSyntaxHighlighter); - if (start < 0 || start >= d->formatChanges.count()) return; @@ -641,7 +637,7 @@ QTextBlockUserData *QSyntaxHighlighter::currentBlockUserData() const \since 4.4 Returns the current text block. - */ +*/ QTextBlock QSyntaxHighlighter::currentBlock() const { Q_D(const QSyntaxHighlighter); -- cgit v0.12 From b49eaedbe81011483ce52af71e9ebf29c61cef43 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 1 Mar 2010 14:43:33 +0100 Subject: remove unused code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer --- src/gui/text/qsyntaxhighlighter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 02dabbb..1dc8e23 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -203,7 +203,6 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block) Q_ASSERT_X(!currentBlock.isValid(), "QSyntaxHighlighter::reformatBlock()", "reFormatBlock() called recursively"); currentBlock = block; - QTextBlock previous = block.previous(); formatChanges.fill(QTextCharFormat(), block.length() - 1); q->highlightBlock(block.text()); -- cgit v0.12 From b7a79ea08be3e127058be549ed354d6276e32e0f Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 1 Mar 2010 14:43:35 +0100 Subject: minor optimization: ignore invalid preeditAreaPosition/preeditAreaText MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer --- src/gui/text/qsyntaxhighlighter.cpp | 40 +++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 1dc8e23..d3db2a1 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -102,20 +102,22 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() const int preeditAreaStart = layout->preeditAreaPosition(); const int preeditAreaLength = layout->preeditAreaText().length(); - QList::Iterator it = ranges.begin(); - while (it != ranges.end()) { - if (it->start >= preeditAreaStart - && it->start + it->length <= preeditAreaStart + preeditAreaLength) { - ++it; - } else { - it = ranges.erase(it); + if (preeditAreaLength != 0) { + QList::Iterator it = ranges.begin(); + while (it != ranges.end()) { + if (it->start >= preeditAreaStart + && it->start + it->length <= preeditAreaStart + preeditAreaLength) { + ++it; + } else { + it = ranges.erase(it); + } } } QTextCharFormat emptyFormat; QTextLayout::FormatRange r; - r.start = r.length = -1; + r.start = -1; int i = 0; while (i < formatChanges.count()) { @@ -137,22 +139,26 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() r.length = i - r.start; - if (r.start >= preeditAreaStart) - r.start += preeditAreaLength; - else if (r.start + r.length >= preeditAreaStart) - r.length += preeditAreaLength; + if (preeditAreaLength != 0) { + if (r.start >= preeditAreaStart) + r.start += preeditAreaLength; + else if (r.start + r.length >= preeditAreaStart) + r.length += preeditAreaLength; + } ranges << r; - r.start = r.length = -1; + r.start = -1; } if (r.start != -1) { r.length = formatChanges.count() - r.start; - if (r.start >= preeditAreaStart) - r.start += preeditAreaLength; - else if (r.start + r.length >= preeditAreaStart) - r.length += preeditAreaLength; + if (preeditAreaLength != 0) { + if (r.start >= preeditAreaStart) + r.start += preeditAreaLength; + else if (r.start + r.length >= preeditAreaStart) + r.length += preeditAreaLength; + } ranges << r; } -- cgit v0.12 From 62faec229dfe654872d3791bee0a27e5290fff4c Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Mon, 1 Mar 2010 14:43:37 +0100 Subject: minor optimization: don't mark contents as dirty if nothing was changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 481 Reviewed-by: Thorbjørn Lindeijer --- src/gui/text/qsyntaxhighlighter.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index d3db2a1..28af5bb 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -95,6 +95,8 @@ public: void QSyntaxHighlighterPrivate::applyFormatChanges() { + bool formatsChanged = false; + QTextLayout *layout = currentBlock.layout(); QList ranges = layout->additionalFormats(); @@ -110,6 +112,7 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() ++it; } else { it = ranges.erase(it); + formatsChanged = true; } } } @@ -147,6 +150,7 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() } ranges << r; + formatsChanged = true; r.start = -1; } @@ -161,9 +165,13 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() } ranges << r; + formatsChanged = true; } - layout->setAdditionalFormats(ranges); + if (formatsChanged) { + layout->setAdditionalFormats(ranges); + doc->markContentsDirty(currentBlock.position(), currentBlock.length()); + } } void QSyntaxHighlighterPrivate::_q_reformatBlocks(int from, int charsRemoved, int charsAdded) @@ -214,8 +222,6 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block) q->highlightBlock(block.text()); applyFormatChanges(); - doc->markContentsDirty(block.position(), block.length()); - currentBlock = QTextBlock(); } -- cgit v0.12 From 0998fc069512d0ae2853929489b80f35e0d9d4ae Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Mar 2010 11:23:45 +0100 Subject: QDeclarativeView: Make usable in Designer Make source a designable property, add missing declarations for enumerations. Reviewed-by: akennedy --- src/declarative/util/qdeclarativeview.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativeview.h b/src/declarative/util/qdeclarativeview.h index 03d8db3..107f3f9 100644 --- a/src/declarative/util/qdeclarativeview.h +++ b/src/declarative/util/qdeclarativeview.h @@ -43,6 +43,7 @@ #define QDECLARATIVEVIEW_H #include +#include #include #include #include @@ -64,7 +65,8 @@ class Q_DECLARATIVE_EXPORT QDeclarativeView : public QGraphicsView Q_OBJECT Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) Q_PROPERTY(Status status READ status NOTIFY statusChanged) - + Q_PROPERTY(QUrl source READ source WRITE setSource DESIGNABLE true) + Q_ENUMS(ResizeMode Status) public: explicit QDeclarativeView(QWidget *parent = 0); QDeclarativeView(const QUrl &source, QWidget *parent = 0); -- cgit v0.12 From 13f23b71cee682ccaaec455d72b1578afc2800ee Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Mar 2010 11:25:16 +0100 Subject: QDeclarativeView: Add a Designer plugin. Reviewed-by: Jarek Kobus Acked-by: akennedy --- tools/designer/src/plugins/plugins.pro | 1 + .../plugins/qdeclarativeview/qdeclarativeview.pro | 13 ++ .../qdeclarativeview/qdeclarativeview_plugin.cpp | 132 +++++++++++++++++++++ .../qdeclarativeview/qdeclarativeview_plugin.h | 74 ++++++++++++ 4 files changed, 220 insertions(+) create mode 100644 tools/designer/src/plugins/qdeclarativeview/qdeclarativeview.pro create mode 100644 tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp create mode 100644 tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.h diff --git a/tools/designer/src/plugins/plugins.pro b/tools/designer/src/plugins/plugins.pro index baf5261..cf4fa8a 100644 --- a/tools/designer/src/plugins/plugins.pro +++ b/tools/designer/src/plugins/plugins.pro @@ -7,3 +7,4 @@ win32:!contains(QT_EDITION, OpenSource):SUBDIRS += activeqt # contains(QT_CONFIG, opengl): SUBDIRS += tools/view3d contains(QT_CONFIG, webkit): SUBDIRS += qwebview contains(QT_CONFIG, phonon): SUBDIRS += phononwidgets +contains(QT_CONFIG, declarative): SUBDIRS += qdeclarativeview diff --git a/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview.pro b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview.pro new file mode 100644 index 0000000..b8abe87 --- /dev/null +++ b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +TARGET = qdeclarativeview +CONFIG += qt warn_on plugin designer +QT += declarative + +include(../plugins.pri) +build_all:!build_pass { + CONFIG -= build_all + CONFIG += release +} + +SOURCES += qdeclarativeview_plugin.cpp +HEADERS += qdeclarativeview_plugin.h diff --git a/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp new file mode 100644 index 0000000..b352a9b --- /dev/null +++ b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.cpp @@ -0,0 +1,132 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Designer of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qdeclarativeview_plugin.h" + +#include +#include + +#include +#include + +static const char toolTipC[] = "QtDeclarative view widget"; + +QT_BEGIN_NAMESPACE + +QDeclarativeViewPlugin::QDeclarativeViewPlugin(QObject *parent) : + QObject(parent), + m_initialized(false) +{ +} + +QString QDeclarativeViewPlugin::name() const +{ + return QLatin1String("QDeclarativeView"); +} + +QString QDeclarativeViewPlugin::group() const +{ + return QLatin1String("Display Widgets"); +} + +QString QDeclarativeViewPlugin::toolTip() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString QDeclarativeViewPlugin::whatsThis() const +{ + return QString(QLatin1String(toolTipC)); +} + +QString QDeclarativeViewPlugin::includeFile() const +{ + return QLatin1String("QtDeclarative/QDeclarativeView"); +} + +QIcon QDeclarativeViewPlugin::icon() const +{ + return QIcon(); +} + +bool QDeclarativeViewPlugin::isContainer() const +{ + return false; +} + +QWidget *QDeclarativeViewPlugin::createWidget(QWidget *parent) +{ + return new QDeclarativeView(parent); +} + +bool QDeclarativeViewPlugin::isInitialized() const +{ + return m_initialized; +} + +void QDeclarativeViewPlugin::initialize(QDesignerFormEditorInterface * /*core*/) +{ + if (m_initialized) + return; + + m_initialized = true; +} + +QString QDeclarativeViewPlugin::domXml() const +{ + return QLatin1String("\ + \ + \ + \ + \ + 0\ + 0\ + 300\ + 200\ + \ + \ + \ + "); +} + +Q_EXPORT_PLUGIN2(customwidgetplugin, QDeclarativeViewPlugin) + +QT_END_NAMESPACE diff --git a/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.h b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.h new file mode 100644 index 0000000..2f13f16 --- /dev/null +++ b/tools/designer/src/plugins/qdeclarativeview/qdeclarativeview_plugin.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Designer of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEVIEW_PLUGIN_H +#define QDECLARATIVEVIEW_PLUGIN_H + +#include + +QT_BEGIN_NAMESPACE + +class QDeclarativeViewPlugin: public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) +public: + QDeclarativeViewPlugin(QObject *parent = 0); + + virtual QString name() const; + virtual QString group() const; + virtual QString toolTip() const; + virtual QString whatsThis() const; + virtual QString includeFile() const; + virtual QIcon icon() const; + virtual bool isContainer() const; + virtual QWidget *createWidget(QWidget *parent); + virtual bool isInitialized() const; + virtual void initialize(QDesignerFormEditorInterface *core); + virtual QString domXml() const; + +private: + bool m_initialized; +}; + +QT_END_NAMESPACE + +#endif // QDECLARATIVEVIEW_PLUGIN_H -- cgit v0.12 From 7366200d7600271c86144e70ae59ce77f39b2a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Mon, 15 Feb 2010 14:06:32 +0100 Subject: Implement alien widgets on Mac/Cocoa. This commit makes alien widgets opt in on a per-widget basis on Mac, set the Qt::WA_NativeWindow flag when creating the widget to enable. Setting this flag on widgets that have native child or sibling NSViews is not supported. The main use case for alien widgets on Mac is to improve performance for applications that have complex user interfaces. Qt can handle thousands of widgets per window, while Cocoa is designed to use a smaller number of NSViews in combination with NSCells and custom control implementations. This commit moves us in the direction of having a few main NSViews with "leaf" qwidgets implemented as a custom control. --- src/gui/kernel/qapplication.cpp | 8 ++---- src/gui/kernel/qapplication_mac.mm | 3 +- src/gui/kernel/qapplication_p.h | 2 +- src/gui/kernel/qcocoaview_mac.mm | 25 +++++++++++++++++ src/gui/kernel/qt_cocoa_helpers_mac.mm | 39 +++++++++++++++++++++++--- src/gui/kernel/qwidget.cpp | 43 +++++++++++++++++++++++++---- src/gui/kernel/qwidget_mac.mm | 50 ++++++++++++++++++++++++++-------- src/gui/kernel/qwidget_p.h | 1 + src/gui/widgets/qmainwindow.cpp | 3 +- 9 files changed, 145 insertions(+), 29 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 4ec2ae2..203f637 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -498,9 +498,7 @@ inline bool QApplicationPrivate::isAlien(QWidget *widget) { if (!widget) return false; -#if defined(Q_WS_MAC) // Fake alien behavior on the Mac :) - return !widget->isWindow() && widget->window()->testAttribute(Qt::WA_DontShowOnScreen); -#elif defined(Q_WS_QWS) +#if defined(Q_WS_QWS) return !widget->isWindow() # ifdef Q_BACKINGSTORE_SUBSURFACES && !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface) @@ -3013,7 +3011,7 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, return result; } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC) /* This function should only be called when the widget changes visibility, i.e. when the \a widget is shown, hidden or deleted. This function does nothing @@ -3073,7 +3071,7 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget) sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver); #endif // QT_NO_CURSOR } -#endif // Q_WS_WIN || Q_WS_X11 +#endif // Q_WS_WIN || Q_WS_X11 || Q_WS_MAC /*! Returns the desktop widget (also called the root window). diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index babfc72..c7d0e48 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -184,7 +184,8 @@ bool qt_mac_app_fullscreen = false; bool qt_scrollbar_jump_to_pos = false; static bool qt_mac_collapse_on_dblclick = true; extern int qt_antialiasing_threshold; // from qapplication.cpp -QPointer qt_button_down; // widget got last button-down +QWidget * qt_button_down; // widget got last button-down +QPointer qt_last_mouse_receiver; #ifndef QT_MAC_USE_COCOA static bool qt_button_down_in_content; // whether the button_down was in the content area. static bool qt_mac_previous_press_in_popup_mode = false; diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index e0a6103..8653dec 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -514,7 +514,7 @@ public: int symbianResourceChange(const QSymbianEvent *symbianEvent); #endif -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) void sendSyntheticEnterLeave(QWidget *widget); #endif diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 6a16403..a1dcc2a 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -185,6 +185,9 @@ extern "C" { extern NSString *NSTextInputReplacementRangeAttributeName; } +#ifdef ALIEN_DEBUG +static int qCocoaViewCount = 0; +#endif @implementation QT_MANGLE_NAMESPACE(QCocoaView) @@ -195,6 +198,12 @@ extern "C" { [self finishInitWithQWidget:widget widgetPrivate:widgetprivate]; } composingText = new QString(); + +#ifdef ALIEN_DEBUG + ++qCocoaViewCount; + qDebug() << "init: qCocoaViewCount is" << qCocoaViewCount; +#endif + composing = false; sendKeyEvents = true; [self setHidden:YES]; @@ -414,6 +423,12 @@ extern "C" { { delete composingText; [[NSNotificationCenter defaultCenter] removeObserver:self]; + +#ifdef ALIEN_DEBUG + --qCocoaViewCount; + qDebug() << "qCocoaViewCount is" << qCocoaViewCount; +#endif + [super dealloc]; } @@ -523,6 +538,10 @@ extern "C" { CGContextClearRect(cg, NSRectToCGRect(aRect)); } + // Check for alien widgets, use qwidgetPrivate->drawWidget() to draw the widget if this + // is the case. This makes sure child widgets are drawn as well, Cocoa does not know about + // those and wont send them drawRect calls. + if (qwidget->testAttribute(Qt::WA_NativeWindow) && qt_widget_private(qwidget)->hasAlienChildren == false) { if (engine && !qwidget->testAttribute(Qt::WA_NoSystemBackground) && (qwidget->isWindow() || qwidget->autoFillBackground()) || qwidget->testAttribute(Qt::WA_TintedBackground) @@ -542,6 +561,12 @@ extern "C" { e.setErased(true); #endif qt_sendSpontaneousEvent(qwidget, &e); + } else { + qwidget->setAttribute(Qt::WA_WState_InPaintEvent, false); // QWidgetPrivate::drawWidget sets this + QWidgetPrivate *qwidgetPrivate = qt_widget_private(qwidget); + qwidgetPrivate->drawWidget(qwidget, qrgn, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen | QWidgetPrivate::DrawRecursive, 0); + } + if (!redirectionOffset.isNull()) QPainter::restoreRedirected(qwidget); if (engine) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 9560952..19bae5a 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -139,7 +139,7 @@ void QMacWindowFader::performFade() extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // qapplication.cpp; extern QWidget * mac_mouse_grabber; -extern QPointer qt_button_down; //qapplication_mac.cpp +extern QWidget *qt_button_down; //qapplication_mac.cpp void macWindowFade(void * /*OSWindowRef*/ window, float durationSeconds) { @@ -686,6 +686,12 @@ bool qt_dispatchKeyEvent(void * /*NSEvent * */ keyEvent, QWidget *widgetToGetEve if ([event type] == NSKeyDown) { qt_keymapper_private()->updateKeyMap(0, key_event, 0); } + + // Redirect keys to alien widgets. + if (widgetToGetEvent->testAttribute(Qt::WA_NativeWindow) == false) { + widgetToGetEvent = qApp->focusWidget(); + } + if (widgetToGetEvent == 0) return false; @@ -940,7 +946,7 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev [static_cast(tmpView) qt_qwidget]; } } else { - extern QPointer qt_button_down; //qapplication_mac.cpp + extern QWidget * qt_button_down; //qapplication_mac.cpp QPoint pos; widgetToGetMouse = QApplicationPrivate::pickMouseReceiver(qwidget, qglobalPoint, pos, eventType, @@ -952,7 +958,20 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev return false; NSPoint localPoint = [tmpView convertPoint:windowPoint fromView:nil]; - QPoint qlocalPoint(localPoint.x, localPoint.y); + QPoint qlocalPoint = QPoint(localPoint.x, localPoint.y); + + // Search for alien child widgets (either on this qwidget or on the popup) + if (widgetToGetMouse->testAttribute(Qt::WA_NativeWindow) == false || qt_widget_private(widgetToGetMouse)->hasAlienChildren) { + QPoint qScreenPoint = flipPoint(globalPoint).toPoint(); +#ifdef ALIEN_DEBUG + qDebug() << "alien mouse event" << qScreenPoint << possibleAlien; +#endif + QWidget *possibleAlien = widgetToGetMouse->childAt(qlocalPoint); + if (possibleAlien) { + qlocalPoint = possibleAlien->mapFromGlobal(widgetToGetMouse->mapToGlobal(qlocalPoint)); + widgetToGetMouse = possibleAlien; + } + } EventRef carbonEvent = static_cast(const_cast([theEvent eventRef])); if (qt_mac_sendMacEventToWidget(widgetToGetMouse, carbonEvent)) @@ -997,7 +1016,19 @@ bool qt_mac_handleMouseEvent(void * /* NSView * */view, void * /* NSEvent * */ev } [QT_MANGLE_NAMESPACE(QCocoaView) currentMouseEvent]->localPoint = localPoint; QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, buttons, keyMods); - qt_sendSpontaneousEvent(widgetToGetMouse, &qme); + +#ifdef ALIEN_DEBUG + qDebug() << "sending mouse event to" << widgetToGetMouse; +#endif + extern QWidget *qt_button_down; + extern QPointer qt_last_mouse_receiver; + + if (qwidget->testAttribute(Qt::WA_NativeWindow) && qt_widget_private(qwidget)->hasAlienChildren == false) + qt_sendSpontaneousEvent(widgetToGetMouse, &qme); + else + QApplicationPrivate::sendMouseEvent(widgetToGetMouse, &qme, widgetToGetMouse, qwidget, &qt_button_down, + qt_last_mouse_receiver); + if (eventType == QEvent::MouseButtonPress && button == Qt::RightButton) { QContextMenuEvent qcme(QContextMenuEvent::Mouse, qlocalPoint, qglobalPoint, keyMods); qt_sendSpontaneousEvent(widgetToGetMouse, &qcme); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 2f6ec6b..b19d541 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -205,6 +205,7 @@ QWidgetPrivate::QWidgetPrivate(int version) , nativeGesturePanEnabled(0) #elif defined(Q_WS_MAC) , needWindowChange(0) + , hasAlienChildren(0) , window_event(0) , qd_hd(0) #endif @@ -1168,6 +1169,10 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) if (f & Qt::MSWindowsOwnDC) q->setAttribute(Qt::WA_NativeWindow); +#ifdef Q_WS_MAC + q->setAttribute(Qt::WA_NativeWindow); +#endif + q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute() adjustQuitOnCloseAttribute(); @@ -1263,6 +1268,10 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) } if (QWidget *parent = parentWidget()) { +#ifdef Q_WS_MAC + if (testAttribute(Qt::WA_NativeWindow) == false) + parent->d_func()->hasAlienChildren = true; +#endif if (type & Qt::Window) { if (!parent->testAttribute(Qt::WA_WState_Created)) parent->createWinId(); @@ -1433,7 +1442,7 @@ QWidget::~QWidget() } } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) else if (!internalWinId() && isVisible()) { qApp->d_func()->sendSyntheticEnterLeave(this); #ifdef Q_WS_QWS @@ -2306,6 +2315,9 @@ QWidget *QWidget::find(WId id) WId QWidget::winId() const { if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { +#ifdef ALIEN_DEBUG + qDebug() << "QWidget::winId: creating native window for" << this; +#endif QWidget *that = const_cast(this); that->setAttribute(Qt::WA_NativeWindow); that->d_func()->createWinId(); @@ -2318,6 +2330,10 @@ WId QWidget::winId() const void QWidgetPrivate::createWinId(WId winid) { Q_Q(QWidget); + +#ifdef ALIEN_DEBUG + qDebug() << "QWidgetPrivate::createWinId for" << q << winid; +#endif const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) { if (!q->isWindow()) { @@ -2360,6 +2376,9 @@ Ensures that the widget has a window system identifier, i.e. that it is known to void QWidget::createWinId() { Q_D(QWidget); +#ifdef ALIEN_DEBUG + qDebug() << "QWidget::createWinId" << this; +#endif // qWarning("QWidget::createWinId is obsolete, please fix your code."); d->createWinId(); } @@ -5249,7 +5268,15 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP QPaintEngine *paintEngine = pdev->paintEngine(); if (paintEngine) { setRedirected(pdev, -offset); +#ifdef Q_WS_MAC + // (Alien support) Special case for Mac when redirecting: If the paint device + // is of the Widget type we need to set WA_WState_InPaintEvent since painting + // outside the paint event is not supported on QWidgets. The attributeis + // restored further down. + if (pdev->devType() == QInternal::Widget) + static_cast(pdev)->setAttribute(Qt::WA_WState_InPaintEvent); +#endif if (sharedPainter) paintEngine->d_func()->systemClip = toBePainted; else @@ -5290,6 +5317,10 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP //restore if (paintEngine) { +#ifdef Q_WS_MAC + if (pdev->devType() == QInternal::Widget) + static_cast(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false); +#endif restoreRedirected(); if (!sharedPainter) paintEngine->d_func()->systemRect = QRect(); @@ -7322,7 +7353,7 @@ void QWidgetPrivate::hide_helper() // next bit tries to move the focus if the focus widget is now // hidden. if (wasVisible) { -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) qApp->d_func()->sendSyntheticEnterLeave(q); #endif @@ -7454,7 +7485,7 @@ void QWidget::setVisible(bool visible) d->show_helper(); -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) qApp->d_func()->sendSyntheticEnterLeave(this); #endif } @@ -7569,7 +7600,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous) widget->d_func()->hide_sys(); } } -#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) qApp->d_func()->sendSyntheticEnterLeave(widget); #endif #ifndef QT_NO_ACCESSIBILITY @@ -9787,7 +9818,7 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) desktopWidget = parent; bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget; -#if defined(Q_WS_X11) || defined(Q_WS_WIN) +#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) if (newParent && parent && !desktopWidget) { if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)) parent->d_func()->enforceNativeChildren(); @@ -10433,7 +10464,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) } case Qt::WA_PaintOnScreen: d->updateIsOpaque(); -#if defined(Q_WS_WIN) || defined(Q_WS_X11) +#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) // Recreate the widget if it's already created as an alien widget and // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id. // So must their children. diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index dcb87fc..6d8c97b 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -459,7 +459,13 @@ static bool qt_isGenuineQWidget(OSViewRef ref) bool qt_isGenuineQWidget(const QWidget *window) { - return window && qt_isGenuineQWidget(OSViewRef(window->winId())); + if (!window) + return false; + + if (!window->internalWinId()) + return true; //alien + + return qt_isGenuineQWidget(OSViewRef(window->internalWinId())); } Q_GUI_EXPORT OSWindowRef qt_mac_window_for(const QWidget *w) @@ -2608,7 +2614,16 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO } } else { data.fstrut_dirty = false; // non-toplevel widgets don't have a frame, so no need to update the strut - if(OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) { + +#ifdef QT_MAC_USE_COCOA + if (q->testAttribute(Qt::WA_NativeWindow) == false || + q->internalWinId() != 0) { +#ifdef ALIEN_DEBUG + qDebug() << "Skipping native widget creation for" << this; +#endif + } else +#endif + if (OSViewRef osview = qt_mac_create_widget(q, this, qt_mac_nativeview_for(parentWidget))) { #ifndef QT_MAC_USE_COCOA HIRect bounds = CGRectMake(data.crect.x(), data.crect.y(), data.crect.width(), data.crect.height()); HIViewSetFrame(osview, &bounds); @@ -2869,9 +2884,12 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) q->setAttribute(Qt::WA_WState_Visible, false); q->setAttribute(Qt::WA_WState_Hidden, false); adjustFlags(data.window_flags, q); - // keep compatibility with previous versions, we need to preserve the created state - // (but we recreate the winId for the widget being reparented, again for compatibility) - if (wasCreated || (!q->isWindow() && parent->testAttribute(Qt::WA_WState_Created))) { + // keep compatibility with previous versions, we need to preserve the created state. + // (but we recreate the winId for the widget being reparented, again for compatibility, + // unless this is an alien widget. ) + const bool nonWindowWithCreatedParent = !q->isWindow() && parent->testAttribute(Qt::WA_WState_Created); + const bool nativeWidget = q->internalWinId() != 0; + if (wasCreated || nativeWidget && nonWindowWithCreatedParent) { createWinId(); if (q->isWindow()) { #ifndef QT_MAC_USE_COCOA @@ -2955,7 +2973,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) QPoint QWidget::mapToGlobal(const QPoint &pos) const { Q_D(const QWidget); - if (!testAttribute(Qt::WA_WState_Created)) { + if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { QPoint p = pos + data->crect.topLeft(); return isWindow() ? p : parentWidget()->mapToGlobal(p); } @@ -2982,7 +3000,7 @@ QPoint QWidget::mapToGlobal(const QPoint &pos) const QPoint QWidget::mapFromGlobal(const QPoint &pos) const { Q_D(const QWidget); - if (!testAttribute(Qt::WA_WState_Created)) { + if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) { QPoint p = isWindow() ? pos : parentWidget()->mapFromGlobal(pos); return p - data->crect.topLeft(); } @@ -3320,10 +3338,20 @@ void QWidgetPrivate::update_sys(const QRegion &rgn) } #else // Cocoa doesn't do regions, it seems more efficient to just update the bounding rect instead of a potential number of message passes for each rect. - const QRect &boundingRect = rgn.boundingRect(); - [qt_mac_nativeview_for(q) setNeedsDisplayInRect:NSMakeRect(boundingRect.x(), - boundingRect.y(), boundingRect.width(), - boundingRect.height())]; + const QRect & boundingRect = rgn.boundingRect(); + + // Alien support: get the first native ancestor widget (will be q itself in the non-alien case), + // map the coordinates from q space to NSView space and invalidate the rect. + QWidget *nativeParent = q->internalWinId() ? q : q->nativeParentWidget(); + if (nativeParent == 0) + return; + const QRect nativeBoundingRect = QRect( + QPoint(q->mapTo(nativeParent, boundingRect.topLeft())), + QSize(boundingRect.size())); + + [qt_mac_nativeview_for(nativeParent) setNeedsDisplayInRect:NSMakeRect(nativeBoundingRect.x(), + nativeBoundingRect.y(), nativeBoundingRect.width(), + nativeBoundingRect.height())]; #endif } diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index efd9a0a..2cb8586 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -720,6 +720,7 @@ public: #elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC // This is new stuff uint needWindowChange : 1; + uint hasAlienChildren : 1; // Each wiget keeps a list of all its child and grandchild OpenGL widgets. // This list is used to update the gl context whenever a parent and a granparent diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 4620597..bdab6fb 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -1478,7 +1478,8 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) return; // ### Disable the unified toolbar when using anything but the native graphics system. - if (windowSurface()) + // ### Disable when using alien widgets as well + if (windowSurface() || testAttribute(Qt::WA_NativeWindow) == false) return; d->useHIToolBar = set; -- cgit v0.12 From 2c0dec10520ce1ae25eaef2d1c67969528ac278d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 2 Mar 2010 12:00:09 +0100 Subject: QtDeclarative: Fix compiler warnings class/struct mixups, unused variables. Reviewed-by: Thomas Hartmann --- src/declarative/graphicsitems/qdeclarativeflickable.cpp | 1 - src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp | 1 - src/declarative/qml/qdeclarativelist.h | 2 +- src/declarative/util/qdeclarativetimeline_p_p.h | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index c54ddd0..1998ccf 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -154,7 +154,6 @@ void QDeclarativeFlickablePrivate::init() */ qreal QDeclarativeFlickablePrivate::overShootDistance(qreal velocity, qreal size) { - Q_Q(QDeclarativeFlickable); if (maxVelocity <= 0) return 0.0; diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index cd72ef9..693fd20 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -1268,7 +1268,6 @@ void QDeclarativeVisualDataModel::_q_dataChanged(const QModelIndex &begin, const void QDeclarativeVisualDataModel::_q_modelReset() { - Q_D(QDeclarativeVisualDataModel); emit modelReset(); } diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h index 8d59384..eac4967 100644 --- a/src/declarative/qml/qdeclarativelist.h +++ b/src/declarative/qml/qdeclarativelist.h @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QObject; -class QMetaObject; +struct QMetaObject; template struct QDeclarativeListProperty { typedef void (*AppendFunction)(QDeclarativeListProperty *, T*); diff --git a/src/declarative/util/qdeclarativetimeline_p_p.h b/src/declarative/util/qdeclarativetimeline_p_p.h index c08c07c..598c897 100644 --- a/src/declarative/util/qdeclarativetimeline_p_p.h +++ b/src/declarative/util/qdeclarativetimeline_p_p.h @@ -160,7 +160,7 @@ public: QDeclarativeTimeLineObject *callbackObject() const; private: - friend class QDeclarativeTimeLinePrivate; + friend struct QDeclarativeTimeLinePrivate; Callback d0; void *d1; QDeclarativeTimeLineObject *d2; -- cgit v0.12 From 671a6a0dc82857dd84feddf49d38540dd59186df Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Tue, 2 Mar 2010 12:16:31 +0100 Subject: OS X 10.4 compile error; required casting int to GLint. --- src/multimedia/base/qpaintervideosurface.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/multimedia/base/qpaintervideosurface.cpp b/src/multimedia/base/qpaintervideosurface.cpp index 97fddc9..fc3d493 100644 --- a/src/multimedia/base/qpaintervideosurface.cpp +++ b/src/multimedia/base/qpaintervideosurface.cpp @@ -1158,14 +1158,14 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::paint( glBindTexture(GL_TEXTURE_2D, m_textureIds[2]); glActiveTexture(GL_TEXTURE0); - m_program.setUniformValue("texY", 0); - m_program.setUniformValue("texU", 1); - m_program.setUniformValue("texV", 2); + m_program.setUniformValue("texY", GLint(0)); + m_program.setUniformValue("texU", GLint(1)); + m_program.setUniformValue("texV", GLint(2)); } else { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, m_textureIds[0]); - m_program.setUniformValue("texRgb", 0); + m_program.setUniformValue("texRgb", GLint(0)); } m_program.setUniformValue("colorMatrix", m_colorMatrix); -- cgit v0.12 From 8b19712189aa2c7e83030b59cd4b4729e5e113cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Tue, 2 Mar 2010 13:50:36 +0100 Subject: Compile. --- tools/qdoc3/node.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index 6ad9a6c..7dda824 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -44,6 +44,7 @@ */ #include "node.h" +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From 298aee0577a45dadf8e30b5bea05224f9e3aa52d Mon Sep 17 00:00:00 2001 From: Zeno Albisser Date: Tue, 2 Mar 2010 13:49:52 +0100 Subject: Added comment about usage of strncpy_s function in VC++ > 14.00 Reviewed-by: Peter Hartmann --- src/corelib/tools/qbytearray.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp index 3324796..c5f70b0 100644 --- a/src/corelib/tools/qbytearray.cpp +++ b/src/corelib/tools/qbytearray.cpp @@ -154,6 +154,10 @@ char *qstrcpy(char *dst, const char *src) This function assumes that \a dst is at least \a len characters long. + \note When compiling with Visual C++ compiler version 14.00 + (Visual C++ 2005) or later, internally the function strncpy_s + will be used. + \sa qstrcpy() */ -- cgit v0.12 From a62177874d961e0884e74ba7c7c8899fdb79fb09 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 1 Mar 2010 18:58:06 +0100 Subject: Always run syncqt if using a Git checkout. Reviewed-by: Olivier Goffart --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 2312165..2c7e431 100755 --- a/configure +++ b/configure @@ -4322,7 +4322,7 @@ if [ -n "$PERL" ] && [ -x "$relpath/bin/syncqt" ]; then [ "$CFG_DEV" = "yes" ] && SYNCQT_OPTS="$SYNCQT_OPTS -check-includes" if [ "$OPT_SHADOW" = "yes" ]; then "$outpath/bin/syncqt" $SYNCQT_OPTS - elif [ "$CFG_DEV" = "yes" ] || [ ! -d $relpath/include ]; then + elif [ "$CFG_DEV" = "yes" ] || [ ! -d $relpath/include ] || [ -d $relpath/.git ]; then QTDIR="$relpath" perl "$outpath/bin/syncqt" $SYNCQT_OPTS fi fi -- cgit v0.12 From 67cd8cc97104e38f2e3bae03b2a4c3575c73c461 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 1 Mar 2010 22:12:01 +0100 Subject: Add a template specialisation for QArgument when T is a reference. We can't form references to references, so this is the proper solution. Though apparently GCC figures out somehow to work without it... Task-number: QTBUG-8592 Reviewed-By: Olivier Goffart --- src/corelib/kernel/qobjectdefs.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h index 8ed7f3f..b045c42 100644 --- a/src/corelib/kernel/qobjectdefs.h +++ b/src/corelib/kernel/qobjectdefs.h @@ -271,6 +271,14 @@ public: : QGenericArgument(aName, static_cast(&aData)) {} }; +template +class QArgument: public QGenericArgument +{ +public: + inline QArgument(const char *aName, T &aData) + : QGenericArgument(aName, static_cast(&aData)) + {} +}; template -- cgit v0.12 From 115c3214161152c99f488fd4cce39b15b40b3600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Tue, 2 Mar 2010 15:34:29 +0100 Subject: Fixed a regression in the syntax highlighter Caused by merging an old version of merge request 481. This patch updates it to the latest version. Merge-request: 481 Reviewed-by: Ritt Konstantin --- src/gui/text/qsyntaxhighlighter.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp index 28af5bb..e594b7e 100644 --- a/src/gui/text/qsyntaxhighlighter.cpp +++ b/src/gui/text/qsyntaxhighlighter.cpp @@ -115,6 +115,9 @@ void QSyntaxHighlighterPrivate::applyFormatChanges() formatsChanged = true; } } + } else if (!ranges.isEmpty()) { + ranges.clear(); + formatsChanged = true; } QTextCharFormat emptyFormat; -- cgit v0.12 From 95087389919837fef920c6c06ccd34c3136c6b5e Mon Sep 17 00:00:00 2001 From: ck Date: Mon, 1 Mar 2010 17:45:15 +0100 Subject: Help system: Build search index with low priority. Reviewed-by: kh1 --- tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp | 2 +- tools/assistant/lib/qhelpsearchindexwriter_default.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp index d9dcec5..4baa376 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_clucene.cpp @@ -586,7 +586,7 @@ void QHelpSearchIndexWriter::updateIndex(const QString &collectionFile, this->m_indexFilesFolder = indexFilesFolder; mutex.unlock(); - start(QThread::NormalPriority); + start(QThread::LowestPriority); } void QHelpSearchIndexWriter::optimizeIndex() diff --git a/tools/assistant/lib/qhelpsearchindexwriter_default.cpp b/tools/assistant/lib/qhelpsearchindexwriter_default.cpp index cb3e49c..827d145 100644 --- a/tools/assistant/lib/qhelpsearchindexwriter_default.cpp +++ b/tools/assistant/lib/qhelpsearchindexwriter_default.cpp @@ -191,7 +191,7 @@ void QHelpSearchIndexWriter::updateIndex(const QString &collectionFile, this->m_collectionFile = collectionFile; this->m_indexFilesFolder = indexFilesFolder; - start(QThread::NormalPriority); + start(QThread::LowestPriority); } void QHelpSearchIndexWriter::run() -- cgit v0.12 From fbcfcea9bb5cf0ce39e5ce1fb9b0628930f034d1 Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 2 Mar 2010 15:31:27 +0100 Subject: Assistant: Un-watch files at shutdown. Not strictly needed, but it seems nicer to have a removePath() for every addPath(). Reviewed-by: kh1 --- tools/assistant/tools/assistant/helpenginewrapper.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/assistant/tools/assistant/helpenginewrapper.cpp b/tools/assistant/tools/assistant/helpenginewrapper.cpp index e21e95d..41ad633 100644 --- a/tools/assistant/tools/assistant/helpenginewrapper.cpp +++ b/tools/assistant/tools/assistant/helpenginewrapper.cpp @@ -167,6 +167,13 @@ HelpEngineWrapper::HelpEngineWrapper(const QString &collectionFile) HelpEngineWrapper::~HelpEngineWrapper() { TRACE_OBJ + const QStringList &namespaces = d->m_helpEngine->registeredDocumentations(); + foreach (const QString &nameSpace, namespaces) { + const QString &docFile + = d->m_helpEngine->documentationFileName(nameSpace); + d->m_qchWatcher->removePath(docFile); + } + delete d; } -- cgit v0.12 From ffec21e1e0694972592150c600f2970b6f28dbad Mon Sep 17 00:00:00 2001 From: ck Date: Tue, 2 Mar 2010 17:09:49 +0100 Subject: Assistant: Don't warn for non-existing English to English translations. They usually don't exist, so we'd just be adding noise otherwise. Reviewed-by: kh1 --- tools/assistant/tools/assistant/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp index 77e5e7c..51ea9f9 100644 --- a/tools/assistant/tools/assistant/main.cpp +++ b/tools/assistant/tools/assistant/main.cpp @@ -292,7 +292,7 @@ void setupTranslation(const QString &fileName, const QString &dir) QTranslator *translator = new QTranslator(QCoreApplication::instance()); if (translator->load(fileName, dir)) { QCoreApplication::installTranslator(translator); - } else { + } else if (!fileName.endsWith(QLatin1String("en_US"))) { qWarning("Could not load translation file %s in directory %s.", qPrintable(fileName), qPrintable(dir)); } -- cgit v0.12 From 31e1fb9103e6d6657c1153f5c30e149087568042 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 2 Mar 2010 17:15:32 +0100 Subject: make the value of QMAKE_QMAKE somewhat less magic the generators change the value of QMAKE_QMAKE, so it is unwise to "redirect" it to a hidden builtin which is reset each time. in particular, this fixes qmake generating makefiles without an absolute path to qmake itself - the initial quoting of the filename will make the variable "real", so contains() will start working for it. --- qmake/project.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index 951ca33..cf1c365 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -3136,7 +3136,6 @@ QStringList &QMakeProject::values(const QString &_var, QMap Date: Wed, 3 Mar 2010 14:46:03 +1000 Subject: fix connecting to an ID. --- src/plugins/bearer/corewlan/qcorewlanengine.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index 598d2f0..a758a4b 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -170,7 +170,7 @@ void QCoreWlanEngine::connectToId(const QString &id) while ((wProfile = [enumerator nextObject])) { //CWWirelessProfile - if(id == nsstringToQString([wProfile ssid])) { + if(id == QString::number(qHash(QLatin1String("corewlan:") + nsstringToQString([wProfile ssid])))) { user8021XProfile = nil; user8021XProfile = [ wProfile user8021XProfile]; -- cgit v0.12 From 9b0747af7e6c456c4215879ece86f2f0dc9b7478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 3 Mar 2010 09:33:28 +0100 Subject: Mac: Select Carbon when using the 10.4u SDK. --- configure | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/configure b/configure index 2c7e431..5aaf347 100755 --- a/configure +++ b/configure @@ -6074,6 +6074,15 @@ if [ "$PLATFORM_MAC" = "yes" ]; then fi fi +# select Carbon when using the 10.4u SDK +if [ "$PLATFORM_MAC" = "yes" ]; then + if [ "TEST$CFG_SDK" = "TEST/Developer/SDKs/MacOSX10.4u.sdk/" ]; then + echo "Carbon on"; + CFG_MAC_COCOA="no"; + CFG_MAC_CARBON="yes"; + fi +fi + # set the global Mac deployment target. This is overridden on an arch-by-arch basis # in some cases, see code further down case "$PLATFORM,$CFG_MAC_COCOA" in -- cgit v0.12 From 97b8727635a73197fac4f5edb8a1122733933db4 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 2 Mar 2010 16:38:42 +0100 Subject: Application menu is not translated in Mac OS X Cocoa The application menu is loaded from the qt_menu.nib which only has English strings. These will now be translated using Qt's own translation mechanism. Every time a new translator is installed, the menu will now try to get the new string. Modification of qt_xx.ts files are done in a different patch. Task-number: QTBUG-4463 Reviewed-by: MortenS --- src/gui/kernel/qapplication.cpp | 16 ++++++++++++++++ src/gui/kernel/qcocoamenuloader_mac.mm | 20 ++++++++++++++++++++ src/gui/kernel/qcocoamenuloader_mac_p.h | 4 +++- src/gui/kernel/qt_cocoa_helpers_mac.mm | 8 ++++++++ src/gui/kernel/qt_cocoa_helpers_mac_p.h | 2 ++ src/gui/widgets/qmenu_mac.mm | 30 ++++++++++++++++++++++-------- 6 files changed, 71 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 203f637..fea8c37 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2309,6 +2309,19 @@ static bool qt_detectRTLLanguage() " languages or to 'RTL' in right-to-left languages (such as Hebrew" " and Arabic) to get proper widget layout.") == QLatin1String("RTL")); } +#if defined(QT_MAC_USE_COCOA) +static const char *application_menu_strings[] = { + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"), + QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All") + }; +QString qt_mac_applicationmenu_string(int type) +{ + return qApp->translate("MAC_APPLICATION_MENU", + application_menu_strings[type]); +} +#endif #endif /*!\reimp @@ -2337,6 +2350,9 @@ bool QApplication::event(QEvent *e) #ifndef QT_NO_TRANSLATION setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight); #endif +#if defined(QT_MAC_USE_COCOA) + qt_mac_post_retranslateAppMenu(); +#endif QWidgetList list = topLevelWidgets(); for (int i = 0; i < list.size(); ++i) { QWidget *w = list.at(i); diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/gui/kernel/qcocoamenuloader_mac.mm index 573b763..35d156a 100644 --- a/src/gui/kernel/qcocoamenuloader_mac.mm +++ b/src/gui/kernel/qcocoamenuloader_mac.mm @@ -48,6 +48,7 @@ #include #include #include +#include QT_FORWARD_DECLARE_CLASS(QCFString) QT_FORWARD_DECLARE_CLASS(QString) @@ -58,6 +59,10 @@ QT_USE_NAMESPACE - (void)awakeFromNib { + servicesItem = [[appMenu itemWithTitle:@"Services"] retain]; + hideAllOthersItem = [[appMenu itemWithTitle:@"Hide Others"] retain]; + showAllItem = [[appMenu itemWithTitle:@"Show All"] retain]; + // Get the names in the nib to match the app name set by Qt. NSString *appName = reinterpret_cast(QCFString::toCFStringRef(qAppName())); [quitItem setTitle:[[quitItem title] stringByReplacingOccurrencesOfString:@"NewApplication" @@ -119,6 +124,10 @@ QT_USE_NAMESPACE - (void)dealloc { + [servicesItem release]; + [hideAllOthersItem release]; + [showAllItem release]; + [lastAppSpecificItem release]; [theMenu release]; [appMenu release]; @@ -214,6 +223,17 @@ QT_USE_NAMESPACE QMenuBarPrivate::macUpdateMenuBarImmediatly(); } +- (void)qtTranslateApplicationMenu +{ +#ifndef QT_NO_TRANSLATION + extern QString qt_mac_applicationmenu_string(int type); + [servicesItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(0))]; + [hideItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(1).arg(qAppName()))]; + [hideAllOthersItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(2))]; + [showAllItem setTitle: qt_mac_QStringToNSString(qt_mac_applicationmenu_string(3))]; +#endif +} + - (IBAction)qtDispatcherToQAction:(id)sender { QScopedLoopLevelCounter loopLevelCounter(QApplicationPrivate::instance()->threadData); diff --git a/src/gui/kernel/qcocoamenuloader_mac_p.h b/src/gui/kernel/qcocoamenuloader_mac_p.h index 2504b8c..a75ad0a 100644 --- a/src/gui/kernel/qcocoamenuloader_mac_p.h +++ b/src/gui/kernel/qcocoamenuloader_mac_p.h @@ -67,7 +67,9 @@ IBOutlet NSMenuItem *aboutQtItem; IBOutlet NSMenuItem *hideItem; NSMenuItem *lastAppSpecificItem; - + NSMenuItem *servicesItem; + NSMenuItem *hideAllOthersItem; + NSMenuItem *showAllItem; } - (void)ensureAppMenuInMenu:(NSMenu *)menu; - (void)removeActionsFromAppMenu; diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 19bae5a..4f4aec0 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1386,4 +1386,12 @@ QMacCocoaAutoReleasePool::~QMacCocoaAutoReleasePool() [(NSAutoreleasePool*)pool release]; } +void qt_mac_post_retranslateAppMenu() +{ +#ifdef QT_MAC_USE_COCOA + QMacCocoaAutoReleasePool pool; + qt_cocoaPostMessage([NSApp QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader)], @selector(qtTranslateApplicationMenu)); +#endif +} + QT_END_NAMESPACE diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h index c43ea55..3fd62a4 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h +++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -208,4 +208,6 @@ bool qt_cocoaPostMessage(id target, SEL selector); #endif +void qt_mac_post_retranslateAppMenu(); + QT_END_NAMESPACE diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 99c550f..2570cb5 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -924,14 +924,27 @@ static QString qt_mac_menu_merge_text(QMacMenuAction *action) else if (action->command == kHICommandQuit) ret = QMenuBar::tr("Quit %1").arg(qAppName()); #else - else if (action->menuItem == [loader aboutMenuItem]) - ret = QMenuBar::tr("About %1").arg(qAppName()); - else if (action->menuItem == [loader aboutQtMenuItem]) - ret = QMenuBar::tr("About Qt"); - else if (action->menuItem == [loader preferencesMenuItem]) - ret = QMenuBar::tr("Preferences"); - else if (action->menuItem == [loader quitMenuItem]) - ret = QMenuBar::tr("Quit %1").arg(qAppName()); + else if (action->menuItem == [loader aboutMenuItem]) { + if (action->action->text() == QString("About %1").arg(qAppName())) + ret = QMenuBar::tr("About %1").arg(qAppName()); + else + ret = action->action->text(); + } else if (action->menuItem == [loader aboutQtMenuItem]) { + if (action->action->text() == QString("About Qt")) + ret = QMenuBar::tr("About Qt"); + else + ret = action->action->text(); + } else if (action->menuItem == [loader preferencesMenuItem]) { + if (action->action->text() == QString("Preferences")) + ret = QMenuBar::tr("Preferences"); + else + ret = action->action->text(); + } else if (action->menuItem == [loader quitMenuItem]) { + if (action->action->text() == QString("Quit %1").arg(qAppName())) + ret = QMenuBar::tr("About %1").arg(qAppName()); + else + ret = action->action->text(); + } #endif return ret; } @@ -2180,3 +2193,4 @@ static OSMenuRef qt_mac_create_menu(QWidget *w) QT_END_NAMESPACE + -- cgit v0.12 From f006691acc45a57e011e5827163c0b3759864bf7 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 2 Mar 2010 17:18:26 +0100 Subject: make the fallback value of QMAKE_QMAKE absolute inspired by the pbx generator. currently this has no effect, as all generators build their own fallbacks anyway. Reviewed-by: mariusSO --- qmake/project.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qmake/project.cpp b/qmake/project.cpp index cf1c365..9e6db10 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -3139,7 +3139,8 @@ QStringList &QMakeProject::values(const QString &_var, QMap Date: Tue, 2 Mar 2010 17:10:46 +0100 Subject: don't have every generator duplicate the QMAKE_QMAKE logic Reviewed-by: mariusSO --- qmake/generators/mac/pbuilder_pbx.cpp | 4 +--- qmake/generators/makefile.cpp | 12 +++++------- qmake/generators/symbian/symmake_abld.cpp | 2 +- qmake/generators/symbian/symmake_sbsv2.cpp | 2 +- qmake/generators/unix/unixmake.cpp | 2 -- qmake/generators/unix/unixmake2.cpp | 4 ++-- qmake/generators/win32/borland_bmake.cpp | 2 -- qmake/generators/win32/mingw_make.cpp | 4 +--- qmake/generators/win32/msvc_nmake.cpp | 2 -- qmake/generators/win32/winmakefile.cpp | 3 +-- 10 files changed, 12 insertions(+), 25 deletions(-) diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp index ac9fa99..1a7391b 100644 --- a/qmake/generators/mac/pbuilder_pbx.cpp +++ b/qmake/generators/mac/pbuilder_pbx.cpp @@ -523,9 +523,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) debug_msg(1, "pbuilder: Creating file: %s", mkfile.toLatin1().constData()); QTextStream mkt(&mkf); writeHeader(mkt); - mkt << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? - QString((QLibraryInfo::location(QLibraryInfo::BinariesPath) + "/qmake")) : - var("QMAKE_QMAKE")) << endl; + mkt << "QMAKE = " << var("QMAKE_QMAKE") << endl; writeMakeQmake(mkt); mkt.flush(); mkf.close(); diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index a8c1c3c..b9d2445 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -806,9 +806,8 @@ MakefileGenerator::init() } // escape qmake command - if (!project->isEmpty("QMAKE_QMAKE")) { - project->values("QMAKE_QMAKE") = escapeFilePaths(project->values("QMAKE_QMAKE")); - } + QStringList &qmk = project->values("QMAKE_QMAKE"); + qmk = escapeFilePaths(qmk); } bool @@ -2097,7 +2096,7 @@ MakefileGenerator::writeExtraVariables(QTextStream &t) bool MakefileGenerator::writeStubMakefile(QTextStream &t) { - t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << endl; QStringList &qut = project->values("QMAKE_EXTRA_TARGETS"); for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it) t << *it << " "; @@ -2212,8 +2211,7 @@ MakefileGenerator::writeHeader(QTextStream &t) t << "# Project: " << fileFixify(project->projectFile()) << endl; t << "# Template: " << var("TEMPLATE") << endl; if(!project->isActiveConfig("build_pass")) - t << "# Command: " << build_args().replace("$(QMAKE)", - (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE"))) << endl; + t << "# Command: " << build_args().replace("$(QMAKE)", var("QMAKE_QMAKE")) << endl; t << "#############################################################################" << endl; t << endl; } @@ -2346,7 +2344,7 @@ MakefileGenerator::writeSubTargets(QTextStream &t, QListisEmpty("MAKEFILE")) project->values("MAKEFILE").append("Makefile"); - if(project->isEmpty("QMAKE_QMAKE")) - project->values("QMAKE_QMAKE").append("qmake"); if(project->values("QMAKE_INTERNAL_QMAKE_DEPS").indexOf("qmake_all") == -1) project->values("QMAKE_INTERNAL_QMAKE_DEPS").append("qmake_all"); return; /* subdirs is done */ diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 025882e..5def030 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -81,7 +81,7 @@ UnixMakefileGenerator::writeMakefile(QTextStream &t) writeHeader(t); if(!project->values("QMAKE_FAILED_REQUIREMENTS").isEmpty()) { - t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << endl; QStringList &qut = project->values("QMAKE_EXTRA_TARGETS"); for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it) t << *it << " "; @@ -154,7 +154,7 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t) t << "AR = " << var("QMAKE_AR") << endl; t << "RANLIB = " << var("QMAKE_RANLIB") << endl; - t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << endl; t << "TAR = " << var("QMAKE_TAR") << endl; t << "COMPRESS = " << var("QMAKE_GZIP") << endl; if(project->isActiveConfig("compile_libtool")) diff --git a/qmake/generators/win32/borland_bmake.cpp b/qmake/generators/win32/borland_bmake.cpp index 9208e1d..b5c33c4 100644 --- a/qmake/generators/win32/borland_bmake.cpp +++ b/qmake/generators/win32/borland_bmake.cpp @@ -115,8 +115,6 @@ BorlandMakefileGenerator::init() project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)"); if(project->values("MAKEFILE").isEmpty()) project->values("MAKEFILE").append("Makefile"); - if(project->values("QMAKE_QMAKE").isEmpty()) - project->values("QMAKE_QMAKE").append("qmake"); return; } diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp index e1f502f..fd43145 100644 --- a/qmake/generators/win32/mingw_make.cpp +++ b/qmake/generators/win32/mingw_make.cpp @@ -143,7 +143,7 @@ bool MingwMakefileGenerator::writeMakefile(QTextStream &t) if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib") { if(Option::mkfile::do_stub_makefile) { - t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : var("QMAKE_QMAKE")) << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << endl; QStringList &qut = project->values("QMAKE_EXTRA_TARGETS"); for(QStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it) t << *it << " "; @@ -248,8 +248,6 @@ void MingwMakefileGenerator::init() project->values("QMAKE_INSTALL_DIR").append("$(COPY_DIR)"); if(project->values("MAKEFILE").isEmpty()) project->values("MAKEFILE").append("Makefile"); - if(project->values("QMAKE_QMAKE").isEmpty()) - project->values("QMAKE_QMAKE").append("qmake"); return; } diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 7566b23..92e8aeb 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -156,8 +156,6 @@ void NmakeMakefileGenerator::init() MakefileGenerator::init(); if(project->values("MAKEFILE").isEmpty()) project->values("MAKEFILE").append("Makefile"); - if(project->values("QMAKE_QMAKE").isEmpty()) - project->values("QMAKE_QMAKE").append("qmake"); if(project->isEmpty("QMAKE_COPY_FILE")) project->values("QMAKE_COPY_FILE").append("$(COPY)"); if(project->isEmpty("QMAKE_COPY_DIR")) diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 9998c1f..44fef5d 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -591,8 +591,7 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t) writeIncPart(t); writeLibsPart(t); - t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? QString("qmake") : - Option::fixPathToTargetOS(var("QMAKE_QMAKE"), false)) << endl; + t << "QMAKE = " << var("QMAKE_QMAKE") << endl; t << "IDC = " << (project->isEmpty("QMAKE_IDC") ? QString("idc") : Option::fixPathToTargetOS(var("QMAKE_IDC"), false)) << endl; t << "IDL = " << (project->isEmpty("QMAKE_IDL") ? QString("midl") : -- cgit v0.12 From 509ac7e069bf17f2725dcebdeb8e9520b98b0e15 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 3 Mar 2010 11:35:33 +0100 Subject: qdoc3: Trying to find a bug that causes a crash. It doesn't crash on OS X, but it does on some other platforms. If you run into this crash running qdoc3, you can work around it by commenting out line 1539 in tools/qdoc3/htmlgenerator.cpp The line to comment out is: generateQmlInheritedBy(qml_cn, marker); --- tools/qdoc3/generator.cpp | 10 +++------- tools/qdoc3/node.cpp | 5 ++++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tools/qdoc3/generator.cpp b/tools/qdoc3/generator.cpp index 0ef5156..c8a39ef 100644 --- a/tools/qdoc3/generator.cpp +++ b/tools/qdoc3/generator.cpp @@ -1190,19 +1190,15 @@ void Generator::appendSortedQmlNames(Text& text, const NodeList& subs, CodeMarker *marker) { - NodeList::ConstIterator r; QMap classMap; int index = 0; qDebug() << "Generator::appendSortedQmlNames():" << base->name() << "is inherited by..."; - - r = subs.begin(); - while (r != subs.end()) { + for (int i = 0; i < subs.size(); ++i) { Text t; - qDebug() << " " << (*r)->name(); - appendFullName(t, (*r), base, marker); + qDebug() << " " << subs[i]->name(); + appendFullName(t, subs[i], base, marker); classMap[t.toString().toLower()] = t; - ++r; } QStringList names = classMap.keys(); diff --git a/tools/qdoc3/node.cpp b/tools/qdoc3/node.cpp index 7dda824..5415559 100644 --- a/tools/qdoc3/node.cpp +++ b/tools/qdoc3/node.cpp @@ -1315,8 +1315,11 @@ void QmlClassNode::addInheritedBy(const QString& base, Node* sub) void QmlClassNode::subclasses(const QString& base, NodeList& subs) { subs.clear(); - if (inheritedBy.contains(base)) + if (inheritedBy.count(base) > 0) { subs = inheritedBy.values(base); + qDebug() << "QmlClassNode::subclasses():" << inheritedBy.count(base) << base + << "subs:" << subs.size(); + } } /*! -- cgit v0.12 From 3335721dcf72cda957ba0e507608d795cab3f1ab Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Wed, 3 Mar 2010 12:45:14 +0100 Subject: Fix focus behavior bug on Mac OS X. With the Full Access Keyboard enabled, the focus could sometimes be stolen by the window. --- src/gui/kernel/qcocoaview_mac.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index a1dcc2a..f7cb21f 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -1028,7 +1028,10 @@ static int qCocoaViewCount = 0; { if (!qwidget) return NO; - if (qwidget->isWindow()) + // Before accepting the focus for a window, we check that + // the focusWidget (if any) is not contained in the same window. + if (qwidget->isWindow() && (!qApp->focusWidget() + || qApp->focusWidget()->window() != qwidget)) return YES; // Always do it, so that windows can accept key press events. return qwidget->focusPolicy() != Qt::NoFocus; } -- cgit v0.12 From 66586707ae875bd1caa802fd7ca88a29727396e5 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 3 Mar 2010 13:51:35 +0100 Subject: Stabilize QWidget Fix for some corner cases observed on Maemo 5 Reviewed-by: Robert Griebl --- src/gui/kernel/qwidget.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index b19d541..7fdee2b 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1122,7 +1122,8 @@ void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f) qFatal("QWidget: Cannot create a QWidget when no GUI is being used"); Q_ASSERT(allWidgets); - allWidgets->insert(q); + if (allWidgets) + allWidgets->insert(q); QWidget *desktopWidget = 0; if (parentWidget && parentWidget->windowType() == Qt::Desktop) { @@ -6500,7 +6501,7 @@ void QWidget::setTabOrder(QWidget* first, QWidget *second) // QWidget *fp = first->d_func()->focus_prev; QWidget *fn = first->d_func()->focus_next; - if (fn == second) + if (fn == second || first == second) return; QWidget *sp = second->d_func()->focus_prev; -- cgit v0.12 From af430b618a196a45e45c87afca446d60b4a3552d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= Date: Wed, 3 Mar 2010 13:29:29 +0100 Subject: Don't print a warning when passing an empty string to QColor Qt 4.6 didn't used to warn about this, and it should be a valid way of setting a color to invalid. QColor::isValidColor has been adapted to still return false when passed an empty string. Reviewed-by: Erik Verbruggen --- src/gui/painting/qcolor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index 0b735a2..cd448a7 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -548,14 +548,14 @@ void QColor::setNamedColor(const QString &name) */ bool QColor::isValidColor(const QString &name) { - return QColor().setColorFromString(name); + return !name.isEmpty() && QColor().setColorFromString(name); } bool QColor::setColorFromString(const QString &name) { if (name.isEmpty()) { invalidate(); - return false; + return true; } if (name.startsWith(QLatin1Char('#'))) { -- cgit v0.12 From 69acbc34d5413e1e7642f1d533e39a8f0137051b Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 3 Mar 2010 14:36:31 +0100 Subject: fix include --- src/gui/widgets/qlabel_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qlabel_p.h b/src/gui/widgets/qlabel_p.h index 21eb128..fba7224 100644 --- a/src/gui/widgets/qlabel_p.h +++ b/src/gui/widgets/qlabel_p.h @@ -55,7 +55,7 @@ #include "qlabel.h" -#include "../text/qtextdocumentlayout_p.h" +#include "private/qtextdocumentlayout_p.h" #include "private/qtextcontrol_p.h" #include "qtextdocumentfragment.h" #include "qframe_p.h" -- cgit v0.12 From 6f07f0a2b9df84302348e290f22de13514f81d50 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 3 Mar 2010 14:48:37 +0100 Subject: test qlist some more --- tests/auto/qlist/tst_qlist.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/auto/qlist/tst_qlist.cpp b/tests/auto/qlist/tst_qlist.cpp index a590fca..e2944cc 100644 --- a/tests/auto/qlist/tst_qlist.cpp +++ b/tests/auto/qlist/tst_qlist.cpp @@ -60,6 +60,7 @@ private slots: void length() const; void lengthSignature() const; void append() const; + void prepend() const; void mid() const; }; @@ -130,6 +131,39 @@ void tst_QList::append() const } +void tst_QList::prepend() const +{ + QList list; + QString *str1 = new QString; + list.prepend(str1); + QVERIFY(list.size() == 1); + QVERIFY(list.at(0) == str1); + QString *str2 = new QString; + list.prepend(str2); + QVERIFY(list.size() == 2); + QVERIFY(list.at(0) == str2); + QVERIFY(list.at(1) == str1); + QString *str3 = new QString; + list.prepend(str3); + QVERIFY(list.size() == 3); + QVERIFY(list.at(0) == str3); + QVERIFY(list.at(1) == str2); + QVERIFY(list.at(2) == str1); + list.removeAll(str2); + delete str2; + QVERIFY(list.size() == 2); + QVERIFY(list.at(0) == str3); + QVERIFY(list.at(1) == str1); + QString *str4 = new QString; + list.prepend(str4); + QVERIFY(list.size() == 3); + QVERIFY(list.at(0) == str4); + QVERIFY(list.at(1) == str3); + QVERIFY(list.at(2) == str1); + qDeleteAll(list); + list.clear(); +} + void tst_QList::mid() const { QList list; -- cgit v0.12 From a1b0dba9971ef88dc1e079d1ea49230a4dd3c514 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 3 Mar 2010 14:48:27 +0100 Subject: fix qmake -project mode the mode is a big hack, and consequently needs hacks to get started as well ... Reviewed-by: mariusSO --- qmake/option.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/qmake/option.cpp b/qmake/option.cpp index 6f0f46b..b41e39d 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -525,6 +525,17 @@ Option::init(int argc, char **argv) } #endif } + } else if (Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) { +#if defined(Q_OS_MAC) + Option::host_mode = Option::HOST_MACX_MODE; + Option::target_mode = Option::TARG_MACX_MODE; +#elif defined(Q_OS_UNIX) + Option::host_mode = Option::HOST_UNIX_MODE; + Option::target_mode = Option::TARG_UNIX_MODE; +#else + Option::host_mode = Option::HOST_WIN_MODE; + Option::target_mode = Option::TARG_WIN_MODE; +#endif } //defaults for globals -- cgit v0.12 From 5d1735d6cf1820107145e7fdfe41ac502d0020f9 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Fri, 29 Jan 2010 16:06:06 +0100 Subject: Optimize QGtkStyle Use latin1 literals instead of QString to prevent one malloc/memcpy/free per rendered table cell. Reviewed-By: Robert Griebl --- src/gui/styles/qgtkpainter.cpp | 2 +- src/gui/styles/qgtkstyle.cpp | 203 +++++++++++++++++++++++------------------ src/gui/styles/qgtkstyle_p.cpp | 103 +++++++++++++++------ src/gui/styles/qgtkstyle_p.h | 73 +++++++++++++-- 4 files changed, 252 insertions(+), 129 deletions(-) diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp index 6cc7455..1f68f2f 100644 --- a/src/gui/styles/qgtkpainter.cpp +++ b/src/gui/styles/qgtkpainter.cpp @@ -142,7 +142,7 @@ QPixmap QGtkPainter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect) } QGtkPainter::QGtkPainter(QPainter *_painter) - : m_window(QGtkStylePrivate::gtkWidget(QLatin1String("GtkWindow"))) + : m_window(QGtkStylePrivate::gtkWidget("GtkWindow")) , m_painter(_painter) , m_alpha(true) , m_hflipped(false) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index b5f052b..e2de43a 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -222,7 +222,7 @@ QPalette QGtkStyle::standardPalette() const QPalette palette = QCleanlooksStyle::standardPalette(); if (d->isThemeAvailable()) { GtkStyle *style = d->gtkStyle(); - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); GtkWidget *gtkEntry = d->getTextColorWidget(); GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg; @@ -253,7 +253,7 @@ QPalette QGtkStyle::standardPalette() const palette.setColor(QPalette::Base, base); QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box - GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView")); + GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView"); GdkColor *gtkAltBase = NULL; d->gtk_widget_style_get(gtkTreeView, "odd-row-color", >kAltBase, NULL); if (gtkAltBase) { @@ -421,14 +421,14 @@ int QGtkStyle::pixelMetric(PixelMetric metric, return 0; case PM_ButtonShiftHorizontal: { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); guint horizontal_shift; d->gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL); return horizontal_shift; } case PM_ButtonShiftVertical: { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); guint vertical_shift; d->gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL); return vertical_shift; @@ -438,7 +438,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric, return 0; case PM_MenuPanelWidth: { - GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu")); + GtkWidget *gtkMenu = d->gtkWidget("GtkMenu"); guint horizontal_padding = 0; // horizontal-padding is used by Maemo to get thicker borders if (!d->gtk_check_version(2, 10, 0)) @@ -495,7 +495,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric, case PM_SliderThickness: case PM_SliderControlThickness: { - GtkWidget *gtkScale = d->gtkWidget(QLS("GtkHScale")); + GtkWidget *gtkScale = d->gtkWidget("GtkHScale"); gint val; d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL); if (metric == PM_SliderControlThickness) @@ -506,7 +506,7 @@ int QGtkStyle::pixelMetric(PixelMetric metric, case PM_ScrollBarExtent: { gint sliderLength; gint trough_border; - GtkWidget *hScrollbar = d->gtkWidget(QLS("GtkHScrollbar")); + GtkWidget *hScrollbar = d->gtkWidget("GtkHScrollbar"); d->gtk_widget_style_get(hScrollbar, "trough-border", &trough_border, "slider-width", &sliderLength, @@ -519,34 +519,34 @@ int QGtkStyle::pixelMetric(PixelMetric metric, case PM_SliderLength: gint val; - d->gtk_widget_style_get(d->gtkWidget(QLS("GtkHScale")), "slider-length", &val, NULL); + d->gtk_widget_style_get(d->gtkWidget("GtkHScale"), "slider-length", &val, NULL); return val; case PM_ExclusiveIndicatorWidth: case PM_ExclusiveIndicatorHeight: case PM_IndicatorWidth: case PM_IndicatorHeight: { - GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); gint size, spacing; d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL); return size + 2 * spacing; } case PM_MenuBarVMargin: { - GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); return qMax(0, gtkMenubar->style->ythickness); } case PM_ScrollView_ScrollBarSpacing: { gint spacing = 3; - GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow")); + GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow"); Q_ASSERT(gtkScrollWindow); d->gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL); return spacing; } case PM_SubMenuOverlap: { gint offset = 0; - GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu")); + GtkWidget *gtkMenu = d->gtkWidget("GtkMenu"); d->gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL); return offset; } @@ -587,7 +587,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg { if (d->isKDE4Session()) return QCleanlooksStyle::styleHint(hint, option, widget, returnData); - GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar")); + GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS; g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL); switch (toolbar_style) { @@ -610,7 +610,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg return int(false); case SH_ComboBox_Popup: { - GtkWidget *gtkComboBox = d->gtkWidget(QLS("GtkComboBox")); + GtkWidget *gtkComboBox = d->gtkWidget("GtkComboBox"); gboolean appears_as_list; d->gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL); return appears_as_list ? 0 : 1; @@ -634,7 +634,7 @@ int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidg if (widget && widget->isWindow()) scrollbars_within_bevel = true; else if (!d->gtk_check_version(2, 12, 0)) { - GtkWidget *gtkScrollWindow = d->gtkWidget(QLS("GtkScrolledWindow")); + GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow"); d->gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL); } return !scrollbars_within_bevel; @@ -712,7 +712,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, GtkStyle *style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "*.GtkScrolledWindow", "*.GtkScrolledWindow", d->gtk_window_get_type()); if (style) - gtkFramePainter.paintShadow(d->gtkWidget(QLS("GtkFrame")), "viewport", pmRect, + gtkFramePainter.paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect, option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, shadow_type, style); QPixmapCache::insert(pmKey, pixmap); @@ -739,7 +739,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, break; case PE_PanelTipLabel: { - GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed + GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow", d->gtk_window_get_type()); gtkPainter.paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style); @@ -754,7 +754,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, break; } GtkShadowType shadow_type; - GtkWidget *gtkStatusbarFrame = d->gtkWidget(QLS("GtkStatusbar.GtkFrame")); + GtkWidget *gtkStatusbarFrame = d->gtkWidget("GtkStatusbar.GtkFrame"); d->gtk_widget_style_get(gtkStatusbarFrame->parent, "shadow-type", &shadow_type, NULL); gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL, shadow_type, gtkStatusbarFrame->style); @@ -763,7 +763,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, case PE_IndicatorHeaderArrow: if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { - GtkWidget *gtkTreeHeader = d->gtkWidget(QLS("GtkTreeView.GtkButton")); + GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton"); GtkStateType state = gtkPainter.gtkState(option); style = gtkTreeHeader->style; GtkArrowType type = GTK_ARROW_UP; @@ -801,7 +801,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, rect.translate(2, 0); GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED; GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED; - GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView")); + GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView"); GtkStateType state = GTK_STATE_NORMAL; if (!(option->state & State_Enabled)) @@ -837,7 +837,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, case PE_IndicatorToolBarSeparator: { const int margin = 6; - GtkWidget *gtkSeparator = d->gtkWidget(QLS("GtkToolbar.GtkSeparatorToolItem")); + GtkWidget *gtkSeparator = d->gtkWidget("GtkToolbar.GtkSeparatorToolItem"); if (option->state & State_Horizontal) { const int offset = option->rect.width()/2; QRect rect = option->rect.adjusted(offset, margin, 0, -margin); @@ -857,7 +857,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, break; case PE_IndicatorToolBarHandle: { - GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar")); + GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); GtkShadowType shadow_type; d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL); //Note when the toolbar is horizontal, the handle is vertical @@ -905,7 +905,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, GtkStateType state = gtkPainter.gtkState(option); QColor arrowColor = option->palette.buttonText().color(); - GtkWidget *gtkArrow = d->gtkWidget(QLS("GtkArrow")); + GtkWidget *gtkArrow = d->gtkWidget("GtkArrow"); GdkColor color = fromQColor(arrowColor); d->gtk_widget_modify_fg (gtkArrow, state, &color); gtkPainter.paintArrow(gtkArrow, "button", arrowRect, @@ -921,7 +921,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, break; case PE_PanelMenu: { - GtkWidget *gtkMenu = d->gtkWidget(QLS("GtkMenu")); + GtkWidget *gtkMenu = d->gtkWidget("GtkMenu"); gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString()); } @@ -933,7 +933,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, // This is only used by floating tool bars if (qobject_cast(widget)) { - GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); gtkPainter.paintBox( gtkMenubar, "toolbar", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style); gtkPainter.paintBox( gtkMenubar, "menu", option->rect, @@ -942,7 +942,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, break; case PE_FrameLineEdit: { - GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry")); + GtkWidget *gtkEntry = d->gtkWidget("GtkEntry"); gboolean interior_focus; @@ -976,7 +976,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, case PE_PanelLineEdit: if (const QStyleOptionFrame *panel = qstyleoption_cast(option)) { - GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry")); + GtkWidget *gtkEntry = d->gtkWidget("GtkEntry"); if (panel->lineWidth > 0) proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget); uint resolve_mask = option->palette.resolve(); @@ -994,7 +994,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, case PE_FrameTabWidget: if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast(option)) { - GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook")); + GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook"); style = gtkPainter.getStyle(gtkNotebook); gtkPainter.setAlphaSupport(false); GtkShadowType shadow = GTK_SHADOW_OUT; @@ -1042,7 +1042,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, GtkStateType state = gtkPainter.gtkState(option); if (option->state & State_On || option->state & State_Sunken) state = GTK_STATE_ACTIVE; - GtkWidget *gtkButton = d->gtkWidget(isTool ? QLS("GtkToolButton.GtkButton") : QLS("GtkButton")); + GtkWidget *gtkButton = isTool ? d->gtkWidget("GtkToolButton.GtkButton") : d->gtkWidget("GtkButton"); gint focusWidth, focusPad; gboolean interiorFocus = false; d->gtk_widget_style_get (gtkButton, @@ -1098,14 +1098,14 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, else shadow = GTK_SHADOW_OUT; - GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton")); + GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton"); gint spacing; d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL); QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing); gtkPainter.setClipRect(option->rect); // ### Note: Ubuntulooks breaks when the proper widget is passed // Murrine engine requires a widget not to get RGBA check - warnings - GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); QString key(QLS("radiobutton")); if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag key += QLatin1Char('f'); @@ -1133,7 +1133,7 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, int spacing; - GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); QString key(QLS("checkbutton")); if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag key += QLatin1Char('f'); @@ -1275,7 +1275,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) { // Draw prelight background - GtkWidget *gtkCheckButton = d->gtkWidget(QLS("GtkCheckButton")); + GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton"); if (option->state & State_MouseOver) { QRect bgRect = textRect | checkBoxRect; @@ -1348,7 +1348,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ? GTK_SHADOW_IN : GTK_SHADOW_OUT; - QString comboBoxPath = QLS(comboBox->editable ? "GtkComboBoxEntry" : "GtkComboBox"); + const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox"); // We use the gtk widget to position arrows and separators for us GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath); @@ -1356,7 +1356,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); d->gtk_widget_size_allocate(gtkCombo, &geometry); - QString buttonPath = comboBoxPath + QLS(".GtkToggleButton"); + QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton"); GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath); d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); if (gtkToggleButton && (appears_as_list || comboBox->editable)) { @@ -1365,7 +1366,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom // Draw the combo box as a line edit with a button next to it if (comboBox->editable || appears_as_list) { GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state; - QString entryPath = QLS(comboBox->editable ? "GtkComboBoxEntry.GtkEntry" : "GtkComboBox.GtkFrame"); + QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame"); GtkWidget *gtkEntry = d->gtkWidget(entryPath); d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); QRect frameRect = option->rect; @@ -1391,11 +1392,11 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom else { gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect, option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, - GTK_SHADOW_NONE, gtkEntry->style, entryPath + QString::number(focus)); + GTK_SHADOW_NONE, gtkEntry->style, entryPath.toString() + QString::number(focus)); } gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState, - GTK_SHADOW_IN, gtkEntry->style, entryPath + + GTK_SHADOW_IN, gtkEntry->style, entryPath.toString() + QString::number(focus) + QString::number(comboBox->editable) + QString::number(option->direction)); if (focus) @@ -1416,7 +1417,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom Q_ASSERT(gtkToggleButton); gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState, - shadow, gtkToggleButton->style, buttonPath + + shadow, gtkToggleButton->style, buttonPath.toString() + QString::number(focus) + QString::number(option->direction)); if (focus) GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); @@ -1429,12 +1430,17 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom gtkCachedPainter.paintBox(gtkToggleButton, "button", buttonRect, state, shadow, gtkToggleButton->style, - buttonPath + QString::number(focus)); + buttonPath.toString() + QString::number(focus)); if (focus) GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS); + QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton"); + // Draw the separator between label and arrows - QString vSeparatorPath = buttonPath + QLS(".GtkHBox.GtkVSeparator"); + QHashableLatin1Literal vSeparatorPath = comboBox->editable + ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator"); if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) { QRect vLineRect(gtkVSeparator->allocation.x, @@ -1444,7 +1450,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom gtkCachedPainter.paintVline( gtkVSeparator, "vseparator", vLineRect, state, gtkVSeparator->style, - 0, vLineRect.height(), 0, vSeparatorPath); + 0, vLineRect.height(), 0, vSeparatorPath.toString()); gint interiorFocus = true; @@ -1469,8 +1475,18 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom else state = GTK_STATE_NORMAL; - QString arrowPath = comboBoxPath + QLS(appears_as_list ? ".GtkToggleButton.GtkArrow" - : ".GtkToggleButton.GtkHBox.GtkArrow"); + QHashableLatin1Literal arrowPath(""); + if (comboBox->editable) { + if (appears_as_list) + arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow"); + else + arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkArrow"); + } else { + if (appears_as_list) + arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkArrow"); + else + arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow"); + } GtkWidget *gtkArrow = d->gtkWidget(arrowPath); gfloat scale = 0.7; @@ -1497,7 +1513,11 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom if (sunken) { int xoff, yoff; - GtkWidget *gtkButton = d->gtkWidget(comboBoxPath + QLS(".GtkToggleButton")); + const QHashableLatin1Literal toggleButtonPath = comboBox->editable + ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton") + : QHashableLatin1Literal("GtkComboBox.GtkToggleButton"); + + GtkWidget *gtkButton = d->gtkWidget(toggleButtonPath); d->gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL); d->gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL); arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff); @@ -1509,7 +1529,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom gtkCachedPainter.setClipRect(option->rect); gtkCachedPainter.paintArrow( gtkArrow, "arrow", arrowRect, GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, TRUE, - style, arrowPath + QString::number(option->direction)); + style, arrowPath.toString() + QString::number(option->direction)); } } END_STYLE_PIXMAPCACHE; @@ -1570,7 +1590,7 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom QStyleOptionToolButton label = *toolbutton; label.state = bflags; - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton"); QPalette pal = toolbutton->palette; if (option->state & State_Enabled && option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) { @@ -1605,8 +1625,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom case CC_ScrollBar: if (const QStyleOptionSlider *scrollBar = qstyleoption_cast(option)) { - GtkWidget *gtkHScrollBar = d->gtkWidget(QLS("GtkHScrollbar")); - GtkWidget *gtkVScrollBar = d->gtkWidget(QLS("GtkVScrollbar")); + GtkWidget *gtkHScrollBar = d->gtkWidget("GtkHScrollbar"); + GtkWidget *gtkVScrollBar = d->gtkWidget("GtkVScrollbar"); // Fill background in case the scrollbar is partially transparent painter->fillRect(option->rect, option->palette.background()); @@ -1751,10 +1771,9 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom case CC_SpinBox: if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - GtkWidget *gtkSpinButton = d->gtkWidget( - spinBox->buttonSymbols == QAbstractSpinBox::NoButtons ? - QLS("GtkEntry") : - QLS("GtkSpinButton")); + GtkWidget *gtkSpinButton = spinBox->buttonSymbols == QAbstractSpinBox::NoButtons + ? d->gtkWidget("GtkEntry") + : d->gtkWidget("GtkSpinButton"); bool isEnabled = (spinBox->state & State_Enabled); bool hover = isEnabled && (spinBox->state & State_MouseOver); bool sunken = (spinBox->state & State_Sunken); @@ -1906,8 +1925,8 @@ void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionCom case CC_Slider: if (const QStyleOptionSlider *slider = qstyleoption_cast(option)) { - GtkWidget *hScaleWidget = d->gtkWidget(QLS("GtkHScale")); - GtkWidget *vScaleWidget = d->gtkWidget(QLS("GtkVScale")); + GtkWidget *hScaleWidget = d->gtkWidget("GtkHScale"); + GtkWidget *vScaleWidget = d->gtkWidget("GtkVScale"); QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); @@ -2097,7 +2116,7 @@ void QGtkStyle::drawControl(ControlElement element, switch (element) { case CE_ProgressBarLabel: if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { - GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); + GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar"); if (!gtkProgressBar) return; @@ -2200,7 +2219,7 @@ void QGtkStyle::drawControl(ControlElement element, if (button->features & QStyleOptionButton::HasMenu) ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0); - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); QPalette pal = button->palette; int labelState = GTK_STATE_INSENSITIVE; if (option->state & State_Enabled) @@ -2221,7 +2240,7 @@ void QGtkStyle::drawControl(ControlElement element, bool isRadio = (element == CE_RadioButton); // Draw prelight background - GtkWidget *gtkRadioButton = d->gtkWidget(QLS("GtkRadioButton")); + GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton"); if (option->state & State_MouseOver) { gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect, @@ -2289,7 +2308,7 @@ void QGtkStyle::drawControl(ControlElement element, } if (!cb->currentText.isEmpty() && !cb->editable) { - GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox")); + GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox"); QPalette pal = cb->palette; int labelState = GTK_STATE_INSENSITIVE; @@ -2366,7 +2385,7 @@ void QGtkStyle::drawControl(ControlElement element, // Draws the header in tables. if (const QStyleOptionHeader *header = qstyleoption_cast(option)) { Q_UNUSED(header); - GtkWidget *gtkTreeView = d->gtkWidget(QLS("GtkTreeView")); + GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView"); // Get the middle column GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1); Q_ASSERT(column); @@ -2387,7 +2406,7 @@ void QGtkStyle::drawControl(ControlElement element, #ifndef QT_NO_SIZEGRIP case CE_SizeGrip: { - GtkWidget *gtkStatusbar = d->gtkWidget(QLS("GtkStatusbar.GtkFrame")); + GtkWidget *gtkStatusbar = d->gtkWidget("GtkStatusbar.GtkFrame"); QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness); gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, QApplication::isRightToLeft() ? @@ -2399,7 +2418,7 @@ void QGtkStyle::drawControl(ControlElement element, #endif // QT_NO_SIZEGRIP case CE_MenuBarEmptyArea: { - GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8)); if (widget) { // See CE_MenuBarItem @@ -2422,8 +2441,8 @@ void QGtkStyle::drawControl(ControlElement element, painter->save(); if (const QStyleOptionMenuItem *mbi = qstyleoption_cast(option)) { - GtkWidget *gtkMenubarItem = d->gtkWidget(QLS("GtkMenuBar.GtkMenuItem")); - GtkWidget *gtkMenubar = d->gtkWidget(QLS("GtkMenuBar")); + GtkWidget *gtkMenubarItem = d->gtkWidget("GtkMenuBar.GtkMenuItem"); + GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar"); style = gtkMenubarItem->style; @@ -2479,7 +2498,7 @@ void QGtkStyle::drawControl(ControlElement element, break; case CE_Splitter: { - GtkWidget *gtkWindow = d->gtkWidget(QLS("GtkWindow")); // The Murrine Engine currently assumes a widget is passed + GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE, !(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, style); @@ -2499,7 +2518,7 @@ void QGtkStyle::drawControl(ControlElement element, if (toolbar->positionWithinLine != QStyleOptionToolBar::End) rect.adjust(0, 0, 1, 0); - GtkWidget *gtkToolbar = d->gtkWidget(QLS("GtkToolbar")); + GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar"); GtkShadowType shadow_type = GTK_SHADOW_NONE; d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL); gtkPainter.paintBox( gtkToolbar, "toolbar", rect, @@ -2518,15 +2537,15 @@ void QGtkStyle::drawControl(ControlElement element, const int windowsItemHMargin = 3; // menu item hor text margin const int windowsItemVMargin = 26; // menu item ver text margin const int windowsRightBorder = 15; // right border on windows - GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")) : - d->gtkWidget(QLS("GtkMenu.GtkMenuItem")); + GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") : + d->gtkWidget("GtkMenu.GtkMenuItem"); style = gtkPainter.getStyle(gtkMenuItem); QColor borderColor = option->palette.background().color().darker(160); QColor shadow = option->palette.dark().color(); if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { - GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); + GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem"); painter->setPen(shadow.lighter(106)); gboolean wide_separators = 0; gint separator_height = 0; @@ -2570,7 +2589,7 @@ void QGtkStyle::drawControl(ControlElement element, bool ignoreCheckMark = false; gint checkSize; - d->gtk_widget_style_get(d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")), "indicator-size", &checkSize, NULL); + d->gtk_widget_style_get(d->gtkWidget("GtkMenu.GtkCheckMenuItem"), "indicator-size", &checkSize, NULL); int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize)); @@ -2781,7 +2800,7 @@ void QGtkStyle::drawControl(ControlElement element, case CE_PushButton: if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget); QStyleOptionButton subopt = *btn; subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); @@ -2807,7 +2826,7 @@ void QGtkStyle::drawControl(ControlElement element, case CE_TabBarTabShape: if (const QStyleOptionTab *tab = qstyleoption_cast(option)) { - GtkWidget *gtkNotebook = d->gtkWidget(QLS("GtkNotebook")); + GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook"); style = gtkPainter.getStyle(gtkNotebook); QRect rect = option->rect; @@ -2874,7 +2893,7 @@ void QGtkStyle::drawControl(ControlElement element, case CE_ProgressBarGroove: if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { Q_UNUSED(bar); - GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); + GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar"); GtkStateType state = gtkPainter.gtkState(option); gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style); } @@ -2884,7 +2903,7 @@ void QGtkStyle::drawControl(ControlElement element, case CE_ProgressBarContents: if (const QStyleOptionProgressBar *bar = qstyleoption_cast(option)) { GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE; - GtkWidget *gtkProgressBar = d->gtkWidget(QLS("GtkProgressBar")); + GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar"); style = gtkProgressBar->style; gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style); int xt = style->xthickness; @@ -3042,7 +3061,7 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast(option)) { - GtkWidget *gtkSpinButton = d->gtkWidget(QLS("GtkSpinButton")); + GtkWidget *gtkSpinButton = d->gtkWidget("GtkSpinButton"); int center = spinbox->rect.height() / 2; int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0; int yt = spinbox->frame ? gtkSpinButton->style->ythickness : 0; @@ -3096,15 +3115,19 @@ QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComple if (const QStyleOptionComboBox *box = qstyleoption_cast(option)) { // We employ the gtk widget to position arrows and separators for us QString comboBoxPath = box->editable ? QLS("GtkComboBoxEntry") : QLS("GtkComboBox"); - GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath); + GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry") + : d->gtkWidget("GtkComboBox"); d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())}; d->gtk_widget_size_allocate(gtkCombo, &geometry); int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget); - QString arrowPath = comboBoxPath + QLS(".GtkToggleButton"); - - if (!box->editable && !appears_as_list) - arrowPath += QLS(".GtkHBox.GtkArrow"); + QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton"); + if (!box->editable) { + if (appears_as_list) + arrowPath = "GtkComboBox.GtkToggleButton"; + else + arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow"; + } GtkWidget *arrowWidget = d->gtkWidget(arrowPath); if (!arrowWidget) @@ -3163,7 +3186,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, case CT_ToolButton: if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast(option)) { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkToolButton.GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton"); newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness); if (widget && qobject_cast(widget->parentWidget())) { QSize minSize(0, 25); @@ -3181,14 +3204,14 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, int textMargin = 8; if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { - GtkWidget *gtkMenuSeparator = d->gtkWidget(QLS("GtkMenu.GtkSeparatorMenuItem")); + GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem"); GtkRequisition sizeReq = {0, 0}; d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq); newSize = QSize(size.width(), sizeReq.height); break; } - GtkWidget *gtkMenuItem = d->gtkWidget(QLS("GtkMenu.GtkCheckMenuItem")); + GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem"); GtkStyle* style = gtkMenuItem->style; // Note we get the perfect height for the default font since we @@ -3210,12 +3233,12 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, case CT_SpinBox: // QSpinBox does some nasty things that depends on CT_LineEdit - newSize = size + QSize(0, -d->gtkWidget(QLS("GtkSpinButton"))->style->ythickness * 2); + newSize = size + QSize(0, -d->gtkWidget("GtkSpinButton")->style->ythickness * 2); break; case CT_PushButton: if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); gint focusPadding, focusWidth; d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL); d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL); @@ -3223,7 +3246,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness); newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding)); - GtkWidget *gtkButtonBox = d->gtkWidget(QLS("GtkHButtonBox")); + GtkWidget *gtkButtonBox = d->gtkWidget("GtkHButtonBox"); gint minWidth = 85, minHeight = 0; d->gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth, "child-min-height", &minHeight, NULL); @@ -3236,13 +3259,13 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, break; case CT_Slider: { - GtkWidget *gtkSlider = d->gtkWidget(QLS("GtkHScale")); + GtkWidget *gtkSlider = d->gtkWidget("GtkHScale"); newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness); } break; case CT_LineEdit: { - GtkWidget *gtkEntry = d->gtkWidget(QLS("GtkEntry")); + GtkWidget *gtkEntry = d->gtkWidget("GtkEntry"); newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness); } break; @@ -3253,7 +3276,7 @@ QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option, case CT_ComboBox: if (const QStyleOptionComboBox *combo = qstyleoption_cast(option)) { - GtkWidget *gtkCombo = d->gtkWidget(QLS("GtkComboBox")); + GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox"); QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget); newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness); @@ -3405,7 +3428,7 @@ QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, return option->rect; case SE_PushButtonContents: if (!d->gtk_check_version(2, 10, 0)) { - GtkWidget *gtkButton = d->gtkWidget(QLS("GtkButton")); + GtkWidget *gtkButton = d->gtkWidget("GtkButton"); GtkBorder *border = 0; d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL); if (border) { diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp index a033407..6916c02 100644 --- a/src/gui/styles/qgtkstyle_p.cpp +++ b/src/gui/styles/qgtkstyle_p.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include @@ -233,17 +234,22 @@ static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *, gpointer) } } -static QString classPath(GtkWidget *widget) +static QHashableLatin1Literal classPath(GtkWidget *widget) { - char* class_path; + char *class_path; QGtkStylePrivate::gtk_widget_path (widget, NULL, &class_path, NULL); - QString path = QLS(class_path); + + char *copy = class_path; + if (strncmp(copy, "GtkWindow.", 10) == 0) + copy += 10; + if (strncmp(copy, "GtkFixed.", 9) == 0) + copy += 9; + + copy = strdup(copy); + g_free(class_path); - // Remove the prefixes - path.remove(QLS("GtkWindow.")); - path.remove(QLS("GtkFixed.")); - return path; + return QHashableLatin1Literal::fromData(copy); } @@ -261,6 +267,7 @@ bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e) } QList QGtkStylePrivate::instances; +QGtkStylePrivate::WidgetMap *QGtkStylePrivate::widgetMap = 0; QGtkStylePrivate::QGtkStylePrivate() : QCleanlooksStylePrivate() @@ -282,7 +289,7 @@ void QGtkStylePrivate::init() qApp->installEventFilter(&filter); } -GtkWidget* QGtkStylePrivate::gtkWidget(const QString &path) +GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path) { GtkWidget *widget = gtkWidgetMap()->value(path); if (!widget) { @@ -292,10 +299,10 @@ GtkWidget* QGtkStylePrivate::gtkWidget(const QString &path) return widget; } -GtkStyle* QGtkStylePrivate::gtkStyle(const QString &path) +GtkStyle* QGtkStylePrivate::gtkStyle(const QHashableLatin1Literal &path) { - if (gtkWidgetMap()->contains(path)) - return gtkWidgetMap()->value(path)->style; + if (GtkWidget *w = gtkWidgetMap()->value(path)) + return w->style; return 0; } @@ -497,7 +504,7 @@ void QGtkStylePrivate::initGtkWidgets() const } static QString themeName; - if (!gtkWidgetMap()->contains(QLS("GtkWindow")) && themeName.isEmpty()) { + if (!gtkWidgetMap()->contains("GtkWindow") && themeName.isEmpty()) { themeName = getThemeName(); if (themeName.isEmpty()) { @@ -522,14 +529,14 @@ void QGtkStylePrivate::initGtkWidgets() const QGtkStylePrivate::gtk_widget_realize(gtkWindow); if (displayDepth == -1) displayDepth = QGtkStylePrivate::gdk_drawable_get_depth(gtkWindow->window); - gtkWidgetMap()->insert(QLS("GtkWindow"), gtkWindow); + gtkWidgetMap()->insert(QHashableLatin1Literal::fromData(strdup("GtkWindow")), gtkWindow); // Make all other widgets. respect the text direction if (qApp->layoutDirection() == Qt::RightToLeft) QGtkStylePrivate::gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); - if (!gtkWidgetMap()->contains(QLS("GtkButton"))) { + if (!gtkWidgetMap()->contains("GtkButton")) { GtkWidget *gtkButton = QGtkStylePrivate::gtk_button_new(); addWidget(gtkButton); g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), 0); @@ -566,12 +573,12 @@ void QGtkStylePrivate::initGtkWidgets() const // When styles change subwidgets can get rearranged // as with the combo box. We need to update the widget map // to reflect this; - QHash oldMap = *gtkWidgetMap(); + QHash oldMap = *gtkWidgetMap(); gtkWidgetMap()->clear(); - QHashIterator it(oldMap); + QHashIterator it(oldMap); while (it.hasNext()) { it.next(); - if (!it.key().contains(QLatin1Char('.'))) { + if (!strchr(it.key().data(), '.')) { addAllSubWidgets(it.value()); } } @@ -586,8 +593,13 @@ void QGtkStylePrivate::initGtkWidgets() const */ void QGtkStylePrivate::cleanupGtkWidgets() { - if (gtkWidgetMap()->contains(QLS("GtkWindow"))) // Gtk will destroy all children - gtk_widget_destroy(gtkWidgetMap()->value(QLS("GtkWindow"))); + if (!widgetMap) + return; + if (widgetMap->contains("GtkWindow")) // Gtk will destroy all children + gtk_widget_destroy(widgetMap->value("GtkWindow")); + for (QHash::const_iterator it = widgetMap->constBegin(); + it != widgetMap->constEnd(); ++it) + free(const_cast(it.key().data())); } static bool resolveGConf() @@ -678,7 +690,7 @@ QString QGtkStylePrivate::getThemeName() int QGtkStylePrivate::getSpinboxArrowSize() const { const int MIN_ARROW_WIDTH = 6; - GtkWidget *spinButton = gtkWidget(QLS("GtkSpinButton")); + GtkWidget *spinButton = gtkWidget("GtkSpinButton"); GtkStyle *style = spinButton->style; gint size = pango_font_description_get_size (style->font_desc); gint arrow_size; @@ -698,17 +710,17 @@ bool QGtkStylePrivate::isKDE4Session() void QGtkStylePrivate::applyCustomPaletteHash() { - QPalette menuPal = gtkWidgetPalette(QLS("GtkMenu")); - GdkColor gdkBg = gtkWidget(QLS("GtkMenu"))->style->bg[GTK_STATE_NORMAL]; + QPalette menuPal = gtkWidgetPalette("GtkMenu"); + GdkColor gdkBg = gtkWidget("GtkMenu")->style->bg[GTK_STATE_NORMAL]; QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8); menuPal.setBrush(QPalette::Base, bgColor); menuPal.setBrush(QPalette::Window, bgColor); qApp->setPalette(menuPal, "QMenu"); - QPalette toolbarPal = gtkWidgetPalette(QLS("GtkToolbar")); + QPalette toolbarPal = gtkWidgetPalette("GtkToolbar"); qApp->setPalette(toolbarPal, "QToolBar"); - QPalette menuBarPal = gtkWidgetPalette(QLS("GtkMenuBar")); + QPalette menuBarPal = gtkWidgetPalette("GtkMenuBar"); qApp->setPalette(menuBarPal, "QMenuBar"); } @@ -717,7 +729,7 @@ void QGtkStylePrivate::applyCustomPaletteHash() */ GtkWidget* QGtkStylePrivate::getTextColorWidget() const { - return gtkWidget(QLS("GtkEntry")); + return gtkWidget("GtkEntry"); } void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget) @@ -726,7 +738,7 @@ void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget) static GtkWidget* protoLayout = 0; if (!protoLayout) { protoLayout = QGtkStylePrivate::gtk_fixed_new(); - QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value(QLS("GtkWindow"))), protoLayout); + QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout); } Q_ASSERT(protoLayout); @@ -739,8 +751,19 @@ void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget) void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget) { if (Q_GTK_IS_WIDGET(widget)) { - gtk_widget_realize(widget); - gtkWidgetMap()->insert(classPath(widget), widget); + gtk_widget_realize(widget); + QHashableLatin1Literal widgetPath = classPath(widget); + + WidgetMap *map = gtkWidgetMap(); + WidgetMap::iterator it = map->find(widgetPath); + if (it != map->end()) { + free(const_cast(it.key().data())); + map->erase(it); + } + map->insert(widgetPath, widget); +#ifdef DUMP_GTK_WIDGET_TREE + qWarning("Inserted Gtk Widget: %s", widgetPath.data()); +#endif } } @@ -753,7 +776,7 @@ void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v) } // Updates window/windowtext palette based on the indicated gtk widget -QPalette QGtkStylePrivate::gtkWidgetPalette(const QString >kWidgetName) const +QPalette QGtkStylePrivate::gtkWidgetPalette(const QHashableLatin1Literal >kWidgetName) const { GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName); Q_ASSERT(gtkWidget); @@ -1089,6 +1112,28 @@ QIcon QGtkStylePrivate::getFilesystemIcon(const QFileInfo &info) return icon; } +bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) +{ + return l1.size() == l2.size() || qstrcmp(l1.data(), l2.data()) == 0; +} + +// copied from qHash.cpp +uint qHash(const QHashableLatin1Literal &key) +{ + int n = key.size(); + const uchar *p = reinterpret_cast(key.data()); + uint h = 0; + uint g; + + while (n--) { + h = (h << 4) + *p++; + if ((g = (h & 0xf0000000)) != 0) + h ^= g >> 23; + h &= ~g; + } + return h; +} + QT_END_NAMESPACE #endif // !defined(QT_NO_STYLE_GTK) diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h index db5b9b9..5ded4dd 100644 --- a/src/gui/styles/qgtkstyle_p.h +++ b/src/gui/styles/qgtkstyle_p.h @@ -56,6 +56,9 @@ #include #if !defined(QT_NO_STYLE_GTK) +#include +#include + #include #include @@ -72,6 +75,50 @@ typedef unsigned long XID; #define QLS(x) QLatin1String(x) +// ### Qt 4.7 - merge with QLatin1Literal +class QHashableLatin1Literal +{ +public: + int size() const { return m_size; } + const char *data() const { return m_data; } + + template + QHashableLatin1Literal(const char (&str)[N]) + : m_size(N - 1), m_data(str) {} + + QHashableLatin1Literal(const QHashableLatin1Literal &other) + : m_size(other.m_size), m_data(other.m_data) + {} + + QHashableLatin1Literal &operator=(const QHashableLatin1Literal &other) + { + if (this == &other) + return *this; + *const_cast(&m_size) = other.m_size; + *const_cast(&m_data) = const_cast(other.m_data); + return *this; + } + + QString toString() const { return QString::fromLatin1(m_data, m_size); } + + static QHashableLatin1Literal fromData(const char *str) + { + return QHashableLatin1Literal(str, qstrlen(str)); + } + +private: + QHashableLatin1Literal(const char *str, int length) + : m_size(length), m_data(str) + {} + + const int m_size; + const char *m_data; +}; + +bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2); +inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); } +uint qHash(const QHashableLatin1Literal &key); + class GConf; class GConfClient; @@ -252,7 +299,6 @@ typedef char* (*Ptr_gnome_icon_lookup_sync) ( GnomeIconLookupFlags flags, GnomeIconLookupResultFlags *result); - class QGtkStylePrivate : public QCleanlooksStylePrivate { Q_DECLARE_PUBLIC(QGtkStyle) @@ -262,8 +308,8 @@ public: QGtkStyleFilter filter; - static GtkWidget* gtkWidget(const QString &path); - static GtkStyle* gtkStyle(const QString &path = QLatin1String("GtkWindow")); + static GtkWidget* gtkWidget(const QHashableLatin1Literal &path); + static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow")); virtual void resolveGtk() const; virtual void initGtkMenu() const; @@ -418,17 +464,25 @@ public: static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync; static Ptr_gnome_vfs_init gnome_vfs_init; - virtual QPalette gtkWidgetPalette(const QString >kWidgetName) const; + virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal >kWidgetName) const; protected: - typedef QHash WidgetMap; + typedef QHash WidgetMap; + + static inline void destroyWidgetMap() + { + cleanupGtkWidgets(); + delete widgetMap; + widgetMap = 0; + } static inline WidgetMap *gtkWidgetMap() { - static WidgetMap *map = 0; - if (!map) - map = new WidgetMap(); - return map; + if (!widgetMap) { + widgetMap = new WidgetMap(); + qAddPostRoutine(destroyWidgetMap); + } + return widgetMap; } static QStringList extract_filter(const QString &rawFilter); @@ -443,6 +497,7 @@ protected: private: static QList instances; + static WidgetMap *widgetMap; friend class QGtkStyleUpdateScheduler; }; -- cgit v0.12 From aee5766de0ab6c942ae3e3747162871651a4ab74 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Thu, 11 Feb 2010 17:31:30 +0100 Subject: Speed up creation of the pixmap cache key As discussed with Jens and Joao Reviewed-by: Robert Griebl --- src/gui/styles/qstylehelper.cpp | 64 +++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/src/gui/styles/qstylehelper.cpp b/src/gui/styles/qstylehelper.cpp index 071ec23..359e7e1 100644 --- a/src/gui/styles/qstylehelper.cpp +++ b/src/gui/styles/qstylehelper.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -56,22 +57,67 @@ QT_BEGIN_NAMESPACE +// internal helper. Converts an integer value to an unique string token +template +struct HexString +{ + inline HexString(const T t) + : val(t) + {} + + inline void write(QChar *&dest) const + { + const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + const char *c = reinterpret_cast(&val); + for (uint i = 0; i < sizeof(T); ++i) { + *dest++ = hexChars[*c & 0xf]; + *dest++ = hexChars[(*c & 0xf0) >> 4]; + ++c; + } + } + + const T val; +}; + +// specialization to enable fast concatenating of our string tokens to a string +template +struct QConcatenable > +{ + typedef HexString type; + enum { ExactSize = true }; + static int size(const HexString &str) { return sizeof(str.val) * 2; } + static inline void appendTo(const HexString &str, QChar *&out) { str.write(out); } +}; + namespace QStyleHelper { QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size) { const QStyleOptionComplex *complexOption = qstyleoption_cast(option); - QString tmp = QString::fromLatin1("%1-%2-%3-%4-%5-%6x%7").arg(key).arg(uint(option->state)).arg(option->direction) - .arg(complexOption ? uint(complexOption->activeSubControls) : uint(0)) - .arg(option->palette.cacheKey()).arg(size.width()).arg(size.height()); + + QString tmp = key + % QLatin1Char('-') + % HexString(option->state) + % QLatin1Char('-') + % HexString(option->direction) + % QLatin1Char('-') + % HexString(complexOption ? uint(complexOption->activeSubControls) : 0u) + % QLatin1Char('-') + % HexString(option->palette.cacheKey()) + % QLatin1Char('-') + % HexString(size.width()) + % QLatin1Char('x') + % HexString(size.height()); + #ifndef QT_NO_SPINBOX if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast(option)) { - tmp.append(QLatin1Char('-')); - tmp.append(QString::number(spinBox->buttonSymbols)); - tmp.append(QLatin1Char('-')); - tmp.append(QString::number(spinBox->stepEnabled)); - tmp.append(QLatin1Char('-')); - tmp.append(QLatin1Char(spinBox->frame ? '1' : '0')); + tmp = tmp + % QLatin1Char('-') + % HexString(spinBox->buttonSymbols) + % QLatin1Char('-') + % HexString(spinBox->stepEnabled) + % QLatin1Char('-') + % QLatin1Char(spinBox->frame ? '1' : '0'); } #endif // QT_NO_SPINBOX return tmp; -- cgit v0.12 From d4bae0d0e96138d913bfc7ec9fa86b887043787f Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 3 Mar 2010 15:44:46 +0100 Subject: Fix for QRadioButtons and QCheckBoxes drawn incorrectly when a style sheet is set. Maemo 5 draws these controls very differently, so we can't rely on QWindowStyle handling CE_RadioButton/CE_CheckBox. Task-number: QTBUG-8356 Reviewed-by: ogoffart --- src/gui/styles/qstylesheetstyle.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index bc1bece..5376386 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -3457,10 +3457,17 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q case CE_RadioButton: case CE_CheckBox: - rule.drawRule(p, opt->rect); - ParentStyle::drawControl(ce, opt, p, w); - return; - + if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) { + rule.drawRule(p, opt->rect); + ParentStyle::drawControl(ce, opt, p, w); + return; + } else if (const QStyleOptionButton *btn = qstyleoption_cast(opt)) { + QStyleOptionButton butOpt(*btn); + rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button); + baseStyle()->drawControl(ce, &butOpt, p, w); + return; + } + break; case CE_RadioButtonLabel: case CE_CheckBoxLabel: if (const QStyleOptionButton *btn = qstyleoption_cast(opt)) { -- cgit v0.12 From f3dab146f231398455e52ff99d4c6f8365c8d412 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Thu, 18 Feb 2010 16:07:27 +0100 Subject: Do not reset state too early on RMB click When long-tapping on a spin box, a context menu event would stop incrementing the spin box since we called reset() too early. Call reset only if it's clear that there's a context menu. Also don't crash if menu is 0. Reviewed-by: Robert Griebl --- src/gui/widgets/qabstractspinbox.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/gui/widgets/qabstractspinbox.cpp index 4a6235c..7e2f20d 100644 --- a/src/gui/widgets/qabstractspinbox.cpp +++ b/src/gui/widgets/qabstractspinbox.cpp @@ -1248,8 +1248,11 @@ void QAbstractSpinBox::contextMenuEvent(QContextMenuEvent *event) #else Q_D(QAbstractSpinBox); - d->reset(); QPointer menu = d->edit->createStandardContextMenu(); + if (!menu) + return; + + d->reset(); QAction *selAll = new QAction(tr("&Select All"), menu); menu->insertAction(d->edit->d_func()->selectAllAction, -- cgit v0.12 From 6ecee3c9790678d34b6d159a10d509d0f9244bc8 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 3 Mar 2010 15:38:43 +0100 Subject: Introduce a setAttribute_internal helper This allows to switch certain attributes on or off without copy/pasting lots of code. Used to switch off mutually exclusive attributes, e.g. the Mac*Size attributes, or Maemo's portrait/landscape attributes. Reviewed-by: Robert Griebl --- src/gui/kernel/qwidget.cpp | 50 +++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 7fdee2b..14fecb0 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -10294,6 +10294,29 @@ const QPixmap *QWidget::icon() const #endif // QT3_SUPPORT + /*! + \internal + + This just sets the corresponding attribute bit to 1 or 0 + */ +static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data, + QWidgetPrivate *d) +{ + if (attribute < int(8*sizeof(uint))) { + if (on) + data->widget_attributes |= (1<widget_attributes &= ~(1<high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint)))); + else + d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint)))); + } +} + /*! Sets the attribute \a attribute on this widget if \a on is true; otherwise clears the attribute. @@ -10320,19 +10343,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) } #endif - if (attribute < int(8*sizeof(uint))) { - if (on) - data->widget_attributes |= (1<widget_attributes &= ~(1<high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint)))); - else - d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint)))); - } + setAttribute_internal(attribute, on, data, d); switch (attribute) { @@ -10391,14 +10402,11 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) #ifdef Q_WS_MAC { // We can only have one of these set at a time - static const int MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, - Qt::WA_MacMiniSize, 0 }; - for (int i = 0; MacSizes[i] != 0; ++i) { - if (MacSizes[i] == attribute) - continue; - int macsize_x = MacSizes[i] - 8*sizeof(uint); - int macsize_int_off = macsize_x / (8*sizeof(uint)); - d->high_attributes[macsize_int_off] &= ~(1<<(macsize_x-(macsize_int_off*8*sizeof(uint)))); + const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize, + Qt::WA_MacMiniSize }; + for (int i = 0; i < 3; ++i) { + if (MacSizes[i] != attribute) + setAttribute_internal(MacSizes[i], false, data, d); } d->macUpdateSizeAttribute(); } -- cgit v0.12 From 4a961ad412846af126ece6d9e2385e3ebe009d72 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 16 Dec 2009 14:43:43 +0100 Subject: be more verbose when warning about incompatible libraries --- src/corelib/kernel/qobject.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 761b31f..8e4ec7c 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -132,7 +132,8 @@ QObjectPrivate::QObjectPrivate(int version) : threadData(0), connectionLists(0), senders(0), currentSender(0), currentChildBeingDeleted(0) { if (version != QObjectPrivateVersion) - qFatal("Cannot mix incompatible Qt libraries"); + qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)", + version, QObjectPrivateVersion); // QObjectData initialization q_ptr = 0; -- cgit v0.12 From 48dc16b34586f7dca8bf513f6447c97543801814 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 3 Mar 2010 15:58:18 +0100 Subject: Block the Maemo5 window attribute values from being assigned to something else on other platforms. Reviewed-By: Harald Fernengel --- src/corelib/global/qnamespace.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 6ee8ae9..d2546a7 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -500,6 +500,14 @@ public: WA_MergeSoftkeys = 124, WA_MergeSoftkeysRecursively = 125, +#if 0 // these values are reserved for Maemo5 - do not re-use them + WA_Maemo5NonComposited = 126, + WA_Maemo5StackedWindow = 127, + WA_Maemo5PortraitOrientation = 128, + WA_Maemo5LandscapeOrientation = 129, + WA_Maemo5AutoOrientation = 130, + WA_Maemo5ShowProgressIndicator = 131, +#endif // Add new attributes before this line WA_AttributeCount }; -- cgit v0.12 From f57521e4c658cf239f4691efed66e49c41f22bd5 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 3 Mar 2010 17:15:47 +0100 Subject: Fix compile --- src/gui/styles/qgtkstyle_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h index 5ded4dd..e8b0be7 100644 --- a/src/gui/styles/qgtkstyle_p.h +++ b/src/gui/styles/qgtkstyle_p.h @@ -56,6 +56,7 @@ #include #if !defined(QT_NO_STYLE_GTK) +#include #include #include -- cgit v0.12 From b489394e695f78d78db9bf08bc985219f8fb9bb2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 3 Mar 2010 17:14:45 +0100 Subject: Fix compilation: include QString in order to use QString. It doesn't happen on my system, but the CI system complains, so I guess it's a namespace issue. --- src/gui/styles/qgtkstyle_p.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h index e8b0be7..6ee7904 100644 --- a/src/gui/styles/qgtkstyle_p.h +++ b/src/gui/styles/qgtkstyle_p.h @@ -76,6 +76,8 @@ typedef unsigned long XID; #define QLS(x) QLatin1String(x) +QT_BEGIN_NAMESPACE + // ### Qt 4.7 - merge with QLatin1Literal class QHashableLatin1Literal { @@ -120,6 +122,8 @@ bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal & inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); } uint qHash(const QHashableLatin1Literal &key); +QT_END_NAMESPACE + class GConf; class GConfClient; -- cgit v0.12 From c7f2181a25243ed07f1406c7023dfdd5fb75d77d Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 3 Mar 2010 17:25:07 +0100 Subject: Make sure not to crash if createStandardContextMenu() returns 0 (e.g. on Maemo5) Reviewed-by: Harald Fernengel --- src/gui/widgets/qlineedit.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 0ba8b9f..595f552 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -2038,9 +2038,10 @@ void QLineEdit::dropEvent(QDropEvent* e) */ void QLineEdit::contextMenuEvent(QContextMenuEvent *event) { - QMenu *menu = createStandardContextMenu(); - menu->setAttribute(Qt::WA_DeleteOnClose); - menu->popup(event->globalPos()); + if (QMenu *menu = createStandardContextMenu()) { + menu->setAttribute(Qt::WA_DeleteOnClose); + menu->popup(event->globalPos()); + } } #if defined(Q_WS_WIN) -- cgit v0.12 From 65e7400babb0625f4d7616ec5d71490a2dcd3c6f Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 27 Jan 2010 15:54:25 +0100 Subject: Always redraw the complete control when an input event comes in. The problem here is that a pre-edit string won't be detected by updateDisplayText(), so the control thinks nothing has changed when a new pre-edit string is set. Reviewed-By: Simon Hausmann (cherry picked from commit 16f30906f6eea3e00351478555f153697a6e186d) --- src/gui/widgets/qlinecontrol.cpp | 6 +++--- src/gui/widgets/qlinecontrol_p.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index db099e8..9ec0feb 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE Updates the display text based of the current edit text If the text has changed will emit displayTextChanged() */ -void QLineControl::updateDisplayText() +void QLineControl::updateDisplayText(bool forceUpdate) { QString orig = m_textLayout.text(); QString str; @@ -102,7 +102,7 @@ void QLineControl::updateDisplayText() m_textLayout.endLayout(); m_ascent = qRound(l.ascent()); - if (str != orig) + if (str != orig || forceUpdate) emit displayTextChanged(str); } @@ -476,7 +476,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) } } m_textLayout.setAdditionalFormats(formats); - updateDisplayText(); + updateDisplayText(/*force*/ true); if (cursorPositionChanged) emitCursorPositionChanged(); if (isGettingInput) diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index d6f2705..3f1bc2c 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -239,7 +239,7 @@ private: void init(const QString &txt); void removeSelectedText(); void internalSetText(const QString &txt, int pos = -1, bool edited = true); - void updateDisplayText(); + void updateDisplayText(bool forceUpdate = false); void internalInsert(const QString &s); void internalDelete(bool wasBackspace = false); -- cgit v0.12 From 97728e94e199017204d9c70f042ccb62e4eacc90 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 3 Mar 2010 17:48:34 +0100 Subject: Remove the Qt 4.7 #if guards that were needed for 4.6 Reviewed-by: TrustMe --- src/gui/widgets/qlineedit.cpp | 3 --- src/gui/widgets/qlineedit.h | 6 ------ 2 files changed, 9 deletions(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 595f552..7ccced6 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -383,8 +383,6 @@ void QLineEdit::setText(const QString& text) d->control->setText(text); } -// ### Qt 4.7: remove this #if guard -#if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5) /*! \since 4.7 @@ -414,7 +412,6 @@ void QLineEdit::setPlaceholderText(const QString& placeholderText) update(); } } -#endif /*! \property QLineEdit::displayText diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index fa04bfc..94e0dbe 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -83,10 +83,7 @@ class Q_GUI_EXPORT QLineEdit : public QWidget Q_PROPERTY(bool undoAvailable READ isUndoAvailable) Q_PROPERTY(bool redoAvailable READ isRedoAvailable) Q_PROPERTY(bool acceptableInput READ hasAcceptableInput) -// ### Qt 4.7: remove this #if guard -#if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5) Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText) -#endif public: explicit QLineEdit(QWidget* parent=0); @@ -102,11 +99,8 @@ public: QString displayText() const; -// ### Qt 4.7: remove this #if guard -#if (QT_VERSION >= 0x407000) || defined(Q_WS_MAEMO_5) QString placeholderText() const; void setPlaceholderText(const QString &); -#endif int maxLength() const; void setMaxLength(int); -- cgit v0.12 From c9c1ae3030bff8b8e64d1c4e02f28faba1a8eb68 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 3 Mar 2010 17:31:40 +0100 Subject: Avoid QString reallocation in QTextEngine::itemize() Calling QString::utf16() will cause reallocation (for null-termination) if the string was created via fromRawData(). Reviewed-by: Benjamin Poulain --- src/gui/text/qtextengine.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 02eae98..2291138 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1434,9 +1434,7 @@ void QTextEngine::itemize() const layoutData->hasBidi = bidiItemize(const_cast(this), analysis, control); } - const ushort *unicode = layoutData->string.utf16(); - // correctly assign script, isTab and isObject to the script analysis - const ushort *uc = unicode; + const ushort *uc = reinterpret_cast(layoutData->string.unicode()); const ushort *e = uc + length; int lastScript = QUnicodeTables::Common; while (uc < e) { -- cgit v0.12 From f3c016b8d69612e1e7e5c59ad66b639059c6e246 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Wed, 3 Mar 2010 17:54:23 +0100 Subject: Disable auto-uppercasing and predictive text for password line edits. Reviewed-by: axis --- src/gui/widgets/qlineedit.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 7ccced6..94ee4b3 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -544,6 +544,11 @@ void QLineEdit::setEchoMode(EchoMode mode) } else { imHints &= ~Qt::ImhHiddenText; } + if (mode != Normal) { + imHints |= (Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + } else { + imHints &= ~(Qt::ImhNoAutoUppercase | Qt::ImhNoPredictiveText); + } setInputMethodHints(imHints); d->control->setEchoMode(mode); update(); -- cgit v0.12 From 8f031e9c1dc4dd3b8caea646c9ea108b04f36b3c Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Thu, 4 Mar 2010 10:20:21 +1000 Subject: remove non wifi interfaces from being handled. handled by generic engine. also fix release crash --- src/plugins/bearer/corewlan/qcorewlanengine.mm | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/plugins/bearer/corewlan/qcorewlanengine.mm b/src/plugins/bearer/corewlan/qcorewlanengine.mm index a758a4b..2d33d36 100644 --- a/src/plugins/bearer/corewlan/qcorewlanengine.mm +++ b/src/plugins/bearer/corewlan/qcorewlanengine.mm @@ -201,7 +201,6 @@ void QCoreWlanEngine::connectToId(const QString &id) return; } } - [apNetwork release]; } } } @@ -292,7 +291,7 @@ void QCoreWlanEngine::doRequestUpdate() if (!interface.addressEntries().isEmpty()) state = QNetworkConfiguration::Active; - if (accessPointConfigurations.contains(id)) { + if (accessPointConfigurations.contains(id)) { //handle only scanned AP's QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); bool changed = false; @@ -319,20 +318,6 @@ void QCoreWlanEngine::doRequestUpdate() if (changed) emit configurationChanged(ptr); - } else { - QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); - - ptr->name = name; - ptr->isValid = true; - ptr->id = id; - ptr->state = state; - ptr->type = QNetworkConfiguration::InternetAccessPoint; - ptr->bearer = qGetInterfaceType(interface.name()); - - accessPointConfigurations.insert(id, ptr); - configurationInterface.insert(id, interface.name()); - - emit configurationAdded(ptr); } } @@ -496,12 +481,6 @@ bool QCoreWlanEngine::getAllScInterfaces() CFStringRef type = SCNetworkInterfaceGetInterfaceType((SCNetworkInterfaceRef)thisInterface); if ( CFEqual(type, kSCNetworkInterfaceTypeIEEE80211)) { typeStr = "WLAN"; -// } else if (CFEqual(type, kSCNetworkInterfaceTypeBluetooth)) { -// typeStr = "Bluetooth"; - } else if(CFEqual(type, kSCNetworkInterfaceTypeEthernet)) { - typeStr = "Ethernet"; - } else if(CFEqual(type, kSCNetworkInterfaceTypeFireWire)) { - typeStr = "Ethernet"; //ok a bit fudged } if(!networkInterfaces.contains(interfaceName) && !typeStr.isEmpty()) { networkInterfaces.insert(interfaceName,typeStr); -- cgit v0.12 From 8d6b5483e34d27f1ee45af9d9fadb87525c9f915 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 4 Mar 2010 09:23:53 +0100 Subject: Make QLabel::text a reloadable property In this way we can correctly load / reload a label in case it contains a rich text with a reference to the image taken from resources. Since QLabel::setText() ignores the call in case we try to set the same text, we force the reload by setting the empty string in between. For performance reasons we do it only in cases when the text value contains :/ (only in this case it might have a reference to the resources). Reviewed-by: Friedemann Kleint Task-number: QTBUG-8347 --- tools/designer/src/lib/shared/formwindowbase.cpp | 12 +++++++++++- tools/designer/src/lib/shared/qdesigner_propertysheet.cpp | 2 ++ tools/designer/src/lib/shared/qdesigner_propertysheet_p.h | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tools/designer/src/lib/shared/formwindowbase.cpp b/tools/designer/src/lib/shared/formwindowbase.cpp index 2c5efbf..b57e9d7 100644 --- a/tools/designer/src/lib/shared/formwindowbase.cpp +++ b/tools/designer/src/lib/shared/formwindowbase.cpp @@ -181,7 +181,17 @@ void FormWindowBase::reloadProperties() QMapIterator itIndex(itSheet.value()); while (itIndex.hasNext()) { const int index = itIndex.next().key(); - sheet->setProperty(index, sheet->property(index)); + const QVariant newValue = sheet->property(index); + if (qobject_cast(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) { + const PropertySheetStringValue newString = qVariantValue(newValue); + // optimize a bit, reset only if the text value might contain a reference to qt resources + // (however reloading of icons other than taken from resources might not work here) + if (newString.value().contains(QLatin1String(":/"))) { + const QVariant resetValue = qVariantFromValue(PropertySheetStringValue()); + sheet->setProperty(index, resetValue); + } + } + sheet->setProperty(index, newValue); } if (QTabWidget *tabWidget = qobject_cast(sheet->object())) { const int count = tabWidget->count(); diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp index 13bb1d7..77ab2a6 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/tools/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -271,6 +271,7 @@ bool QDesignerPropertySheetPrivate::isReloadableProperty(int index) const { return isResourceProperty(index) || propertyType(index) == QDesignerPropertySheet::PropertyStyleSheet + || propertyType(index) == QDesignerPropertySheet::PropertyText || q->property(index).type() == QVariant::Url; } @@ -549,6 +550,7 @@ QDesignerPropertySheet::PropertyType QDesignerPropertySheet::propertyTypeFromNam propertyTypeHash.insert(QLatin1String("windowModality"), PropertyWindowModality); propertyTypeHash.insert(QLatin1String("windowModified"), PropertyWindowModified); propertyTypeHash.insert(QLatin1String("styleSheet"), PropertyStyleSheet); + propertyTypeHash.insert(QLatin1String("text"), PropertyText); } return propertyTypeHash.value(name, PropertyNone); } diff --git a/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h b/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h index 9db7367..0105eac 100644 --- a/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h +++ b/tools/designer/src/lib/shared/qdesigner_propertysheet_p.h @@ -176,7 +176,8 @@ public: PropertyWindowIconText, PropertyWindowModality, PropertyWindowModified, - PropertyStyleSheet + PropertyStyleSheet, + PropertyText }; enum ObjectType { ObjectNone, ObjectLabel, ObjectLayout, ObjectLayoutWidget, ObjectQ3GroupBox }; -- cgit v0.12 From a63dc3b837fbabafcd8ccdc6c30e304f69b278da Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 4 Mar 2010 09:59:24 +0100 Subject: Avoid QString reallocation for smallcaps fonts in Itemizer::generate() Reviewed-by: Simon Hausmann --- src/gui/text/qtextengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 2291138..b826588 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -81,7 +81,7 @@ public: void generate(int start, int length, QFont::Capitalization caps) { if ((int)caps == (int)QFont::SmallCaps) - generateScriptItemsSmallCaps(m_string.utf16(), start, length); + generateScriptItemsSmallCaps(reinterpret_cast(m_string.unicode()), start, length); else if(caps == QFont::Capitalize) generateScriptItemsCapitalize(start, length); else if(caps != QFont::MixedCase) { -- cgit v0.12 From 7d7a85fa16b28fdba257bb466be5a6d2b4bf5d2f Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Thu, 4 Mar 2010 10:01:56 +0100 Subject: Enable two fast path for blend_tiled_rgb565 Blending ARGB8565 and RGB16 on top of RGB16 is common on system with 16 bits color depth. The faster blending functions can be used instead of blend_tiled_generic. Reviewed-by: Tom Cooksey --- src/gui/painting/qdrawhelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 891f4c2..8d2da69 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5072,7 +5072,7 @@ static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData) static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData) { -#if defined(QT_QWS_DEPTH_16) +#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16) QSpanData *data = reinterpret_cast(userData); if (data->texture.format == QImage::Format_ARGB8565_Premultiplied) -- cgit v0.12 From 52da988db3a03bce5513bc5e2efa3d69f3664f24 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 4 Mar 2010 11:47:36 +0100 Subject: qmake/MinGw: Link statically for Qt Creator to be able to detect it. Qt Creator detects Qt versions by running qmake. This fails if no MinGw setup is in the path as is usually the case when starting it from the menu. Make it possible to run qmake without setup. Strip executable. Reviewed-by: Thierry Bastian Reviewed-by: mariusSO --- qmake/Makefile.win32-g++ | 2 +- qmake/Makefile.win32-g++-sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qmake/Makefile.win32-g++ b/qmake/Makefile.win32-g++ index d4d6e0e..27ae27b 100644 --- a/qmake/Makefile.win32-g++ +++ b/qmake/Makefile.win32-g++ @@ -27,7 +27,7 @@ CFLAGS = -c -o$@ -O \ -DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \ -DQT_BOOTSTRAPPED CXXFLAGS = $(CFLAGS) -LFLAGS = +LFLAGS = -static-libgcc -s LIBS = -lole32 -luuid LINKQMAKE = g++ $(LFLAGS) -o qmake.exe $(OBJS) $(QTOBJS) $(LIBS) ADDCLEAN = diff --git a/qmake/Makefile.win32-g++-sh b/qmake/Makefile.win32-g++-sh index 5061089..f7b486f 100644 --- a/qmake/Makefile.win32-g++-sh +++ b/qmake/Makefile.win32-g++-sh @@ -27,7 +27,7 @@ CFLAGS = -c -o$@ -O \ -DQT_BUILD_QMAKE -DQT_NO_THREAD -DQT_NO_QOBJECT -DQT_NO_GEOM_VARIANT -DQT_NO_DATASTREAM \ -DQT_BOOTSTRAPPED CXXFLAGS = $(CFLAGS) -LFLAGS = +LFLAGS = -static-libgcc -s LIBS = -lole32 -luuid LINKQMAKE = g++ $(LFLAGS) -o qmake.exe $(OBJS) $(QTOBJS) $(LIBS) ADDCLEAN = -- cgit v0.12 From 4574b342ebb8800ba50ca23f154c20b3e8a239af Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Thu, 4 Mar 2010 11:55:01 +0100 Subject: Fix compile Missing header added --- tools/designer/src/lib/shared/formwindowbase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/designer/src/lib/shared/formwindowbase.cpp b/tools/designer/src/lib/shared/formwindowbase.cpp index b57e9d7..5292f5f 100644 --- a/tools/designer/src/lib/shared/formwindowbase.cpp +++ b/tools/designer/src/lib/shared/formwindowbase.cpp @@ -72,6 +72,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From 8c8e9ffb60c244462f615f510bc71d4010cf8faf Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Thu, 4 Mar 2010 11:47:45 +0100 Subject: Remove the OBJECTS_DIR variable assignment from some projets in Qt. This prevent debug and release object file to be mixed up when linking these application in a debug_and_release configured Qt. Reviewed-by: Marius Storm-Olsen --- demos/qtdemo/qtdemo.pro | 2 -- examples/threads/waitconditions/waitconditions.pro | 2 -- src/tools/moc/util/generate_keywords.pro | 1 - .../auto/qapplication/desktopsettingsaware/desktopsettingsaware.pro | 5 ----- tools/qev/qev.pro | 2 -- 5 files changed, 12 deletions(-) diff --git a/demos/qtdemo/qtdemo.pro b/demos/qtdemo/qtdemo.pro index 011ea0c..2a776ac 100644 --- a/demos/qtdemo/qtdemo.pro +++ b/demos/qtdemo/qtdemo.pro @@ -3,8 +3,6 @@ TARGET = qtdemo DEMO_DESTDIR = $$QT_BUILD_TREE isEmpty(DEMO_DESTDIR):DEMO_DESTDIR=../.. DESTDIR = $$DEMO_DESTDIR/bin -OBJECTS_DIR = .obj -MOC_DIR = .moc INSTALLS += target sources diff --git a/examples/threads/waitconditions/waitconditions.pro b/examples/threads/waitconditions/waitconditions.pro index b07b413..c2be6cd 100644 --- a/examples/threads/waitconditions/waitconditions.pro +++ b/examples/threads/waitconditions/waitconditions.pro @@ -10,8 +10,6 @@ INCLUDEPATH += . # Input SOURCES += waitconditions.cpp CONFIG += qt warn_on create_prl link_prl console -OBJECTS_DIR=obj/debug-shared -MOC_DIR=moc/debug-shared # install target.path = $$[QT_INSTALL_EXAMPLES]/threads/waitconditions diff --git a/src/tools/moc/util/generate_keywords.pro b/src/tools/moc/util/generate_keywords.pro index 8dff744..eb04409 100644 --- a/src/tools/moc/util/generate_keywords.pro +++ b/src/tools/moc/util/generate_keywords.pro @@ -10,4 +10,3 @@ INCLUDEPATH += . # Input SOURCES += generate_keywords.cpp CONFIG += qt create_prl link_prl -OBJECTS_DIR=.obj/debug-shared diff --git a/tests/auto/qapplication/desktopsettingsaware/desktopsettingsaware.pro b/tests/auto/qapplication/desktopsettingsaware/desktopsettingsaware.pro index 93a03db..e8b1ce9 100644 --- a/tests/auto/qapplication/desktopsettingsaware/desktopsettingsaware.pro +++ b/tests/auto/qapplication/desktopsettingsaware/desktopsettingsaware.pro @@ -13,8 +13,3 @@ wince*|symbian*:TARGET = ../desktopsettingsaware SOURCES += main.cpp CONFIG += qt warn_on create_prl link_prl CONFIG -= app_bundle - -!symbian*: { -OBJECTS_DIR=.obj/debug-shared -MOC_DIR=.moc/debug-shared -} diff --git a/tools/qev/qev.pro b/tools/qev/qev.pro index 28383c6..962b9fa 100644 --- a/tools/qev/qev.pro +++ b/tools/qev/qev.pro @@ -9,5 +9,3 @@ INCLUDEPATH += . # Input SOURCES += qev.cpp CONFIG += qt warn_on create_prl link_prl -OBJECTS_DIR=.obj/debug-shared -MOC_DIR=.moc/debug-shared -- cgit v0.12 From edb37d5ab12c061b6085d0a84fcf075faf2dba54 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 2 Mar 2010 14:12:32 +0100 Subject: Added a documentation for the new enum value in gesture api. Task-number: QTBUG-7400 Reviewed-by: David Boddie --- src/corelib/global/qnamespace.qdoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index db910ce..c5b5998 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2978,6 +2978,11 @@ the Qt::GestureStarted state and ending with a gesture in the Qt::GestureFinished or Qt::GestureCanceled states. + \value IgnoredGesturesPropagateToParent Since Qt 4.7, this flag allows you + to fine-tune gesture event propagation. By setting the flag when + \l{QGraphicsObject::grabGesture}{grabbing} a gesture all ignored partial + gestures will propagate to their parent items. + \sa QWidget::grabGesture(), QGraphicsObject::grabGesture() */ -- cgit v0.12 From 1a666089d84cb85ec8e2bda3fe0fff6f2ec2ec4a Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 2 Mar 2010 15:00:55 +0100 Subject: Allow building documentation without all of Qt added a new make target 'sub-qdoc3' which builds qdoc3 and it's dependencies only, so that when running "make docs" we don't build all of sub-tools (including declarative module), but qdoc3 only Reviewed-by: David Boddie Reviewed-by: Joao --- doc/doc.pri | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/doc.pri b/doc/doc.pri index aea5b08..3d04049 100644 --- a/doc/doc.pri +++ b/doc/doc.pri @@ -43,11 +43,11 @@ win32-g++:isEmpty(QMAKE_SH) { # Build rules: adp_docs.commands = ($$QDOC $$ADP_DOCS_QDOCCONF_FILE) -adp_docs.depends += sub-tools # qdoc3 +adp_docs.depends += sub-qdoc3 # qdoc3 qch_docs.commands = $$QT_DOCUMENTATION -qch_docs.depends += sub-tools +qch_docs.depends += sub-qdoc3 -docs.depends = adp_docs qch_docs +docs.depends = sub-qdoc3 adp_docs qch_docs docs_zh_CN.depends = docs docs_zh_CN.commands = $$QT_ZH_CN_DOCUMENTATION @@ -64,5 +64,8 @@ qchdocs.CONFIG += no_check_exist docimages.files = $$QT_BUILD_TREE/doc/src/images docimages.path = $$[QT_INSTALL_DOCS]/src -QMAKE_EXTRA_TARGETS += qdoc adp_docs qch_docs docs docs_zh_CN +sub-qdoc3.depends = sub-corelib sub-xml +sub-qdoc3.commands += (cd tools/qdoc3 && $(MAKE)) + +QMAKE_EXTRA_TARGETS += sub-qdoc3 adp_docs qch_docs docs docs_zh_CN INSTALLS += htmldocs qchdocs docimages -- cgit v0.12 From a0cb1ae902dce0c00dc2de8b92229d66945054c8 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Thu, 4 Mar 2010 14:26:24 +0100 Subject: Setting ImhHiddenText for NoEcho line edits is not 100% correct, but still way better than fully visible text. Reviewed-by: axis --- src/gui/widgets/qlineedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 94ee4b3..817547c 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -539,7 +539,7 @@ void QLineEdit::setEchoMode(EchoMode mode) if (mode == (EchoMode)d->control->echoMode()) return; Qt::InputMethodHints imHints = inputMethodHints(); - if (mode == Password) { + if (mode == Password || mode == NoEcho) { imHints |= Qt::ImhHiddenText; } else { imHints &= ~Qt::ImhHiddenText; -- cgit v0.12 From 4b3953678983b3da925066f464b55340fab3503c Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 4 Mar 2010 15:12:49 +0100 Subject: doc: Fixed some qdoc errors. The QtMultimedia module needed to have its own \page unique name so that the QtMultimedia \module would not conflict with the QtMultimedia \namespace. --- doc/src/modules.qdoc | 1 + tools/qdoc3/cppcodeparser.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/src/modules.qdoc b/doc/src/modules.qdoc index 9e1d340..76a52b4 100644 --- a/doc/src/modules.qdoc +++ b/doc/src/modules.qdoc @@ -130,6 +130,7 @@ /*! \module QtMultimedia + \page qtmultimedia-module.html \title QtMultimedia Module \contentspage All Qt Modules \previouspage QtCore diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index fef3c14..6884781 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -47,6 +47,7 @@ #include #include +#include #include "codechunk.h" #include "config.h" @@ -1650,8 +1651,9 @@ bool CppCodeParser::matchNamespaceDecl(InnerNode *parent) */ QString namespaceName = previousLexeme(); NamespaceNode *namespasse = 0; - if (parent) + if (parent) { namespasse = static_cast(parent->findNode(namespaceName, Node::Namespace)); + } if (!namespasse) { namespasse = new NamespaceNode(parent, namespaceName); namespasse->setAccess(access); -- cgit v0.12