From e84ab1fee7f44a28ee82793f83b0b27d04d28c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Wed, 6 Oct 2010 14:19:44 +0200 Subject: QGraphicsItem device coordinate cache unefficient in portrait mode Problem was that we always invalidated the cache whenever the item was rotated. This is however not required for simple rotations such as 90, 180 and 270 degrees. This commit also removes the somewhat arbitrary logic which takes the desktop size into account. We now use the viewport size instead. Auto test included. Task-number: QT-3779 Reviewed-by: yoann --- src/gui/graphicsview/qgraphicsscene.cpp | 76 ++++++++++++++++++++------ tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 76 ++++++++++++++++++++++++++ 2 files changed, 134 insertions(+), 18 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index e58b93c..a0015dc 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4362,6 +4362,50 @@ static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion & } } +// Copied from qpaintengine_vg.cpp +// Returns true for 90, 180, and 270 degree rotations. +static inline bool transformIsSimple(const QTransform& transform) +{ + QTransform::TransformationType type = transform.type(); + if (type == QTransform::TxNone || type == QTransform::TxTranslate) { + return true; + } else if (type == QTransform::TxScale) { + // Check for 0 and 180 degree rotations. + // (0 might happen after 4 rotations of 90 degrees). + qreal m11 = transform.m11(); + qreal m12 = transform.m12(); + qreal m21 = transform.m21(); + qreal m22 = transform.m22(); + if (m12 == 0.0f && m21 == 0.0f) { + if (m11 == 1.0f && m22 == 1.0f) + return true; // 0 degrees + else if (m11 == -1.0f && m22 == -1.0f) + return true; // 180 degrees. + if(m11 == 1.0f && m22 == -1.0f) + return true; // 0 degrees inverted y. + else if(m11 == -1.0f && m22 == 1.0f) + return true; // 180 degrees inverted y. + } + } else if (type == QTransform::TxRotate) { + // Check for 90, and 270 degree rotations. + qreal m11 = transform.m11(); + qreal m12 = transform.m12(); + qreal m21 = transform.m21(); + qreal m22 = transform.m22(); + if (m11 == 0.0f && m22 == 0.0f) { + if (m12 == 1.0f && m21 == -1.0f) + return true; // 90 degrees. + else if (m12 == -1.0f && m21 == 1.0f) + return true; // 270 degrees. + else if (m12 == -1.0f && m21 == -1.0f) + return true; // 90 degrees inverted y. + else if (m12 == 1.0f && m21 == 1.0f) + return true; // 270 degrees inverted y. + } + } + return false; +} + /*! \internal @@ -4530,32 +4574,28 @@ void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painte if (invertable) diff *= painter->worldTransform(); deviceData->lastTransform = painter->worldTransform(); - if (!invertable - || diff.type() > QTransform::TxTranslate - || painter->worldTransform().type() > QTransform::TxScale) { + bool allowPartialCacheExposure = false; + bool simpleTransform = invertable && diff.type() <= QTransform::TxTranslate + && transformIsSimple(painter->worldTransform()); + if (!simpleTransform) { pixModified = true; itemCache->allExposed = true; itemCache->exposed.clear(); + deviceData->cacheIndent = QPoint(); pix = QPixmap(); + } else { + allowPartialCacheExposure = deviceData->cacheIndent != QPoint(); } - // ### This is a pretty bad way to determine when to start partial - // exposure for DeviceCoordinateCache but it's the least intrusive - // approach for now. -#if 0 - // Only if the device rect isn't fully contained. - bool allowPartialCacheExposure = !viewRect.contains(deviceRect); -#else - // Only if deviceRect is 20% taller or wider than the desktop. - bool allowPartialCacheExposure = false; - if (widget) { - QRect desktopRect = QApplication::desktop()->availableGeometry(widget); - allowPartialCacheExposure = (desktopRect.width() * 1.2 < deviceRect.width() - || desktopRect.height() * 1.2 < deviceRect.height()); + // Allow partial cache exposure if the device rect isn't fully contained and + // deviceRect is 20% taller or wider than the viewRect. + if (!allowPartialCacheExposure && !viewRect.contains(deviceRect)) { + allowPartialCacheExposure = (viewRect.width() * 1.2 < deviceRect.width()) + || (viewRect.height() * 1.2 < deviceRect.height()); } -#endif + QRegion scrollExposure; - if (deviceData->cacheIndent != QPoint() || allowPartialCacheExposure) { + if (allowPartialCacheExposure) { // Part of pixmap is drawn. Either device contains viewrect (big // item covers whole screen) or parts of device are outside the // viewport. In either case the device rect must be the intersect diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 25ec040..2901dd5 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -445,6 +445,7 @@ private slots: void textItem_shortcuts(); void scroll(); void stopClickFocusPropagation(); + void deviceCoordinateCache_simpleRotations(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -10560,6 +10561,81 @@ void tst_QGraphicsItem::stopClickFocusPropagation() QVERIFY(itemWithFocus->hasFocus()); } +void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations() +{ + // Make sure we don't invalidate the cache when applying simple + // (90, 180, 270, 360) rotation transforms to the item. + QGraphicsRectItem *item = new QGraphicsRectItem(0, 0, 300, 200); + item->setBrush(Qt::red); + item->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + + QGraphicsScene scene; + scene.setSceneRect(0, 0, 300, 200); + scene.addItem(item); + + MyGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + QTRY_VERIFY(view.repaints > 0); + + QGraphicsItemCache *itemCache = QGraphicsItemPrivate::get(item)->extraItemCache(); + Q_ASSERT(itemCache); + QPixmapCache::Key currentKey = itemCache->deviceData.value(view.viewport()).key; + + // Trigger an update and verify that the cache is unchanged. + QPixmapCache::Key oldKey = currentKey; + view.reset(); + view.viewport()->update(); + QTRY_VERIFY(view.repaints > 0); + currentKey = itemCache->deviceData.value(view.viewport()).key; + QCOMPARE(currentKey, oldKey); + + // Check 90, 180, 270 and 360 degree rotations. + for (int angle = 90; angle <= 360; angle += 90) { + // Rotate item and verify that the cache was invalidated. + oldKey = currentKey; + view.reset(); + QTransform transform; + transform.translate(150, 100); + transform.rotate(angle); + transform.translate(-150, -100); + item->setTransform(transform); + QTRY_VERIFY(view.repaints > 0); + currentKey = itemCache->deviceData.value(view.viewport()).key; + QVERIFY(currentKey != oldKey); + + // IMPORTANT PART: + // Trigger an update and verify that the cache is unchanged. + oldKey = currentKey; + view.reset(); + view.viewport()->update(); + QTRY_VERIFY(view.repaints > 0); + currentKey = itemCache->deviceData.value(view.viewport()).key; + QCOMPARE(currentKey, oldKey); + } + + // 45 degree rotation. + oldKey = currentKey; + view.reset(); + QTransform transform; + transform.translate(150, 100); + transform.rotate(45); + transform.translate(-150, -100); + item->setTransform(transform); + QTRY_VERIFY(view.repaints > 0); + currentKey = itemCache->deviceData.value(view.viewport()).key; + QVERIFY(currentKey != oldKey); + + // Trigger an update and verify that the cache was invalidated. + // We should always invalidate the cache for non-trivial transforms. + oldKey = currentKey; + view.reset(); + view.viewport()->update(); + QTRY_VERIFY(view.repaints > 0); + currentKey = itemCache->deviceData.value(view.viewport()).key; + QVERIFY(currentKey != oldKey); +} + void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor() { struct Item : public QGraphicsTextItem -- cgit v0.12 From 0ece9b7f45e2cda9dfeb8dbab9b51ad39433c07e Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:30 +0200 Subject: Refactored PreviewWidget in qtconfig Removed the legacy code and behavior. Now this part of qtconfig doesn't need the qt3support module to be built. Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/main.cpp | 1 - tools/qtconfig/previewwidget.cpp | 15 +- tools/qtconfig/previewwidget.h | 12 +- tools/qtconfig/previewwidget.ui | 268 +++++++++++++++++++++++++++ tools/qtconfig/previewwidgetbase.cpp | 88 --------- tools/qtconfig/previewwidgetbase.h | 68 ------- tools/qtconfig/previewwidgetbase.ui | 340 ----------------------------------- tools/qtconfig/qtconfig.pro | 6 +- 8 files changed, 285 insertions(+), 513 deletions(-) create mode 100644 tools/qtconfig/previewwidget.ui delete mode 100644 tools/qtconfig/previewwidgetbase.cpp delete mode 100644 tools/qtconfig/previewwidgetbase.h delete mode 100644 tools/qtconfig/previewwidgetbase.ui diff --git a/tools/qtconfig/main.cpp b/tools/qtconfig/main.cpp index 928cf01..47b0994 100644 --- a/tools/qtconfig/main.cpp +++ b/tools/qtconfig/main.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include "ui_previewwidgetbase.h" #include "mainwindow.h" #include #include diff --git a/tools/qtconfig/previewwidget.cpp b/tools/qtconfig/previewwidget.cpp index 757b448..9fa9591 100644 --- a/tools/qtconfig/previewwidget.cpp +++ b/tools/qtconfig/previewwidget.cpp @@ -44,15 +44,16 @@ QT_BEGIN_NAMESPACE -PreviewWidget::PreviewWidget( QWidget *parent, const char *name ) - : PreviewWidgetBase( parent, name ) +PreviewWidget::PreviewWidget(QWidget *parent) + : QWidget(parent) { + setupUi(this); + // install event filter on child widgets - QObjectList l = queryList("QWidget"); - for (int i = 0; i < l.size(); ++i) { - QObject * obj = l.at(i); - obj->installEventFilter(this); - ((QWidget*)obj)->setFocusPolicy(Qt::NoFocus); + QList l = findChildren(); + foreach(QWidget* w, l) { + w->installEventFilter(this); + w->setFocusPolicy(Qt::NoFocus); } } diff --git a/tools/qtconfig/previewwidget.h b/tools/qtconfig/previewwidget.h index 37e9cba..ee5ae02 100644 --- a/tools/qtconfig/previewwidget.h +++ b/tools/qtconfig/previewwidget.h @@ -42,21 +42,21 @@ #ifndef PREVIEWWIDGET_H #define PREVIEWWIDGET_H -#include "previewwidgetbase.h" +#include "ui_previewwidget.h" QT_BEGIN_NAMESPACE -class PreviewWidget : public PreviewWidgetBase +class PreviewWidget : public QWidget, public Ui::PreviewWidget { Q_OBJECT public: - PreviewWidget( QWidget *parent = 0, const char *name = 0 ); + PreviewWidget(QWidget* parent = 0); - void closeEvent(QCloseEvent *); - bool eventFilter(QObject *, QEvent *); + void closeEvent(QCloseEvent*); + bool eventFilter(QObject*, QEvent*); }; QT_END_NAMESPACE -#endif +#endif // PREVIEWWIDGET_H diff --git a/tools/qtconfig/previewwidget.ui b/tools/qtconfig/previewwidget.ui new file mode 100644 index 0000000..12de30d --- /dev/null +++ b/tools/qtconfig/previewwidget.ui @@ -0,0 +1,268 @@ + + + ********************************************************************* +** +** 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 tools applications 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$ +** +********************************************************************* + PreviewWidget + + + + 0 + 0 + 414 + 318 + + + + + 0 + 0 + + + + Preview Window + + + + 6 + + + 11 + + + + + 6 + + + 0 + + + + + 6 + + + 0 + + + + + GroupBox + + + + 6 + + + 11 + + + + + RadioButton1 + + + true + + + + + + + RadioButton2 + + + + + + + RadioButton3 + + + + + + + + + + GroupBox2 + + + + 6 + + + 11 + + + + + CheckBox1 + + + true + + + + + + + CheckBox2 + + + + + + + + + + 50 + + + + + + + + + 6 + + + 0 + + + + + LineEdit + + + + + + + + ComboBox + + + + + + + + 6 + + + 0 + + + + + + + + PushButton + + + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + + + + + + 32767 + 50 + + + + true + + + <p> +<a href="http://qt.nokia.com">http://qt.nokia.com</a> +</p> +<p> +<a href="http://www.kde.org">http://www.kde.org</a> +</p> + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + + + + diff --git a/tools/qtconfig/previewwidgetbase.cpp b/tools/qtconfig/previewwidgetbase.cpp deleted file mode 100644 index 9234b6f..0000000 --- a/tools/qtconfig/previewwidgetbase.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** 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 tools applications 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 "previewwidgetbase.h" - -#include - -QT_BEGIN_NAMESPACE - -/* - * Constructs a PreviewWidgetBase as a child of 'parent', with the - * name 'name' and widget flags set to 'f'. - */ -PreviewWidgetBase::PreviewWidgetBase(QWidget* parent, const char* name, Qt::WindowFlags fl) - : QWidget(parent, name, fl) -{ - setupUi(this); - - - // signals and slots connections - init(); -} - -/* - * Destroys the object and frees any allocated resources - */ -PreviewWidgetBase::~PreviewWidgetBase() -{ - destroy(); - // no need to delete child widgets, Qt does it all for us -} - -/* - * Sets the strings of the subwidgets using the current - * language. - */ -void PreviewWidgetBase::languageChange() -{ - retranslateUi(this); -} - -void PreviewWidgetBase::init() -{ -} - -void PreviewWidgetBase::destroy() -{ -} - -QT_END_NAMESPACE diff --git a/tools/qtconfig/previewwidgetbase.h b/tools/qtconfig/previewwidgetbase.h deleted file mode 100644 index 829415e..0000000 --- a/tools/qtconfig/previewwidgetbase.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** 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 tools applications 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 PREVIEWWIDGETBASE_H -#define PREVIEWWIDGETBASE_H - -#include "ui_previewwidgetbase.h" -#include - -QT_BEGIN_NAMESPACE - -class PreviewWidgetBase : public QWidget, public Ui::PreviewWidgetBase -{ - Q_OBJECT - -public: - PreviewWidgetBase(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0); - ~PreviewWidgetBase(); - -protected slots: - virtual void languageChange(); - - virtual void init(); - virtual void destroy(); - -}; - -QT_END_NAMESPACE - -#endif // PREVIEWWIDGETBASE_H diff --git a/tools/qtconfig/previewwidgetbase.ui b/tools/qtconfig/previewwidgetbase.ui deleted file mode 100644 index 701bf84..0000000 --- a/tools/qtconfig/previewwidgetbase.ui +++ /dev/null @@ -1,340 +0,0 @@ - - - ********************************************************************* -** -** 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 tools applications 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$ -** -********************************************************************* - - PreviewWidgetBase - - - PreviewWidgetBase - - - - 0 - 0 - 378 - 236 - - - - - 1 - 1 - 0 - 0 - - - - Preview Window - - - - unnamed - - - 11 - - - 6 - - - - - unnamed - - - 0 - - - 6 - - - - - unnamed - - - 0 - - - 6 - - - - - ButtonGroup1 - - - ButtonGroup - - - - unnamed - - - 11 - - - 6 - - - - - RadioButton1 - - - RadioButton1 - - - true - - - - - - - RadioButton2 - - - RadioButton2 - - - - - - - RadioButton3 - - - RadioButton3 - - - - - - - - - - ButtonGroup2 - - - ButtonGroup2 - - - - unnamed - - - 11 - - - 6 - - - - - CheckBox1 - - - CheckBox1 - - - true - - - - - - - CheckBox2 - - - CheckBox2 - - - - - - - - - - ProgressBar1 - - - 50 - - - - - - - - - unnamed - - - 0 - - - 6 - - - - - LineEdit1 - - - LineEdit - - - - - - - ComboBox1 - - - - ComboBox - - - - - - - - unnamed - - - 0 - - - 6 - - - - - SpinBox1 - - - - - - - PushButton1 - - - PushButton - - - - - - - - - ScrollBar1 - - - Qt::Horizontal - - - - - - - Slider1 - - - Qt::Horizontal - - - - - - - textView - - - - 32767 - 50 - - - - true - - - <p> -<a href="http://qt.nokia.com">http://qt.nokia.com</a> -</p> -<p> -<a href="http://www.kde.org">http://www.kde.org</a> -</p> - - - - - - - - - - - - 20 - 20 - - - - Expanding - - - Vertical - - - - - - qPixmapFromMimeSource - diff --git a/tools/qtconfig/qtconfig.pro b/tools/qtconfig/qtconfig.pro index d1fd320..b0f2563 100644 --- a/tools/qtconfig/qtconfig.pro +++ b/tools/qtconfig/qtconfig.pro @@ -14,11 +14,11 @@ contains(QT_CONFIG, phonon) { DEFINES += HAVE_PHONON } SOURCES += colorbutton.cpp main.cpp previewframe.cpp previewwidget.cpp mainwindow.cpp paletteeditoradvanced.cpp \ - mainwindowbase.cpp paletteeditoradvancedbase.cpp previewwidgetbase.cpp + mainwindowbase.cpp paletteeditoradvancedbase.cpp HEADERS += colorbutton.h previewframe.h previewwidget.h mainwindow.h paletteeditoradvanced.h \ - mainwindowbase.h paletteeditoradvancedbase.h previewwidgetbase.h + mainwindowbase.h paletteeditoradvancedbase.h -FORMS = mainwindowbase.ui paletteeditoradvancedbase.ui previewwidgetbase.ui +FORMS = mainwindowbase.ui paletteeditoradvancedbase.ui previewwidget.ui RESOURCES = qtconfig.qrc PROJECTNAME = Qt Configuration -- cgit v0.12 From 24ea581ffff713a591157b6ca3d4749824020a0a Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:31 +0200 Subject: Removed more legacy code from qtconfig and fixed codestyle issues Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/previewframe.cpp | 15 +++++++-------- tools/qtconfig/previewframe.h | 10 +++++----- tools/qtconfig/previewwidget.cpp | 4 ++-- tools/qtconfig/previewwidget.h | 6 +++--- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/tools/qtconfig/previewframe.cpp b/tools/qtconfig/previewframe.cpp index 3b46e8d..95d64cf 100644 --- a/tools/qtconfig/previewframe.cpp +++ b/tools/qtconfig/previewframe.cpp @@ -47,8 +47,8 @@ QT_BEGIN_NAMESPACE -PreviewFrame::PreviewFrame( QWidget *parent, const char *name ) - : QFrame( parent, name ) +PreviewFrame::PreviewFrame(QWidget *parent) + : QFrame(parent) { setMinimumSize(200, 200); setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); @@ -82,23 +82,22 @@ void PreviewFrame::setPreviewVisible(bool visible) workspace->viewport()->update(); } -Workspace::Workspace(PreviewFrame* parent, const char* name) +Workspace::Workspace(PreviewFrame* parent) : QMdiArea(parent) { previewFrame = parent; PreviewWidget *previewWidget = previewFrame->widget(); - setObjectName(QLatin1String(name)); QMdiSubWindow *frame = addSubWindow(previewWidget, Qt::Window); - frame->move(10,10); + frame->move(10, 10); frame->show(); } void Workspace::paintEvent( QPaintEvent* ) { - QPainter p (viewport()); + QPainter p(viewport()); p.fillRect(rect(), palette().color(backgroundRole()).dark()); - p.setPen( QPen( Qt::white ) ); - p.drawText ( 0, height() / 2, width(), height(), Qt::AlignHCenter, previewFrame->previewText()); + p.setPen(QPen(Qt::white)); + p.drawText(0, height() / 2, width(), height(), Qt::AlignHCenter, previewFrame->previewText()); } QT_END_NAMESPACE diff --git a/tools/qtconfig/previewframe.h b/tools/qtconfig/previewframe.h index de364e4..b21e529 100644 --- a/tools/qtconfig/previewframe.h +++ b/tools/qtconfig/previewframe.h @@ -54,11 +54,11 @@ class Workspace : public QMdiArea Q_OBJECT public: - Workspace( PreviewFrame* parent = 0, const char* name = 0 ); + Workspace(PreviewFrame *parent = 0); ~Workspace() {} protected: - void paintEvent( QPaintEvent* ); + void paintEvent(QPaintEvent *); private: PreviewFrame *previewFrame; }; @@ -68,14 +68,14 @@ class PreviewFrame : public QFrame Q_OBJECT public: - PreviewFrame( QWidget *parent = 0, const char *name = 0 ); + PreviewFrame(QWidget *parent = 0); void setPreviewPalette(QPalette); void setPreviewVisible(bool val); QString previewText() const; PreviewWidget *widget() const { return previewWidget; } private: - Workspace *workspace; - PreviewWidget *previewWidget; + Workspace *workspace; + PreviewWidget *previewWidget; QString m_previewWindowText; }; diff --git a/tools/qtconfig/previewwidget.cpp b/tools/qtconfig/previewwidget.cpp index 9fa9591..abbf669 100644 --- a/tools/qtconfig/previewwidget.cpp +++ b/tools/qtconfig/previewwidget.cpp @@ -50,8 +50,8 @@ PreviewWidget::PreviewWidget(QWidget *parent) setupUi(this); // install event filter on child widgets - QList l = findChildren(); - foreach(QWidget* w, l) { + QList l = findChildren(); + foreach(QWidget *w, l) { w->installEventFilter(this); w->setFocusPolicy(Qt::NoFocus); } diff --git a/tools/qtconfig/previewwidget.h b/tools/qtconfig/previewwidget.h index ee5ae02..1452932 100644 --- a/tools/qtconfig/previewwidget.h +++ b/tools/qtconfig/previewwidget.h @@ -51,10 +51,10 @@ class PreviewWidget : public QWidget, public Ui::PreviewWidget Q_OBJECT public: - PreviewWidget(QWidget* parent = 0); + PreviewWidget(QWidget *parent = 0); - void closeEvent(QCloseEvent*); - bool eventFilter(QObject*, QEvent*); + void closeEvent(QCloseEvent *); + bool eventFilter(QObject *, QEvent *); }; QT_END_NAMESPACE -- cgit v0.12 From 10c33f225c65517a481610c3373ecd16f0f6dcdf Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:32 +0200 Subject: Refactored PaletteEditorAdvanced in qtconfig The widget was redrawn and now makes use of QDialogButtonBox. The ColorButton's are created more correctly for now. Also, all of the Qt4 ColorRoles are now supported. All the legacy code was dropped so it must not depend of qt3support. Some refactoring job also was done and much of unused code was removed. Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/mainwindow.cpp | 5 +- tools/qtconfig/paletteeditoradvanced.cpp | 541 ++++++++--------------- tools/qtconfig/paletteeditoradvanced.h | 60 ++- tools/qtconfig/paletteeditoradvanced.ui | 416 ++++++++++++++++++ tools/qtconfig/paletteeditoradvancedbase.cpp | 144 ------- tools/qtconfig/paletteeditoradvancedbase.h | 78 ---- tools/qtconfig/paletteeditoradvancedbase.ui | 617 --------------------------- tools/qtconfig/qtconfig.pro | 6 +- 8 files changed, 623 insertions(+), 1244 deletions(-) create mode 100644 tools/qtconfig/paletteeditoradvanced.ui delete mode 100644 tools/qtconfig/paletteeditoradvancedbase.cpp delete mode 100644 tools/qtconfig/paletteeditoradvancedbase.h delete mode 100644 tools/qtconfig/paletteeditoradvancedbase.ui diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 9675f99..3895418 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -753,9 +753,8 @@ void MainWindow::updateColorButtons() void MainWindow::tunePalette() { bool ok; - QPalette pal = PaletteEditorAdvanced::getPalette(&ok, editPalette, - backgroundMode(), this); - if (! ok) + QPalette pal = PaletteEditorAdvanced::getPalette(&ok, editPalette, backgroundRole(), this); + if (!ok) return; editPalette = pal; diff --git a/tools/qtconfig/paletteeditoradvanced.cpp b/tools/qtconfig/paletteeditoradvanced.cpp index 2728557..fa108e7 100644 --- a/tools/qtconfig/paletteeditoradvanced.cpp +++ b/tools/qtconfig/paletteeditoradvanced.cpp @@ -42,26 +42,41 @@ #include "paletteeditoradvanced.h" #include "colorbutton.h" -#include -#include -#include -#include -#include -#include - QT_BEGIN_NAMESPACE -PaletteEditorAdvanced::PaletteEditorAdvanced( QWidget * parent, - const char * name, bool modal, Qt::WindowFlags f ) - : PaletteEditorAdvancedBase( parent, name, modal, f ), selectedPalette(0) +PaletteEditorAdvanced::PaletteEditorAdvanced(QWidget *parent) + : QDialog(parent), selectedPalette(0) { - // work around buggy UI file - comboEffect->setEnabled(false); + setupUi(this); + + // create a ColorButton's + buttonCentral = new ColorButton(groupCentral); + buttonCentral->setToolTip(tr("Choose a color")); + buttonCentral->setWhatsThis(tr("Choose a color for the selected central color role.")); + layoutCentral->addWidget(buttonCentral); + labelCentral->setBuddy(buttonCentral); + + buttonEffect = new ColorButton(groupEffect); + buttonEffect->setToolTip(tr("Choose a color")); + buttonEffect->setWhatsThis(tr("Choose a color for the selected effect color role.")); buttonEffect->setEnabled(false); + layoutEffect->addWidget(buttonEffect); + labelEffect->setBuddy(buttonEffect); + + // signals and slots connections + connect(paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); + connect(comboCentral, SIGNAL(activated(int)), SLOT(onCentral(int))); + connect(buttonCentral, SIGNAL(clicked()), SLOT(onChooseCentralColor())); + connect(buttonEffect, SIGNAL(clicked()), SLOT(onChooseEffectColor())); + connect(comboEffect, SIGNAL(activated(int)), SLOT(onEffect(int))); + connect(checkBuildEffect, SIGNAL(toggled(bool)), SLOT(onToggleBuildEffects(bool))); + connect(checkBuildEffect, SIGNAL(toggled(bool)), buttonEffect, SLOT(setDisabled(bool))); + connect(checkBuildInactive, SIGNAL(toggled(bool)), SLOT(onToggleBuildInactive(bool))); + connect(checkBuildDisabled, SIGNAL(toggled(bool)), SLOT(onToggleBuildDisabled(bool))); + onToggleBuildEffects(true); editPalette = QApplication::palette(); - setPreviewPalette( editPalette ); } PaletteEditorAdvanced::~PaletteEditorAdvanced() @@ -76,12 +91,12 @@ void PaletteEditorAdvanced::onToggleBuildInactive( bool v ) } if (v) { - buildInactive(); + build(QPalette::Inactive); updateColorButtons(); } } -void PaletteEditorAdvanced::onToggleBuildDisabled( bool v ) +void PaletteEditorAdvanced::onToggleBuildDisabled(bool v) { if (selectedPalette == 2) { groupCentral->setDisabled(v); @@ -89,7 +104,7 @@ void PaletteEditorAdvanced::onToggleBuildDisabled( bool v ) } if (v) { - buildDisabled(); + build(QPalette::Disabled); updateColorButtons(); } } @@ -115,385 +130,192 @@ void PaletteEditorAdvanced::paletteSelected(int p) void PaletteEditorAdvanced::onChooseCentralColor() { - switch(selectedPalette) { - case 0: - default: - mapToActiveCentralRole( buttonCentral->color() ); - break; - case 1: - mapToInactiveCentralRole( buttonCentral->color() ); - break; - case 2: - mapToDisabledCentralRole( buttonCentral->color() ); - break; + QPalette::ColorGroup group = groupFromIndex(selectedPalette); + editPalette.setColor(group, centralFromIndex(comboCentral->currentIndex()), + buttonCentral->color()); + + buildEffect(group); + if (group == QPalette::Active) { + if(checkBuildInactive->isChecked()) + build(QPalette::Inactive); + if(checkBuildDisabled->isChecked()) + build(QPalette::Disabled); } + updateColorButtons(); } void PaletteEditorAdvanced::onChooseEffectColor() { - switch(selectedPalette) { - case 0: - default: - mapToActiveEffectRole( buttonEffect->color() ); - break; - case 1: - mapToInactiveEffectRole( buttonEffect->color() ); - break; - case 2: - mapToDisabledEffectRole( buttonEffect->color() ); - break; + QPalette::ColorGroup group = groupFromIndex(selectedPalette); + editPalette.setColor(group, effectFromIndex(comboEffect->currentIndex()), + buttonEffect->color()); + + if (group == QPalette::Active) { + if(checkBuildInactive->isChecked()) + build(QPalette::Inactive); + if(checkBuildDisabled->isChecked()) + build(QPalette::Disabled); } + updateColorButtons(); } -void PaletteEditorAdvanced::onToggleBuildEffects( bool on ) +void PaletteEditorAdvanced::onToggleBuildEffects(bool on) { - if (!on) return; - buildActiveEffect(); - buildInactiveEffect(); - buildDisabledEffect(); + if (on) { + for (int i = 0; i < QPalette::NColorGroups; i++) + buildEffect(QPalette::ColorGroup(i)); + } } -QColorGroup::ColorRole PaletteEditorAdvanced::centralFromItem( int item ) +QPalette::ColorGroup PaletteEditorAdvanced::groupFromIndex(int item) { switch( item ) { - case 0: - return QColorGroup::Window; - case 1: - return QColorGroup::WindowText; - case 2: - return QColorGroup::Button; - case 3: - return QColorGroup::Base; - case 4: - return QColorGroup::Text; - case 5: - return QColorGroup::BrightText; - case 6: - return QColorGroup::ButtonText; - case 7: - return QColorGroup::Highlight; - case 8: - return QColorGroup::HighlightedText; - default: - return QColorGroup::NColorRoles; + case 0: + default: + return QPalette::Active; + case 1: + return QPalette::Inactive; + case 2: + return QPalette::Disabled; } } -QColorGroup::ColorRole PaletteEditorAdvanced::effectFromItem( int item ) + +QPalette::ColorRole PaletteEditorAdvanced::centralFromIndex(int item) { switch( item ) { case 0: - return QColorGroup::Light; + return QPalette::Window; case 1: - return QColorGroup::Midlight; + return QPalette::WindowText; case 2: - return QColorGroup::Mid; + return QPalette::Base; case 3: - return QColorGroup::Dark; + return QPalette::AlternateBase; case 4: - return QColorGroup::Shadow; + return QPalette::ToolTipBase; + case 5: + return QPalette::ToolTipText; + case 6: + return QPalette::Text; + case 7: + return QPalette::Button; + case 8: + return QPalette::ButtonText; + case 9: + return QPalette::BrightText; + case 10: + return QPalette::Highlight; + case 11: + return QPalette::HighlightedText; + case 12: + return QPalette::Link; + case 13: + return QPalette::LinkVisited; default: - return QColorGroup::NColorRoles; + return QPalette::NoRole; } } -void PaletteEditorAdvanced::onCentral( int item ) +QPalette::ColorRole PaletteEditorAdvanced::effectFromIndex(int item) { - QColor c; - - switch(selectedPalette) { + switch( item ) { case 0: - default: - c = editPalette.active().color( centralFromItem(item) ); - break; + return QPalette::Light; case 1: - c = editPalette.inactive().color( centralFromItem(item) ); - break; + return QPalette::Midlight; case 2: - c = editPalette.disabled().color( centralFromItem(item) ); - break; - } - - buttonCentral->setColor(c); -} - -void PaletteEditorAdvanced::onEffect( int item ) -{ - QColor c; - switch(selectedPalette) { - case 0: + return QPalette::Mid; + case 3: + return QPalette::Dark; + case 4: + return QPalette::Shadow; default: - c = editPalette.active().color( effectFromItem(item) ); - break; - case 1: - editPalette.inactive().color( effectFromItem(item) ); - break; - case 2: - editPalette.disabled().color( effectFromItem(item) ); - break; + return QPalette::NoRole; } - buttonEffect->setColor(c); -} - -void PaletteEditorAdvanced::mapToActiveCentralRole( const QColor& c ) -{ - QColorGroup cg = editPalette.active(); - cg.setColor( centralFromItem(comboCentral->currentItem()), c ); - editPalette.setActive( cg ); - - buildActiveEffect(); - if(checkBuildInactive->isChecked()) - buildInactive(); - if(checkBuildDisabled->isChecked()) - buildDisabled(); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToActiveEffectRole( const QColor& c ) -{ - QColorGroup cg = editPalette.active(); - cg.setColor( effectFromItem(comboEffect->currentItem()), c ); - editPalette.setActive( cg ); - - if(checkBuildInactive->isChecked()) - buildInactive(); - if(checkBuildDisabled->isChecked()) - buildDisabled(); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToActivePixmapRole( const QPixmap& pm ) -{ - QColorGroup::ColorRole role = centralFromItem(comboCentral->currentItem()); - QColorGroup cg = editPalette.active(); - if ( !pm.isNull() ) - cg.setBrush( role, QBrush( cg.color( role ), pm ) ); - else - cg.setBrush( role, QBrush( cg.color( role ) ) ); - editPalette.setActive( cg ); - - - buildActiveEffect(); - if(checkBuildInactive->isChecked()) - buildInactive(); - if(checkBuildDisabled->isChecked()) - buildDisabled(); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToInactiveCentralRole( const QColor& c ) -{ - QColorGroup cg = editPalette.inactive(); - cg.setColor( centralFromItem(comboCentral->currentItem()), c ); - editPalette.setInactive( cg ); - - buildInactiveEffect(); - - setPreviewPalette( editPalette ); } -void PaletteEditorAdvanced::mapToInactiveEffectRole( const QColor& c ) +void PaletteEditorAdvanced::onCentral(int item) { - QColorGroup cg = editPalette.inactive(); - cg.setColor( effectFromItem(comboEffect->currentItem()), c ); - editPalette.setInactive( cg ); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToInactivePixmapRole( const QPixmap& pm ) -{ - QColorGroup::ColorRole role = centralFromItem(comboCentral->currentItem()); - QColorGroup cg = editPalette.inactive(); - if ( !pm.isNull() ) - cg.setBrush( role, QBrush( cg.color( role ), pm ) ); - else - cg.setBrush( role, QBrush( cg.color( role ) ) ); - editPalette.setInactive( cg ); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToDisabledCentralRole( const QColor& c ) -{ - QColorGroup cg = editPalette.disabled(); - cg.setColor( centralFromItem(comboCentral->currentItem()), c ); - editPalette.setDisabled( cg ); - - buildDisabledEffect(); - - setPreviewPalette( editPalette ); -} - -void PaletteEditorAdvanced::mapToDisabledEffectRole( const QColor& c ) -{ - QColorGroup cg = editPalette.disabled(); - cg.setColor( effectFromItem(comboEffect->currentItem()), c ); - editPalette.setDisabled( cg ); - - setPreviewPalette( editPalette ); + QColor c = editPalette.color(groupFromIndex(selectedPalette), centralFromIndex(item)); + buttonCentral->setColor(c); } -void PaletteEditorAdvanced::mapToDisabledPixmapRole( const QPixmap& pm ) +void PaletteEditorAdvanced::onEffect(int item) { - QColorGroup::ColorRole role = centralFromItem(comboCentral->currentItem()); - QColorGroup cg = editPalette.disabled(); - if ( !pm.isNull() ) - cg.setBrush( role, QBrush( cg.color( role ), pm ) ); - else - cg.setBrush( role, QBrush( cg.color( role ) ) ); - - editPalette.setDisabled( cg ); - - setPreviewPalette( editPalette ); + QColor c = editPalette.color(groupFromIndex(selectedPalette), effectFromIndex(item)); + buttonEffect->setColor(c); } -void PaletteEditorAdvanced::buildActiveEffect() +QPalette PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup colorGroup, + const QPalette &basePalette) { - QColorGroup cg = editPalette.active(); - QColor btn = cg.color( QColorGroup::Button ); + QPalette result(basePalette); - QPalette temp( btn, btn ); + if (colorGroup == QPalette::Active) { + QPalette calculatedPalette(basePalette.color(colorGroup, QPalette::Button), + basePalette.color(colorGroup, QPalette::Window)); - for (int i = 0; i<5; i++) - cg.setColor( effectFromItem(i), temp.active().color( effectFromItem(i) ) ); - - editPalette.setActive( cg ); - setPreviewPalette( editPalette ); - - updateColorButtons(); -} - -void PaletteEditorAdvanced::buildInactive() -{ - editPalette.setInactive( editPalette.active() ); - if ( checkBuildEffect->isChecked() ) - buildInactiveEffect(); + for (int i = 0; i < 5; i++) { + QPalette::ColorRole effectRole = effectFromIndex(i); + result.setColor(colorGroup, effectRole, + calculatedPalette.color(colorGroup, effectRole)); + } + } else { - setPreviewPalette( editPalette ); - updateColorButtons(); + QColor btn = basePalette.color(colorGroup, QPalette::Button); + + result.setColor(colorGroup, QPalette::Light, btn.lighter()); + result.setColor(colorGroup, QPalette::Midlight, btn.lighter(115)); + result.setColor(colorGroup, QPalette::Mid, btn.darker(150)); + result.setColor(colorGroup, QPalette::Dark, btn.darker()); + result.setColor(colorGroup, QPalette::Shadow, Qt::black); } + return result; } -void PaletteEditorAdvanced::buildInactiveEffect() +void PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup colorGroup) { - QColorGroup cg = editPalette.inactive(); - - QColor light, midlight, mid, dark, shadow; - QColor btn = cg.color( QColorGroup::Button ); - - light = btn.light(150); - midlight = btn.light(115); - mid = btn.dark(150); - dark = btn.dark(); - shadow = Qt::black; - - cg.setColor( QColorGroup::Light, light ); - cg.setColor( QColorGroup::Midlight, midlight ); - cg.setColor( QColorGroup::Mid, mid ); - cg.setColor( QColorGroup::Dark, dark ); - cg.setColor( QColorGroup::Shadow, shadow ); - - editPalette.setInactive( cg ); - setPreviewPalette( editPalette ); + editPalette = buildEffect(colorGroup, editPalette); updateColorButtons(); } -void PaletteEditorAdvanced::buildDisabled() +void PaletteEditorAdvanced::build(QPalette::ColorGroup colorGroup) { - QColorGroup cg = editPalette.active(); - cg.setColor( QColorGroup::ButtonText, Qt::darkGray ); - cg.setColor( QColorGroup::WindowText, Qt::darkGray ); - cg.setColor( QColorGroup::Text, Qt::darkGray ); - cg.setColor( QColorGroup::HighlightedText, Qt::darkGray ); - editPalette.setDisabled( cg ); - - if ( checkBuildEffect->isChecked() ) - buildDisabledEffect(); - else { - setPreviewPalette( editPalette ); - updateColorButtons(); - } -} - -void PaletteEditorAdvanced::buildDisabledEffect() -{ - QColorGroup cg = editPalette.disabled(); - - QColor light, midlight, mid, dark, shadow; - QColor btn = cg.color( QColorGroup::Button ); - - light = btn.light(150); - midlight = btn.light(115); - mid = btn.dark(150); - dark = btn.dark(); - shadow = Qt::black; + if (colorGroup != QPalette::Active) { + for (int i = 0; i < QPalette::NColorRoles; i++) + editPalette.setColor(colorGroup, QPalette::ColorRole(i), + editPalette.color(QPalette::Active, QPalette::ColorRole(i))); - cg.setColor( QColorGroup::Light, light ); - cg.setColor( QColorGroup::Midlight, midlight ); - cg.setColor( QColorGroup::Mid, mid ); - cg.setColor( QColorGroup::Dark, dark ); - cg.setColor( QColorGroup::Shadow, shadow ); + if (colorGroup == QPalette::Disabled) { + editPalette.setColor(colorGroup, QPalette::ButtonText, Qt::darkGray); + editPalette.setColor(colorGroup, QPalette::WindowText, Qt::darkGray); + editPalette.setColor(colorGroup, QPalette::Text, Qt::darkGray); + editPalette.setColor(colorGroup, QPalette::HighlightedText, Qt::darkGray); + } - editPalette.setDisabled( cg ); - setPreviewPalette( editPalette ); - updateColorButtons(); -} - -void PaletteEditorAdvanced::setPreviewPalette( const QPalette& pal ) -{ - QColorGroup cg; - - switch (selectedPalette) { - case 0: - default: - cg = pal.active(); - break; - case 1: - cg = pal.inactive(); - break; - case 2: - cg = pal.disabled(); - break; + if (checkBuildEffect->isChecked()) + buildEffect(colorGroup); + else + updateColorButtons(); } - previewPalette.setActive( cg ); - previewPalette.setInactive( cg ); - previewPalette.setDisabled( cg ); } void PaletteEditorAdvanced::updateColorButtons() { - QColor central, effect; - switch (selectedPalette) { - case 0: - default: - central = editPalette.active().color( centralFromItem( comboCentral->currentItem() ) ); - effect = editPalette.active().color( effectFromItem( comboEffect->currentItem() ) ); - break; - case 1: - central = editPalette.inactive().color( centralFromItem( comboCentral->currentItem() ) ); - effect = editPalette.inactive().color( effectFromItem( comboEffect->currentItem() ) ); - break; - case 2: - central = editPalette.disabled().color( centralFromItem( comboCentral->currentItem() ) ); - effect = editPalette.disabled().color( effectFromItem( comboEffect->currentItem() ) ); - break; - } - - buttonCentral->setColor(central); - buttonEffect->setColor(effect); + QPalette::ColorGroup colorGroup = groupFromIndex(selectedPalette); + buttonCentral->setColor(editPalette.color(colorGroup, + centralFromIndex(comboCentral->currentIndex()))); + buttonEffect->setColor(editPalette.color(colorGroup, + effectFromIndex(comboEffect->currentIndex()))); } -void PaletteEditorAdvanced::setPal( const QPalette& pal ) +void PaletteEditorAdvanced::setPal(const QPalette &pal) { editPalette = pal; - setPreviewPalette( pal ); updateColorButtons(); } @@ -502,51 +324,51 @@ QPalette PaletteEditorAdvanced::pal() const return editPalette; } -void PaletteEditorAdvanced::setupBackgroundMode( Qt::BackgroundMode mode ) +void PaletteEditorAdvanced::setupBackgroundRole(QPalette::ColorRole role) { int initRole = 0; - switch( mode ) { - case Qt::PaletteBackground: + switch(role) { + case QPalette::Window: initRole = 0; break; - case Qt::PaletteForeground: + case QPalette::WindowText: initRole = 1; break; - case Qt::PaletteButton: + case QPalette::Base: initRole = 2; break; - case Qt::PaletteBase: + case QPalette::AlternateBase: initRole = 3; break; - case Qt::PaletteText: + case QPalette::ToolTipBase: initRole = 4; break; - case Qt::PaletteBrightText: + case QPalette::ToolTipText: initRole = 5; break; - case Qt::PaletteButtonText: + case QPalette::Text: initRole = 6; break; - case Qt::PaletteHighlight: + case QPalette::Button: initRole = 7; break; - case Qt::PaletteHighlightedText: + case QPalette::ButtonText: initRole = 8; break; - case Qt::PaletteLight: + case QPalette::BrightText: initRole = 9; break; - case Qt::PaletteMidlight: + case QPalette::Highlight: initRole = 10; break; - case Qt::PaletteDark: + case QPalette::HighlightedText: initRole = 11; break; - case Qt::PaletteMid: + case QPalette::Link: initRole = 12; break; - case Qt::PaletteShadow: + case QPalette::LinkVisited: initRole = 13; break; default: @@ -554,36 +376,27 @@ void PaletteEditorAdvanced::setupBackgroundMode( Qt::BackgroundMode mode ) break; } - if ( initRole <= -1 ) return; - - if (initRole > 8 ) { - comboEffect->setCurrentItem( initRole - 9 ); - } - else { - comboCentral->setCurrentItem( initRole ); - } + if (initRole != -1) + comboCentral->setCurrentIndex(initRole); } -QPalette PaletteEditorAdvanced::getPalette( bool *ok, const QPalette &init, - Qt::BackgroundMode mode, QWidget* parent, - const char* name ) +QPalette PaletteEditorAdvanced::getPalette(bool *ok, const QPalette &init, + QPalette::ColorRole backgroundRole, QWidget *parent) { - PaletteEditorAdvanced* dlg = new PaletteEditorAdvanced( parent, name, true ); - dlg->setupBackgroundMode( mode ); + PaletteEditorAdvanced *dlg = new PaletteEditorAdvanced(parent); + dlg->setupBackgroundRole(backgroundRole); if ( init != QPalette() ) dlg->setPal( init ); int resultCode = dlg->exec(); QPalette result = init; - if ( resultCode == QDialog::Accepted ) { - if ( ok ) - *ok = true; + if (resultCode == QDialog::Accepted) result = dlg->pal(); - } else { - if ( ok ) - *ok = false; - } + + if (ok) + *ok = resultCode; + delete dlg; return result; } diff --git a/tools/qtconfig/paletteeditoradvanced.h b/tools/qtconfig/paletteeditoradvanced.h index a1eb8e7..f70648b 100644 --- a/tools/qtconfig/paletteeditoradvanced.h +++ b/tools/qtconfig/paletteeditoradvanced.h @@ -42,69 +42,59 @@ #ifndef PALETTEEDITORADVANCED_H #define PALETTEEDITORADVANCED_H -#include "paletteeditoradvancedbase.h" +#include "ui_paletteeditoradvanced.h" QT_BEGIN_NAMESPACE -class PaletteEditorAdvanced : public PaletteEditorAdvancedBase +class ColorButton; + +class PaletteEditorAdvanced : public QDialog, public Ui::PaletteEditorAdvanced { Q_OBJECT public: - PaletteEditorAdvanced( QWidget * parent=0, const char * name=0, - bool modal=false, Qt::WindowFlags f=0 ); + PaletteEditorAdvanced(QWidget *parent = 0); ~PaletteEditorAdvanced(); - static QPalette getPalette( bool *ok, const QPalette &pal, Qt::BackgroundMode mode = Qt::PaletteBackground, - QWidget* parent = 0, const char* name = 0 ); + static QPalette getPalette( bool *ok, const QPalette &pal, + QPalette::ColorRole backgroundRole = QPalette::Window, + QWidget *parent = 0 ); + + static QPalette buildEffect(QPalette::ColorGroup colorGroup, const QPalette &basePalette); protected slots: void paletteSelected(int); - void onCentral( int ); - void onEffect( int ); + void onCentral(int); + void onEffect(int); void onChooseCentralColor(); void onChooseEffectColor(); - void onToggleBuildEffects( bool ); - void onToggleBuildInactive( bool ); - void onToggleBuildDisabled( bool ); + void onToggleBuildEffects(bool); + void onToggleBuildInactive(bool); + void onToggleBuildDisabled(bool); protected: - void mapToActiveCentralRole( const QColor& ); - void mapToActiveEffectRole( const QColor& ); - void mapToActivePixmapRole( const QPixmap& ); - void mapToInactiveCentralRole( const QColor& ); - void mapToInactiveEffectRole( const QColor& ); - void mapToInactivePixmapRole( const QPixmap& ); - void mapToDisabledCentralRole( const QColor& ); - void mapToDisabledEffectRole( const QColor& ); - void mapToDisabledPixmapRole( const QPixmap& ); - - - void buildPalette(); - void buildActiveEffect(); - void buildInactive(); - void buildInactiveEffect(); - void buildDisabled(); - void buildDisabledEffect(); + void buildEffect(QPalette::ColorGroup); + void build(QPalette::ColorGroup); private: - void setPreviewPalette( const QPalette& ); void updateColorButtons(); - void setupBackgroundMode( Qt::BackgroundMode ); + void setupBackgroundRole(QPalette::ColorRole); QPalette pal() const; - void setPal( const QPalette& ); + void setPal(const QPalette &); - QColorGroup::ColorRole centralFromItem( int ); - QColorGroup::ColorRole effectFromItem( int ); + static QPalette::ColorGroup groupFromIndex(int); + static QPalette::ColorRole centralFromIndex(int); + static QPalette::ColorRole effectFromIndex(int); QPalette editPalette; - QPalette previewPalette; int selectedPalette; + ColorButton *buttonCentral; + ColorButton *buttonEffect; }; QT_END_NAMESPACE -#endif +#endif // PALETTEEDITORADVANCED_H diff --git a/tools/qtconfig/paletteeditoradvanced.ui b/tools/qtconfig/paletteeditoradvanced.ui new file mode 100644 index 0000000..b1d6b95 --- /dev/null +++ b/tools/qtconfig/paletteeditoradvanced.ui @@ -0,0 +1,416 @@ + + + ********************************************************************* +** +** 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 tools applications 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$ +** +********************************************************************* + PaletteEditorAdvanced + + + + 0 + 0 + 239 + 344 + + + + Tune Palette + + + + + + + + Select &Palette: + + + paletteCombo + + + + + + + + Active Palette + + + + + Inactive Palette + + + + + Disabled Palette + + + + + + + + + + + 0 + 0 + + + + Auto + + + + + + Build inactive palette from active + + + true + + + + + + + Build disabled palette from active + + + true + + + + + + + + + + Central color &roles + + + + + + Choose central color role + + + <b>Select a color role.</b><p>Available central roles are: <ul> <li>Window - general background color.</li> <li>WindowText - general foreground color. </li> <li>Base - used as background color for e.g. text entry widgets, usually white or another light color. </li> <li>Text - the foreground color used with Base. Usually this is the same as WindowText, in what case it must provide good contrast both with Window and Base. </li> <li>Button - general button background color, where buttons need a background different from Window, as in the Macintosh style. </li> <li>ButtonText - a foreground color used with the Button color. </li> <li>Highlight - a color to indicate a selected or highlighted item. </li> <li>HighlightedText - a text color that contrasts to Highlight. </li> <li>BrightText - a text color that is very different from WindowText and contrasts well with e.g. black. </li> </ul> </p> + + + + Window + + + + + WindowText + + + + + Base + + + + + AlternateBase + + + + + ToolTipBase + + + + + ToolTipText + + + + + Text + + + + + Button + + + + + ButtonText + + + + + BrightText + + + + + Highlight + + + + + HighlightedText + + + + + Link + + + + + LinkVisited + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + &Select Color: + + + + + + + + + + + + 3-D shadow &effects + + + + + + + + Generate shadings + + + Check to let 3D-effect colors be calculated from button-color. + + + Build &from button color + + + true + + + + + + + false + + + Choose 3D-effect color role + + + <b>Select a color role.</b><p>Available effect roles are: <ul> <li>Light - lighter than Button color. </li> <li>Midlight - between Button and Light. </li> <li>Mid - between Button and Dark. </li> <li>Dark - darker than Button. </li> <li>Shadow - a very dark color. </li> </ul> + + + + Light + + + + + Midlight + + + + + Mid + + + + + Dark + + + + + Shadow + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Select Co&lor: + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + PaletteEditorAdvanced + accept() + + + 238 + 384 + + + 157 + 274 + + + + + buttonBox + rejected() + PaletteEditorAdvanced + reject() + + + 306 + 390 + + + 286 + 274 + + + + + checkBuildEffect + toggled(bool) + comboEffect + setDisabled(bool) + + + 82 + 262 + + + 190 + 262 + + + + + diff --git a/tools/qtconfig/paletteeditoradvancedbase.cpp b/tools/qtconfig/paletteeditoradvancedbase.cpp deleted file mode 100644 index 708c834..0000000 --- a/tools/qtconfig/paletteeditoradvancedbase.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** 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 tools applications 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 "paletteeditoradvancedbase.h" -#include "colorbutton.h" - -#include - -QT_BEGIN_NAMESPACE - -/* - * Constructs a PaletteEditorAdvancedBase as a child of 'parent', with the - * name 'name' and widget flags set to 'f'. - * - * The dialog will by default be modeless, unless you set 'modal' to - * true to construct a modal dialog. - */ -PaletteEditorAdvancedBase::PaletteEditorAdvancedBase(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl) - : QDialog(parent, name, modal, fl) -{ - setupUi(this); - - - // signals and slots connections - connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); - connect(paletteCombo, SIGNAL(activated(int)), this, SLOT(paletteSelected(int))); - connect(comboCentral, SIGNAL(activated(int)), this, SLOT(onCentral(int))); - connect(buttonCentral, SIGNAL(clicked()), this, SLOT(onChooseCentralColor())); - connect(buttonEffect, SIGNAL(clicked()), this, SLOT(onChooseEffectColor())); - connect(comboEffect, SIGNAL(activated(int)), this, SLOT(onEffect(int))); - connect(checkBuildEffect, SIGNAL(toggled(bool)), this, SLOT(onToggleBuildEffects(bool))); - connect(checkBuildEffect, SIGNAL(toggled(bool)), comboEffect, SLOT(setDisabled(bool))); - connect(checkBuildEffect, SIGNAL(toggled(bool)), buttonEffect, SLOT(setDisabled(bool))); - connect(checkBuildInactive, SIGNAL(toggled(bool)), this, SLOT(onToggleBuildInactive(bool))); - connect(checkBuildDisabled, SIGNAL(toggled(bool)), this, SLOT(onToggleBuildDisabled(bool))); - init(); -} - -/* - * Destroys the object and frees any allocated resources - */ -PaletteEditorAdvancedBase::~PaletteEditorAdvancedBase() -{ - destroy(); - // no need to delete child widgets, Qt does it all for us -} - -/* - * Sets the strings of the subwidgets using the current - * language. - */ -void PaletteEditorAdvancedBase::languageChange() -{ - retranslateUi(this); -} - -void PaletteEditorAdvancedBase::init() -{ -} - -void PaletteEditorAdvancedBase::destroy() -{ -} - -void PaletteEditorAdvancedBase::onCentral(int) -{ - qWarning("PaletteEditorAdvancedBase::onCentral(int): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onChooseCentralColor() -{ - qWarning("PaletteEditorAdvancedBase::onChooseCentralColor(): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onChooseEffectColor() -{ - qWarning("PaletteEditorAdvancedBase::onChooseEffectColor(): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onEffect(int) -{ - qWarning("PaletteEditorAdvancedBase::onEffect(int): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onToggleBuildDisabled(bool) -{ - qWarning("PaletteEditorAdvancedBase::onToggleBuildDisabled(bool): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onToggleBuildEffects(bool) -{ - qWarning("PaletteEditorAdvancedBase::onToggleBuildEffects(bool): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::onToggleBuildInactive(bool) -{ - qWarning("PaletteEditorAdvancedBase::onToggleBuildInactive(bool): Not implemented yet"); -} - -void PaletteEditorAdvancedBase::paletteSelected(int) -{ - qWarning("PaletteEditorAdvancedBase::paletteSelected(int): Not implemented yet"); -} - -QT_END_NAMESPACE diff --git a/tools/qtconfig/paletteeditoradvancedbase.h b/tools/qtconfig/paletteeditoradvancedbase.h deleted file mode 100644 index ee14a26..0000000 --- a/tools/qtconfig/paletteeditoradvancedbase.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** 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 tools applications 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 PALETTEEDITORADVANCEDBASE_H -#define PALETTEEDITORADVANCEDBASE_H - -#include "ui_paletteeditoradvancedbase.h" -#include - -QT_BEGIN_NAMESPACE - -class ColorButton; - -class PaletteEditorAdvancedBase : public QDialog, public Ui::PaletteEditorAdvancedBase -{ - Q_OBJECT - -public: - PaletteEditorAdvancedBase(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0); - ~PaletteEditorAdvancedBase(); - -protected slots: - virtual void languageChange(); - - virtual void init(); - virtual void destroy(); - virtual void onCentral(int); - virtual void onChooseCentralColor(); - virtual void onChooseEffectColor(); - virtual void onEffect(int); - virtual void onToggleBuildDisabled(bool); - virtual void onToggleBuildEffects(bool); - virtual void onToggleBuildInactive(bool); - virtual void paletteSelected(int); - -}; - -QT_END_NAMESPACE - -#endif // PALETTEEDITORADVANCEDBASE_H diff --git a/tools/qtconfig/paletteeditoradvancedbase.ui b/tools/qtconfig/paletteeditoradvancedbase.ui deleted file mode 100644 index 12c5a7d..0000000 --- a/tools/qtconfig/paletteeditoradvancedbase.ui +++ /dev/null @@ -1,617 +0,0 @@ - - - ********************************************************************* -** -** 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 tools applications 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$ -** -********************************************************************* - - PaletteEditorAdvancedBase - - - PaletteEditorAdvancedBase - - - true - - - - 0 - 0 - 295 - 346 - - - - Tune Palette - - - true - - - <b>Edit Palette</b><p>Change the palette of the current widget or form.</p><p>Use a generated palette or select colors for each color group and each color role.</p><p>The palette can be tested with different widget layouts in the preview section.</p> - - - - unnamed - - - 11 - - - 6 - - - - - unnamed - - - 0 - - - 6 - - - - - TextLabel1 - - - Select &Palette: - - - paletteCombo - - - - - - - paletteCombo - - - - Active Palette - - - - - Inactive Palette - - - - - Disabled Palette - - - - - - - - - - ButtonGroup1 - - - - 5 - 4 - 0 - 0 - - - - Auto - - - - unnamed - - - 11 - - - 6 - - - - - checkBuildInactive - - - Build inactive palette from active - - - true - - - - - - - checkBuildDisabled - - - Build disabled palette from active - - - true - - - - - - - - - - groupCentral - - - Central color &roles - - - - unnamed - - - 11 - - - 6 - - - - - comboCentral - - - Choose central color role - - - <b>Select a color role.</b><p>Available central roles are: <ul> <li>Window - general background color.</li> <li>WindowText - general foreground color. </li> <li>Base - used as background color for e.g. text entry widgets, usually white or another light color. </li> <li>Text - the foreground color used with Base. Usually this is the same as WindowText, in what case it must provide good contrast both with Window and Base. </li> <li>Button - general button background color, where buttons need a background different from Window, as in the Macintosh style. </li> <li>ButtonText - a foreground color used with the Button color. </li> <li>Highlight - a color to indicate a selected or highlighted item. </li> <li>HighlightedText - a text color that contrasts to Highlight. </li> <li>BrightText - a text color that is very different from WindowText and contrasts well with e.g. black. </li> </ul> </p> - - - - Window - - - - - WindowText - - - - - Button - - - - - Base - - - - - Text - - - - - BrightText - - - - - ButtonText - - - - - Highlight - - - - - HighlightedText - - - - - - - - unnamed - - - 0 - - - 6 - - - - - - 20 - 20 - - - - Expanding - - - Horizontal - - - - - - - labelCentral - - - - 1 - 1 - 0 - 0 - - - - - 0 - 0 - - - - &Select Color: - - - buttonCentral - - - - - - - buttonCentral - - - - 0 - 0 - 0 - 0 - - - - Qt::TabFocus - - - Choose a color - - - Choose a color for the selected central color role. - - - - - - - - - - - - groupEffect - - - 3-D shadow &effects - - - - unnamed - - - 11 - - - 6 - - - - - unnamed - - - 0 - - - 6 - - - - - checkBuildEffect - - - Build &from button color - - - true - - - Generate shadings - - - Check to let 3D-effect colors be calculated from button-color. - - - - - - - comboEffect - - - Choose 3D-effect color role - - - <b>Select a color role.</b><p>Available effect roles are: <ul> <li>Light - lighter than Button color. </li> <li>Midlight - between Button and Light. </li> <li>Mid - between Button and Dark. </li> <li>Dark - darker than Button. </li> <li>Shadow - a very dark color. </li> </ul> - - - - Light - - - - - Midlight - - - - - Mid - - - - - Dark - - - - - Shadow - - - - - - - - - - unnamed - - - 0 - - - 6 - - - - - - 20 - 20 - - - - Expanding - - - Horizontal - - - - - - - labelEffect - - - - 1 - 1 - 0 - 0 - - - - - 0 - 0 - - - - Select Co&lor: - - - buttonEffect - - - - - - - buttonEffect - - - - 0 - 0 - 0 - 0 - - - - Qt::TabFocus - - - Choose a color - - - Choose a color for the selected effect color role. - - - - - - - - - - - - unnamed - - - 0 - - - 6 - - - - - - 20 - 20 - - - - Expanding - - - Horizontal - - - - - - - buttonOk - - - OK - - - true - - - true - - - Close dialog and apply all changes. - - - - - - - buttonCancel - - - Cancel - - - true - - - Close dialog and discard all changes. - - - - - - - - - - - ColorButton - -
colorbutton.h
- - 40 - 25 - - 0 - - 5 - 5 - - image0 - - color - pixmap - -
-
- - buttonOk - buttonCancel - paletteCombo - checkBuildInactive - checkBuildDisabled - comboCentral - buttonCentral - checkBuildEffect - comboEffect - buttonEffect - - - - 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 - - -
diff --git a/tools/qtconfig/qtconfig.pro b/tools/qtconfig/qtconfig.pro index b0f2563..f4ddebe 100644 --- a/tools/qtconfig/qtconfig.pro +++ b/tools/qtconfig/qtconfig.pro @@ -14,11 +14,11 @@ contains(QT_CONFIG, phonon) { DEFINES += HAVE_PHONON } SOURCES += colorbutton.cpp main.cpp previewframe.cpp previewwidget.cpp mainwindow.cpp paletteeditoradvanced.cpp \ - mainwindowbase.cpp paletteeditoradvancedbase.cpp + mainwindowbase.cpp HEADERS += colorbutton.h previewframe.h previewwidget.h mainwindow.h paletteeditoradvanced.h \ - mainwindowbase.h paletteeditoradvancedbase.h + mainwindowbase.h -FORMS = mainwindowbase.ui paletteeditoradvancedbase.ui previewwidget.ui +FORMS = mainwindowbase.ui paletteeditoradvanced.ui previewwidget.ui RESOURCES = qtconfig.qrc PROJECTNAME = Qt Configuration -- cgit v0.12 From 5999b2ac29c1a144d5edda8e6916bd05bbc4727e Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:33 +0200 Subject: Refactored the MainWindow in qtconfig qtconfig can now be fully build without qt3support module. Removed some legacy and unused code, changed one of labels on widget to reflect the real meaning of configuration parameter. Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/mainwindow.cpp | 451 ++++------ tools/qtconfig/mainwindow.h | 13 +- tools/qtconfig/mainwindow.ui | 1377 +++++++++++++++++++++++++++++ tools/qtconfig/mainwindowbase.cpp | 250 ------ tools/qtconfig/mainwindowbase.h | 95 -- tools/qtconfig/mainwindowbase.ui | 1384 ------------------------------ tools/qtconfig/paletteeditoradvanced.cpp | 1 - tools/qtconfig/qtconfig.pro | 8 +- 8 files changed, 1559 insertions(+), 2020 deletions(-) create mode 100644 tools/qtconfig/mainwindow.ui delete mode 100644 tools/qtconfig/mainwindowbase.cpp delete mode 100644 tools/qtconfig/mainwindowbase.h delete mode 100644 tools/qtconfig/mainwindowbase.ui diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 3895418..81d7813 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -59,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -154,36 +153,20 @@ static const char *phonon_text = "

It is reccommended to leave all settings on \"Auto\" to let " "Phonon determine your settings automatically."; -static QColorGroup::ColorRole centralFromItem( int item ) -{ - switch( item ) { - case 0: return QColorGroup::Window; - case 1: return QColorGroup::WindowText; - case 2: return QColorGroup::Button; - case 3: return QColorGroup::Base; - case 4: return QColorGroup::Text; - case 5: return QColorGroup::BrightText; - case 6: return QColorGroup::ButtonText; - case 7: return QColorGroup::Highlight; - case 8: return QColorGroup::HighlightedText; - default: return QColorGroup::NColorRoles; - } -} - -static QColorGroup::ColorRole effectFromItem( int item ) +QPalette::ColorGroup MainWindow::groupFromIndex(int item) { switch( item ) { - case 0: return QColorGroup::Light; - case 1: return QColorGroup::Midlight; - case 2: return QColorGroup::Mid; - case 3: return QColorGroup::Dark; - case 4: return QColorGroup::Shadow; - default: return QColorGroup::NColorRoles; + case 0: + default: + return QPalette::Active; + case 1: + return QPalette::Inactive; + case 2: + return QPalette::Disabled; } } - static void setStyleHelper(QWidget *w, QStyle *s) { const QObjectList children = w->children(); @@ -197,9 +180,52 @@ static void setStyleHelper(QWidget *w, QStyle *s) MainWindow::MainWindow() - : MainWindowBase(0, "main window"), - editPalette(palette()), previewPalette(palette()), previewstyle(0) -{ + : QMainWindow(), editPalette(palette()), previewPalette(palette()), previewstyle(0) +{ + setupUi(this); + statusBar(); + + // signals and slots connections + connect(fontpathlineedit, SIGNAL(returnPressed()), SLOT(addFontpath())); + connect(PushButton15, SIGNAL(clicked()), SLOT(addFontpath())); + connect(PushButton1, SIGNAL(clicked()), SLOT(addSubstitute())); + connect(PushButton14, SIGNAL(clicked()), SLOT(browseFontpath())); + connect(stylecombo, SIGNAL(activated(int)), SLOT(buildFont())); + connect(psizecombo, SIGNAL(activated(int)), SLOT(buildFont())); + connect(PushButton12, SIGNAL(clicked()), SLOT(downFontpath())); + connect(PushButton3, SIGNAL(clicked()), SLOT(downSubstitute())); + connect(familycombo, SIGNAL(activated(QString)), SLOT(familySelected(QString))); + connect(fileExitAction, SIGNAL(activated()), SLOT(fileExit())); + connect(fileSaveAction, SIGNAL(activated()), SLOT(fileSave())); + connect(helpAboutAction, SIGNAL(activated()), SLOT(helpAbout())); + connect(helpAboutQtAction, SIGNAL(activated()), SLOT(helpAboutQt())); + connect(TabWidget3, SIGNAL(currentChanged(QWidget*)), SLOT(pageChanged(QWidget*))); + connect(paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); + connect(PushButton13, SIGNAL(clicked()), SLOT(removeFontpath())); + connect(PushButton4, SIGNAL(clicked()), SLOT(removeSubstitute())); + connect(toolboxeffect, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(dcispin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(cfispin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(wslspin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(menueffect, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(comboeffect, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(audiosinkCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(videomodeCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(tooltipeffect, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(strutwidth, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(strutheight, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(effectcheckbox, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(resolvelinks, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(fontembeddingcheckbox, SIGNAL(clicked()), SLOT(somethingModified())); + connect(rtlExtensions, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(inputStyle, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(inputMethod, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(gstylecombo, SIGNAL(activated(QString)), SLOT(styleSelected(QString))); + connect(familysubcombo, SIGNAL(activated(QString)), SLOT(substituteSelected(QString))); + connect(btnAdvanced, SIGNAL(clicked()), SLOT(tunePalette())); + connect(PushButton11, SIGNAL(clicked()), SLOT(upFontpath())); + connect(PushButton2, SIGNAL(clicked()), SLOT(upSubstitute())); + modified = true; desktopThemeName = tr("Desktop Settings (Default)"); QStringList gstyles = QStyleFactory::keys(); @@ -207,31 +233,31 @@ MainWindow::MainWindow() gstylecombo->addItem(desktopThemeName); gstylecombo->setItemData(gstylecombo->findText(desktopThemeName), tr("Choose style and palette based on your desktop settings."), Qt::ToolTipRole); - gstylecombo->insertStringList(gstyles); + gstylecombo->addItems(gstyles); QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QString currentstyle = settings.value(QLatin1String("style")).toString(); if (currentstyle.isEmpty()) { - gstylecombo->setCurrentItem(gstylecombo->findText(desktopThemeName)); - currentstyle = QLatin1String(QApplication::style()->name()); + gstylecombo->setCurrentIndex(gstylecombo->findText(desktopThemeName)); + currentstyle = QApplication::style()->objectName(); } else { int index = gstylecombo->findText(currentstyle, Qt::MatchFixedString); if (index != -1) { - gstylecombo->setCurrentItem(index); + gstylecombo->setCurrentIndex(index); } else { // we give up - gstylecombo->insertItem(QLatin1String("Unknown")); - gstylecombo->setCurrentItem(gstylecombo->count() - 1); + gstylecombo->addItem(QLatin1String("Unknown")); + gstylecombo->setCurrentIndex(gstylecombo->count() - 1); } } buttonMainColor->setColor(palette().color(QPalette::Active, - QColorGroup::Button)); - buttonMainColor2->setColor(palette().color(QPalette::Active, - QColorGroup::Window)); + QPalette::Button)); + buttonWindowColor->setColor(palette().color(QPalette::Active, + QPalette::Window)); connect(buttonMainColor, SIGNAL(colorChanged(QColor)), this, SLOT(buildPalette())); - connect(buttonMainColor2, SIGNAL(colorChanged(QColor)), + connect(buttonWindowColor, SIGNAL(colorChanged(QColor)), this, SLOT(buildPalette())); if (X11->desktopEnvironment == DE_KDE) @@ -241,7 +267,7 @@ MainWindow::MainWindow() QFontDatabase db; QStringList families = db.families(); - familycombo->insertStringList(families); + familycombo->addItems(families); QStringList fs = families; QStringList fs2 = QFont::substitutions(); @@ -252,13 +278,12 @@ MainWindow::MainWindow() fsit++; } fs.sort(); - familysubcombo->insertStringList(fs); + familysubcombo->addItems(fs); - choosesubcombo->insertStringList(families); - Q3ValueList sizes = db.standardSizes(); - Q3ValueList::Iterator it = sizes.begin(); - while (it != sizes.end()) - psizecombo->insertItem(QString::number(*it++)); + choosesubcombo->addItems(families); + QList sizes = db.standardSizes(); + foreach(int i, sizes) + psizecombo->addItem(QString::number(i)); dcispin->setValue(QApplication::doubleClickInterval()); cfispin->setValue(QApplication::cursorFlashTime()); @@ -270,20 +295,20 @@ MainWindow::MainWindow() effectbase->setEnabled(effectcheckbox->isChecked()); if (QApplication::isEffectEnabled(Qt::UI_FadeMenu)) - menueffect->setCurrentItem(2); + menueffect->setCurrentIndex(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) - menueffect->setCurrentItem(1); + menueffect->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo)) - comboeffect->setCurrentItem(1); + comboeffect->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)) - tooltipeffect->setCurrentItem(2); + tooltipeffect->setCurrentIndex(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)) - tooltipeffect->setCurrentItem(1); + tooltipeffect->setCurrentIndex(1); if ( QApplication::isEffectEnabled( Qt::UI_AnimateToolBox ) ) - toolboxeffect->setCurrentItem( 1 ); + toolboxeffect->setCurrentIndex( 1 ); QSize globalStrut = QApplication::globalStrut(); strutwidth->setValue(globalStrut.width()); @@ -306,10 +331,10 @@ MainWindow::MainWindow() if (i == -1) // no clue about the current font i = 0; - familycombo->setCurrentItem(i); + familycombo->setCurrentIndex(i); QStringList styles = db.styles(familycombo->currentText()); - stylecombo->insertStringList(styles); + stylecombo->addItems(styles); QString stylestring = db.styleString(QApplication::font()); sit = styles.begin(); @@ -328,29 +353,31 @@ MainWindow::MainWindow() i = possible; if (i == -1) // no clue about the current font i = 0; - stylecombo->setCurrentItem(i); + stylecombo->setCurrentIndex(i); i = 0; for (int psize = QApplication::font().pointSize(); i < psizecombo->count(); ++i) { - const int sz = psizecombo->text(i).toInt(); + const int sz = psizecombo->itemText(i).toInt(); if (sz == psize) { - psizecombo->setCurrentItem(i); + psizecombo->setCurrentIndex(i); break; } else if(sz > psize) { psizecombo->insertItem(i, QString::number(psize)); - psizecombo->setCurrentItem(i); + psizecombo->setCurrentIndex(i); break; } } QStringList subs = QFont::substitutes(familysubcombo->currentText()); sublistbox->clear(); - sublistbox->insertStringList(subs); + sublistbox->insertItems(0, subs); rtlExtensions->setChecked(settings.value(QLatin1String("useRtlExtensions"), false).toBool()); #ifdef Q_WS_X11 - inputStyle->setCurrentText(settings.value(QLatin1String("XIMInputStyle"), trUtf8("On The Spot")).toString()); + QString settingsInputStyle = settings.value(QLatin1String("XIMInputStyle")).toString(); + if (!settingsInputStyle.isEmpty()) + inputStyle->setCurrentIndex(inputStyle->findText(settingsInputStyle)); #else inputStyle->hide(); inputStyleLabel->hide(); @@ -381,7 +408,7 @@ MainWindow::MainWindow() fontembeddingcheckbox->setChecked(settings.value(QLatin1String("embedFonts"), true).toBool()); fontpaths = settings.value(QLatin1String("fontPath")).toStringList(); - fontpathlistbox->insertStringList(fontpaths); + fontpathlistbox->insertItems(0, fontpaths); audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); audiosinkCombo->setItemData(audiosinkCombo->findText(tr("Auto (default)")), @@ -397,9 +424,9 @@ MainWindow::MainWindow() gchar *versionString = gst_version_string(); gstversionLabel->setText(QLatin1String(versionString)); g_free(versionString); - GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); + GList *factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); QString name, klass, description; - for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { + for (GList *iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); klass = QLatin1String(gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature))); if (klass == QLatin1String("Sink/Audio")) { @@ -439,8 +466,8 @@ MainWindow::MainWindow() QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); - audiosinkCombo->setCurrentItem(audiosinkCombo->findData(audioSink)); - videomodeCombo->setCurrentItem(videomodeCombo->findData(videoMode)); + audiosinkCombo->setCurrentIndex(audiosinkCombo->findData(audioSink)); + videomodeCombo->setCurrentIndex(videomodeCombo->findData(videoMode)); settings.endGroup(); // Qt @@ -480,15 +507,15 @@ void MainWindow::fileSave() bool overrideDesktopSettings = (gstylecombo->currentText() != desktopThemeName); if (overrideDesktopSettings) { int i; - for (i = 0; i < QColorGroup::NColorRoles; i++) + for (i = 0; i < QPalette::NColorRoles; i++) actcg << editPalette.color(QPalette::Active, - (QColorGroup::ColorRole) i).name(); - for (i = 0; i < QColorGroup::NColorRoles; i++) + (QPalette::ColorRole) i).name(); + for (i = 0; i < QPalette::NColorRoles; i++) inactcg << editPalette.color(QPalette::Inactive, - (QColorGroup::ColorRole) i).name(); - for (i = 0; i < QColorGroup::NColorRoles; i++) + (QPalette::ColorRole) i).name(); + for (i = 0; i < QPalette::NColorRoles; i++) discg << editPalette.color(QPalette::Disabled, - (QColorGroup::ColorRole) i).name(); + (QPalette::ColorRole) i).name(); } settings.setValue(QLatin1String("font"), font.toString()); @@ -535,21 +562,21 @@ void MainWindow::fileSave() if (effectcheckbox->isChecked()) { effects << QLatin1String("general"); - switch (menueffect->currentItem()) { + switch (menueffect->currentIndex()) { case 1: effects << QLatin1String("animatemenu"); break; case 2: effects << QLatin1String("fademenu"); break; } - switch (comboeffect->currentItem()) { + switch (comboeffect->currentIndex()) { case 1: effects << QLatin1String("animatecombo"); break; } - switch (tooltipeffect->currentItem()) { + switch (tooltipeffect->currentIndex()) { case 1: effects << QLatin1String("animatetooltip"); break; case 2: effects << QLatin1String("fadetooltip"); break; } - switch ( toolboxeffect->currentItem() ) { + switch ( toolboxeffect->currentIndex() ) { case 1: effects << QLatin1String("animatetoolbox"); break; } } else @@ -595,149 +622,28 @@ void MainWindow::setModified(bool m) void MainWindow::buildPalette() { - int i; - QColorGroup cg; - QColor btn = buttonMainColor->color(); - QColor back = buttonMainColor2->color(); - QPalette automake( btn, back ); - - for (i = 0; i<9; i++) - cg.setColor( centralFromItem(i), automake.active().color( centralFromItem(i) ) ); - - editPalette.setActive( cg ); - buildActiveEffect(); - - cg = editPalette.inactive(); - - QPalette temp( editPalette.active().color( QColorGroup::Button ), - editPalette.active().color( QColorGroup::Window ) ); + QPalette temp(buttonMainColor->color(), buttonWindowColor->color()); + for (int i = 0; icurrentIndex()); - switch (paletteCombo->currentItem()) { - case 0: - default: - cg = pal.active(); - break; - case 1: - cg = pal.inactive(); - break; - case 2: - cg = pal.disabled(); - break; + for (int i = 0; isetPreviewPalette(previewPalette); } @@ -745,16 +651,17 @@ void MainWindow::setPreviewPalette( const QPalette& pal ) void MainWindow::updateColorButtons() { - buttonMainColor->setColor( editPalette.active().color( QColorGroup::Button )); - buttonMainColor2->setColor( editPalette.active().color( QColorGroup::Window )); + buttonMainColor->setColor( editPalette.color( QPalette::Active, QPalette::Button )); + buttonWindowColor->setColor( editPalette.color( QPalette::Active, QPalette::Window )); } void MainWindow::tunePalette() { bool ok; - QPalette pal = PaletteEditorAdvanced::getPalette(&ok, editPalette, backgroundRole(), this); - if (!ok) + QPalette pal = PaletteEditorAdvanced::getPalette(&ok, editPalette, + backgroundRole(), this); + if (! ok) return; editPalette = pal; @@ -799,8 +706,8 @@ void MainWindow::familySelected(const QString &family) QFontDatabase db; QStringList styles = db.styles(family); stylecombo->clear(); - stylecombo->insertStringList(styles); - familysubcombo->insertItem(family); + stylecombo->addItems(styles); + familysubcombo->addItem(family); buildFont(); } @@ -820,24 +727,23 @@ void MainWindow::substituteSelected(const QString &family) { QStringList subs = QFont::substitutes(family); sublistbox->clear(); - sublistbox->insertStringList(subs); + sublistbox->insertItems(0, subs); } void MainWindow::removeSubstitute() { - if (sublistbox->currentItem() < 0 || - uint(sublistbox->currentItem()) > sublistbox->count()) + if (!sublistbox->currentItem()) return; - int item = sublistbox->currentItem(); + int row = sublistbox->currentRow(); QStringList subs = QFont::substitutes(familysubcombo->currentText()); - subs.removeAt(sublistbox->currentItem()); + subs.removeAt(sublistbox->currentRow()); sublistbox->clear(); - sublistbox->insertStringList(subs); - if (uint(item) > sublistbox->count()) - item = int(sublistbox->count()) - 1; - sublistbox->setCurrentItem(item); + sublistbox->insertItems(0, subs); + if (row > sublistbox->count()) + row = sublistbox->count() - 1; + sublistbox->setCurrentRow(row); QFont::removeSubstitution(familysubcombo->currentText()); QFont::insertSubstitutions(familysubcombo->currentText(), subs); setModified(true); @@ -846,40 +752,38 @@ void MainWindow::removeSubstitute() void MainWindow::addSubstitute() { - if (sublistbox->currentItem() < 0 || - uint(sublistbox->currentItem()) > sublistbox->count()) { + if (!sublistbox->currentItem()) { QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); QStringList subs = QFont::substitutes(familysubcombo->currentText()); sublistbox->clear(); - sublistbox->insertStringList(subs); + sublistbox->insertItems(0, subs); setModified(true); return; } - int item = sublistbox->currentItem(); + int row = sublistbox->currentRow(); QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); QStringList subs = QFont::substitutes(familysubcombo->currentText()); sublistbox->clear(); - sublistbox->insertStringList(subs); - sublistbox->setCurrentItem(item); + sublistbox->insertItems(0, subs); + sublistbox->setCurrentRow(row); setModified(true); } void MainWindow::downSubstitute() { - if (sublistbox->currentItem() < 0 || - uint(sublistbox->currentItem()) >= sublistbox->count()) + if (!sublistbox->currentItem() || sublistbox->currentRow() >= sublistbox->count()) return; - int item = sublistbox->currentItem(); + int row = sublistbox->currentRow(); QStringList subs = QFont::substitutes(familysubcombo->currentText()); - QString fam = subs.at(item); - subs.removeAt(item); - subs.insert(item+1, fam); + QString fam = subs.at(row); + subs.removeAt(row); + subs.insert(row + 1, fam); sublistbox->clear(); - sublistbox->insertStringList(subs); - sublistbox->setCurrentItem(item + 1); + sublistbox->insertItems(0, subs); + sublistbox->setCurrentRow(row + 1); QFont::removeSubstitution(familysubcombo->currentText()); QFont::insertSubstitutions(familysubcombo->currentText(), subs); setModified(true); @@ -888,17 +792,17 @@ void MainWindow::downSubstitute() void MainWindow::upSubstitute() { - if (sublistbox->currentItem() < 1) + if (!sublistbox->currentItem() || sublistbox->currentRow() < 1) return; - int item = sublistbox->currentItem(); + int row = sublistbox->currentRow(); QStringList subs = QFont::substitutes(familysubcombo->currentText()); - QString fam = subs.at(item); - subs.removeAt(item); - subs.insert(item-1, fam); + QString fam = subs.at(row); + subs.removeAt(row); + subs.insert(row-1, fam); sublistbox->clear(); - sublistbox->insertStringList(subs); - sublistbox->setCurrentItem(item - 1); + sublistbox->insertItems(0, subs); + sublistbox->setCurrentRow(row - 1); QFont::removeSubstitution(familysubcombo->currentText()); QFont::insertSubstitutions(familysubcombo->currentText(), subs); setModified(true); @@ -907,17 +811,16 @@ void MainWindow::upSubstitute() void MainWindow::removeFontpath() { - if (fontpathlistbox->currentItem() < 0 || - uint(fontpathlistbox->currentItem()) > fontpathlistbox->count()) + if (!fontpathlistbox->currentItem()) return; - int item = fontpathlistbox->currentItem(); - fontpaths.removeAt(fontpathlistbox->currentItem()); + int row = fontpathlistbox->currentRow(); + fontpaths.removeAt(row); fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); - if (uint(item) > fontpathlistbox->count()) - item = int(fontpathlistbox->count()) - 1; - fontpathlistbox->setCurrentItem(item); + fontpathlistbox->insertItems(0, fontpaths); + if (row > fontpathlistbox->count()) + row = fontpathlistbox->count() - 1; + fontpathlistbox->setCurrentRow(row); setModified(true); } @@ -927,63 +830,59 @@ void MainWindow::addFontpath() if (fontpathlineedit->text().isEmpty()) return; - if (fontpathlistbox->currentItem() < 0 || - uint(fontpathlistbox->currentItem()) > fontpathlistbox->count()) { + if (!fontpathlistbox->currentItem()) { fontpaths.append(fontpathlineedit->text()); fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); + fontpathlistbox->insertItems(0, fontpaths); setModified(true); return; } - int item = fontpathlistbox->currentItem(); - fontpaths.insert(fontpathlistbox->currentItem()+1, - fontpathlineedit->text()); + int row = fontpathlistbox->currentRow(); + fontpaths.insert(row + 1, fontpathlineedit->text()); fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); - fontpathlistbox->setCurrentItem(item); + fontpathlistbox->insertItems(0, fontpaths); + fontpathlistbox->setCurrentRow(row); setModified(true); } void MainWindow::downFontpath() { - if (fontpathlistbox->currentItem() < 0 || - uint(fontpathlistbox->currentItem()) >= fontpathlistbox->count() - 1) + if (!fontpathlistbox->currentItem() || fontpathlistbox->currentRow() >= fontpathlistbox->count() - 1) return; - int item = fontpathlistbox->currentItem(); - QString fam = fontpaths.at(item); - fontpaths.removeAt(item); - fontpaths.insert(item+1, fam); + int row = fontpathlistbox->currentRow(); + QString fam = fontpaths.at(row); + fontpaths.removeAt(row); + fontpaths.insert(row + 1, fam); fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); - fontpathlistbox->setCurrentItem(item + 1); + fontpathlistbox->insertItems(0, fontpaths); + fontpathlistbox->setCurrentRow(row + 1); setModified(true); } void MainWindow::upFontpath() { - if (fontpathlistbox->currentItem() < 1) + if (!fontpathlistbox->currentItem() || fontpathlistbox->currentRow() < 1) return; - int item = fontpathlistbox->currentItem(); - QString fam = fontpaths.at(item); - fontpaths.removeAt(item); - fontpaths.insert(item-1, fam); + int row = fontpathlistbox->currentRow(); + QString fam = fontpaths.at(row); + fontpaths.removeAt(row); + fontpaths.insert(row - 1, fam); fontpathlistbox->clear(); - fontpathlistbox->insertStringList(fontpaths); - fontpathlistbox->setCurrentItem(item - 1); + fontpathlistbox->insertItems(0, fontpaths); + fontpathlistbox->setCurrentRow(row - 1); setModified(true); } void MainWindow::browseFontpath() { - QString dirname = QFileDialog::getExistingDirectory(QString(), this, 0, - tr("Select a Directory")); + QString dirname = QFileDialog::getExistingDirectory(this, tr("Select a Directory")); if (dirname.isNull()) return; @@ -1002,7 +901,7 @@ void MainWindow::helpAbout() QMessageBox box(this); box.setText(tr("

%1

" "
Version %2" - "

Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).") + "

Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).") .arg(tr("Qt Configuration")).arg(QLatin1String(QT_VERSION_STR))); box.setWindowTitle(tr("Qt Configuration")); box.setIcon(QMessageBox::NoIcon); diff --git a/tools/qtconfig/mainwindow.h b/tools/qtconfig/mainwindow.h index 9bc8068..76e3691 100644 --- a/tools/qtconfig/mainwindow.h +++ b/tools/qtconfig/mainwindow.h @@ -42,11 +42,11 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include "mainwindowbase.h" +#include "ui_mainwindow.h" QT_BEGIN_NAMESPACE -class MainWindow : public MainWindowBase +class MainWindow : public QMainWindow, public Ui::MainWindow { Q_OBJECT @@ -83,17 +83,12 @@ public slots: private: - void buildActive(); - void buildActiveEffect(); - void buildInactive(); - void buildInactiveEffect(); - void buildDisabled(); - void buildDisabledEffect(); - void updateColorButtons(); void updateFontSample(); void updateStyleLayout(); + static QPalette::ColorGroup groupFromIndex(int); + void setPreviewPalette(const QPalette &); void setModified(bool); diff --git a/tools/qtconfig/mainwindow.ui b/tools/qtconfig/mainwindow.ui new file mode 100644 index 0000000..117a777 --- /dev/null +++ b/tools/qtconfig/mainwindow.ui @@ -0,0 +1,1377 @@ + + + ********************************************************************* +** +** 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 tools applications 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$ +** +********************************************************************* + MainWindow + + + + 0 + 0 + 815 + 716 + + + + Qt Configuration + + + + + 8 + + + + + + 200 + 0 + + + + true + + + + + + + 0 + + + + Appearance + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + GUI Style + + + + 4 + + + 8 + + + + + + 0 + 0 + + + + Select GUI &Style: + + + gstylecombo + + + + + + + + + + + + + + 0 + 0 + + + + Preview + + + + + + Select &Palette: + + + paletteCombo + + + + + + + + Active Palette + + + + + Inactive Palette + + + + + Disabled Palette + + + + + + + + + 0 + 0 + + + + + 410 + 260 + + + + + + + + + + + + 0 + 0 + + + + + 400 + 0 + + + + Build Palette + + + + + + + 0 + + + + + &Button Background: + + + buttonMainColor + + + + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + 1 + + + 0 + + + Window Back&ground: + + + Qt::AlignVCenter + + + 0 + + + buttonWindowColor + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 70 + 20 + + + + + + + + &Tune Palette... + + + + + + + + + + Please use the KDE Control Center to set the palette. + + + + + + + + + + + Fonts + + + + + + Default Font + + + + 8 + + + 4 + + + + + true + + + false + + + + + + + true + + + false + + + + + + + true + + + true + + + false + + + + + + + &Style: + + + stylecombo + + + + + + + &Point Size: + + + psizecombo + + + + + + + F&amily: + + + familycombo + + + + + + + Sample Text + + + Qt::AlignHCenter + + + + + + + + + + Font Substitution + + + + 4 + + + 8 + + + + + 4 + + + 0 + + + + + S&elect or Enter a Family: + + + familysubcombo + + + + + + + true + + + true + + + false + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + Qt::Horizontal + + + + + + + Current Substitutions: + + + + + + + + + + 4 + + + 0 + + + + + Up + + + + + + + Down + + + + + + + Remove + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + Qt::Horizontal + + + + + + + 4 + + + 0 + + + + + Select s&ubstitute Family: + + + choosesubcombo + + + + + + + true + + + false + + + + + + + Add + + + + + + + + + + + + + Interface + + + + + + Feel Settings + + + + 8 + + + 4 + + + + + ms + + + 10 + + + 10000 + + + + + + + &Double Click Interval: + + + dcispin + + + + + + + No blinking + + + ms + + + 9 + + + 10000 + + + + + + + &Cursor Flash Time: + + + cfispin + + + + + + + lines + + + 1 + + + 20 + + + + + + + Wheel &Scroll Lines: + + + wslspin + + + + + + + Resolve symlinks in URLs + + + + + + + + + + GUI Effects + + + + 4 + + + 8 + + + + + &Enable + + + Alt+E + + + + + + + + 4 + + + + + &Menu Effect: + + + menueffect + + + + + + + C&omboBox Effect: + + + comboeffect + + + + + + + &ToolTip Effect: + + + tooltipeffect + + + + + + + Tool&Box Effect: + + + toolboxeffect + + + + + + + 0 + + + true + + + + Disable + + + + + Animate + + + + + Fade + + + + + + + + + Disable + + + + + Animate + + + + + + + + + Disable + + + + + Animate + + + + + Fade + + + + + + + + + Disable + + + + + Animate + + + + + + + + + + + + + + Global Strut + + + + 8 + + + 4 + + + + + Minimum &Width: + + + strutwidth + + + + + + + Minimum Hei&ght: + + + strutheight + + + + + + + pixels + + + 1000 + + + + + + + pixels + + + 1000 + + + + + + + + + + Enhanced support for languages written right-to-left + + + + + + + XIM Input Style: + + + + + + + 0 + + + + On The Spot + + + + + Over The Spot + + + + + Off The Spot + + + + + Root + + + + + + + + Default Input Method: + + + + + + + -1 + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + + Printer + + + + + + Enable Font embedding + + + true + + + + + + + + 0 + 0 + + + + Font Paths + + + + 4 + + + 8 + + + + + 0 + + + 4 + + + + + Up + + + + + + + Remove + + + + + + + Down + + + + + + + + + + + + 0 + + + 4 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 20 + 20 + + + + + + + + Add + + + + + + + Browse... + + + + + + + Press the <b>Browse</b> button or enter a directory and press Enter to add them to the list. + + + + + + + + + + + + + + + + Phonon + + + + + + About Phonon + + + + + + Current Version: + + + + + + + Not available + + + + + + + Website: + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://phonon.kde.org"><span style=" text-decoration: underline; color:#0000ff;">http://phonon.kde.org</span></a></p></body></html> + + + true + + + + + + + + + + About GStreamer + + + + + + Current Version: + + + + + + + Not available + + + + + + + Website: + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://gstreamer.freedesktop.org/"><span style=" text-decoration: underline; color:#0000ff;">http://gstreamer.freedesktop.org/</span></a></p></body></html> + + + true + + + + + + + + + + GStreamer backend settings + + + + + + Preferred audio sink: + + + audiosinkCombo + + + + + + + + + + Preferred render method: + + + videomodeCombo + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Note: changes to these settings may prevent applications from starting up correctly.</span></p></body></html> + + + Qt::RichText + + + false + + + true + + + 2 + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + 0 + 0 + 815 + 19 + + + + + + 203 + 114 + 161 + 110 + + + + &File + + + + + + + + + 234 + 115 + 161 + 106 + + + + &Help + + + + + + + + + + + &Save + + + Save + + + Ctrl+S + + + + + E&xit + + + Exit + + + Ctrl+Q + + + + + &About + + + About + + + + + + + + About &Qt + + + About Qt + + + + + + ColorButton + +
colorbutton.h
+
+ + PreviewFrame + +
previewframe.h
+
+
+ + helpview + familycombo + stylecombo + psizecombo + samplelineedit + familysubcombo + PushButton2 + PushButton3 + PushButton4 + choosesubcombo + PushButton1 + dcispin + cfispin + wslspin + effectcheckbox + menueffect + comboeffect + tooltipeffect + strutwidth + strutheight + sublistbox + + + + + effectcheckbox + toggled(bool) + effectbase + setEnabled(bool) + + + 417 + 257 + + + 578 + 379 + + + + + fontembeddingcheckbox + toggled(bool) + GroupBox10 + setEnabled(bool) + + + 449 + 69 + + + 447 + 94 + + + + +
diff --git a/tools/qtconfig/mainwindowbase.cpp b/tools/qtconfig/mainwindowbase.cpp deleted file mode 100644 index 2460bca..0000000 --- a/tools/qtconfig/mainwindowbase.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/**************************************************************************** -** -** 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 tools applications 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 "mainwindowbase.h" -#include "colorbutton.h" -#include "previewframe.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -/* - * Constructs a MainWindowBase as a child of 'parent', with the - * name 'name' and widget flags set to 'f'. - * - */ -MainWindowBase::MainWindowBase(QWidget* parent, const char* name, Qt::WindowFlags fl) - : Q3MainWindow(parent, name, fl) -{ - setupUi(this); - - (void)statusBar(); - - // signals and slots connections - connect(fontpathlineedit, SIGNAL(returnPressed()), this, SLOT(addFontpath())); - connect(PushButton15, SIGNAL(clicked()), this, SLOT(addFontpath())); - connect(PushButton1, SIGNAL(clicked()), this, SLOT(addSubstitute())); - connect(PushButton14, SIGNAL(clicked()), this, SLOT(browseFontpath())); - connect(stylecombo, SIGNAL(activated(int)), this, SLOT(buildFont())); - connect(psizecombo, SIGNAL(activated(int)), this, SLOT(buildFont())); - connect(PushButton12, SIGNAL(clicked()), this, SLOT(downFontpath())); - connect(PushButton3, SIGNAL(clicked()), this, SLOT(downSubstitute())); - connect(familycombo, SIGNAL(activated(QString)), this, SLOT(familySelected(QString))); - connect(fileExitAction, SIGNAL(activated()), this, SLOT(fileExit())); - connect(fileSaveAction, SIGNAL(activated()), this, SLOT(fileSave())); - connect(helpAboutAction, SIGNAL(activated()), this, SLOT(helpAbout())); - connect(helpAboutQtAction, SIGNAL(activated()), this, SLOT(helpAboutQt())); - connect(TabWidget3, SIGNAL(currentChanged(QWidget*)), this, SLOT(pageChanged(QWidget*))); - connect(paletteCombo, SIGNAL(activated(int)), this, SLOT(paletteSelected(int))); - connect(PushButton13, SIGNAL(clicked()), this, SLOT(removeFontpath())); - connect(PushButton4, SIGNAL(clicked()), this, SLOT(removeSubstitute())); - connect(effectcheckbox, SIGNAL(toggled(bool)), effectbase, SLOT(setEnabled(bool))); - connect(fontembeddingcheckbox, SIGNAL(toggled(bool)), GroupBox10, SLOT(setEnabled(bool))); - connect(toolboxeffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(dcispin, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(cfispin, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(wslspin, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(menueffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(comboeffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(audiosinkCombo, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(videomodeCombo, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(tooltipeffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(strutwidth, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(strutheight, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); - connect(effectcheckbox, SIGNAL(toggled(bool)), this, SLOT(somethingModified())); - connect(resolvelinks, SIGNAL(toggled(bool)), this, SLOT(somethingModified())); - connect(fontembeddingcheckbox, SIGNAL(clicked()), this, SLOT(somethingModified())); - connect(rtlExtensions, SIGNAL(toggled(bool)), this, SLOT(somethingModified())); - connect(inputStyle, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(inputMethod, SIGNAL(activated(int)), this, SLOT(somethingModified())); - connect(gstylecombo, SIGNAL(activated(QString)), this, SLOT(styleSelected(QString))); - connect(familysubcombo, SIGNAL(activated(QString)), this, SLOT(substituteSelected(QString))); - connect(btnAdvanced, SIGNAL(clicked()), this, SLOT(tunePalette())); - connect(PushButton11, SIGNAL(clicked()), this, SLOT(upFontpath())); - connect(PushButton2, SIGNAL(clicked()), this, SLOT(upSubstitute())); - init(); -} - -/* - * Destroys the object and frees any allocated resources - */ -MainWindowBase::~MainWindowBase() -{ - destroy(); - // no need to delete child widgets, Qt does it all for us -} - -/* - * Sets the strings of the subwidgets using the current - * language. - */ -void MainWindowBase::languageChange() -{ - retranslateUi(this); -} - -void MainWindowBase::init() -{ -} - -void MainWindowBase::destroy() -{ -} - -void MainWindowBase::addFontpath() -{ - qWarning("MainWindowBase::addFontpath(): Not implemented yet"); -} - -void MainWindowBase::addSubstitute() -{ - qWarning("MainWindowBase::addSubstitute(): Not implemented yet"); -} - -void MainWindowBase::browseFontpath() -{ - qWarning("MainWindowBase::browseFontpath(): Not implemented yet"); -} - -void MainWindowBase::buildFont() -{ - qWarning("MainWindowBase::buildFont(): Not implemented yet"); -} - -void MainWindowBase::buildPalette() -{ - qWarning("MainWindowBase::buildPalette(): Not implemented yet"); -} - -void MainWindowBase::downFontpath() -{ - qWarning("MainWindowBase::downFontpath(): Not implemented yet"); -} - -void MainWindowBase::downSubstitute() -{ - qWarning("MainWindowBase::downSubstitute(): Not implemented yet"); -} - -void MainWindowBase::familySelected( const QString &) -{ - qWarning("MainWindowBase::familySelected( const QString &): Not implemented yet"); -} - -void MainWindowBase::fileExit() -{ - qWarning("MainWindowBase::fileExit(): Not implemented yet"); -} - -void MainWindowBase::fileSave() -{ - qWarning("MainWindowBase::fileSave(): Not implemented yet"); -} - -void MainWindowBase::helpAbout() -{ - qWarning("MainWindowBase::helpAbout(): Not implemented yet"); -} - -void MainWindowBase::helpAboutQt() -{ - qWarning("MainWindowBase::helpAboutQt(): Not implemented yet"); -} - -void MainWindowBase::new_slot() -{ - qWarning("MainWindowBase::new_slot(): Not implemented yet"); -} - -void MainWindowBase::pageChanged( QWidget *) -{ - qWarning("MainWindowBase::pageChanged( QWidget *): Not implemented yet"); -} - -void MainWindowBase::paletteSelected(int) -{ - qWarning("MainWindowBase::paletteSelected(int): Not implemented yet"); -} - -void MainWindowBase::removeFontpath() -{ - qWarning("MainWindowBase::removeFontpath(): Not implemented yet"); -} - -void MainWindowBase::removeSubstitute() -{ - qWarning("MainWindowBase::removeSubstitute(): Not implemented yet"); -} - -void MainWindowBase::somethingModified() -{ - qWarning("MainWindowBase::somethingModified(): Not implemented yet"); -} - -void MainWindowBase::styleSelected( const QString &) -{ - qWarning("MainWindowBase::styleSelected( const QString &): Not implemented yet"); -} - -void MainWindowBase::substituteSelected( const QString &) -{ - qWarning("MainWindowBase::substituteSelected( const QString &): Not implemented yet"); -} - -void MainWindowBase::tunePalette() -{ - qWarning("MainWindowBase::tunePalette(): Not implemented yet"); -} - -void MainWindowBase::upFontpath() -{ - qWarning("MainWindowBase::upFontpath(): Not implemented yet"); -} - -void MainWindowBase::upSubstitute() -{ - qWarning("MainWindowBase::upSubstitute(): Not implemented yet"); -} - -QT_END_NAMESPACE diff --git a/tools/qtconfig/mainwindowbase.h b/tools/qtconfig/mainwindowbase.h deleted file mode 100644 index 1e1dabf..0000000 --- a/tools/qtconfig/mainwindowbase.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** 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 tools applications 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 MAINWINDOWBASE_H -#define MAINWINDOWBASE_H - -#include "ui_mainwindowbase.h" -#include - -QT_BEGIN_NAMESPACE - -class ColorButton; -class PreviewFrame; - -class MainWindowBase : public Q3MainWindow, public Ui::MainWindowBase -{ - Q_OBJECT - -public: - MainWindowBase(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::Window); - ~MainWindowBase(); - -public slots: - virtual void addFontpath(); - virtual void addSubstitute(); - virtual void browseFontpath(); - virtual void buildFont(); - virtual void buildPalette(); - virtual void downFontpath(); - virtual void downSubstitute(); - virtual void familySelected( const QString & ); - virtual void fileExit(); - virtual void fileSave(); - virtual void helpAbout(); - virtual void helpAboutQt(); - virtual void new_slot(); - virtual void pageChanged( QWidget * ); - virtual void paletteSelected( int ); - virtual void removeFontpath(); - virtual void removeSubstitute(); - virtual void somethingModified(); - virtual void styleSelected( const QString & ); - virtual void substituteSelected( const QString & ); - virtual void tunePalette(); - virtual void upFontpath(); - virtual void upSubstitute(); - -protected slots: - virtual void languageChange(); - - virtual void init(); - virtual void destroy(); -}; - -QT_END_NAMESPACE - -#endif // MAINWINDOWBASE_H diff --git a/tools/qtconfig/mainwindowbase.ui b/tools/qtconfig/mainwindowbase.ui deleted file mode 100644 index b09abd0..0000000 --- a/tools/qtconfig/mainwindowbase.ui +++ /dev/null @@ -1,1384 +0,0 @@ - - - ********************************************************************* -** -** 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 tools applications 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$ -** -********************************************************************* - MainWindowBase - - - - 0 - 0 - 815 - 716 - - - - Qt Configuration - - - - - 0 - 26 - 815 - 690 - - - - - 8 - - - - - - 200 - 0 - - - - true - - - - - - - 0 - - - - Appearance - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - GUI Style - - - - 4 - - - 8 - - - - - - 0 - 0 - - - - Select GUI &Style: - - - gstylecombo - - - - - - - - - - - - - - 0 - 0 - - - - Preview - - - - - - Select &Palette: - - - paletteCombo - - - - - - - - Active Palette - - - - - Inactive Palette - - - - - Disabled Palette - - - - - - - - - 0 - 0 - - - - - 410 - 260 - - - - - - - - - - - - 0 - 0 - - - - - 400 - 0 - - - - Build Palette - - - - - - - 0 - - - - - &3-D Effects: - - - buttonMainColor - - - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - 1 - - - 0 - - - Window Back&ground: - - - Qt::AlignVCenter - - - 0 - - - buttonMainColor2 - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 70 - 20 - - - - - - - - &Tune Palette... - - - - - - - - - - Please use the KDE Control Center to set the palette. - - - - - - - - - - - Fonts - - - - - - Default Font - - - - 8 - - - 4 - - - - - true - - - false - - - - - - - true - - - false - - - - - - - true - - - true - - - false - - - - - - - &Style: - - - stylecombo - - - - - - - &Point Size: - - - psizecombo - - - - - - - F&amily: - - - familycombo - - - - - - - Sample Text - - - Qt::AlignHCenter - - - - - - - - - - Font Substitution - - - - 4 - - - 8 - - - - - 4 - - - 0 - - - - - S&elect or Enter a Family: - - - familysubcombo - - - - - - - true - - - true - - - false - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - Qt::Horizontal - - - - - - - Current Substitutions: - - - - - - - - - - 4 - - - 0 - - - - - Up - - - - - - - Down - - - - - - - Remove - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - Qt::Horizontal - - - - - - - 4 - - - 0 - - - - - Select s&ubstitute Family: - - - choosesubcombo - - - - - - - true - - - false - - - - - - - Add - - - - - - - - - - - - - Interface - - - - - - Feel Settings - - - - 8 - - - 4 - - - - - ms - - - 10 - - - 10000 - - - - - - - &Double Click Interval: - - - dcispin - - - - - - - No blinking - - - ms - - - 9 - - - 10000 - - - - - - - &Cursor Flash Time: - - - cfispin - - - - - - - lines - - - 1 - - - 20 - - - - - - - Wheel &Scroll Lines: - - - wslspin - - - - - - - Resolve symlinks in URLs - - - - - - - - - - GUI Effects - - - - 4 - - - 8 - - - - - &Enable - - - Alt+E - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 - - - 4 - - - - - &Menu Effect: - - - menueffect - - - - - - - C&omboBox Effect: - - - comboeffect - - - - - - - &ToolTip Effect: - - - tooltipeffect - - - - - - - Tool&Box Effect: - - - toolboxeffect - - - - - - - 0 - - - true - - - - Disable - - - - - Animate - - - - - Fade - - - - - - - - - Disable - - - - - Animate - - - - - - - - - Disable - - - - - Animate - - - - - Fade - - - - - - - - - Disable - - - - - Animate - - - - - - - - - - - - - - Global Strut - - - - 8 - - - 4 - - - - - Minimum &Width: - - - strutwidth - - - - - - - Minimum Hei&ght: - - - strutheight - - - - - - - pixels - - - 1000 - - - - - - - pixels - - - 1000 - - - - - - - - - - Enhanced support for languages written right-to-left - - - - - - - XIM Input Style: - - - - - - - 0 - - - - On The Spot - - - - - Over The Spot - - - - - Off The Spot - - - - - Root - - - - - - - - Default Input Method: - - - - - - - -1 - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - - Printer - - - - - - Enable Font embedding - - - true - - - - - - - - 0 - 0 - - - - Font Paths - - - - 4 - - - 8 - - - - - 0 - - - 4 - - - - - Up - - - - - - - Remove - - - - - - - Down - - - - - - - - - - - - 0 - - - 4 - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 20 - 20 - - - - - - - - Add - - - - - - - Browse... - - - - - - - Press the <b>Browse</b> button or enter a directory and press Enter to add them to the list. - - - - - - - - - - - - - - - - Phonon - - - - - - About Phonon - - - - - - Current Version: - - - - - - - Not available - - - - - - - Website: - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://phonon.kde.org"><span style=" text-decoration: underline; color:#0000ff;">http://phonon.kde.org</span></a></p></body></html> - - - true - - - - - - - - - - About GStreamer - - - - - - Current Version: - - - - - - - Not available - - - - - - - Website: - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://gstreamer.freedesktop.org/"><span style=" text-decoration: underline; color:#0000ff;">http://gstreamer.freedesktop.org/</span></a></p></body></html> - - - true - - - - - - - - - - GStreamer backend settings - - - - - - Preferred audio sink: - - - audiosinkCombo - - - - - - - - - - Preferred render method: - - - videomodeCombo - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Note: changes to these settings may prevent applications from starting up correctly.</span></p></body></html> - - - Qt::RichText - - - false - - - true - - - 2 - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - 0 - 0 - 815 - 26 - - - - - - 0 - 0 - 123 - 92 - - - - &File - - - - - - - - - - - - 0 - 0 - 123 - 90 - - - - &Help - - - - - - - - - - - - - - &Save - - - Save - - - Ctrl+S - - - - - E&xit - - - Exit - - - - - - - - &About - - - About - - - - - - - - About &Qt - - - About Qt - - - - - - Q3Frame - QFrame -
Qt3Support/Q3Frame
- 1 -
- - Q3MainWindow - QWidget -
q3mainwindow.h
- 1 -
- - Q3ListBox - Q3Frame -
q3listbox.h
-
- - ColorButton - -
colorbutton.h
-
- - PreviewFrame - -
previewframe.h
-
-
- - helpview - familycombo - stylecombo - psizecombo - samplelineedit - familysubcombo - PushButton2 - PushButton3 - PushButton4 - choosesubcombo - PushButton1 - dcispin - cfispin - wslspin - effectcheckbox - menueffect - comboeffect - tooltipeffect - strutwidth - strutheight - sublistbox - - - -
diff --git a/tools/qtconfig/paletteeditoradvanced.cpp b/tools/qtconfig/paletteeditoradvanced.cpp index fa108e7..e757d00 100644 --- a/tools/qtconfig/paletteeditoradvanced.cpp +++ b/tools/qtconfig/paletteeditoradvanced.cpp @@ -182,7 +182,6 @@ QPalette::ColorGroup PaletteEditorAdvanced::groupFromIndex(int item) } } - QPalette::ColorRole PaletteEditorAdvanced::centralFromIndex(int item) { switch( item ) { diff --git a/tools/qtconfig/qtconfig.pro b/tools/qtconfig/qtconfig.pro index f4ddebe..4cfc944 100644 --- a/tools/qtconfig/qtconfig.pro +++ b/tools/qtconfig/qtconfig.pro @@ -13,12 +13,10 @@ contains(QT_CONFIG, phonon) { QT += phonon DEFINES += HAVE_PHONON } -SOURCES += colorbutton.cpp main.cpp previewframe.cpp previewwidget.cpp mainwindow.cpp paletteeditoradvanced.cpp \ - mainwindowbase.cpp -HEADERS += colorbutton.h previewframe.h previewwidget.h mainwindow.h paletteeditoradvanced.h \ - mainwindowbase.h +SOURCES += colorbutton.cpp main.cpp previewframe.cpp previewwidget.cpp mainwindow.cpp paletteeditoradvanced.cpp +HEADERS += colorbutton.h previewframe.h previewwidget.h mainwindow.h paletteeditoradvanced.h -FORMS = mainwindowbase.ui paletteeditoradvanced.ui previewwidget.ui +FORMS = mainwindow.ui paletteeditoradvanced.ui previewwidget.ui RESOURCES = qtconfig.qrc PROJECTNAME = Qt Configuration -- cgit v0.12 From 5c87763ffa0ec38443c14f8870294e340edd4db1 Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:34 +0200 Subject: Fixed some code style issues in qtconfig Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/mainwindow.cpp | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 81d7813..12024e7 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -178,7 +178,6 @@ static void setStyleHelper(QWidget *w, QStyle *s) w->setStyle(s); } - MainWindow::MainWindow() : QMainWindow(), editPalette(palette()), previewPalette(palette()), previewstyle(0) { @@ -477,7 +476,6 @@ MainWindow::MainWindow() updateStyleLayout(); } - MainWindow::~MainWindow() { } @@ -603,13 +601,11 @@ void MainWindow::fileSave() statusBar()->showMessage(QLatin1String("Saved changes.")); } - void MainWindow::fileExit() { qApp->closeAllWindows(); } - void MainWindow::setModified(bool m) { if (modified == m) @@ -619,7 +615,6 @@ void MainWindow::setModified(bool m) fileSaveAction->setEnabled(m); } - void MainWindow::buildPalette() { QPalette temp(buttonMainColor->color(), buttonWindowColor->color()); @@ -648,14 +643,12 @@ void MainWindow::setPreviewPalette( const QPalette& pal ) previewFrame->setPreviewPalette(previewPalette); } - void MainWindow::updateColorButtons() { buttonMainColor->setColor( editPalette.color( QPalette::Active, QPalette::Button )); buttonWindowColor->setColor( editPalette.color( QPalette::Active, QPalette::Window )); } - void MainWindow::tunePalette() { bool ok; @@ -669,7 +662,6 @@ void MainWindow::tunePalette() setModified(true); } - void MainWindow::paletteSelected(int) { setPreviewPalette(editPalette); @@ -700,7 +692,6 @@ void MainWindow::styleSelected(const QString &stylename) updateStyleLayout(); } - void MainWindow::familySelected(const QString &family) { QFontDatabase db; @@ -711,7 +702,6 @@ void MainWindow::familySelected(const QString &family) buildFont(); } - void MainWindow::buildFont() { QFontDatabase db; @@ -722,7 +712,6 @@ void MainWindow::buildFont() setModified(true); } - void MainWindow::substituteSelected(const QString &family) { QStringList subs = QFont::substitutes(family); @@ -730,7 +719,6 @@ void MainWindow::substituteSelected(const QString &family) sublistbox->insertItems(0, subs); } - void MainWindow::removeSubstitute() { if (!sublistbox->currentItem()) @@ -749,7 +737,6 @@ void MainWindow::removeSubstitute() setModified(true); } - void MainWindow::addSubstitute() { if (!sublistbox->currentItem()) { @@ -770,7 +757,6 @@ void MainWindow::addSubstitute() setModified(true); } - void MainWindow::downSubstitute() { if (!sublistbox->currentItem() || sublistbox->currentRow() >= sublistbox->count()) @@ -789,7 +775,6 @@ void MainWindow::downSubstitute() setModified(true); } - void MainWindow::upSubstitute() { if (!sublistbox->currentItem() || sublistbox->currentRow() < 1) @@ -808,7 +793,6 @@ void MainWindow::upSubstitute() setModified(true); } - void MainWindow::removeFontpath() { if (!fontpathlistbox->currentItem()) @@ -824,7 +808,6 @@ void MainWindow::removeFontpath() setModified(true); } - void MainWindow::addFontpath() { if (fontpathlineedit->text().isEmpty()) @@ -847,11 +830,12 @@ void MainWindow::addFontpath() setModified(true); } - void MainWindow::downFontpath() { - if (!fontpathlistbox->currentItem() || fontpathlistbox->currentRow() >= fontpathlistbox->count() - 1) + if (!fontpathlistbox->currentItem() + || fontpathlistbox->currentRow() >= (fontpathlistbox->count() - 1)) { return; + } int row = fontpathlistbox->currentRow(); QString fam = fontpaths.at(row); @@ -863,7 +847,6 @@ void MainWindow::downFontpath() setModified(true); } - void MainWindow::upFontpath() { if (!fontpathlistbox->currentItem() || fontpathlistbox->currentRow() < 1) @@ -879,7 +862,6 @@ void MainWindow::upFontpath() setModified(true); } - void MainWindow::browseFontpath() { QString dirname = QFileDialog::getExistingDirectory(this, tr("Select a Directory")); @@ -889,13 +871,11 @@ void MainWindow::browseFontpath() fontpathlineedit->setText(dirname); } - void MainWindow::somethingModified() { setModified(true); } - void MainWindow::helpAbout() { QMessageBox box(this); @@ -908,13 +888,11 @@ void MainWindow::helpAbout() box.exec(); } - void MainWindow::helpAboutQt() { QMessageBox::aboutQt(this, tr("Qt Configuration")); } - void MainWindow::pageChanged(QWidget *page) { if (page == tab) @@ -929,7 +907,6 @@ void MainWindow::pageChanged(QWidget *page) helpview->setText(tr(phonon_text)); } - void MainWindow::closeEvent(QCloseEvent *e) { if (modified) { -- cgit v0.12 From 27fa758a28943698749a0608039efd88574da5e5 Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:34 +0200 Subject: Modified previewwidget's ui file in qtconfig The modification is needed to prevent ui compilation time warnings. Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/previewwidget.ui | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/qtconfig/previewwidget.ui b/tools/qtconfig/previewwidget.ui index 12de30d..9d86a1f 100644 --- a/tools/qtconfig/previewwidget.ui +++ b/tools/qtconfig/previewwidget.ui @@ -1,6 +1,6 @@ - ********************************************************************* + ********************************************************************* ** ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. @@ -67,7 +67,7 @@ 11 - + 6 @@ -75,7 +75,7 @@ 0 - + 6 @@ -87,7 +87,7 @@ GroupBox - + 6 @@ -126,7 +126,7 @@ GroupBox2 - + 6 @@ -163,7 +163,7 @@ - + 6 @@ -187,7 +187,7 @@ - + 6 -- cgit v0.12 From 31ea34d217e28f83cf868c76a998d61a846385e6 Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:35 +0200 Subject: Finally removed the qtconfig dependency from qt3support Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/qtconfig.pro | 1 - tools/tools.pro | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/qtconfig/qtconfig.pro b/tools/qtconfig/qtconfig.pro index 4cfc944..a066d4e 100644 --- a/tools/qtconfig/qtconfig.pro +++ b/tools/qtconfig/qtconfig.pro @@ -5,7 +5,6 @@ build_all:!build_pass { CONFIG += release } LANGUAGE = C++ -QT += qt3support contains(QT_CONFIG, gstreamer):LIBS += $$QT_LIBS_GSTREAMER -lgstinterfaces-0.10 -lgstvideo-0.10 -lgstbase-0.10 contains(QT_CONFIG, gstreamer):QMAKE_CXXFLAGS += $$QT_CFLAGS_GSTREAMER diff --git a/tools/tools.pro b/tools/tools.pro index 8f23fe4..c64fe25 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -20,7 +20,7 @@ TEMPLATE = subdirs SUBDIRS += designer } } - unix:!mac:!embedded:contains(QT_CONFIG, qt3support):SUBDIRS += qtconfig + unix:!mac:!embedded:SUBDIRS += qtconfig win32:!wince*:SUBDIRS += activeqt } contains(QT_CONFIG, declarative):SUBDIRS += qml -- cgit v0.12 From 55f7ab61482cbfdf93ab25e409649ecea9bcdb0e Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:36 +0200 Subject: Resolved some code style issues and fixed the broken copyright year Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/mainwindow.cpp | 51 ++++++++++++++++---------------- tools/qtconfig/paletteeditoradvanced.cpp | 14 ++++----- tools/qtconfig/paletteeditoradvanced.h | 6 ++-- tools/qtconfig/previewframe.cpp | 4 +-- tools/qtconfig/previewwidget.cpp | 4 +-- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 12024e7..fd083c1 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -156,7 +156,7 @@ static const char *phonon_text = QPalette::ColorGroup MainWindow::groupFromIndex(int item) { - switch( item ) { + switch (item) { case 0: default: return QPalette::Active; @@ -272,7 +272,7 @@ MainWindow::MainWindow() QStringList fs2 = QFont::substitutions(); QStringList::Iterator fsit = fs2.begin(); while (fsit != fs2.end()) { - if (! fs.contains(*fsit)) + if (!fs.contains(*fsit)) fs += *fsit; fsit++; } @@ -306,8 +306,8 @@ MainWindow::MainWindow() else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)) tooltipeffect->setCurrentIndex(1); - if ( QApplication::isEffectEnabled( Qt::UI_AnimateToolBox ) ) - toolboxeffect->setCurrentIndex( 1 ); + if (QApplication::isEffectEnabled(Qt::UI_AnimateToolBox)) + toolboxeffect->setCurrentIndex(1); QSize globalStrut = QApplication::globalStrut(); strutwidth->setValue(globalStrut.width()); @@ -526,7 +526,7 @@ void MainWindow::fileSave() settings.setValue(QLatin1String("style"), overrideDesktopSettings ? gstylecombo->currentText() : QString()); settings.setValue(QLatin1String("doubleClickInterval"), dcispin->value()); - settings.setValue(QLatin1String("cursorFlashTime"), cfispin->value() == 9 ? 0 : cfispin->value() ); + settings.setValue(QLatin1String("cursorFlashTime"), cfispin->value() == 9 ? 0 : cfispin->value()); settings.setValue(QLatin1String("wheelScrollLines"), wslspin->value()); settings.setValue(QLatin1String("resolveSymlinks"), resolvelinks->isChecked()); @@ -539,13 +539,13 @@ void MainWindow::fileSave() #ifdef Q_WS_X11 QString style = inputStyle->currentText(); QString str = QLatin1String("On The Spot"); - if ( style == trUtf8( "Over The Spot" ) ) + if (style == trUtf8("Over The Spot")) str = QLatin1String("Over The Spot"); - else if ( style == trUtf8( "Off The Spot" ) ) + else if (style == trUtf8("Off The Spot")) str = QLatin1String("Off The Spot"); - else if ( style == trUtf8( "Root" ) ) + else if (style == trUtf8("Root")) str = QLatin1String("Root"); - settings.setValue( QLatin1String("XIMInputStyle"), str ); + settings.setValue(QLatin1String("XIMInputStyle"), str); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) settings.setValue(QLatin1String("DefaultInputMethod"), inputMethod->currentText()); @@ -574,7 +574,7 @@ void MainWindow::fileSave() case 2: effects << QLatin1String("fadetooltip"); break; } - switch ( toolboxeffect->currentIndex() ) { + switch (toolboxeffect->currentIndex()) { case 1: effects << QLatin1String("animatetoolbox"); break; } } else @@ -618,8 +618,8 @@ void MainWindow::setModified(bool m) void MainWindow::buildPalette() { QPalette temp(buttonMainColor->color(), buttonWindowColor->color()); - for (int i = 0; icurrentIndex()); - for (int i = 0; isetColor( editPalette.color( QPalette::Active, QPalette::Button )); - buttonWindowColor->setColor( editPalette.color( QPalette::Active, QPalette::Window )); + buttonMainColor->setColor(editPalette.color(QPalette::Active, QPalette::Button)); + buttonWindowColor->setColor(editPalette.color(QPalette::Active, QPalette::Window)); } void MainWindow::tunePalette() @@ -654,7 +654,7 @@ void MainWindow::tunePalette() bool ok; QPalette pal = PaletteEditorAdvanced::getPalette(&ok, editPalette, backgroundRole(), this); - if (! ok) + if (!ok) return; editPalette = pal; @@ -881,7 +881,7 @@ void MainWindow::helpAbout() QMessageBox box(this); box.setText(tr("

%1

" "
Version %2" - "

Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).") + "

Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).") .arg(tr("Qt Configuration")).arg(QLatin1String(QT_VERSION_STR))); box.setWindowTitle(tr("Qt Configuration")); box.setIcon(QMessageBox::NoIcon); @@ -910,19 +910,20 @@ void MainWindow::pageChanged(QWidget *page) void MainWindow::closeEvent(QCloseEvent *e) { if (modified) { - switch(QMessageBox::warning(this, tr("Save Changes"), - tr("Save changes to settings?"), - tr("&Yes"), tr("&No"), tr("&Cancel"), 0, 2)) { - case 0: // save + switch (QMessageBox::warning(this, tr("Save Changes"), + tr("Save changes to settings?"), + (QMessageBox::Yes | QMessageBox::No + | QMessageBox::Cancel))) { + case QMessageBox::Yes: // save qApp->processEvents(); fileSave(); // fall through intended - case 1: // don't save + case QMessageBox::No: // don't save e->accept(); break; - case 2: // cancel + case QMessageBox::Cancel: // cancel e->ignore(); break; diff --git a/tools/qtconfig/paletteeditoradvanced.cpp b/tools/qtconfig/paletteeditoradvanced.cpp index e757d00..b285c8c 100644 --- a/tools/qtconfig/paletteeditoradvanced.cpp +++ b/tools/qtconfig/paletteeditoradvanced.cpp @@ -83,7 +83,7 @@ PaletteEditorAdvanced::~PaletteEditorAdvanced() { } -void PaletteEditorAdvanced::onToggleBuildInactive( bool v ) +void PaletteEditorAdvanced::onToggleBuildInactive(bool v) { if (selectedPalette == 1) { groupCentral->setDisabled(v); @@ -171,7 +171,7 @@ void PaletteEditorAdvanced::onToggleBuildEffects(bool on) QPalette::ColorGroup PaletteEditorAdvanced::groupFromIndex(int item) { - switch( item ) { + switch (item) { case 0: default: return QPalette::Active; @@ -184,7 +184,7 @@ QPalette::ColorGroup PaletteEditorAdvanced::groupFromIndex(int item) QPalette::ColorRole PaletteEditorAdvanced::centralFromIndex(int item) { - switch( item ) { + switch (item) { case 0: return QPalette::Window; case 1: @@ -220,7 +220,7 @@ QPalette::ColorRole PaletteEditorAdvanced::centralFromIndex(int item) QPalette::ColorRole PaletteEditorAdvanced::effectFromIndex(int item) { - switch( item ) { + switch (item) { case 0: return QPalette::Light; case 1: @@ -327,7 +327,7 @@ void PaletteEditorAdvanced::setupBackgroundRole(QPalette::ColorRole role) { int initRole = 0; - switch(role) { + switch (role) { case QPalette::Window: initRole = 0; break; @@ -385,8 +385,8 @@ QPalette PaletteEditorAdvanced::getPalette(bool *ok, const QPalette &init, PaletteEditorAdvanced *dlg = new PaletteEditorAdvanced(parent); dlg->setupBackgroundRole(backgroundRole); - if ( init != QPalette() ) - dlg->setPal( init ); + if (init != QPalette()) + dlg->setPal(init); int resultCode = dlg->exec(); QPalette result = init; diff --git a/tools/qtconfig/paletteeditoradvanced.h b/tools/qtconfig/paletteeditoradvanced.h index f70648b..9dc4657 100644 --- a/tools/qtconfig/paletteeditoradvanced.h +++ b/tools/qtconfig/paletteeditoradvanced.h @@ -55,9 +55,9 @@ public: PaletteEditorAdvanced(QWidget *parent = 0); ~PaletteEditorAdvanced(); - static QPalette getPalette( bool *ok, const QPalette &pal, - QPalette::ColorRole backgroundRole = QPalette::Window, - QWidget *parent = 0 ); + static QPalette getPalette(bool *ok, const QPalette &pal, + QPalette::ColorRole backgroundRole = QPalette::Window, + QWidget *parent = 0); static QPalette buildEffect(QPalette::ColorGroup colorGroup, const QPalette &basePalette); diff --git a/tools/qtconfig/previewframe.cpp b/tools/qtconfig/previewframe.cpp index 95d64cf..d08b770 100644 --- a/tools/qtconfig/previewframe.cpp +++ b/tools/qtconfig/previewframe.cpp @@ -82,7 +82,7 @@ void PreviewFrame::setPreviewVisible(bool visible) workspace->viewport()->update(); } -Workspace::Workspace(PreviewFrame* parent) +Workspace::Workspace(PreviewFrame *parent) : QMdiArea(parent) { previewFrame = parent; @@ -92,7 +92,7 @@ Workspace::Workspace(PreviewFrame* parent) frame->show(); } -void Workspace::paintEvent( QPaintEvent* ) +void Workspace::paintEvent(QPaintEvent *) { QPainter p(viewport()); p.fillRect(rect(), palette().color(backgroundRole()).dark()); diff --git a/tools/qtconfig/previewwidget.cpp b/tools/qtconfig/previewwidget.cpp index abbf669..4a4a580 100644 --- a/tools/qtconfig/previewwidget.cpp +++ b/tools/qtconfig/previewwidget.cpp @@ -50,7 +50,7 @@ PreviewWidget::PreviewWidget(QWidget *parent) setupUi(this); // install event filter on child widgets - QList l = findChildren(); + QList l = findChildren(); foreach(QWidget *w, l) { w->installEventFilter(this); w->setFocusPolicy(Qt::NoFocus); @@ -66,7 +66,7 @@ void PreviewWidget::closeEvent(QCloseEvent *e) bool PreviewWidget::eventFilter(QObject *, QEvent *e) { - switch ( e->type() ) { + switch (e->type()) { case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: -- cgit v0.12 From 0bcad9bd0d8c98807babe6ae3de2ef54dfbf7c22 Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:37 +0200 Subject: Replaced the unnecessary include with declaration Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/previewframe.cpp | 1 + tools/qtconfig/previewframe.h | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/qtconfig/previewframe.cpp b/tools/qtconfig/previewframe.cpp index d08b770..f37ac78 100644 --- a/tools/qtconfig/previewframe.cpp +++ b/tools/qtconfig/previewframe.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "previewframe.h" +#include "previewwidget.h" #include #include diff --git a/tools/qtconfig/previewframe.h b/tools/qtconfig/previewframe.h index b21e529..41c5030 100644 --- a/tools/qtconfig/previewframe.h +++ b/tools/qtconfig/previewframe.h @@ -42,8 +42,6 @@ #ifndef PREVIEWFRAME_H #define PREVIEWFRAME_H -#include "previewwidget.h" - #include QT_BEGIN_NAMESPACE @@ -63,6 +61,7 @@ private: PreviewFrame *previewFrame; }; +class PreviewWidget; class PreviewFrame : public QFrame { Q_OBJECT -- cgit v0.12 From 5aeda02c1b34ee0534390872f2ae400baab7baed Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:38 +0200 Subject: Removed the inheritance from ui file in qtconfig's PaletteEditorAdvanced Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/paletteeditoradvanced.cpp | 73 ++++++++++++++++---------------- tools/qtconfig/paletteeditoradvanced.h | 10 ++++- 2 files changed, 45 insertions(+), 38 deletions(-) diff --git a/tools/qtconfig/paletteeditoradvanced.cpp b/tools/qtconfig/paletteeditoradvanced.cpp index b285c8c..196cdea 100644 --- a/tools/qtconfig/paletteeditoradvanced.cpp +++ b/tools/qtconfig/paletteeditoradvanced.cpp @@ -38,41 +38,41 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - +#include "ui_paletteeditoradvanced.h" #include "paletteeditoradvanced.h" #include "colorbutton.h" QT_BEGIN_NAMESPACE PaletteEditorAdvanced::PaletteEditorAdvanced(QWidget *parent) - : QDialog(parent), selectedPalette(0) + : QDialog(parent), ui(new Ui::PaletteEditorAdvanced), selectedPalette(0) { - setupUi(this); + ui->setupUi(this); // create a ColorButton's - buttonCentral = new ColorButton(groupCentral); + buttonCentral = new ColorButton(ui->groupCentral); buttonCentral->setToolTip(tr("Choose a color")); buttonCentral->setWhatsThis(tr("Choose a color for the selected central color role.")); - layoutCentral->addWidget(buttonCentral); - labelCentral->setBuddy(buttonCentral); + ui->layoutCentral->addWidget(buttonCentral); + ui->labelCentral->setBuddy(buttonCentral); - buttonEffect = new ColorButton(groupEffect); + buttonEffect = new ColorButton(ui->groupEffect); buttonEffect->setToolTip(tr("Choose a color")); buttonEffect->setWhatsThis(tr("Choose a color for the selected effect color role.")); buttonEffect->setEnabled(false); - layoutEffect->addWidget(buttonEffect); - labelEffect->setBuddy(buttonEffect); + ui->layoutEffect->addWidget(buttonEffect); + ui->labelEffect->setBuddy(buttonEffect); // signals and slots connections - connect(paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); - connect(comboCentral, SIGNAL(activated(int)), SLOT(onCentral(int))); + connect(ui->paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); + connect(ui->comboCentral, SIGNAL(activated(int)), SLOT(onCentral(int))); connect(buttonCentral, SIGNAL(clicked()), SLOT(onChooseCentralColor())); connect(buttonEffect, SIGNAL(clicked()), SLOT(onChooseEffectColor())); - connect(comboEffect, SIGNAL(activated(int)), SLOT(onEffect(int))); - connect(checkBuildEffect, SIGNAL(toggled(bool)), SLOT(onToggleBuildEffects(bool))); - connect(checkBuildEffect, SIGNAL(toggled(bool)), buttonEffect, SLOT(setDisabled(bool))); - connect(checkBuildInactive, SIGNAL(toggled(bool)), SLOT(onToggleBuildInactive(bool))); - connect(checkBuildDisabled, SIGNAL(toggled(bool)), SLOT(onToggleBuildDisabled(bool))); + connect(ui->comboEffect, SIGNAL(activated(int)), SLOT(onEffect(int))); + connect(ui->checkBuildEffect, SIGNAL(toggled(bool)), SLOT(onToggleBuildEffects(bool))); + connect(ui->checkBuildEffect, SIGNAL(toggled(bool)), buttonEffect, SLOT(setDisabled(bool))); + connect(ui->checkBuildInactive, SIGNAL(toggled(bool)), SLOT(onToggleBuildInactive(bool))); + connect(ui->checkBuildDisabled, SIGNAL(toggled(bool)), SLOT(onToggleBuildDisabled(bool))); onToggleBuildEffects(true); @@ -81,13 +81,14 @@ PaletteEditorAdvanced::PaletteEditorAdvanced(QWidget *parent) PaletteEditorAdvanced::~PaletteEditorAdvanced() { + delete ui; } void PaletteEditorAdvanced::onToggleBuildInactive(bool v) { if (selectedPalette == 1) { - groupCentral->setDisabled(v); - groupEffect->setDisabled(v); + ui->groupCentral->setDisabled(v); + ui->groupEffect->setDisabled(v); } if (v) { @@ -99,8 +100,8 @@ void PaletteEditorAdvanced::onToggleBuildInactive(bool v) void PaletteEditorAdvanced::onToggleBuildDisabled(bool v) { if (selectedPalette == 2) { - groupCentral->setDisabled(v); - groupEffect->setDisabled(v); + ui->groupCentral->setDisabled(v); + ui->groupEffect->setDisabled(v); } if (v) { @@ -114,16 +115,16 @@ void PaletteEditorAdvanced::paletteSelected(int p) selectedPalette = p; if(p == 1) { // inactive - groupCentral->setDisabled(checkBuildInactive->isChecked()); - groupEffect->setDisabled(checkBuildInactive->isChecked()); + ui->groupCentral->setDisabled(ui->checkBuildInactive->isChecked()); + ui->groupEffect->setDisabled(ui->checkBuildInactive->isChecked()); } else if (p == 2) { // disabled - groupCentral->setDisabled(checkBuildDisabled->isChecked()); - groupEffect->setDisabled(checkBuildDisabled->isChecked()); + ui->groupCentral->setDisabled(ui->checkBuildDisabled->isChecked()); + ui->groupEffect->setDisabled(ui->checkBuildDisabled->isChecked()); } else { - groupCentral->setEnabled(true); - groupEffect->setEnabled(true); + ui->groupCentral->setEnabled(true); + ui->groupEffect->setEnabled(true); } updateColorButtons(); } @@ -131,14 +132,14 @@ void PaletteEditorAdvanced::paletteSelected(int p) void PaletteEditorAdvanced::onChooseCentralColor() { QPalette::ColorGroup group = groupFromIndex(selectedPalette); - editPalette.setColor(group, centralFromIndex(comboCentral->currentIndex()), + editPalette.setColor(group, centralFromIndex(ui->comboCentral->currentIndex()), buttonCentral->color()); buildEffect(group); if (group == QPalette::Active) { - if(checkBuildInactive->isChecked()) + if(ui->checkBuildInactive->isChecked()) build(QPalette::Inactive); - if(checkBuildDisabled->isChecked()) + if(ui->checkBuildDisabled->isChecked()) build(QPalette::Disabled); } @@ -148,13 +149,13 @@ void PaletteEditorAdvanced::onChooseCentralColor() void PaletteEditorAdvanced::onChooseEffectColor() { QPalette::ColorGroup group = groupFromIndex(selectedPalette); - editPalette.setColor(group, effectFromIndex(comboEffect->currentIndex()), + editPalette.setColor(group, effectFromIndex(ui->comboEffect->currentIndex()), buttonEffect->color()); if (group == QPalette::Active) { - if(checkBuildInactive->isChecked()) + if(ui->checkBuildInactive->isChecked()) build(QPalette::Inactive); - if(checkBuildDisabled->isChecked()) + if(ui->checkBuildDisabled->isChecked()) build(QPalette::Disabled); } @@ -296,7 +297,7 @@ void PaletteEditorAdvanced::build(QPalette::ColorGroup colorGroup) editPalette.setColor(colorGroup, QPalette::HighlightedText, Qt::darkGray); } - if (checkBuildEffect->isChecked()) + if (ui->checkBuildEffect->isChecked()) buildEffect(colorGroup); else updateColorButtons(); @@ -307,9 +308,9 @@ void PaletteEditorAdvanced::updateColorButtons() { QPalette::ColorGroup colorGroup = groupFromIndex(selectedPalette); buttonCentral->setColor(editPalette.color(colorGroup, - centralFromIndex(comboCentral->currentIndex()))); + centralFromIndex(ui->comboCentral->currentIndex()))); buttonEffect->setColor(editPalette.color(colorGroup, - effectFromIndex(comboEffect->currentIndex()))); + effectFromIndex(ui->comboEffect->currentIndex()))); } void PaletteEditorAdvanced::setPal(const QPalette &pal) @@ -376,7 +377,7 @@ void PaletteEditorAdvanced::setupBackgroundRole(QPalette::ColorRole role) } if (initRole != -1) - comboCentral->setCurrentIndex(initRole); + ui->comboCentral->setCurrentIndex(initRole); } QPalette PaletteEditorAdvanced::getPalette(bool *ok, const QPalette &init, diff --git a/tools/qtconfig/paletteeditoradvanced.h b/tools/qtconfig/paletteeditoradvanced.h index 9dc4657..9f7a3f7 100644 --- a/tools/qtconfig/paletteeditoradvanced.h +++ b/tools/qtconfig/paletteeditoradvanced.h @@ -42,13 +42,17 @@ #ifndef PALETTEEDITORADVANCED_H #define PALETTEEDITORADVANCED_H -#include "ui_paletteeditoradvanced.h" +#include + +namespace Ui { + class PaletteEditorAdvanced; +} QT_BEGIN_NAMESPACE class ColorButton; -class PaletteEditorAdvanced : public QDialog, public Ui::PaletteEditorAdvanced +class PaletteEditorAdvanced : public QDialog { Q_OBJECT public: @@ -90,6 +94,8 @@ private: static QPalette::ColorRole effectFromIndex(int); QPalette editPalette; + Ui::PaletteEditorAdvanced *ui; + int selectedPalette; ColorButton *buttonCentral; ColorButton *buttonEffect; -- cgit v0.12 From 9e2ad8173868fad7b31c1d249a5a816b40a65cfe Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:39 +0200 Subject: Fixed some problems in qtconfig's PreviewWidget One problem was introduced by the convertion of widget from Qt3: there is no such field as "text" in QTextEdit. Also, widget now is not direct ancestor of UI file. Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/previewwidget.cpp | 16 ++++++++++------ tools/qtconfig/previewwidget.h | 13 ++++++++++--- tools/qtconfig/previewwidget.ui | 32 ++++++++------------------------ 3 files changed, 28 insertions(+), 33 deletions(-) diff --git a/tools/qtconfig/previewwidget.cpp b/tools/qtconfig/previewwidget.cpp index 4a4a580..0573846 100644 --- a/tools/qtconfig/previewwidget.cpp +++ b/tools/qtconfig/previewwidget.cpp @@ -40,14 +40,15 @@ ****************************************************************************/ #include "previewwidget.h" +#include "ui_previewwidget.h" #include QT_BEGIN_NAMESPACE PreviewWidget::PreviewWidget(QWidget *parent) - : QWidget(parent) + : QWidget(parent), ui(new Ui::PreviewWidget) { - setupUi(this); + ui->setupUi(this); // install event filter on child widgets QList l = findChildren(); @@ -57,13 +58,11 @@ PreviewWidget::PreviewWidget(QWidget *parent) } } - -void PreviewWidget::closeEvent(QCloseEvent *e) +PreviewWidget::~PreviewWidget() { - e->ignore(); + delete ui; } - bool PreviewWidget::eventFilter(QObject *, QEvent *e) { switch (e->type()) { @@ -82,4 +81,9 @@ bool PreviewWidget::eventFilter(QObject *, QEvent *e) return false; } +void PreviewWidget::closeEvent(QCloseEvent *e) +{ + e->ignore(); +} + QT_END_NAMESPACE diff --git a/tools/qtconfig/previewwidget.h b/tools/qtconfig/previewwidget.h index 1452932..ee3513d 100644 --- a/tools/qtconfig/previewwidget.h +++ b/tools/qtconfig/previewwidget.h @@ -42,19 +42,26 @@ #ifndef PREVIEWWIDGET_H #define PREVIEWWIDGET_H -#include "ui_previewwidget.h" +#include + +namespace Ui { + class PreviewWidget; +} QT_BEGIN_NAMESPACE -class PreviewWidget : public QWidget, public Ui::PreviewWidget +class PreviewWidget : public QWidget { Q_OBJECT public: PreviewWidget(QWidget *parent = 0); + ~PreviewWidget(); - void closeEvent(QCloseEvent *); bool eventFilter(QObject *, QEvent *); +private: + void closeEvent(QCloseEvent *); + Ui::PreviewWidget* ui; }; QT_END_NAMESPACE diff --git a/tools/qtconfig/previewwidget.ui b/tools/qtconfig/previewwidget.ui index 9d86a1f..2e0789f 100644 --- a/tools/qtconfig/previewwidget.ui +++ b/tools/qtconfig/previewwidget.ui @@ -46,8 +46,8 @@ 0 0 - 414 - 318 + 398 + 282 @@ -59,21 +59,9 @@ Preview Window - - - 6 - - - 11 - + - - 6 - - - 0 - @@ -225,19 +213,15 @@ 32767 - 50 + 55 true - - <p> -<a href="http://qt.nokia.com">http://qt.nokia.com</a> -</p> -<p> -<a href="http://www.kde.org">http://www.kde.org</a> -</p> + + <p><a href="http://qt.nokia.com">http://qt.nokia.com</a></p> +<p><a href="http://www.kde.org">http://www.kde.org</a></p> @@ -256,7 +240,7 @@ 20 - 20 + 0 -- cgit v0.12 From 68334589014e9b392a8ab274b6ef718e52512f82 Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:39 +0200 Subject: Fixed a bug and resolved some translation issues in qtconfig Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/mainwindow.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index fd083c1..e7d7a13 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -231,7 +231,7 @@ MainWindow::MainWindow() gstyles.sort(); gstylecombo->addItem(desktopThemeName); gstylecombo->setItemData(gstylecombo->findText(desktopThemeName), - tr("Choose style and palette based on your desktop settings."), Qt::ToolTipRole); + tr("Choose style and palette based on your desktop settings."), Qt::ToolTipRole); gstylecombo->addItems(gstyles); QSettings settings(QLatin1String("Trolltech")); @@ -246,7 +246,7 @@ MainWindow::MainWindow() if (index != -1) { gstylecombo->setCurrentIndex(index); } else { // we give up - gstylecombo->addItem(QLatin1String("Unknown")); + gstylecombo->addItem(tr("Unknown")); gstylecombo->setCurrentIndex(gstylecombo->count() - 1); } } @@ -436,7 +436,7 @@ MainWindow::MainWindow() continue; //This is used implicitly from the auto setting GstElement *sink = gst_element_factory_make (qPrintable(name), NULL); if (sink) { - description = QLatin1String(gst_element_factory_get_description (GST_ELEMENT_FACTORY(feature))); + description = QLatin1String(gst_element_factory_get_description(GST_ELEMENT_FACTORY(feature))); audiosinkCombo->addItem(name, name); audiosinkCombo->setItemData(audiosinkCombo->findText(name), description, Qt::ToolTipRole); gst_object_unref (sink); @@ -539,11 +539,11 @@ void MainWindow::fileSave() #ifdef Q_WS_X11 QString style = inputStyle->currentText(); QString str = QLatin1String("On The Spot"); - if (style == trUtf8("Over The Spot")) + if (style == tr("Over The Spot")) str = QLatin1String("Over The Spot"); - else if (style == trUtf8("Off The Spot")) + else if (style == tr("Off The Spot")) str = QLatin1String("Off The Spot"); - else if (style == trUtf8("Root")) + else if (style == tr("Root")) str = QLatin1String("Root"); settings.setValue(QLatin1String("XIMInputStyle"), str); #endif @@ -598,7 +598,7 @@ void MainWindow::fileSave() #endif // Q_WS_X11 setModified(false); - statusBar()->showMessage(QLatin1String("Saved changes.")); + statusBar()->showMessage(tr("Saved changes.")); } void MainWindow::fileExit() @@ -622,7 +622,7 @@ void MainWindow::buildPalette() temp = PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup(i), temp); editPalette = temp; - + setPreviewPalette(editPalette); updateColorButtons(); setModified(true); -- cgit v0.12 From ece4b6c39c32ec32e10cb841157c54d5724c76df Mon Sep 17 00:00:00 2001 From: Boris Date: Wed, 6 Oct 2010 15:51:40 +0200 Subject: Removed inheritance from UI file in qtconfig's MainWindow Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/mainwindow.cpp | 504 ++++++++++++++++++++++-------------------- tools/qtconfig/mainwindow.h | 10 +- 2 files changed, 269 insertions(+), 245 deletions(-) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index e7d7a13..7301bab 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -40,6 +40,8 @@ ****************************************************************************/ #include "mainwindow.h" +#include "ui_mainwindow.h" + #include "colorbutton.h" #include "previewframe.h" #include "paletteeditoradvanced.h" @@ -179,94 +181,92 @@ static void setStyleHelper(QWidget *w, QStyle *s) } MainWindow::MainWindow() - : QMainWindow(), editPalette(palette()), previewPalette(palette()), previewstyle(0) + : QMainWindow(), ui(new Ui::MainWindow), editPalette(palette()), previewPalette(palette()), + previewstyle(0) { - setupUi(this); + ui->setupUi(this); statusBar(); // signals and slots connections - connect(fontpathlineedit, SIGNAL(returnPressed()), SLOT(addFontpath())); - connect(PushButton15, SIGNAL(clicked()), SLOT(addFontpath())); - connect(PushButton1, SIGNAL(clicked()), SLOT(addSubstitute())); - connect(PushButton14, SIGNAL(clicked()), SLOT(browseFontpath())); - connect(stylecombo, SIGNAL(activated(int)), SLOT(buildFont())); - connect(psizecombo, SIGNAL(activated(int)), SLOT(buildFont())); - connect(PushButton12, SIGNAL(clicked()), SLOT(downFontpath())); - connect(PushButton3, SIGNAL(clicked()), SLOT(downSubstitute())); - connect(familycombo, SIGNAL(activated(QString)), SLOT(familySelected(QString))); - connect(fileExitAction, SIGNAL(activated()), SLOT(fileExit())); - connect(fileSaveAction, SIGNAL(activated()), SLOT(fileSave())); - connect(helpAboutAction, SIGNAL(activated()), SLOT(helpAbout())); - connect(helpAboutQtAction, SIGNAL(activated()), SLOT(helpAboutQt())); - connect(TabWidget3, SIGNAL(currentChanged(QWidget*)), SLOT(pageChanged(QWidget*))); - connect(paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); - connect(PushButton13, SIGNAL(clicked()), SLOT(removeFontpath())); - connect(PushButton4, SIGNAL(clicked()), SLOT(removeSubstitute())); - connect(toolboxeffect, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(dcispin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(cfispin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(wslspin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(menueffect, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(comboeffect, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(audiosinkCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(videomodeCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(tooltipeffect, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(strutwidth, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(strutheight, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(effectcheckbox, SIGNAL(toggled(bool)), SLOT(somethingModified())); - connect(resolvelinks, SIGNAL(toggled(bool)), SLOT(somethingModified())); - connect(fontembeddingcheckbox, SIGNAL(clicked()), SLOT(somethingModified())); - connect(rtlExtensions, SIGNAL(toggled(bool)), SLOT(somethingModified())); - connect(inputStyle, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(inputMethod, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(gstylecombo, SIGNAL(activated(QString)), SLOT(styleSelected(QString))); - connect(familysubcombo, SIGNAL(activated(QString)), SLOT(substituteSelected(QString))); - connect(btnAdvanced, SIGNAL(clicked()), SLOT(tunePalette())); - connect(PushButton11, SIGNAL(clicked()), SLOT(upFontpath())); - connect(PushButton2, SIGNAL(clicked()), SLOT(upSubstitute())); + connect(ui->fontpathlineedit, SIGNAL(returnPressed()), SLOT(addFontpath())); + connect(ui->PushButton15, SIGNAL(clicked()), SLOT(addFontpath())); + connect(ui->PushButton1, SIGNAL(clicked()), SLOT(addSubstitute())); + connect(ui->PushButton14, SIGNAL(clicked()), SLOT(browseFontpath())); + connect(ui->stylecombo, SIGNAL(activated(int)), SLOT(buildFont())); + connect(ui->psizecombo, SIGNAL(activated(int)), SLOT(buildFont())); + connect(ui->PushButton12, SIGNAL(clicked()), SLOT(downFontpath())); + connect(ui->PushButton3, SIGNAL(clicked()), SLOT(downSubstitute())); + connect(ui->familycombo, SIGNAL(activated(QString)), SLOT(familySelected(QString))); + connect(ui->fileExitAction, SIGNAL(activated()), SLOT(fileExit())); + connect(ui->fileSaveAction, SIGNAL(activated()), SLOT(fileSave())); + connect(ui->helpAboutAction, SIGNAL(activated()), SLOT(helpAbout())); + connect(ui->helpAboutQtAction, SIGNAL(activated()), SLOT(helpAboutQt())); + connect(ui->TabWidget3, SIGNAL(currentChanged(QWidget*)), SLOT(pageChanged(QWidget*))); + connect(ui->paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); + connect(ui->PushButton13, SIGNAL(clicked()), SLOT(removeFontpath())); + connect(ui->PushButton4, SIGNAL(clicked()), SLOT(removeSubstitute())); + connect(ui->toolboxeffect, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->dcispin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->cfispin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->wslspin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->menueffect, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->comboeffect, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->audiosinkCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->videomodeCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->tooltipeffect, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->strutwidth, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->strutheight, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->effectcheckbox, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(ui->resolvelinks, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(ui->fontembeddingcheckbox, SIGNAL(clicked()), SLOT(somethingModified())); + connect(ui->rtlExtensions, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(ui->inputStyle, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->inputMethod, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->gstylecombo, SIGNAL(activated(QString)), SLOT(styleSelected(QString))); + connect(ui->familysubcombo, SIGNAL(activated(QString)), SLOT(substituteSelected(QString))); + connect(ui->btnAdvanced, SIGNAL(clicked()), SLOT(tunePalette())); + connect(ui->PushButton11, SIGNAL(clicked()), SLOT(upFontpath())); + connect(ui->PushButton2, SIGNAL(clicked()), SLOT(upSubstitute())); modified = true; desktopThemeName = tr("Desktop Settings (Default)"); QStringList gstyles = QStyleFactory::keys(); gstyles.sort(); - gstylecombo->addItem(desktopThemeName); - gstylecombo->setItemData(gstylecombo->findText(desktopThemeName), - tr("Choose style and palette based on your desktop settings."), Qt::ToolTipRole); - gstylecombo->addItems(gstyles); + ui->gstylecombo->addItem(desktopThemeName); + ui->gstylecombo->setItemData(ui->gstylecombo->findText(desktopThemeName), + tr("Choose style and palette based on your desktop settings."), + Qt::ToolTipRole); + ui->gstylecombo->addItems(gstyles); QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QString currentstyle = settings.value(QLatin1String("style")).toString(); if (currentstyle.isEmpty()) { - gstylecombo->setCurrentIndex(gstylecombo->findText(desktopThemeName)); + ui->gstylecombo->setCurrentIndex(ui->gstylecombo->findText(desktopThemeName)); currentstyle = QApplication::style()->objectName(); } else { - int index = gstylecombo->findText(currentstyle, Qt::MatchFixedString); + int index = ui->gstylecombo->findText(currentstyle, Qt::MatchFixedString); if (index != -1) { - gstylecombo->setCurrentIndex(index); + ui->gstylecombo->setCurrentIndex(index); } else { // we give up - gstylecombo->addItem(tr("Unknown")); - gstylecombo->setCurrentIndex(gstylecombo->count() - 1); + ui->gstylecombo->addItem(tr("Unknown")); + ui->gstylecombo->setCurrentIndex(ui->gstylecombo->count() - 1); } } - buttonMainColor->setColor(palette().color(QPalette::Active, - QPalette::Button)); - buttonWindowColor->setColor(palette().color(QPalette::Active, - QPalette::Window)); - connect(buttonMainColor, SIGNAL(colorChanged(QColor)), - this, SLOT(buildPalette())); - connect(buttonWindowColor, SIGNAL(colorChanged(QColor)), - this, SLOT(buildPalette())); + ui->buttonMainColor->setColor(palette().color(QPalette::Active, QPalette::Button)); + ui->buttonWindowColor->setColor(palette().color(QPalette::Active, QPalette::Window)); + connect(ui->buttonMainColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette())); + connect(ui->buttonWindowColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette())); if (X11->desktopEnvironment == DE_KDE) - colorConfig->hide(); + ui->colorConfig->hide(); else - labelKDENote->hide(); + ui->labelKDENote->hide(); QFontDatabase db; QStringList families = db.families(); - familycombo->addItems(families); + ui->familycombo->addItems(families); QStringList fs = families; QStringList fs2 = QFont::substitutions(); @@ -277,41 +277,41 @@ MainWindow::MainWindow() fsit++; } fs.sort(); - familysubcombo->addItems(fs); + ui->familysubcombo->addItems(fs); - choosesubcombo->addItems(families); + ui->choosesubcombo->addItems(families); QList sizes = db.standardSizes(); foreach(int i, sizes) - psizecombo->addItem(QString::number(i)); + ui->psizecombo->addItem(QString::number(i)); - dcispin->setValue(QApplication::doubleClickInterval()); - cfispin->setValue(QApplication::cursorFlashTime()); - wslspin->setValue(QApplication::wheelScrollLines()); + ui->dcispin->setValue(QApplication::doubleClickInterval()); + ui->cfispin->setValue(QApplication::cursorFlashTime()); + ui->wslspin->setValue(QApplication::wheelScrollLines()); // ############# // resolvelinks->setChecked(qt_resolve_symlinks); - effectcheckbox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); - effectbase->setEnabled(effectcheckbox->isChecked()); + ui->effectcheckbox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); + ui->effectbase->setEnabled(ui->effectcheckbox->isChecked()); if (QApplication::isEffectEnabled(Qt::UI_FadeMenu)) - menueffect->setCurrentIndex(2); + ui->menueffect->setCurrentIndex(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) - menueffect->setCurrentIndex(1); + ui->menueffect->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo)) - comboeffect->setCurrentIndex(1); + ui->comboeffect->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)) - tooltipeffect->setCurrentIndex(2); + ui->tooltipeffect->setCurrentIndex(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)) - tooltipeffect->setCurrentIndex(1); + ui->tooltipeffect->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_AnimateToolBox)) - toolboxeffect->setCurrentIndex(1); + ui->toolboxeffect->setCurrentIndex(1); QSize globalStrut = QApplication::globalStrut(); - strutwidth->setValue(globalStrut.width()); - strutheight->setValue(globalStrut.height()); + ui->strutwidth->setValue(globalStrut.width()); + ui->strutheight->setValue(globalStrut.height()); // find the default family QStringList::Iterator sit = families.begin(); @@ -330,10 +330,10 @@ MainWindow::MainWindow() if (i == -1) // no clue about the current font i = 0; - familycombo->setCurrentIndex(i); + ui->familycombo->setCurrentIndex(i); - QStringList styles = db.styles(familycombo->currentText()); - stylecombo->addItems(styles); + QStringList styles = db.styles(ui->familycombo->currentText()); + ui->stylecombo->addItems(styles); QString stylestring = db.styleString(QApplication::font()); sit = styles.begin(); @@ -352,34 +352,35 @@ MainWindow::MainWindow() i = possible; if (i == -1) // no clue about the current font i = 0; - stylecombo->setCurrentIndex(i); + ui->stylecombo->setCurrentIndex(i); i = 0; - for (int psize = QApplication::font().pointSize(); i < psizecombo->count(); ++i) { - const int sz = psizecombo->itemText(i).toInt(); + for (int psize = QApplication::font().pointSize(); i < ui->psizecombo->count(); ++i) { + const int sz = ui->psizecombo->itemText(i).toInt(); if (sz == psize) { - psizecombo->setCurrentIndex(i); + ui->psizecombo->setCurrentIndex(i); break; } else if(sz > psize) { - psizecombo->insertItem(i, QString::number(psize)); - psizecombo->setCurrentIndex(i); + ui->psizecombo->insertItem(i, QString::number(psize)); + ui->psizecombo->setCurrentIndex(i); break; } } - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - sublistbox->clear(); - sublistbox->insertItems(0, subs); + QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); + ui->sublistbox->clear(); + ui->sublistbox->insertItems(0, subs); - rtlExtensions->setChecked(settings.value(QLatin1String("useRtlExtensions"), false).toBool()); + ui->rtlExtensions->setChecked(settings.value(QLatin1String("useRtlExtensions"), false) + .toBool()); #ifdef Q_WS_X11 QString settingsInputStyle = settings.value(QLatin1String("XIMInputStyle")).toString(); if (!settingsInputStyle.isEmpty()) - inputStyle->setCurrentIndex(inputStyle->findText(settingsInputStyle)); + ui->inputStyle->setCurrentIndex(ui->inputStyle->findText(settingsInputStyle)); #else - inputStyle->hide(); - inputStyleLabel->hide(); + ui->inputStyle->hide(); + ui->inputStyleLabel->hide(); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) @@ -398,32 +399,35 @@ MainWindow::MainWindow() } if (inputMethodIndex == -1 && !inputMethods.isEmpty()) inputMethodIndex = 0; - inputMethod->addItems(inputMethods); - inputMethod->setCurrentIndex(inputMethodIndex); + ui->inputMethod->addItems(inputMethods); + ui->inputMethod->setCurrentIndex(inputMethodIndex); #else - inputMethod->hide(); - inputMethodLabel->hide(); + ui->inputMethod->hide(); + ui->inputMethodLabel->hide(); #endif - fontembeddingcheckbox->setChecked(settings.value(QLatin1String("embedFonts"), true).toBool()); + ui->fontembeddingcheckbox->setChecked(settings.value(QLatin1String("embedFonts"), true) + .toBool()); fontpaths = settings.value(QLatin1String("fontPath")).toStringList(); - fontpathlistbox->insertItems(0, fontpaths); - - audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); - audiosinkCombo->setItemData(audiosinkCombo->findText(tr("Auto (default)")), - tr("Choose audio output automatically."), Qt::ToolTipRole); - audiosinkCombo->addItem(tr("aRts"), QLatin1String("artssink")); - audiosinkCombo->setItemData(audiosinkCombo->findText(tr("aRts")), - tr("Experimental aRts support for GStreamer."), Qt::ToolTipRole); + ui->fontpathlistbox->insertItems(0, fontpaths); + + ui->audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); + ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(tr("Auto (default)")), + tr("Choose audio output automatically."), Qt::ToolTipRole); + ui->audiosinkCombo->addItem(tr("aRts"), QLatin1String("artssink")); + ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(tr("aRts")), + tr("Experimental aRts support for GStreamer."), + Qt::ToolTipRole); #ifdef HAVE_PHONON phononVersionLabel->setText(QLatin1String(Phonon::phononVersion())); #endif #ifndef QT_NO_GSTREAMER if (gst_init_check(0, 0, 0)) { gchar *versionString = gst_version_string(); - gstversionLabel->setText(QLatin1String(versionString)); + ui->gstversionLabel->setText(QLatin1String(versionString)); g_free(versionString); - GList *factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); + GList *factoryList = gst_registry_get_feature_list(gst_registry_get_default(), + GST_TYPE_ELEMENT_FACTORY); QString name, klass, description; for (GList *iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); @@ -431,14 +435,15 @@ MainWindow::MainWindow() if (klass == QLatin1String("Sink/Audio")) { name = QLatin1String(GST_PLUGIN_FEATURE_NAME(feature)); if (name == QLatin1String("sfsink")) - continue; //useless to output audio to file when you cannot set the file path + continue; // useless to output audio to file when you cannot set the file path else if (name == QLatin1String("autoaudiosink")) continue; //This is used implicitly from the auto setting GstElement *sink = gst_element_factory_make (qPrintable(name), NULL); if (sink) { description = QLatin1String(gst_element_factory_get_description(GST_ELEMENT_FACTORY(feature))); - audiosinkCombo->addItem(name, name); - audiosinkCombo->setItemData(audiosinkCombo->findText(name), description, Qt::ToolTipRole); + ui->audiosinkCombo->addItem(name, name); + ui->audiosinkCombo->setItemData(audiosinkCombo->findText(name), description, + Qt::ToolTipRole); gst_object_unref (sink); } } @@ -446,31 +451,40 @@ MainWindow::MainWindow() g_list_free(factoryList); } #else - tab4->setEnabled(false); - phononLabel->setText(tr("Phonon GStreamer backend not available.")); + ui->tab4->setEnabled(false); + ui->phononLabel->setText(tr("Phonon GStreamer backend not available.")); #endif - videomodeCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); - videomodeCombo->setItemData(videomodeCombo->findText(tr("Auto (default)")), tr("Choose render method automatically"), Qt::ToolTipRole); + ui->videomodeCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); + ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("Auto (default)")), + tr("Choose render method automatically"), Qt::ToolTipRole); #ifdef Q_WS_X11 - videomodeCombo->addItem(tr("X11"), QLatin1String("X11")); - videomodeCombo->setItemData(videomodeCombo->findText(tr("X11")), tr("Use X11 Overlays"), Qt::ToolTipRole); + ui->videomodeCombo->addItem(tr("X11"), QLatin1String("X11")); + ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("X11")), + tr("Use X11 Overlays"), Qt::ToolTipRole); #endif #ifndef QT_NO_OPENGL +<<<<<<< HEAD videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); videomodeCombo->setItemData(videomodeCombo->findText(tr("OpenGL")), tr("Use OpenGL if available"), Qt::ToolTipRole); +======= + ui->videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); + ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("OpenGL")), + tr("Use OpenGL if avaiable"), Qt::ToolTipRole); +>>>>>>> Removed inheritance from UI file in qtconfig's MainWindow #endif - videomodeCombo->addItem(tr("Software"), QLatin1String("Software")); - videomodeCombo->setItemData(videomodeCombo->findText(tr("Software")), tr("Use simple software rendering"), Qt::ToolTipRole); + ui->videomodeCombo->addItem(tr("Software"), QLatin1String("Software")); + ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("Software")), + tr("Use simple software rendering"), Qt::ToolTipRole); QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); - audiosinkCombo->setCurrentIndex(audiosinkCombo->findData(audioSink)); - videomodeCombo->setCurrentIndex(videomodeCombo->findData(videoMode)); + ui->audiosinkCombo->setCurrentIndex(ui->audiosinkCombo->findData(audioSink)); + ui->videomodeCombo->setCurrentIndex(ui->videomodeCombo->findData(videoMode)); settings.endGroup(); // Qt - helpview->setText(tr(appearance_text)); + ui->helpview->setText(tr(appearance_text)); setModified(false); updateStyleLayout(); @@ -478,6 +492,7 @@ MainWindow::MainWindow() MainWindow::~MainWindow() { + delete ui; } #ifdef Q_WS_X11 @@ -497,23 +512,23 @@ void MainWindow::fileSave() QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QFontDatabase db; - QFont font = db.font(familycombo->currentText(), - stylecombo->currentText(), - psizecombo->currentText().toInt()); + QFont font = db.font(ui->familycombo->currentText(), + ui->stylecombo->currentText(), + ui->psizecombo->currentText().toInt()); QStringList actcg, inactcg, discg; - bool overrideDesktopSettings = (gstylecombo->currentText() != desktopThemeName); + bool overrideDesktopSettings = (ui->gstylecombo->currentText() != desktopThemeName); if (overrideDesktopSettings) { int i; for (i = 0; i < QPalette::NColorRoles; i++) actcg << editPalette.color(QPalette::Active, - (QPalette::ColorRole) i).name(); + QPalette::ColorRole(i)).name(); for (i = 0; i < QPalette::NColorRoles; i++) inactcg << editPalette.color(QPalette::Inactive, - (QPalette::ColorRole) i).name(); + QPalette::ColorRole(i)).name(); for (i = 0; i < QPalette::NColorRoles; i++) discg << editPalette.color(QPalette::Disabled, - (QPalette::ColorRole) i).name(); + QPalette::ColorRole(i)).name(); } settings.setValue(QLatin1String("font"), font.toString()); @@ -522,22 +537,24 @@ void MainWindow::fileSave() settings.setValue(QLatin1String("Palette/disabled"), discg); settings.setValue(QLatin1String("fontPath"), fontpaths); - settings.setValue(QLatin1String("embedFonts"), fontembeddingcheckbox->isChecked()); - settings.setValue(QLatin1String("style"), overrideDesktopSettings ? gstylecombo->currentText() : QString()); + settings.setValue(QLatin1String("embedFonts"), ui->fontembeddingcheckbox->isChecked()); + settings.setValue(QLatin1String("style"), + overrideDesktopSettings ? ui->gstylecombo->currentText() : QString()); - settings.setValue(QLatin1String("doubleClickInterval"), dcispin->value()); - settings.setValue(QLatin1String("cursorFlashTime"), cfispin->value() == 9 ? 0 : cfispin->value()); - settings.setValue(QLatin1String("wheelScrollLines"), wslspin->value()); - settings.setValue(QLatin1String("resolveSymlinks"), resolvelinks->isChecked()); + settings.setValue(QLatin1String("doubleClickInterval"), ui->dcispin->value()); + settings.setValue(QLatin1String("cursorFlashTime"), + ui->cfispin->value() == 9 ? 0 : ui->cfispin->value()); + settings.setValue(QLatin1String("wheelScrollLines"), ui->wslspin->value()); + settings.setValue(QLatin1String("resolveSymlinks"), ui->resolvelinks->isChecked()); - QSize strut(strutwidth->value(), strutheight->value()); + QSize strut(ui->strutwidth->value(), ui->strutheight->value()); settings.setValue(QLatin1String("globalStrut/width"), strut.width()); settings.setValue(QLatin1String("globalStrut/height"), strut.height()); - settings.setValue(QLatin1String("useRtlExtensions"), rtlExtensions->isChecked()); + settings.setValue(QLatin1String("useRtlExtensions"), ui->rtlExtensions->isChecked()); #ifdef Q_WS_X11 - QString style = inputStyle->currentText(); + QString style = ui->inputStyle->currentText(); QString str = QLatin1String("On The Spot"); if (style == tr("Over The Spot")) str = QLatin1String("Over The Spot"); @@ -548,33 +565,35 @@ void MainWindow::fileSave() settings.setValue(QLatin1String("XIMInputStyle"), str); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) - settings.setValue(QLatin1String("DefaultInputMethod"), inputMethod->currentText()); + settings.setValue(QLatin1String("DefaultInputMethod"), ui->inputMethod->currentText()); #endif QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); - settings.setValue(QLatin1String("audiosink"), audiosinkCombo->itemData(audiosinkCombo->currentIndex())); - settings.setValue(QLatin1String("videomode"), videomodeCombo->itemData(videomodeCombo->currentIndex())); + settings.setValue(QLatin1String("audiosink"), + ui->audiosinkCombo->itemData(ui->audiosinkCombo->currentIndex())); + settings.setValue(QLatin1String("videomode"), + ui->videomodeCombo->itemData(ui->videomodeCombo->currentIndex())); QStringList effects; - if (effectcheckbox->isChecked()) { + if (ui->effectcheckbox->isChecked()) { effects << QLatin1String("general"); - switch (menueffect->currentIndex()) { + switch (ui->menueffect->currentIndex()) { case 1: effects << QLatin1String("animatemenu"); break; case 2: effects << QLatin1String("fademenu"); break; } - switch (comboeffect->currentIndex()) { + switch (ui->comboeffect->currentIndex()) { case 1: effects << QLatin1String("animatecombo"); break; } - switch (tooltipeffect->currentIndex()) { + switch (ui->tooltipeffect->currentIndex()) { case 1: effects << QLatin1String("animatetooltip"); break; case 2: effects << QLatin1String("fadetooltip"); break; } - switch (toolboxeffect->currentIndex()) { + switch (ui->toolboxeffect->currentIndex()) { case 1: effects << QLatin1String("animatetoolbox"); break; } } else @@ -612,12 +631,12 @@ void MainWindow::setModified(bool m) return; modified = m; - fileSaveAction->setEnabled(m); + ui->fileSaveAction->setEnabled(m); } void MainWindow::buildPalette() { - QPalette temp(buttonMainColor->color(), buttonWindowColor->color()); + QPalette temp(ui->buttonMainColor->color(), ui->buttonWindowColor->color()); for (int i = 0; i < QPalette::NColorGroups; i++) temp = PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup(i), temp); @@ -630,7 +649,7 @@ void MainWindow::buildPalette() void MainWindow::setPreviewPalette(const QPalette &pal) { - QPalette::ColorGroup colorGroup = groupFromIndex(paletteCombo->currentIndex()); + QPalette::ColorGroup colorGroup = groupFromIndex(ui->paletteCombo->currentIndex()); for (int i = 0; i < QPalette::NColorGroups; i++) { for (int j = 0; j < QPalette::NColorRoles; j++) { @@ -640,13 +659,13 @@ void MainWindow::setPreviewPalette(const QPalette &pal) } } - previewFrame->setPreviewPalette(previewPalette); + ui->previewFrame->setPreviewPalette(previewPalette); } void MainWindow::updateColorButtons() { - buttonMainColor->setColor(editPalette.color(QPalette::Active, QPalette::Button)); - buttonWindowColor->setColor(editPalette.color(QPalette::Active, QPalette::Window)); + ui->buttonMainColor->setColor(editPalette.color(QPalette::Active, QPalette::Button)); + ui->buttonWindowColor->setColor(editPalette.color(QPalette::Active, QPalette::Window)); } void MainWindow::tunePalette() @@ -669,10 +688,10 @@ void MainWindow::paletteSelected(int) void MainWindow::updateStyleLayout() { - QString currentStyle = gstylecombo->currentText(); + QString currentStyle = ui->gstylecombo->currentText(); bool autoStyle = (currentStyle == desktopThemeName); - previewFrame->setPreviewVisible(!autoStyle); - groupAutoPalette->setEnabled(currentStyle.toLower() != QLatin1String("gtk") && !autoStyle); + ui->previewFrame->setPreviewVisible(!autoStyle); + ui->groupAutoPalette->setEnabled(currentStyle.toLower() != QLatin1String("gtk") && !autoStyle); } void MainWindow::styleSelected(const QString &stylename) @@ -684,7 +703,7 @@ void MainWindow::styleSelected(const QString &stylename) style = QStyleFactory::create(stylename); if (!style) return; - setStyleHelper(previewFrame, style); + setStyleHelper(ui->previewFrame, style); delete previewstyle; previewstyle = style; setModified(true); @@ -696,169 +715,170 @@ void MainWindow::familySelected(const QString &family) { QFontDatabase db; QStringList styles = db.styles(family); - stylecombo->clear(); - stylecombo->addItems(styles); - familysubcombo->addItem(family); + ui->stylecombo->clear(); + ui->stylecombo->addItems(styles); + ui->familysubcombo->addItem(family); buildFont(); } void MainWindow::buildFont() { QFontDatabase db; - QFont font = db.font(familycombo->currentText(), - stylecombo->currentText(), - psizecombo->currentText().toInt()); - samplelineedit->setFont(font); + QFont font = db.font(ui->familycombo->currentText(), + ui->stylecombo->currentText(), + ui->psizecombo->currentText().toInt()); + ui->samplelineedit->setFont(font); setModified(true); } void MainWindow::substituteSelected(const QString &family) { QStringList subs = QFont::substitutes(family); - sublistbox->clear(); - sublistbox->insertItems(0, subs); + ui->sublistbox->clear(); + ui->sublistbox->insertItems(0, subs); } void MainWindow::removeSubstitute() { - if (!sublistbox->currentItem()) + if (!ui->sublistbox->currentItem()) return; - int row = sublistbox->currentRow(); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - subs.removeAt(sublistbox->currentRow()); - sublistbox->clear(); - sublistbox->insertItems(0, subs); - if (row > sublistbox->count()) - row = sublistbox->count() - 1; - sublistbox->setCurrentRow(row); - QFont::removeSubstitution(familysubcombo->currentText()); - QFont::insertSubstitutions(familysubcombo->currentText(), subs); + int row = ui->sublistbox->currentRow(); + QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); + subs.removeAt(ui->sublistbox->currentRow()); + ui->sublistbox->clear(); + ui->sublistbox->insertItems(0, subs); + if (row > ui->sublistbox->count()) + row = ui->sublistbox->count() - 1; + ui->sublistbox->setCurrentRow(row); + QFont::removeSubstitution(ui->familysubcombo->currentText()); + QFont::insertSubstitutions(ui->familysubcombo->currentText(), subs); setModified(true); } void MainWindow::addSubstitute() { - if (!sublistbox->currentItem()) { - QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - sublistbox->clear(); - sublistbox->insertItems(0, subs); + if (!ui->sublistbox->currentItem()) { + QFont::insertSubstitution(ui->familysubcombo->currentText(), + ui->choosesubcombo->currentText()); + QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); + ui->sublistbox->clear(); + ui->sublistbox->insertItems(0, subs); setModified(true); return; } - int row = sublistbox->currentRow(); - QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); - sublistbox->clear(); - sublistbox->insertItems(0, subs); - sublistbox->setCurrentRow(row); + int row = ui->sublistbox->currentRow(); + QFont::insertSubstitution(ui->familysubcombo->currentText(), ui->choosesubcombo->currentText()); + QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); + ui->sublistbox->clear(); + ui->sublistbox->insertItems(0, subs); + ui->sublistbox->setCurrentRow(row); setModified(true); } void MainWindow::downSubstitute() { - if (!sublistbox->currentItem() || sublistbox->currentRow() >= sublistbox->count()) + if (!ui->sublistbox->currentItem() || ui->sublistbox->currentRow() >= ui->sublistbox->count()) return; - int row = sublistbox->currentRow(); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); + int row = ui->sublistbox->currentRow(); + QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); QString fam = subs.at(row); subs.removeAt(row); subs.insert(row + 1, fam); - sublistbox->clear(); - sublistbox->insertItems(0, subs); - sublistbox->setCurrentRow(row + 1); - QFont::removeSubstitution(familysubcombo->currentText()); - QFont::insertSubstitutions(familysubcombo->currentText(), subs); + ui->sublistbox->clear(); + ui->sublistbox->insertItems(0, subs); + ui->sublistbox->setCurrentRow(row + 1); + QFont::removeSubstitution(ui->familysubcombo->currentText()); + QFont::insertSubstitutions(ui->familysubcombo->currentText(), subs); setModified(true); } void MainWindow::upSubstitute() { - if (!sublistbox->currentItem() || sublistbox->currentRow() < 1) + if (!ui->sublistbox->currentItem() || ui->sublistbox->currentRow() < 1) return; - int row = sublistbox->currentRow(); - QStringList subs = QFont::substitutes(familysubcombo->currentText()); + int row = ui->sublistbox->currentRow(); + QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); QString fam = subs.at(row); subs.removeAt(row); subs.insert(row-1, fam); - sublistbox->clear(); - sublistbox->insertItems(0, subs); - sublistbox->setCurrentRow(row - 1); - QFont::removeSubstitution(familysubcombo->currentText()); - QFont::insertSubstitutions(familysubcombo->currentText(), subs); + ui->sublistbox->clear(); + ui->sublistbox->insertItems(0, subs); + ui->sublistbox->setCurrentRow(row - 1); + QFont::removeSubstitution(ui->familysubcombo->currentText()); + QFont::insertSubstitutions(ui->familysubcombo->currentText(), subs); setModified(true); } void MainWindow::removeFontpath() { - if (!fontpathlistbox->currentItem()) + if (!ui->fontpathlistbox->currentItem()) return; - int row = fontpathlistbox->currentRow(); + int row = ui->fontpathlistbox->currentRow(); fontpaths.removeAt(row); - fontpathlistbox->clear(); - fontpathlistbox->insertItems(0, fontpaths); - if (row > fontpathlistbox->count()) - row = fontpathlistbox->count() - 1; - fontpathlistbox->setCurrentRow(row); + ui->fontpathlistbox->clear(); + ui->fontpathlistbox->insertItems(0, fontpaths); + if (row > ui->fontpathlistbox->count()) + row = ui->fontpathlistbox->count() - 1; + ui->fontpathlistbox->setCurrentRow(row); setModified(true); } void MainWindow::addFontpath() { - if (fontpathlineedit->text().isEmpty()) + if (ui->fontpathlineedit->text().isEmpty()) return; - if (!fontpathlistbox->currentItem()) { - fontpaths.append(fontpathlineedit->text()); - fontpathlistbox->clear(); - fontpathlistbox->insertItems(0, fontpaths); + if (!ui->fontpathlistbox->currentItem()) { + fontpaths.append(ui->fontpathlineedit->text()); + ui->fontpathlistbox->clear(); + ui->fontpathlistbox->insertItems(0, fontpaths); setModified(true); return; } - int row = fontpathlistbox->currentRow(); - fontpaths.insert(row + 1, fontpathlineedit->text()); - fontpathlistbox->clear(); - fontpathlistbox->insertItems(0, fontpaths); - fontpathlistbox->setCurrentRow(row); + int row = ui->fontpathlistbox->currentRow(); + fontpaths.insert(row + 1, ui->fontpathlineedit->text()); + ui->fontpathlistbox->clear(); + ui->fontpathlistbox->insertItems(0, fontpaths); + ui->fontpathlistbox->setCurrentRow(row); setModified(true); } void MainWindow::downFontpath() { - if (!fontpathlistbox->currentItem() - || fontpathlistbox->currentRow() >= (fontpathlistbox->count() - 1)) { + if (!ui->fontpathlistbox->currentItem() + || ui->fontpathlistbox->currentRow() >= (ui->fontpathlistbox->count() - 1)) { return; } - int row = fontpathlistbox->currentRow(); + int row = ui->fontpathlistbox->currentRow(); QString fam = fontpaths.at(row); fontpaths.removeAt(row); fontpaths.insert(row + 1, fam); - fontpathlistbox->clear(); - fontpathlistbox->insertItems(0, fontpaths); - fontpathlistbox->setCurrentRow(row + 1); + ui->fontpathlistbox->clear(); + ui->fontpathlistbox->insertItems(0, fontpaths); + ui->fontpathlistbox->setCurrentRow(row + 1); setModified(true); } void MainWindow::upFontpath() { - if (!fontpathlistbox->currentItem() || fontpathlistbox->currentRow() < 1) + if (!ui->fontpathlistbox->currentItem() || ui->fontpathlistbox->currentRow() < 1) return; - int row = fontpathlistbox->currentRow(); + int row = ui->fontpathlistbox->currentRow(); QString fam = fontpaths.at(row); fontpaths.removeAt(row); fontpaths.insert(row - 1, fam); - fontpathlistbox->clear(); - fontpathlistbox->insertItems(0, fontpaths); - fontpathlistbox->setCurrentRow(row - 1); + ui->fontpathlistbox->clear(); + ui->fontpathlistbox->insertItems(0, fontpaths); + ui->fontpathlistbox->setCurrentRow(row - 1); setModified(true); } @@ -868,7 +888,7 @@ void MainWindow::browseFontpath() if (dirname.isNull()) return; - fontpathlineedit->setText(dirname); + ui->fontpathlineedit->setText(dirname); } void MainWindow::somethingModified() @@ -895,16 +915,16 @@ void MainWindow::helpAboutQt() void MainWindow::pageChanged(QWidget *page) { - if (page == tab) - helpview->setText(tr(interface_text)); - else if (page == tab1) - helpview->setText(tr(appearance_text)); - else if (page == tab2) - helpview->setText(tr(font_text)); - else if (page == tab3) - helpview->setText(tr(printer_text)); - else if (page == tab4) - helpview->setText(tr(phonon_text)); + if (page == ui->tab) + ui->helpview->setText(tr(interface_text)); + else if (page == ui->tab1) + ui->helpview->setText(tr(appearance_text)); + else if (page == ui->tab2) + ui->helpview->setText(tr(font_text)); + else if (page == ui->tab3) + ui->helpview->setText(tr(printer_text)); + else if (page == ui->tab4) + ui->helpview->setText(tr(phonon_text)); } void MainWindow::closeEvent(QCloseEvent *e) diff --git a/tools/qtconfig/mainwindow.h b/tools/qtconfig/mainwindow.h index 76e3691..7cc6522 100644 --- a/tools/qtconfig/mainwindow.h +++ b/tools/qtconfig/mainwindow.h @@ -42,11 +42,15 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include "ui_mainwindow.h" +namespace Ui { + class MainWindow; +} + +#include QT_BEGIN_NAMESPACE -class MainWindow : public QMainWindow, public Ui::MainWindow +class MainWindow : public QMainWindow { Q_OBJECT @@ -56,7 +60,6 @@ public: void closeEvent(QCloseEvent *); - public slots: virtual void buildPalette(); virtual void buildFont(); @@ -93,6 +96,7 @@ private: void setModified(bool); + Ui::MainWindow *ui; QString desktopThemeName; QPalette editPalette, previewPalette; QStyle *previewstyle; -- cgit v0.12 From 668afe43593ae95217c93be5ac4a8d3f5e833e89 Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:41 +0200 Subject: Renamed controls in qtconfig's MainWindow All the controls are ensured to be named according to a Qt Coding Style. The code is much more readable now. Also, the html code inserts and tab stops in UI was fixed. Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/mainwindow.cpp | 410 +++++++++++++++++++++--------------------- tools/qtconfig/mainwindow.ui | 293 +++++++++++++++--------------- 2 files changed, 357 insertions(+), 346 deletions(-) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 7301bab..266d9e4 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -188,70 +188,70 @@ MainWindow::MainWindow() statusBar(); // signals and slots connections - connect(ui->fontpathlineedit, SIGNAL(returnPressed()), SLOT(addFontpath())); - connect(ui->PushButton15, SIGNAL(clicked()), SLOT(addFontpath())); - connect(ui->PushButton1, SIGNAL(clicked()), SLOT(addSubstitute())); - connect(ui->PushButton14, SIGNAL(clicked()), SLOT(browseFontpath())); - connect(ui->stylecombo, SIGNAL(activated(int)), SLOT(buildFont())); - connect(ui->psizecombo, SIGNAL(activated(int)), SLOT(buildFont())); - connect(ui->PushButton12, SIGNAL(clicked()), SLOT(downFontpath())); - connect(ui->PushButton3, SIGNAL(clicked()), SLOT(downSubstitute())); - connect(ui->familycombo, SIGNAL(activated(QString)), SLOT(familySelected(QString))); + connect(ui->fontPathLineEdit, SIGNAL(returnPressed()), SLOT(addFontpath())); + connect(ui->addFontPathButton, SIGNAL(clicked()), SLOT(addFontpath())); + connect(ui->addSubstitutionButton, SIGNAL(clicked()), SLOT(addSubstitute())); + connect(ui->browseFontPathButton, SIGNAL(clicked()), SLOT(browseFontpath())); + connect(ui->fontStyleCombo, SIGNAL(activated(int)), SLOT(buildFont())); + connect(ui->pointSizeCombo, SIGNAL(activated(int)), SLOT(buildFont())); + connect(ui->downFontpathButton, SIGNAL(clicked()), SLOT(downFontpath())); + connect(ui->downSubstitutionButton, SIGNAL(clicked()), SLOT(downSubstitute())); + connect(ui->fontFamilyCombo, SIGNAL(activated(QString)), SLOT(familySelected(QString))); connect(ui->fileExitAction, SIGNAL(activated()), SLOT(fileExit())); connect(ui->fileSaveAction, SIGNAL(activated()), SLOT(fileSave())); connect(ui->helpAboutAction, SIGNAL(activated()), SLOT(helpAbout())); connect(ui->helpAboutQtAction, SIGNAL(activated()), SLOT(helpAboutQt())); - connect(ui->TabWidget3, SIGNAL(currentChanged(QWidget*)), SLOT(pageChanged(QWidget*))); + connect(ui->mainTabWidget, SIGNAL(currentChanged(QWidget*)), SLOT(pageChanged(QWidget*))); connect(ui->paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); - connect(ui->PushButton13, SIGNAL(clicked()), SLOT(removeFontpath())); - connect(ui->PushButton4, SIGNAL(clicked()), SLOT(removeSubstitute())); - connect(ui->toolboxeffect, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->dcispin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->cfispin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->wslspin, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->menueffect, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->comboeffect, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->removeFontpathButton, SIGNAL(clicked()), SLOT(removeFontpath())); + connect(ui->removeSubstitutionButton, SIGNAL(clicked()), SLOT(removeSubstitute())); + connect(ui->toolBoxEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->doubleClickIntervalSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->cursorFlashTimeSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->wheelScrollLinesSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->menuEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->comboEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); connect(ui->audiosinkCombo, SIGNAL(activated(int)), SLOT(somethingModified())); connect(ui->videomodeCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->tooltipeffect, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->strutwidth, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->strutheight, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->effectcheckbox, SIGNAL(toggled(bool)), SLOT(somethingModified())); - connect(ui->resolvelinks, SIGNAL(toggled(bool)), SLOT(somethingModified())); - connect(ui->fontembeddingcheckbox, SIGNAL(clicked()), SLOT(somethingModified())); - connect(ui->rtlExtensions, SIGNAL(toggled(bool)), SLOT(somethingModified())); - connect(ui->inputStyle, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->inputMethod, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->gstylecombo, SIGNAL(activated(QString)), SLOT(styleSelected(QString))); - connect(ui->familysubcombo, SIGNAL(activated(QString)), SLOT(substituteSelected(QString))); - connect(ui->btnAdvanced, SIGNAL(clicked()), SLOT(tunePalette())); - connect(ui->PushButton11, SIGNAL(clicked()), SLOT(upFontpath())); - connect(ui->PushButton2, SIGNAL(clicked()), SLOT(upSubstitute())); + connect(ui->toolTipEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->strutWidthSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->strutHeightSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); + connect(ui->effectsCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(ui->resolveLinksCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(ui->fontEmbeddingCheckBox, SIGNAL(clicked()), SLOT(somethingModified())); + connect(ui->rtlExtensionsCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified())); + connect(ui->inputStyleCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->inputMethodCombo, SIGNAL(activated(int)), SLOT(somethingModified())); + connect(ui->guiStyleCombo, SIGNAL(activated(QString)), SLOT(styleSelected(QString))); + connect(ui->familySubstitutionCombo, SIGNAL(activated(QString)), SLOT(substituteSelected(QString))); + connect(ui->tunePaletteButton, SIGNAL(clicked()), SLOT(tunePalette())); + connect(ui->upFontpathButton, SIGNAL(clicked()), SLOT(upFontpath())); + connect(ui->upSubstitutionButton, SIGNAL(clicked()), SLOT(upSubstitute())); modified = true; desktopThemeName = tr("Desktop Settings (Default)"); QStringList gstyles = QStyleFactory::keys(); gstyles.sort(); - ui->gstylecombo->addItem(desktopThemeName); - ui->gstylecombo->setItemData(ui->gstylecombo->findText(desktopThemeName), - tr("Choose style and palette based on your desktop settings."), - Qt::ToolTipRole); - ui->gstylecombo->addItems(gstyles); + ui->guiStyleCombo->addItem(desktopThemeName); + ui->guiStyleCombo->setItemData(ui->guiStyleCombo->findText(desktopThemeName), + tr("Choose style and palette based on your desktop settings."), + Qt::ToolTipRole); + ui->guiStyleCombo->addItems(gstyles); QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QString currentstyle = settings.value(QLatin1String("style")).toString(); if (currentstyle.isEmpty()) { - ui->gstylecombo->setCurrentIndex(ui->gstylecombo->findText(desktopThemeName)); + ui->guiStyleCombo->setCurrentIndex(ui->guiStyleCombo->findText(desktopThemeName)); currentstyle = QApplication::style()->objectName(); } else { - int index = ui->gstylecombo->findText(currentstyle, Qt::MatchFixedString); + int index = ui->guiStyleCombo->findText(currentstyle, Qt::MatchFixedString); if (index != -1) { - ui->gstylecombo->setCurrentIndex(index); + ui->guiStyleCombo->setCurrentIndex(index); } else { // we give up - ui->gstylecombo->addItem(tr("Unknown")); - ui->gstylecombo->setCurrentIndex(ui->gstylecombo->count() - 1); + ui->guiStyleCombo->addItem(tr("Unknown")); + ui->guiStyleCombo->setCurrentIndex(ui->guiStyleCombo->count() - 1); } } ui->buttonMainColor->setColor(palette().color(QPalette::Active, QPalette::Button)); @@ -262,11 +262,11 @@ MainWindow::MainWindow() if (X11->desktopEnvironment == DE_KDE) ui->colorConfig->hide(); else - ui->labelKDENote->hide(); + ui->kdeNoteLabel->hide(); QFontDatabase db; QStringList families = db.families(); - ui->familycombo->addItems(families); + ui->fontFamilyCombo->addItems(families); QStringList fs = families; QStringList fs2 = QFont::substitutions(); @@ -277,41 +277,41 @@ MainWindow::MainWindow() fsit++; } fs.sort(); - ui->familysubcombo->addItems(fs); + ui->familySubstitutionCombo->addItems(fs); - ui->choosesubcombo->addItems(families); + ui->chooseSubstitutionCombo->addItems(families); QList sizes = db.standardSizes(); foreach(int i, sizes) - ui->psizecombo->addItem(QString::number(i)); + ui->pointSizeCombo->addItem(QString::number(i)); - ui->dcispin->setValue(QApplication::doubleClickInterval()); - ui->cfispin->setValue(QApplication::cursorFlashTime()); - ui->wslspin->setValue(QApplication::wheelScrollLines()); + ui->doubleClickIntervalSpinBox->setValue(QApplication::doubleClickInterval()); + ui->cursorFlashTimeSpinBox->setValue(QApplication::cursorFlashTime()); + ui->wheelScrollLinesSpinBox->setValue(QApplication::wheelScrollLines()); // ############# -// resolvelinks->setChecked(qt_resolve_symlinks); +// resolveLinksCheckBox->setChecked(qt_resolve_symlinks); - ui->effectcheckbox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); - ui->effectbase->setEnabled(ui->effectcheckbox->isChecked()); + ui->effectsCheckBox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); + ui->effectsFrame->setEnabled(ui->effectsCheckBox->isChecked()); if (QApplication::isEffectEnabled(Qt::UI_FadeMenu)) - ui->menueffect->setCurrentIndex(2); + ui->menuEffectCombo->setCurrentIndex(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) - ui->menueffect->setCurrentIndex(1); + ui->menuEffectCombo->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo)) - ui->comboeffect->setCurrentIndex(1); + ui->comboEffectCombo->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)) - ui->tooltipeffect->setCurrentIndex(2); + ui->toolTipEffectCombo->setCurrentIndex(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)) - ui->tooltipeffect->setCurrentIndex(1); + ui->toolTipEffectCombo->setCurrentIndex(1); if (QApplication::isEffectEnabled(Qt::UI_AnimateToolBox)) - ui->toolboxeffect->setCurrentIndex(1); + ui->toolBoxEffectCombo->setCurrentIndex(1); QSize globalStrut = QApplication::globalStrut(); - ui->strutwidth->setValue(globalStrut.width()); - ui->strutheight->setValue(globalStrut.height()); + ui->strutWidthSpinBox->setValue(globalStrut.width()); + ui->strutHeightSpinBox->setValue(globalStrut.height()); // find the default family QStringList::Iterator sit = families.begin(); @@ -330,10 +330,10 @@ MainWindow::MainWindow() if (i == -1) // no clue about the current font i = 0; - ui->familycombo->setCurrentIndex(i); + ui->fontFamilyCombo->setCurrentIndex(i); - QStringList styles = db.styles(ui->familycombo->currentText()); - ui->stylecombo->addItems(styles); + QStringList styles = db.styles(ui->fontFamilyCombo->currentText()); + ui->fontStyleCombo->addItems(styles); QString stylestring = db.styleString(QApplication::font()); sit = styles.begin(); @@ -352,64 +352,64 @@ MainWindow::MainWindow() i = possible; if (i == -1) // no clue about the current font i = 0; - ui->stylecombo->setCurrentIndex(i); + ui->fontStyleCombo->setCurrentIndex(i); i = 0; - for (int psize = QApplication::font().pointSize(); i < ui->psizecombo->count(); ++i) { - const int sz = ui->psizecombo->itemText(i).toInt(); + for (int psize = QApplication::font().pointSize(); i < ui->pointSizeCombo->count(); ++i) { + const int sz = ui->pointSizeCombo->itemText(i).toInt(); if (sz == psize) { - ui->psizecombo->setCurrentIndex(i); + ui->pointSizeCombo->setCurrentIndex(i); break; } else if(sz > psize) { - ui->psizecombo->insertItem(i, QString::number(psize)); - ui->psizecombo->setCurrentIndex(i); + ui->pointSizeCombo->insertItem(i, QString::number(psize)); + ui->pointSizeCombo->setCurrentIndex(i); break; } } - QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); - ui->sublistbox->clear(); - ui->sublistbox->insertItems(0, subs); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); - ui->rtlExtensions->setChecked(settings.value(QLatin1String("useRtlExtensions"), false) - .toBool()); + ui->rtlExtensionsCheckBox->setChecked(settings.value(QLatin1String("useRtlExtensions"), false) + .toBool()); #ifdef Q_WS_X11 QString settingsInputStyle = settings.value(QLatin1String("XIMInputStyle")).toString(); if (!settingsInputStyle.isEmpty()) - ui->inputStyle->setCurrentIndex(ui->inputStyle->findText(settingsInputStyle)); + ui->inputStyleCombo->setCurrentIndex(ui->inputStyleCombo->findText(settingsInputStyle)); #else - ui->inputStyle->hide(); - ui->inputStyleLabel->hide(); + ui->inputStyleCombo->hide(); + ui->inputStyleComboLabel->hide(); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) - QStringList inputMethods = QInputContextFactory::keys(); - int inputMethodIndex = -1; + QStringList inputMethodCombo = QInputContextFactory::keys(); + int inputMethodComboIndex = -1; QString defaultInputMethod = settings.value(QLatin1String("DefaultInputMethod"), QLatin1String("xim")).toString(); - for (int i = inputMethods.size()-1; i >= 0; --i) { - const QString &im = inputMethods.at(i); + for (int i = inputMethodCombo.size()-1; i >= 0; --i) { + const QString &im = inputMethodCombo.at(i); if (im.contains(QLatin1String("imsw"))) { - inputMethods.removeAt(i); - if (inputMethodIndex > i) - --inputMethodIndex; + inputMethodCombo.removeAt(i); + if (inputMethodComboIndex > i) + --inputMethodComboIndex; } else if (im == defaultInputMethod) { - inputMethodIndex = i; + inputMethodComboIndex = i; } } - if (inputMethodIndex == -1 && !inputMethods.isEmpty()) - inputMethodIndex = 0; - ui->inputMethod->addItems(inputMethods); - ui->inputMethod->setCurrentIndex(inputMethodIndex); + if (inputMethodComboIndex == -1 && !inputMethodCombo.isEmpty()) + inputMethodComboIndex = 0; + ui->inputMethodCombo->addItems(inputMethodCombo); + ui->inputMethodCombo->setCurrentIndex(inputMethodComboIndex); #else - ui->inputMethod->hide(); - ui->inputMethodLabel->hide(); + ui->inputMethodCombo->hide(); + ui->inputMethodComboLabel->hide(); #endif - ui->fontembeddingcheckbox->setChecked(settings.value(QLatin1String("embedFonts"), true) + ui->fontEmbeddingCheckBox->setChecked(settings.value(QLatin1String("embedFonts"), true) .toBool()); fontpaths = settings.value(QLatin1String("fontPath")).toStringList(); - ui->fontpathlistbox->insertItems(0, fontpaths); + ui->fontpathListBox->insertItems(0, fontpaths); ui->audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(tr("Auto (default)")), @@ -424,7 +424,7 @@ MainWindow::MainWindow() #ifndef QT_NO_GSTREAMER if (gst_init_check(0, 0, 0)) { gchar *versionString = gst_version_string(); - ui->gstversionLabel->setText(QLatin1String(versionString)); + ui->gstVersionLabel->setText(QLatin1String(versionString)); g_free(versionString); GList *factoryList = gst_registry_get_feature_list(gst_registry_get_default(), GST_TYPE_ELEMENT_FACTORY); @@ -451,7 +451,7 @@ MainWindow::MainWindow() g_list_free(factoryList); } #else - ui->tab4->setEnabled(false); + ui->phononTab->setEnabled(false); ui->phononLabel->setText(tr("Phonon GStreamer backend not available.")); #endif @@ -484,7 +484,7 @@ MainWindow::MainWindow() settings.endGroup(); // Qt - ui->helpview->setText(tr(appearance_text)); + ui->helpView->setText(tr(appearance_text)); setModified(false); updateStyleLayout(); @@ -512,12 +512,12 @@ void MainWindow::fileSave() QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QFontDatabase db; - QFont font = db.font(ui->familycombo->currentText(), - ui->stylecombo->currentText(), - ui->psizecombo->currentText().toInt()); + QFont font = db.font(ui->fontFamilyCombo->currentText(), + ui->fontStyleCombo->currentText(), + ui->pointSizeCombo->currentText().toInt()); QStringList actcg, inactcg, discg; - bool overrideDesktopSettings = (ui->gstylecombo->currentText() != desktopThemeName); + bool overrideDesktopSettings = (ui->guiStyleCombo->currentText() != desktopThemeName); if (overrideDesktopSettings) { int i; for (i = 0; i < QPalette::NColorRoles; i++) @@ -537,24 +537,24 @@ void MainWindow::fileSave() settings.setValue(QLatin1String("Palette/disabled"), discg); settings.setValue(QLatin1String("fontPath"), fontpaths); - settings.setValue(QLatin1String("embedFonts"), ui->fontembeddingcheckbox->isChecked()); + settings.setValue(QLatin1String("embedFonts"), ui->fontEmbeddingCheckBox->isChecked()); settings.setValue(QLatin1String("style"), - overrideDesktopSettings ? ui->gstylecombo->currentText() : QString()); + overrideDesktopSettings ? ui->guiStyleCombo->currentText() : QString()); - settings.setValue(QLatin1String("doubleClickInterval"), ui->dcispin->value()); + settings.setValue(QLatin1String("doubleClickInterval"), ui->doubleClickIntervalSpinBox->value()); settings.setValue(QLatin1String("cursorFlashTime"), - ui->cfispin->value() == 9 ? 0 : ui->cfispin->value()); - settings.setValue(QLatin1String("wheelScrollLines"), ui->wslspin->value()); - settings.setValue(QLatin1String("resolveSymlinks"), ui->resolvelinks->isChecked()); + ui->cursorFlashTimeSpinBox->value() == 9 ? 0 : ui->cursorFlashTimeSpinBox->value()); + settings.setValue(QLatin1String("wheelScrollLines"), ui->wheelScrollLinesSpinBox->value()); + settings.setValue(QLatin1String("resolveSymlinks"), ui->resolveLinksCheckBox->isChecked()); - QSize strut(ui->strutwidth->value(), ui->strutheight->value()); + QSize strut(ui->strutWidthSpinBox->value(), ui->strutHeightSpinBox->value()); settings.setValue(QLatin1String("globalStrut/width"), strut.width()); settings.setValue(QLatin1String("globalStrut/height"), strut.height()); - settings.setValue(QLatin1String("useRtlExtensions"), ui->rtlExtensions->isChecked()); + settings.setValue(QLatin1String("useRtlExtensions"), ui->rtlExtensionsCheckBox->isChecked()); #ifdef Q_WS_X11 - QString style = ui->inputStyle->currentText(); + QString style = ui->inputStyleCombo->currentText(); QString str = QLatin1String("On The Spot"); if (style == tr("Over The Spot")) str = QLatin1String("Over The Spot"); @@ -565,7 +565,7 @@ void MainWindow::fileSave() settings.setValue(QLatin1String("XIMInputStyle"), str); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) - settings.setValue(QLatin1String("DefaultInputMethod"), ui->inputMethod->currentText()); + settings.setValue(QLatin1String("DefaultInputMethod"), ui->inputMethodCombo->currentText()); #endif QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); @@ -576,24 +576,24 @@ void MainWindow::fileSave() ui->videomodeCombo->itemData(ui->videomodeCombo->currentIndex())); QStringList effects; - if (ui->effectcheckbox->isChecked()) { + if (ui->effectsCheckBox->isChecked()) { effects << QLatin1String("general"); - switch (ui->menueffect->currentIndex()) { + switch (ui->menuEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatemenu"); break; case 2: effects << QLatin1String("fademenu"); break; } - switch (ui->comboeffect->currentIndex()) { + switch (ui->comboEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatecombo"); break; } - switch (ui->tooltipeffect->currentIndex()) { + switch (ui->toolTipEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatetooltip"); break; case 2: effects << QLatin1String("fadetooltip"); break; } - switch (ui->toolboxeffect->currentIndex()) { + switch (ui->toolBoxEffectCombo->currentIndex()) { case 1: effects << QLatin1String("animatetoolbox"); break; } } else @@ -688,10 +688,10 @@ void MainWindow::paletteSelected(int) void MainWindow::updateStyleLayout() { - QString currentStyle = ui->gstylecombo->currentText(); + QString currentStyle = ui->guiStyleCombo->currentText(); bool autoStyle = (currentStyle == desktopThemeName); ui->previewFrame->setPreviewVisible(!autoStyle); - ui->groupAutoPalette->setEnabled(currentStyle.toLower() != QLatin1String("gtk") && !autoStyle); + ui->buildPaletteGroup->setEnabled(currentStyle.toLower() != QLatin1String("gtk") && !autoStyle); } void MainWindow::styleSelected(const QString &stylename) @@ -715,170 +715,170 @@ void MainWindow::familySelected(const QString &family) { QFontDatabase db; QStringList styles = db.styles(family); - ui->stylecombo->clear(); - ui->stylecombo->addItems(styles); - ui->familysubcombo->addItem(family); + ui->fontStyleCombo->clear(); + ui->fontStyleCombo->addItems(styles); + ui->familySubstitutionCombo->addItem(family); buildFont(); } void MainWindow::buildFont() { QFontDatabase db; - QFont font = db.font(ui->familycombo->currentText(), - ui->stylecombo->currentText(), - ui->psizecombo->currentText().toInt()); - ui->samplelineedit->setFont(font); + QFont font = db.font(ui->fontFamilyCombo->currentText(), + ui->fontStyleCombo->currentText(), + ui->pointSizeCombo->currentText().toInt()); + ui->sampleLineEdit->setFont(font); setModified(true); } void MainWindow::substituteSelected(const QString &family) { QStringList subs = QFont::substitutes(family); - ui->sublistbox->clear(); - ui->sublistbox->insertItems(0, subs); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); } void MainWindow::removeSubstitute() { - if (!ui->sublistbox->currentItem()) + if (!ui->substitutionsListBox->currentItem()) return; - int row = ui->sublistbox->currentRow(); - QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); - subs.removeAt(ui->sublistbox->currentRow()); - ui->sublistbox->clear(); - ui->sublistbox->insertItems(0, subs); - if (row > ui->sublistbox->count()) - row = ui->sublistbox->count() - 1; - ui->sublistbox->setCurrentRow(row); - QFont::removeSubstitution(ui->familysubcombo->currentText()); - QFont::insertSubstitutions(ui->familysubcombo->currentText(), subs); + int row = ui->substitutionsListBox->currentRow(); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + subs.removeAt(ui->substitutionsListBox->currentRow()); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); + if (row > ui->substitutionsListBox->count()) + row = ui->substitutionsListBox->count() - 1; + ui->substitutionsListBox->setCurrentRow(row); + QFont::removeSubstitution(ui->familySubstitutionCombo->currentText()); + QFont::insertSubstitutions(ui->familySubstitutionCombo->currentText(), subs); setModified(true); } void MainWindow::addSubstitute() { - if (!ui->sublistbox->currentItem()) { - QFont::insertSubstitution(ui->familysubcombo->currentText(), - ui->choosesubcombo->currentText()); - QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); - ui->sublistbox->clear(); - ui->sublistbox->insertItems(0, subs); + if (!ui->substitutionsListBox->currentItem()) { + QFont::insertSubstitution(ui->familySubstitutionCombo->currentText(), + ui->chooseSubstitutionCombo->currentText()); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); setModified(true); return; } - int row = ui->sublistbox->currentRow(); - QFont::insertSubstitution(ui->familysubcombo->currentText(), ui->choosesubcombo->currentText()); - QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); - ui->sublistbox->clear(); - ui->sublistbox->insertItems(0, subs); - ui->sublistbox->setCurrentRow(row); + int row = ui->substitutionsListBox->currentRow(); + QFont::insertSubstitution(ui->familySubstitutionCombo->currentText(), ui->chooseSubstitutionCombo->currentText()); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); + ui->substitutionsListBox->setCurrentRow(row); setModified(true); } void MainWindow::downSubstitute() { - if (!ui->sublistbox->currentItem() || ui->sublistbox->currentRow() >= ui->sublistbox->count()) + if (!ui->substitutionsListBox->currentItem() || ui->substitutionsListBox->currentRow() >= ui->substitutionsListBox->count()) return; - int row = ui->sublistbox->currentRow(); - QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); + int row = ui->substitutionsListBox->currentRow(); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); QString fam = subs.at(row); subs.removeAt(row); subs.insert(row + 1, fam); - ui->sublistbox->clear(); - ui->sublistbox->insertItems(0, subs); - ui->sublistbox->setCurrentRow(row + 1); - QFont::removeSubstitution(ui->familysubcombo->currentText()); - QFont::insertSubstitutions(ui->familysubcombo->currentText(), subs); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); + ui->substitutionsListBox->setCurrentRow(row + 1); + QFont::removeSubstitution(ui->familySubstitutionCombo->currentText()); + QFont::insertSubstitutions(ui->familySubstitutionCombo->currentText(), subs); setModified(true); } void MainWindow::upSubstitute() { - if (!ui->sublistbox->currentItem() || ui->sublistbox->currentRow() < 1) + if (!ui->substitutionsListBox->currentItem() || ui->substitutionsListBox->currentRow() < 1) return; - int row = ui->sublistbox->currentRow(); - QStringList subs = QFont::substitutes(ui->familysubcombo->currentText()); + int row = ui->substitutionsListBox->currentRow(); + QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); QString fam = subs.at(row); subs.removeAt(row); subs.insert(row-1, fam); - ui->sublistbox->clear(); - ui->sublistbox->insertItems(0, subs); - ui->sublistbox->setCurrentRow(row - 1); - QFont::removeSubstitution(ui->familysubcombo->currentText()); - QFont::insertSubstitutions(ui->familysubcombo->currentText(), subs); + ui->substitutionsListBox->clear(); + ui->substitutionsListBox->insertItems(0, subs); + ui->substitutionsListBox->setCurrentRow(row - 1); + QFont::removeSubstitution(ui->familySubstitutionCombo->currentText()); + QFont::insertSubstitutions(ui->familySubstitutionCombo->currentText(), subs); setModified(true); } void MainWindow::removeFontpath() { - if (!ui->fontpathlistbox->currentItem()) + if (!ui->fontpathListBox->currentItem()) return; - int row = ui->fontpathlistbox->currentRow(); + int row = ui->fontpathListBox->currentRow(); fontpaths.removeAt(row); - ui->fontpathlistbox->clear(); - ui->fontpathlistbox->insertItems(0, fontpaths); - if (row > ui->fontpathlistbox->count()) - row = ui->fontpathlistbox->count() - 1; - ui->fontpathlistbox->setCurrentRow(row); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); + if (row > ui->fontpathListBox->count()) + row = ui->fontpathListBox->count() - 1; + ui->fontpathListBox->setCurrentRow(row); setModified(true); } void MainWindow::addFontpath() { - if (ui->fontpathlineedit->text().isEmpty()) + if (ui->fontPathLineEdit->text().isEmpty()) return; - if (!ui->fontpathlistbox->currentItem()) { - fontpaths.append(ui->fontpathlineedit->text()); - ui->fontpathlistbox->clear(); - ui->fontpathlistbox->insertItems(0, fontpaths); + if (!ui->fontpathListBox->currentItem()) { + fontpaths.append(ui->fontPathLineEdit->text()); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); setModified(true); return; } - int row = ui->fontpathlistbox->currentRow(); - fontpaths.insert(row + 1, ui->fontpathlineedit->text()); - ui->fontpathlistbox->clear(); - ui->fontpathlistbox->insertItems(0, fontpaths); - ui->fontpathlistbox->setCurrentRow(row); + int row = ui->fontpathListBox->currentRow(); + fontpaths.insert(row + 1, ui->fontPathLineEdit->text()); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); + ui->fontpathListBox->setCurrentRow(row); setModified(true); } void MainWindow::downFontpath() { - if (!ui->fontpathlistbox->currentItem() - || ui->fontpathlistbox->currentRow() >= (ui->fontpathlistbox->count() - 1)) { + if (!ui->fontpathListBox->currentItem() + || ui->fontpathListBox->currentRow() >= (ui->fontpathListBox->count() - 1)) { return; } - int row = ui->fontpathlistbox->currentRow(); + int row = ui->fontpathListBox->currentRow(); QString fam = fontpaths.at(row); fontpaths.removeAt(row); fontpaths.insert(row + 1, fam); - ui->fontpathlistbox->clear(); - ui->fontpathlistbox->insertItems(0, fontpaths); - ui->fontpathlistbox->setCurrentRow(row + 1); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); + ui->fontpathListBox->setCurrentRow(row + 1); setModified(true); } void MainWindow::upFontpath() { - if (!ui->fontpathlistbox->currentItem() || ui->fontpathlistbox->currentRow() < 1) + if (!ui->fontpathListBox->currentItem() || ui->fontpathListBox->currentRow() < 1) return; - int row = ui->fontpathlistbox->currentRow(); + int row = ui->fontpathListBox->currentRow(); QString fam = fontpaths.at(row); fontpaths.removeAt(row); fontpaths.insert(row - 1, fam); - ui->fontpathlistbox->clear(); - ui->fontpathlistbox->insertItems(0, fontpaths); - ui->fontpathlistbox->setCurrentRow(row - 1); + ui->fontpathListBox->clear(); + ui->fontpathListBox->insertItems(0, fontpaths); + ui->fontpathListBox->setCurrentRow(row - 1); setModified(true); } @@ -888,7 +888,7 @@ void MainWindow::browseFontpath() if (dirname.isNull()) return; - ui->fontpathlineedit->setText(dirname); + ui->fontPathLineEdit->setText(dirname); } void MainWindow::somethingModified() @@ -915,16 +915,16 @@ void MainWindow::helpAboutQt() void MainWindow::pageChanged(QWidget *page) { - if (page == ui->tab) - ui->helpview->setText(tr(interface_text)); - else if (page == ui->tab1) - ui->helpview->setText(tr(appearance_text)); - else if (page == ui->tab2) - ui->helpview->setText(tr(font_text)); - else if (page == ui->tab3) - ui->helpview->setText(tr(printer_text)); - else if (page == ui->tab4) - ui->helpview->setText(tr(phonon_text)); + if (page == ui->interfaceTab) + ui->helpView->setText(tr(interface_text)); + else if (page == ui->appearanceTab) + ui->helpView->setText(tr(appearance_text)); + else if (page == ui->fontsTab) + ui->helpView->setText(tr(font_text)); + else if (page == ui->printerTab) + ui->helpView->setText(tr(printer_text)); + else if (page == ui->phononTab) + ui->helpView->setText(tr(phonon_text)); } void MainWindow::closeEvent(QCloseEvent *e) diff --git a/tools/qtconfig/mainwindow.ui b/tools/qtconfig/mainwindow.ui index 117a777..2ca9101 100644 --- a/tools/qtconfig/mainwindow.ui +++ b/tools/qtconfig/mainwindow.ui @@ -59,7 +59,7 @@ 8 - + 200 @@ -72,17 +72,17 @@ - + 0 - + Appearance - + 0 @@ -106,7 +106,7 @@ 8 - + 0 @@ -117,18 +117,18 @@ Select GUI &Style: - gstylecombo + guiStyleCombo - + - + 0 @@ -140,7 +140,7 @@ - + Select &Palette: @@ -188,7 +188,7 @@ - + 0 @@ -278,7 +278,7 @@ - + &Tune Palette... @@ -288,7 +288,7 @@ - + Please use the KDE Control Center to set the palette. @@ -299,13 +299,13 @@ - + Fonts - + Default Font @@ -317,7 +317,7 @@ 4 - + true @@ -327,7 +327,7 @@ - + true @@ -337,7 +337,7 @@ - + true @@ -350,37 +350,37 @@ - + &Style: - stylecombo + fontStyleCombo - + &Point Size: - psizecombo + pointSizeCombo - + F&amily: - familycombo + fontFamilyCombo - + Sample Text @@ -393,7 +393,7 @@ - + Font Substitution @@ -413,17 +413,17 @@ 0 - + S&elect or Enter a Family: - familysubcombo + familySubstitutionCombo - + true @@ -451,14 +451,14 @@ - + Current Substitutions: - + @@ -469,21 +469,21 @@ 0 - + Up - + Down - + Remove @@ -513,17 +513,17 @@ 0 - + Select s&ubstitute Family: - choosesubcombo + chooseSubstitutionCombo - + true @@ -533,7 +533,7 @@ - + Add @@ -546,13 +546,13 @@ - + Interface - + Feel Settings @@ -564,7 +564,7 @@ 4 - + ms @@ -577,17 +577,17 @@ - + &Double Click Interval: - dcispin + doubleClickIntervalSpinBox - + No blinking @@ -603,17 +603,17 @@ - + &Cursor Flash Time: - cfispin + cursorFlashTimeSpinBox - + lines @@ -626,17 +626,17 @@ - + Wheel &Scroll Lines: - wslspin + wheelScrollLinesSpinBox - + Resolve symlinks in URLs @@ -646,7 +646,7 @@ - + GUI Effects @@ -658,7 +658,7 @@ 8 - + &Enable @@ -668,53 +668,53 @@ - + 4 - + &Menu Effect: - menueffect + menuEffectCombo - + C&omboBox Effect: - comboeffect + comboEffectCombo - + &ToolTip Effect: - tooltipeffect + toolTipEffectCombo - + Tool&Box Effect: - toolboxeffect + toolBoxEffectCombo - + 0 @@ -739,7 +739,7 @@ - + Disable @@ -753,7 +753,7 @@ - + Disable @@ -772,7 +772,7 @@ - + Disable @@ -792,7 +792,7 @@ - + Global Strut @@ -804,27 +804,27 @@ 4 - + Minimum &Width: - strutwidth + strutWidthSpinBox - + Minimum Hei&ght: - strutheight + strutHeightSpinBox - + pixels @@ -834,7 +834,7 @@ - + pixels @@ -847,7 +847,7 @@ - + Enhanced support for languages written right-to-left @@ -861,7 +861,7 @@ - + 0 @@ -895,7 +895,7 @@ - + -1 @@ -919,13 +919,13 @@ - + Printer - + Enable Font embedding @@ -935,7 +935,7 @@ - + 0 @@ -961,28 +961,28 @@ 4 - + Up - + Remove - + Down - + @@ -1011,28 +1011,28 @@ - + Add - + Browse... - + Press the <b>Browse</b> button or enter a directory and press Enter to add them to the list. - + @@ -1041,19 +1041,19 @@ - + Phonon - + About Phonon - + Current Version: @@ -1067,20 +1067,16 @@ - + Website: - + - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://phonon.kde.org"><span style=" text-decoration: underline; color:#0000ff;">http://phonon.kde.org</span></a></p></body></html> + <a href="http://phonon.kde.org">http://phonon.kde.org/</a> true @@ -1091,40 +1087,36 @@ p, li { white-space: pre-wrap; } - + About GStreamer - + Current Version: - + Not available - + Website: - + - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://gstreamer.freedesktop.org/"><span style=" text-decoration: underline; color:#0000ff;">http://gstreamer.freedesktop.org/</span></a></p></body></html> + <a href="http://gstreamer.freedesktop.org/">http://gstreamer.freedesktop.org/</a> true @@ -1135,13 +1127,13 @@ p, li { white-space: pre-wrap; } - + GStreamer backend settings - + Preferred audio sink: @@ -1154,7 +1146,7 @@ p, li { white-space: pre-wrap; } - + Preferred render method: @@ -1167,7 +1159,7 @@ p, li { white-space: pre-wrap; } - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> @@ -1218,7 +1210,7 @@ p, li { white-space: pre-wrap; } - + 0 @@ -1227,7 +1219,7 @@ p, li { white-space: pre-wrap; } 19 - + 203 @@ -1243,11 +1235,11 @@ p, li { white-space: pre-wrap; } - + - 234 - 115 + 543 + 98 161 106 @@ -1258,9 +1250,9 @@ p, li { white-space: pre-wrap; } - + - + @@ -1317,34 +1309,53 @@ p, li { white-space: pre-wrap; } - helpview - familycombo - stylecombo - psizecombo - samplelineedit - familysubcombo - PushButton2 - PushButton3 - PushButton4 - choosesubcombo - PushButton1 - dcispin - cfispin - wslspin - effectcheckbox - menueffect - comboeffect - tooltipeffect - strutwidth - strutheight - sublistbox + helpView + mainTabWidget + guiStyleCombo + tunePaletteButton + paletteCombo + fontFamilyCombo + fontStyleCombo + pointSizeCombo + sampleLineEdit + familySubstitutionCombo + substitutionsListBox + upSubstitutionButton + downSubstitutionButton + removeSubstitutionButton + chooseSubstitutionCombo + addSubstitutionButton + doubleClickIntervalSpinBox + cursorFlashTimeSpinBox + wheelScrollLinesSpinBox + resolveLinksCheckBox + effectsCheckBox + menuEffectCombo + comboEffectCombo + toolTipEffectCombo + toolBoxEffectCombo + strutWidthSpinBox + strutHeightSpinBox + rtlExtensionsCheckBox + inputStyleCombo + inputMethodCombo + fontEmbeddingCheckBox + fontpathListBox + upFontpathButton + downFontpathButton + removeFontpathButton + fontPathLineEdit + browseFontPathButton + addFontPathButton + audiosinkCombo + videomodeCombo - effectcheckbox + effectsCheckBox toggled(bool) - effectbase + effectsFrame setEnabled(bool) @@ -1358,9 +1369,9 @@ p, li { white-space: pre-wrap; } - fontembeddingcheckbox + fontEmbeddingCheckBox toggled(bool) - GroupBox10 + fontPathsGroup setEnabled(bool) -- cgit v0.12 From 114be749e8bb82291cd3cc02dd85d56a3759853f Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:42 +0200 Subject: Resolved a little code style issue in qtconfig Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/mainwindow.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 266d9e4..9ff2087 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -181,7 +181,9 @@ static void setStyleHelper(QWidget *w, QStyle *s) } MainWindow::MainWindow() - : QMainWindow(), ui(new Ui::MainWindow), editPalette(palette()), previewPalette(palette()), + : ui(new Ui::MainWindow), + editPalette(palette()), + previewPalette(palette()), previewstyle(0) { ui->setupUi(this); -- cgit v0.12 From 255c512d7f536573963f371cdd73be0c4bd169b9 Mon Sep 17 00:00:00 2001 From: Boris Moiseev Date: Wed, 6 Oct 2010 15:51:43 +0200 Subject: Fixed the build error in qtconfig qtconfig failed to build with Phonon gstreamer backend turned on Merge-request: 2286 Reviewed-by: Benjamin Poulain --- tools/qtconfig/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 9ff2087..2536275 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -444,7 +444,7 @@ MainWindow::MainWindow() if (sink) { description = QLatin1String(gst_element_factory_get_description(GST_ELEMENT_FACTORY(feature))); ui->audiosinkCombo->addItem(name, name); - ui->audiosinkCombo->setItemData(audiosinkCombo->findText(name), description, + ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(name), description, Qt::ToolTipRole); gst_object_unref (sink); } -- cgit v0.12 From a9a35d40f14751d0d9a0c82696c4b5cd0090bbea Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Wed, 6 Oct 2010 15:46:33 +0200 Subject: Doc: fix description of the expected behavior for QGraphicsItem::cursor It was fixed for setCursor in 600ff0193c9bfac4d2b40960766002e8b81aca22. Reviewed-by: Alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index fc44a44..60cd020 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2125,7 +2125,7 @@ void QGraphicsItem::setToolTip(const QString &toolTip) \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 2 - If no cursor has been set, the parent's cursor is used. + If no cursor has been set, the cursor of the item beneath is used. \sa setCursor(), hasCursor(), unsetCursor(), QWidget::cursor, QApplication::overrideCursor() -- cgit v0.12 From 311170a69e61fdd0fa4c302ec9ceb33df2c49a5d Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Wed, 6 Oct 2010 16:46:43 +0200 Subject: Fix a pending issue with the merge request 2286 A merge conflict was forgoten in the last update. This patch fixes that. --- tools/qtconfig/mainwindow.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 2536275..5bd3592 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -466,14 +466,9 @@ MainWindow::MainWindow() tr("Use X11 Overlays"), Qt::ToolTipRole); #endif #ifndef QT_NO_OPENGL -<<<<<<< HEAD - videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); - videomodeCombo->setItemData(videomodeCombo->findText(tr("OpenGL")), tr("Use OpenGL if available"), Qt::ToolTipRole); -======= ui->videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("OpenGL")), - tr("Use OpenGL if avaiable"), Qt::ToolTipRole); ->>>>>>> Removed inheritance from UI file in qtconfig's MainWindow + tr("Use OpenGL if available"), Qt::ToolTipRole); #endif ui->videomodeCombo->addItem(tr("Software"), QLatin1String("Software")); ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("Software")), -- cgit v0.12 From d0dc82056231d40978e3369f2f4910298560bf98 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Wed, 6 Oct 2010 17:01:14 +0200 Subject: Code cleaning with the merge request 2286 The merge request 2286 changes a lot of the QtConfig tool. I took this opportunity to clean some old style mistake. --- tools/qtconfig/colorbutton.cpp | 9 +++++---- tools/qtconfig/mainwindow.cpp | 2 +- tools/qtconfig/paletteeditoradvanced.cpp | 9 +++------ tools/qtconfig/previewwidget.h | 2 +- tools/qtconfig/qtconfig.pro | 10 +++++----- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/tools/qtconfig/colorbutton.cpp b/tools/qtconfig/colorbutton.cpp index 30617e4..443effa 100644 --- a/tools/qtconfig/colorbutton.cpp +++ b/tools/qtconfig/colorbutton.cpp @@ -52,19 +52,20 @@ QT_BEGIN_NAMESPACE ColorButton::ColorButton(QWidget *parent) - : QAbstractButton(parent), mousepressed(false) + : QAbstractButton(parent) + , mousepressed(false) + , col(Qt::black) { setAcceptDrops(true); - col = Qt::black; connect(this, SIGNAL(clicked()), SLOT(changeColor())); } ColorButton::ColorButton(const QColor &c, QWidget *parent) : QAbstractButton(parent) + , col(c) { setAcceptDrops(true); - col = c; connect(this, SIGNAL(clicked()), SLOT(changeColor())); } @@ -182,7 +183,7 @@ void ColorButton::mouseReleaseEvent(QMouseEvent *e) void ColorButton::mouseMoveEvent(QMouseEvent *e) { - if (! mousepressed) + if (!mousepressed) return; if ((presspos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 5bd3592..1a30405 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -290,7 +290,7 @@ MainWindow::MainWindow() ui->cursorFlashTimeSpinBox->setValue(QApplication::cursorFlashTime()); ui->wheelScrollLinesSpinBox->setValue(QApplication::wheelScrollLines()); // ############# -// resolveLinksCheckBox->setChecked(qt_resolve_symlinks); + // resolveLinksCheckBox->setChecked(qt_resolve_symlinks); ui->effectsCheckBox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); ui->effectsFrame->setEnabled(ui->effectsCheckBox->isChecked()); diff --git a/tools/qtconfig/paletteeditoradvanced.cpp b/tools/qtconfig/paletteeditoradvanced.cpp index 196cdea..a700b8d 100644 --- a/tools/qtconfig/paletteeditoradvanced.cpp +++ b/tools/qtconfig/paletteeditoradvanced.cpp @@ -117,12 +117,10 @@ void PaletteEditorAdvanced::paletteSelected(int p) if(p == 1) { // inactive ui->groupCentral->setDisabled(ui->checkBuildInactive->isChecked()); ui->groupEffect->setDisabled(ui->checkBuildInactive->isChecked()); - } - else if (p == 2) { // disabled + } else if (p == 2) { // disabled ui->groupCentral->setDisabled(ui->checkBuildDisabled->isChecked()); ui->groupEffect->setDisabled(ui->checkBuildDisabled->isChecked()); - } - else { + } else { ui->groupCentral->setEnabled(true); ui->groupEffect->setEnabled(true); } @@ -263,8 +261,7 @@ QPalette PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup colorGroup, result.setColor(colorGroup, effectRole, calculatedPalette.color(colorGroup, effectRole)); } - } - else { + } else { QColor btn = basePalette.color(colorGroup, QPalette::Button); result.setColor(colorGroup, QPalette::Light, btn.lighter()); diff --git a/tools/qtconfig/previewwidget.h b/tools/qtconfig/previewwidget.h index ee3513d..f3e5f71 100644 --- a/tools/qtconfig/previewwidget.h +++ b/tools/qtconfig/previewwidget.h @@ -61,7 +61,7 @@ public: bool eventFilter(QObject *, QEvent *); private: void closeEvent(QCloseEvent *); - Ui::PreviewWidget* ui; + Ui::PreviewWidget *ui; }; QT_END_NAMESPACE diff --git a/tools/qtconfig/qtconfig.pro b/tools/qtconfig/qtconfig.pro index a066d4e..cb06e5a 100644 --- a/tools/qtconfig/qtconfig.pro +++ b/tools/qtconfig/qtconfig.pro @@ -1,5 +1,5 @@ TEMPLATE = app -CONFIG += qt warn_on x11 +CONFIG += qt warn_on x11 build_all:!build_pass { CONFIG -= build_all CONFIG += release @@ -19,10 +19,10 @@ FORMS = mainwindow.ui paletteeditoradvanced.ui previewwidget.ui RESOURCES = qtconfig.qrc PROJECTNAME = Qt Configuration -TARGET = qtconfig -DESTDIR = ../../bin +TARGET = qtconfig +DESTDIR = ../../bin target.path=$$[QT_INSTALL_BINS] INSTALLS += target -INCLUDEPATH += . -DBFILE = qtconfig.db +INCLUDEPATH += . +DBFILE = qtconfig.db -- cgit v0.12 From 9c46cde0ca27bf5edc05046b84096379d46dca33 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 7 Oct 2010 10:26:25 +0200 Subject: Fix compilation after merge request 2286 --- tools/qtconfig/mainwindow.cpp | 2 +- tools/qtconfig/mainwindow.h | 8 ++++---- tools/qtconfig/paletteeditoradvanced.h | 4 ++-- tools/qtconfig/previewwidget.h | 3 ++- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index 1a30405..f07da4f 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -421,7 +421,7 @@ MainWindow::MainWindow() tr("Experimental aRts support for GStreamer."), Qt::ToolTipRole); #ifdef HAVE_PHONON - phononVersionLabel->setText(QLatin1String(Phonon::phononVersion())); + ui->phononVersionLabel->setText(QLatin1String(Phonon::phononVersion())); #endif #ifndef QT_NO_GSTREAMER if (gst_init_check(0, 0, 0)) { diff --git a/tools/qtconfig/mainwindow.h b/tools/qtconfig/mainwindow.h index 7cc6522..50d73f9 100644 --- a/tools/qtconfig/mainwindow.h +++ b/tools/qtconfig/mainwindow.h @@ -42,14 +42,14 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -namespace Ui { - class MainWindow; -} - #include QT_BEGIN_NAMESPACE +namespace Ui { + class MainWindow; +} + class MainWindow : public QMainWindow { Q_OBJECT diff --git a/tools/qtconfig/paletteeditoradvanced.h b/tools/qtconfig/paletteeditoradvanced.h index 9f7a3f7..2bdb95d 100644 --- a/tools/qtconfig/paletteeditoradvanced.h +++ b/tools/qtconfig/paletteeditoradvanced.h @@ -44,12 +44,12 @@ #include +QT_BEGIN_NAMESPACE + namespace Ui { class PaletteEditorAdvanced; } -QT_BEGIN_NAMESPACE - class ColorButton; class PaletteEditorAdvanced : public QDialog diff --git a/tools/qtconfig/previewwidget.h b/tools/qtconfig/previewwidget.h index f3e5f71..e7707cd 100644 --- a/tools/qtconfig/previewwidget.h +++ b/tools/qtconfig/previewwidget.h @@ -44,11 +44,12 @@ #include +QT_BEGIN_NAMESPACE + namespace Ui { class PreviewWidget; } -QT_BEGIN_NAMESPACE class PreviewWidget : public QWidget { -- cgit v0.12 From c9533981e129655e2ca74b13ac1ff107df7db0e7 Mon Sep 17 00:00:00 2001 From: Patrick Spendrin Date: Wed, 6 Oct 2010 13:18:59 +0200 Subject: ActiveQt: also make the designer plugin for qaxwidget build in the opensource versions Reviewed-by: Olivier Goffart Merge-Request: 843 --- tools/designer/src/plugins/plugins.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/designer/src/plugins/plugins.pro b/tools/designer/src/plugins/plugins.pro index cf4fa8a..bcebb82 100644 --- a/tools/designer/src/plugins/plugins.pro +++ b/tools/designer/src/plugins/plugins.pro @@ -3,7 +3,7 @@ CONFIG += ordered REQUIRES = !CONFIG(static,shared|static) contains(QT_CONFIG, qt3support): SUBDIRS += widgets -win32:!contains(QT_EDITION, OpenSource):SUBDIRS += activeqt +win32: SUBDIRS += activeqt # contains(QT_CONFIG, opengl): SUBDIRS += tools/view3d contains(QT_CONFIG, webkit): SUBDIRS += qwebview contains(QT_CONFIG, phonon): SUBDIRS += phononwidgets -- cgit v0.12 From 6967f9e3fadfff8122809207dc7a99af444f699b Mon Sep 17 00:00:00 2001 From: Bernhard Rosenkraenzer Date: Thu, 7 Oct 2010 10:33:05 +0200 Subject: Fix build with cups 1.5 snapshots Without this patch, Qt CUPS support fails to build with current CUPS snapshots: In file included from ../../include/QtGui/private/qcups_p.h:1:0, from painting/qpdf.cpp:47: .../qcups_p.h:78:11: error: 'ppd_file_t' does not name a type .../qcups_p.h:80:11: error: 'ppd_file_t' does not name a type .../qcups_p.h:81:11: error: 'ppd_option_t' does not name a type .../qcups_p.h:84:11: error: 'ppd_option_t' does not name a type .../qcups_p.h:87:34: error: ISO C++ forbids declaration of 'type name' with no type .../qcups_p.h:87:47: error: template argument 1 is invalid .../qcups_p.h:103:56: error: 'ppd_group_t' does not name a type .../qcups_p.h:103:77: error: ISO C++ forbids declaration of 'group' with no type .../qcups_p.h:104:62: error: 'ppd_group_t' does not name a type .../qcups_p.h:104:75: error: ISO C++ forbids declaration of 'group' with no type .../qcups_p.h:108:11: error: 'ppd_option_t' does not name a type .../qcups_p.h:110:5: error: 'ppd_file_t' does not name a type Merge-request: 835 Reviewed-by: Olivier Goffart --- src/gui/painting/qcups_p.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/painting/qcups_p.h b/src/gui/painting/qcups_p.h index 9259679..239c244 100644 --- a/src/gui/painting/qcups_p.h +++ b/src/gui/painting/qcups_p.h @@ -59,6 +59,7 @@ #ifndef QT_NO_CUPS #include #include +#include QT_BEGIN_NAMESPACE -- cgit v0.12 From fbca6e1747eb8430729f0f0eb80b13f6d3d19f3a Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 7 Oct 2010 12:51:43 +0200 Subject: Fix text rendering in GL when using the broken-fbo-fallback This is a backport of 3874cd95e203da40d5205ef6455d7f56cba6923a which was committed to qt:master. Since the patch that originally exposed the bug was added to 4.7.2, this patch is required there as well. Bug is visible when resizing the glyph cache on devices where QGLContext::brokenFBOReadback defaults to true, or by setting this to true on desktop. Reviewed-by: Gunnar --- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 9a5bac0..919c542 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -137,7 +137,7 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height) if (ctx->d_ptr->workaround_brokenFBOReadBack) { QImageTextureGlyphCache::resizeTextureData(width, height); Q_ASSERT(image().depth() == 8); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, oldWidth, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits()); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, oldHeight, GL_ALPHA, GL_UNSIGNED_BYTE, image().constBits()); glDeleteTextures(1, &oldTexture); return; } -- cgit v0.12 From e3edad83a1e6e99a551d40d4118352435c6dd710 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Thu, 7 Oct 2010 14:16:50 +0200 Subject: Revert the integration of the merge request 2286. The merge request 2286 will be integrated in master. This should let an angry developer calm down and resume his work. --- tools/qtconfig/colorbutton.cpp | 9 +- tools/qtconfig/main.cpp | 1 + tools/qtconfig/mainwindow.cpp | 785 ++++++++------- tools/qtconfig/mainwindow.h | 19 +- tools/qtconfig/mainwindow.ui | 1388 -------------------------- tools/qtconfig/mainwindowbase.cpp | 250 +++++ tools/qtconfig/mainwindowbase.h | 95 ++ tools/qtconfig/mainwindowbase.ui | 1384 +++++++++++++++++++++++++ tools/qtconfig/paletteeditoradvanced.cpp | 579 +++++++---- tools/qtconfig/paletteeditoradvanced.h | 66 +- tools/qtconfig/paletteeditoradvanced.ui | 416 -------- tools/qtconfig/paletteeditoradvancedbase.cpp | 144 +++ tools/qtconfig/paletteeditoradvancedbase.h | 78 ++ tools/qtconfig/paletteeditoradvancedbase.ui | 617 ++++++++++++ tools/qtconfig/previewframe.cpp | 18 +- tools/qtconfig/previewframe.h | 13 +- tools/qtconfig/previewwidget.cpp | 29 +- tools/qtconfig/previewwidget.h | 18 +- tools/qtconfig/previewwidget.ui | 252 ----- tools/qtconfig/previewwidgetbase.cpp | 88 ++ tools/qtconfig/previewwidgetbase.h | 68 ++ tools/qtconfig/previewwidgetbase.ui | 340 +++++++ tools/qtconfig/qtconfig.pro | 19 +- tools/tools.pro | 2 +- 24 files changed, 3990 insertions(+), 2688 deletions(-) delete mode 100644 tools/qtconfig/mainwindow.ui create mode 100644 tools/qtconfig/mainwindowbase.cpp create mode 100644 tools/qtconfig/mainwindowbase.h create mode 100644 tools/qtconfig/mainwindowbase.ui delete mode 100644 tools/qtconfig/paletteeditoradvanced.ui create mode 100644 tools/qtconfig/paletteeditoradvancedbase.cpp create mode 100644 tools/qtconfig/paletteeditoradvancedbase.h create mode 100644 tools/qtconfig/paletteeditoradvancedbase.ui delete mode 100644 tools/qtconfig/previewwidget.ui create mode 100644 tools/qtconfig/previewwidgetbase.cpp create mode 100644 tools/qtconfig/previewwidgetbase.h create mode 100644 tools/qtconfig/previewwidgetbase.ui diff --git a/tools/qtconfig/colorbutton.cpp b/tools/qtconfig/colorbutton.cpp index 443effa..30617e4 100644 --- a/tools/qtconfig/colorbutton.cpp +++ b/tools/qtconfig/colorbutton.cpp @@ -52,20 +52,19 @@ QT_BEGIN_NAMESPACE ColorButton::ColorButton(QWidget *parent) - : QAbstractButton(parent) - , mousepressed(false) - , col(Qt::black) + : QAbstractButton(parent), mousepressed(false) { setAcceptDrops(true); + col = Qt::black; connect(this, SIGNAL(clicked()), SLOT(changeColor())); } ColorButton::ColorButton(const QColor &c, QWidget *parent) : QAbstractButton(parent) - , col(c) { setAcceptDrops(true); + col = c; connect(this, SIGNAL(clicked()), SLOT(changeColor())); } @@ -183,7 +182,7 @@ void ColorButton::mouseReleaseEvent(QMouseEvent *e) void ColorButton::mouseMoveEvent(QMouseEvent *e) { - if (!mousepressed) + if (! mousepressed) return; if ((presspos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { diff --git a/tools/qtconfig/main.cpp b/tools/qtconfig/main.cpp index 47b0994..928cf01 100644 --- a/tools/qtconfig/main.cpp +++ b/tools/qtconfig/main.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#include "ui_previewwidgetbase.h" #include "mainwindow.h" #include #include diff --git a/tools/qtconfig/mainwindow.cpp b/tools/qtconfig/mainwindow.cpp index f07da4f..9675f99 100644 --- a/tools/qtconfig/mainwindow.cpp +++ b/tools/qtconfig/mainwindow.cpp @@ -40,8 +40,6 @@ ****************************************************************************/ #include "mainwindow.h" -#include "ui_mainwindow.h" - #include "colorbutton.h" #include "previewframe.h" #include "paletteeditoradvanced.h" @@ -61,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -155,20 +154,36 @@ static const char *phonon_text = "

It is reccommended to leave all settings on \"Auto\" to let " "Phonon determine your settings automatically."; +static QColorGroup::ColorRole centralFromItem( int item ) +{ + switch( item ) { + case 0: return QColorGroup::Window; + case 1: return QColorGroup::WindowText; + case 2: return QColorGroup::Button; + case 3: return QColorGroup::Base; + case 4: return QColorGroup::Text; + case 5: return QColorGroup::BrightText; + case 6: return QColorGroup::ButtonText; + case 7: return QColorGroup::Highlight; + case 8: return QColorGroup::HighlightedText; + default: return QColorGroup::NColorRoles; + } +} + -QPalette::ColorGroup MainWindow::groupFromIndex(int item) +static QColorGroup::ColorRole effectFromItem( int item ) { - switch (item) { - case 0: - default: - return QPalette::Active; - case 1: - return QPalette::Inactive; - case 2: - return QPalette::Disabled; + switch( item ) { + case 0: return QColorGroup::Light; + case 1: return QColorGroup::Midlight; + case 2: return QColorGroup::Mid; + case 3: return QColorGroup::Dark; + case 4: return QColorGroup::Shadow; + default: return QColorGroup::NColorRoles; } } + static void setStyleHelper(QWidget *w, QStyle *s) { const QObjectList children = w->children(); @@ -180,140 +195,99 @@ static void setStyleHelper(QWidget *w, QStyle *s) w->setStyle(s); } -MainWindow::MainWindow() - : ui(new Ui::MainWindow), - editPalette(palette()), - previewPalette(palette()), - previewstyle(0) -{ - ui->setupUi(this); - statusBar(); - - // signals and slots connections - connect(ui->fontPathLineEdit, SIGNAL(returnPressed()), SLOT(addFontpath())); - connect(ui->addFontPathButton, SIGNAL(clicked()), SLOT(addFontpath())); - connect(ui->addSubstitutionButton, SIGNAL(clicked()), SLOT(addSubstitute())); - connect(ui->browseFontPathButton, SIGNAL(clicked()), SLOT(browseFontpath())); - connect(ui->fontStyleCombo, SIGNAL(activated(int)), SLOT(buildFont())); - connect(ui->pointSizeCombo, SIGNAL(activated(int)), SLOT(buildFont())); - connect(ui->downFontpathButton, SIGNAL(clicked()), SLOT(downFontpath())); - connect(ui->downSubstitutionButton, SIGNAL(clicked()), SLOT(downSubstitute())); - connect(ui->fontFamilyCombo, SIGNAL(activated(QString)), SLOT(familySelected(QString))); - connect(ui->fileExitAction, SIGNAL(activated()), SLOT(fileExit())); - connect(ui->fileSaveAction, SIGNAL(activated()), SLOT(fileSave())); - connect(ui->helpAboutAction, SIGNAL(activated()), SLOT(helpAbout())); - connect(ui->helpAboutQtAction, SIGNAL(activated()), SLOT(helpAboutQt())); - connect(ui->mainTabWidget, SIGNAL(currentChanged(QWidget*)), SLOT(pageChanged(QWidget*))); - connect(ui->paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); - connect(ui->removeFontpathButton, SIGNAL(clicked()), SLOT(removeFontpath())); - connect(ui->removeSubstitutionButton, SIGNAL(clicked()), SLOT(removeSubstitute())); - connect(ui->toolBoxEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->doubleClickIntervalSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->cursorFlashTimeSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->wheelScrollLinesSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->menuEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->comboEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->audiosinkCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->videomodeCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->toolTipEffectCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->strutWidthSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->strutHeightSpinBox, SIGNAL(valueChanged(int)), SLOT(somethingModified())); - connect(ui->effectsCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified())); - connect(ui->resolveLinksCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified())); - connect(ui->fontEmbeddingCheckBox, SIGNAL(clicked()), SLOT(somethingModified())); - connect(ui->rtlExtensionsCheckBox, SIGNAL(toggled(bool)), SLOT(somethingModified())); - connect(ui->inputStyleCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->inputMethodCombo, SIGNAL(activated(int)), SLOT(somethingModified())); - connect(ui->guiStyleCombo, SIGNAL(activated(QString)), SLOT(styleSelected(QString))); - connect(ui->familySubstitutionCombo, SIGNAL(activated(QString)), SLOT(substituteSelected(QString))); - connect(ui->tunePaletteButton, SIGNAL(clicked()), SLOT(tunePalette())); - connect(ui->upFontpathButton, SIGNAL(clicked()), SLOT(upFontpath())); - connect(ui->upSubstitutionButton, SIGNAL(clicked()), SLOT(upSubstitute())); +MainWindow::MainWindow() + : MainWindowBase(0, "main window"), + editPalette(palette()), previewPalette(palette()), previewstyle(0) +{ modified = true; desktopThemeName = tr("Desktop Settings (Default)"); QStringList gstyles = QStyleFactory::keys(); gstyles.sort(); - ui->guiStyleCombo->addItem(desktopThemeName); - ui->guiStyleCombo->setItemData(ui->guiStyleCombo->findText(desktopThemeName), - tr("Choose style and palette based on your desktop settings."), - Qt::ToolTipRole); - ui->guiStyleCombo->addItems(gstyles); + gstylecombo->addItem(desktopThemeName); + gstylecombo->setItemData(gstylecombo->findText(desktopThemeName), + tr("Choose style and palette based on your desktop settings."), Qt::ToolTipRole); + gstylecombo->insertStringList(gstyles); QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QString currentstyle = settings.value(QLatin1String("style")).toString(); if (currentstyle.isEmpty()) { - ui->guiStyleCombo->setCurrentIndex(ui->guiStyleCombo->findText(desktopThemeName)); - currentstyle = QApplication::style()->objectName(); + gstylecombo->setCurrentItem(gstylecombo->findText(desktopThemeName)); + currentstyle = QLatin1String(QApplication::style()->name()); } else { - int index = ui->guiStyleCombo->findText(currentstyle, Qt::MatchFixedString); + int index = gstylecombo->findText(currentstyle, Qt::MatchFixedString); if (index != -1) { - ui->guiStyleCombo->setCurrentIndex(index); + gstylecombo->setCurrentItem(index); } else { // we give up - ui->guiStyleCombo->addItem(tr("Unknown")); - ui->guiStyleCombo->setCurrentIndex(ui->guiStyleCombo->count() - 1); + gstylecombo->insertItem(QLatin1String("Unknown")); + gstylecombo->setCurrentItem(gstylecombo->count() - 1); } } - ui->buttonMainColor->setColor(palette().color(QPalette::Active, QPalette::Button)); - ui->buttonWindowColor->setColor(palette().color(QPalette::Active, QPalette::Window)); - connect(ui->buttonMainColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette())); - connect(ui->buttonWindowColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette())); + buttonMainColor->setColor(palette().color(QPalette::Active, + QColorGroup::Button)); + buttonMainColor2->setColor(palette().color(QPalette::Active, + QColorGroup::Window)); + connect(buttonMainColor, SIGNAL(colorChanged(QColor)), + this, SLOT(buildPalette())); + connect(buttonMainColor2, SIGNAL(colorChanged(QColor)), + this, SLOT(buildPalette())); if (X11->desktopEnvironment == DE_KDE) - ui->colorConfig->hide(); + colorConfig->hide(); else - ui->kdeNoteLabel->hide(); + labelKDENote->hide(); QFontDatabase db; QStringList families = db.families(); - ui->fontFamilyCombo->addItems(families); + familycombo->insertStringList(families); QStringList fs = families; QStringList fs2 = QFont::substitutions(); QStringList::Iterator fsit = fs2.begin(); while (fsit != fs2.end()) { - if (!fs.contains(*fsit)) + if (! fs.contains(*fsit)) fs += *fsit; fsit++; } fs.sort(); - ui->familySubstitutionCombo->addItems(fs); + familysubcombo->insertStringList(fs); - ui->chooseSubstitutionCombo->addItems(families); - QList sizes = db.standardSizes(); - foreach(int i, sizes) - ui->pointSizeCombo->addItem(QString::number(i)); + choosesubcombo->insertStringList(families); + Q3ValueList sizes = db.standardSizes(); + Q3ValueList::Iterator it = sizes.begin(); + while (it != sizes.end()) + psizecombo->insertItem(QString::number(*it++)); - ui->doubleClickIntervalSpinBox->setValue(QApplication::doubleClickInterval()); - ui->cursorFlashTimeSpinBox->setValue(QApplication::cursorFlashTime()); - ui->wheelScrollLinesSpinBox->setValue(QApplication::wheelScrollLines()); + dcispin->setValue(QApplication::doubleClickInterval()); + cfispin->setValue(QApplication::cursorFlashTime()); + wslspin->setValue(QApplication::wheelScrollLines()); // ############# - // resolveLinksCheckBox->setChecked(qt_resolve_symlinks); +// resolvelinks->setChecked(qt_resolve_symlinks); - ui->effectsCheckBox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); - ui->effectsFrame->setEnabled(ui->effectsCheckBox->isChecked()); + effectcheckbox->setChecked(QApplication::isEffectEnabled(Qt::UI_General)); + effectbase->setEnabled(effectcheckbox->isChecked()); if (QApplication::isEffectEnabled(Qt::UI_FadeMenu)) - ui->menuEffectCombo->setCurrentIndex(2); + menueffect->setCurrentItem(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) - ui->menuEffectCombo->setCurrentIndex(1); + menueffect->setCurrentItem(1); if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo)) - ui->comboEffectCombo->setCurrentIndex(1); + comboeffect->setCurrentItem(1); if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)) - ui->toolTipEffectCombo->setCurrentIndex(2); + tooltipeffect->setCurrentItem(2); else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip)) - ui->toolTipEffectCombo->setCurrentIndex(1); + tooltipeffect->setCurrentItem(1); - if (QApplication::isEffectEnabled(Qt::UI_AnimateToolBox)) - ui->toolBoxEffectCombo->setCurrentIndex(1); + if ( QApplication::isEffectEnabled( Qt::UI_AnimateToolBox ) ) + toolboxeffect->setCurrentItem( 1 ); QSize globalStrut = QApplication::globalStrut(); - ui->strutWidthSpinBox->setValue(globalStrut.width()); - ui->strutHeightSpinBox->setValue(globalStrut.height()); + strutwidth->setValue(globalStrut.width()); + strutheight->setValue(globalStrut.height()); // find the default family QStringList::Iterator sit = families.begin(); @@ -332,10 +306,10 @@ MainWindow::MainWindow() if (i == -1) // no clue about the current font i = 0; - ui->fontFamilyCombo->setCurrentIndex(i); + familycombo->setCurrentItem(i); - QStringList styles = db.styles(ui->fontFamilyCombo->currentText()); - ui->fontStyleCombo->addItems(styles); + QStringList styles = db.styles(familycombo->currentText()); + stylecombo->insertStringList(styles); QString stylestring = db.styleString(QApplication::font()); sit = styles.begin(); @@ -354,98 +328,91 @@ MainWindow::MainWindow() i = possible; if (i == -1) // no clue about the current font i = 0; - ui->fontStyleCombo->setCurrentIndex(i); + stylecombo->setCurrentItem(i); i = 0; - for (int psize = QApplication::font().pointSize(); i < ui->pointSizeCombo->count(); ++i) { - const int sz = ui->pointSizeCombo->itemText(i).toInt(); + for (int psize = QApplication::font().pointSize(); i < psizecombo->count(); ++i) { + const int sz = psizecombo->text(i).toInt(); if (sz == psize) { - ui->pointSizeCombo->setCurrentIndex(i); + psizecombo->setCurrentItem(i); break; } else if(sz > psize) { - ui->pointSizeCombo->insertItem(i, QString::number(psize)); - ui->pointSizeCombo->setCurrentIndex(i); + psizecombo->insertItem(i, QString::number(psize)); + psizecombo->setCurrentItem(i); break; } } - QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); - ui->substitutionsListBox->clear(); - ui->substitutionsListBox->insertItems(0, subs); + QStringList subs = QFont::substitutes(familysubcombo->currentText()); + sublistbox->clear(); + sublistbox->insertStringList(subs); - ui->rtlExtensionsCheckBox->setChecked(settings.value(QLatin1String("useRtlExtensions"), false) - .toBool()); + rtlExtensions->setChecked(settings.value(QLatin1String("useRtlExtensions"), false).toBool()); #ifdef Q_WS_X11 - QString settingsInputStyle = settings.value(QLatin1String("XIMInputStyle")).toString(); - if (!settingsInputStyle.isEmpty()) - ui->inputStyleCombo->setCurrentIndex(ui->inputStyleCombo->findText(settingsInputStyle)); + inputStyle->setCurrentText(settings.value(QLatin1String("XIMInputStyle"), trUtf8("On The Spot")).toString()); #else - ui->inputStyleCombo->hide(); - ui->inputStyleComboLabel->hide(); + inputStyle->hide(); + inputStyleLabel->hide(); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) - QStringList inputMethodCombo = QInputContextFactory::keys(); - int inputMethodComboIndex = -1; + QStringList inputMethods = QInputContextFactory::keys(); + int inputMethodIndex = -1; QString defaultInputMethod = settings.value(QLatin1String("DefaultInputMethod"), QLatin1String("xim")).toString(); - for (int i = inputMethodCombo.size()-1; i >= 0; --i) { - const QString &im = inputMethodCombo.at(i); + for (int i = inputMethods.size()-1; i >= 0; --i) { + const QString &im = inputMethods.at(i); if (im.contains(QLatin1String("imsw"))) { - inputMethodCombo.removeAt(i); - if (inputMethodComboIndex > i) - --inputMethodComboIndex; + inputMethods.removeAt(i); + if (inputMethodIndex > i) + --inputMethodIndex; } else if (im == defaultInputMethod) { - inputMethodComboIndex = i; + inputMethodIndex = i; } } - if (inputMethodComboIndex == -1 && !inputMethodCombo.isEmpty()) - inputMethodComboIndex = 0; - ui->inputMethodCombo->addItems(inputMethodCombo); - ui->inputMethodCombo->setCurrentIndex(inputMethodComboIndex); + if (inputMethodIndex == -1 && !inputMethods.isEmpty()) + inputMethodIndex = 0; + inputMethod->addItems(inputMethods); + inputMethod->setCurrentIndex(inputMethodIndex); #else - ui->inputMethodCombo->hide(); - ui->inputMethodComboLabel->hide(); + inputMethod->hide(); + inputMethodLabel->hide(); #endif - ui->fontEmbeddingCheckBox->setChecked(settings.value(QLatin1String("embedFonts"), true) - .toBool()); + fontembeddingcheckbox->setChecked(settings.value(QLatin1String("embedFonts"), true).toBool()); fontpaths = settings.value(QLatin1String("fontPath")).toStringList(); - ui->fontpathListBox->insertItems(0, fontpaths); - - ui->audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); - ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(tr("Auto (default)")), - tr("Choose audio output automatically."), Qt::ToolTipRole); - ui->audiosinkCombo->addItem(tr("aRts"), QLatin1String("artssink")); - ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(tr("aRts")), - tr("Experimental aRts support for GStreamer."), - Qt::ToolTipRole); + fontpathlistbox->insertStringList(fontpaths); + + audiosinkCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); + audiosinkCombo->setItemData(audiosinkCombo->findText(tr("Auto (default)")), + tr("Choose audio output automatically."), Qt::ToolTipRole); + audiosinkCombo->addItem(tr("aRts"), QLatin1String("artssink")); + audiosinkCombo->setItemData(audiosinkCombo->findText(tr("aRts")), + tr("Experimental aRts support for GStreamer."), Qt::ToolTipRole); #ifdef HAVE_PHONON - ui->phononVersionLabel->setText(QLatin1String(Phonon::phononVersion())); + phononVersionLabel->setText(QLatin1String(Phonon::phononVersion())); #endif #ifndef QT_NO_GSTREAMER if (gst_init_check(0, 0, 0)) { gchar *versionString = gst_version_string(); - ui->gstVersionLabel->setText(QLatin1String(versionString)); + gstversionLabel->setText(QLatin1String(versionString)); g_free(versionString); - GList *factoryList = gst_registry_get_feature_list(gst_registry_get_default(), - GST_TYPE_ELEMENT_FACTORY); + GList* factoryList = gst_registry_get_feature_list(gst_registry_get_default (), GST_TYPE_ELEMENT_FACTORY); QString name, klass, description; - for (GList *iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { + for (GList* iter = g_list_first(factoryList) ; iter != NULL ; iter = g_list_next(iter)) { GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data); klass = QLatin1String(gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature))); if (klass == QLatin1String("Sink/Audio")) { name = QLatin1String(GST_PLUGIN_FEATURE_NAME(feature)); if (name == QLatin1String("sfsink")) - continue; // useless to output audio to file when you cannot set the file path + continue; //useless to output audio to file when you cannot set the file path else if (name == QLatin1String("autoaudiosink")) continue; //This is used implicitly from the auto setting GstElement *sink = gst_element_factory_make (qPrintable(name), NULL); if (sink) { - description = QLatin1String(gst_element_factory_get_description(GST_ELEMENT_FACTORY(feature))); - ui->audiosinkCombo->addItem(name, name); - ui->audiosinkCombo->setItemData(ui->audiosinkCombo->findText(name), description, - Qt::ToolTipRole); + description = QLatin1String(gst_element_factory_get_description (GST_ELEMENT_FACTORY(feature))); + audiosinkCombo->addItem(name, name); + audiosinkCombo->setItemData(audiosinkCombo->findText(name), description, Qt::ToolTipRole); gst_object_unref (sink); } } @@ -453,43 +420,39 @@ MainWindow::MainWindow() g_list_free(factoryList); } #else - ui->phononTab->setEnabled(false); - ui->phononLabel->setText(tr("Phonon GStreamer backend not available.")); + tab4->setEnabled(false); + phononLabel->setText(tr("Phonon GStreamer backend not available.")); #endif - ui->videomodeCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); - ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("Auto (default)")), - tr("Choose render method automatically"), Qt::ToolTipRole); + videomodeCombo->addItem(tr("Auto (default)"), QLatin1String("Auto")); + videomodeCombo->setItemData(videomodeCombo->findText(tr("Auto (default)")), tr("Choose render method automatically"), Qt::ToolTipRole); #ifdef Q_WS_X11 - ui->videomodeCombo->addItem(tr("X11"), QLatin1String("X11")); - ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("X11")), - tr("Use X11 Overlays"), Qt::ToolTipRole); + videomodeCombo->addItem(tr("X11"), QLatin1String("X11")); + videomodeCombo->setItemData(videomodeCombo->findText(tr("X11")), tr("Use X11 Overlays"), Qt::ToolTipRole); #endif #ifndef QT_NO_OPENGL - ui->videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); - ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("OpenGL")), - tr("Use OpenGL if available"), Qt::ToolTipRole); + videomodeCombo->addItem(tr("OpenGL"), QLatin1String("OpenGL")); + videomodeCombo->setItemData(videomodeCombo->findText(tr("OpenGL")), tr("Use OpenGL if available"), Qt::ToolTipRole); #endif - ui->videomodeCombo->addItem(tr("Software"), QLatin1String("Software")); - ui->videomodeCombo->setItemData(ui->videomodeCombo->findText(tr("Software")), - tr("Use simple software rendering"), Qt::ToolTipRole); + videomodeCombo->addItem(tr("Software"), QLatin1String("Software")); + videomodeCombo->setItemData(videomodeCombo->findText(tr("Software")), tr("Use simple software rendering"), Qt::ToolTipRole); QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); - ui->audiosinkCombo->setCurrentIndex(ui->audiosinkCombo->findData(audioSink)); - ui->videomodeCombo->setCurrentIndex(ui->videomodeCombo->findData(videoMode)); + audiosinkCombo->setCurrentItem(audiosinkCombo->findData(audioSink)); + videomodeCombo->setCurrentItem(videomodeCombo->findData(videoMode)); settings.endGroup(); // Qt - ui->helpView->setText(tr(appearance_text)); + helpview->setText(tr(appearance_text)); setModified(false); updateStyleLayout(); } + MainWindow::~MainWindow() { - delete ui; } #ifdef Q_WS_X11 @@ -509,23 +472,23 @@ void MainWindow::fileSave() QSettings settings(QLatin1String("Trolltech")); settings.beginGroup(QLatin1String("Qt")); QFontDatabase db; - QFont font = db.font(ui->fontFamilyCombo->currentText(), - ui->fontStyleCombo->currentText(), - ui->pointSizeCombo->currentText().toInt()); + QFont font = db.font(familycombo->currentText(), + stylecombo->currentText(), + psizecombo->currentText().toInt()); QStringList actcg, inactcg, discg; - bool overrideDesktopSettings = (ui->guiStyleCombo->currentText() != desktopThemeName); + bool overrideDesktopSettings = (gstylecombo->currentText() != desktopThemeName); if (overrideDesktopSettings) { int i; - for (i = 0; i < QPalette::NColorRoles; i++) + for (i = 0; i < QColorGroup::NColorRoles; i++) actcg << editPalette.color(QPalette::Active, - QPalette::ColorRole(i)).name(); - for (i = 0; i < QPalette::NColorRoles; i++) + (QColorGroup::ColorRole) i).name(); + for (i = 0; i < QColorGroup::NColorRoles; i++) inactcg << editPalette.color(QPalette::Inactive, - QPalette::ColorRole(i)).name(); - for (i = 0; i < QPalette::NColorRoles; i++) + (QColorGroup::ColorRole) i).name(); + for (i = 0; i < QColorGroup::NColorRoles; i++) discg << editPalette.color(QPalette::Disabled, - QPalette::ColorRole(i)).name(); + (QColorGroup::ColorRole) i).name(); } settings.setValue(QLatin1String("font"), font.toString()); @@ -534,63 +497,59 @@ void MainWindow::fileSave() settings.setValue(QLatin1String("Palette/disabled"), discg); settings.setValue(QLatin1String("fontPath"), fontpaths); - settings.setValue(QLatin1String("embedFonts"), ui->fontEmbeddingCheckBox->isChecked()); - settings.setValue(QLatin1String("style"), - overrideDesktopSettings ? ui->guiStyleCombo->currentText() : QString()); + settings.setValue(QLatin1String("embedFonts"), fontembeddingcheckbox->isChecked()); + settings.setValue(QLatin1String("style"), overrideDesktopSettings ? gstylecombo->currentText() : QString()); - settings.setValue(QLatin1String("doubleClickInterval"), ui->doubleClickIntervalSpinBox->value()); - settings.setValue(QLatin1String("cursorFlashTime"), - ui->cursorFlashTimeSpinBox->value() == 9 ? 0 : ui->cursorFlashTimeSpinBox->value()); - settings.setValue(QLatin1String("wheelScrollLines"), ui->wheelScrollLinesSpinBox->value()); - settings.setValue(QLatin1String("resolveSymlinks"), ui->resolveLinksCheckBox->isChecked()); + settings.setValue(QLatin1String("doubleClickInterval"), dcispin->value()); + settings.setValue(QLatin1String("cursorFlashTime"), cfispin->value() == 9 ? 0 : cfispin->value() ); + settings.setValue(QLatin1String("wheelScrollLines"), wslspin->value()); + settings.setValue(QLatin1String("resolveSymlinks"), resolvelinks->isChecked()); - QSize strut(ui->strutWidthSpinBox->value(), ui->strutHeightSpinBox->value()); + QSize strut(strutwidth->value(), strutheight->value()); settings.setValue(QLatin1String("globalStrut/width"), strut.width()); settings.setValue(QLatin1String("globalStrut/height"), strut.height()); - settings.setValue(QLatin1String("useRtlExtensions"), ui->rtlExtensionsCheckBox->isChecked()); + settings.setValue(QLatin1String("useRtlExtensions"), rtlExtensions->isChecked()); #ifdef Q_WS_X11 - QString style = ui->inputStyleCombo->currentText(); + QString style = inputStyle->currentText(); QString str = QLatin1String("On The Spot"); - if (style == tr("Over The Spot")) + if ( style == trUtf8( "Over The Spot" ) ) str = QLatin1String("Over The Spot"); - else if (style == tr("Off The Spot")) + else if ( style == trUtf8( "Off The Spot" ) ) str = QLatin1String("Off The Spot"); - else if (style == tr("Root")) + else if ( style == trUtf8( "Root" ) ) str = QLatin1String("Root"); - settings.setValue(QLatin1String("XIMInputStyle"), str); + settings.setValue( QLatin1String("XIMInputStyle"), str ); #endif #if defined(Q_WS_X11) && !defined(QT_NO_XIM) - settings.setValue(QLatin1String("DefaultInputMethod"), ui->inputMethodCombo->currentText()); + settings.setValue(QLatin1String("DefaultInputMethod"), inputMethod->currentText()); #endif QString audioSink = settings.value(QLatin1String("audiosink"), QLatin1String("Auto")).toString(); QString videoMode = settings.value(QLatin1String("videomode"), QLatin1String("Auto")).toString(); - settings.setValue(QLatin1String("audiosink"), - ui->audiosinkCombo->itemData(ui->audiosinkCombo->currentIndex())); - settings.setValue(QLatin1String("videomode"), - ui->videomodeCombo->itemData(ui->videomodeCombo->currentIndex())); + settings.setValue(QLatin1String("audiosink"), audiosinkCombo->itemData(audiosinkCombo->currentIndex())); + settings.setValue(QLatin1String("videomode"), videomodeCombo->itemData(videomodeCombo->currentIndex())); QStringList effects; - if (ui->effectsCheckBox->isChecked()) { + if (effectcheckbox->isChecked()) { effects << QLatin1String("general"); - switch (ui->menuEffectCombo->currentIndex()) { + switch (menueffect->currentItem()) { case 1: effects << QLatin1String("animatemenu"); break; case 2: effects << QLatin1String("fademenu"); break; } - switch (ui->comboEffectCombo->currentIndex()) { + switch (comboeffect->currentItem()) { case 1: effects << QLatin1String("animatecombo"); break; } - switch (ui->toolTipEffectCombo->currentIndex()) { + switch (tooltipeffect->currentItem()) { case 1: effects << QLatin1String("animatetooltip"); break; case 2: effects << QLatin1String("fadetooltip"); break; } - switch (ui->toolBoxEffectCombo->currentIndex()) { + switch ( toolboxeffect->currentItem() ) { case 1: effects << QLatin1String("animatetoolbox"); break; } } else @@ -614,63 +573,189 @@ void MainWindow::fileSave() #endif // Q_WS_X11 setModified(false); - statusBar()->showMessage(tr("Saved changes.")); + statusBar()->showMessage(QLatin1String("Saved changes.")); } + void MainWindow::fileExit() { qApp->closeAllWindows(); } + void MainWindow::setModified(bool m) { if (modified == m) return; modified = m; - ui->fileSaveAction->setEnabled(m); + fileSaveAction->setEnabled(m); } + void MainWindow::buildPalette() { - QPalette temp(ui->buttonMainColor->color(), ui->buttonWindowColor->color()); - for (int i = 0; i < QPalette::NColorGroups; i++) - temp = PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup(i), temp); + int i; + QColorGroup cg; + QColor btn = buttonMainColor->color(); + QColor back = buttonMainColor2->color(); + QPalette automake( btn, back ); + + for (i = 0; i<9; i++) + cg.setColor( centralFromItem(i), automake.active().color( centralFromItem(i) ) ); + + editPalette.setActive( cg ); + buildActiveEffect(); + + cg = editPalette.inactive(); + + QPalette temp( editPalette.active().color( QColorGroup::Button ), + editPalette.active().color( QColorGroup::Window ) ); + + for (i = 0; i<9; i++) + cg.setColor( centralFromItem(i), temp.inactive().color( centralFromItem(i) ) ); + + editPalette.setInactive( cg ); + buildInactiveEffect(); + + cg = editPalette.disabled(); + + for (i = 0; i<9; i++) + cg.setColor( centralFromItem(i), temp.disabled().color( centralFromItem(i) ) ); + + editPalette.setDisabled( cg ); + buildDisabledEffect(); - editPalette = temp; - setPreviewPalette(editPalette); updateColorButtons(); setModified(true); } -void MainWindow::setPreviewPalette(const QPalette &pal) + +void MainWindow::buildActiveEffect() { - QPalette::ColorGroup colorGroup = groupFromIndex(ui->paletteCombo->currentIndex()); + QColorGroup cg = editPalette.active(); + QColor btn = cg.color( QColorGroup::Button ); - for (int i = 0; i < QPalette::NColorGroups; i++) { - for (int j = 0; j < QPalette::NColorRoles; j++) { - QPalette::ColorGroup targetGroup = QPalette::ColorGroup(i); - QPalette::ColorRole targetRole = QPalette::ColorRole(j); - previewPalette.setColor(targetGroup, targetRole, pal.color(colorGroup, targetRole)); - } + QPalette temp( btn, btn ); + + for (int i = 0; i<5; i++) + cg.setColor( effectFromItem(i), temp.active().color( effectFromItem(i) ) ); + + editPalette.setActive( cg ); + setPreviewPalette( editPalette ); + + updateColorButtons(); +} + + +void MainWindow::buildInactive() +{ + editPalette.setInactive( editPalette.active() ); + buildInactiveEffect(); +} + + +void MainWindow::buildInactiveEffect() +{ + QColorGroup cg = editPalette.inactive(); + + QColor light, midlight, mid, dark, shadow; + QColor btn = cg.color( QColorGroup::Button ); + + light = btn.light(150); + midlight = btn.light(115); + mid = btn.dark(150); + dark = btn.dark(); + shadow = Qt::black; + + cg.setColor( QColorGroup::Light, light ); + cg.setColor( QColorGroup::Midlight, midlight ); + cg.setColor( QColorGroup::Mid, mid ); + cg.setColor( QColorGroup::Dark, dark ); + cg.setColor( QColorGroup::Shadow, shadow ); + + editPalette.setInactive( cg ); + setPreviewPalette( editPalette ); + updateColorButtons(); +} + + +void MainWindow::buildDisabled() +{ + QColorGroup cg = editPalette.active(); + cg.setColor( QColorGroup::ButtonText, Qt::darkGray ); + cg.setColor( QColorGroup::WindowText, Qt::darkGray ); + cg.setColor( QColorGroup::Text, Qt::darkGray ); + cg.setColor( QColorGroup::HighlightedText, Qt::darkGray ); + editPalette.setDisabled( cg ); + + buildDisabledEffect(); +} + + +void MainWindow::buildDisabledEffect() +{ + QColorGroup cg = editPalette.disabled(); + + QColor light, midlight, mid, dark, shadow; + QColor btn = cg.color( QColorGroup::Button ); + + light = btn.light(150); + midlight = btn.light(115); + mid = btn.dark(150); + dark = btn.dark(); + shadow = Qt::black; + + cg.setColor( QColorGroup::Light, light ); + cg.setColor( QColorGroup::Midlight, midlight ); + cg.setColor( QColorGroup::Mid, mid ); + cg.setColor( QColorGroup::Dark, dark ); + cg.setColor( QColorGroup::Shadow, shadow ); + + editPalette.setDisabled( cg ); + setPreviewPalette( editPalette ); + updateColorButtons(); +} + + +void MainWindow::setPreviewPalette( const QPalette& pal ) +{ + QColorGroup cg; + + switch (paletteCombo->currentItem()) { + case 0: + default: + cg = pal.active(); + break; + case 1: + cg = pal.inactive(); + break; + case 2: + cg = pal.disabled(); + break; } + previewPalette.setActive( cg ); + previewPalette.setInactive( cg ); + previewPalette.setDisabled( cg ); - ui->previewFrame->setPreviewPalette(previewPalette); + previewFrame->setPreviewPalette(previewPalette); } + void MainWindow::updateColorButtons() { - ui->buttonMainColor->setColor(editPalette.color(QPalette::Active, QPalette::Button)); - ui->buttonWindowColor->setColor(editPalette.color(QPalette::Active, QPalette::Window)); + buttonMainColor->setColor( editPalette.active().color( QColorGroup::Button )); + buttonMainColor2->setColor( editPalette.active().color( QColorGroup::Window )); } + void MainWindow::tunePalette() { bool ok; QPalette pal = PaletteEditorAdvanced::getPalette(&ok, editPalette, - backgroundRole(), this); - if (!ok) + backgroundMode(), this); + if (! ok) return; editPalette = pal; @@ -678,6 +763,7 @@ void MainWindow::tunePalette() setModified(true); } + void MainWindow::paletteSelected(int) { setPreviewPalette(editPalette); @@ -685,10 +771,10 @@ void MainWindow::paletteSelected(int) void MainWindow::updateStyleLayout() { - QString currentStyle = ui->guiStyleCombo->currentText(); + QString currentStyle = gstylecombo->currentText(); bool autoStyle = (currentStyle == desktopThemeName); - ui->previewFrame->setPreviewVisible(!autoStyle); - ui->buildPaletteGroup->setEnabled(currentStyle.toLower() != QLatin1String("gtk") && !autoStyle); + previewFrame->setPreviewVisible(!autoStyle); + groupAutoPalette->setEnabled(currentStyle.toLower() != QLatin1String("gtk") && !autoStyle); } void MainWindow::styleSelected(const QString &stylename) @@ -700,7 +786,7 @@ void MainWindow::styleSelected(const QString &stylename) style = QStyleFactory::create(stylename); if (!style) return; - setStyleHelper(ui->previewFrame, style); + setStyleHelper(previewFrame, style); delete previewstyle; previewstyle = style; setModified(true); @@ -708,191 +794,210 @@ void MainWindow::styleSelected(const QString &stylename) updateStyleLayout(); } + void MainWindow::familySelected(const QString &family) { QFontDatabase db; QStringList styles = db.styles(family); - ui->fontStyleCombo->clear(); - ui->fontStyleCombo->addItems(styles); - ui->familySubstitutionCombo->addItem(family); + stylecombo->clear(); + stylecombo->insertStringList(styles); + familysubcombo->insertItem(family); buildFont(); } + void MainWindow::buildFont() { QFontDatabase db; - QFont font = db.font(ui->fontFamilyCombo->currentText(), - ui->fontStyleCombo->currentText(), - ui->pointSizeCombo->currentText().toInt()); - ui->sampleLineEdit->setFont(font); + QFont font = db.font(familycombo->currentText(), + stylecombo->currentText(), + psizecombo->currentText().toInt()); + samplelineedit->setFont(font); setModified(true); } + void MainWindow::substituteSelected(const QString &family) { QStringList subs = QFont::substitutes(family); - ui->substitutionsListBox->clear(); - ui->substitutionsListBox->insertItems(0, subs); + sublistbox->clear(); + sublistbox->insertStringList(subs); } + void MainWindow::removeSubstitute() { - if (!ui->substitutionsListBox->currentItem()) + if (sublistbox->currentItem() < 0 || + uint(sublistbox->currentItem()) > sublistbox->count()) return; - int row = ui->substitutionsListBox->currentRow(); - QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); - subs.removeAt(ui->substitutionsListBox->currentRow()); - ui->substitutionsListBox->clear(); - ui->substitutionsListBox->insertItems(0, subs); - if (row > ui->substitutionsListBox->count()) - row = ui->substitutionsListBox->count() - 1; - ui->substitutionsListBox->setCurrentRow(row); - QFont::removeSubstitution(ui->familySubstitutionCombo->currentText()); - QFont::insertSubstitutions(ui->familySubstitutionCombo->currentText(), subs); + int item = sublistbox->currentItem(); + QStringList subs = QFont::substitutes(familysubcombo->currentText()); + subs.removeAt(sublistbox->currentItem()); + sublistbox->clear(); + sublistbox->insertStringList(subs); + if (uint(item) > sublistbox->count()) + item = int(sublistbox->count()) - 1; + sublistbox->setCurrentItem(item); + QFont::removeSubstitution(familysubcombo->currentText()); + QFont::insertSubstitutions(familysubcombo->currentText(), subs); setModified(true); } + void MainWindow::addSubstitute() { - if (!ui->substitutionsListBox->currentItem()) { - QFont::insertSubstitution(ui->familySubstitutionCombo->currentText(), - ui->chooseSubstitutionCombo->currentText()); - QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); - ui->substitutionsListBox->clear(); - ui->substitutionsListBox->insertItems(0, subs); + if (sublistbox->currentItem() < 0 || + uint(sublistbox->currentItem()) > sublistbox->count()) { + QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); + QStringList subs = QFont::substitutes(familysubcombo->currentText()); + sublistbox->clear(); + sublistbox->insertStringList(subs); setModified(true); return; } - int row = ui->substitutionsListBox->currentRow(); - QFont::insertSubstitution(ui->familySubstitutionCombo->currentText(), ui->chooseSubstitutionCombo->currentText()); - QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); - ui->substitutionsListBox->clear(); - ui->substitutionsListBox->insertItems(0, subs); - ui->substitutionsListBox->setCurrentRow(row); + int item = sublistbox->currentItem(); + QFont::insertSubstitution(familysubcombo->currentText(), choosesubcombo->currentText()); + QStringList subs = QFont::substitutes(familysubcombo->currentText()); + sublistbox->clear(); + sublistbox->insertStringList(subs); + sublistbox->setCurrentItem(item); setModified(true); } + void MainWindow::downSubstitute() { - if (!ui->substitutionsListBox->currentItem() || ui->substitutionsListBox->currentRow() >= ui->substitutionsListBox->count()) + if (sublistbox->currentItem() < 0 || + uint(sublistbox->currentItem()) >= sublistbox->count()) return; - int row = ui->substitutionsListBox->currentRow(); - QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); - QString fam = subs.at(row); - subs.removeAt(row); - subs.insert(row + 1, fam); - ui->substitutionsListBox->clear(); - ui->substitutionsListBox->insertItems(0, subs); - ui->substitutionsListBox->setCurrentRow(row + 1); - QFont::removeSubstitution(ui->familySubstitutionCombo->currentText()); - QFont::insertSubstitutions(ui->familySubstitutionCombo->currentText(), subs); + int item = sublistbox->currentItem(); + QStringList subs = QFont::substitutes(familysubcombo->currentText()); + QString fam = subs.at(item); + subs.removeAt(item); + subs.insert(item+1, fam); + sublistbox->clear(); + sublistbox->insertStringList(subs); + sublistbox->setCurrentItem(item + 1); + QFont::removeSubstitution(familysubcombo->currentText()); + QFont::insertSubstitutions(familysubcombo->currentText(), subs); setModified(true); } + void MainWindow::upSubstitute() { - if (!ui->substitutionsListBox->currentItem() || ui->substitutionsListBox->currentRow() < 1) + if (sublistbox->currentItem() < 1) return; - int row = ui->substitutionsListBox->currentRow(); - QStringList subs = QFont::substitutes(ui->familySubstitutionCombo->currentText()); - QString fam = subs.at(row); - subs.removeAt(row); - subs.insert(row-1, fam); - ui->substitutionsListBox->clear(); - ui->substitutionsListBox->insertItems(0, subs); - ui->substitutionsListBox->setCurrentRow(row - 1); - QFont::removeSubstitution(ui->familySubstitutionCombo->currentText()); - QFont::insertSubstitutions(ui->familySubstitutionCombo->currentText(), subs); + int item = sublistbox->currentItem(); + QStringList subs = QFont::substitutes(familysubcombo->currentText()); + QString fam = subs.at(item); + subs.removeAt(item); + subs.insert(item-1, fam); + sublistbox->clear(); + sublistbox->insertStringList(subs); + sublistbox->setCurrentItem(item - 1); + QFont::removeSubstitution(familysubcombo->currentText()); + QFont::insertSubstitutions(familysubcombo->currentText(), subs); setModified(true); } + void MainWindow::removeFontpath() { - if (!ui->fontpathListBox->currentItem()) + if (fontpathlistbox->currentItem() < 0 || + uint(fontpathlistbox->currentItem()) > fontpathlistbox->count()) return; - int row = ui->fontpathListBox->currentRow(); - fontpaths.removeAt(row); - ui->fontpathListBox->clear(); - ui->fontpathListBox->insertItems(0, fontpaths); - if (row > ui->fontpathListBox->count()) - row = ui->fontpathListBox->count() - 1; - ui->fontpathListBox->setCurrentRow(row); + int item = fontpathlistbox->currentItem(); + fontpaths.removeAt(fontpathlistbox->currentItem()); + fontpathlistbox->clear(); + fontpathlistbox->insertStringList(fontpaths); + if (uint(item) > fontpathlistbox->count()) + item = int(fontpathlistbox->count()) - 1; + fontpathlistbox->setCurrentItem(item); setModified(true); } + void MainWindow::addFontpath() { - if (ui->fontPathLineEdit->text().isEmpty()) + if (fontpathlineedit->text().isEmpty()) return; - if (!ui->fontpathListBox->currentItem()) { - fontpaths.append(ui->fontPathLineEdit->text()); - ui->fontpathListBox->clear(); - ui->fontpathListBox->insertItems(0, fontpaths); + if (fontpathlistbox->currentItem() < 0 || + uint(fontpathlistbox->currentItem()) > fontpathlistbox->count()) { + fontpaths.append(fontpathlineedit->text()); + fontpathlistbox->clear(); + fontpathlistbox->insertStringList(fontpaths); setModified(true); return; } - int row = ui->fontpathListBox->currentRow(); - fontpaths.insert(row + 1, ui->fontPathLineEdit->text()); - ui->fontpathListBox->clear(); - ui->fontpathListBox->insertItems(0, fontpaths); - ui->fontpathListBox->setCurrentRow(row); + int item = fontpathlistbox->currentItem(); + fontpaths.insert(fontpathlistbox->currentItem()+1, + fontpathlineedit->text()); + fontpathlistbox->clear(); + fontpathlistbox->insertStringList(fontpaths); + fontpathlistbox->setCurrentItem(item); setModified(true); } + void MainWindow::downFontpath() { - if (!ui->fontpathListBox->currentItem() - || ui->fontpathListBox->currentRow() >= (ui->fontpathListBox->count() - 1)) { + if (fontpathlistbox->currentItem() < 0 || + uint(fontpathlistbox->currentItem()) >= fontpathlistbox->count() - 1) return; - } - int row = ui->fontpathListBox->currentRow(); - QString fam = fontpaths.at(row); - fontpaths.removeAt(row); - fontpaths.insert(row + 1, fam); - ui->fontpathListBox->clear(); - ui->fontpathListBox->insertItems(0, fontpaths); - ui->fontpathListBox->setCurrentRow(row + 1); + int item = fontpathlistbox->currentItem(); + QString fam = fontpaths.at(item); + fontpaths.removeAt(item); + fontpaths.insert(item+1, fam); + fontpathlistbox->clear(); + fontpathlistbox->insertStringList(fontpaths); + fontpathlistbox->setCurrentItem(item + 1); setModified(true); } + void MainWindow::upFontpath() { - if (!ui->fontpathListBox->currentItem() || ui->fontpathListBox->currentRow() < 1) + if (fontpathlistbox->currentItem() < 1) return; - int row = ui->fontpathListBox->currentRow(); - QString fam = fontpaths.at(row); - fontpaths.removeAt(row); - fontpaths.insert(row - 1, fam); - ui->fontpathListBox->clear(); - ui->fontpathListBox->insertItems(0, fontpaths); - ui->fontpathListBox->setCurrentRow(row - 1); + int item = fontpathlistbox->currentItem(); + QString fam = fontpaths.at(item); + fontpaths.removeAt(item); + fontpaths.insert(item-1, fam); + fontpathlistbox->clear(); + fontpathlistbox->insertStringList(fontpaths); + fontpathlistbox->setCurrentItem(item - 1); setModified(true); } + void MainWindow::browseFontpath() { - QString dirname = QFileDialog::getExistingDirectory(this, tr("Select a Directory")); + QString dirname = QFileDialog::getExistingDirectory(QString(), this, 0, + tr("Select a Directory")); if (dirname.isNull()) return; - ui->fontPathLineEdit->setText(dirname); + fontpathlineedit->setText(dirname); } + void MainWindow::somethingModified() { setModified(true); } + void MainWindow::helpAbout() { QMessageBox box(this); @@ -905,42 +1010,44 @@ void MainWindow::helpAbout() box.exec(); } + void MainWindow::helpAboutQt() { QMessageBox::aboutQt(this, tr("Qt Configuration")); } + void MainWindow::pageChanged(QWidget *page) { - if (page == ui->interfaceTab) - ui->helpView->setText(tr(interface_text)); - else if (page == ui->appearanceTab) - ui->helpView->setText(tr(appearance_text)); - else if (page == ui->fontsTab) - ui->helpView->setText(tr(font_text)); - else if (page == ui->printerTab) - ui->helpView->setText(tr(printer_text)); - else if (page == ui->phononTab) - ui->helpView->setText(tr(phonon_text)); + if (page == tab) + helpview->setText(tr(interface_text)); + else if (page == tab1) + helpview->setText(tr(appearance_text)); + else if (page == tab2) + helpview->setText(tr(font_text)); + else if (page == tab3) + helpview->setText(tr(printer_text)); + else if (page == tab4) + helpview->setText(tr(phonon_text)); } + void MainWindow::closeEvent(QCloseEvent *e) { if (modified) { - switch (QMessageBox::warning(this, tr("Save Changes"), - tr("Save changes to settings?"), - (QMessageBox::Yes | QMessageBox::No - | QMessageBox::Cancel))) { - case QMessageBox::Yes: // save + switch(QMessageBox::warning(this, tr("Save Changes"), + tr("Save changes to settings?"), + tr("&Yes"), tr("&No"), tr("&Cancel"), 0, 2)) { + case 0: // save qApp->processEvents(); fileSave(); // fall through intended - case QMessageBox::No: // don't save + case 1: // don't save e->accept(); break; - case QMessageBox::Cancel: // cancel + case 2: // cancel e->ignore(); break; diff --git a/tools/qtconfig/mainwindow.h b/tools/qtconfig/mainwindow.h index 50d73f9..9bc8068 100644 --- a/tools/qtconfig/mainwindow.h +++ b/tools/qtconfig/mainwindow.h @@ -42,15 +42,11 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include +#include "mainwindowbase.h" QT_BEGIN_NAMESPACE -namespace Ui { - class MainWindow; -} - -class MainWindow : public QMainWindow +class MainWindow : public MainWindowBase { Q_OBJECT @@ -60,6 +56,7 @@ public: void closeEvent(QCloseEvent *); + public slots: virtual void buildPalette(); virtual void buildFont(); @@ -86,17 +83,21 @@ public slots: private: + void buildActive(); + void buildActiveEffect(); + void buildInactive(); + void buildInactiveEffect(); + void buildDisabled(); + void buildDisabledEffect(); + void updateColorButtons(); void updateFontSample(); void updateStyleLayout(); - static QPalette::ColorGroup groupFromIndex(int); - void setPreviewPalette(const QPalette &); void setModified(bool); - Ui::MainWindow *ui; QString desktopThemeName; QPalette editPalette, previewPalette; QStyle *previewstyle; diff --git a/tools/qtconfig/mainwindow.ui b/tools/qtconfig/mainwindow.ui deleted file mode 100644 index 2ca9101..0000000 --- a/tools/qtconfig/mainwindow.ui +++ /dev/null @@ -1,1388 +0,0 @@ - - - ********************************************************************* -** -** 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 tools applications 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$ -** -********************************************************************* - MainWindow - - - - 0 - 0 - 815 - 716 - - - - Qt Configuration - - - - - 8 - - - - - - 200 - 0 - - - - true - - - - - - - 0 - - - - Appearance - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - GUI Style - - - - 4 - - - 8 - - - - - - 0 - 0 - - - - Select GUI &Style: - - - guiStyleCombo - - - - - - - - - - - - - - 0 - 0 - - - - Preview - - - - - - Select &Palette: - - - paletteCombo - - - - - - - - Active Palette - - - - - Inactive Palette - - - - - Disabled Palette - - - - - - - - - 0 - 0 - - - - - 410 - 260 - - - - - - - - - - - - 0 - 0 - - - - - 400 - 0 - - - - Build Palette - - - - - - - 0 - - - - - &Button Background: - - - buttonMainColor - - - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - 1 - - - 0 - - - Window Back&ground: - - - Qt::AlignVCenter - - - 0 - - - buttonWindowColor - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 70 - 20 - - - - - - - - &Tune Palette... - - - - - - - - - - Please use the KDE Control Center to set the palette. - - - - - - - - - - - Fonts - - - - - - Default Font - - - - 8 - - - 4 - - - - - true - - - false - - - - - - - true - - - false - - - - - - - true - - - true - - - false - - - - - - - &Style: - - - fontStyleCombo - - - - - - - &Point Size: - - - pointSizeCombo - - - - - - - F&amily: - - - fontFamilyCombo - - - - - - - Sample Text - - - Qt::AlignHCenter - - - - - - - - - - Font Substitution - - - - 4 - - - 8 - - - - - 4 - - - 0 - - - - - S&elect or Enter a Family: - - - familySubstitutionCombo - - - - - - - true - - - true - - - false - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - Qt::Horizontal - - - - - - - Current Substitutions: - - - - - - - - - - 4 - - - 0 - - - - - Up - - - - - - - Down - - - - - - - Remove - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - Qt::Horizontal - - - - - - - 4 - - - 0 - - - - - Select s&ubstitute Family: - - - chooseSubstitutionCombo - - - - - - - true - - - false - - - - - - - Add - - - - - - - - - - - - - Interface - - - - - - Feel Settings - - - - 8 - - - 4 - - - - - ms - - - 10 - - - 10000 - - - - - - - &Double Click Interval: - - - doubleClickIntervalSpinBox - - - - - - - No blinking - - - ms - - - 9 - - - 10000 - - - - - - - &Cursor Flash Time: - - - cursorFlashTimeSpinBox - - - - - - - lines - - - 1 - - - 20 - - - - - - - Wheel &Scroll Lines: - - - wheelScrollLinesSpinBox - - - - - - - Resolve symlinks in URLs - - - - - - - - - - GUI Effects - - - - 4 - - - 8 - - - - - &Enable - - - Alt+E - - - - - - - - 4 - - - - - &Menu Effect: - - - menuEffectCombo - - - - - - - C&omboBox Effect: - - - comboEffectCombo - - - - - - - &ToolTip Effect: - - - toolTipEffectCombo - - - - - - - Tool&Box Effect: - - - toolBoxEffectCombo - - - - - - - 0 - - - true - - - - Disable - - - - - Animate - - - - - Fade - - - - - - - - - Disable - - - - - Animate - - - - - - - - - Disable - - - - - Animate - - - - - Fade - - - - - - - - - Disable - - - - - Animate - - - - - - - - - - - - - - Global Strut - - - - 8 - - - 4 - - - - - Minimum &Width: - - - strutWidthSpinBox - - - - - - - Minimum Hei&ght: - - - strutHeightSpinBox - - - - - - - pixels - - - 1000 - - - - - - - pixels - - - 1000 - - - - - - - - - - Enhanced support for languages written right-to-left - - - - - - - XIM Input Style: - - - - - - - 0 - - - - On The Spot - - - - - Over The Spot - - - - - Off The Spot - - - - - Root - - - - - - - - Default Input Method: - - - - - - - -1 - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - - Printer - - - - - - Enable Font embedding - - - true - - - - - - - - 0 - 0 - - - - Font Paths - - - - 4 - - - 8 - - - - - 0 - - - 4 - - - - - Up - - - - - - - Remove - - - - - - - Down - - - - - - - - - - - - 0 - - - 4 - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 20 - 20 - - - - - - - - Add - - - - - - - Browse... - - - - - - - Press the <b>Browse</b> button or enter a directory and press Enter to add them to the list. - - - - - - - - - - - - - - - - Phonon - - - - - - About Phonon - - - - - - Current Version: - - - - - - - Not available - - - - - - - Website: - - - - - - - <a href="http://phonon.kde.org">http://phonon.kde.org/</a> - - - true - - - - - - - - - - About GStreamer - - - - - - Current Version: - - - - - - - Not available - - - - - - - Website: - - - - - - - <a href="http://gstreamer.freedesktop.org/">http://gstreamer.freedesktop.org/</a> - - - true - - - - - - - - - - GStreamer backend settings - - - - - - Preferred audio sink: - - - audiosinkCombo - - - - - - - - - - Preferred render method: - - - videomodeCombo - - - - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Note: changes to these settings may prevent applications from starting up correctly.</span></p></body></html> - - - Qt::RichText - - - false - - - true - - - 2 - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - 0 - 0 - 815 - 19 - - - - - - 203 - 114 - 161 - 110 - - - - &File - - - - - - - - - 543 - 98 - 161 - 106 - - - - &Help - - - - - - - - - - - &Save - - - Save - - - Ctrl+S - - - - - E&xit - - - Exit - - - Ctrl+Q - - - - - &About - - - About - - - - - - - - About &Qt - - - About Qt - - - - - - ColorButton - -

colorbutton.h
- - - PreviewFrame - -
previewframe.h
-
- - - helpView - mainTabWidget - guiStyleCombo - tunePaletteButton - paletteCombo - fontFamilyCombo - fontStyleCombo - pointSizeCombo - sampleLineEdit - familySubstitutionCombo - substitutionsListBox - upSubstitutionButton - downSubstitutionButton - removeSubstitutionButton - chooseSubstitutionCombo - addSubstitutionButton - doubleClickIntervalSpinBox - cursorFlashTimeSpinBox - wheelScrollLinesSpinBox - resolveLinksCheckBox - effectsCheckBox - menuEffectCombo - comboEffectCombo - toolTipEffectCombo - toolBoxEffectCombo - strutWidthSpinBox - strutHeightSpinBox - rtlExtensionsCheckBox - inputStyleCombo - inputMethodCombo - fontEmbeddingCheckBox - fontpathListBox - upFontpathButton - downFontpathButton - removeFontpathButton - fontPathLineEdit - browseFontPathButton - addFontPathButton - audiosinkCombo - videomodeCombo - - - - - effectsCheckBox - toggled(bool) - effectsFrame - setEnabled(bool) - - - 417 - 257 - - - 578 - 379 - - - - - fontEmbeddingCheckBox - toggled(bool) - fontPathsGroup - setEnabled(bool) - - - 449 - 69 - - - 447 - 94 - - - - -
diff --git a/tools/qtconfig/mainwindowbase.cpp b/tools/qtconfig/mainwindowbase.cpp new file mode 100644 index 0000000..2460bca --- /dev/null +++ b/tools/qtconfig/mainwindowbase.cpp @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** 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 tools applications 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 "mainwindowbase.h" +#include "colorbutton.h" +#include "previewframe.h" + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +/* + * Constructs a MainWindowBase as a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + * + */ +MainWindowBase::MainWindowBase(QWidget* parent, const char* name, Qt::WindowFlags fl) + : Q3MainWindow(parent, name, fl) +{ + setupUi(this); + + (void)statusBar(); + + // signals and slots connections + connect(fontpathlineedit, SIGNAL(returnPressed()), this, SLOT(addFontpath())); + connect(PushButton15, SIGNAL(clicked()), this, SLOT(addFontpath())); + connect(PushButton1, SIGNAL(clicked()), this, SLOT(addSubstitute())); + connect(PushButton14, SIGNAL(clicked()), this, SLOT(browseFontpath())); + connect(stylecombo, SIGNAL(activated(int)), this, SLOT(buildFont())); + connect(psizecombo, SIGNAL(activated(int)), this, SLOT(buildFont())); + connect(PushButton12, SIGNAL(clicked()), this, SLOT(downFontpath())); + connect(PushButton3, SIGNAL(clicked()), this, SLOT(downSubstitute())); + connect(familycombo, SIGNAL(activated(QString)), this, SLOT(familySelected(QString))); + connect(fileExitAction, SIGNAL(activated()), this, SLOT(fileExit())); + connect(fileSaveAction, SIGNAL(activated()), this, SLOT(fileSave())); + connect(helpAboutAction, SIGNAL(activated()), this, SLOT(helpAbout())); + connect(helpAboutQtAction, SIGNAL(activated()), this, SLOT(helpAboutQt())); + connect(TabWidget3, SIGNAL(currentChanged(QWidget*)), this, SLOT(pageChanged(QWidget*))); + connect(paletteCombo, SIGNAL(activated(int)), this, SLOT(paletteSelected(int))); + connect(PushButton13, SIGNAL(clicked()), this, SLOT(removeFontpath())); + connect(PushButton4, SIGNAL(clicked()), this, SLOT(removeSubstitute())); + connect(effectcheckbox, SIGNAL(toggled(bool)), effectbase, SLOT(setEnabled(bool))); + connect(fontembeddingcheckbox, SIGNAL(toggled(bool)), GroupBox10, SLOT(setEnabled(bool))); + connect(toolboxeffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); + connect(dcispin, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); + connect(cfispin, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); + connect(wslspin, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); + connect(menueffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); + connect(comboeffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); + connect(audiosinkCombo, SIGNAL(activated(int)), this, SLOT(somethingModified())); + connect(videomodeCombo, SIGNAL(activated(int)), this, SLOT(somethingModified())); + connect(tooltipeffect, SIGNAL(activated(int)), this, SLOT(somethingModified())); + connect(strutwidth, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); + connect(strutheight, SIGNAL(valueChanged(int)), this, SLOT(somethingModified())); + connect(effectcheckbox, SIGNAL(toggled(bool)), this, SLOT(somethingModified())); + connect(resolvelinks, SIGNAL(toggled(bool)), this, SLOT(somethingModified())); + connect(fontembeddingcheckbox, SIGNAL(clicked()), this, SLOT(somethingModified())); + connect(rtlExtensions, SIGNAL(toggled(bool)), this, SLOT(somethingModified())); + connect(inputStyle, SIGNAL(activated(int)), this, SLOT(somethingModified())); + connect(inputMethod, SIGNAL(activated(int)), this, SLOT(somethingModified())); + connect(gstylecombo, SIGNAL(activated(QString)), this, SLOT(styleSelected(QString))); + connect(familysubcombo, SIGNAL(activated(QString)), this, SLOT(substituteSelected(QString))); + connect(btnAdvanced, SIGNAL(clicked()), this, SLOT(tunePalette())); + connect(PushButton11, SIGNAL(clicked()), this, SLOT(upFontpath())); + connect(PushButton2, SIGNAL(clicked()), this, SLOT(upSubstitute())); + init(); +} + +/* + * Destroys the object and frees any allocated resources + */ +MainWindowBase::~MainWindowBase() +{ + destroy(); + // no need to delete child widgets, Qt does it all for us +} + +/* + * Sets the strings of the subwidgets using the current + * language. + */ +void MainWindowBase::languageChange() +{ + retranslateUi(this); +} + +void MainWindowBase::init() +{ +} + +void MainWindowBase::destroy() +{ +} + +void MainWindowBase::addFontpath() +{ + qWarning("MainWindowBase::addFontpath(): Not implemented yet"); +} + +void MainWindowBase::addSubstitute() +{ + qWarning("MainWindowBase::addSubstitute(): Not implemented yet"); +} + +void MainWindowBase::browseFontpath() +{ + qWarning("MainWindowBase::browseFontpath(): Not implemented yet"); +} + +void MainWindowBase::buildFont() +{ + qWarning("MainWindowBase::buildFont(): Not implemented yet"); +} + +void MainWindowBase::buildPalette() +{ + qWarning("MainWindowBase::buildPalette(): Not implemented yet"); +} + +void MainWindowBase::downFontpath() +{ + qWarning("MainWindowBase::downFontpath(): Not implemented yet"); +} + +void MainWindowBase::downSubstitute() +{ + qWarning("MainWindowBase::downSubstitute(): Not implemented yet"); +} + +void MainWindowBase::familySelected( const QString &) +{ + qWarning("MainWindowBase::familySelected( const QString &): Not implemented yet"); +} + +void MainWindowBase::fileExit() +{ + qWarning("MainWindowBase::fileExit(): Not implemented yet"); +} + +void MainWindowBase::fileSave() +{ + qWarning("MainWindowBase::fileSave(): Not implemented yet"); +} + +void MainWindowBase::helpAbout() +{ + qWarning("MainWindowBase::helpAbout(): Not implemented yet"); +} + +void MainWindowBase::helpAboutQt() +{ + qWarning("MainWindowBase::helpAboutQt(): Not implemented yet"); +} + +void MainWindowBase::new_slot() +{ + qWarning("MainWindowBase::new_slot(): Not implemented yet"); +} + +void MainWindowBase::pageChanged( QWidget *) +{ + qWarning("MainWindowBase::pageChanged( QWidget *): Not implemented yet"); +} + +void MainWindowBase::paletteSelected(int) +{ + qWarning("MainWindowBase::paletteSelected(int): Not implemented yet"); +} + +void MainWindowBase::removeFontpath() +{ + qWarning("MainWindowBase::removeFontpath(): Not implemented yet"); +} + +void MainWindowBase::removeSubstitute() +{ + qWarning("MainWindowBase::removeSubstitute(): Not implemented yet"); +} + +void MainWindowBase::somethingModified() +{ + qWarning("MainWindowBase::somethingModified(): Not implemented yet"); +} + +void MainWindowBase::styleSelected( const QString &) +{ + qWarning("MainWindowBase::styleSelected( const QString &): Not implemented yet"); +} + +void MainWindowBase::substituteSelected( const QString &) +{ + qWarning("MainWindowBase::substituteSelected( const QString &): Not implemented yet"); +} + +void MainWindowBase::tunePalette() +{ + qWarning("MainWindowBase::tunePalette(): Not implemented yet"); +} + +void MainWindowBase::upFontpath() +{ + qWarning("MainWindowBase::upFontpath(): Not implemented yet"); +} + +void MainWindowBase::upSubstitute() +{ + qWarning("MainWindowBase::upSubstitute(): Not implemented yet"); +} + +QT_END_NAMESPACE diff --git a/tools/qtconfig/mainwindowbase.h b/tools/qtconfig/mainwindowbase.h new file mode 100644 index 0000000..1e1dabf --- /dev/null +++ b/tools/qtconfig/mainwindowbase.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 tools applications 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 MAINWINDOWBASE_H +#define MAINWINDOWBASE_H + +#include "ui_mainwindowbase.h" +#include + +QT_BEGIN_NAMESPACE + +class ColorButton; +class PreviewFrame; + +class MainWindowBase : public Q3MainWindow, public Ui::MainWindowBase +{ + Q_OBJECT + +public: + MainWindowBase(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = Qt::Window); + ~MainWindowBase(); + +public slots: + virtual void addFontpath(); + virtual void addSubstitute(); + virtual void browseFontpath(); + virtual void buildFont(); + virtual void buildPalette(); + virtual void downFontpath(); + virtual void downSubstitute(); + virtual void familySelected( const QString & ); + virtual void fileExit(); + virtual void fileSave(); + virtual void helpAbout(); + virtual void helpAboutQt(); + virtual void new_slot(); + virtual void pageChanged( QWidget * ); + virtual void paletteSelected( int ); + virtual void removeFontpath(); + virtual void removeSubstitute(); + virtual void somethingModified(); + virtual void styleSelected( const QString & ); + virtual void substituteSelected( const QString & ); + virtual void tunePalette(); + virtual void upFontpath(); + virtual void upSubstitute(); + +protected slots: + virtual void languageChange(); + + virtual void init(); + virtual void destroy(); +}; + +QT_END_NAMESPACE + +#endif // MAINWINDOWBASE_H diff --git a/tools/qtconfig/mainwindowbase.ui b/tools/qtconfig/mainwindowbase.ui new file mode 100644 index 0000000..b09abd0 --- /dev/null +++ b/tools/qtconfig/mainwindowbase.ui @@ -0,0 +1,1384 @@ + + + ********************************************************************* +** +** 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 tools applications 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$ +** +********************************************************************* + MainWindowBase + + + + 0 + 0 + 815 + 716 + + + + Qt Configuration + + + + + 0 + 26 + 815 + 690 + + + + + 8 + + + + + + 200 + 0 + + + + true + + + + + + + 0 + + + + Appearance + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + GUI Style + + + + 4 + + + 8 + + + + + + 0 + 0 + + + + Select GUI &Style: + + + gstylecombo + + + + + + + + + + + + + + 0 + 0 + + + + Preview + + + + + + Select &Palette: + + + paletteCombo + + + + + + + + Active Palette + + + + + Inactive Palette + + + + + Disabled Palette + + + + + + + + + 0 + 0 + + + + + 410 + 260 + + + + + + + + + + + + 0 + 0 + + + + + 400 + 0 + + + + Build Palette + + + + + + + 0 + + + + + &3-D Effects: + + + buttonMainColor + + + + + + + + + + + 0 + 0 + + + + + 50 + 0 + + + + 1 + + + 0 + + + Window Back&ground: + + + Qt::AlignVCenter + + + 0 + + + buttonMainColor2 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 70 + 20 + + + + + + + + &Tune Palette... + + + + + + + + + + Please use the KDE Control Center to set the palette. + + + + + + + + + + + Fonts + + + + + + Default Font + + + + 8 + + + 4 + + + + + true + + + false + + + + + + + true + + + false + + + + + + + true + + + true + + + false + + + + + + + &Style: + + + stylecombo + + + + + + + &Point Size: + + + psizecombo + + + + + + + F&amily: + + + familycombo + + + + + + + Sample Text + + + Qt::AlignHCenter + + + + + + + + + + Font Substitution + + + + 4 + + + 8 + + + + + 4 + + + 0 + + + + + S&elect or Enter a Family: + + + familysubcombo + + + + + + + true + + + true + + + false + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + Qt::Horizontal + + + + + + + Current Substitutions: + + + + + + + + + + 4 + + + 0 + + + + + Up + + + + + + + Down + + + + + + + Remove + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + Qt::Horizontal + + + + + + + 4 + + + 0 + + + + + Select s&ubstitute Family: + + + choosesubcombo + + + + + + + true + + + false + + + + + + + Add + + + + + + + + + + + + + Interface + + + + + + Feel Settings + + + + 8 + + + 4 + + + + + ms + + + 10 + + + 10000 + + + + + + + &Double Click Interval: + + + dcispin + + + + + + + No blinking + + + ms + + + 9 + + + 10000 + + + + + + + &Cursor Flash Time: + + + cfispin + + + + + + + lines + + + 1 + + + 20 + + + + + + + Wheel &Scroll Lines: + + + wslspin + + + + + + + Resolve symlinks in URLs + + + + + + + + + + GUI Effects + + + + 4 + + + 8 + + + + + &Enable + + + Alt+E + + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + + 0 + + + 4 + + + + + &Menu Effect: + + + menueffect + + + + + + + C&omboBox Effect: + + + comboeffect + + + + + + + &ToolTip Effect: + + + tooltipeffect + + + + + + + Tool&Box Effect: + + + toolboxeffect + + + + + + + 0 + + + true + + + + Disable + + + + + Animate + + + + + Fade + + + + + + + + + Disable + + + + + Animate + + + + + + + + + Disable + + + + + Animate + + + + + Fade + + + + + + + + + Disable + + + + + Animate + + + + + + + + + + + + + + Global Strut + + + + 8 + + + 4 + + + + + Minimum &Width: + + + strutwidth + + + + + + + Minimum Hei&ght: + + + strutheight + + + + + + + pixels + + + 1000 + + + + + + + pixels + + + 1000 + + + + + + + + + + Enhanced support for languages written right-to-left + + + + + + + XIM Input Style: + + + + + + + 0 + + + + On The Spot + + + + + Over The Spot + + + + + Off The Spot + + + + + Root + + + + + + + + Default Input Method: + + + + + + + -1 + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 40 + + + + + + + + + Printer + + + + + + Enable Font embedding + + + true + + + + + + + + 0 + 0 + + + + Font Paths + + + + 4 + + + 8 + + + + + 0 + + + 4 + + + + + Up + + + + + + + Remove + + + + + + + Down + + + + + + + + + + + + 0 + + + 4 + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 20 + 20 + + + + + + + + Add + + + + + + + Browse... + + + + + + + Press the <b>Browse</b> button or enter a directory and press Enter to add them to the list. + + + + + + + + + + + + + + + + Phonon + + + + + + About Phonon + + + + + + Current Version: + + + + + + + Not available + + + + + + + Website: + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://phonon.kde.org"><span style=" text-decoration: underline; color:#0000ff;">http://phonon.kde.org</span></a></p></body></html> + + + true + + + + + + + + + + About GStreamer + + + + + + Current Version: + + + + + + + Not available + + + + + + + Website: + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://gstreamer.freedesktop.org/"><span style=" text-decoration: underline; color:#0000ff;">http://gstreamer.freedesktop.org/</span></a></p></body></html> + + + true + + + + + + + + + + GStreamer backend settings + + + + + + Preferred audio sink: + + + audiosinkCombo + + + + + + + + + + Preferred render method: + + + videomodeCombo + + + + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-style:italic;">Note: changes to these settings may prevent applications from starting up correctly.</span></p></body></html> + + + Qt::RichText + + + false + + + true + + + 2 + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + 0 + 0 + 815 + 26 + + + + + + 0 + 0 + 123 + 92 + + + + &File + + + + + + + + + + + + 0 + 0 + 123 + 90 + + + + &Help + + + + + + + + + + + + + + &Save + + + Save + + + Ctrl+S + + + + + E&xit + + + Exit + + + + + + + + &About + + + About + + + + + + + + About &Qt + + + About Qt + + + + + + Q3Frame + QFrame +
Qt3Support/Q3Frame
+ 1 +
+ + Q3MainWindow + QWidget +
q3mainwindow.h
+ 1 +
+ + Q3ListBox + Q3Frame +
q3listbox.h
+
+ + ColorButton + +
colorbutton.h
+
+ + PreviewFrame + +
previewframe.h
+
+
+ + helpview + familycombo + stylecombo + psizecombo + samplelineedit + familysubcombo + PushButton2 + PushButton3 + PushButton4 + choosesubcombo + PushButton1 + dcispin + cfispin + wslspin + effectcheckbox + menueffect + comboeffect + tooltipeffect + strutwidth + strutheight + sublistbox + + + +
diff --git a/tools/qtconfig/paletteeditoradvanced.cpp b/tools/qtconfig/paletteeditoradvanced.cpp index a700b8d..f59584e 100644 --- a/tools/qtconfig/paletteeditoradvanced.cpp +++ b/tools/qtconfig/paletteeditoradvanced.cpp @@ -38,74 +38,58 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "ui_paletteeditoradvanced.h" + #include "paletteeditoradvanced.h" #include "colorbutton.h" +#include +#include +#include +#include +#include +#include + QT_BEGIN_NAMESPACE -PaletteEditorAdvanced::PaletteEditorAdvanced(QWidget *parent) - : QDialog(parent), ui(new Ui::PaletteEditorAdvanced), selectedPalette(0) +PaletteEditorAdvanced::PaletteEditorAdvanced( QWidget * parent, + const char * name, bool modal, Qt::WindowFlags f ) + : PaletteEditorAdvancedBase( parent, name, modal, f ), selectedPalette(0) { - ui->setupUi(this); - - // create a ColorButton's - buttonCentral = new ColorButton(ui->groupCentral); - buttonCentral->setToolTip(tr("Choose a color")); - buttonCentral->setWhatsThis(tr("Choose a color for the selected central color role.")); - ui->layoutCentral->addWidget(buttonCentral); - ui->labelCentral->setBuddy(buttonCentral); - - buttonEffect = new ColorButton(ui->groupEffect); - buttonEffect->setToolTip(tr("Choose a color")); - buttonEffect->setWhatsThis(tr("Choose a color for the selected effect color role.")); + // work around buggy UI file + comboEffect->setEnabled(false); buttonEffect->setEnabled(false); - ui->layoutEffect->addWidget(buttonEffect); - ui->labelEffect->setBuddy(buttonEffect); - - // signals and slots connections - connect(ui->paletteCombo, SIGNAL(activated(int)), SLOT(paletteSelected(int))); - connect(ui->comboCentral, SIGNAL(activated(int)), SLOT(onCentral(int))); - connect(buttonCentral, SIGNAL(clicked()), SLOT(onChooseCentralColor())); - connect(buttonEffect, SIGNAL(clicked()), SLOT(onChooseEffectColor())); - connect(ui->comboEffect, SIGNAL(activated(int)), SLOT(onEffect(int))); - connect(ui->checkBuildEffect, SIGNAL(toggled(bool)), SLOT(onToggleBuildEffects(bool))); - connect(ui->checkBuildEffect, SIGNAL(toggled(bool)), buttonEffect, SLOT(setDisabled(bool))); - connect(ui->checkBuildInactive, SIGNAL(toggled(bool)), SLOT(onToggleBuildInactive(bool))); - connect(ui->checkBuildDisabled, SIGNAL(toggled(bool)), SLOT(onToggleBuildDisabled(bool))); - onToggleBuildEffects(true); editPalette = QApplication::palette(); + setPreviewPalette( editPalette ); } PaletteEditorAdvanced::~PaletteEditorAdvanced() { - delete ui; } -void PaletteEditorAdvanced::onToggleBuildInactive(bool v) +void PaletteEditorAdvanced::onToggleBuildInactive( bool v ) { if (selectedPalette == 1) { - ui->groupCentral->setDisabled(v); - ui->groupEffect->setDisabled(v); + groupCentral->setDisabled(v); + groupEffect->setDisabled(v); } if (v) { - build(QPalette::Inactive); + buildInactive(); updateColorButtons(); } } -void PaletteEditorAdvanced::onToggleBuildDisabled(bool v) +void PaletteEditorAdvanced::onToggleBuildDisabled( bool v ) { if (selectedPalette == 2) { - ui->groupCentral->setDisabled(v); - ui->groupEffect->setDisabled(v); + groupCentral->setDisabled(v); + groupEffect->setDisabled(v); } if (v) { - build(QPalette::Disabled); + buildDisabled(); updateColorButtons(); } } @@ -115,204 +99,402 @@ void PaletteEditorAdvanced::paletteSelected(int p) selectedPalette = p; if(p == 1) { // inactive - ui->groupCentral->setDisabled(ui->checkBuildInactive->isChecked()); - ui->groupEffect->setDisabled(ui->checkBuildInactive->isChecked()); - } else if (p == 2) { // disabled - ui->groupCentral->setDisabled(ui->checkBuildDisabled->isChecked()); - ui->groupEffect->setDisabled(ui->checkBuildDisabled->isChecked()); - } else { - ui->groupCentral->setEnabled(true); - ui->groupEffect->setEnabled(true); + groupCentral->setDisabled(checkBuildInactive->isChecked()); + groupEffect->setDisabled(checkBuildInactive->isChecked()); + } + else if (p == 2) { // disabled + groupCentral->setDisabled(checkBuildDisabled->isChecked()); + groupEffect->setDisabled(checkBuildDisabled->isChecked()); + } + else { + groupCentral->setEnabled(true); + groupEffect->setEnabled(true); } updateColorButtons(); } void PaletteEditorAdvanced::onChooseCentralColor() { - QPalette::ColorGroup group = groupFromIndex(selectedPalette); - editPalette.setColor(group, centralFromIndex(ui->comboCentral->currentIndex()), - buttonCentral->color()); - - buildEffect(group); - if (group == QPalette::Active) { - if(ui->checkBuildInactive->isChecked()) - build(QPalette::Inactive); - if(ui->checkBuildDisabled->isChecked()) - build(QPalette::Disabled); + switch(selectedPalette) { + case 0: + default: + mapToActiveCentralRole( buttonCentral->color() ); + break; + case 1: + mapToInactiveCentralRole( buttonCentral->color() ); + break; + case 2: + mapToDisabledCentralRole( buttonCentral->color() ); + break; } - updateColorButtons(); } void PaletteEditorAdvanced::onChooseEffectColor() { - QPalette::ColorGroup group = groupFromIndex(selectedPalette); - editPalette.setColor(group, effectFromIndex(ui->comboEffect->currentIndex()), - buttonEffect->color()); - - if (group == QPalette::Active) { - if(ui->checkBuildInactive->isChecked()) - build(QPalette::Inactive); - if(ui->checkBuildDisabled->isChecked()) - build(QPalette::Disabled); + switch(selectedPalette) { + case 0: + default: + mapToActiveEffectRole( buttonEffect->color() ); + break; + case 1: + mapToInactiveEffectRole( buttonEffect->color() ); + break; + case 2: + mapToDisabledEffectRole( buttonEffect->color() ); + break; } - updateColorButtons(); } -void PaletteEditorAdvanced::onToggleBuildEffects(bool on) +void PaletteEditorAdvanced::onToggleBuildEffects( bool on ) { - if (on) { - for (int i = 0; i < QPalette::NColorGroups; i++) - buildEffect(QPalette::ColorGroup(i)); - } + if (!on) return; + buildActiveEffect(); + buildInactiveEffect(); + buildDisabledEffect(); } -QPalette::ColorGroup PaletteEditorAdvanced::groupFromIndex(int item) +QColorGroup::ColorRole PaletteEditorAdvanced::centralFromItem( int item ) { - switch (item) { - case 0: - default: - return QPalette::Active; - case 1: - return QPalette::Inactive; - case 2: - return QPalette::Disabled; + switch( item ) { + case 0: + return QColorGroup::Window; + case 1: + return QColorGroup::WindowText; + case 2: + return QColorGroup::Button; + case 3: + return QColorGroup::Base; + case 4: + return QColorGroup::Text; + case 5: + return QColorGroup::BrightText; + case 6: + return QColorGroup::ButtonText; + case 7: + return QColorGroup::Highlight; + case 8: + return QColorGroup::HighlightedText; + default: + return QColorGroup::NColorRoles; } } -QPalette::ColorRole PaletteEditorAdvanced::centralFromIndex(int item) +QColorGroup::ColorRole PaletteEditorAdvanced::effectFromItem( int item ) + { - switch (item) { + switch( item ) { case 0: - return QPalette::Window; + return QColorGroup::Light; case 1: - return QPalette::WindowText; + return QColorGroup::Midlight; case 2: - return QPalette::Base; + return QColorGroup::Mid; case 3: - return QPalette::AlternateBase; + return QColorGroup::Dark; case 4: - return QPalette::ToolTipBase; - case 5: - return QPalette::ToolTipText; - case 6: - return QPalette::Text; - case 7: - return QPalette::Button; - case 8: - return QPalette::ButtonText; - case 9: - return QPalette::BrightText; - case 10: - return QPalette::Highlight; - case 11: - return QPalette::HighlightedText; - case 12: - return QPalette::Link; - case 13: - return QPalette::LinkVisited; + return QColorGroup::Shadow; default: - return QPalette::NoRole; + return QColorGroup::NColorRoles; } } -QPalette::ColorRole PaletteEditorAdvanced::effectFromIndex(int item) +void PaletteEditorAdvanced::onCentral( int item ) { - switch (item) { + QColor c; + + switch(selectedPalette) { case 0: - return QPalette::Light; + default: + c = editPalette.active().color( centralFromItem(item) ); + break; case 1: - return QPalette::Midlight; + c = editPalette.inactive().color( centralFromItem(item) ); + break; case 2: - return QPalette::Mid; - case 3: - return QPalette::Dark; - case 4: - return QPalette::Shadow; + c = editPalette.disabled().color( centralFromItem(item) ); + break; + } + + buttonCentral->setColor(c); +} + +void PaletteEditorAdvanced::onEffect( int item ) +{ + QColor c; + switch(selectedPalette) { + case 0: default: - return QPalette::NoRole; + c = editPalette.active().color( effectFromItem(item) ); + break; + case 1: + editPalette.inactive().color( effectFromItem(item) ); + break; + case 2: + editPalette.disabled().color( effectFromItem(item) ); + break; } + buttonEffect->setColor(c); } -void PaletteEditorAdvanced::onCentral(int item) +void PaletteEditorAdvanced::mapToActiveCentralRole( const QColor& c ) { - QColor c = editPalette.color(groupFromIndex(selectedPalette), centralFromIndex(item)); - buttonCentral->setColor(c); + QColorGroup cg = editPalette.active(); + cg.setColor( centralFromItem(comboCentral->currentItem()), c ); + editPalette.setActive( cg ); + + buildActiveEffect(); + if(checkBuildInactive->isChecked()) + buildInactive(); + if(checkBuildDisabled->isChecked()) + buildDisabled(); + + setPreviewPalette( editPalette ); } -void PaletteEditorAdvanced::onEffect(int item) +void PaletteEditorAdvanced::mapToActiveEffectRole( const QColor& c ) { - QColor c = editPalette.color(groupFromIndex(selectedPalette), effectFromIndex(item)); - buttonEffect->setColor(c); + QColorGroup cg = editPalette.active(); + cg.setColor( effectFromItem(comboEffect->currentItem()), c ); + editPalette.setActive( cg ); + + if(checkBuildInactive->isChecked()) + buildInactive(); + if(checkBuildDisabled->isChecked()) + buildDisabled(); + + setPreviewPalette( editPalette ); +} + +void PaletteEditorAdvanced::mapToActivePixmapRole( const QPixmap& pm ) +{ + QColorGroup::ColorRole role = centralFromItem(comboCentral->currentItem()); + QColorGroup cg = editPalette.active(); + if ( !pm.isNull() ) + cg.setBrush( role, QBrush( cg.color( role ), pm ) ); + else + cg.setBrush( role, QBrush( cg.color( role ) ) ); + editPalette.setActive( cg ); + + + buildActiveEffect(); + if(checkBuildInactive->isChecked()) + buildInactive(); + if(checkBuildDisabled->isChecked()) + buildDisabled(); + + setPreviewPalette( editPalette ); } -QPalette PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup colorGroup, - const QPalette &basePalette) +void PaletteEditorAdvanced::mapToInactiveCentralRole( const QColor& c ) { - QPalette result(basePalette); + QColorGroup cg = editPalette.inactive(); + cg.setColor( centralFromItem(comboCentral->currentItem()), c ); + editPalette.setInactive( cg ); - if (colorGroup == QPalette::Active) { - QPalette calculatedPalette(basePalette.color(colorGroup, QPalette::Button), - basePalette.color(colorGroup, QPalette::Window)); + buildInactiveEffect(); - for (int i = 0; i < 5; i++) { - QPalette::ColorRole effectRole = effectFromIndex(i); - result.setColor(colorGroup, effectRole, - calculatedPalette.color(colorGroup, effectRole)); - } - } else { - QColor btn = basePalette.color(colorGroup, QPalette::Button); + setPreviewPalette( editPalette ); +} + +void PaletteEditorAdvanced::mapToInactiveEffectRole( const QColor& c ) +{ + QColorGroup cg = editPalette.inactive(); + cg.setColor( effectFromItem(comboEffect->currentItem()), c ); + editPalette.setInactive( cg ); + + setPreviewPalette( editPalette ); +} - result.setColor(colorGroup, QPalette::Light, btn.lighter()); - result.setColor(colorGroup, QPalette::Midlight, btn.lighter(115)); - result.setColor(colorGroup, QPalette::Mid, btn.darker(150)); - result.setColor(colorGroup, QPalette::Dark, btn.darker()); - result.setColor(colorGroup, QPalette::Shadow, Qt::black); +void PaletteEditorAdvanced::mapToInactivePixmapRole( const QPixmap& pm ) +{ + QColorGroup::ColorRole role = centralFromItem(comboCentral->currentItem()); + QColorGroup cg = editPalette.inactive(); + if ( !pm.isNull() ) + cg.setBrush( role, QBrush( cg.color( role ), pm ) ); + else + cg.setBrush( role, QBrush( cg.color( role ) ) ); + editPalette.setInactive( cg ); + + setPreviewPalette( editPalette ); +} + +void PaletteEditorAdvanced::mapToDisabledCentralRole( const QColor& c ) +{ + QColorGroup cg = editPalette.disabled(); + cg.setColor( centralFromItem(comboCentral->currentItem()), c ); + editPalette.setDisabled( cg ); + + buildDisabledEffect(); + + setPreviewPalette( editPalette ); +} + +void PaletteEditorAdvanced::mapToDisabledEffectRole( const QColor& c ) +{ + QColorGroup cg = editPalette.disabled(); + cg.setColor( effectFromItem(comboEffect->currentItem()), c ); + editPalette.setDisabled( cg ); + + setPreviewPalette( editPalette ); +} + +void PaletteEditorAdvanced::mapToDisabledPixmapRole( const QPixmap& pm ) +{ + QColorGroup::ColorRole role = centralFromItem(comboCentral->currentItem()); + QColorGroup cg = editPalette.disabled(); + if ( !pm.isNull() ) + cg.setBrush( role, QBrush( cg.color( role ), pm ) ); + else + cg.setBrush( role, QBrush( cg.color( role ) ) ); + + editPalette.setDisabled( cg ); + + setPreviewPalette( editPalette ); +} + +void PaletteEditorAdvanced::buildActiveEffect() +{ + QColorGroup cg = editPalette.active(); + QColor btn = cg.color( QColorGroup::Button ); + + QPalette temp( btn, btn ); + + for (int i = 0; i<5; i++) + cg.setColor( effectFromItem(i), temp.active().color( effectFromItem(i) ) ); + + editPalette.setActive( cg ); + setPreviewPalette( editPalette ); + + updateColorButtons(); +} + +void PaletteEditorAdvanced::buildInactive() +{ + editPalette.setInactive( editPalette.active() ); + if ( checkBuildEffect->isChecked() ) + buildInactiveEffect(); + else { + setPreviewPalette( editPalette ); + updateColorButtons(); } - return result; } -void PaletteEditorAdvanced::buildEffect(QPalette::ColorGroup colorGroup) +void PaletteEditorAdvanced::buildInactiveEffect() { - editPalette = buildEffect(colorGroup, editPalette); + QColorGroup cg = editPalette.inactive(); + + QColor light, midlight, mid, dark, shadow; + QColor btn = cg.color( QColorGroup::Button ); + + light = btn.light(150); + midlight = btn.light(115); + mid = btn.dark(150); + dark = btn.dark(); + shadow = Qt::black; + + cg.setColor( QColorGroup::Light, light ); + cg.setColor( QColorGroup::Midlight, midlight ); + cg.setColor( QColorGroup::Mid, mid ); + cg.setColor( QColorGroup::Dark, dark ); + cg.setColor( QColorGroup::Shadow, shadow ); + + editPalette.setInactive( cg ); + setPreviewPalette( editPalette ); updateColorButtons(); } -void PaletteEditorAdvanced::build(QPalette::ColorGroup colorGroup) +void PaletteEditorAdvanced::buildDisabled() { - if (colorGroup != QPalette::Active) { - for (int i = 0; i < QPalette::NColorRoles; i++) - editPalette.setColor(colorGroup, QPalette::ColorRole(i), - editPalette.color(QPalette::Active, QPalette::ColorRole(i))); + QColorGroup cg = editPalette.active(); + cg.setColor( QColorGroup::ButtonText, Qt::darkGray ); + cg.setColor( QColorGroup::WindowText, Qt::darkGray ); + cg.setColor( QColorGroup::Text, Qt::darkGray ); + cg.setColor( QColorGroup::HighlightedText, Qt::darkGray ); + editPalette.setDisabled( cg ); + + if ( checkBuildEffect->isChecked() ) + buildDisabledEffect(); + else { + setPreviewPalette( editPalette ); + updateColorButtons(); + } +} + +void PaletteEditorAdvanced::buildDisabledEffect() +{ + QColorGroup cg = editPalette.disabled(); + + QColor light, midlight, mid, dark, shadow; + QColor btn = cg.color( QColorGroup::Button ); + + light = btn.light(150); + midlight = btn.light(115); + mid = btn.dark(150); + dark = btn.dark(); + shadow = Qt::black; - if (colorGroup == QPalette::Disabled) { - editPalette.setColor(colorGroup, QPalette::ButtonText, Qt::darkGray); - editPalette.setColor(colorGroup, QPalette::WindowText, Qt::darkGray); - editPalette.setColor(colorGroup, QPalette::Text, Qt::darkGray); - editPalette.setColor(colorGroup, QPalette::HighlightedText, Qt::darkGray); - } + cg.setColor( QColorGroup::Light, light ); + cg.setColor( QColorGroup::Midlight, midlight ); + cg.setColor( QColorGroup::Mid, mid ); + cg.setColor( QColorGroup::Dark, dark ); + cg.setColor( QColorGroup::Shadow, shadow ); - if (ui->checkBuildEffect->isChecked()) - buildEffect(colorGroup); - else - updateColorButtons(); + editPalette.setDisabled( cg ); + setPreviewPalette( editPalette ); + updateColorButtons(); +} + +void PaletteEditorAdvanced::setPreviewPalette( const QPalette& pal ) +{ + QColorGroup cg; + + switch (selectedPalette) { + case 0: + default: + cg = pal.active(); + break; + case 1: + cg = pal.inactive(); + break; + case 2: + cg = pal.disabled(); + break; } + previewPalette.setActive( cg ); + previewPalette.setInactive( cg ); + previewPalette.setDisabled( cg ); } void PaletteEditorAdvanced::updateColorButtons() { - QPalette::ColorGroup colorGroup = groupFromIndex(selectedPalette); - buttonCentral->setColor(editPalette.color(colorGroup, - centralFromIndex(ui->comboCentral->currentIndex()))); - buttonEffect->setColor(editPalette.color(colorGroup, - effectFromIndex(ui->comboEffect->currentIndex()))); + QColor central, effect; + switch (selectedPalette) { + case 0: + default: + central = editPalette.active().color( centralFromItem( comboCentral->currentItem() ) ); + effect = editPalette.active().color( effectFromItem( comboEffect->currentItem() ) ); + break; + case 1: + central = editPalette.inactive().color( centralFromItem( comboCentral->currentItem() ) ); + effect = editPalette.inactive().color( effectFromItem( comboEffect->currentItem() ) ); + break; + case 2: + central = editPalette.disabled().color( centralFromItem( comboCentral->currentItem() ) ); + effect = editPalette.disabled().color( effectFromItem( comboEffect->currentItem() ) ); + break; + } + + buttonCentral->setColor(central); + buttonEffect->setColor(effect); } -void PaletteEditorAdvanced::setPal(const QPalette &pal) +void PaletteEditorAdvanced::setPal( const QPalette& pal ) { editPalette = pal; + setPreviewPalette( pal ); updateColorButtons(); } @@ -321,51 +503,51 @@ QPalette PaletteEditorAdvanced::pal() const return editPalette; } -void PaletteEditorAdvanced::setupBackgroundRole(QPalette::ColorRole role) +void PaletteEditorAdvanced::setupBackgroundMode( Qt::BackgroundMode mode ) { int initRole = 0; - switch (role) { - case QPalette::Window: + switch( mode ) { + case Qt::PaletteBackground: initRole = 0; break; - case QPalette::WindowText: + case Qt::PaletteForeground: initRole = 1; break; - case QPalette::Base: + case Qt::PaletteButton: initRole = 2; break; - case QPalette::AlternateBase: + case Qt::PaletteBase: initRole = 3; break; - case QPalette::ToolTipBase: + case Qt::PaletteText: initRole = 4; break; - case QPalette::ToolTipText: + case Qt::PaletteBrightText: initRole = 5; break; - case QPalette::Text: + case Qt::PaletteButtonText: initRole = 6; break; - case QPalette::Button: + case Qt::PaletteHighlight: initRole = 7; break; - case QPalette::ButtonText: + case Qt::PaletteHighlightedText: initRole = 8; break; - case QPalette::BrightText: + case Qt::PaletteLight: initRole = 9; break; - case QPalette::Highlight: + case Qt::PaletteMidlight: initRole = 10; break; - case QPalette::HighlightedText: + case Qt::PaletteDark: initRole = 11; break; - case QPalette::Link: + case Qt::PaletteMid: initRole = 12; break; - case QPalette::LinkVisited: + case Qt::PaletteShadow: initRole = 13; break; default: @@ -373,27 +555,36 @@ void PaletteEditorAdvanced::setupBackgroundRole(QPalette::ColorRole role) break; } - if (initRole != -1) - ui->comboCentral->setCurrentIndex(initRole); + if ( initRole <= -1 ) return; + + if (initRole > 8 ) { + comboEffect->setCurrentItem( initRole - 9 ); + } + else { + comboCentral->setCurrentItem( initRole ); + } } -QPalette PaletteEditorAdvanced::getPalette(bool *ok, const QPalette &init, - QPalette::ColorRole backgroundRole, QWidget *parent) +QPalette PaletteEditorAdvanced::getPalette( bool *ok, const QPalette &init, + Qt::BackgroundMode mode, QWidget* parent, + const char* name ) { - PaletteEditorAdvanced *dlg = new PaletteEditorAdvanced(parent); - dlg->setupBackgroundRole(backgroundRole); + PaletteEditorAdvanced* dlg = new PaletteEditorAdvanced( parent, name, true ); + dlg->setupBackgroundMode( mode ); - if (init != QPalette()) - dlg->setPal(init); + if ( init != QPalette() ) + dlg->setPal( init ); int resultCode = dlg->exec(); QPalette result = init; - if (resultCode == QDialog::Accepted) + if ( resultCode == QDialog::Accepted ) { + if ( ok ) + *ok = true; result = dlg->pal(); - - if (ok) - *ok = resultCode; - + } else { + if ( ok ) + *ok = false; + } delete dlg; return result; } diff --git a/tools/qtconfig/paletteeditoradvanced.h b/tools/qtconfig/paletteeditoradvanced.h index 2bdb95d..a1eb8e7 100644 --- a/tools/qtconfig/paletteeditoradvanced.h +++ b/tools/qtconfig/paletteeditoradvanced.h @@ -42,65 +42,69 @@ #ifndef PALETTEEDITORADVANCED_H #define PALETTEEDITORADVANCED_H -#include +#include "paletteeditoradvancedbase.h" QT_BEGIN_NAMESPACE -namespace Ui { - class PaletteEditorAdvanced; -} - -class ColorButton; - -class PaletteEditorAdvanced : public QDialog +class PaletteEditorAdvanced : public PaletteEditorAdvancedBase { Q_OBJECT public: - PaletteEditorAdvanced(QWidget *parent = 0); + PaletteEditorAdvanced( QWidget * parent=0, const char * name=0, + bool modal=false, Qt::WindowFlags f=0 ); ~PaletteEditorAdvanced(); - static QPalette getPalette(bool *ok, const QPalette &pal, - QPalette::ColorRole backgroundRole = QPalette::Window, - QWidget *parent = 0); - - static QPalette buildEffect(QPalette::ColorGroup colorGroup, const QPalette &basePalette); + static QPalette getPalette( bool *ok, const QPalette &pal, Qt::BackgroundMode mode = Qt::PaletteBackground, + QWidget* parent = 0, const char* name = 0 ); protected slots: void paletteSelected(int); - void onCentral(int); - void onEffect(int); + void onCentral( int ); + void onEffect( int ); void onChooseCentralColor(); void onChooseEffectColor(); - void onToggleBuildEffects(bool); - void onToggleBuildInactive(bool); - void onToggleBuildDisabled(bool); + void onToggleBuildEffects( bool ); + void onToggleBuildInactive( bool ); + void onToggleBuildDisabled( bool ); protected: - void buildEffect(QPalette::ColorGroup); - void build(QPalette::ColorGroup); + void mapToActiveCentralRole( const QColor& ); + void mapToActiveEffectRole( const QColor& ); + void mapToActivePixmapRole( const QPixmap& ); + void mapToInactiveCentralRole( const QColor& ); + void mapToInactiveEffectRole( const QColor& ); + void mapToInactivePixmapRole( const QPixmap& ); + void mapToDisabledCentralRole( const QColor& ); + void mapToDisabledEffectRole( const QColor& ); + void mapToDisabledPixmapRole( const QPixmap& ); + + + void buildPalette(); + void buildActiveEffect(); + void buildInactive(); + void buildInactiveEffect(); + void buildDisabled(); + void buildDisabledEffect(); private: + void setPreviewPalette( const QPalette& ); void updateColorButtons(); - void setupBackgroundRole(QPalette::ColorRole); + void setupBackgroundMode( Qt::BackgroundMode ); QPalette pal() const; - void setPal(const QPalette &); + void setPal( const QPalette& ); - static QPalette::ColorGroup groupFromIndex(int); - static QPalette::ColorRole centralFromIndex(int); - static QPalette::ColorRole effectFromIndex(int); + QColorGroup::ColorRole centralFromItem( int ); + QColorGroup::ColorRole effectFromItem( int ); QPalette editPalette; - - Ui::PaletteEditorAdvanced *ui; + QPalette previewPalette; int selectedPalette; - ColorButton *buttonCentral; - ColorButton *buttonEffect; }; QT_END_NAMESPACE -#endif // PALETTEEDITORADVANCED_H +#endif diff --git a/tools/qtconfig/paletteeditoradvanced.ui b/tools/qtconfig/paletteeditoradvanced.ui deleted file mode 100644 index b1d6b95..0000000 --- a/tools/qtconfig/paletteeditoradvanced.ui +++ /dev/null @@ -1,416 +0,0 @@ - - - ********************************************************************* -** -** 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 tools applications 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$ -** -********************************************************************* - PaletteEditorAdvanced - - - - 0 - 0 - 239 - 344 - - - - Tune Palette - - - - - - - - Select &Palette: - - - paletteCombo - - - - - - - - Active Palette - - - - - Inactive Palette - - - - - Disabled Palette - - - - - - - - - - - 0 - 0 - - - - Auto - - - - - - Build inactive palette from active - - - true - - - - - - - Build disabled palette from active - - - true - - - - - - - - - - Central color &roles - - - - - - Choose central color role - - - <b>Select a color role.</b><p>Available central roles are: <ul> <li>Window - general background color.</li> <li>WindowText - general foreground color. </li> <li>Base - used as background color for e.g. text entry widgets, usually white or another light color. </li> <li>Text - the foreground color used with Base. Usually this is the same as WindowText, in what case it must provide good contrast both with Window and Base. </li> <li>Button - general button background color, where buttons need a background different from Window, as in the Macintosh style. </li> <li>ButtonText - a foreground color used with the Button color. </li> <li>Highlight - a color to indicate a selected or highlighted item. </li> <li>HighlightedText - a text color that contrasts to Highlight. </li> <li>BrightText - a text color that is very different from WindowText and contrasts well with e.g. black. </li> </ul> </p> - - - - Window - - - - - WindowText - - - - - Base - - - - - AlternateBase - - - - - ToolTipBase - - - - - ToolTipText - - - - - Text - - - - - Button - - - - - ButtonText - - - - - BrightText - - - - - Highlight - - - - - HighlightedText - - - - - Link - - - - - LinkVisited - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - &Select Color: - - - - - - - - - - - - 3-D shadow &effects - - - - - - - - Generate shadings - - - Check to let 3D-effect colors be calculated from button-color. - - - Build &from button color - - - true - - - - - - - false - - - Choose 3D-effect color role - - - <b>Select a color role.</b><p>Available effect roles are: <ul> <li>Light - lighter than Button color. </li> <li>Midlight - between Button and Light. </li> <li>Mid - between Button and Dark. </li> <li>Dark - darker than Button. </li> <li>Shadow - a very dark color. </li> </ul> - - - - Light - - - - - Midlight - - - - - Mid - - - - - Dark - - - - - Shadow - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Select Co&lor: - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - PaletteEditorAdvanced - accept() - - - 238 - 384 - - - 157 - 274 - - - - - buttonBox - rejected() - PaletteEditorAdvanced - reject() - - - 306 - 390 - - - 286 - 274 - - - - - checkBuildEffect - toggled(bool) - comboEffect - setDisabled(bool) - - - 82 - 262 - - - 190 - 262 - - - - - diff --git a/tools/qtconfig/paletteeditoradvancedbase.cpp b/tools/qtconfig/paletteeditoradvancedbase.cpp new file mode 100644 index 0000000..708c834 --- /dev/null +++ b/tools/qtconfig/paletteeditoradvancedbase.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** 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 tools applications 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 "paletteeditoradvancedbase.h" +#include "colorbutton.h" + +#include + +QT_BEGIN_NAMESPACE + +/* + * Constructs a PaletteEditorAdvancedBase as a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + * + * The dialog will by default be modeless, unless you set 'modal' to + * true to construct a modal dialog. + */ +PaletteEditorAdvancedBase::PaletteEditorAdvancedBase(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl) + : QDialog(parent, name, modal, fl) +{ + setupUi(this); + + + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(paletteCombo, SIGNAL(activated(int)), this, SLOT(paletteSelected(int))); + connect(comboCentral, SIGNAL(activated(int)), this, SLOT(onCentral(int))); + connect(buttonCentral, SIGNAL(clicked()), this, SLOT(onChooseCentralColor())); + connect(buttonEffect, SIGNAL(clicked()), this, SLOT(onChooseEffectColor())); + connect(comboEffect, SIGNAL(activated(int)), this, SLOT(onEffect(int))); + connect(checkBuildEffect, SIGNAL(toggled(bool)), this, SLOT(onToggleBuildEffects(bool))); + connect(checkBuildEffect, SIGNAL(toggled(bool)), comboEffect, SLOT(setDisabled(bool))); + connect(checkBuildEffect, SIGNAL(toggled(bool)), buttonEffect, SLOT(setDisabled(bool))); + connect(checkBuildInactive, SIGNAL(toggled(bool)), this, SLOT(onToggleBuildInactive(bool))); + connect(checkBuildDisabled, SIGNAL(toggled(bool)), this, SLOT(onToggleBuildDisabled(bool))); + init(); +} + +/* + * Destroys the object and frees any allocated resources + */ +PaletteEditorAdvancedBase::~PaletteEditorAdvancedBase() +{ + destroy(); + // no need to delete child widgets, Qt does it all for us +} + +/* + * Sets the strings of the subwidgets using the current + * language. + */ +void PaletteEditorAdvancedBase::languageChange() +{ + retranslateUi(this); +} + +void PaletteEditorAdvancedBase::init() +{ +} + +void PaletteEditorAdvancedBase::destroy() +{ +} + +void PaletteEditorAdvancedBase::onCentral(int) +{ + qWarning("PaletteEditorAdvancedBase::onCentral(int): Not implemented yet"); +} + +void PaletteEditorAdvancedBase::onChooseCentralColor() +{ + qWarning("PaletteEditorAdvancedBase::onChooseCentralColor(): Not implemented yet"); +} + +void PaletteEditorAdvancedBase::onChooseEffectColor() +{ + qWarning("PaletteEditorAdvancedBase::onChooseEffectColor(): Not implemented yet"); +} + +void PaletteEditorAdvancedBase::onEffect(int) +{ + qWarning("PaletteEditorAdvancedBase::onEffect(int): Not implemented yet"); +} + +void PaletteEditorAdvancedBase::onToggleBuildDisabled(bool) +{ + qWarning("PaletteEditorAdvancedBase::onToggleBuildDisabled(bool): Not implemented yet"); +} + +void PaletteEditorAdvancedBase::onToggleBuildEffects(bool) +{ + qWarning("PaletteEditorAdvancedBase::onToggleBuildEffects(bool): Not implemented yet"); +} + +void PaletteEditorAdvancedBase::onToggleBuildInactive(bool) +{ + qWarning("PaletteEditorAdvancedBase::onToggleBuildInactive(bool): Not implemented yet"); +} + +void PaletteEditorAdvancedBase::paletteSelected(int) +{ + qWarning("PaletteEditorAdvancedBase::paletteSelected(int): Not implemented yet"); +} + +QT_END_NAMESPACE diff --git a/tools/qtconfig/paletteeditoradvancedbase.h b/tools/qtconfig/paletteeditoradvancedbase.h new file mode 100644 index 0000000..ee14a26 --- /dev/null +++ b/tools/qtconfig/paletteeditoradvancedbase.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 tools applications 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 PALETTEEDITORADVANCEDBASE_H +#define PALETTEEDITORADVANCEDBASE_H + +#include "ui_paletteeditoradvancedbase.h" +#include + +QT_BEGIN_NAMESPACE + +class ColorButton; + +class PaletteEditorAdvancedBase : public QDialog, public Ui::PaletteEditorAdvancedBase +{ + Q_OBJECT + +public: + PaletteEditorAdvancedBase(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WindowFlags fl = 0); + ~PaletteEditorAdvancedBase(); + +protected slots: + virtual void languageChange(); + + virtual void init(); + virtual void destroy(); + virtual void onCentral(int); + virtual void onChooseCentralColor(); + virtual void onChooseEffectColor(); + virtual void onEffect(int); + virtual void onToggleBuildDisabled(bool); + virtual void onToggleBuildEffects(bool); + virtual void onToggleBuildInactive(bool); + virtual void paletteSelected(int); + +}; + +QT_END_NAMESPACE + +#endif // PALETTEEDITORADVANCEDBASE_H diff --git a/tools/qtconfig/paletteeditoradvancedbase.ui b/tools/qtconfig/paletteeditoradvancedbase.ui new file mode 100644 index 0000000..12c5a7d --- /dev/null +++ b/tools/qtconfig/paletteeditoradvancedbase.ui @@ -0,0 +1,617 @@ + + + ********************************************************************* +** +** 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 tools applications 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$ +** +********************************************************************* + + PaletteEditorAdvancedBase + + + PaletteEditorAdvancedBase + + + true + + + + 0 + 0 + 295 + 346 + + + + Tune Palette + + + true + + + <b>Edit Palette</b><p>Change the palette of the current widget or form.</p><p>Use a generated palette or select colors for each color group and each color role.</p><p>The palette can be tested with different widget layouts in the preview section.</p> + + + + unnamed + + + 11 + + + 6 + + + + + unnamed + + + 0 + + + 6 + + + + + TextLabel1 + + + Select &Palette: + + + paletteCombo + + + + + + + paletteCombo + + + + Active Palette + + + + + Inactive Palette + + + + + Disabled Palette + + + + + + + + + + ButtonGroup1 + + + + 5 + 4 + 0 + 0 + + + + Auto + + + + unnamed + + + 11 + + + 6 + + + + + checkBuildInactive + + + Build inactive palette from active + + + true + + + + + + + checkBuildDisabled + + + Build disabled palette from active + + + true + + + + + + + + + + groupCentral + + + Central color &roles + + + + unnamed + + + 11 + + + 6 + + + + + comboCentral + + + Choose central color role + + + <b>Select a color role.</b><p>Available central roles are: <ul> <li>Window - general background color.</li> <li>WindowText - general foreground color. </li> <li>Base - used as background color for e.g. text entry widgets, usually white or another light color. </li> <li>Text - the foreground color used with Base. Usually this is the same as WindowText, in what case it must provide good contrast both with Window and Base. </li> <li>Button - general button background color, where buttons need a background different from Window, as in the Macintosh style. </li> <li>ButtonText - a foreground color used with the Button color. </li> <li>Highlight - a color to indicate a selected or highlighted item. </li> <li>HighlightedText - a text color that contrasts to Highlight. </li> <li>BrightText - a text color that is very different from WindowText and contrasts well with e.g. black. </li> </ul> </p> + + + + Window + + + + + WindowText + + + + + Button + + + + + Base + + + + + Text + + + + + BrightText + + + + + ButtonText + + + + + Highlight + + + + + HighlightedText + + + + + + + + unnamed + + + 0 + + + 6 + + + + + + 20 + 20 + + + + Expanding + + + Horizontal + + + + + + + labelCentral + + + + 1 + 1 + 0 + 0 + + + + + 0 + 0 + + + + &Select Color: + + + buttonCentral + + + + + + + buttonCentral + + + + 0 + 0 + 0 + 0 + + + + Qt::TabFocus + + + Choose a color + + + Choose a color for the selected central color role. + + + + + + + + + + + + groupEffect + + + 3-D shadow &effects + + + + unnamed + + + 11 + + + 6 + + + + + unnamed + + + 0 + + + 6 + + + + + checkBuildEffect + + + Build &from button color + + + true + + + Generate shadings + + + Check to let 3D-effect colors be calculated from button-color. + + + + + + + comboEffect + + + Choose 3D-effect color role + + + <b>Select a color role.</b><p>Available effect roles are: <ul> <li>Light - lighter than Button color. </li> <li>Midlight - between Button and Light. </li> <li>Mid - between Button and Dark. </li> <li>Dark - darker than Button. </li> <li>Shadow - a very dark color. </li> </ul> + + + + Light + + + + + Midlight + + + + + Mid + + + + + Dark + + + + + Shadow + + + + + + + + + + unnamed + + + 0 + + + 6 + + + + + + 20 + 20 + + + + Expanding + + + Horizontal + + + + + + + labelEffect + + + + 1 + 1 + 0 + 0 + + + + + 0 + 0 + + + + Select Co&lor: + + + buttonEffect + + + + + + + buttonEffect + + + + 0 + 0 + 0 + 0 + + + + Qt::TabFocus + + + Choose a color + + + Choose a color for the selected effect color role. + + + + + + + + + + + + unnamed + + + 0 + + + 6 + + + + + + 20 + 20 + + + + Expanding + + + Horizontal + + + + + + + buttonOk + + + OK + + + true + + + true + + + Close dialog and apply all changes. + + + + + + + buttonCancel + + + Cancel + + + true + + + Close dialog and discard all changes. + + + + + + + + + + + ColorButton + +
colorbutton.h
+ + 40 + 25 + + 0 + + 5 + 5 + + image0 + + color + pixmap + +
+
+ + buttonOk + buttonCancel + paletteCombo + checkBuildInactive + checkBuildDisabled + comboCentral + buttonCentral + checkBuildEffect + comboEffect + buttonEffect + + + + 789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758 + + +
diff --git a/tools/qtconfig/previewframe.cpp b/tools/qtconfig/previewframe.cpp index f37ac78..3b46e8d 100644 --- a/tools/qtconfig/previewframe.cpp +++ b/tools/qtconfig/previewframe.cpp @@ -40,7 +40,6 @@ ****************************************************************************/ #include "previewframe.h" -#include "previewwidget.h" #include #include @@ -48,8 +47,8 @@ QT_BEGIN_NAMESPACE -PreviewFrame::PreviewFrame(QWidget *parent) - : QFrame(parent) +PreviewFrame::PreviewFrame( QWidget *parent, const char *name ) + : QFrame( parent, name ) { setMinimumSize(200, 200); setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); @@ -83,22 +82,23 @@ void PreviewFrame::setPreviewVisible(bool visible) workspace->viewport()->update(); } -Workspace::Workspace(PreviewFrame *parent) +Workspace::Workspace(PreviewFrame* parent, const char* name) : QMdiArea(parent) { previewFrame = parent; PreviewWidget *previewWidget = previewFrame->widget(); + setObjectName(QLatin1String(name)); QMdiSubWindow *frame = addSubWindow(previewWidget, Qt::Window); - frame->move(10, 10); + frame->move(10,10); frame->show(); } -void Workspace::paintEvent(QPaintEvent *) +void Workspace::paintEvent( QPaintEvent* ) { - QPainter p(viewport()); + QPainter p (viewport()); p.fillRect(rect(), palette().color(backgroundRole()).dark()); - p.setPen(QPen(Qt::white)); - p.drawText(0, height() / 2, width(), height(), Qt::AlignHCenter, previewFrame->previewText()); + p.setPen( QPen( Qt::white ) ); + p.drawText ( 0, height() / 2, width(), height(), Qt::AlignHCenter, previewFrame->previewText()); } QT_END_NAMESPACE diff --git a/tools/qtconfig/previewframe.h b/tools/qtconfig/previewframe.h index 41c5030..de364e4 100644 --- a/tools/qtconfig/previewframe.h +++ b/tools/qtconfig/previewframe.h @@ -42,6 +42,8 @@ #ifndef PREVIEWFRAME_H #define PREVIEWFRAME_H +#include "previewwidget.h" + #include QT_BEGIN_NAMESPACE @@ -52,29 +54,28 @@ class Workspace : public QMdiArea Q_OBJECT public: - Workspace(PreviewFrame *parent = 0); + Workspace( PreviewFrame* parent = 0, const char* name = 0 ); ~Workspace() {} protected: - void paintEvent(QPaintEvent *); + void paintEvent( QPaintEvent* ); private: PreviewFrame *previewFrame; }; -class PreviewWidget; class PreviewFrame : public QFrame { Q_OBJECT public: - PreviewFrame(QWidget *parent = 0); + PreviewFrame( QWidget *parent = 0, const char *name = 0 ); void setPreviewPalette(QPalette); void setPreviewVisible(bool val); QString previewText() const; PreviewWidget *widget() const { return previewWidget; } private: - Workspace *workspace; - PreviewWidget *previewWidget; + Workspace *workspace; + PreviewWidget *previewWidget; QString m_previewWindowText; }; diff --git a/tools/qtconfig/previewwidget.cpp b/tools/qtconfig/previewwidget.cpp index 0573846..757b448 100644 --- a/tools/qtconfig/previewwidget.cpp +++ b/tools/qtconfig/previewwidget.cpp @@ -40,32 +40,32 @@ ****************************************************************************/ #include "previewwidget.h" -#include "ui_previewwidget.h" #include QT_BEGIN_NAMESPACE -PreviewWidget::PreviewWidget(QWidget *parent) - : QWidget(parent), ui(new Ui::PreviewWidget) +PreviewWidget::PreviewWidget( QWidget *parent, const char *name ) + : PreviewWidgetBase( parent, name ) { - ui->setupUi(this); - // install event filter on child widgets - QList l = findChildren(); - foreach(QWidget *w, l) { - w->installEventFilter(this); - w->setFocusPolicy(Qt::NoFocus); + QObjectList l = queryList("QWidget"); + for (int i = 0; i < l.size(); ++i) { + QObject * obj = l.at(i); + obj->installEventFilter(this); + ((QWidget*)obj)->setFocusPolicy(Qt::NoFocus); } } -PreviewWidget::~PreviewWidget() + +void PreviewWidget::closeEvent(QCloseEvent *e) { - delete ui; + e->ignore(); } + bool PreviewWidget::eventFilter(QObject *, QEvent *e) { - switch (e->type()) { + switch ( e->type() ) { case QEvent::MouseButtonPress: case QEvent::MouseButtonRelease: case QEvent::MouseButtonDblClick: @@ -81,9 +81,4 @@ bool PreviewWidget::eventFilter(QObject *, QEvent *e) return false; } -void PreviewWidget::closeEvent(QCloseEvent *e) -{ - e->ignore(); -} - QT_END_NAMESPACE diff --git a/tools/qtconfig/previewwidget.h b/tools/qtconfig/previewwidget.h index e7707cd..37e9cba 100644 --- a/tools/qtconfig/previewwidget.h +++ b/tools/qtconfig/previewwidget.h @@ -42,29 +42,21 @@ #ifndef PREVIEWWIDGET_H #define PREVIEWWIDGET_H -#include +#include "previewwidgetbase.h" QT_BEGIN_NAMESPACE -namespace Ui { - class PreviewWidget; -} - - -class PreviewWidget : public QWidget +class PreviewWidget : public PreviewWidgetBase { Q_OBJECT public: - PreviewWidget(QWidget *parent = 0); - ~PreviewWidget(); + PreviewWidget( QWidget *parent = 0, const char *name = 0 ); - bool eventFilter(QObject *, QEvent *); -private: void closeEvent(QCloseEvent *); - Ui::PreviewWidget *ui; + bool eventFilter(QObject *, QEvent *); }; QT_END_NAMESPACE -#endif // PREVIEWWIDGET_H +#endif diff --git a/tools/qtconfig/previewwidget.ui b/tools/qtconfig/previewwidget.ui deleted file mode 100644 index 2e0789f..0000000 --- a/tools/qtconfig/previewwidget.ui +++ /dev/null @@ -1,252 +0,0 @@ - - - ********************************************************************* -** -** 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 tools applications 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$ -** -********************************************************************* - PreviewWidget - - - - 0 - 0 - 398 - 282 - - - - - 0 - 0 - - - - Preview Window - - - - - - - - 6 - - - 0 - - - - - GroupBox - - - - 6 - - - 11 - - - - - RadioButton1 - - - true - - - - - - - RadioButton2 - - - - - - - RadioButton3 - - - - - - - - - - GroupBox2 - - - - 6 - - - 11 - - - - - CheckBox1 - - - true - - - - - - - CheckBox2 - - - - - - - - - - 50 - - - - - - - - - 6 - - - 0 - - - - - LineEdit - - - - - - - - ComboBox - - - - - - - - 6 - - - 0 - - - - - - - - PushButton - - - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - - - - - 32767 - 55 - - - - true - - - <p><a href="http://qt.nokia.com">http://qt.nokia.com</a></p> -<p><a href="http://www.kde.org">http://www.kde.org</a></p> - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 0 - - - - - - - - - diff --git a/tools/qtconfig/previewwidgetbase.cpp b/tools/qtconfig/previewwidgetbase.cpp new file mode 100644 index 0000000..9234b6f --- /dev/null +++ b/tools/qtconfig/previewwidgetbase.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** 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 tools applications 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 "previewwidgetbase.h" + +#include + +QT_BEGIN_NAMESPACE + +/* + * Constructs a PreviewWidgetBase as a child of 'parent', with the + * name 'name' and widget flags set to 'f'. + */ +PreviewWidgetBase::PreviewWidgetBase(QWidget* parent, const char* name, Qt::WindowFlags fl) + : QWidget(parent, name, fl) +{ + setupUi(this); + + + // signals and slots connections + init(); +} + +/* + * Destroys the object and frees any allocated resources + */ +PreviewWidgetBase::~PreviewWidgetBase() +{ + destroy(); + // no need to delete child widgets, Qt does it all for us +} + +/* + * Sets the strings of the subwidgets using the current + * language. + */ +void PreviewWidgetBase::languageChange() +{ + retranslateUi(this); +} + +void PreviewWidgetBase::init() +{ +} + +void PreviewWidgetBase::destroy() +{ +} + +QT_END_NAMESPACE diff --git a/tools/qtconfig/previewwidgetbase.h b/tools/qtconfig/previewwidgetbase.h new file mode 100644 index 0000000..829415e --- /dev/null +++ b/tools/qtconfig/previewwidgetbase.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** 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 tools applications 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 PREVIEWWIDGETBASE_H +#define PREVIEWWIDGETBASE_H + +#include "ui_previewwidgetbase.h" +#include + +QT_BEGIN_NAMESPACE + +class PreviewWidgetBase : public QWidget, public Ui::PreviewWidgetBase +{ + Q_OBJECT + +public: + PreviewWidgetBase(QWidget* parent = 0, const char* name = 0, Qt::WindowFlags fl = 0); + ~PreviewWidgetBase(); + +protected slots: + virtual void languageChange(); + + virtual void init(); + virtual void destroy(); + +}; + +QT_END_NAMESPACE + +#endif // PREVIEWWIDGETBASE_H diff --git a/tools/qtconfig/previewwidgetbase.ui b/tools/qtconfig/previewwidgetbase.ui new file mode 100644 index 0000000..701bf84 --- /dev/null +++ b/tools/qtconfig/previewwidgetbase.ui @@ -0,0 +1,340 @@ + + + ********************************************************************* +** +** 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 tools applications 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$ +** +********************************************************************* + + PreviewWidgetBase + + + PreviewWidgetBase + + + + 0 + 0 + 378 + 236 + + + + + 1 + 1 + 0 + 0 + + + + Preview Window + + + + unnamed + + + 11 + + + 6 + + + + + unnamed + + + 0 + + + 6 + + + + + unnamed + + + 0 + + + 6 + + + + + ButtonGroup1 + + + ButtonGroup + + + + unnamed + + + 11 + + + 6 + + + + + RadioButton1 + + + RadioButton1 + + + true + + + + + + + RadioButton2 + + + RadioButton2 + + + + + + + RadioButton3 + + + RadioButton3 + + + + + + + + + + ButtonGroup2 + + + ButtonGroup2 + + + + unnamed + + + 11 + + + 6 + + + + + CheckBox1 + + + CheckBox1 + + + true + + + + + + + CheckBox2 + + + CheckBox2 + + + + + + + + + + ProgressBar1 + + + 50 + + + + + + + + + unnamed + + + 0 + + + 6 + + + + + LineEdit1 + + + LineEdit + + + + + + + ComboBox1 + + + + ComboBox + + + + + + + + unnamed + + + 0 + + + 6 + + + + + SpinBox1 + + + + + + + PushButton1 + + + PushButton + + + + + + + + + ScrollBar1 + + + Qt::Horizontal + + + + + + + Slider1 + + + Qt::Horizontal + + + + + + + textView + + + + 32767 + 50 + + + + true + + + <p> +<a href="http://qt.nokia.com">http://qt.nokia.com</a> +</p> +<p> +<a href="http://www.kde.org">http://www.kde.org</a> +</p> + + + + + + + + + + + + 20 + 20 + + + + Expanding + + + Vertical + + + + + + qPixmapFromMimeSource + diff --git a/tools/qtconfig/qtconfig.pro b/tools/qtconfig/qtconfig.pro index cb06e5a..d1fd320 100644 --- a/tools/qtconfig/qtconfig.pro +++ b/tools/qtconfig/qtconfig.pro @@ -1,10 +1,11 @@ TEMPLATE = app -CONFIG += qt warn_on x11 +CONFIG += qt warn_on x11 build_all:!build_pass { CONFIG -= build_all CONFIG += release } LANGUAGE = C++ +QT += qt3support contains(QT_CONFIG, gstreamer):LIBS += $$QT_LIBS_GSTREAMER -lgstinterfaces-0.10 -lgstvideo-0.10 -lgstbase-0.10 contains(QT_CONFIG, gstreamer):QMAKE_CXXFLAGS += $$QT_CFLAGS_GSTREAMER @@ -12,17 +13,19 @@ contains(QT_CONFIG, phonon) { QT += phonon DEFINES += HAVE_PHONON } -SOURCES += colorbutton.cpp main.cpp previewframe.cpp previewwidget.cpp mainwindow.cpp paletteeditoradvanced.cpp -HEADERS += colorbutton.h previewframe.h previewwidget.h mainwindow.h paletteeditoradvanced.h +SOURCES += colorbutton.cpp main.cpp previewframe.cpp previewwidget.cpp mainwindow.cpp paletteeditoradvanced.cpp \ + mainwindowbase.cpp paletteeditoradvancedbase.cpp previewwidgetbase.cpp +HEADERS += colorbutton.h previewframe.h previewwidget.h mainwindow.h paletteeditoradvanced.h \ + mainwindowbase.h paletteeditoradvancedbase.h previewwidgetbase.h -FORMS = mainwindow.ui paletteeditoradvanced.ui previewwidget.ui +FORMS = mainwindowbase.ui paletteeditoradvancedbase.ui previewwidgetbase.ui RESOURCES = qtconfig.qrc PROJECTNAME = Qt Configuration -TARGET = qtconfig -DESTDIR = ../../bin +TARGET = qtconfig +DESTDIR = ../../bin target.path=$$[QT_INSTALL_BINS] INSTALLS += target -INCLUDEPATH += . -DBFILE = qtconfig.db +INCLUDEPATH += . +DBFILE = qtconfig.db diff --git a/tools/tools.pro b/tools/tools.pro index c64fe25..8f23fe4 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -20,7 +20,7 @@ TEMPLATE = subdirs SUBDIRS += designer } } - unix:!mac:!embedded:SUBDIRS += qtconfig + unix:!mac:!embedded:contains(QT_CONFIG, qt3support):SUBDIRS += qtconfig win32:!wince*:SUBDIRS += activeqt } contains(QT_CONFIG, declarative):SUBDIRS += qml -- cgit v0.12 From a3c755e358596238dc7fc1c284328a6226c2ed3a Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Thu, 7 Oct 2010 12:41:03 +0300 Subject: Removed the need for S60main.rsc resource file in Symbian. Qt upgrade was failing since the s60main.rsc is being locked by S60 application framework. And when installer detects that old version of Qt has already been installed it first tries to uninstall the old one and then install the new one. The uninstallion failed since the file was locked by the running Qt application. It should be noted that this patch fixes the Qt upgradibility only for Qt versions where patch is included. I.e. the versions before 4.7.2 need a different mechanism to be upgradable. This different mechanism is based on partial upgrade SIS packages as described in QT-4052. Task-number: QT-3471 Reviewed-by: Axis --- src/gui/kernel/qt_s60_p.h | 9 ++++++++- src/gui/kernel/qwidget_s60.cpp | 25 ++++++++++++++++++++++--- src/gui/s60framework/qs60mainapplication.cpp | 5 ----- src/gui/s60framework/qs60mainappui.cpp | 28 ++++++++++++++-------------- src/gui/s60framework/s60framework.pri | 18 ------------------ src/s60installs/s60installs.pro | 17 ++++------------- src/s60main/s60main.rsg | 3 --- 7 files changed, 48 insertions(+), 57 deletions(-) delete mode 100644 src/s60main/s60main.rsg diff --git a/src/gui/kernel/qt_s60_p.h b/src/gui/kernel/qt_s60_p.h index 7fd2baa..93f64f6 100644 --- a/src/gui/kernel/qt_s60_p.h +++ b/src/gui/kernel/qt_s60_p.h @@ -142,6 +142,7 @@ public: int avkonComponentsSupportTransparency : 1; int menuBeingConstructed : 1; QApplication::QS60MainApplicationFactory s60ApplicationFactory; // typedef'ed pointer type + static CEikButtonGroupContainer *cba; enum ScanCodeState { Unpressed, @@ -162,6 +163,7 @@ public: static inline CAknTitlePane* titlePane(); static inline CAknContextPane* contextPane(); static inline CEikButtonGroupContainer* buttonGroupContainer(); + static inline void setButtonGroupContainer(CEikButtonGroupContainer* newCba); static void setStatusPaneAndButtonGroupVisibility(bool statusPaneVisible, bool buttonGroupVisible); #endif static void controlVisibilityChanged(CCoeControl *control, bool visible); @@ -383,7 +385,12 @@ inline CAknContextPane* QS60Data::contextPane() inline CEikButtonGroupContainer* QS60Data::buttonGroupContainer() { - return CEikonEnv::Static()->AppUiFactory()->Cba(); + return QS60Data::cba; +} + +inline void QS60Data::setButtonGroupContainer(CEikButtonGroupContainer *newCba) +{ + QS60Data::cba = newCba; } #endif // Q_WS_S60 diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 4109ed8..49d2ffc 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -69,6 +69,7 @@ extern bool qt_nograb(); QWidget *QWidgetPrivate::mouseGrabber = 0; QWidget *QWidgetPrivate::keyboardGrabber = 0; +CEikButtonGroupContainer *QS60Data::cba = 0; static bool isEqual(const QList& a, const QList& b) { @@ -494,9 +495,27 @@ void QWidgetPrivate::show_sys() // Create the status pane and CBA here CEikAppUi *ui = static_cast(S60->appUi()); MEikAppUiFactory *factory = CEikonEnv::Static()->AppUiFactory(); - TRAP_IGNORE(factory->ReadAppInfoResourceL(0, ui)); - if (S60->buttonGroupContainer()) - S60->buttonGroupContainer()->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + + QT_TRAP_THROWING( + factory->CreateResourceIndependentFurnitureL(ui); + + TRect boundingRect = static_cast(S60->appUi())->ClientRect(); + + CEikButtonGroupContainer *cba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, + CEikButtonGroupContainer::EHorizontal,ui,R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + + CEikButtonGroupContainer *oldCba = CEikonEnv::Static()->AppUiFactory()->SwapButtonGroup(cba); + Q_ASSERT(!oldCba); + S60->setButtonGroupContainer(cba); + + CEikMenuBar *menuBar = new(ELeave) CEikMenuBar; + menuBar->ConstructL(ui, 0, R_AVKON_MENUPANE_EMPTY); + menuBar->SetMenuType(CEikMenuBar::EMenuOptions); + S60->appUi()->AddToStackL(menuBar,ECoeStackPriorityMenu,ECoeStackFlagRefusesFocus); + + CEikMenuBar *oldMenu = CEikonEnv::Static()->AppUiFactory()->SwapMenuBar(menuBar); + Q_ASSERT(!oldMenu); + ) if (S60->statusPane()) { // Use QDesktopWidget as the status pane observer to proxy for the AppUi. diff --git a/src/gui/s60framework/qs60mainapplication.cpp b/src/gui/s60framework/qs60mainapplication.cpp index 5d4c54e..74432af 100644 --- a/src/gui/s60framework/qs60mainapplication.cpp +++ b/src/gui/s60framework/qs60mainapplication.cpp @@ -58,7 +58,6 @@ CApaApplication *newS60Application() return new QS60MainApplication; } -_LIT(KQtWrapperResourceFile, "\\resource\\apps\\s60main" QT_LIBINFIX_UNICODE L".rsc"); /*! \class QS60MainApplication @@ -129,10 +128,6 @@ TUid QS60MainApplication::AppDllUid() const */ TFileName QS60MainApplication::ResourceFileName() const { - TFindFile finder(iCoeEnv->FsSession()); - TInt err = finder.FindByDir(KQtWrapperResourceFile, KNullDesC); - if (err == KErrNone) - return finder.File(); return KNullDesC(); } diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index ea9dbb3..92b3b55 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -50,16 +50,6 @@ #endif #include #include -#ifdef Q_WS_S60 -# if defined(QT_LIBINFIX_UNQUOTED) -// Two level macro needed for proper expansion of libinfix -# define QT_S60MAIN_RSG_2(x) -# define QT_S60MAIN_RSG(x) QT_S60MAIN_RSG_2(x) -# include QT_S60MAIN_RSG(QT_LIBINFIX_UNQUOTED) -# else -# include -# endif -#endif #include "qs60mainappui.h" #include @@ -125,8 +115,8 @@ void QS60MainAppUi::ConstructL() #ifdef Q_WS_S60 flags |= CAknAppUi::EAknEnableSkin; // After 5th Edition S60, native side supports animated wallpapers. - // However, there is no support for that feature on Qt side, so indicate to - // native UI framework that this application will not support background animations. + // However, there is no support for that feature on Qt side, so indicate to + // native UI framework that this application will not support background animations. if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) flags |= KAknDisableAnimationBackground; #endif @@ -244,7 +234,7 @@ void QS60MainAppUi::DynInitMenuBarL(TInt /* resourceId */, CEikMenuBar * /* menu void QS60MainAppUi::DynInitMenuPaneL(TInt resourceId, CEikMenuPane *menuPane) { #ifdef Q_WS_S60 - if (resourceId == R_QT_WRAPPERAPP_MENU) { + if (resourceId == R_AVKON_MENUPANE_EMPTY) { if (menuPane->NumberOfItemsInPane() <= 1) QT_TRYCATCH_LEAVING(qt_symbian_show_toplevel(menuPane)); @@ -274,7 +264,17 @@ void QS60MainAppUi::RestoreMenuL(CCoeControl *menuWindow, TInt resourceId, TMenu DynInitMenuPaneL(resourceId, (CEikMenuPane*)menuWindow); else DynInitMenuBarL(resourceId, (CEikMenuBar*)menuWindow); - } else + } else if(resourceId == R_AVKON_MENUPANE_EMPTY) { + CEikMenuBarTitle *title = new(ELeave) CEikMenuBarTitle; + CleanupStack::PushL(title); + + title->iData.iMenuPaneResourceId = R_AVKON_MENUPANE_EMPTY; + title->iTitleFlags = 0; + + S60->menuBar()->TitleArray()->AddTitleL(title); + CleanupStack::Pop( title ); + } + else #endif { QS60MainAppUiBase::RestoreMenuL(menuWindow, resourceId, menuType); diff --git a/src/gui/s60framework/s60framework.pri b/src/gui/s60framework/s60framework.pri index edbacc0..19525b7 100644 --- a/src/gui/s60framework/s60framework.pri +++ b/src/gui/s60framework/s60framework.pri @@ -1,21 +1,3 @@ -contains(QT_CONFIG, s60) { -# This block serves the minimalistic resource file for S60 3.1 platforms. -# Note there is no way to ifdef S60 version in mmp file, that is why the resource -# file is always compiled for WINSCW - - minimalAppResource31 = \ - "SOURCEPATH s60framework" \ - "START RESOURCE s60main.rss" \ - "TARGET s60main$${QT_LIBINFIX}" \ - "HEADER" \ - "TARGETPATH /resource/apps" \ - "END" - - MMP_RULES += minimalAppResource31 - - SYMBIAN_RESOURCES += s60framework/s60main.rss -} - SOURCES += s60framework/qs60mainapplication.cpp \ s60framework/qs60mainappui.cpp \ s60framework/qs60maindocument.cpp diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index 1f622c0..c73ed06 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -11,10 +11,10 @@ symbian: { isEmpty(QT_LIBINFIX) { TARGET.UID3 = 0x2001E61C - + # Sqlite3 is expected to be already found on phone if infixed configuration is built. # It is also expected that devices newer than those based on S60 5.0 all have sqlite3.dll. - contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { BLD_INF_RULES.prj_exports += \ "sqlite3.sis /epoc32/data/qt/sis/sqlite3.sis" \ "sqlite3_selfsigned.sis /epoc32/data/qt/sis/sqlite3_selfsigned.sis" @@ -35,15 +35,6 @@ symbian: { } VERSION=$${QT_MAJOR_VERSION}.$${QT_MINOR_VERSION}.$${QT_PATCH_VERSION} - symbian-abld|symbian-sbsv2 { - qtresources.sources = $${EPOCROOT}$$HW_ZDIR$$APP_RESOURCE_DIR/s60main$${QT_LIBINFIX}.rsc - } else { - qtresources.sources = $$QMAKE_LIBDIR_QT/s60main$${QT_LIBINFIX}.rsc - DESTDIR = $$QMAKE_LIBDIR_QT - } - qtresources.path = c:$$APP_RESOURCE_DIR - DEPLOYMENT += qtresources - qtlibraries.sources = \ $$QMAKE_LIBDIR_QT/QtCore$${QT_LIBINFIX}.dll \ $$QMAKE_LIBDIR_QT/QtXml$${QT_LIBINFIX}.dll \ @@ -109,9 +100,9 @@ symbian: { qtlibraries.pkg_prerules = vendorinfo qtlibraries.pkg_prerules += "; Dependencies of Qt libraries" - + # It is expected that Symbian^3 and newer phones will have sufficiently new OpenC already installed - contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { + contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) { qtlibraries.pkg_prerules += "(0x20013851), 1, 5, 1, {\"PIPS Installer\"}" contains(QT_CONFIG, openssl) | contains(QT_CONFIG, openssl-linked) { qtlibraries.pkg_prerules += "(0x200110CB), 1, 5, 1, {\"Open C LIBSSL Common\"}" diff --git a/src/s60main/s60main.rsg b/src/s60main/s60main.rsg deleted file mode 100644 index 8cdf3ba..0000000 --- a/src/s60main/s60main.rsg +++ /dev/null @@ -1,3 +0,0 @@ -#define R_DEFAULT_DOCUMENT_NAME 0x55567002 -#define R_QT_WRAPPERAPP_MENUBAR 0x55567004 -#define R_QT_WRAPPERAPP_MENU 0x55567005 -- cgit v0.12 From 7f875312dcc09a4b2dcc5030e813e921b1dc7ee4 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Thu, 7 Oct 2010 15:52:27 +0200 Subject: Fix crash when using Q_GLOBAL_STATIC(QWidget...) If Q_GLOBAL_STATIC is used with a QWidget (or subclass) then the destructor of QWidget will be executed after the destructor of QApplication. Since ~QApplication() destroys the S60 environment and the trap handler, we need to be sure that if QApplication is destroyed, we do not attempt to use anything from the S60 environment. This includes RWsSession and the trap handler. The fix is to avoid flushing the WSERV buffer if QApplication has been deleted already. Reviewed-by: axis --- src/gui/kernel/qwidget_s60.cpp | 3 ++- tests/auto/qapplication/tst_qapplication.cpp | 40 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 49d2ffc..9a451ce 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -1252,7 +1252,8 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows) // At this point the backing store should already be destroyed // so we flush the command buffer to ensure that the freeing of // those resources and deleting the window can happen "atomically" - S60->wsSession().Flush(); + if (qApp) + S60->wsSession().Flush(); } } diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 91ae921..a198d7f 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -147,6 +147,10 @@ private slots: void symbianNeedForTraps(); void symbianLeaveThroughMain(); void qtbug_12673(); + + + + void globalStaticObjectDestruction(); // run this last }; class EventSpy : public QObject @@ -2257,6 +2261,42 @@ void tst_QApplication::qtbug_12673() #endif // Q_OS_SYMBIAN } +/* + This test is meant to ensure that certain objects (public & commonly used) + can safely be used in a Q_GLOBAL_STATIC such that their destructors are + executed *after* the destruction of QApplication. + */ +Q_GLOBAL_STATIC(QLocale, tst_qapp_locale); +Q_GLOBAL_STATIC(QProcess, tst_qapp_process); +Q_GLOBAL_STATIC(QFileSystemWatcher, tst_qapp_fileSystemWatcher); +Q_GLOBAL_STATIC(QSharedMemory, tst_qapp_sharedMemory); +Q_GLOBAL_STATIC(QElapsedTimer, tst_qapp_elapsedTimer); +Q_GLOBAL_STATIC(QMutex, tst_qapp_mutex); +Q_GLOBAL_STATIC(QWidget, tst_qapp_widget); +Q_GLOBAL_STATIC(QPixmap, tst_qapp_pixmap); +Q_GLOBAL_STATIC(QFont, tst_qapp_font); +Q_GLOBAL_STATIC(QRegion, tst_qapp_region); +Q_GLOBAL_STATIC(QFontDatabase, tst_qapp_fontDatabase); +Q_GLOBAL_STATIC(QCursor, tst_qapp_cursor); + +void tst_QApplication::globalStaticObjectDestruction() +{ + int argc = 1; + QApplication app(argc, &argv0, QApplication::GuiServer); + QVERIFY(tst_qapp_locale()); + QVERIFY(tst_qapp_process()); + QVERIFY(tst_qapp_fileSystemWatcher()); + QVERIFY(tst_qapp_sharedMemory()); + QVERIFY(tst_qapp_elapsedTimer()); + QVERIFY(tst_qapp_mutex()); + QVERIFY(tst_qapp_widget()); + QVERIFY(tst_qapp_pixmap()); + QVERIFY(tst_qapp_font()); + QVERIFY(tst_qapp_region()); + QVERIFY(tst_qapp_fontDatabase()); + QVERIFY(tst_qapp_cursor()); +} + //QTEST_APPLESS_MAIN(tst_QApplication) int main(int argc, char *argv[]) { -- cgit v0.12 From e7db6cd0bddb7203c5460e97e2b8164bbaf420b8 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Thu, 7 Oct 2010 18:51:49 +0200 Subject: Live texture updates to meegographicssystem plugin. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 848 Reviewed-by: Samuel Rødal --- src/gui/image/qpixmap_x11_p.h | 1 + .../graphicssystems/meego/qmeegoextensions.cpp | 32 ++++ .../graphicssystems/meego/qmeegoextensions.h | 15 ++ .../graphicssystems/meego/qmeegographicssystem.cpp | 203 +++++++++++++++++++++ .../graphicssystems/meego/qmeegographicssystem.h | 21 +++ .../graphicssystems/meego/qmeegopixmapdata.cpp | 30 +++ .../graphicssystems/meego/qmeegopixmapdata.h | 1 + 7 files changed, 303 insertions(+) diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h index 821fb69..f171281 100644 --- a/src/gui/image/qpixmap_x11_p.h +++ b/src/gui/image/qpixmap_x11_p.h @@ -115,6 +115,7 @@ private: friend class QEglContext; // Needs gl_surface friend class QGLContext; // Needs gl_surface friend class QX11GLPixmapData; // Needs gl_surface + friend class QMeeGoGraphicsSystem; // Needs gl_surface and flags friend bool qt_createEGLSurfaceForPixmap(QPixmapData*, bool); // Needs gl_surface void release(); diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp index e7f6439..611c962 100644 --- a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp @@ -46,6 +46,7 @@ bool QMeeGoExtensions::initialized = false; bool QMeeGoExtensions::hasImageShared = false; bool QMeeGoExtensions::hasSurfaceScaling = false; +bool QMeeGoExtensions::hasLockSurface = false; /* Extension funcs */ @@ -53,11 +54,15 @@ typedef EGLBoolean (EGLAPIENTRY *eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR, typedef EGLNativeSharedImageTypeNOK (EGLAPIENTRY *eglCreateSharedImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint*); typedef EGLBoolean (EGLAPIENTRY *eglDestroySharedImageNOKFunc)(EGLDisplay, EGLNativeSharedImageTypeNOK); typedef EGLBoolean (EGLAPIENTRY *eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint); +typedef EGLBoolean (EGLAPIENTRY *eglLockSurfaceKHRFunc)(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRY *eglUnlockSurfaceKHRFunc)(EGLDisplay display, EGLSurface surface); static eglQueryImageNOKFunc _eglQueryImageNOK = 0; static eglCreateSharedImageNOKFunc _eglCreateSharedImageNOK = 0; static eglDestroySharedImageNOKFunc _eglDestroySharedImageNOK = 0; static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK = 0; +static eglLockSurfaceKHRFunc _eglLockSurfaceKHR = 0; +static eglUnlockSurfaceKHRFunc _eglUnlockSurfaceKHR = 0; /* Public */ @@ -101,6 +106,22 @@ bool QMeeGoExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surfac return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height); } +bool QMeeGoExtensions::eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list) +{ + if (! hasLockSurface) + qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!"); + + return _eglLockSurfaceKHR(display, surface, attrib_list); +} + +bool QMeeGoExtensions::eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface) +{ + if (! hasLockSurface) + qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!"); + + return _eglUnlockSurfaceKHR(display, surface); +} + /* Private */ void QMeeGoExtensions::initialize() @@ -113,6 +134,8 @@ void QMeeGoExtensions::initialize() _eglQueryImageNOK = (eglQueryImageNOKFunc) eglGetProcAddress("eglQueryImageNOK"); _eglCreateSharedImageNOK = (eglCreateSharedImageNOKFunc) eglGetProcAddress("eglCreateSharedImageNOK"); _eglDestroySharedImageNOK = (eglDestroySharedImageNOKFunc) eglGetProcAddress("eglDestroySharedImageNOK"); + _eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR"); + _eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR"); Q_ASSERT(_eglQueryImageNOK && _eglCreateSharedImageNOK && _eglDestroySharedImageNOK); hasImageShared = true; @@ -125,5 +148,14 @@ void QMeeGoExtensions::initialize() Q_ASSERT(_eglSetSurfaceScalingNOK); hasSurfaceScaling = true; } + + if (QEgl::hasExtension("EGL_KHR_lock_surface2")) { + qDebug("MeegoGraphics: found EGL_KHR_lock_surface2"); + _eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR"); + _eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR"); + + Q_ASSERT(_eglLockSurfaceKHR && _eglUnlockSurfaceKHR); + hasLockSurface = true; + } } diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.h b/src/plugins/graphicssystems/meego/qmeegoextensions.h index ee20bd8..9e78caf 100644 --- a/src/plugins/graphicssystems/meego/qmeegoextensions.h +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.h @@ -65,6 +65,18 @@ typedef void* EGLNativeSharedImageTypeNOK; #define EGL_FIXED_HEIGHT_NOK 0x30DC #endif +#ifndef EGL_BITMAP_POINTER_KHR +#define EGL_BITMAP_POINTER_KHR 0x30C6 +#define EGL_BITMAP_PITCH_KHR 0x30C7 +#endif + +#ifndef EGL_MAP_PRESERVE_PIXELS_KHR +#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 +#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 +#define EGL_READ_SURFACE_BIT_KHR 0x0001 +#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 +#endif + /* Class */ class QMeeGoExtensions @@ -76,6 +88,8 @@ public: static bool eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v); static bool eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img); static bool eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height); + static bool eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); + static bool eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface); private: static void initialize(); @@ -83,6 +97,7 @@ private: static bool initialized; static bool hasImageShared; static bool hasSurfaceScaling; + static bool hasLockSurface; }; #endif diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index 2a64d49..f8b228c 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include "qmeegopixmapdata.h" #include "qmeegographicssystem.h" @@ -58,6 +59,8 @@ bool QMeeGoGraphicsSystem::surfaceWasCreated = false; +QHash QMeeGoGraphicsSystem::liveTexturePixmaps; + QMeeGoGraphicsSystem::QMeeGoGraphicsSystem() { qDebug("Using the meego graphics system"); @@ -170,6 +173,22 @@ QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handl } } +QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLImage(Qt::HANDLE handle) +{ + if (QMeeGoGraphicsSystem::meeGoRunning()) { + QMeeGoPixmapData *pmd = new QMeeGoPixmapData; + pmd->fromEGLImage(handle); + + // FIXME Ok. This is a bit BAD BAD BAD. We're abusing here the fact that we KNOW + // that this function is used for the live pixmap... + pmd->texture()->options &= ~QGLContext::InvertedYBindOption; + return QMeeGoGraphicsSystem::wrapPixmapData(pmd); + } else { + qFatal("Can't create from EGL image when not running meego graphics system!"); + return NULL; + } +} + void QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap) { QMeeGoPixmapData *pmd = (QMeeGoPixmapData *) pixmap->pixmapData(); @@ -188,6 +207,109 @@ QPixmapData *QMeeGoGraphicsSystem::pixmapDataWithGLTexture(int w, int h) return QMeeGoGraphicsSystem::wrapPixmapData(pmd); } +Qt::HANDLE QMeeGoGraphicsSystem::createLiveTexture(int w, int h, QImage::Format format) +{ + // No need to wrap the QPixmapData here. This QPixmap(Data) is a + // internal implementation and we don't migrate it between + // graphics system switching. + + // We use a bit ugly way of enforcing a color format on the X pixmap -- we create + // a local QImage and fromImage from there. This is quite redundant (extra overhead of creating + // the useless image only to delete it) but shouldn't be too bad for now... you're not expected + // to call createLiveTexture too often anyways. Would be great if QX11PixmapData had a way to + // force the X format upon creation or resize. + + QImage image(w, h, format); + QX11PixmapData *pmd = new QX11PixmapData(QPixmapData::PixmapType); + pmd->fromImage(image, Qt::NoOpaqueDetection); + QPixmap *p = new QPixmap(pmd); + + liveTexturePixmaps.insert(p->handle(), p); + return p->handle(); +} + +void QMeeGoGraphicsSystem::destroyLiveTexture(Qt::HANDLE h) +{ + if (liveTexturePixmaps.contains(h)) { + QPixmap *p = liveTexturePixmaps.value(h); + delete p; + liveTexturePixmaps.remove(h); + } else + qWarning("Trying to destroy live texture %ld which was not found!", h); +} + +bool QMeeGoGraphicsSystem::lockLiveTexture(Qt::HANDLE h) +{ + if (! liveTexturePixmaps.contains(h)) { + qWarning("Trying to lock live texture %ld which was not found!", h); + return false; + } + + EGLint attribs[] = { + EGL_MAP_PRESERVE_PIXELS_KHR, EGL_TRUE, + EGL_LOCK_USAGE_HINT_KHR, EGL_READ_SURFACE_BIT_KHR | EGL_WRITE_SURFACE_BIT_KHR, + EGL_NONE + }; + + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + EGLSurface surface = getSurfaceForLiveTexturePixmap(liveTexturePixmaps.value(h)); + return QMeeGoExtensions::eglLockSurfaceKHR(QEgl::display(), surface, attribs); +} + +bool QMeeGoGraphicsSystem::unlockLiveTexture(Qt::HANDLE h) +{ + if (! liveTexturePixmaps.contains(h)) { + qWarning("Trying to lock live texture %ld which was not found!", h); + return false; + } + + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + QMeeGoExtensions::ensureInitialized(); + + EGLSurface surface = getSurfaceForLiveTexturePixmap(liveTexturePixmaps.value(h)); + if (QMeeGoExtensions::eglUnlockSurfaceKHR(QEgl::display(), surface)) { + glFinish(); + return true; + } else { + return false; + } +} + +void QMeeGoGraphicsSystem::queryLiveTexture(Qt::HANDLE h, void **data, int *pitch) +{ + // FIXME Only allow this on locked surfaces + if (! liveTexturePixmaps.contains(h)) { + qWarning("Trying to query live texture %ld which was not found!", h); + return; + } + + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + QMeeGoExtensions::ensureInitialized(); + + EGLSurface surface = getSurfaceForLiveTexturePixmap(liveTexturePixmaps.value(h)); + eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_POINTER_KHR, (EGLint*) data); + eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_PITCH_KHR, (EGLint*) pitch); +} + +Qt::HANDLE QMeeGoGraphicsSystem::liveTextureToEGLImage(Qt::HANDLE h) +{ + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + QMeeGoExtensions::ensureInitialized(); + + EGLint attribs[] = { + EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, + EGL_NONE + }; + + EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, + (EGLClientBuffer) h, attribs); + + if (eglImage == EGL_NO_IMAGE_KHR) + qWarning("eglCreateImageKHR failed!"); + + return (Qt::HANDLE) eglImage; +} + bool QMeeGoGraphicsSystem::meeGoRunning() { if (! QApplicationPrivate::instance()) { @@ -204,6 +326,52 @@ bool QMeeGoGraphicsSystem::meeGoRunning() return (name == "meego"); } +void QMeeGoGraphicsSystem::destroySurfaceForLiveTexturePixmap(QPixmapData* pmd) +{ + Q_ASSERT(pmd->classId() == QPixmapData::X11Class); + QX11PixmapData *pixmapData = static_cast(pmd); + if (pixmapData->gl_surface) { + eglDestroySurface(QEgl::display(), (EGLSurface)pixmapData->gl_surface); + pixmapData->gl_surface = 0; + } +} + +EGLSurface QMeeGoGraphicsSystem::getSurfaceForLiveTexturePixmap(QPixmap *pixmap) +{ + // This code is a crative remix of the stuff that can be found in the + // Qt's TFP implementation in /src/opengl/qgl_x11egl.cpp ::bindiTextureFromNativePixmap + QX11PixmapData *pixmapData = static_cast(pixmap->data_ptr().data()); + Q_ASSERT(pixmapData->classId() == QPixmapData::X11Class); + bool hasAlpha = pixmapData->hasAlphaChannel(); + + if (pixmapData->gl_surface && + hasAlpha == (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha)) + return pixmapData->gl_surface; + + // Check to see if the surface is still valid + if (pixmapData->gl_surface && + hasAlpha != ((pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha) > 0)) { + // Surface is invalid! + QMeeGoGraphicsSystem::destroySurfaceForLiveTexturePixmap(pixmapData); + } + + if (pixmapData->gl_surface == 0) { + EGLConfig config = QEgl::defaultConfig(QInternal::Pixmap, + QEgl::OpenGL, + hasAlpha ? QEgl::Translucent : QEgl::NoOptions); + + pixmapData->gl_surface = (void*)QEgl::createSurface(pixmap, config); + + if (hasAlpha) + pixmapData->flags = pixmapData->flags | QX11PixmapData::GlSurfaceCreatedWithAlpha; + + if (pixmapData->gl_surface == (void*)EGL_NO_SURFACE) + return NULL; + } + + return pixmapData->gl_surface; +} + /* C API */ int qt_meego_image_to_egl_shared_image(const QImage &image) @@ -216,6 +384,11 @@ QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const return QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage); } +QPixmapData* qt_meego_pixmapdata_from_egl_image(Qt::HANDLE handle) +{ + return QMeeGoGraphicsSystem::pixmapDataFromEGLImage(handle); +} + QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h) { return QMeeGoGraphicsSystem::pixmapDataWithGLTexture(w, h); @@ -245,3 +418,33 @@ void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap) { QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(pixmap); } + +Qt::HANDLE qt_meego_live_texture_create(int w, int h, QImage::Format format) +{ + return QMeeGoGraphicsSystem::createLiveTexture(w, h, format); +} + +void qt_meego_live_texture_destroy(Qt::HANDLE h) +{ + QMeeGoGraphicsSystem::destroyLiveTexture(h); +} + +bool qt_meego_live_texture_lock(Qt::HANDLE h) +{ + return QMeeGoGraphicsSystem::lockLiveTexture(h); +} + +bool qt_meego_live_texture_unlock(Qt::HANDLE h) +{ + return QMeeGoGraphicsSystem::unlockLiveTexture(h); +} + +void qt_meego_live_texture_query(Qt::HANDLE h, void **data, int *pitch) +{ + return QMeeGoGraphicsSystem::queryLiveTexture(h, data, pitch); +} + +Qt::HANDLE qt_meego_live_texture_to_egl_image(Qt::HANDLE h) +{ + return QMeeGoGraphicsSystem::liveTextureToEGLImage(h); +} diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h index 905f0c3..934d32d 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h @@ -43,6 +43,9 @@ #define MGRAPHICSSYSTEM_H #include +#include +#include +#include class QMeeGoGraphicsSystem : public QGraphicsSystem { @@ -60,13 +63,24 @@ public: static void setTranslucent(bool translucent); static QPixmapData *pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + static QPixmapData *pixmapDataFromEGLImage(Qt::HANDLE handle); static QPixmapData *pixmapDataWithGLTexture(int w, int h); static void updateEGLSharedImagePixmap(QPixmap *pixmap); + static Qt::HANDLE createLiveTexture(int w, int h, QImage::Format format); + static void destroyLiveTexture(Qt::HANDLE h); + static bool lockLiveTexture(Qt::HANDLE h); + static bool unlockLiveTexture(Qt::HANDLE h); + static void queryLiveTexture(Qt::HANDLE h, void **data, int *pitch); + static Qt::HANDLE liveTextureToEGLImage(Qt::HANDLE h); + private: static bool meeGoRunning(); + static EGLSurface getSurfaceForLiveTexturePixmap(QPixmap *pixmap); + static void destroySurfaceForLiveTexturePixmap(QPixmapData* pmd); static bool surfaceWasCreated; + static QHash liveTexturePixmaps; }; /* C api */ @@ -74,12 +88,19 @@ private: extern "C" { Q_DECL_EXPORT int qt_meego_image_to_egl_shared_image(const QImage &image); Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); + Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_egl_image(Qt::HANDLE handle); Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h); Q_DECL_EXPORT void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap); Q_DECL_EXPORT bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle); Q_DECL_EXPORT void qt_meego_set_surface_fixed_size(int width, int height); Q_DECL_EXPORT void qt_meego_set_surface_scaling(int x, int y, int width, int height); Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent); + Q_DECL_EXPORT Qt::HANDLE m_live_texture_create(int w, int h, QImage::Format format); + Q_DECL_EXPORT void m_live_texture_destroy(Qt::HANDLE h); + Q_DECL_EXPORT bool m_live_texture_lock(Qt::HANDLE h); + Q_DECL_EXPORT bool m_live_texture_unlock(Qt::HANDLE h); + Q_DECL_EXPORT void m_live_texture_query(Qt::HANDLE h, void **data, int *pitch); + Q_DECL_EXPORT Qt::HANDLE m_live_texture_to_egl_image(Qt::HANDLE h); } #endif diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp index 33611dc..84fc593 100644 --- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp @@ -87,6 +87,36 @@ void QMeeGoPixmapData::fromImage(const QImage &image, } } +void QMeeGoPixmapData::fromEGLImage(Qt::HANDLE handle) +{ + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + QMeeGoExtensions::ensureInitialized(); + + bool textureIsBound = false; + GLuint newTextureId; + GLint newWidth, newHeight; + + glGenTextures(1, &newTextureId); + glBindTexture(GL_TEXTURE_2D, newTextureId); + + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (EGLImageKHR) handle); + GLint err = glGetError(); + if (err == GL_NO_ERROR) + textureIsBound = true; + + QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), (EGLImageKHR) handle, EGL_WIDTH, &newWidth); + QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), (EGLImageKHR) handle, EGL_HEIGHT, &newHeight); + + if (textureIsBound) { + // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix + // for QGLPixmapData. + fromTexture(newTextureId, newWidth, newHeight, true); + } else { + qWarning("Failed to create a texture from an egl image!"); + glDeleteTextures(1, &newTextureId); + } +} + void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) { if (si.isNull()) diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h index 8af33bd..8b1ae14 100644 --- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h @@ -56,6 +56,7 @@ public: QMeeGoPixmapData(); void fromTexture(GLuint textureId, int w, int h, bool alpha); + virtual void fromEGLImage(Qt::HANDLE handle); virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); virtual void fromImage (const QImage &image, Qt::ImageConversionFlags flags); virtual QImage toImage() const; -- cgit v0.12 From df61814c228e6f2badf378e25b69daf9941c646b Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Thu, 7 Oct 2010 18:51:50 +0200 Subject: Live texture updates to meegographicssystem helper. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge-request: 848 Reviewed-by: Samuel Rødal --- .../qmeegographicssystemhelper.cpp | 9 +- .../qmeegographicssystemhelper.h | 7 + .../qmeegographicssystemhelper.pro | 4 +- .../qmeegographicssystemhelper/qmeegoliveimage.cpp | 115 ---------------- tools/qmeegographicssystemhelper/qmeegoliveimage.h | 106 --------------- .../qmeegographicssystemhelper/qmeegoliveimage_p.h | 63 --------- .../qmeegolivepixmap.cpp | 150 +++++++++------------ .../qmeegographicssystemhelper/qmeegolivepixmap.h | 35 +++-- .../qmeegolivepixmap_p.h | 11 +- tools/qmeegographicssystemhelper/qmeegoruntime.cpp | 92 +++++++++++-- tools/qmeegographicssystemhelper/qmeegoruntime.h | 11 +- 11 files changed, 197 insertions(+), 406 deletions(-) delete mode 100644 tools/qmeegographicssystemhelper/qmeegoliveimage.cpp delete mode 100644 tools/qmeegographicssystemhelper/qmeegoliveimage.h delete mode 100644 tools/qmeegographicssystemhelper/qmeegoliveimage_p.h diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp index 0670ac4..d348e70 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -68,6 +68,11 @@ bool QMeeGoGraphicsSystemHelper::isRunningMeeGo() return (runningGraphicsSystemName() == QLatin1String("meego")); } +bool QMeeGoGraphicsSystemHelper::isRunningRuntime() +{ + return (QApplicationPrivate::instance()->graphics_system_name == QLatin1String("runtime")); +} + void QMeeGoGraphicsSystemHelper::switchToMeeGo() { if (isRunningMeeGo()) @@ -105,13 +110,13 @@ QPixmap QMeeGoGraphicsSystemHelper::pixmapFromEGLSharedImage(Qt::HANDLE handle, // This function is supported when not running meego too. A raster-backed // pixmap will be created... but when you switch back to 'meego', it'll // be replaced with a EGL shared image backing. - return QMeeGoRuntime::pixmapFromEGLSharedImage(handle, softImage); + return QPixmap(QMeeGoRuntime::pixmapDataFromEGLSharedImage(handle, softImage)); } QPixmap QMeeGoGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) { ENSURE_RUNNING_MEEGO; - return QMeeGoRuntime::pixmapWithGLTexture(w, h); + return QPixmap(QMeeGoRuntime::pixmapDataWithGLTexture(w, h)); } bool QMeeGoGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h index 02f2fa2..2bb75eb 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -89,6 +89,13 @@ public: switching is 'meego'. */ static bool isRunningMeeGo(); + + //! Returns true if running with a 'runtime' graphicssystem. + /*! + This function can be used in combination with ::runningGraphicsSystemName to figure out + the existing situation. + */ + static bool isRunningRuntime(); //! Switches to meego graphics system. /*! diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro index 1e6e233..4d69fac 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro @@ -6,5 +6,5 @@ include(../../src/qbase.pri) QT += gui INCLUDEPATH += '../../src/plugins/graphicssystems/meego' -HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoliveimage.h qmeegoruntime.h qmeegoliveimage_p.h qmeegolivepixmap_p.h -SOURCES = qmeegographicssystemhelper.cpp qmeegooverlaywidget.cpp qmeegoruntime.cpp qmeegolivepixmap.cpp qmeegoliveimage.cpp +HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoruntime.h qmeegolivepixmap_p.h +SOURCES = qmeegographicssystemhelper.cpp qmeegooverlaywidget.cpp qmeegoruntime.cpp qmeegolivepixmap.cpp diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp deleted file mode 100644 index 83a1e28..0000000 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** 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 plugins 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 "qmeegoliveimage.h" -#include "qmeegoliveimage_p.h" -#include "qmeegolivepixmap.h" -#include "qmeegolivepixmap_p.h" - -/* QMeeGoLiveImagePrivate */ - -QMeeGoLiveImagePrivate::QMeeGoLiveImagePrivate() -{ -} - -QMeeGoLiveImagePrivate::~QMeeGoLiveImagePrivate() -{ - if (attachedPixmaps.length() > 0) - qWarning("Destroying QMeeGoLiveImage but it still has QMeeGoLivePixmaps attached!"); -} - -void QMeeGoLiveImagePrivate::attachPixmap(QMeeGoLivePixmap* pixmap) -{ - attachedPixmaps << pixmap; -} - -void QMeeGoLiveImagePrivate::detachPixmap(QMeeGoLivePixmap* pixmap) -{ - attachedPixmaps.removeAll(pixmap); -} - -/* QMeeGoLiveImage */ - -QMeeGoLiveImage* QMeeGoLiveImage::liveImageWithSize(int w, int h, Format format, int buffers) -{ - if (format != Format_ARGB32_Premultiplied) { - qWarning("Only _ARGB32_Premultiplied format is supported for live images now!"); - return 0; - } - - if (buffers != 1) { - qWarning("Only single-buffer streams are supported at the moment"); - return 0; - } - - QMeeGoLiveImage *liveImage = new QMeeGoLiveImage(w, h); - return liveImage; -} - -QMeeGoLiveImage::QMeeGoLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new QMeeGoLiveImagePrivate()) -{ - Q_D(QMeeGoLiveImage); - d->q_ptr = this; -} - -QMeeGoLiveImage::~QMeeGoLiveImage() -{ -} - -void QMeeGoLiveImage::lock(int buffer) -{ - if (buffer != 0) - qWarning("Only locking 0 buffer is supported at the moment!"); -} - -void QMeeGoLiveImage::release(int buffer) -{ - Q_D(QMeeGoLiveImage); - - if (buffer != 0) { - qWarning("Only locking 0 buffer is supported at the moment!"); - return; - } - - // We need to copy the update image to all the client QMeeGoLivePixmap's - foreach (QMeeGoLivePixmap* livePixmap, d->attachedPixmaps) - livePixmap->d_ptr->copyBackFrom((const void *) bits()); -} diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.h b/tools/qmeegographicssystemhelper/qmeegoliveimage.h deleted file mode 100644 index 1e21e7b..0000000 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** 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 plugins 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 QMEEGOLIVEIMAGE_H -#define QMEEGOLIVEIMAGE_H - -#include - -class QMeeGoLivePixmap; -class QMeeGoLiveImagePrivate; - -//! A streamable QImage subclass. -/*! -*/ - -class QMeeGoLiveImage : public QImage -{ -public: - //! Format specifier. - /*! - Used to specify the format of the underlying image data for QMeeGoLiveImage. - */ - enum Format { - Format_ARGB32_Premultiplied //! 32bit, AARRGGBB format. The typical Qt format. - }; - - //! Locks the access to the image. - /*! - All drawing/access to the underlying image data needs to happen between - ::lock() and ::unlock() pairs. - */ - void lock(int buffer = 0); - - //! Unlocks the access to the image. - /*! - All drawing/access to the underlying image data needs to happen between - ::lock() and ::unlock() pairs. - */ - void release(int buffer = 0); - - //! Destroys the image. - /*! - It's a mistake to destroy an image before destroying all the QMeeGoLivePixmaps - built on top of it. You should first destroy all the QMeeGoLivePixmaps. - */ - virtual ~QMeeGoLiveImage(); - - //! Creates and returns a new live image with the given parameters. - /*! - The new image is created with the given width w and the given height h. - The format specifies the color format used by the image. Optionally, a - number of buffers can be specfied for a stream-like behavior. - */ - static QMeeGoLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1); - -private: - QMeeGoLiveImage(int w, int h); //! Private bits. - Q_DISABLE_COPY(QMeeGoLiveImage) - Q_DECLARE_PRIVATE(QMeeGoLiveImage) - -protected: - QScopedPointer d_ptr; - - friend class QMeeGoLivePixmap; - friend class QMeeGoLivePixmapPrivate; -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h deleted file mode 100644 index 085fed4..0000000 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** 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 plugins 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 "qmeegoliveimage.h" - -#ifndef QMEEGOLIVEIMAGE_P_H -#define QMEEGOLIVEIMAGE_P_H - -class QMeeGoLiveImagePrivate -{ -public: - Q_DECLARE_PUBLIC(QMeeGoLiveImage); - QMeeGoLiveImagePrivate(); - virtual ~QMeeGoLiveImagePrivate(); - void attachPixmap(QMeeGoLivePixmap* pixmap); - void detachPixmap(QMeeGoLivePixmap* pixmap); - - QList attachedPixmaps; - QMeeGoLiveImage *q_ptr; - - friend class QMeeGoLivePixmap; - friend class QMeeGoLivePixmapPrivate; -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp index 2a1c04b..b9dbb2b 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp @@ -43,121 +43,101 @@ #include #include #include "qmeegolivepixmap_p.h" -#include "qmeegoliveimage_p.h" +#include "qmeegoruntime.h" #include /* QMeeGoLivePixmapPrivate */ -QMeeGoLivePixmapPrivate::QMeeGoLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) +QMeeGoLivePixmapPrivate::QMeeGoLivePixmapPrivate(Qt::HANDLE h) : handle(h) { } -void QMeeGoLivePixmapPrivate::copyBackFrom(const void *raw) +QMeeGoLivePixmapPrivate::~QMeeGoLivePixmapPrivate() { - Q_Q(QMeeGoLivePixmap); - - q->detach(); - shm->lock(); - uchar *dest = ((uchar *) shm->data()) + (2 * sizeof(int)); - memcpy(dest, raw, q->width() * q->height() * 4); - shm->unlock(); } -QMeeGoLivePixmapPrivate::~QMeeGoLivePixmapPrivate() +/* QMeeGoLivePixmap */ + +QMeeGoLivePixmap* QMeeGoLivePixmap::livePixmapWithSize(int w, int h, Format format) { - Q_Q(QMeeGoLivePixmap); + QImage::Format qtFormat; + if (format == Format_RGB16) + qtFormat = QImage::Format_RGB16; + else if (format == Format_ARGB32_Premultiplied) + qtFormat = QImage::Format_ARGB32_Premultiplied; + else { + qWarning("Unsupported live pixmap format!"); + return 0; + } - if (parentImage) - parentImage->d_ptr->detachPixmap(q); - - if (shm) - shm->detach(); - - if (owns) - delete shm; -} + Qt::HANDLE liveTextureHandle = QMeeGoRuntime::createLiveTexture(w, h, qtFormat); + if (! liveTextureHandle) { + qWarning("Failed to create a live texture with given size!"); + return NULL; + } -/* QMeeGoLivePixmap */ + return QMeeGoLivePixmap::fromHandle(liveTextureHandle); +} -QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new QMeeGoLivePixmapPrivate()) +QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p, Qt::HANDLE h) : QPixmap(p), d_ptr(new QMeeGoLivePixmapPrivate(h)) { Q_D(QMeeGoLivePixmap); d->q_ptr = this; } -QMeeGoLivePixmap* QMeeGoLivePixmap::fromLiveImage(QMeeGoLiveImage *liveImage) +QMeeGoLivePixmap* QMeeGoLivePixmap::fromHandle(Qt::HANDLE liveTextureHandle) { - static int counter = 100; - QSharedMemory *shm = NULL; - uchar* imgData = NULL; - int *header = NULL; - int w = liveImage->width(); - int h = liveImage->height(); - - counter++; - shm = new QSharedMemory(QString(QLatin1String("QMeeGoLivePixmap%1")).arg(counter)); - shm->create((w * h * 4) + 2 * sizeof(int)); // +2 to store width & height - shm->attach(); - - imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); - header = (int *) shm->data(); - - header[0] = w; - header[1] = h; - - QImage img(imgData, w, h, QImage::Format_ARGB32_Premultiplied); - - QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); - pmd->fromImage(img, Qt::NoOpaqueDetection); - - QMeeGoLivePixmap *livePixmap = new QMeeGoLivePixmap(pmd); - livePixmap->d_ptr->shm = shm; - livePixmap->d_ptr->owns = true; - livePixmap->d_ptr->shmSerial = counter; - livePixmap->d_ptr->parentImage = liveImage; - - liveImage->d_ptr->attachPixmap(livePixmap); + Qt::HANDLE eglImage = QMeeGoRuntime::liveTextureToEGLImage(liveTextureHandle); + if (! eglImage) { + qWarning("Failed to bind the live texture as an egl image!"); + return NULL; + } - return livePixmap; + QPixmapData *pmd = QMeeGoRuntime::pixmapDataFromEGLImage(eglImage); + if (! pmd) { + qWarning("Failed to allocate a pixmap data from a given live texture egl image!"); + return NULL; + } + + return new QMeeGoLivePixmap(pmd, liveTextureHandle); } -QMeeGoLivePixmap* QMeeGoLivePixmap::fromHandle(Qt::HANDLE handle) +Qt::HANDLE QMeeGoLivePixmap::handle() { - QSharedMemory *shm = NULL; - int *header; - int width; - int height; - uchar* imgData; - - shm = new QSharedMemory(QString(QLatin1String("QMeeGoLivePixmap%1")).arg(handle)); - shm->attach(); - - shm->lock(); - header = (int *) shm->data(); - width = header[0]; - height = header[1]; - shm->unlock(); - - imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); - QImage img(imgData, width, height, QImage::Format_ARGB32_Premultiplied); - - QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); - pmd->fromImage(img, Qt::NoOpaqueDetection); - - QMeeGoLivePixmap *livePixmap = new QMeeGoLivePixmap(pmd); - livePixmap->d_ptr->shm = shm; - livePixmap->d_ptr->owns = false; - livePixmap->d_ptr->shmSerial = handle; - - return livePixmap; + Q_D(QMeeGoLivePixmap); + return d->handle; } QMeeGoLivePixmap::~QMeeGoLivePixmap() { } -Qt::HANDLE QMeeGoLivePixmap::handle() +QImage* QMeeGoLivePixmap::lock() +{ + Q_D(QMeeGoLivePixmap); + + void *data = NULL; + int pitch = 0; + + if (! QMeeGoRuntime::lockLiveTexture(d->handle)) { + qWarning("Failed to lock a live texture!"); + return new QImage(); + } + + QMeeGoRuntime::queryLiveTexture(d->handle, &data, &pitch); + if (data == NULL || pitch == 0) { + qWarning("Failed to query the live texture!"); + return new QImage(); + } + + // FIXME Bug here! FIX FIX FIX FIX FIX FIX + return new QImage((uchar *) data, width(), height(), QImage::Format_RGB16); +} + +void QMeeGoLivePixmap::release(QImage *img) { Q_D(QMeeGoLivePixmap); - return d->shmSerial; + // FIXME Make sure we're locked! + QMeeGoRuntime::unlockLiveTexture(d->handle); + delete img; } diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h index 2fa9db2..12fe994 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h @@ -43,7 +43,6 @@ #define QMEEGOLIVEPIXMAP_H #include -#include "qmeegoliveimage.h" class QMeeGoLivePixmapPrivate; class QSharedMemory; @@ -56,13 +55,17 @@ class QImage; class QMeeGoLivePixmap : public QPixmap { public: - //! Creates new pixmap from the given QMeeGoLiveImage. - /*! - The created QMeeGoLivePixmap will be attached to the given QMeeGoLiveImage. - Updates to the QMeeGoLiveImage will be represented on this newly created - QMeeGoLivePixmap. + enum Format { + Format_RGB16, //! 16bit, 5-6-5 RGB format. + Format_ARGB32_Premultiplied //! 32bit, AARRGGBB format. The typical Qt format. + }; + + //! Creates and returns a new live pixmap with the given parameters. + /*! + The new pixmap is created with the given width w and the given height h. + The format specifies the color format used by the pixmap. */ - static QMeeGoLivePixmap* fromLiveImage(QMeeGoLiveImage *liveImage); + static QMeeGoLivePixmap* livePixmapWithSize(int w, int h, Format format); //! Creates a new QMeeGoLivePixmap from the specified handle. /*! @@ -75,24 +78,30 @@ public: The handle can be used to share QMeeGoLivePixmap cross-process. */ Qt::HANDLE handle(); + + //! Locks the access to the pixmap. + /*! + The returned image can be used for direct access. + */ + QImage* lock(); + + //! Unlocks the access to the pixmap. + /*! + */ + void release(QImage *img); //! Destroys the QMeeGoLivePixmap. /*! - All QMeeGoLivePixmaps attached to a given QMeeGoLiveImage have to be destroyed - before the QMeeGoLiveImage itself is destroyed. */ virtual ~QMeeGoLivePixmap(); private: - QMeeGoLivePixmap(QPixmapData *p); + QMeeGoLivePixmap(QPixmapData *p, Qt::HANDLE h); Q_DISABLE_COPY(QMeeGoLivePixmap) Q_DECLARE_PRIVATE(QMeeGoLivePixmap) protected: QScopedPointer d_ptr; //! Private bits. - - friend class QMeeGoLiveImage; - friend class QMeeGoLiveImagePrivate; }; #endif diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h index c2591dc..22347d6 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h @@ -48,19 +48,12 @@ class QMeeGoLivePixmapPrivate { public: Q_DECLARE_PUBLIC(QMeeGoLivePixmap); - QMeeGoLivePixmapPrivate(); - void copyBackFrom(const void *raw); + QMeeGoLivePixmapPrivate(Qt::HANDLE handle); virtual ~QMeeGoLivePixmapPrivate(); - QSharedMemory *shm; - int shmSerial; - bool owns; - QMeeGoLiveImage *parentImage; + Qt::HANDLE handle; QMeeGoLivePixmap *q_ptr; - - friend class QMeeGoLiveImage; - friend class QMeeGoLiveImagePrivate; }; #endif diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp index 70b5dc1..44f9f58 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -51,21 +51,36 @@ bool QMeeGoRuntime::initialized = false; typedef int (*QMeeGoImageToEglSharedImageFunc) (const QImage&); typedef QPixmapData* (*QMeeGoPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); +typedef QPixmapData* (*QMeeGoPixmapDataFromEglImageFunc) (Qt::HANDLE handle); typedef QPixmapData* (*QMeeGoPixmapDataWithGLTextureFunc) (int w, int h); typedef bool (*QMeeGoDestroyEGLSharedImageFunc) (Qt::HANDLE handle); typedef void (*QMeeGoUpdateEglSharedImagePixmapFunc) (QPixmap*); typedef void (*QMeeGoSetSurfaceFixedSizeFunc) (int w, int h); typedef void (*QMeeGoSetSurfaceScalingFunc) (int x, int y, int w, int h); typedef void (*QMeeGoSetTranslucentFunc) (bool translucent); +typedef Qt::HANDLE (*QMeeGoLiveTextureCreateFunc) (int w, int h, QImage::Format format); +typedef bool (*QMeeGoLiveTextureLockFunc) (Qt::HANDLE h); +typedef bool (*QMeeGoLiveTextureUnlockFunc) (Qt::HANDLE h); +typedef void (*QMeeGoLiveTextureDestroyFunc) (Qt::HANDLE h); +typedef void (*QMeeGoLiveTextureQueryFunc) (Qt::HANDLE h, void **data, int *pitch); +typedef Qt::HANDLE (*QMeeGoLiveTextureToEglImageFunc) (Qt::HANDLE h); static QMeeGoImageToEglSharedImageFunc qt_meego_image_to_egl_shared_image = NULL; static QMeeGoPixmapDataFromEglSharedImageFunc qt_meego_pixmapdata_from_egl_shared_image = NULL; +static QMeeGoPixmapDataFromEglImageFunc qt_meego_pixmapdata_from_egl_image = NULL; static QMeeGoPixmapDataWithGLTextureFunc qt_meego_pixmapdata_with_gl_texture = NULL; static QMeeGoDestroyEGLSharedImageFunc qt_meego_destroy_egl_shared_image = NULL; static QMeeGoUpdateEglSharedImagePixmapFunc qt_meego_update_egl_shared_image_pixmap = NULL; static QMeeGoSetSurfaceFixedSizeFunc qt_meego_set_surface_fixed_size = NULL; static QMeeGoSetSurfaceScalingFunc qt_meego_set_surface_scaling = NULL; static QMeeGoSetTranslucentFunc qt_meego_set_translucent = NULL; +static QMeeGoLiveTextureCreateFunc qt_meego_live_texture_create = NULL; +static QMeeGoLiveTextureLockFunc qt_meego_live_texture_lock = NULL; +static QMeeGoLiveTextureUnlockFunc qt_meego_live_texture_unlock = NULL; +static QMeeGoLiveTextureDestroyFunc qt_meego_live_texture_destroy = NULL; +static QMeeGoLiveTextureQueryFunc qt_meego_live_texture_query = NULL; +static QMeeGoLiveTextureToEglImageFunc qt_meego_live_texture_to_egl_image = NULL; + void QMeeGoRuntime::initialize() { @@ -80,17 +95,26 @@ void QMeeGoRuntime::initialize() if (success) { qt_meego_image_to_egl_shared_image = (QMeeGoImageToEglSharedImageFunc) library.resolve("qt_meego_image_to_egl_shared_image"); - qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library.resolve("qt_meego_pixmapdata_from_egl_shared_image"); + qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library.resolve("qt_meego_pixmapdata_from_egl_shared_image"); + qt_meego_pixmapdata_from_egl_image = (QMeeGoPixmapDataFromEglImageFunc) library.resolve("qt_meego_pixmapdata_from_egl_image"); qt_meego_pixmapdata_with_gl_texture = (QMeeGoPixmapDataWithGLTextureFunc) library.resolve("qt_meego_pixmapdata_with_gl_texture"); qt_meego_destroy_egl_shared_image = (QMeeGoDestroyEGLSharedImageFunc) library.resolve("qt_meego_destroy_egl_shared_image"); qt_meego_update_egl_shared_image_pixmap = (QMeeGoUpdateEglSharedImagePixmapFunc) library.resolve("qt_meego_update_egl_shared_image_pixmap"); qt_meego_set_surface_fixed_size = (QMeeGoSetSurfaceFixedSizeFunc) library.resolve("qt_meego_set_surface_fixed_size"); qt_meego_set_surface_scaling = (QMeeGoSetSurfaceScalingFunc) library.resolve("qt_meego_set_surface_scaling"); qt_meego_set_translucent = (QMeeGoSetTranslucentFunc) library.resolve("qt_meego_set_translucent"); - - if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image && qt_meego_pixmapdata_with_gl_texture - && qt_meego_destroy_egl_shared_image && qt_meego_update_egl_shared_image_pixmap && qt_meego_set_surface_fixed_size - && qt_meego_set_surface_scaling && qt_meego_set_translucent) + qt_meego_live_texture_create = (QMeeGoLiveTextureCreateFunc) library.resolve("qt_meego_live_texture_create"); + qt_meego_live_texture_lock = (QMeeGoLiveTextureLockFunc) library.resolve("qt_meego_live_texture_lock"); + qt_meego_live_texture_unlock = (QMeeGoLiveTextureUnlockFunc) library.resolve("qt_meego_live_texture_unlock"); + qt_meego_live_texture_destroy = (QMeeGoLiveTextureDestroyFunc) library.resolve("qt_meego_live_texture_destroy"); + qt_meego_live_texture_query = (QMeeGoLiveTextureQueryFunc) library.resolve("qt_meego_live_texture_query"); + qt_meego_live_texture_to_egl_image = (QMeeGoLiveTextureToEglImageFunc) library.resolve("qt_meego_live_texture_to_egl_image"); + + if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image && qt_meego_pixmapdata_from_egl_image && + qt_meego_pixmapdata_with_gl_texture && qt_meego_destroy_egl_shared_image && qt_meego_update_egl_shared_image_pixmap && + qt_meego_set_surface_fixed_size && qt_meego_set_surface_scaling && qt_meego_set_translucent && + qt_meego_live_texture_create && qt_meego_live_texture_lock && qt_meego_live_texture_unlock && + qt_meego_live_texture_destroy && qt_meego_live_texture_query && qt_meego_live_texture_to_egl_image) { qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion)); } @@ -108,18 +132,25 @@ Qt::HANDLE QMeeGoRuntime::imageToEGLSharedImage(const QImage &image) return qt_meego_image_to_egl_shared_image(image); } -QPixmap QMeeGoRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +QPixmapData* QMeeGoRuntime::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) { ENSURE_INITIALIZED; Q_ASSERT(qt_meego_pixmapdata_from_egl_shared_image); - return QPixmap(qt_meego_pixmapdata_from_egl_shared_image(handle, softImage)); + return qt_meego_pixmapdata_from_egl_shared_image(handle, softImage); +} + +QPixmapData* QMeeGoRuntime::pixmapDataFromEGLImage(Qt::HANDLE handle) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_pixmapdata_from_egl_image); + return qt_meego_pixmapdata_from_egl_image(handle); } -QPixmap QMeeGoRuntime::pixmapWithGLTexture(int w, int h) +QPixmapData* QMeeGoRuntime::pixmapDataWithGLTexture(int w, int h) { ENSURE_INITIALIZED; Q_ASSERT(qt_meego_pixmapdata_with_gl_texture); - return QPixmap(qt_meego_pixmapdata_with_gl_texture(w, h)); + return qt_meego_pixmapdata_with_gl_texture(w, h); } bool QMeeGoRuntime::destroyEGLSharedImage(Qt::HANDLE handle) @@ -156,3 +187,46 @@ void QMeeGoRuntime::setTranslucent(bool translucent) Q_ASSERT(qt_meego_set_translucent); qt_meego_set_translucent(translucent); } + +Qt::HANDLE QMeeGoRuntime::createLiveTexture(int w, int h, QImage::Format format) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_create); + return qt_meego_live_texture_create(w, h, format); +} + +bool QMeeGoRuntime::lockLiveTexture(Qt::HANDLE h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_lock); + return qt_meego_live_texture_lock(h); +} + +bool QMeeGoRuntime::unlockLiveTexture(Qt::HANDLE h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_unlock); + return qt_meego_live_texture_unlock(h); +} + +void QMeeGoRuntime::destroyLiveTexture(Qt::HANDLE h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_destroy); + qt_meego_live_texture_destroy(h); +} + +void QMeeGoRuntime::queryLiveTexture(Qt::HANDLE h, void **data, int *pitch) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_query); + qt_meego_live_texture_query(h, data, pitch); +} + +Qt::HANDLE QMeeGoRuntime::liveTextureToEGLImage(Qt::HANDLE handle) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_to_egl_image); + return qt_meego_live_texture_to_egl_image(handle); +} + diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h index 82fdb52..048b9be 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.h +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -48,13 +48,20 @@ public: static void initialize(); static Qt::HANDLE imageToEGLSharedImage(const QImage &image); - static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); - static QPixmap pixmapWithGLTexture(int w, int h); + static QPixmapData* pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + static QPixmapData* pixmapDataFromEGLImage(Qt::HANDLE handle); + static QPixmapData* pixmapDataWithGLTexture(int w, int h); static bool destroyEGLSharedImage(Qt::HANDLE handle); static void updateEGLSharedImagePixmap(QPixmap *p); static void setSurfaceFixedSize(int w, int h); static void setSurfaceScaling(int x, int y, int w, int h); static void setTranslucent(bool translucent); + static Qt::HANDLE createLiveTexture(int w, int h, QImage::Format format); + static bool lockLiveTexture(Qt::HANDLE h); + static bool unlockLiveTexture(Qt::HANDLE h); + static void destroyLiveTexture(Qt::HANDLE h); + static void queryLiveTexture(Qt::HANDLE h, void **data, int *pitch); + static Qt::HANDLE liveTextureToEGLImage(Qt::HANDLE); private: static bool initialized; -- cgit v0.12 From eca7559542584a5675d22d619a7710e0f17cfba0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 8 Oct 2010 09:08:34 +1000 Subject: Fix dragging items within a PathView The test to determine whether the mouse had moved greater than startDragDistance() compared the starting point on the path to the current mouse position. Fix to compare nearest path position. Task-number: QTBUG-14220 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativepathview.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index 31943b2..81c84f5 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -1112,16 +1112,16 @@ void QDeclarativePathViewPrivate::handleMouseMoveEvent(QGraphicsSceneMouseEvent if (!interactive || !lastPosTime.isValid()) return; + qreal newPc; + QPointF pathPoint = pointNear(event->pos(), &newPc); if (!stealMouse) { - QPointF delta = event->pos() - startPoint; + QPointF delta = pathPoint - startPoint; if (qAbs(delta.x()) > QApplication::startDragDistance() || qAbs(delta.y()) > QApplication::startDragDistance()) stealMouse = true; } if (stealMouse) { moveReason = QDeclarativePathViewPrivate::Mouse; - qreal newPc; - pointNear(event->pos(), &newPc); qreal diff = (newPc - startPc)*modelCount*mappedRange; if (diff) { setOffset(offset + diff); -- cgit v0.12 From 8480eb288990c44c9ab337f42898bc4ef6dc62f4 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 8 Oct 2010 11:06:34 +1000 Subject: Don't allow multiple values to be assigned to a singular property Task-number: QTBUG-14005 --- src/declarative/qml/qdeclarativecompiler.cpp | 3 +++ .../declarative/qdeclarativebehaviors/data/reassignedAnimation.qml | 7 ++++++- .../qdeclarativelanguage/data/singularProperty.2.errors.txt | 1 + .../declarative/qdeclarativelanguage/data/singularProperty.2.qml | 7 +++++++ .../qdeclarativelanguage/data/singularProperty.errors.txt | 1 + .../declarative/qdeclarativelanguage/data/singularProperty.qml | 6 ++++++ .../declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp | 2 ++ 7 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index dc28e22..7a29f24 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1932,6 +1932,9 @@ bool QDeclarativeCompiler::buildPropertyAssignment(QDeclarativeParser::Property { obj->addValueProperty(prop); + if (prop->values.count() > 1) + COMPILE_EXCEPTION(prop->values.at(0), tr( "Cannot assign multiple values to a singular property") ); + for (int ii = 0; ii < prop->values.count(); ++ii) { Value *v = prop->values.at(ii); if (v->object) { diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml index 9fca5c3..56ac216 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml +++ b/tests/auto/declarative/qdeclarativebehaviors/data/reassignedAnimation.qml @@ -7,9 +7,9 @@ Rectangle { objectName: "MyRect" width: 100; height: 100; color: "green" Behavior on x { + id: myBehavior objectName: "MyBehavior" NumberAnimation {id: na1; duration: 200 } - NumberAnimation {id: na2; duration: 1000 } } } MouseArea { @@ -24,4 +24,9 @@ Rectangle { x: 200 } } + + NumberAnimation {id: na2; duration: 1000 } + Component.onCompleted: { + myBehavior.animation = na2; + } } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt new file mode 100644 index 0000000..beae562 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.errors.txt @@ -0,0 +1 @@ +5:10:Cannot assign multiple values to a singular property diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml new file mode 100644 index 0000000..2fd7fd2 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.2.qml @@ -0,0 +1,7 @@ +import QtQuick 1.0 + +QtObject { + property QtObject a + a: [ QtObject {}, QtObject {} ] +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt new file mode 100644 index 0000000..beae562 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.errors.txt @@ -0,0 +1 @@ +5:10:Cannot assign multiple values to a singular property diff --git a/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml new file mode 100644 index 0000000..da56cb8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/singularProperty.qml @@ -0,0 +1,6 @@ +import QtQuick 1.0 + +QtObject { + property variant a + a: [ QtObject {}, QtObject {} ] +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 9a8c944..bb1312b 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -380,6 +380,8 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false; QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false; QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false; + QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false; + QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false; } -- cgit v0.12 From a5b0d58bbba508d708b2711124c61a74e3b4f310 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 8 Oct 2010 11:26:57 +1000 Subject: Ensure Flickable.contentX and Flickable.contentY return correct values. The animation value was used previously, but this isn't the actual position of the contentItem. Task-number: QTBUG-13603 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativeflickable.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 33c21b1..001abca 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -466,7 +466,7 @@ QDeclarativeFlickable::~QDeclarativeFlickable() qreal QDeclarativeFlickable::contentX() const { Q_D(const QDeclarativeFlickable); - return -d->hData.move.value(); + return -d->contentItem->x(); } void QDeclarativeFlickable::setContentX(qreal pos) @@ -484,7 +484,7 @@ void QDeclarativeFlickable::setContentX(qreal pos) qreal QDeclarativeFlickable::contentY() const { Q_D(const QDeclarativeFlickable); - return -d->vData.move.value(); + return -d->contentItem->y(); } void QDeclarativeFlickable::setContentY(qreal pos) -- cgit v0.12 From e38185424bda5b97bca4c381abbb6f4c577d55cf Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 8 Oct 2010 11:44:16 +1000 Subject: Remove some unnecessary includes in cpp files --- src/declarative/graphicsitems/qdeclarativeimagebase.cpp | 2 -- src/declarative/graphicsitems/qdeclarativeitem.cpp | 1 - src/declarative/graphicsitems/qdeclarativepainteditem.cpp | 1 - src/declarative/qml/qdeclarativecomponent.cpp | 1 - src/declarative/util/qdeclarativefontloader.cpp | 1 - 5 files changed, 6 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index 02b4807..b06e2f7 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -46,8 +46,6 @@ #include #include -#include - QT_BEGIN_NAMESPACE QDeclarativeImageBase::QDeclarativeImageBase(QDeclarativeImageBasePrivate &dd, QDeclarativeItem *parent) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 250a43b..735698e 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -56,7 +56,6 @@ #include #include -#include #include #include #include diff --git a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp index a6db1fa..b470b3a 100644 --- a/src/declarative/graphicsitems/qdeclarativepainteditem.cpp +++ b/src/declarative/graphicsitems/qdeclarativepainteditem.cpp @@ -44,7 +44,6 @@ #include #include -#include #include #include #include diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index b532b0c..cfef9cf 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -57,7 +57,6 @@ #include #include -#include #include #include diff --git a/src/declarative/util/qdeclarativefontloader.cpp b/src/declarative/util/qdeclarativefontloader.cpp index 3e4a81a..d2f65ef 100644 --- a/src/declarative/util/qdeclarativefontloader.cpp +++ b/src/declarative/util/qdeclarativefontloader.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include -- cgit v0.12 From 0bf05331d901ca27e358ec22569a07489a70b7a5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 8 Oct 2010 11:46:36 +1000 Subject: emit currentSectionChanged when section changes in ListView. Task-number: QTBUG-13981 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativelistview.cpp | 15 ++++++++++++--- .../qdeclarativelistview/tst_qdeclarativelistview.cpp | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 6b46bc5..4943aef 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -1009,18 +1009,27 @@ void QDeclarativeListViewPrivate::updateSections() void QDeclarativeListViewPrivate::updateCurrentSection() { + Q_Q(QDeclarativeListView); if (!sectionCriteria || visibleItems.isEmpty()) { - currentSection.clear(); + if (!currentSection.isEmpty()) { + currentSection.clear(); + emit q->currentSectionChanged(); + } return; } int index = 0; while (index < visibleItems.count() && visibleItems.at(index)->endPosition() < position()) ++index; + QString newSection = currentSection; if (index < visibleItems.count()) - currentSection = visibleItems.at(index)->attached->section(); + newSection = visibleItems.at(index)->attached->section(); else - currentSection = visibleItems.first()->attached->section(); + newSection = visibleItems.first()->attached->section(); + if (newSection != currentSection) { + currentSection = newSection; + emit q->currentSectionChanged(); + } } void QDeclarativeListViewPrivate::updateCurrent(int modelIndex) diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 6452bae..65ff635 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -937,6 +937,8 @@ void tst_QDeclarativeListView::sections() QCOMPARE(next->text().toInt(), (i+1)/5); } + QSignalSpy currentSectionChangedSpy(listview, SIGNAL(currentSectionChanged())); + // Remove section boundary model.removeItem(5); @@ -972,9 +974,13 @@ void tst_QDeclarativeListView::sections() listview->setContentY(140); QTRY_COMPARE(listview->currentSection(), QString("1")); + QTRY_COMPARE(currentSectionChangedSpy.count(), 1); + listview->setContentY(20); QTRY_COMPARE(listview->currentSection(), QString("0")); + QTRY_COMPARE(currentSectionChangedSpy.count(), 2); + item = findItem(contentItem, "wrapper", 1); QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 20.0); -- cgit v0.12 From 10f0cc708b8e7fc2206d1a141dfd4122e7a6f4b0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 8 Oct 2010 12:55:21 +1000 Subject: Ensure that onRelease is called for doubleClick events. Also ensures that the pressed property is updated appropriately and the double click and hold is possible. Task-number: QTBUG-14279 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativemousearea.cpp | 12 ++++++------ src/declarative/graphicsitems/qdeclarativemousearea_p_p.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativemousearea.cpp b/src/declarative/graphicsitems/qdeclarativemousearea.cpp index a0208ef..1533d55 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea.cpp +++ b/src/declarative/graphicsitems/qdeclarativemousearea.cpp @@ -557,6 +557,7 @@ void QDeclarativeMouseArea::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ungrabMouse(); setKeepMouseGrab(false); } + d->doubleClick = false; } void QDeclarativeMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) @@ -565,14 +566,12 @@ void QDeclarativeMouseArea::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even if (!d->absorb) { QDeclarativeItem::mouseDoubleClickEvent(event); } else { + d->doubleClick = true; d->saveEvent(event); QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, true, false); me.setAccepted(d->isDoubleClickConnected()); emit this->doubleClicked(&me); - if (!me.isAccepted()) { - // Only deliver the press event if we haven't accepted the double click. - QDeclarativeItem::mouseDoubleClickEvent(event); - } + QDeclarativeItem::mouseDoubleClickEvent(event); } } @@ -841,7 +840,8 @@ bool QDeclarativeMouseArea::setPressed(bool p) d->pressed = p; QDeclarativeMouseEvent me(d->lastPos.x(), d->lastPos.y(), d->lastButton, d->lastButtons, d->lastModifiers, isclick, d->longPress); if (d->pressed) { - emit pressed(&me); + if (!d->doubleClick) + emit pressed(&me); me.setX(d->lastPos.x()); me.setY(d->lastPos.y()); emit mousePositionChanged(&me); @@ -849,7 +849,7 @@ bool QDeclarativeMouseArea::setPressed(bool p) emit released(&me); me.setX(d->lastPos.x()); me.setY(d->lastPos.y()); - if (isclick && !d->longPress) + if (isclick && !d->longPress && !d->doubleClick) emit clicked(&me); } diff --git a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h index 48a56d9..06a01d3 100644 --- a/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativemousearea_p_p.h @@ -68,7 +68,7 @@ class QDeclarativeMouseAreaPrivate : public QDeclarativeItemPrivate public: QDeclarativeMouseAreaPrivate() : absorb(true), hovered(false), pressed(false), longPress(false), - moved(false), stealMouse(false), drag(0) + moved(false), stealMouse(false), doubleClick(false), drag(0) { } @@ -109,6 +109,7 @@ public: bool dragX : 1; bool dragY : 1; bool stealMouse : 1; + bool doubleClick : 1; QDeclarativeDrag *drag; QPointF startScene; qreal startX; -- cgit v0.12 From 5447a9590dc0efa1a79fde6235fdcf76d3ae81fe Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 8 Oct 2010 13:01:11 +1000 Subject: Add test for QTBUG-14279 Task-number: QTBUG-14279 --- tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml | 2 ++ .../declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml b/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml index 2348444..55b0812 100644 --- a/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml +++ b/tests/auto/declarative/qdeclarativemousearea/data/doubleclick.qml @@ -4,11 +4,13 @@ Item { id: root property int clicked: 0 property int doubleClicked: 0 + property int released: 0 MouseArea { width: 200; height: 200 onClicked: { root.clicked++ } onDoubleClicked: { root.doubleClicked++ } + onReleased: { root.released++ } } } diff --git a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp index 5e88450..5a50e0d 100644 --- a/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp +++ b/tests/auto/declarative/qdeclarativemousearea/tst_qdeclarativemousearea.cpp @@ -413,14 +413,19 @@ void tst_QDeclarativeMouseArea::doubleClick() releaseEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &releaseEvent); + QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); + QGraphicsSceneMouseEvent dblClickEvent(QEvent::GraphicsSceneMouseDoubleClick); dblClickEvent.setScenePos(QPointF(100, 100)); dblClickEvent.setButton(Qt::LeftButton); dblClickEvent.setButtons(Qt::LeftButton); QApplication::sendEvent(scene, &dblClickEvent); + QApplication::sendEvent(scene, &releaseEvent); + QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1); + QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); } QTEST_MAIN(tst_QDeclarativeMouseArea) -- cgit v0.12 From c4cbd04275906b1bfa1a55147a0a4bb626033a20 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 8 Oct 2010 13:47:17 +1000 Subject: Check plugin and QML file case on Mac and Windows This test should prevent the case where a QML app that is developed on a case insensitive filesystem (like on Mac or Windows) and then run on a case sensitive filesystem (like on Linux) fails to find module plugins, imports and QML files. Task-number: QTBUG-13517 --- src/declarative/qml/qdeclarativeengine.cpp | 26 +++++++ src/declarative/qml/qdeclarativeglobal_p.h | 13 ++++ src/declarative/qml/qdeclarativeimport.cpp | 11 ++- src/declarative/qml/qdeclarativetypeloader.cpp | 8 +++ .../data/importIncorrectCase.qml | 5 ++ .../data/incorrectCase.errors.insensitive.txt | 2 + .../data/incorrectCase.errors.sensitive.txt | 1 + .../qdeclarativelanguage/data/incorrectCase.qml | 4 ++ .../data/incorrectCaseType.qml | 4 ++ .../tst_qdeclarativelanguage.cpp | 24 +++++++ .../data/incorrectCase.qml | 4 ++ .../imports/com/nokia/WrongCase/qmldir | 1 + .../pluginWrongCase/plugin.cpp | 83 ++++++++++++++++++++++ .../pluginWrongCase/pluginWrongCase.pro | 10 +++ .../qdeclarativemoduleplugin.pro | 2 +- .../tst_qdeclarativemoduleplugin.cpp | 20 ++++++ 16 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp create mode 100644 tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 584c5ec..0749767 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -2159,4 +2159,30 @@ const QMetaObject *QDeclarativeEnginePrivate::metaObjectForType(int t) const } } +bool QDeclarative_isFileCaseCorrect(const QString &fileName) +{ +#if defined(Q_OS_MAC) || defined(Q_OS_WIN) + QFileInfo info(fileName); + + QString absolute = info.absoluteFilePath(); + QString canonical = info.canonicalFilePath(); + + int absoluteLength = absolute.length(); + int canonicalLength = canonical.length(); + + int length = qMin(absoluteLength, canonicalLength); + for (int ii = 0; ii < length; ++ii) { + const QChar &a = absolute.at(absoluteLength - 1 - ii); + const QChar &c = canonical.at(canonicalLength - 1 - ii); + + if (a.toLower() != c.toLower()) + return true; + if (a != c) + return false; + } +#endif + + return true; +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeglobal_p.h b/src/declarative/qml/qdeclarativeglobal_p.h index 1041992..65d9b24 100644 --- a/src/declarative/qml/qdeclarativeglobal_p.h +++ b/src/declarative/qml/qdeclarativeglobal_p.h @@ -75,6 +75,19 @@ struct QDeclarativeGraphics_DerivedObject : public QObject }; /*! + Returns true if the case of \a fileName is equivalent to the file case of + \a fileName on disk, and false otherwise. + + This is used to ensure that the behavior of QML on a case-insensitive file + system is the same as on a case-sensitive file system. This function + performs a "best effort" attempt to determine the real case of the file. + It may have false positives (say the case is correct when it isn't), but it + should never have a false negative (say the case is incorrect when it is + correct). +*/ +bool QDeclarative_isFileCaseCorrect(const QString &fileName); + +/*! Makes the \a object a child of \a parent. Note that when using this method, neither \a parent nor the object's previous parent (if it had one) will receive ChildRemoved or ChildAdded events. diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index fe4ed48..6f5216a 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -351,7 +351,11 @@ bool QDeclarativeImportsPrivate::importExtension(const QString &absoluteFilePath { QFile file(absoluteFilePath); QString filecontent; - if (file.open(QFile::ReadOnly)) { + if (!QDeclarative_isFileCaseCorrect(absoluteFilePath)) { + if (errorString) + *errorString = QDeclarativeImportDatabase::tr("cannot load module \"%1\": File name case mismatch for \"%2\"").arg(uri).arg(absoluteFilePath); + return false; + } else if (file.open(QFile::ReadOnly)) { filecontent = QString::fromUtf8(file.readAll()); if (qmlImportTrace()) qDebug().nospace() << "QDeclarativeImports(" << qPrintable(base.toString()) << "::importExtension: " @@ -913,6 +917,11 @@ bool QDeclarativeImportDatabase::importPlugin(const QString &filePath, const QSt } if (!engineInitialized || !typesRegistered) { + if (!QDeclarative_isFileCaseCorrect(absoluteFilePath)) { + if (errorString) + *errorString = tr("File name case mismatch for \"%2\"").arg(absoluteFilePath); + return false; + } QPluginLoader loader(absoluteFilePath); if (!loader.load()) { diff --git a/src/declarative/qml/qdeclarativetypeloader.cpp b/src/declarative/qml/qdeclarativetypeloader.cpp index 061f309..c8e1a07 100644 --- a/src/declarative/qml/qdeclarativetypeloader.cpp +++ b/src/declarative/qml/qdeclarativetypeloader.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include @@ -493,6 +494,13 @@ void QDeclarativeDataLoader::load(QDeclarativeDataBlob *blob) QString lf = QDeclarativeEnginePrivate::urlToLocalFileOrQrc(blob->m_url); if (!lf.isEmpty()) { + if (!QDeclarative_isFileCaseCorrect(lf)) { + QDeclarativeError error; + error.setUrl(blob->m_url); + error.setDescription(QLatin1String("File name case mismatch")); + blob->setError(error); + return; + } QFile file(lf); if (file.open(QFile::ReadOnly)) { QByteArray data = file.readAll(); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml b/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml new file mode 100644 index 0000000..247f527 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/importIncorrectCase.qml @@ -0,0 +1,5 @@ +import QtQuick 1.0 +import com.Nokia.installedtest 1.0 + +QtObject { +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt new file mode 100644 index 0000000..3813680 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.insensitive.txt @@ -0,0 +1,2 @@ +3:1:Type IncorrectCaseType unavailable +-1:-1:File name case mismatch diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt new file mode 100644 index 0000000..abed1a7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.errors.sensitive.txt @@ -0,0 +1 @@ +3:1:IncorrectCaseType is not a type diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml new file mode 100644 index 0000000..d11000b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCase.qml @@ -0,0 +1,4 @@ +import QtQuick 1.0 + +IncorrectCaseType { +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml new file mode 100644 index 0000000..cf32b45 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/incorrectCaseType.qml @@ -0,0 +1,4 @@ +import QtQuick 1.0 + +QtObject { +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index bb1312b..2aac27e 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -144,6 +144,7 @@ private slots: void importsInstalled(); void importsOrder_data(); void importsOrder(); + void importIncorrectCase(); void qmlAttachedPropertiesObjectMethod(); void customOnProperty(); @@ -382,6 +383,13 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false; QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false; QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false; + QTest::newRow("incorrectCase") << "incorrectCase.qml" +#if defined(Q_OS_MAC) || defined(Q_OS_WIN) + << "incorrectCase.errors.insensitive.txt" +#else + << "incorrectCase.errors.sensitive.txt" +#endif + << false; } @@ -1724,6 +1732,22 @@ void tst_qdeclarativelanguage::importsOrder() testType(qml,type,error); } +void tst_qdeclarativelanguage::importIncorrectCase() +{ + QDeclarativeComponent component(&engine, TEST_FILE("importIncorrectCase.qml")); + + QList errors = component.errors(); + QCOMPARE(errors.count(), 1); + +#if defined(Q_OS_MAC) || defined(Q_OS_WIN) + QString expectedError = QLatin1String("cannot load module \"com.Nokia.installedtest\": File name case mismatch for \"") + QFileInfo(__FILE__).absoluteDir().filePath("data/lib/com/Nokia/installedtest/qmldir") + QLatin1String("\""); +#else + QString expectedError = QLatin1String("module \"com.Nokia.installedtest\" is not installed"); +#endif + + QCOMPARE(errors.at(0).description(), expectedError); +} + void tst_qdeclarativelanguage::qmlAttachedPropertiesObjectMethod() { QObject object; diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml b/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml new file mode 100644 index 0000000..a21ece7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/data/incorrectCase.qml @@ -0,0 +1,4 @@ +import com.nokia.WrongCase 1.0 + +MyPluginType { value: 123 } + diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir new file mode 100644 index 0000000..6c87874 --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/imports/com/nokia/WrongCase/qmldir @@ -0,0 +1 @@ +plugin PluGin diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp new file mode 100644 index 0000000..5e91f4e --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/plugin.cpp @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 test suite 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 +#include +#include +#include + +class MyPluginType : public QObject +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue) + +public: + MyPluginType(QObject *parent=0) : QObject(parent) + { + qWarning("import worked"); + } + + int value() const { return v; } + void setValue(int i) { v = i; } + +private: + int v; +}; + + +class MyPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + MyPlugin() + { + qWarning("plugin created"); + } + + void registerTypes(const char *uri) + { + Q_ASSERT(QLatin1String(uri) == "com.nokia.WrongCase"); + qmlRegisterType(uri, 1, 0, "MyPluginType"); + } +}; + +#include "plugin.moc" + +Q_EXPORT_PLUGIN2(plugin, MyPlugin); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro new file mode 100644 index 0000000..c7337ca --- /dev/null +++ b/tests/auto/declarative/qdeclarativemoduleplugin/pluginWrongCase/pluginWrongCase.pro @@ -0,0 +1,10 @@ +TEMPLATE = lib +CONFIG += plugin +SOURCES = plugin.cpp +QT = core declarative +TARGET = Plugin +DESTDIR = ../imports/com/nokia/WrongCase + +symbian: { + TARGET.EPOCALLOWDLLDATA=1 +} diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro index 824b402..221e465 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro +++ b/tests/auto/declarative/qdeclarativemoduleplugin/qdeclarativemoduleplugin.pro @@ -1,6 +1,6 @@ QT = core TEMPLATE = subdirs -SUBDIRS = plugin +SUBDIRS = plugin pluginWrongCase tst_qdeclarativemoduleplugin_pro.depends += plugin SUBDIRS += tst_qdeclarativemoduleplugin.pro diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index e1022e0..587a86a 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -54,6 +54,7 @@ public: private slots: void importsPlugin(); + void incorrectPluginCase(); }; #ifdef Q_OS_SYMBIAN @@ -120,6 +121,25 @@ void tst_qdeclarativemoduleplugin::importsPlugin() delete object; } +void tst_qdeclarativemoduleplugin::incorrectPluginCase() +{ + QDeclarativeEngine engine; + engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); + + QDeclarativeComponent component(&engine, TEST_FILE("data/incorrectCase.qml")); + + QList errors = component.errors(); + QCOMPARE(errors.count(), 1); + +#if defined(Q_OS_MAC) || defined(Q_OS_WIN) + QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QFileInfo(__FILE__).absoluteDir().filePath("imports/com/nokia/WrongCase/libPluGin.dylib") + QLatin1String("\""); +#else + QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found"); +#endif + + QCOMPARE(errors.at(0).description(), expectedError); +} + QTEST_MAIN(tst_qdeclarativemoduleplugin) #include "tst_qdeclarativemoduleplugin.moc" -- cgit v0.12 From a139b9aff0d658758cc7a8063377824178a8ea92 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 8 Oct 2010 14:03:37 +1000 Subject: Disable Text {} image caching by default Task-number: QTBUG-14050 --- src/declarative/graphicsitems/qdeclarativetext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 65f1564..54cb062 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -82,7 +82,7 @@ private: static QSet errors; }; -DEFINE_BOOL_CONFIG_OPTION(disableImageCache, QML_DISABLE_IMAGE_CACHE); +DEFINE_BOOL_CONFIG_OPTION(enableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE); QDeclarativeTextPrivate::QDeclarativeTextPrivate() : color((QRgb)0), style(QDeclarativeText::Normal), @@ -90,7 +90,7 @@ QDeclarativeTextPrivate::QDeclarativeTextPrivate() imgDirty(true), dirty(true), richText(false), singleline(false), cache(true), internalWidthUpdate(false), doc(0), format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap) { - cache = !disableImageCache(); + cache = enableImageCache(); QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton; QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; } -- cgit v0.12 From 762b03e1ae83ffd66965810e1d70326b364115f5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 8 Oct 2010 14:17:05 +1000 Subject: Don't forward keys to invisible items. Task-number: QTBUG-13685 Reviewed-by: Michael Brasser --- src/declarative/graphicsitems/qdeclarativeitem.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeitem.cpp b/src/declarative/graphicsitems/qdeclarativeitem.cpp index 735698e..51eb5f2 100644 --- a/src/declarative/graphicsitems/qdeclarativeitem.cpp +++ b/src/declarative/graphicsitems/qdeclarativeitem.cpp @@ -1180,7 +1180,7 @@ void QDeclarativeKeysAttached::keyPressed(QKeyEvent *event, bool post) d->inPress = true; for (int ii = 0; ii < d->targets.count(); ++ii) { QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i) { + if (i && i->isVisible()) { d->item->scene()->sendEvent(i, event); if (event->isAccepted()) { d->inPress = false; @@ -1222,7 +1222,7 @@ void QDeclarativeKeysAttached::keyReleased(QKeyEvent *event, bool post) d->inRelease = true; for (int ii = 0; ii < d->targets.count(); ++ii) { QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i) { + if (i && i->isVisible()) { d->item->scene()->sendEvent(i, event); if (event->isAccepted()) { d->inRelease = false; @@ -1247,7 +1247,7 @@ void QDeclarativeKeysAttached::inputMethodEvent(QInputMethodEvent *event, bool p d->inIM = true; for (int ii = 0; ii < d->targets.count(); ++ii) { QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod)) { + if (i && i->isVisible() && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod)) { d->item->scene()->sendEvent(i, event); if (event->isAccepted()) { d->imeItem = i; @@ -1275,7 +1275,7 @@ QVariant QDeclarativeKeysAttached::inputMethodQuery(Qt::InputMethodQuery query) if (d->item) { for (int ii = 0; ii < d->targets.count(); ++ii) { QGraphicsItem *i = d->finalFocusProxy(d->targets.at(ii)); - if (i && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check? + if (i && i->isVisible() && (i->flags() & QGraphicsItem::ItemAcceptsInputMethod) && i == d->imeItem) { //### how robust is i == d->imeItem check? QVariant v = static_cast(i)->doInputMethodQuery(query); if (v.userType() == QVariant::RectF) v = d->item->mapRectFromItem(i, v.toRectF()); //### cost? -- cgit v0.12 From fd2d104988955e4e94252abd8d90507aa33dc10d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 8 Oct 2010 14:34:48 +1000 Subject: Test for QTBUG-13685 Task-number: QTBUG-13685 --- tests/auto/declarative/qdeclarativeitem/data/keystest.qml | 1 + .../declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/tests/auto/declarative/qdeclarativeitem/data/keystest.qml b/tests/auto/declarative/qdeclarativeitem/data/keystest.qml index 3927f42..9af6e9f 100644 --- a/tests/auto/declarative/qdeclarativeitem/data/keystest.qml +++ b/tests/auto/declarative/qdeclarativeitem/data/keystest.qml @@ -17,6 +17,7 @@ Item { Item { id: item2 + visible: forwardeeVisible Keys.onPressed: keysTestObject.forwardedKey(event.key) Keys.onReleased: keysTestObject.forwardedKey(event.key) } diff --git a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp index bbbf73e..b4903ae 100644 --- a/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp +++ b/tests/auto/declarative/qdeclarativeitem/tst_qdeclarativeitem.cpp @@ -204,6 +204,7 @@ void tst_QDeclarativeItem::keys() canvas->rootContext()->setContextProperty("keysTestObject", testObject); canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); + canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true)); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keystest.qml")); canvas->show(); @@ -287,6 +288,17 @@ void tst_QDeclarativeItem::keys() testObject->reset(); + canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(false)); + key = QKeyEvent(QEvent::KeyPress, Qt::Key_A, Qt::NoModifier, "A", false, 1); + QApplication::sendEvent(canvas, &key); + QCOMPARE(testObject->mKey, int(Qt::Key_A)); + QCOMPARE(testObject->mForwardedKey, 0); + QCOMPARE(testObject->mText, QLatin1String("A")); + QVERIFY(testObject->mModifiers == Qt::NoModifier); + QVERIFY(!key.isAccepted()); + + testObject->reset(); + canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(false)); QCOMPARE(canvas->rootObject()->property("isEnabled").toBool(), false); -- cgit v0.12 From e17a5398bf20b89834d4d6c7f4d9203f192b101f Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Fri, 8 Oct 2010 14:50:43 +1000 Subject: Image.sourceSize is incorrect after changing Image.source Task-number: QTBUG-14303 --- .../graphicsitems/qdeclarativeimagebase.cpp | 13 +++++---- .../graphicsitems/qdeclarativeimagebase_p_p.h | 2 ++ .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 34 ++++++++++++++++++++-- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index b06e2f7..c3bac2d 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -113,6 +113,7 @@ void QDeclarativeImageBase::setSourceSize(const QSize& size) return; d->sourcesize = size; + d->explicitSourceSize = true; emit sourceSizeChanged(); if (isComponentComplete()) load(); @@ -121,7 +122,10 @@ void QDeclarativeImageBase::setSourceSize(const QSize& size) QSize QDeclarativeImageBase::sourceSize() const { Q_D(const QDeclarativeImageBase); - return d->sourcesize.isValid() ? d->sourcesize : QSize(implicitWidth(),implicitHeight()); + + int width = d->sourcesize.width(); + int height = d->sourcesize.height(); + return QSize(width != -1 ? width : implicitWidth(), height != -1 ? height : implicitHeight()); } void QDeclarativeImageBase::load() @@ -139,7 +143,7 @@ void QDeclarativeImageBase::load() pixmapChange(); update(); } else { - d->pix.load(qmlEngine(this), d->url, d->sourcesize, d->async); + d->pix.load(qmlEngine(this), d->url, d->explicitSourceSize ? sourceSize() : QSize(), d->async); if (d->pix.isLoading()) { d->progress = 0.0; @@ -184,11 +188,8 @@ void QDeclarativeImageBase::requestFinished() setImplicitWidth(d->pix.width()); setImplicitHeight(d->pix.height()); - if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height()) { - d->sourcesize.setWidth(d->pix.width()); - d->sourcesize.setHeight(d->pix.height()); + if (d->sourcesize.width() != d->pix.width() || d->sourcesize.height() != d->pix.height()) emit sourceSizeChanged(); - } if (d->status != oldStatus) emit statusChanged(d->status); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h index aee8b28..3d23ba9 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativeimagebase_p_p.h @@ -69,6 +69,7 @@ public: QDeclarativeImageBasePrivate() : status(QDeclarativeImageBase::Null), progress(0.0), + explicitSourceSize(false), async(false) { QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; @@ -79,6 +80,7 @@ public: QUrl url; qreal progress; QSize sourcesize; + bool explicitSourceSize : 1; bool async : 1; }; diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 8f9b2ea..f1e026f 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -84,6 +84,7 @@ private slots: void tiling_QTBUG_6716(); void noLoading(); void paintedWidthHeight(); + void sourceSize_QTBUG_14303(); private: template @@ -377,7 +378,7 @@ void tst_qdeclarativeimage::noLoading() QTRY_COMPARE(statusSpy.count(), 0); // Loading remote file - ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/oldcolors.png"); + ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/heart200.png"); QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading); QTRY_VERIFY(obj->progress() == 0.0); QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); @@ -388,7 +389,7 @@ void tst_qdeclarativeimage::noLoading() // Loading remote file again - should not go through 'Loading' state. ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png")); - ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/oldcolors.png"); + ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/heart200.png"); QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); QTRY_VERIFY(obj->progress() == 1.0); QTRY_COMPARE(sourceSpy.count(), 4); @@ -436,6 +437,35 @@ void tst_qdeclarativeimage::paintedWidthHeight() } } +void tst_qdeclarativeimage::sourceSize_QTBUG_14303() +{ + QString componentStr = "import QtQuick 1.0\nImage { source: srcImage }"; + QDeclarativeContext *ctxt = engine.rootContext(); + ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png")); + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeImage *obj = qobject_cast(component.create()); + + QSignalSpy sourceSizeSpy(obj, SIGNAL(sourceSizeChanged())); + + QTRY_VERIFY(obj != 0); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); + + QTRY_COMPARE(obj->sourceSize().width(), 200); + QTRY_COMPARE(obj->sourceSize().height(), 200); + QTRY_COMPARE(sourceSizeSpy.count(), 0); + + ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/colors.png")); + QTRY_COMPARE(obj->sourceSize().width(), 120); + QTRY_COMPARE(obj->sourceSize().height(), 120); + QTRY_COMPARE(sourceSizeSpy.count(), 1); + + ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(SRCDIR "/data/heart200.png")); + QTRY_COMPARE(obj->sourceSize().width(), 200); + QTRY_COMPARE(obj->sourceSize().height(), 200); + QTRY_COMPARE(sourceSizeSpy.count(), 2); +} + /* Find an item with the specified objectName. If index is supplied then the item must also evaluate the {index} expression equal to index -- cgit v0.12 From 63e6b999144dfbd4ab230973d7e682361e8fe182 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 8 Oct 2010 15:06:17 +1000 Subject: Allow aliases to value type properties Task-number: QTBUG-14254 --- src/declarative/qml/qdeclarativecompiler.cpp | 27 +++++++++++-- src/declarative/qml/qdeclarativevmemetaobject.cpp | 25 +++++++++--- src/declarative/qml/qdeclarativevmemetaobject_p.h | 19 ++++++++++ .../qdeclarativelanguage/data/alias.10.qml | 8 ++++ .../qdeclarativelanguage/data/alias.11.qml | 8 ++++ .../data/invalidAlias.10.errors.txt | 1 + .../qdeclarativelanguage/data/invalidAlias.10.qml | 6 +++ .../data/invalidAlias.3.errors.txt | 2 +- .../qdeclarativelanguage/data/invalidAlias.3.qml | 2 +- .../data/invalidAlias.4.errors.txt | 2 +- .../data/invalidAlias.8.errors.txt | 1 + .../qdeclarativelanguage/data/invalidAlias.8.qml | 7 ++++ .../data/invalidAlias.9.errors.txt | 1 + .../qdeclarativelanguage/data/invalidAlias.9.qml | 6 +++ .../tst_qdeclarativelanguage.cpp | 44 ++++++++++++++++++++++ 15 files changed, 147 insertions(+), 12 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 7a29f24..74bc5bd 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -2565,8 +2565,8 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder, QStringList alias = astNodeToStringList(node); - if (alias.count() != 1 && alias.count() != 2) - COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as or .")); + if (alias.count() < 1 || alias.count() > 3) + COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. An alias reference must be specified as , . or ..")); if (!compileState.ids.contains(alias.at(0))) COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias reference. Unable to find id \"%1\"").arg(alias.at(0))); @@ -2578,11 +2578,14 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder, int propIdx = -1; int flags = 0; bool writable = false; - if (alias.count() == 2) { + if (alias.count() == 2 || alias.count() == 3) { propIdx = idObject->metaObject()->indexOfProperty(alias.at(1).toUtf8().constData()); - if (-1 == propIdx) + if (-1 == propIdx) { COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); + } else if (propIdx > 0xFFFF) { + COMPILE_EXCEPTION(prop.defaultValue, tr("Alias property exceeds alias bounds")); + } QMetaProperty aliasProperty = idObject->metaObject()->property(propIdx); if (!aliasProperty.isScriptable()) @@ -2590,6 +2593,22 @@ bool QDeclarativeCompiler::compileAlias(QMetaObjectBuilder &builder, writable = aliasProperty.isWritable(); + if (alias.count() == 3) { + QDeclarativeValueType *valueType = enginePrivate->valueTypes[aliasProperty.type()]; + if (!valueType) + COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); + + propIdx |= ((unsigned int)aliasProperty.type()) << 24; + + int valueTypeIndex = valueType->metaObject()->indexOfProperty(alias.at(2).toUtf8().constData()); + if (valueTypeIndex == -1) + COMPILE_EXCEPTION(prop.defaultValue, tr("Invalid alias location")); + Q_ASSERT(valueTypeIndex <= 0xFF); + + aliasProperty = valueType->metaObject()->property(valueTypeIndex); + propIdx |= (valueTypeIndex << 16); + } + if (aliasProperty.isEnumType()) typeName = "int"; // Avoid introducing a dependency on the aliased metaobject else diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp index 37f08fc..e28062b 100644 --- a/src/declarative/qml/qdeclarativevmemetaobject.cpp +++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp @@ -459,7 +459,7 @@ int QDeclarativeVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a) id -= propOffset; if (id < metaData->propertyCount) { - int t = (metaData->propertyData() + id)->propertyType; + int t = (metaData->propertyData() + id)->propertyType; bool needActivate = false; if (t == -1) { @@ -586,11 +586,26 @@ int QDeclarativeVMEMetaObject::metaCall(QMetaObject::Call c, int _id, void **a) connectAlias(id); - if (d->propertyIdx == -1) { + if (d->isObjectAlias()) { *reinterpret_cast(a[0]) = target; return -1; + } else if (d->isValueTypeAlias()) { + // Value type property + QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(ctxt->engine); + + QDeclarativeValueType *valueType = ep->valueTypes[d->valueType()]; + Q_ASSERT(valueType); + + valueType->read(target, d->propertyIndex()); + int rv = QMetaObject::metacall(valueType, c, d->valueTypeIndex(), a); + + if (c == QMetaObject::WriteProperty) + valueType->write(target, d->propertyIndex(), 0x00); + + return rv; + } else { - return QMetaObject::metacall(target, c, d->propertyIdx, a); + return QMetaObject::metacall(target, c, d->propertyIndex(), a); } } @@ -823,8 +838,8 @@ void QDeclarativeVMEMetaObject::connectAlias(int aliasId) int sigIdx = methodOffset + aliasId + metaData->propertyCount; QMetaObject::connect(context, d->contextIdx + ctxtPriv->notifyIndex, object, sigIdx); - if (d->propertyIdx != -1) { - QMetaProperty prop = target->metaObject()->property(d->propertyIdx); + if (!d->isObjectAlias()) { + QMetaProperty prop = target->metaObject()->property(d->propertyIndex()); if (prop.hasNotifySignal()) QDeclarativePropertyPrivate::connect(target, prop.notifySignalIndex(), object, sigIdx); } diff --git a/src/declarative/qml/qdeclarativevmemetaobject_p.h b/src/declarative/qml/qdeclarativevmemetaobject_p.h index 4ccaa73..5134763 100644 --- a/src/declarative/qml/qdeclarativevmemetaobject_p.h +++ b/src/declarative/qml/qdeclarativevmemetaobject_p.h @@ -84,6 +84,25 @@ struct QDeclarativeVMEMetaData int contextIdx; int propertyIdx; int flags; + + bool isObjectAlias() const { + return propertyIdx == -1; + } + bool isPropertyAlias() const { + return !isObjectAlias() && !(propertyIdx & 0xFF000000); + } + bool isValueTypeAlias() const { + return !isObjectAlias() && (propertyIdx & 0xFF000000); + } + int propertyIndex() const { + return propertyIdx & 0x0000FFFF; + } + int valueTypeIndex() const { + return (propertyIdx & 0x00FF0000) >> 16; + } + int valueType() const { + return ((unsigned int)propertyIdx) >> 24; + } }; struct PropertyData { diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml new file mode 100644 index 0000000..bf6352e --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.10.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias valueAlias: root.rectProperty + + rectProperty: "10,11,9x8" +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml b/tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml new file mode 100644 index 0000000..fbd50d9 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/alias.11.qml @@ -0,0 +1,8 @@ +import Test 1.0 + +MyTypeObject { + id: root + + property alias aliasProperty: root.rectProperty.x + rectProperty: "19,13,100x120" +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt new file mode 100644 index 0000000..93652a7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias location diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml new file mode 100644 index 0000000..3ff7b16 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.10.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: root.rectProperty.blah +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt index 7260be4..fbf1b58 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.errors.txt @@ -1 +1 @@ -5:23:Invalid alias reference. An alias reference must be specified as or . +5:23:Invalid alias reference. An alias reference must be specified as , . or .. diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml index cc71753..a363373 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.3.qml @@ -2,5 +2,5 @@ import Test 1.0 MyTypeObject { id: root - property alias a: root.rectProperty.x + property alias a: root.rectProperty.x.y } diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt index 7260be4..fbf1b58 100644 --- a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.4.errors.txt @@ -1 +1 @@ -5:23:Invalid alias reference. An alias reference must be specified as or . +5:23:Invalid alias reference. An alias reference must be specified as , . or .. diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt new file mode 100644 index 0000000..93652a7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias location diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml new file mode 100644 index 0000000..4faa52d --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.8.qml @@ -0,0 +1,7 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: root.imaginary.x +} + diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt new file mode 100644 index 0000000..93652a7 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.errors.txt @@ -0,0 +1 @@ +5:23:Invalid alias location diff --git a/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml new file mode 100644 index 0000000..f183912 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/invalidAlias.9.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + id: root + property alias a: root.floatProperty.x +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 2aac27e..6a45957 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -349,6 +349,9 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("invalidAlias.5") << "invalidAlias.5.qml" << "invalidAlias.5.errors.txt" << false; QTest::newRow("invalidAlias.6") << "invalidAlias.6.qml" << "invalidAlias.6.errors.txt" << false; QTest::newRow("invalidAlias.7") << "invalidAlias.7.qml" << "invalidAlias.7.errors.txt" << false; + QTest::newRow("invalidAlias.8") << "invalidAlias.8.qml" << "invalidAlias.8.errors.txt" << false; + QTest::newRow("invalidAlias.9") << "invalidAlias.9.qml" << "invalidAlias.9.errors.txt" << false; + QTest::newRow("invalidAlias.10") << "invalidAlias.10.qml" << "invalidAlias.10.errors.txt" << false; QTest::newRow("invalidAttachedProperty.1") << "invalidAttachedProperty.1.qml" << "invalidAttachedProperty.1.errors.txt" << false; QTest::newRow("invalidAttachedProperty.2") << "invalidAttachedProperty.2.qml" << "invalidAttachedProperty.2.errors.txt" << false; @@ -1064,6 +1067,47 @@ void tst_qdeclarativelanguage::aliasProperties() delete object; } + + // Valuetype alias + // Simple "int" alias + { + QDeclarativeComponent component(&engine, TEST_FILE("alias.10.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + // Read through alias + QCOMPARE(object->property("valueAlias").toRect(), QRect(10, 11, 9, 8)); + object->setProperty("rectProperty", QVariant(QRect(33, 12, 99, 100))); + QCOMPARE(object->property("valueAlias").toRect(), QRect(33, 12, 99, 100)); + + // Write throught alias + object->setProperty("valueAlias", QVariant(QRect(3, 3, 4, 9))); + QCOMPARE(object->property("valueAlias").toRect(), QRect(3, 3, 4, 9)); + QCOMPARE(object->property("rectProperty").toRect(), QRect(3, 3, 4, 9)); + + delete object; + } + + // Valuetype sub-alias + { + QDeclarativeComponent component(&engine, TEST_FILE("alias.11.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + // Read through alias + QCOMPARE(object->property("aliasProperty").toInt(), 19); + object->setProperty("rectProperty", QVariant(QRect(33, 8, 102, 111))); + QCOMPARE(object->property("aliasProperty").toInt(), 33); + + // Write throught alias + object->setProperty("aliasProperty", QVariant(4)); + QCOMPARE(object->property("aliasProperty").toInt(), 4); + QCOMPARE(object->property("rectProperty").toRect(), QRect(4, 8, 102, 111)); + + delete object; + } } // QTBUG-13374 Test that alias properties and signals can coexist -- cgit v0.12 From 11536f150887266b6a6f5cf00b22f9d1fcc1aaeb Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 8 Oct 2010 16:12:31 +1000 Subject: Ensure GridView header is visible at the top of the view. The view was scrolled to the top of the first item, rather than the top of the header. Task-number: QTBUG-13906 Reviewed-by: Michael Brasser --- .../graphicsitems/qdeclarativegridview.cpp | 9 +++++- .../qdeclarativegridview/data/header.qml | 32 ++++++++++++++++++++ .../tst_qdeclarativegridview.cpp | 35 ++++++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativegridview/data/header.qml diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index 8216ab7..6ee6b0d 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -218,7 +218,14 @@ public: return visibleItems.last()->rowPos() + rows * rowSize(); } } else { - return (modelIndex / columns) * rowSize(); + qreal pos = (modelIndex / columns) * rowSize(); + if (header) { + qreal headerSize = flow == QDeclarativeGridView::LeftToRight + ? header->item->height() + : header->item->width(); + pos += headerSize; + } + return pos; } return 0; } diff --git a/tests/auto/declarative/qdeclarativegridview/data/header.qml b/tests/auto/declarative/qdeclarativegridview/data/header.qml new file mode 100644 index 0000000..99baacd --- /dev/null +++ b/tests/auto/declarative/qdeclarativegridview/data/header.qml @@ -0,0 +1,32 @@ +import QtQuick 1.0 + +Rectangle { + width: 240 + height: 320 + color: "#ffffff" + Component { + id: myDelegate + Rectangle { + id: wrapper + objectName: "wrapper" + width: 80 + height: 60 + border.color: "blue" + Text { + text: index + } + color: GridView.isCurrentItem ? "lightsteelblue" : "white" + } + } + GridView { + id: grid + objectName: "grid" + width: 240 + height: 320 + cellWidth: 80 + cellHeight: 60 + model: testModel + delegate: myDelegate + header: Text { objectName: "header"; text: "Header"; height: 30 } + } +} diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index 975cf8f..f7acd87 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -82,6 +82,7 @@ private slots: void QTBUG_8456(); void manualHighlight(); void footer(); + void header(); private: QDeclarativeView *createView(); @@ -1214,6 +1215,40 @@ void tst_QDeclarativeGridView::footer() QTRY_COMPARE(footer->y(), 0.0); } +void tst_QDeclarativeGridView::header() +{ + QDeclarativeView *canvas = createView(); + + TestModel model; + for (int i = 0; i < 7; i++) + model.addItem("Item" + QString::number(i), ""); + + QDeclarativeContext *ctxt = canvas->rootContext(); + ctxt->setContextProperty("testModel", &model); + + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/header.qml")); + qApp->processEvents(); + + QDeclarativeGridView *gridview = findItem(canvas->rootObject(), "grid"); + QTRY_VERIFY(gridview != 0); + + QDeclarativeItem *contentItem = gridview->contentItem(); + QTRY_VERIFY(contentItem != 0); + + QDeclarativeText *header = findItem(contentItem, "header"); + QVERIFY(header); + + QCOMPARE(header->y(), 0.0); + QCOMPARE(gridview->contentY(), 0.0); + + QDeclarativeItem *item = findItem(contentItem, "wrapper", 0); + QVERIFY(item); + QCOMPARE(item->y(), 30.0); + + model.clear(); + QTRY_COMPARE(header->y(), 0.0); +} + QDeclarativeView *tst_QDeclarativeGridView::createView() { -- cgit v0.12 From fcf4b598a169b336344393958f67320f5f9652ce Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 28 Sep 2010 11:01:20 +0100 Subject: Progressive download in Phonon MMF backend: added download managers This patch adds a Download class which uses the RHttpDownloadMgr API to download a media clip over HTTP. Task-number: QTBUG-10769 Reviewed-by: Derick Hawcroft --- src/3rdparty/phonon/mmf/download.cpp | 194 +++++++++++++++++++++++++++++++++++ src/3rdparty/phonon/mmf/download.h | 111 ++++++++++++++++++++ src/plugins/phonon/mmf/mmf.pro | 3 + 3 files changed, 308 insertions(+) create mode 100644 src/3rdparty/phonon/mmf/download.cpp create mode 100644 src/3rdparty/phonon/mmf/download.h diff --git a/src/3rdparty/phonon/mmf/download.cpp b/src/3rdparty/phonon/mmf/download.cpp new file mode 100644 index 0000000..7b80e4a --- /dev/null +++ b/src/3rdparty/phonon/mmf/download.cpp @@ -0,0 +1,194 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#include "download.h" +#include "utils.h" +#include +#include + +QT_BEGIN_NAMESPACE + +using namespace Phonon; +using namespace Phonon::MMF; + +static const TBool InheritDownloads = EFalse; + +DownloadPrivate::DownloadPrivate(Download *parent) + : QObject(parent) + , m_parent(parent) + , m_download(0) + , m_length(0) +{ + +} + +DownloadPrivate::~DownloadPrivate() +{ + m_downloadManager.Disconnect(); + m_downloadManager.Close(); +} + +bool DownloadPrivate::start() +{ + TRACE_CONTEXT(DownloadPrivate::start, EVideoApi); + Q_ASSERT(!m_download); + // Connect to download manager + RProcess process; + const TUid uid3 = process.SecureId(); + TRAPD(err, m_downloadManager.ConnectL(uid3, *this, InheritDownloads)); + TRACE("connect err %d", err); + if (KErrNone == err) { + // Start download + QHBufC url(m_parent->sourceUrl().toString()); + TPtr8 url8 = url->Des().Collapse(); + TRAP(err, m_download = &m_downloadManager.CreateDownloadL(url8)); + TRACE("start err %d", err); + if (KErrNone == err) + m_download->Start(); + } + return (KErrNone == err); +} + +void DownloadPrivate::resume() +{ + +} + +void DownloadPrivate::HandleDMgrEventL(RHttpDownload &aDownload, THttpDownloadEvent aEvent) +{ + TRACE_CONTEXT(DownloadPrivate::HandleDMgrEventL, EVideoApi); + Q_ASSERT(&aDownload == m_download); + switch (aEvent.iDownloadState) { + case EHttpDlPaused: + if (EHttpContentTypeReceived == aEvent.iProgressState) { + TRACE_0("paused, content type received"); + m_download->Start(); + } + break; + case EHttpDlInprogress: + switch (aEvent.iProgressState) { + case EHttpProgResponseHeaderReceived: + { + TFileName fileName; + m_download->GetStringAttribute(EDlAttrDestFilename, fileName); + TRACE("in progress, response header received, filename %S", &fileName); + const QString fileNameQt = QDir::fromNativeSeparators(qt_TDesC2QString(fileName)); + m_parent->downloadStarted(fileNameQt); + } + break; + case EHttpProgResponseBodyReceived: + { + TInt32 length = 0; + m_download->GetIntAttribute(EDlAttrDownloadedSize, length); + if (length != m_length) { + TRACE("in progress, length %d", length); + m_length = length; + emit lengthChanged(m_length); + } + } + break; + } + break; + case EHttpDlCompleted: + TRACE_0("complete"); + m_parent->complete(); + break; + case EHttpDlFailed: + TRACE_0("failed"); + m_parent->error(); + break; + } +} + +Download::Download(const QUrl &url, QObject *parent) + : QObject(parent) + , m_private(new DownloadPrivate(this)) + , m_sourceUrl(url) + , m_state(Idle) +{ + qRegisterMetaType(); + connect(m_private, SIGNAL(lengthChanged(qint64)), this, SIGNAL(lengthChanged(qint64))); +} + +Download::~Download() +{ + +} + +const QUrl &Download::sourceUrl() const +{ + return m_sourceUrl; +} + +const QString &Download::targetFileName() const +{ + return m_targetFileName; +} + +void Download::start() +{ + TRACE_CONTEXT(Download::start, EVideoApi); + TRACE_ENTRY_0(); + Q_ASSERT(Idle == m_state); + const bool ok = m_private->start(); + setState(ok ? Initializing : Error); + TRACE_EXIT_0(); +} + +void Download::resume() +{ + TRACE_CONTEXT(Download::resume, EVideoApi); + TRACE_ENTRY_0(); + m_private->resume(); + TRACE_EXIT_0(); +} + +void Download::setState(State state) +{ + TRACE_CONTEXT(Download::setState, EVideoApi); + TRACE("oldState %d newState %d", m_state, state); + const State oldState = m_state; + m_state = state; + if (oldState != m_state) + emit stateChanged(m_state); +} + +void Download::error() +{ + TRACE_CONTEXT(Download::error, EVideoApi); + TRACE_0(""); + setState(Error); +} + +void Download::downloadStarted(const QString &targetFileName) +{ + TRACE_CONTEXT(Download::downloadStarted, EVideoApi); + TRACE_0("downloadStarted"); + m_targetFileName = targetFileName; + setState(Downloading); +} + +void Download::complete() +{ + TRACE_CONTEXT(Download::complete, EVideoApi); + TRACE_0(""); + setState(Complete); +} + +QT_END_NAMESPACE + diff --git a/src/3rdparty/phonon/mmf/download.h b/src/3rdparty/phonon/mmf/download.h new file mode 100644 index 0000000..b57348b --- /dev/null +++ b/src/3rdparty/phonon/mmf/download.h @@ -0,0 +1,111 @@ +/* This file is part of the KDE project. + +Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). + +This library is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 or 3 of the License. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this library. If not, see . + +*/ + +#ifndef PHONON_MMF_DOWNLOAD_H +#define PHONON_MMF_DOWNLOAD_H + +#include +#include +#include +#include + +QT_FORWARD_DECLARE_CLASS(QByteArray) +QT_FORWARD_DECLARE_CLASS(QFile) + +QT_BEGIN_NAMESPACE + +namespace Phonon +{ +namespace MMF +{ + +class Download; + +class DownloadPrivate : public QObject + , public MHttpDownloadMgrObserver +{ + Q_OBJECT +public: + DownloadPrivate(Download *parent); + ~DownloadPrivate(); + bool start(); + void resume(); +signals: + void error(); + void targetFileNameChanged(); + void lengthChanged(qint64 length); + void complete(); +private: + // MHttpDownloadMgrObserver + void HandleDMgrEventL(RHttpDownload &aDownload, THttpDownloadEvent aEvent); +private: + Download *m_parent; + RHttpDownloadMgr m_downloadManager; + RHttpDownload *m_download; + qint64 m_length; +}; + +class Download : public QObject +{ + Q_OBJECT + friend class DownloadPrivate; +public: + Download(const QUrl &url, QObject *parent = 0); + ~Download(); + const QUrl &sourceUrl() const; + const QString &targetFileName() const; + void start(); + + // Only has effect when QT_PHONON_MMF_DOWNLOAD_DUMMY is defined + void resume(); + + enum State { + Idle, + Initializing, + Downloading, + Complete, + Error + }; + +signals: + void lengthChanged(qint64 length); + void stateChanged(Download::State state); + +private: + void setState(State state); + + // Called by DownloadPrivate + void error(); + void downloadStarted(const QString &targetFileName); + void complete(); + +private: + DownloadPrivate *m_private; + QUrl m_sourceUrl; + QString m_targetFileName; + State m_state; +}; + +} +} + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(Phonon::MMF::Download::State) + +#endif diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 7a6fdf8..902354f 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -36,6 +36,7 @@ symbian { $$PHONON_MMF_DIR/backend.h \ $$PHONON_MMF_DIR/bassboost.h \ $$PHONON_MMF_DIR/defs.h \ + $$PHONON_MMF_DIR/download.h \ $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/effectfactory.h \ $$PHONON_MMF_DIR/effectparameter.h \ @@ -61,6 +62,7 @@ symbian { $$PHONON_MMF_DIR/abstractvideoplayer.cpp \ $$PHONON_MMF_DIR/backend.cpp \ $$PHONON_MMF_DIR/bassboost.cpp \ + $$PHONON_MMF_DIR/download.cpp \ $$PHONON_MMF_DIR/dummyplayer.cpp \ $$PHONON_MMF_DIR/effectfactory.cpp \ $$PHONON_MMF_DIR/effectparameter.cpp \ @@ -111,6 +113,7 @@ symbian { LIBS += -lapgrfx -lapmime # For recognizer LIBS += -lmmfcontrollerframework # For CMMFMetaDataEntry LIBS += -lmediaclientaudiostream # For CMdaAudioOutputStream + LIBS += -ldownloadmgr # These are for effects. LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect -- cgit v0.12 From bb994a5e2a260911ed3c5603d3414c63a28faab4 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Tue, 28 Sep 2010 11:05:41 +0100 Subject: Progressive download in Phonon MMF backend: integrated with player This commit integrates the Download class with the media playback classes in the backend, to implement Progressive Download. Note that this PDL implementation has one drawback: when video playback is paused due to shortage of data (i.e. due to the download being temporarily stalled), the display goes black. This is because, when the end of the currently-downloaded data is reached, the playback session is closed. When more data becomes available, the clip is re-opened, a seek is done to reach the previous playback position, and playback is re-started. Closing the playback session closes the video stack's connection to the display, thereby causing the video widget to go black while more data is buffered. This is a consequence of the level in the native video stack at which the Phonon integration is done: managing a network stall without requiring the playback session to be closed would require integration below the MMF client API, specifically at the MMF controller level. Task-number: QTBUG-10769 Reviewed-by: Derick Hawcroft --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 148 +++++++++++++++++++++--- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 17 +++ src/3rdparty/phonon/mmf/abstractvideoplayer.cpp | 24 +++- src/3rdparty/phonon/mmf/abstractvideoplayer.h | 5 +- src/3rdparty/phonon/mmf/audioplayer.cpp | 18 ++- src/3rdparty/phonon/mmf/audioplayer.h | 5 +- src/3rdparty/phonon/mmf/mediaobject.cpp | 36 +++--- src/3rdparty/phonon/mmf/mediaobject.h | 1 + 8 files changed, 211 insertions(+), 43 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 3702560..a728423 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -51,10 +51,13 @@ MMF::AbstractMediaPlayer::AbstractMediaPlayer , m_parent(parent) , m_pending(NothingPending) , m_positionTimer(new QTimer(this)) + , m_position(0) , m_bufferStatusTimer(new QTimer(this)) , m_mmfMaxVolume(NullMaxVolume) , m_prefinishMarkSent(false) , m_aboutToFinishSent(false) + , m_download(0) + , m_downloadStalled(false) { connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick())); connect(m_bufferStatusTimer.data(), SIGNAL(timeout()), this, SLOT(bufferStatusTick())); @@ -183,6 +186,7 @@ void MMF::AbstractMediaPlayer::seek(qint64 ms) } doSeek(ms); + m_position = ms; resetMarksIfRewound(); if(wasPlaying && state() != ErrorState) { @@ -207,6 +211,11 @@ bool MMF::AbstractMediaPlayer::isSeekable() const return true; } +qint64 MMF::AbstractMediaPlayer::currentTime() const +{ + return m_position; +} + void MMF::AbstractMediaPlayer::doSetTickInterval(qint32 interval) { TRACE_CONTEXT(AbstractMediaPlayer::doSetTickInterval, EAudioApi); @@ -247,6 +256,14 @@ void MMF::AbstractMediaPlayer::open() symbianErr = openFile(*file); if (KErrNone != symbianErr) errorMessage = tr("Error opening file"); + } else if (url.scheme() == QLatin1String("http")) { + Q_ASSERT(!m_download); + m_download = new Download(url, this); + connect(m_download, SIGNAL(lengthChanged(qint64)), + this, SLOT(downloadLengthChanged(qint64))); + connect(m_download, SIGNAL(stateChanged(Download::State)), + this, SLOT(downloadStateChanged(Download::State))); + m_download->start(); } else { symbianErr = openUrl(url.toString()); if (KErrNone != symbianErr) @@ -288,6 +305,14 @@ void MMF::AbstractMediaPlayer::open() TRACE_EXIT_0(); } +void MMF::AbstractMediaPlayer::close() +{ + doClose(); + delete m_download; + m_download = 0; + m_position = 0; +} + void MMF::AbstractMediaPlayer::volumeChanged(qreal volume) { TRACE_CONTEXT(AbstractMediaPlayer::volumeChanged, EAudioInternal); @@ -374,7 +399,8 @@ void MMF::AbstractMediaPlayer::bufferingComplete() { stopBufferStatusTimer(); emit MMF::AbstractPlayer::bufferStatus(100); - changeState(m_stateBeforeBuffering); + if (!progressiveDownloadStalled()) + changeState(m_stateBeforeBuffering); } void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) @@ -385,13 +411,28 @@ void MMF::AbstractMediaPlayer::maxVolumeChanged(int mmfMaxVolume) void MMF::AbstractMediaPlayer::loadingComplete(int error) { - Q_ASSERT(Phonon::LoadingState == state()); - - if (KErrNone == error) { - updateMetaData(); - changeState(StoppedState); + TRACE_CONTEXT(AbstractMediaPlayer::loadingComplete, EAudioApi); + TRACE_ENTRY("state %d error %d", state(), error); + if (progressiveDownloadStalled()) { + Q_ASSERT(Phonon::BufferingState == state()); + if (KErrNone == error) { + bufferingComplete(); + doSeek(m_position); + startPlayback(); + m_downloadStalled = false; + } } else { - setError(tr("Loading clip failed"), error); + Q_ASSERT(Phonon::LoadingState == state()); + if (KErrNone == error) { + updateMetaData(); + changeState(StoppedState); + } else { + if (isProgressiveDownload() && KErrCorrupt == error) { + setProgressiveDownloadStalled(); + } else { + setError(tr("Loading clip failed"), error); + } + } } } @@ -415,8 +456,12 @@ void MMF::AbstractMediaPlayer::playbackComplete(int error) QMetaObject::invokeMethod(m_parent, "switchToNextSource", Qt::QueuedConnection); } else { - setError(tr("Playback complete"), error); - emit finished(); + if (isProgressiveDownload() && KErrCorrupt == error) { + setProgressiveDownloadStalled(); + } else { + setError(tr("Playback complete"), error); + emit finished(); + } } } @@ -425,15 +470,28 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds return in.Int64() / 1000; } +bool MMF::AbstractMediaPlayer::isProgressiveDownload() const +{ + return (0 != m_download); +} + +bool MMF::AbstractMediaPlayer::progressiveDownloadStalled() const +{ + return m_downloadStalled; +} + //----------------------------------------------------------------------------- // Slots //----------------------------------------------------------------------------- void MMF::AbstractMediaPlayer::positionTick() { - const qint64 current = currentTime(); - emitMarksIfReached(current); - emit MMF::AbstractPlayer::tick(current); + const qint64 pos = getCurrentTime(); + if (pos > m_position) { + m_position = pos; + emitMarksIfReached(m_position); + emit MMF::AbstractPlayer::tick(m_position); + } } void MMF::AbstractMediaPlayer::emitMarksIfReached(qint64 current) @@ -458,7 +516,7 @@ void MMF::AbstractMediaPlayer::emitMarksIfReached(qint64 current) void MMF::AbstractMediaPlayer::resetMarksIfRewound() { - const qint64 current = currentTime(); + const qint64 current = getCurrentTime(); const qint64 total = totalTime(); const qint64 remaining = total - current; @@ -487,9 +545,71 @@ void MMF::AbstractMediaPlayer::startPlayback() changeState(PlayingState); } +void MMF::AbstractMediaPlayer::setProgressiveDownloadStalled() +{ + TRACE_CONTEXT(AbstractMediaPlayer::setProgressiveDownloadStalled, EAudioApi); + TRACE_ENTRY("state %d", state()); + Q_ASSERT(isProgressiveDownload()); + m_downloadStalled = true; + doClose(); + bufferingStarted(); + // Video player loses window handle when closed - need to reapply it here + videoOutputChanged(); +#ifdef QT_PHONON_MMF_DOWNLOAD_DUMMY + m_download->resume(); +#endif +} + void MMF::AbstractMediaPlayer::bufferStatusTick() { - emit MMF::AbstractPlayer::bufferStatus(bufferStatus()); + // During progressive download, there is no way to detect the buffering status. + // Phonon does not support a "buffering; amount unknown" signal, therefore we + // return a buffering status of zero. + const int status = progressiveDownloadStalled() ? 0 : bufferStatus(); + emit MMF::AbstractPlayer::bufferStatus(status); +} + +void MMF::AbstractMediaPlayer::downloadLengthChanged(qint64 length) +{ + TRACE_CONTEXT(AbstractMediaPlayer::downloadLengthChanged, EAudioApi); + TRACE_ENTRY("length %Ld", length); + Q_UNUSED(length) + if (m_downloadStalled) { + bufferingComplete(); + int err = m_parent->openFileHandle(m_download->targetFileName()); + if (KErrNone == err) + err = openFile(*m_parent->file()); + if (KErrNone != err) + setError(tr("Error opening file")); + } +} + +void MMF::AbstractMediaPlayer::downloadStateChanged(Download::State state) +{ + TRACE_CONTEXT(AbstractMediaPlayer::downloadStateChanged, EAudioApi); + TRACE_ENTRY("state %d", state); + switch (state) { + case Download::Idle: + case Download::Initializing: + break; + case Download::Downloading: + { + int err = m_parent->openFileHandle(m_download->targetFileName()); + if (KErrNone == err) + err = openFile(*m_parent->file()); + else if (KErrCorrupt == err) + // Insufficient data downloaded - enter Buffering state + setProgressiveDownloadStalled(); + if (KErrNone != err) + setError(tr("Error opening file")); + } + break; + case Download::Complete: + break; + case Download::Error: + setError(tr("Download error")); + break; + } } Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) const diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index e795ecb..99fc101 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -23,6 +23,7 @@ along with this library. If not, see . #include #include #include "abstractplayer.h" +#include "download.h" class RFile; @@ -48,6 +49,7 @@ protected: public: virtual void open(); + virtual void close(); // MediaObjectInterface virtual void play(); @@ -55,6 +57,7 @@ public: virtual void stop(); virtual void seek(qint64 milliseconds); virtual bool isSeekable() const; + virtual qint64 currentTime() const; virtual void volumeChanged(qreal volume); protected: @@ -68,12 +71,15 @@ protected: virtual void doStop() = 0; virtual void doSeek(qint64 pos) = 0; virtual int setDeviceVolume(int mmfVolume) = 0; + virtual int openFile(const QString &fileName) = 0; virtual int openFile(RFile& file) = 0; virtual int openUrl(const QString& url) = 0; virtual int openDescriptor(const TDesC8 &des) = 0; virtual int bufferStatus() const = 0; + virtual void doClose() = 0; void updateMetaData(); + virtual qint64 getCurrentTime() const = 0; virtual int numberOfMetaDataEntries() const = 0; virtual QPair metaDataEntry(int index) const = 0; @@ -86,6 +92,9 @@ protected: static qint64 toMilliSeconds(const TTimeIntervalMicroSeconds &); + bool isProgressiveDownload() const; + bool progressiveDownloadStalled() const; + private: void startPositionTimer(); void stopPositionTimer(); @@ -96,6 +105,7 @@ private: void emitMarksIfReached(qint64 position); void resetMarksIfRewound(); void startPlayback(); + void setProgressiveDownloadStalled(); enum Pending { NothingPending, @@ -108,6 +118,8 @@ private: private Q_SLOTS: void positionTick(); void bufferStatusTick(); + void downloadLengthChanged(qint64); + void downloadStateChanged(Download::State); private: MediaObject *const m_parent; @@ -115,6 +127,7 @@ private: Pending m_pending; QScopedPointer m_positionTimer; + qint64 m_position; QScopedPointer m_bufferStatusTimer; PrivateState m_stateBeforeBuffering; @@ -127,6 +140,10 @@ private: // Used for playback of resource files TPtrC8 m_buffer; + // Used for progressive download + Download *m_download; + bool m_downloadStalled; + QMultiMap m_metaData; }; diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp index fb20bea..1ab5bae 100644 --- a/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.cpp @@ -16,6 +16,7 @@ along with this library. If not, see . */ +#include #include #include #include @@ -132,6 +133,13 @@ int MMF::AbstractVideoPlayer::setDeviceVolume(int mmfVolume) return err; } +int MMF::AbstractVideoPlayer::openFile(const QString &fileName) +{ + const QHBufC nativeFileName(QDir::toNativeSeparators(fileName)); + TRAPD(err, m_player->OpenFileL(*nativeFileName)); + return err; +} + int MMF::AbstractVideoPlayer::openFile(RFile &file) { TRAPD(err, m_player->OpenFileL(file)); @@ -157,7 +165,7 @@ int MMF::AbstractVideoPlayer::bufferStatus() const return result; } -void MMF::AbstractVideoPlayer::close() +void MMF::AbstractVideoPlayer::doClose() { m_player->Close(); } @@ -167,9 +175,9 @@ bool MMF::AbstractVideoPlayer::hasVideo() const return true; } -qint64 MMF::AbstractVideoPlayer::currentTime() const +qint64 MMF::AbstractVideoPlayer::getCurrentTime() const { - TRACE_CONTEXT(AbstractVideoPlayer::currentTime, EVideoApi); + TRACE_CONTEXT(AbstractVideoPlayer::getCurrentTime, EVideoApi); TTimeIntervalMicroSeconds us; TRAPD(err, us = m_player->PositionL()) @@ -246,7 +254,9 @@ void MMF::AbstractVideoPlayer::MvpuoOpenComplete(TInt aError) TRACE_CONTEXT(AbstractVideoPlayer::MvpuoOpenComplete, EVideoApi); TRACE_ENTRY("state %d error %d", state(), aError); - __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); + __ASSERT_ALWAYS(LoadingState == state() || + progressiveDownloadStalled() && BufferingState == state(), + Utils::panic(InvalidStatePanic)); if (KErrNone == aError) m_player->Prepare(); @@ -261,7 +271,9 @@ void MMF::AbstractVideoPlayer::MvpuoPrepareComplete(TInt aError) TRACE_CONTEXT(AbstractVideoPlayer::MvpuoPrepareComplete, EVideoApi); TRACE_ENTRY("state %d error %d", state(), aError); - __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); + __ASSERT_ALWAYS(LoadingState == state() || + progressiveDownloadStalled() && BufferingState == state(), + Utils::panic(InvalidStatePanic)); TRAPD(err, getVideoClipParametersL(aError)); @@ -470,7 +482,7 @@ void MMF::AbstractVideoPlayer::updateScaleFactors(const QSize &windowSize, bool void MMF::AbstractVideoPlayer::parametersChanged(VideoParameters parameters) { - if (state() == LoadingState) + if (state() == LoadingState || progressiveDownloadStalled() && BufferingState == state()) m_pendingChanges |= parameters; else handleParametersChanged(parameters); diff --git a/src/3rdparty/phonon/mmf/abstractvideoplayer.h b/src/3rdparty/phonon/mmf/abstractvideoplayer.h index 3ff3c75..3bc5c7c 100644 --- a/src/3rdparty/phonon/mmf/abstractvideoplayer.h +++ b/src/3rdparty/phonon/mmf/abstractvideoplayer.h @@ -64,21 +64,22 @@ public: virtual void doStop(); virtual void doSeek(qint64 milliseconds); virtual int setDeviceVolume(int mmfVolume); + virtual int openFile(const QString &fileName); virtual int openFile(RFile &file); virtual int openUrl(const QString &url); virtual int openDescriptor(const TDesC8 &des); virtual int bufferStatus() const; - virtual void close(); + virtual void doClose(); // MediaObjectInterface virtual bool hasVideo() const; - virtual qint64 currentTime() const; virtual qint64 totalTime() const; // AbstractPlayer virtual void videoOutputChanged(); // AbstractMediaPlayer + virtual qint64 getCurrentTime() const; virtual int numberOfMetaDataEntries() const; virtual QPair metaDataEntry(int index) const; diff --git a/src/3rdparty/phonon/mmf/audioplayer.cpp b/src/3rdparty/phonon/mmf/audioplayer.cpp index 7c8b9bd..dc5c800 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.cpp +++ b/src/3rdparty/phonon/mmf/audioplayer.cpp @@ -16,6 +16,7 @@ along with this library. If not, see . */ +#include #include #include "audioplayer.h" @@ -109,6 +110,13 @@ int MMF::AudioPlayer::setDeviceVolume(int mmfVolume) #endif } +int MMF::AudioPlayer::openFile(const QString &fileName) +{ + const QHBufC nativeFileName(QDir::toNativeSeparators(fileName)); + TRAPD(err, m_player->OpenFileL(*nativeFileName)); + return err; +} + int MMF::AudioPlayer::openFile(RFile& file) { TRAPD(err, m_player->OpenFileL(file)); @@ -150,7 +158,7 @@ int MMF::AudioPlayer::bufferStatus() const return result; } -void MMF::AudioPlayer::close() +void MMF::AudioPlayer::doClose() { m_player->Close(); } @@ -160,9 +168,9 @@ bool MMF::AudioPlayer::hasVideo() const return false; } -qint64 MMF::AudioPlayer::currentTime() const +qint64 MMF::AudioPlayer::getCurrentTime() const { - TRACE_CONTEXT(AudioPlayer::currentTime, EAudioApi); + TRACE_CONTEXT(AudioPlayer::getCurrentTime, EAudioApi); TTimeIntervalMicroSeconds us; const TInt err = m_player->GetPosition(us); @@ -203,7 +211,9 @@ void MMF::AudioPlayer::MapcInitComplete(TInt aError, TRACE_CONTEXT(AudioPlayer::MapcInitComplete, EAudioInternal); TRACE_ENTRY("state %d error %d", state(), aError); - __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); + __ASSERT_ALWAYS(LoadingState == state() || + progressiveDownloadStalled() && BufferingState == state(), + Utils::panic(InvalidStatePanic)); if (KErrNone == aError) { maxVolumeChanged(m_player->MaxVolume()); diff --git a/src/3rdparty/phonon/mmf/audioplayer.h b/src/3rdparty/phonon/mmf/audioplayer.h index e43cadd..cf4f6d5 100644 --- a/src/3rdparty/phonon/mmf/audioplayer.h +++ b/src/3rdparty/phonon/mmf/audioplayer.h @@ -65,18 +65,19 @@ typedef CMdaAudioPlayerUtility NativePlayer; virtual void doStop(); virtual void doSeek(qint64 milliseconds); virtual int setDeviceVolume(int mmfVolume); + virtual int openFile(const QString &fileName); virtual int openFile(RFile& file); virtual int openUrl(const QString& url); virtual int openDescriptor(const TDesC8 &des); virtual int bufferStatus() const; - virtual void close(); + virtual void doClose(); // MediaObjectInterface virtual bool hasVideo() const; - virtual qint64 currentTime() const; virtual qint64 totalTime() const; // AbstractMediaPlayer + virtual qint64 getCurrentTime() const; virtual int numberOfMetaDataEntries() const; virtual QPair metaDataEntry(int index) const; diff --git a/src/3rdparty/phonon/mmf/mediaobject.cpp b/src/3rdparty/phonon/mmf/mediaobject.cpp index 98326b8..2c7a7ef 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.cpp +++ b/src/3rdparty/phonon/mmf/mediaobject.cpp @@ -61,6 +61,9 @@ MMF::MediaObject::MediaObject(QObject *parent) : MMF::MediaNode::MediaNode(paren TRACE_CONTEXT(MediaObject::MediaObject, EAudioApi); TRACE_ENTRY_0(); + const int err = m_fileServer.Connect(); + QT_TRAP_THROWING(User::LeaveIfError(err)); + Q_UNUSED(parent); TRACE_EXIT_0(); @@ -99,12 +102,6 @@ bool MMF::MediaObject::openRecognizer() return false; } - err = m_fileServer.Connect(); - if (KErrNone != err) { - TRACE("RFs::Connect error %d", err); - return false; - } - // This must be called in order to be able to share file handles with // the recognizer server (see fileMediaType function). err = m_fileServer.ShareProtected(); @@ -127,13 +124,8 @@ MMF::MediaType MMF::MediaObject::fileMediaType MediaType result = MediaTypeUnknown; if (openRecognizer()) { - - const QHBufC fileNameSymbian(QDir::toNativeSeparators(fileName)); - - Q_ASSERT(!m_file); - m_file = new RFile; - TInt err = m_file->Open(m_fileServer, *fileNameSymbian, EFileRead | EFileShareReadersOnly); - + TInt err = openFileHandle(fileName); + const QHBufC nativeFileName(QDir::toNativeSeparators(fileName)); if (KErrNone == err) { TDataRecognitionResult recognizerResult; err = m_recognizer.RecognizeData(*m_file, recognizerResult); @@ -141,16 +133,30 @@ MMF::MediaType MMF::MediaObject::fileMediaType const TPtrC mimeType = recognizerResult.iDataType.Des(); result = Utils::mimeTypeToMediaType(mimeType); } else { - TRACE("RApaLsSession::RecognizeData filename %S error %d", fileNameSymbian.data(), err); + TRACE("RApaLsSession::RecognizeData filename %S error %d", nativeFileName.data(), err); } } else { - TRACE("RFile::Open filename %S error %d", fileNameSymbian.data(), err); + TRACE("RFile::Open filename %S error %d", nativeFileName.data(), err); } } return result; } +int MMF::MediaObject::openFileHandle(const QString &fileName) +{ + TRACE_CONTEXT(MediaObject::openFileHandle, EAudioInternal); + const QHBufC nativeFileName(QDir::toNativeSeparators(fileName)); + TRACE_ENTRY("filename %S", nativeFileName.data()); + if (m_file) + m_file->Close(); + delete m_file; + m_file = 0; + m_file = new RFile; + TInt err = m_file->Open(m_fileServer, *nativeFileName, EFileRead | EFileShareReadersOrWriters); + return err; +} + MMF::MediaType MMF::MediaObject::bufferMediaType(const uchar *data, qint64 size) { TRACE_CONTEXT(MediaObject::bufferMediaType, EAudioInternal); diff --git a/src/3rdparty/phonon/mmf/mediaobject.h b/src/3rdparty/phonon/mmf/mediaobject.h index 5399e27..5d785fb 100644 --- a/src/3rdparty/phonon/mmf/mediaobject.h +++ b/src/3rdparty/phonon/mmf/mediaobject.h @@ -89,6 +89,7 @@ public: void setVideoOutput(AbstractVideoOutput* videoOutput); + int openFileHandle(const QString &fileName); RFile* file() const; QResource* resource() const; -- cgit v0.12 From d1b6c5d5e101c9ffdfdfb7b712ea69025150ab05 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Mon, 27 Sep 2010 18:07:35 +0100 Subject: qmediaplayer: show buffer status of 0% During progressive download, it is not possible for the Symbian MMF Phonon backend to determine the buffering status, so it returns a value of 0%. This change causes qmediaplayer to display this value in the UI, thereby giving a visible notification of buffering during progressive download. Task-number: QTBUG-10769 Reviewed-by: Derick Hawcroft --- demos/qmediaplayer/mediaplayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index 3cb0616..97a8e35 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -716,7 +716,7 @@ void MediaPlayer::openFile() void MediaPlayer::bufferStatus(int percent) { - if (percent == 0 || percent == 100) + if (percent == 100) progressLabel->setText(QString()); else { QString str = QString::fromLatin1("(%1%)").arg(percent); -- cgit v0.12 From 71af72bc037db6bac023bf9a0bbf6032c06b2d29 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Sun, 3 Oct 2010 19:43:29 +0100 Subject: Added qmake check for presence of RHttpDownloadMgr header downloadmgrclient.h is not found on S^4 baselines, causing a build failure. This commit is a temporary workaround, which disables progressive download support if the header is not found. The correct solution is to determine whether the RHttpDownloadMgr definition has moved, and if so, to modify the .pro file to include the new path. Task-number: QTBUG-10769 Reviewed-by: TrustMe --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 26 ++++++++++-- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 9 ++++- src/3rdparty/phonon/mmf/download.h | 2 - src/plugins/phonon/mmf/mmf.pro | 53 +++++++++++++++---------- 4 files changed, 61 insertions(+), 29 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index a728423..dfc5840 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -56,8 +56,10 @@ MMF::AbstractMediaPlayer::AbstractMediaPlayer , m_mmfMaxVolume(NullMaxVolume) , m_prefinishMarkSent(false) , m_aboutToFinishSent(false) +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD , m_download(0) , m_downloadStalled(false) +#endif { connect(m_positionTimer.data(), SIGNAL(timeout()), this, SLOT(positionTick())); connect(m_bufferStatusTimer.data(), SIGNAL(timeout()), this, SLOT(bufferStatusTick())); @@ -256,7 +258,9 @@ void MMF::AbstractMediaPlayer::open() symbianErr = openFile(*file); if (KErrNone != symbianErr) errorMessage = tr("Error opening file"); - } else if (url.scheme() == QLatin1String("http")) { + } +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD + else if (url.scheme() == QLatin1String("http")) { Q_ASSERT(!m_download); m_download = new Download(url, this); connect(m_download, SIGNAL(lengthChanged(qint64)), @@ -264,7 +268,9 @@ void MMF::AbstractMediaPlayer::open() connect(m_download, SIGNAL(stateChanged(Download::State)), this, SLOT(downloadStateChanged(Download::State))); m_download->start(); - } else { + } +#endif + else { symbianErr = openUrl(url.toString()); if (KErrNone != symbianErr) errorMessage = tr("Error opening URL"); @@ -308,8 +314,10 @@ void MMF::AbstractMediaPlayer::open() void MMF::AbstractMediaPlayer::close() { doClose(); +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD delete m_download; m_download = 0; +#endif m_position = 0; } @@ -419,7 +427,9 @@ void MMF::AbstractMediaPlayer::loadingComplete(int error) bufferingComplete(); doSeek(m_position); startPlayback(); +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD m_downloadStalled = false; +#endif } } else { Q_ASSERT(Phonon::LoadingState == state()); @@ -472,12 +482,20 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds bool MMF::AbstractMediaPlayer::isProgressiveDownload() const { +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD return (0 != m_download); +#else + return false; +#endif } bool MMF::AbstractMediaPlayer::progressiveDownloadStalled() const { +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD return m_downloadStalled; +#else + return false; +#endif } //----------------------------------------------------------------------------- @@ -547,6 +565,7 @@ void MMF::AbstractMediaPlayer::startPlayback() void MMF::AbstractMediaPlayer::setProgressiveDownloadStalled() { +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD TRACE_CONTEXT(AbstractMediaPlayer::setProgressiveDownloadStalled, EAudioApi); TRACE_ENTRY("state %d", state()); Q_ASSERT(isProgressiveDownload()); @@ -555,7 +574,6 @@ void MMF::AbstractMediaPlayer::setProgressiveDownloadStalled() bufferingStarted(); // Video player loses window handle when closed - need to reapply it here videoOutputChanged(); -#ifdef QT_PHONON_MMF_DOWNLOAD_DUMMY m_download->resume(); #endif } @@ -569,6 +587,7 @@ void MMF::AbstractMediaPlayer::bufferStatusTick() emit MMF::AbstractPlayer::bufferStatus(status); } +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD void MMF::AbstractMediaPlayer::downloadLengthChanged(qint64 length) { TRACE_CONTEXT(AbstractMediaPlayer::downloadLengthChanged, EAudioApi); @@ -611,6 +630,7 @@ void MMF::AbstractMediaPlayer::downloadStateChanged(Download::State state) break; } } +#endif // PHONON_MMF_PROGRESSIVE_DOWNLOAD Phonon::State MMF::AbstractMediaPlayer::phononState(PrivateState state) const { diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index 99fc101..c3b4528 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -23,7 +23,9 @@ along with this library. If not, see . #include #include #include "abstractplayer.h" -#include "download.h" +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD +# include "download.h" +#endif class RFile; @@ -118,8 +120,10 @@ private: private Q_SLOTS: void positionTick(); void bufferStatusTick(); +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD void downloadLengthChanged(qint64); void downloadStateChanged(Download::State); +#endif private: MediaObject *const m_parent; @@ -140,9 +144,10 @@ private: // Used for playback of resource files TPtrC8 m_buffer; - // Used for progressive download +#ifdef PHONON_MMF_PROGRESSIVE_DOWNLOAD Download *m_download; bool m_downloadStalled; +#endif QMultiMap m_metaData; diff --git a/src/3rdparty/phonon/mmf/download.h b/src/3rdparty/phonon/mmf/download.h index b57348b..bda7963 100644 --- a/src/3rdparty/phonon/mmf/download.h +++ b/src/3rdparty/phonon/mmf/download.h @@ -70,8 +70,6 @@ public: const QUrl &sourceUrl() const; const QString &targetFileName() const; void start(); - - // Only has effect when QT_PHONON_MMF_DOWNLOAD_DUMMY is defined void resume(); enum State { diff --git a/src/plugins/phonon/mmf/mmf.pro b/src/plugins/phonon/mmf/mmf.pro index 902354f..ac11188 100644 --- a/src/plugins/phonon/mmf/mmf.pro +++ b/src/plugins/phonon/mmf/mmf.pro @@ -36,7 +36,6 @@ symbian { $$PHONON_MMF_DIR/backend.h \ $$PHONON_MMF_DIR/bassboost.h \ $$PHONON_MMF_DIR/defs.h \ - $$PHONON_MMF_DIR/download.h \ $$PHONON_MMF_DIR/dummyplayer.h \ $$PHONON_MMF_DIR/effectfactory.h \ $$PHONON_MMF_DIR/effectparameter.h \ @@ -62,7 +61,6 @@ symbian { $$PHONON_MMF_DIR/abstractvideoplayer.cpp \ $$PHONON_MMF_DIR/backend.cpp \ $$PHONON_MMF_DIR/bassboost.cpp \ - $$PHONON_MMF_DIR/download.cpp \ $$PHONON_MMF_DIR/dummyplayer.cpp \ $$PHONON_MMF_DIR/effectfactory.cpp \ $$PHONON_MMF_DIR/effectparameter.cpp \ @@ -77,25 +75,37 @@ symbian { $$PHONON_MMF_DIR/utils.cpp \ $$PHONON_MMF_DIR/videowidget.cpp - # Test for whether the build environment supports video rendering to graphics - # surfaces. - symbian:exists($${EPOCROOT}epoc32/include/platform/videoplayer2.h) { - HEADERS += \ - $$PHONON_MMF_DIR/videooutput_surface.h \ - $$PHONON_MMF_DIR/videoplayer_surface.h - SOURCES += \ - $$PHONON_MMF_DIR/videooutput_surface.cpp \ - $$PHONON_MMF_DIR/videoplayer_surface.cpp - DEFINES += PHONON_MMF_VIDEO_SURFACES - } else { - HEADERS += \ - $$PHONON_MMF_DIR/ancestormovemonitor.h \ - $$PHONON_MMF_DIR/videooutput_dsa.h \ - $$PHONON_MMF_DIR/videoplayer_dsa.h - SOURCES += \ - $$PHONON_MMF_DIR/ancestormovemonitor.cpp \ - $$PHONON_MMF_DIR/videooutput_dsa.cpp \ - $$PHONON_MMF_DIR/videoplayer_dsa.cpp \ + symbian { + # Test for whether the build environment supports video rendering to graphics + # surfaces. + exists($${EPOCROOT}epoc32/include/platform/videoplayer2.h) { + HEADERS += \ + $$PHONON_MMF_DIR/videooutput_surface.h \ + $$PHONON_MMF_DIR/videoplayer_surface.h + SOURCES += \ + $$PHONON_MMF_DIR/videooutput_surface.cpp \ + $$PHONON_MMF_DIR/videoplayer_surface.cpp + DEFINES += PHONON_MMF_VIDEO_SURFACES + } else { + HEADERS += \ + $$PHONON_MMF_DIR/ancestormovemonitor.h \ + $$PHONON_MMF_DIR/videooutput_dsa.h \ + $$PHONON_MMF_DIR/videoplayer_dsa.h + SOURCES += \ + $$PHONON_MMF_DIR/ancestormovemonitor.cpp \ + $$PHONON_MMF_DIR/videooutput_dsa.cpp \ + $$PHONON_MMF_DIR/videoplayer_dsa.cpp \ + } + + # Test whether the build environment includes support for the Download Manager + # API, required for Progressive Download + exists($${EPOCROOT}epoc32/include/downloadmgrclient.h) | \ + exists($${EPOCROOT}epoc32/include/mw/downloadmgrclient.h) { + HEADERS += $$PHONON_MMF_DIR/download.h + SOURCES += $$PHONON_MMF_DIR/download.cpp + LIBS += -ldownloadmgr + DEFINES += PHONON_MMF_PROGRESSIVE_DOWNLOAD + } } LIBS += -lcone @@ -113,7 +123,6 @@ symbian { LIBS += -lapgrfx -lapmime # For recognizer LIBS += -lmmfcontrollerframework # For CMMFMetaDataEntry LIBS += -lmediaclientaudiostream # For CMdaAudioOutputStream - LIBS += -ldownloadmgr # These are for effects. LIBS += -lAudioEqualizerEffect -lBassBoostEffect -lDistanceAttenuationEffect -lDopplerBase -lEffectBase -lEnvironmentalReverbEffect -lListenerDopplerEffect -lListenerLocationEffect -lListenerOrientationEffect -lLocationBase -lLoudnessEffect -lOrientationBase -lSourceDopplerEffect -lSourceLocationEffect -lSourceOrientationEffect -lStereoWideningEffect -- cgit v0.12 From 978416807b7e92d9317036cb4348ee172dde7d4e Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 8 Oct 2010 09:08:54 +0200 Subject: Fix memory leak in QPixmap::toSymbianRSgImage() when an error occurs. In the cases where an error occured while converting a QPixmap to a VGImage this function would return without deleting the RSgImage pointer that it created. Fix is to use a QScopedPointer instead. Also don't use q_check_ptr() since this isn't a CBase derived class. In case you are wondering why I didn't use a custom deleter here so that Close() was also called, we need to make sure that Close() is called on the RSgImage instance before calling Close() on the driver. Reviewed-by: mread --- src/openvg/qvg_symbian.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp index ef0160c..a9625b2 100644 --- a/src/openvg/qvg_symbian.cpp +++ b/src/openvg/qvg_symbian.cpp @@ -228,7 +228,7 @@ void* QVGPixmapData::toNativeType(NativeType type) sgInfo.iSizeInPixels.SetSize(w, h); sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface; - RSgImage *sgImage = q_check_ptr(new RSgImage()); + QScopedPointer sgImage(new RSgImage()); err = sgImage->Create(sgInfo, NULL, NULL); if (err != KErrNone) { driver.Close(); @@ -239,7 +239,7 @@ void* QVGPixmapData::toNativeType(NativeType type) EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, - (EGLClientBuffer)sgImage, + (EGLClientBuffer)sgImage.data(), (EGLint*)KEglImageAttribs); if (!eglImage || eglGetError() != EGL_SUCCESS) { sgImage->Close(); @@ -261,13 +261,14 @@ void* QVGPixmapData::toNativeType(NativeType type) if (vgGetError() != VG_NO_ERROR) { sgImage->Close(); - sgImage = 0; + sgImage.reset(); } + // release stuff vgDestroyImage(dstVgImage); QEgl::eglDestroyImageKHR(QEgl::display(), eglImage); driver.Close(); - return reinterpret_cast(sgImage); + return reinterpret_cast(sgImage.take()); #endif } else if (type == QPixmapData::FbsBitmap) { CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); -- cgit v0.12 From 4cff91c66207b870e12365421e63cd978e162e64 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 8 Oct 2010 10:55:54 +0200 Subject: Fix infinite loop when justifying undisplayable Arabic text If the Arabic text is for some reason undisplayable, e.g. because of QTBUG-13132, the font engine will be unable to find the tatweel character and the kashida width may be returned as 0. This would potentially cause an infinite loop, as "need" would remain >= minKashida forever because x - 0 is still >= 0. Task-number: QTBUG-13130 Reviewed-by: Lars --- src/gui/text/qtextengine.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 05de8f5..3bd6122 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1949,9 +1949,11 @@ void QTextEngine::justify(const QScriptLine &line) if (kashida_pos >= 0) { // qDebug("kashida position at %d in word", kashida_pos); set(&justificationPoints[nPoints], kashida_type, g.mid(kashida_pos), fontEngine(si)); - minKashida = qMin(minKashida, justificationPoints[nPoints].kashidaWidth); - maxJustify = qMax(maxJustify, justificationPoints[nPoints].type); - ++nPoints; + if (justificationPoints[nPoints].kashidaWidth > 0) { + minKashida = qMin(minKashida, justificationPoints[nPoints].kashidaWidth); + maxJustify = qMax(maxJustify, justificationPoints[nPoints].type); + ++nPoints; + } } kashida_pos = -1; kashida_type = HB_Arabic_Normal; @@ -1975,9 +1977,11 @@ void QTextEngine::justify(const QScriptLine &line) } if (kashida_pos >= 0) { set(&justificationPoints[nPoints], kashida_type, g.mid(kashida_pos), fontEngine(si)); - minKashida = qMin(minKashida, justificationPoints[nPoints].kashidaWidth); - maxJustify = qMax(maxJustify, justificationPoints[nPoints].type); - ++nPoints; + if (justificationPoints[nPoints].kashidaWidth > 0) { + minKashida = qMin(minKashida, justificationPoints[nPoints].kashidaWidth); + maxJustify = qMax(maxJustify, justificationPoints[nPoints].type); + ++nPoints; + } } } -- cgit v0.12 From 4d974ff0a748b22e668a4cb7ef38101122c85b3b Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Fri, 8 Oct 2010 14:21:10 +0200 Subject: Avoid in-place convertion of images with multiple references The decoding from image reader was assuming the image reader do not keep the image internally. This is not true for the GIF plugins because the previous image can be used to compose the current image. This was causing crash on ARM because the 16 bits color depth causes the image memory to be reduce by half. When the plugin was accessing the memory, it assumes the images has not changed and is on 32 bits. This patch disable the in-place conversion if a detach is required. Regular conversion is the correct solution in this case, and it can also be made faster by converting while copying. Reviewed-by: Andreas Kling --- src/gui/image/qimage.cpp | 4 ++++ tests/auto/qpixmap/tst_qpixmap.cpp | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index ac148ee..1157b93 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -6607,6 +6607,10 @@ bool QImageData::convertInPlace(QImage::Format newFormat, Qt::ImageConversionFla if (format == newFormat) return true; + // No in-place conversion if we have to detach + if (ref > 1) + return false; + const InPlace_Image_Converter *const converterPtr = &inplace_converter_map[format][newFormat]; InPlace_Image_Converter converter = *converterPtr; if (converter) diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 8005ec5..24cbb21 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -179,6 +179,7 @@ private slots: void fromImageReader_data(); void fromImageReader(); + void fromImageReaderAnimatedGif_data(); void fromImageReaderAnimatedGif(); void preserveDepth(); @@ -1605,6 +1606,8 @@ void tst_QPixmap::fromImageReader_data() QTest::newRow("designer_indexed8_no_alpha.gif") << prefix + "/designer_indexed8_no_alpha.gif"; QTest::newRow("designer_indexed8_with_alpha.gif") << prefix + "/designer_indexed8_with_alpha.gif"; QTest::newRow("designer_rgb32.jpg") << prefix + "/designer_rgb32.jpg"; + QTest::newRow("designer_indexed8_with_alpha_animated") << prefix + "/designer_indexed8_with_alpha_animated.gif"; + QTest::newRow("designer_indexed8_with_alpha_animated") << prefix + "/designer_indexed8_no_alpha_animated.gif"; } void tst_QPixmap::fromImageReader() @@ -1621,14 +1624,22 @@ void tst_QPixmap::fromImageReader() QVERIFY(pixmapsAreEqual(&pixmapWithCopy, &directLoadingPixmap)); } +void tst_QPixmap::fromImageReaderAnimatedGif_data() +{ + QTest::addColumn("imagePath"); + QTest::newRow("gif with alpha") << QString::fromLatin1("/designer_indexed8_with_alpha_animated.gif"); + QTest::newRow("gif without alpha") << QString::fromLatin1("/designer_indexed8_no_alpha_animated.gif"); +} + void tst_QPixmap::fromImageReaderAnimatedGif() { + QFETCH(QString, imagePath); #ifdef Q_OS_SYMBIAN const QString prefix = QLatin1String(SRCDIR) + "loadFromData"; #else const QString prefix = QLatin1String(SRCDIR) + "/loadFromData"; #endif - const QString path = prefix + QString::fromLatin1("/designer_indexed8_with_alpha_animated.gif"); + const QString path = prefix + imagePath; QImageReader referenceReader(path); QImageReader pixmapReader(path); -- cgit v0.12 From 7ca4e9622c4b2e4142d401fa10d50a0a45906615 Mon Sep 17 00:00:00 2001 From: axis Date: Thu, 7 Oct 2010 15:26:47 +0200 Subject: Fixed missing QMAKE_MOC definition in certain mkspecs. Also removed the use of DIR_SEPARATOR. It does not get defined until after symbian.conf has finished parsing. RevBy: Miikka Heikkinen --- mkspecs/common/symbian/symbian-mmp.conf | 10 ---------- mkspecs/common/symbian/symbian.conf | 8 ++++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/mkspecs/common/symbian/symbian-mmp.conf b/mkspecs/common/symbian/symbian-mmp.conf index 5292781..1fbd302 100644 --- a/mkspecs/common/symbian/symbian-mmp.conf +++ b/mkspecs/common/symbian/symbian-mmp.conf @@ -4,16 +4,6 @@ include(symbian.conf) -contains(QMAKE_HOST.os, "Windows") { - QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc.exe - QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic.exe - QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc.exe -} else { - QMAKE_MOC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}moc - QMAKE_UIC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}uic - QMAKE_IDC = $$[QT_INSTALL_BINS]$${DIR_SEPARATOR}idc -} - load(symbian/add_mmp_rules) symbian-abld { diff --git a/mkspecs/common/symbian/symbian.conf b/mkspecs/common/symbian/symbian.conf index cc5b788..d8c38f4 100644 --- a/mkspecs/common/symbian/symbian.conf +++ b/mkspecs/common/symbian/symbian.conf @@ -95,6 +95,10 @@ contains(QMAKE_HOST.os,Windows) { QMAKE_DEL_DIR = rmdir QMAKE_DEL_TREE = rmdir /s /q QMAKE_CHK_DIR_EXISTS = if not exist + + QMAKE_MOC = $$[QT_INSTALL_BINS]\\moc.exe + QMAKE_UIC = $$[QT_INSTALL_BINS]\\uic.exe + QMAKE_IDC = $$[QT_INSTALL_BINS]\\idc.exe } else { QMAKE_COPY = cp QMAKE_COPY_DIR = cp -r @@ -104,6 +108,10 @@ contains(QMAKE_HOST.os,Windows) { QMAKE_DEL_DIR = rmdir QMAKE_DEL_TREE = rm -rf QMAKE_CHK_DIR_EXISTS = test -d + + QMAKE_MOC = $$[QT_INSTALL_BINS]/moc + QMAKE_UIC = $$[QT_INSTALL_BINS]/uic + QMAKE_IDC = $$[QT_INSTALL_BINS]/idc } QMAKE_IDL = midl -- cgit v0.12 From aa0f3a7745472ea8c9ca43bb7d690a0591bde83b Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 8 Oct 2010 14:58:44 +0200 Subject: Fixed some preprocessor parameters for Mac support. RevBy: Liang Qi --- mkspecs/features/symbian/symbian_building.prf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mkspecs/features/symbian/symbian_building.prf b/mkspecs/features/symbian/symbian_building.prf index 614fb65..1a51cb2 100644 --- a/mkspecs/features/symbian/symbian_building.prf +++ b/mkspecs/features/symbian/symbian_building.prf @@ -229,7 +229,7 @@ symbian_resources_INCLUDES = $$replace(symbian_resources_INCLUDES, ",", " -I") symbian_resources_INCLUDES += $$join(INCLUDEPATH, " -I", "-I") symbian_resources_DEFINES = $$join(DEFINES, " -D", "-D") symbian_resources_RCC_DIR = $$replace(RCC_DIR, "/$", "") -symbian_resources_INCLUDES += "-I $$symbian_resources_RCC_DIR" +symbian_resources_INCLUDES += "-I$$symbian_resources_RCC_DIR" for(symbian_resource, SYMBIAN_RESOURCES) { symbian_resource = $$basename(symbian_resource) @@ -245,7 +245,7 @@ symbianresources.commands = cpp -nostdinc -undef \ $$symbian_resources_INCLUDES \ $$symbian_resources_DEFINES \ ${QMAKE_FILE_NAME} \ - -o $${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \ + > $${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \ && rcomp -u -m045,046,047 \ -s$${symbian_resources_RCC_DIR}/${QMAKE_FILE_BASE}.rpp \ -o$${symbianDestdir}/${QMAKE_FILE_BASE}$${QT_LIBINFIX}.rsc \ @@ -265,7 +265,7 @@ contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") { $$symbian_resources_INCLUDES \ $$symbian_resources_DEFINES \ $${baseTarget}.rss \ - -o $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ + > $${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ && rcomp -u -m045,046,047 \ -s$${symbian_resources_RCC_DIR}/$${baseTarget}.rpp \ -o$${symbianDestdir}/$${baseTarget}.rsc \ @@ -284,7 +284,7 @@ contains(TEMPLATE, "app"):!contains(CONFIG, "no_icon") { $$symbian_resources_INCLUDES \ $$symbian_resources_DEFINES \ $${baseTarget}_reg.rss \ - -o $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ + > $${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ && rcomp -u -m045,046,047 \ -s$${symbian_resources_RCC_DIR}/$${baseTarget}_reg.rpp \ -o$${symbianDestdir}/$${baseTarget}_reg.rsc \ -- cgit v0.12 From 4ee912a752a4b7f129e98e180328f1f46f053d4f Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 1 Oct 2010 13:25:28 +0200 Subject: Added support for using inputMethodHints in QInputDialog edit widget. AutoTest: Included Task: QTBUG-13200 RevBy: Denis Dzyubenko --- src/gui/dialogs/qinputdialog.cpp | 6 ++++++ src/gui/kernel/qwidget.cpp | 11 +++++++++-- src/gui/kernel/qwidget_p.h | 3 +++ tests/auto/qinputdialog/tst_qinputdialog.cpp | 20 ++++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/gui/dialogs/qinputdialog.cpp b/src/gui/dialogs/qinputdialog.cpp index e996ee9..700b234 100644 --- a/src/gui/dialogs/qinputdialog.cpp +++ b/src/gui/dialogs/qinputdialog.cpp @@ -244,6 +244,9 @@ void QInputDialogPrivate::ensureLineEdit() Q_Q(QInputDialog); if (!lineEdit) { lineEdit = new QLineEdit(q); +#ifndef QT_NO_IM + qt_widget_private(lineEdit)->inheritsInputMethodHints = 1; +#endif lineEdit->hide(); QObject::connect(lineEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_textChanged(QString))); @@ -255,6 +258,9 @@ void QInputDialogPrivate::ensureComboBox() Q_Q(QInputDialog); if (!comboBox) { comboBox = new QComboBox(q); +#ifndef QT_NO_IM + qt_widget_private(comboBox)->inheritsInputMethodHints = 1; +#endif comboBox->hide(); QObject::connect(comboBox, SIGNAL(editTextChanged(QString)), q, SLOT(_q_textChanged(QString))); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index dc0dbf4..330d699 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -273,6 +273,9 @@ QWidgetPrivate::QWidgetPrivate(int version) , isMoved(0) , isGLWidget(0) , usesDoubleBufferedGLContext(0) +#ifndef QT_NO_IM + , inheritsInputMethodHints(0) +#endif #if defined(Q_WS_X11) , picture(0) #elif defined(Q_WS_WIN) @@ -9228,9 +9231,13 @@ QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const */ Qt::InputMethodHints QWidget::inputMethodHints() const { - Q_D(const QWidget); #ifndef QT_NO_IM - return d->imHints; + const QWidgetPrivate *priv = d_func(); + while (priv->inheritsInputMethodHints) { + priv = priv->q_func()->parentWidget()->d_func(); + Q_ASSERT(priv); + } + return priv->imHints; #else //QT_NO_IM return 0; #endif //QT_NO_IM diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 4a79dc7..6c89659 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -748,6 +748,9 @@ public: uint isMoved : 1; uint isGLWidget : 1; uint usesDoubleBufferedGLContext : 1; +#ifndef QT_NO_IM + uint inheritsInputMethodHints : 1; +#endif // *************************** Platform specific ************************************ #if defined(Q_WS_X11) // <----------------------------------------------------------- X11 diff --git a/tests/auto/qinputdialog/tst_qinputdialog.cpp b/tests/auto/qinputdialog/tst_qinputdialog.cpp index 0d6644a..5d03142 100644 --- a/tests/auto/qinputdialog/tst_qinputdialog.cpp +++ b/tests/auto/qinputdialog/tst_qinputdialog.cpp @@ -74,6 +74,7 @@ private slots: void getItem_data(); void getItem(); void task256299_getTextReturnNullStringOnRejected(); + void inputMethodHintsOfChildWidget(); }; QString stripFraction(const QString &s) @@ -404,5 +405,24 @@ void tst_QInputDialog::getItem() delete parent; } +void tst_QInputDialog::inputMethodHintsOfChildWidget() +{ + QInputDialog dialog; + dialog.setInputMode(QInputDialog::TextInput); + QList children = dialog.children(); + QLineEdit *editWidget = 0; + for (int c = 0; c < children.size(); c++) { + editWidget = qobject_cast(children.at(c)); + if (editWidget) + break; + } + QVERIFY(editWidget); + QCOMPARE(editWidget->inputMethodHints(), dialog.inputMethodHints()); + QCOMPARE(editWidget->inputMethodHints(), Qt::ImhNone); + dialog.setInputMethodHints(Qt::ImhDigitsOnly); + QCOMPARE(editWidget->inputMethodHints(), dialog.inputMethodHints()); + QCOMPARE(editWidget->inputMethodHints(), Qt::ImhDigitsOnly); +} + QTEST_MAIN(tst_QInputDialog) #include "tst_qinputdialog.moc" -- cgit v0.12 From 0fcee2f495eb2e1c4b76aa8c3e5462595aed0ab3 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 8 Oct 2010 13:25:04 +0100 Subject: Account for native child widgets when handling focus events The code previously contained an implicit assumption that the control which received the FocusChanged event was a top-level widget. This meant that focus events delivered to native child widgets could cause unexpected changes in visibility of the statusbar and CBA. Task-number: QTBUG-13761 Reviewed-by: Jason Barron --- src/gui/kernel/qapplication_s60.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 296f24f..5ff2fd4 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1237,10 +1237,11 @@ void QSymbianControl::FocusChanged(TDrawNow /* aDrawNow */) qwidget->d_func()->setWindowTitle_sys(qwidget->windowTitle()); #ifdef Q_WS_S60 // If widget is fullscreen/minimized, hide status pane and button container otherwise show them. - const bool visible = !(qwidget->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); + QWidget *const window = qwidget->window(); + const bool visible = !(window->windowState() & (Qt::WindowFullScreen | Qt::WindowMinimized)); const bool statusPaneVisibility = visible; - const bool isFullscreen = qwidget->windowState() & Qt::WindowFullScreen; - const bool cbaVisibilityHint = qwidget->windowFlags() & Qt::WindowSoftkeysVisibleHint; + const bool isFullscreen = window->windowState() & Qt::WindowFullScreen; + const bool cbaVisibilityHint = window->windowFlags() & Qt::WindowSoftkeysVisibleHint; const bool buttonGroupVisibility = (visible || (isFullscreen && cbaVisibilityHint)); S60->setStatusPaneAndButtonGroupVisibility(statusPaneVisibility, buttonGroupVisibility); #endif -- cgit v0.12 From d11a15081c6385bb32ce78c8501fc259f56b2be2 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Fri, 8 Oct 2010 16:37:34 +0200 Subject: Added Q_INVOKABLE to ignore file. Task-number: QTBUG-14281 Reviewed-by: David Boddie --- tools/qdoc3/test/qt-cpp-ignore.qdocconf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/qdoc3/test/qt-cpp-ignore.qdocconf b/tools/qdoc3/test/qt-cpp-ignore.qdocconf index b78b512..5d52a47 100644 --- a/tools/qdoc3/test/qt-cpp-ignore.qdocconf +++ b/tools/qdoc3/test/qt-cpp-ignore.qdocconf @@ -71,8 +71,9 @@ Cpp.ignoretokens = QAXFACTORY_EXPORT \ QT_END_INCLUDE_NAMESPACE \ PHONON_EXPORT \ Q_DECLARATIVE_EXPORT \ - Q_GADGET \ - QWEBKIT_EXPORT + Q_GADGET \ + QWEBKIT_EXPORT \ + Q_INVOKABLE Cpp.ignoredirectives = Q_DECLARE_HANDLE \ Q_DECLARE_INTERFACE \ Q_DECLARE_METATYPE \ -- cgit v0.12 From f0c1f381af7d6338ded9f65d00ed54b1b9405ba9 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Sat, 9 Oct 2010 17:28:06 +0200 Subject: Add missing data for the autotest of in-place conversion for Pixmap The commit 4d974ff0a748b22e668a4cb7ef38101122c85b3b uses an new image which was not commited with the patch. --- .../loadFromData/designer_indexed8_no_alpha_animated.gif | Bin 0 -> 4075 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha_animated.gif diff --git a/tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha_animated.gif b/tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha_animated.gif new file mode 100644 index 0000000..86a3a2e Binary files /dev/null and b/tests/auto/qpixmap/loadFromData/designer_indexed8_no_alpha_animated.gif differ -- cgit v0.12 From aa7fa8608939676ba56e130214b85f5d0c3745df Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 11 Oct 2010 11:24:05 +1000 Subject: Add a declarative callback for when a QObject's objectName changes Task-number: QTBUG-13999 Reviewed-by: Martin Jones --- src/corelib/kernel/qobject.cpp | 6 ++++++ src/corelib/kernel/qobject_p.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8330e47..579c225 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -127,6 +127,7 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0; void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0; +void (*QAbstractDeclarativeData::objectNameChanged)(QAbstractDeclarativeData *, QObject *) = 0; QObjectData::~QObjectData() {} @@ -1094,7 +1095,12 @@ QString QObject::objectName() const void QObject::setObjectName(const QString &name) { Q_D(QObject); + bool objectNameChanged = d->declarativeData && d->objectName != name; + d->objectName = name; + + if (objectNameChanged) + d->declarativeData->objectNameChanged(d->declarativeData, this); } diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index 4800e6a..814769c 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -89,6 +89,7 @@ class Q_CORE_EXPORT QAbstractDeclarativeData public: static void (*destroyed)(QAbstractDeclarativeData *, QObject *); static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *); + static void (*objectNameChanged)(QAbstractDeclarativeData *, QObject *); }; class Q_CORE_EXPORT QObjectPrivate : public QObjectData -- cgit v0.12 From e11ee40cefc981fbdcfb10816039d4efb080fb17 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 11 Oct 2010 10:26:34 +1000 Subject: Don't give focus to a FocusScope that has had focus explicitly cleared. If focus was explicitly cleared on a non-visible FocusScope, and then it was made visible, it would incorrectly grab focus. Task-number: QTBUG-13380 --- src/gui/graphicsview/qgraphicsitem.cpp | 16 ++++++++----- src/gui/graphicsview/qgraphicsitem_p.h | 2 +- .../qdeclarativefocusscope/data/qtBug13380.qml | 24 ++++++++++++++++++++ .../tst_qdeclarativefocusscope.cpp | 26 ++++++++++++++++++++++ tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 3 +++ 5 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 60cd020..e63acac 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2365,7 +2365,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible()) fsi = fsi->d_ptr->focusScopeItem; fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true, - /* focusFromShow = */ true); + /* focusFromHide = */ false); } break; } @@ -2375,6 +2375,10 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo QGraphicsItem *fi = subFocusItem; if (fi && fi != scene->focusItem()) { scene->setFocusItem(fi); + } else if (flags & QGraphicsItem::ItemIsFocusScope && + !scene->focusItem() && + q->isAncestorOf(scene->d_func()->lastFocusItem)) { + q_ptr->setFocus(); } } } else { @@ -2385,7 +2389,7 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo if (p->flags() & QGraphicsItem::ItemIsFocusScope) { if (p->d_ptr->visible) { p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true, - /* focusFromShow = */ true); + /* focusFromHide = */ true); } break; } @@ -3245,13 +3249,13 @@ bool QGraphicsItem::hasFocus() const */ void QGraphicsItem::setFocus(Qt::FocusReason focusReason) { - d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromShow = */ false); + d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromHide = */ false); } /*! \internal */ -void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow) +void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide) { // Disabled / unfocusable items cannot accept focus. if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable)) @@ -3272,7 +3276,7 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim if (p->flags() & QGraphicsItem::ItemIsFocusScope) { QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem; p->d_ptr->focusScopeItem = q_ptr; - if (!p->focusItem() && !focusFromShow) { + if (!p->focusItem() && !focusFromHide) { if (oldFocusScopeItem) oldFocusScopeItem->d_ptr->focusScopeItemChange(false); focusScopeItemChange(true); @@ -3334,7 +3338,7 @@ void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent) while (p) { if (p->flags() & QGraphicsItem::ItemIsFocusScope) { p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false, - /* focusFromShow = */ false); + /* focusFromHide = */ false); return; } p = p->d_ptr->parent; diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index c8a7699..8480c19 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -477,7 +477,7 @@ public: inline void markParentDirty(bool updateBoundingRect = false); - void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromShow); + void setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide); void clearFocusHelper(bool giveFocusToParent); void setSubFocus(QGraphicsItem *rootItem = 0); void clearSubFocus(QGraphicsItem *rootItem = 0); diff --git a/tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml b/tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml new file mode 100644 index 0000000..1784202 --- /dev/null +++ b/tests/auto/declarative/qdeclarativefocusscope/data/qtBug13380.qml @@ -0,0 +1,24 @@ +import QtQuick 1.0 + +Rectangle { + width: 400; height: 400 + + property bool showRect: false + onShowRectChanged: if (showRect) rect.visible = true + property bool noFocus: !fs2.activeFocus + + FocusScope { + id: fs1 + focus: true + } + Rectangle { + id: rect + visible: false + FocusScope { + id: fs2 + Rectangle { + focus: true + } + } + } +} diff --git a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp index ec8f048..4cafbd9 100644 --- a/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp +++ b/tests/auto/declarative/qdeclarativefocusscope/tst_qdeclarativefocusscope.cpp @@ -70,6 +70,7 @@ private slots: void forceFocus(); void noParentFocus(); void signalEmission(); + void qtBug13380(); }; /* @@ -400,6 +401,31 @@ void tst_qdeclarativefocusscope::signalEmission() delete view; } +void tst_qdeclarativefocusscope::qtBug13380() +{ + QDeclarativeView *view = new QDeclarativeView; + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/qtBug13380.qml")); + + view->show(); + QVERIFY(view->rootObject()); + qApp->setActiveWindow(view); + qApp->processEvents(); + +#ifdef Q_WS_X11 + // to be safe and avoid failing setFocus with window managers + qt_x11_wait_for_window_manager(view); +#endif + + QVERIFY(view->hasFocus()); + QVERIFY(view->scene()->hasFocus()); + QVERIFY(view->rootObject()->property("noFocus").toBool()); + + view->rootObject()->setProperty("showRect", true); + QVERIFY(view->rootObject()->property("noFocus").toBool()); + + delete view; +} + QTEST_MAIN(tst_qdeclarativefocusscope) #include "tst_qdeclarativefocusscope.moc" diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 2901dd5..2ddccd2 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -9065,6 +9065,9 @@ void tst_QGraphicsItem::focusScope() scope2->hide(); scope2->show(); QVERIFY(!scope2->hasFocus()); + QVERIFY(scope1->hasFocus()); + scope2->setFocus(); + scope3->setFocus(); QVERIFY(scope3->hasFocus()); QGraphicsRectItem *rect4 = new QGraphicsRectItem; -- cgit v0.12 From f69eeec7030a5df12803a9128819207e3fc5bead Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 11 Oct 2010 11:43:59 +1000 Subject: Install the declarative objectNameChanged callback Task-number: QTBUG-13999 --- src/declarative/qml/qdeclarativedata_p.h | 2 ++ src/declarative/qml/qdeclarativeengine.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h index e916273..c7857b7 100644 --- a/src/declarative/qml/qdeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedata_p.h @@ -82,10 +82,12 @@ public: static inline void init() { QAbstractDeclarativeData::destroyed = destroyed; QAbstractDeclarativeData::parentChanged = parentChanged; + QAbstractDeclarativeData::objectNameChanged = objectNameChanged; } static void destroyed(QAbstractDeclarativeData *, QObject *); static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *); + static void objectNameChanged(QAbstractDeclarativeData *, QObject *); void destroyed(QObject *); void parentChanged(QObject *, QObject *); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 0749767..dfc29c4 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -468,6 +468,10 @@ void QDeclarativeData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QO static_cast(d)->parentChanged(o, p); } +void QDeclarativeData::objectNameChanged(QAbstractDeclarativeData *d, QObject *o) +{ +} + void QDeclarativeEnginePrivate::init() { Q_Q(QDeclarativeEngine); -- cgit v0.12 From 759da9b325f19670a3d79ede5f06fb3fa1f95495 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 11 Oct 2010 12:07:24 +1000 Subject: Allow objectName to be used in QML bindings Task-number: QTBUG-13999 --- src/declarative/qml/qdeclarativedata_p.h | 18 +++++++-- src/declarative/qml/qdeclarativeengine.cpp | 43 ++++++++++++++++++---- src/declarative/qml/qdeclarativefastproperties.cpp | 9 +++++ .../qml/qdeclarativeobjectscriptclass.cpp | 9 ++++- .../qdeclarativeecmascript/data/objectName.qml | 8 ++++ .../tst_qdeclarativeecmascript.cpp | 19 ++++++++++ 6 files changed, 93 insertions(+), 13 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h index c7857b7..def4188 100644 --- a/src/declarative/qml/qdeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedata_p.h @@ -64,6 +64,7 @@ class QDeclarativeAbstractBinding; class QDeclarativeContext; class QDeclarativePropertyCache; class QDeclarativeContextData; +class QDeclarativeNotifier; // This class is structured in such a way, that simply zero'ing it is the // default state for elemental object allocations. This is crucial in the // workings of the QDeclarativeInstruction::CreateSimpleObject instruction. @@ -75,7 +76,7 @@ public: : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false), context(0), outerContext(0), bindings(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0), bindingBits(0), lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), - attachedProperties(0), scriptValue(0), objectDataRefCount(0), propertyCache(0), guards(0) { + scriptValue(0), objectDataRefCount(0), propertyCache(0), guards(0), extendedData(0) { init(); } @@ -91,6 +92,7 @@ public: void destroyed(QObject *); void parentChanged(QObject *, QObject *); + void objectNameChanged(QObject *); void setImplicitDestructible() { if (!explicitIndestructibleSet) indestructible = false; @@ -125,8 +127,6 @@ public: QDeclarativeCompiledData *deferredComponent; // Can't this be found from the context? unsigned int deferredIdx; - QHash *attachedProperties; - // ### Can we make this QScriptValuePrivate so we incur no additional allocation // cost? QScriptValue *scriptValue; @@ -149,6 +149,18 @@ public: return 0; } } + + QDeclarativeNotifier *objectNameNotifier() const; + QHash *attachedProperties() const; + + struct ExtendedData { + ExtendedData(); + ~ExtendedData(); + + QHash attachedProperties; + void *objectNameNotifier; + }; + mutable ExtendedData *extendedData; }; template diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index dfc29c4..7ed925a 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -68,6 +68,7 @@ #include "private/qdeclarativelist_p.h" #include "private/qdeclarativetypenamecache_p.h" #include "private/qdeclarativeinclude_p.h" +#include "private/qdeclarativenotifier_p.h" #include #include @@ -470,6 +471,7 @@ void QDeclarativeData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QO void QDeclarativeData::objectNameChanged(QAbstractDeclarativeData *d, QObject *o) { + static_cast(d)->objectNameChanged(o); } void QDeclarativeEnginePrivate::init() @@ -953,7 +955,7 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre if (!data) return 0; // Attached properties are only on objects created by QML - QObject *rv = data->attachedProperties?data->attachedProperties->value(id):0; + QObject *rv = data->extendedData?data->attachedProperties()->value(id):0; if (rv || !create) return rv; @@ -963,11 +965,8 @@ QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool cre rv = pf(const_cast(object)); - if (rv) { - if (!data->attachedProperties) - data->attachedProperties = new QHash(); - data->attachedProperties->insert(id, rv); - } + if (rv) + data->attachedProperties()->insert(id, rv); return rv; } @@ -988,8 +987,6 @@ void QDeclarativeData::destroyed(QObject *object) { if (deferredComponent) deferredComponent->release(); - if (attachedProperties) - delete attachedProperties; if (nextContextObject) nextContextObject->prevContextObject = prevContextObject; @@ -1023,6 +1020,9 @@ void QDeclarativeData::destroyed(QObject *object) if (scriptValue) delete scriptValue; + if (extendedData) + delete extendedData; + if (ownMemory) delete this; } @@ -1032,6 +1032,11 @@ void QDeclarativeData::parentChanged(QObject *, QObject *parent) if (!parent && scriptValue) { delete scriptValue; scriptValue = 0; } } +void QDeclarativeData::objectNameChanged(QObject *) +{ + if (extendedData) objectNameNotifier()->notify(); +} + bool QDeclarativeData::hasBindingBit(int bit) const { if (bindingBitsSize > bit) @@ -1068,6 +1073,28 @@ void QDeclarativeData::setBindingBit(QObject *obj, int bit) bindingBits[bit / 32] |= (1 << (bit % 32)); } +QDeclarativeData::ExtendedData::ExtendedData() +: objectNameNotifier(0) +{ +} + +QDeclarativeData::ExtendedData::~ExtendedData() +{ + ((QDeclarativeNotifier *)&objectNameNotifier)->~QDeclarativeNotifier(); +} + +QDeclarativeNotifier *QDeclarativeData::objectNameNotifier() const +{ + if (!extendedData) extendedData = new ExtendedData; + return (QDeclarativeNotifier *)&extendedData->objectNameNotifier; +} + +QHash *QDeclarativeData::attachedProperties() const +{ + if (!extendedData) extendedData = new ExtendedData; + return &extendedData->attachedProperties; +} + /*! Creates a QScriptValue allowing you to use \a object in QML script. \a engine is the QDeclarativeEngine it is to be created in. diff --git a/src/declarative/qml/qdeclarativefastproperties.cpp b/src/declarative/qml/qdeclarativefastproperties.cpp index eb69b6a..78e3afd 100644 --- a/src/declarative/qml/qdeclarativefastproperties.cpp +++ b/src/declarative/qml/qdeclarativefastproperties.cpp @@ -51,10 +51,19 @@ QT_BEGIN_NAMESPACE // primarily read from bindings is a candidate for inclusion as a fast // property. +static void QObject_objectName(QObject *object, void *output, QDeclarativeNotifierEndpoint *endpoint) +{ + if (endpoint) + endpoint->connect(QDeclarativeData::get(object, true)->objectNameNotifier()); + *((QString *)output) = object->objectName(); +} + QDeclarativeFastProperties::QDeclarativeFastProperties() { add(&QDeclarativeItem::staticMetaObject, QDeclarativeItem::staticMetaObject.indexOfProperty("parent"), QDeclarativeItemPrivate::parentProperty); + add(&QObject::staticMetaObject, QObject::staticMetaObject.indexOfProperty("objectName"), + QObject_objectName); } int QDeclarativeFastProperties::accessorIndexForProperty(const QMetaObject *metaObject, int propertyIndex) diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index ab6ff74..61a1f55 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -239,8 +239,13 @@ QDeclarativeObjectScriptClass::property(QObject *obj, const Identifier &name) } } else { if (enginePriv->captureProperties && !(lastData->flags & QDeclarativePropertyCache::Data::IsConstant)) { - enginePriv->capturedProperties << - QDeclarativeEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex); + if (lastData->coreIndex == 0) { + enginePriv->capturedProperties << + QDeclarativeEnginePrivate::CapturedProperty(QDeclarativeData::get(obj, true)->objectNameNotifier()); + } else { + enginePriv->capturedProperties << + QDeclarativeEnginePrivate::CapturedProperty(obj, lastData->coreIndex, lastData->notifyIndex); + } } if (QDeclarativeValueTypeFactory::isValueType((uint)lastData->propType)) { diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml b/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml new file mode 100644 index 0000000..ca8c90d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/objectName.qml @@ -0,0 +1,8 @@ +import QtQuick 1.0 + +QtObject { + objectName: "hello" + + property string test1: objectName + property string test2: objectName.substr(1, 3) +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 4feb630..02832f3 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -162,6 +162,7 @@ private slots: void deleteLater(); void in(); void sharedAttachedObject(); + void objectName(); void include(); @@ -2594,6 +2595,24 @@ void tst_qdeclarativeecmascript::sharedAttachedObject() delete o; } +// QTBUG-13999 +void tst_qdeclarativeecmascript::objectName() +{ + QDeclarativeComponent component(&engine, TEST_FILE("objectName.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + + QCOMPARE(o->property("test1").toString(), QString("hello")); + QCOMPARE(o->property("test2").toString(), QString("ell")); + + o->setObjectName("world"); + + QCOMPARE(o->property("test1").toString(), QString("world")); + QCOMPARE(o->property("test2").toString(), QString("orl")); + + delete o; +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" -- cgit v0.12 From e67800d9e0dc82a38b01c9b8eff4dc1a10f306d8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 11 Oct 2010 13:29:04 +1000 Subject: Test for absent qmldir Task-number: QTBUG-13051 --- .../qtest/declarative/qmllanguage/noqmldir/Test.qml | 2 ++ .../auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp | 1 + 2 files changed, 3 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/noqmldir/Test.qml diff --git a/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/noqmldir/Test.qml b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/noqmldir/Test.qml new file mode 100644 index 0000000..0b054d0 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/qtest/declarative/qmllanguage/noqmldir/Test.qml @@ -0,0 +1,2 @@ +import QtQuick 1.0 +Rectangle { } diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 6a45957..be04dee 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -1569,6 +1569,7 @@ void tst_qdeclarativelanguage::basicRemote_data() QString serverdir = "http://127.0.0.1:14447/qtest/declarative/qmllanguage/"; QTest::newRow("no need for qmldir") << QUrl(serverdir+"Test.qml") << "" << ""; + QTest::newRow("absent qmldir") << QUrl(serverdir+"/noqmldir/Test.qml") << "" << ""; QTest::newRow("need qmldir") << QUrl(serverdir+"TestLocal.qml") << "" << ""; } -- cgit v0.12 From 9849d8f5f1c0c3f03d3f83cc51eea2beb3d9cbbc Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 11 Oct 2010 18:07:35 +1000 Subject: Fix autotest on windows --- src/declarative/qml/qdeclarativeengine.cpp | 12 ++++++++++++ .../tst_qdeclarativemoduleplugin.cpp | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 7ed925a..d768882 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -2196,7 +2196,19 @@ bool QDeclarative_isFileCaseCorrect(const QString &fileName) QFileInfo info(fileName); QString absolute = info.absoluteFilePath(); + +#if defined(Q_OS_MAC) QString canonical = info.canonicalFilePath(); +#elif defined(Q_OS_WIN) + wchar_t buffer[1024]; + + DWORD rv = ::GetShortPathName((wchar_t*)absolute.utf16(), buffer, 1024); + if (rv == 0 || rv >= 1024) return true; + rv = ::GetLongPathName(buffer, buffer, 1024); + if (rv == 0 || rv >= 1024) return true; + + QString canonical((QChar *)buffer); +#endif int absoluteLength = absolute.length(); int canonicalLength = canonical.length(); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index 587a86a..51f66a5 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -132,7 +132,12 @@ void tst_qdeclarativemoduleplugin::incorrectPluginCase() QCOMPARE(errors.count(), 1); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) - QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QFileInfo(__FILE__).absoluteDir().filePath("imports/com/nokia/WrongCase/libPluGin.dylib") + QLatin1String("\""); +#if defined(Q_OS_MAC) + QString libname = "libPluGin.dylib"; +#elif defined(Q_OS_WIN) + QString libname = "PluGin.dll"; +#endif + QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QFileInfo(__FILE__).absoluteDir().filePath("imports/com/nokia/WrongCase/" + libname) + QLatin1String("\""); #else QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found"); #endif -- cgit v0.12 From 36438bc216f939acd4e6772847d435e2e77d41c3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 11 Oct 2010 10:48:54 +0200 Subject: Designer: Fix a crash when copying empty page-based containers. Reviewed-by: Jarek Kobus Task-number: QTBUG-14208 --- tools/designer/src/components/formeditor/formwindow.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/designer/src/components/formeditor/formwindow.cpp b/tools/designer/src/components/formeditor/formwindow.cpp index 15775f6..38a0544 100644 --- a/tools/designer/src/components/formeditor/formwindow.cpp +++ b/tools/designer/src/components/formeditor/formwindow.cpp @@ -1683,10 +1683,13 @@ void FormWindow::cut() // for cases like QMainWindow (central widget is an inner container) or QStackedWidget (page is an inner container) QWidget *FormWindow::innerContainer(QWidget *outerContainer) const { - bool isContainer = m_core->widgetDataBase()->isContainer(outerContainer); - if (isContainer) - if (QDesignerContainerExtension *container = qt_extension(m_core->extensionManager(), outerContainer)) - return container->widget(container->currentIndex()); + if (m_core->widgetDataBase()->isContainer(outerContainer)) + if (const QDesignerContainerExtension *container = qt_extension(m_core->extensionManager(), outerContainer)) { + const int currentIndex = container->currentIndex(); + return currentIndex >= 0 ? + container->widget(currentIndex) : + static_cast(0); + } return outerContainer; } @@ -1706,8 +1709,10 @@ QWidget *FormWindow::containerForPaste() const QWidget *containerOfW = findContainer(selection.first(), /* exclude layouts */ true); if (!containerOfW || containerOfW == mainContainer()) break; - // No layouts, must be container + // No layouts, must be container. No empty page-based containers. containerOfW = innerContainer(containerOfW); + if (!containerOfW) + break; if (LayoutInfo::layoutType(m_core, containerOfW) != LayoutInfo::NoLayout || !m_core->widgetDataBase()->isContainer(containerOfW)) break; w = containerOfW; @@ -1716,6 +1721,8 @@ QWidget *FormWindow::containerForPaste() const // and the like as the central widget has the layout). w = innerContainer(w); + if (!w) + return 0; if (LayoutInfo::layoutType(m_core, w) != LayoutInfo::NoLayout) return 0; // Go up via container extension (also includes step from QMainWindow to its central widget) -- cgit v0.12 From 48f18622b6fbfd19ccc77574d3750a8c0c1f6a7d Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 8 Oct 2010 16:59:44 +0100 Subject: Spectrum demo: put binaries into correct locations on Windows Task-number: QTBUG-13483 Reviewed-by: Miikka Heikkinen --- demos/spectrum/3rdparty/fftreal/fftreal.pro | 2 +- demos/spectrum/app/app.pro | 9 ++------- demos/spectrum/spectrum.pri | 12 ++++++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/demos/spectrum/3rdparty/fftreal/fftreal.pro b/demos/spectrum/3rdparty/fftreal/fftreal.pro index 6305af4..e5093ba 100644 --- a/demos/spectrum/3rdparty/fftreal/fftreal.pro +++ b/demos/spectrum/3rdparty/fftreal/fftreal.pro @@ -40,7 +40,7 @@ symbian { macx { CONFIG += lib_bundle } else { - !symbian: DESTDIR = ../.. + !symbian: DESTDIR = ../..$${spectrum_build_dir} } # Install diff --git a/demos/spectrum/app/app.pro b/demos/spectrum/app/app.pro index 4fe8b6d..57be114 100644 --- a/demos/spectrum/app/app.pro +++ b/demos/spectrum/app/app.pro @@ -65,7 +65,7 @@ symbian { LIBS += -F$${fftreal_dir} LIBS += -framework fftreal } else { - LIBS += -L.. + LIBS += -L..$${spectrum_build_dir} LIBS += -lfftreal } } @@ -91,10 +91,8 @@ symbian { DEPLOYMENT += fftreal } } else { + DESTDIR = ..$${spectrum_build_dir} macx { - # Specify directory in which to create spectrum.app bundle - DESTDIR = .. - !contains(DEFINES, DISABLE_FFT) { # Relocate fftreal.framework into spectrum.app bundle framework_dir = ../spectrum.app/Contents/Frameworks @@ -110,9 +108,6 @@ symbian { ../spectrum.app/Contents/MacOS/spectrum } } else { - # Specify directory in which to create spectrum application - DESTDIR = .. - unix: { # Provide relative path from application to fftreal library QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN diff --git a/demos/spectrum/spectrum.pri b/demos/spectrum/spectrum.pri index c09aa0d..5773900 100644 --- a/demos/spectrum/spectrum.pri +++ b/demos/spectrum/spectrum.pri @@ -35,3 +35,15 @@ DEFINES += SPECTRUM_ANALYSER_SEPARATE_THREAD # Suppress warnings about strncpy potentially being unsafe, emitted by MSVC win32: DEFINES += _CRT_SECURE_NO_WARNINGS +win32 { + # spectrum_build_dir is defined with a leading slash so that it can + # be used in contexts such as + # ..$${spectrum_build_dir} + # without the result having a trailing slash where spectrum_build_dir + # is undefined. + spectrum_build_dir = /release + if (!debug_and_release|build_pass): CONFIG(debug, debug|release) { + spectrum_build_dir = /debug + } +} + -- cgit v0.12 From 3c2296647d2e7ddda4df6679a622b0bf46b34c35 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Fri, 8 Oct 2010 15:10:56 +0100 Subject: Spectrum demo: only use --rpath for linux-g++* mkspecs Task-number: QTBUG-13940 Reviewed-by: Martin Pejcoch --- demos/spectrum/app/app.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/spectrum/app/app.pro b/demos/spectrum/app/app.pro index 57be114..b3ff227 100644 --- a/demos/spectrum/app/app.pro +++ b/demos/spectrum/app/app.pro @@ -108,7 +108,7 @@ symbian { ../spectrum.app/Contents/MacOS/spectrum } } else { - unix: { + linux-g++*: { # Provide relative path from application to fftreal library QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN } -- cgit v0.12 From c27f1586d7c4c56af1f46fa09ad77f03b7736e5d Mon Sep 17 00:00:00 2001 From: mread Date: Fri, 8 Oct 2010 15:31:09 +0100 Subject: Making the hybrid allocator change compatible across all 4.7.x The hybrid allocator introduced a new export to qtcore.dll and made all apps link to it when they linked with the corresponding qtmain.lib. However, this made all apps depend on this new export, and since that export is not present in early 4.7.x release, these apps would not run with the Qt DLLs from those releases, which breaks Qt's compatibility guarantees for patch releases. This change makes apps compatible with all 4.7.x releases again. For export frozen Qt builds (the sort that should be compatible across all 4.7.x releases), qtmain.lib no longer forces a static import link to qt_symbian_SetupThreadHeap(). Instead it dynamically loads qtcore.dll, looks up qt_symbian_SetupThreadHeap(), and calls it if present. If the function is not present, or on emulator builds where we know that qtcore will use the system allocator creation function, we call the system allocator creation function. For export unfrozen builds, there is no compatibility between builds or releases, so we do use a static import link to qt_symbian_SetupThreadHeap(), as we have to use the qtcore dll we have built with it anyway. This has been tested as follows: S60 3.1 SDK, def files not frozen. App compiled against latest code runs on the corresponding DLLs, and does not start with 4.7.0, which is what we expect. S60 3.2 SDK, def files frozen. App compiled against latest code runs on the corresponding DLLs with the new allocator, and runs on 4.7.0 DLLs with the old allocator. Which demonstrates compatibility. S60 5.0 SDK, def files not frozen, debug build. Same result as for the 3.1 SDK, which demonstrates debug build working too (all other tests are release build tests). S60 5.0 SDK, def files frozen, debug build. Same result as on S60 3.2 SDK, which demonstrates debug build working with def files. Symbian^3 SDK, def files frozen. Same result as on S60 3.2 SDK, demonstrating Symbian^3 compatibility. Symbian^4, code and tests compile and does not affect running. *** This change is only required for 4.7. It is not needed for 4.8+ *** *** If this change appears in 4.8+, it can be reverted. *** Task-number: QT-4080 Reviewed-by: Shane Kearns --- src/s60main/newallocator_hook.cpp | 87 ++++++++++++++++++++++++++++++++++++++- src/s60main/s60main.pro | 3 ++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/s60main/newallocator_hook.cpp b/src/s60main/newallocator_hook.cpp index 9cc6afb..9ea2ef0 100644 --- a/src/s60main/newallocator_hook.cpp +++ b/src/s60main/newallocator_hook.cpp @@ -41,6 +41,11 @@ #include #include +#ifdef QT_EXPORTS_NOT_FROZEN +// If exports in Qt DLLs are not frozen in this build, then we have to pick up the +// allocator creation function by import link. We know the function will be present +// in the DLLs we test with, as we have to use the DLLs we have built. + struct SStdEpocThreadCreateInfo; Q_CORE_EXPORT TInt qt_symbian_SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo); @@ -51,8 +56,88 @@ Q_CORE_EXPORT TInt qt_symbian_SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCre * Uses link-time symbol preemption to capture a call from the application * startup. On return, there is some kind of heap allocator installed on the * thread. -*/ +*/ TInt UserHeap::SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo) { return qt_symbian_SetupThreadHeap(aNotFirst, aInfo); } + +#else // QT_EXPORTS_NOT_FROZEN +// If we are using an export frozen build, it should be compatible with all 4.7.x Qt releases. +// We want to use the allocator creation function introduced in qtcore.dll after 4.7.1. But we +// can't import link to it, as it may not be present in whatever 4.7.x DLLs we are running with. +// So the function is found and called dynamically, by library lookup. If it is not found, we +// use the OS allocator creation functions instead. + +struct SThreadCreateInfo + { + TAny* iHandle; + TInt iType; + TThreadFunction iFunction; + TAny* iPtr; + TAny* iSupervisorStack; + TInt iSupervisorStackSize; + TAny* iUserStack; + TInt iUserStackSize; + TInt iInitialThreadPriority; + TPtrC iName; + TInt iTotalSize; // Size including any extras (must be a multiple of 8 bytes) + }; + +struct SStdEpocThreadCreateInfo : public SThreadCreateInfo + { + RAllocator* iAllocator; + TInt iHeapInitialSize; + TInt iHeapMaxSize; + TInt iPadding; // Make structure size a multiple of 8 bytes + }; + + +/* \internal + * + * Uses link-time symbol preemption to capture a call from the application + * startup. On return, there is some kind of heap allocator installed on the + * thread. +*/ +TInt UserHeap::SetupThreadHeap(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo) +{ + TInt r = KErrNone; + +#ifndef __WINS__ + // attempt to create the fast allocator through a known export ordinal in qtcore.dll + RLibrary qtcore; + if (qtcore.Load(_L("qtcore.dll")) == KErrNone) + { + const int qt_symbian_SetupThreadHeap_eabi_ordinal = 3713; + TLibraryFunction libFunc = qtcore.Lookup(qt_symbian_SetupThreadHeap_eabi_ordinal); + if (libFunc) + { + typedef int (*TSetupThreadHeapFunc)(TBool aNotFirst, SStdEpocThreadCreateInfo& aInfo); + TSetupThreadHeapFunc p_qt_symbian_SetupThreadHeap = TSetupThreadHeapFunc(libFunc); + r = (*p_qt_symbian_SetupThreadHeap)(aNotFirst, aInfo); + } + qtcore.Close(); + if (libFunc) + return r; + } +#endif + + // no fast allocator support - use default allocator creation + if (!aInfo.iAllocator && aInfo.iHeapInitialSize>0) + { + // new heap required + RHeap* pH = NULL; + r = UserHeap::CreateThreadHeap(aInfo, pH); + } + else if (aInfo.iAllocator) + { + // sharing a heap + RAllocator* pA = aInfo.iAllocator; + pA->Open(); + User::SwitchAllocator(pA); + r = KErrNone; + } + return r; +} + +#endif // QT_EXPORTS_NOT_FROZEN diff --git a/src/s60main/s60main.pro b/src/s60main/s60main.pro index 664f155..8ab3bd3 100644 --- a/src/s60main/s60main.pro +++ b/src/s60main/s60main.pro @@ -31,6 +31,9 @@ symbian { # against GCCE apps, so remove it MMP_RULES -= $$MMP_RULES_DONT_EXPORT_ALL_CLASS_IMPEDIMENTA linux-armcc:QMAKE_CXXFLAGS *= --export_all_vtbl + + # Flag if exports are not frozen to avoid lookup of qtcore allocator creation function by ordinal + contains(CONFIG, def_files_disabled): DEFINES += QT_EXPORTS_NOT_FROZEN } else { error("$$_FILE_ is intended only for Symbian!") } -- cgit v0.12 From 062b8cfa9b1ece569fe2a8ae18230c862ca6f857 Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Mon, 11 Oct 2010 15:14:56 +0200 Subject: Moved the property documentation to its proper location. Task-number: QTBUG-14351 Reviewed-by: David Boddie --- src/gui/graphicsview/qgraphicswidget.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 1bfe266..4a733be 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -750,6 +750,22 @@ QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c /*! \property QGraphicsWidget::layout \brief The layout of the widget + + Any existing layout manager is deleted before the new layout is assigned. If + \a layout is 0, the widget is left without a layout. Existing subwidgets' + geometries will remain unaffected. + + QGraphicsWidget takes ownership of \a layout. + + All widgets that are currently managed by \a layout or all of its + sublayouts, are automatically reparented to this item. The layout is then + invalidated, and the child widget geometries are adjusted according to + this item's geometry() and contentsMargins(). Children who are not + explicitly managed by \a layout remain unaffected by the layout after + it has been assigned to this widget. + + If no layout is currently managing this widget, layout() will return 0. + */ /*! -- cgit v0.12 From 0644896a666b1215dad9c04d73dd44f03554060d Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Mon, 11 Oct 2010 16:00:22 +0200 Subject: Added the default format of QTime::toString(). Task-number: QTBUG-13710 Reviewed-by: David Boddie --- src/corelib/tools/qdatetime.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index ab7530d..c252e64 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -1630,6 +1630,7 @@ QString QTime::toString(Qt::DateFormat format) const \endtable If the datetime is invalid, an empty string will be returned. + If \a format is empty, the default format "hh:mm:ss" is used. \sa QDate::toString() QDateTime::toString() */ -- cgit v0.12 From ef7df41b11c4f5e026b85ca9b02a9c05b427a301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 8 Oct 2010 15:33:25 +0200 Subject: Compile fix for OpenVG without VGFont. ShivaVG doesn't have VGFont support for example. Reviewed-by: Jason Barron --- src/openvg/qpaintengine_vg.cpp | 9 ++------- src/openvg/qvg_p.h | 5 +++++ src/openvg/qvgfontglyphcache_p.h | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp index f6d2435..ce9d11a 100644 --- a/src/openvg/qpaintengine_vg.cpp +++ b/src/openvg/qpaintengine_vg.cpp @@ -61,11 +61,6 @@ QT_BEGIN_NAMESPACE -// vgDrawGlyphs() only exists in OpenVG 1.1 and higher. -#if !defined(OPENVG_VERSION_1_1) && !defined(QVG_NO_DRAW_GLYPHS) -#define QVG_NO_DRAW_GLYPHS 1 -#endif - // vgRenderToMask() only exists in OpenVG 1.1 and higher. // Also, disable masking completely if we are using the scissor to clip. #if !defined(OPENVG_VERSION_1_1) && !defined(QVG_NO_RENDER_TO_MASK) @@ -75,11 +70,11 @@ QT_BEGIN_NAMESPACE #define QVG_NO_RENDER_TO_MASK 1 #endif -#if !defined(QVG_NO_DRAW_GLYPHS) - // use the same rounding as in qrasterizer.cpp (6 bit fixed point) static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; +#if !defined(QVG_NO_DRAW_GLYPHS) + Q_DECL_IMPORT extern int qt_defaultDpiX(); Q_DECL_IMPORT extern int qt_defaultDpiY(); diff --git a/src/openvg/qvg_p.h b/src/openvg/qvg_p.h index 51abbee..94d1eae 100644 --- a/src/openvg/qvg_p.h +++ b/src/openvg/qvg_p.h @@ -55,6 +55,11 @@ // We mean it. // +// vgDrawGlyphs() only exists in OpenVG 1.1 and higher. +#if !defined(OPENVG_VERSION_1_1) && !defined(QVG_NO_DRAW_GLYPHS) +#define QVG_NO_DRAW_GLYPHS 1 +#endif + #include #if !defined(QT_NO_EGL) diff --git a/src/openvg/qvgfontglyphcache_p.h b/src/openvg/qvgfontglyphcache_p.h index b32a873..8bcdcc7 100644 --- a/src/openvg/qvgfontglyphcache_p.h +++ b/src/openvg/qvgfontglyphcache_p.h @@ -56,10 +56,14 @@ #include #include +#include + QT_BEGIN_NAMESPACE class QVGPaintEnginePrivate; +#ifndef QVG_NO_DRAW_GLYPHS + class QVGFontGlyphCache { public: @@ -90,6 +94,8 @@ public: }; #endif +#endif + QT_END_NAMESPACE #endif // QVGFONTGLYPHCACHE_H -- cgit v0.12 From 650a0078e2cef43eff107fe8d2505f64a0bfedf0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 12 Oct 2010 13:11:38 +1000 Subject: Update sections if model content changes. We didn't handle the section property changing, e.g. due to asynchronous model. Task-number: QT-4093 Reviewed-by: Aaron Kennedy --- .../graphicsitems/qdeclarativelistview.cpp | 40 ++++++++++++++++++++-- .../graphicsitems/qdeclarativelistview_p.h | 2 ++ .../graphicsitems/qdeclarativevisualitemmodel.cpp | 21 ++++++++++++ .../graphicsitems/qdeclarativevisualitemmodel_p.h | 4 +++ .../tst_qdeclarativelistview.cpp | 11 ++++++ 5 files changed, 75 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 4943aef..6fd3b71 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -775,7 +775,6 @@ void QDeclarativeListViewPrivate::layout() setPosition(0); return; } - updateSections(); if (!visibleItems.isEmpty()) { qreal oldEnd = visibleItems.last()->endPosition(); qreal pos = visibleItems.first()->endPosition() + spacing + 1; @@ -934,6 +933,7 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem) return; if (listItem->attached->m_prevSection != listItem->attached->m_section) { if (!listItem->section) { + qreal pos = listItem->position(); int i = sectionCacheSize-1; while (i >= 0 && !sectionCache[i]) --i; @@ -961,8 +961,10 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem) delete context; } } + listItem->setPosition(pos); } } else if (listItem->section) { + qreal pos = listItem->position(); int i = 0; do { if (!sectionCache[i]) { @@ -975,12 +977,13 @@ void QDeclarativeListViewPrivate::createSection(FxListItem *listItem) } while (i < sectionCacheSize); delete listItem->section; listItem->section = 0; + listItem->setPosition(pos); } } void QDeclarativeListViewPrivate::updateSections() { - if (sectionCriteria) { + if (sectionCriteria && !visibleItems.isEmpty()) { QString prevSection; if (visibleIndex > 0) prevSection = sectionAt(visibleIndex-1); @@ -990,6 +993,8 @@ void QDeclarativeListViewPrivate::updateSections() if (visibleItems.at(i)->index != -1) { QDeclarativeListViewAttached *attached = visibleItems.at(i)->attached; attached->setPrevSection(prevSection); + QString propValue = model->stringValue(visibleItems.at(i)->index, sectionCriteria->property()); + attached->setSection(sectionCriteria->sectionString(propValue)); if (prevAtt) prevAtt->setNextSection(attached->section()); createSection(visibleItems.at(i)); @@ -1560,6 +1565,7 @@ void QDeclarativeListView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); disconnect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); disconnect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); + disconnect(d->model, SIGNAL(itemsChanged(int,int)), this, SLOT(itemsChanged(int,int))); disconnect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); disconnect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); @@ -1590,6 +1596,7 @@ void QDeclarativeListView::setModel(const QVariant &model) if (d->model) { d->bufferMode = QDeclarativeListViewPrivate::BufferBefore | QDeclarativeListViewPrivate::BufferAfter; if (isComponentComplete()) { + updateSections(); refill(); if (d->currentIndex >= d->model->count() || d->currentIndex < 0) { setCurrentIndex(0); @@ -1605,6 +1612,7 @@ void QDeclarativeListView::setModel(const QVariant &model) connect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); connect(d->model, SIGNAL(itemsRemoved(int,int)), this, SLOT(itemsRemoved(int,int))); connect(d->model, SIGNAL(itemsMoved(int,int,int)), this, SLOT(itemsMoved(int,int,int))); + connect(d->model, SIGNAL(itemsChanged(int,int)), this, SLOT(itemsChanged(int,int))); connect(d->model, SIGNAL(modelReset()), this, SLOT(modelReset())); connect(d->model, SIGNAL(createdItem(int, QDeclarativeItem*)), this, SLOT(createdItem(int,QDeclarativeItem*))); connect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); @@ -1662,6 +1670,7 @@ void QDeclarativeListView::setDelegate(QDeclarativeComponent *delegate) d->visibleItems.clear(); d->releaseItem(d->currentItem); d->currentItem = 0; + updateSections(); refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); @@ -2075,8 +2084,10 @@ void QDeclarativeListView::setCacheBuffer(int b) QDeclarativeViewSection *QDeclarativeListView::sectionCriteria() { Q_D(QDeclarativeListView); - if (!d->sectionCriteria) + if (!d->sectionCriteria) { d->sectionCriteria = new QDeclarativeViewSection(this); + connect(d->sectionCriteria, SIGNAL(propertyChanged()), this, SLOT(updateSections())); + } return d->sectionCriteria; } @@ -2669,6 +2680,7 @@ void QDeclarativeListView::componentComplete() { Q_D(QDeclarativeListView); QDeclarativeFlickable::componentComplete(); + updateSections(); if (d->isValid()) { refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; @@ -2685,6 +2697,18 @@ void QDeclarativeListView::componentComplete() } } +void QDeclarativeListView::updateSections() +{ + Q_D(QDeclarativeListView); + if (isComponentComplete() && d->model) { + QList roles; + if (d->sectionCriteria && !d->sectionCriteria->property().isEmpty()) + roles << d->sectionCriteria->property().toUtf8(); + d->model->setWatchedRoles(roles); + d->updateSections(); + } +} + void QDeclarativeListView::refill() { Q_D(QDeclarativeListView); @@ -2894,6 +2918,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) for (int j = 0; j < added.count(); ++j) added.at(j)->attached->emitAdd(); + d->updateSections(); d->itemCount += count; emit countChanged(); } @@ -2986,6 +3011,7 @@ void QDeclarativeListView::itemsRemoved(int modelIndex, int count) } } + d->updateSections(); emit countChanged(); } @@ -3107,6 +3133,14 @@ void QDeclarativeListView::itemsMoved(int from, int to, int count) // Ensure we don't cause an ugly list scroll. d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy); + d->updateSections(); + d->layout(); +} + +void QDeclarativeListView::itemsChanged(int, int) +{ + Q_D(QDeclarativeListView); + d->updateSections(); d->layout(); } diff --git a/src/declarative/graphicsitems/qdeclarativelistview_p.h b/src/declarative/graphicsitems/qdeclarativelistview_p.h index 735b248..2678b90 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview_p.h +++ b/src/declarative/graphicsitems/qdeclarativelistview_p.h @@ -250,11 +250,13 @@ protected: virtual void componentComplete(); private Q_SLOTS: + void updateSections(); void refill(); void trackedPositionChanged(); void itemsInserted(int index, int count); void itemsRemoved(int index, int count); void itemsMoved(int from, int to, int count); + void itemsChanged(int index, int count); void modelReset(); void destroyRemoved(); void createdItem(int index, QDeclarativeItem *item); diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 439f500..e569dd2 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -403,6 +403,8 @@ public: QDeclarativeListAccessor *m_listAccessor; QModelIndex m_root; + QList watchedRoles; + QList watchedRoleIds; }; class QDeclarativeVisualDataModelDataMetaObject : public QDeclarativeOpenMetaObject @@ -1170,10 +1172,25 @@ int QDeclarativeVisualDataModel::indexOf(QDeclarativeItem *item, QObject *) cons return -1; } +void QDeclarativeVisualDataModel::setWatchedRoles(QList roles) +{ + Q_D(QDeclarativeVisualDataModel); + d->watchedRoles = roles; + d->watchedRoleIds.clear(); +} + void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, const QList &roles) { Q_D(QDeclarativeVisualDataModel); + bool changed = false; + if (!d->watchedRoles.isEmpty() && d->watchedRoleIds.isEmpty()) { + foreach (QByteArray r, d->watchedRoles) { + if (d->m_roleNames.contains(r)) + d->watchedRoleIds << d->m_roleNames.value(r); + } + } + for (QHash::ConstIterator iter = d->m_cache.begin(); iter != d->m_cache.end(); ++iter) { const int idx = iter.key(); @@ -1183,6 +1200,8 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, QDeclarativeVisualDataModelData *data = d->data(objRef.obj); for (int roleIdx = 0; roleIdx < roles.count(); ++roleIdx) { int role = roles.at(roleIdx); + if (!changed && !d->watchedRoleIds.isEmpty() && d->watchedRoleIds.contains(role)) + changed = true; int propId = data->propForRole(role); if (propId != -1) { if (data->hasValue(propId)) { @@ -1217,6 +1236,8 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, } } } + if (changed) + emit itemsChanged(index, count); } void QDeclarativeVisualDataModel::_q_itemsInserted(int index, int count) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h index f09d8dd..5e187c2 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel_p.h @@ -79,6 +79,7 @@ public: virtual bool completePending() const = 0; virtual void completeItem() = 0; virtual QString stringValue(int, const QString &) = 0; + virtual void setWatchedRoles(QList roles) = 0; virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const = 0; @@ -87,6 +88,7 @@ Q_SIGNALS: void itemsInserted(int index, int count); void itemsRemoved(int index, int count); void itemsMoved(int from, int to, int count); + void itemsChanged(int index, int count); void modelReset(); void createdItem(int index, QDeclarativeItem *item); void destroyingItem(QDeclarativeItem *item); @@ -120,6 +122,7 @@ public: virtual bool completePending() const; virtual void completeItem(); virtual QString stringValue(int index, const QString &role); + virtual void setWatchedRoles(QList) {} virtual int indexOf(QDeclarativeItem *item, QObject *objectContext) const; @@ -174,6 +177,7 @@ public: bool completePending() const; void completeItem(); virtual QString stringValue(int index, const QString &role); + virtual void setWatchedRoles(QList roles); int indexOf(QDeclarativeItem *item, QObject *objectContext) const; diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 65ff635..7a58773 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -985,6 +985,17 @@ void tst_QDeclarativeListView::sections() QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 20.0); + // check that headers change when item changes + listview->setContentY(0); + model.modifyItem(0, "changed", "2"); + + canvas->show(); + qApp->exec(); + + item = findItem(contentItem, "wrapper", 1); + QTRY_VERIFY(item); + QTRY_COMPARE(item->height(), 40.0); + delete canvas; } -- cgit v0.12 From e4dbf0c82b46e7a32e21185c8f633506229be944 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Tue, 12 Oct 2010 14:35:22 +1000 Subject: Bug: TextEdit ignores plain text format when pasting text Task-number: QTBUG-14003 Reviewed-by: Michael Brasser --- .../graphicsitems/qdeclarativetextedit.cpp | 1 + .../tst_qdeclarativetextedit.cpp | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index 6f5608a..e05f4e4 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -319,6 +319,7 @@ void QDeclarativeTextEdit::setTextFormat(TextFormat format) updateSize(); } d->format = format; + d->control->setAcceptRichText(d->format != PlainText); emit textFormatChanged(d->format); } diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index 472c5ef..a7971cc 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -56,6 +56,8 @@ #include #include #include +#include +#include #include #include @@ -119,6 +121,8 @@ private slots: void openInputPanelOnClick(); void openInputPanelOnFocus(); void geometrySignals(); + void pastingRichText_QTBUG_14003(); + private: void simulateKey(QDeclarativeView *, int key); QDeclarativeView *createView(const QString &filename); @@ -1174,6 +1178,27 @@ void tst_qdeclarativetextedit::geometrySignals() delete o; } +void tst_qdeclarativetextedit::pastingRichText_QTBUG_14003() +{ +#ifndef QT_NO_CLIPBOARD + QString componentStr = "import QtQuick 1.0\nTextEdit { textFormat: TextEdit.PlainText }"; + QDeclarativeComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeTextEdit *obj = qobject_cast(component.create()); + + QTRY_VERIFY(obj != 0); + QTRY_VERIFY(obj->textFormat() == QDeclarativeTextEdit::PlainText); + + QMimeData *mData = new QMimeData; + mData->setHtml("Hello"); + QApplication::clipboard()->setMimeData(mData); + + obj->paste(); + QTRY_VERIFY(obj->text() == ""); + QTRY_VERIFY(obj->textFormat() == QDeclarativeTextEdit::PlainText); +#endif +} + QTEST_MAIN(tst_qdeclarativetextedit) #include "tst_qdeclarativetextedit.moc" -- cgit v0.12 From 99390f4d639e35f3b0606df4d2abbcd3879f128f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 12 Oct 2010 16:06:07 +1000 Subject: Compile on MSVC2008 --- src/declarative/qml/qdeclarativeengine.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index d768882..ec583f9 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -105,6 +105,7 @@ #ifdef Q_OS_WIN // for %APPDATA% #include #include +#include #define CSIDL_APPDATA 0x001a // \Application Data #endif @@ -2202,9 +2203,7 @@ bool QDeclarative_isFileCaseCorrect(const QString &fileName) #elif defined(Q_OS_WIN) wchar_t buffer[1024]; - DWORD rv = ::GetShortPathName((wchar_t*)absolute.utf16(), buffer, 1024); - if (rv == 0 || rv >= 1024) return true; - rv = ::GetLongPathName(buffer, buffer, 1024); + DWORD rv = ::GetLongPathName((wchar_t*)absolute.utf16(), buffer, 1024); if (rv == 0 || rv >= 1024) return true; QString canonical((QChar *)buffer); -- cgit v0.12 From 912085070b97af83a88d7de181cb0c5ef946589c Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Tue, 12 Oct 2010 17:14:15 +1000 Subject: Update QtCore def files --- src/s60installs/bwins/QtCoreu.def | 1 + src/s60installs/eabi/QtCoreu.def | 1 + 2 files changed, 2 insertions(+) diff --git a/src/s60installs/bwins/QtCoreu.def b/src/s60installs/bwins/QtCoreu.def index 5eeb244..f4e3a28 100644 --- a/src/s60installs/bwins/QtCoreu.def +++ b/src/s60installs/bwins/QtCoreu.def @@ -4483,4 +4483,5 @@ EXPORTS ?msecsSinceReference@QElapsedTimer@@QBE_JXZ @ 4482 NONAME ; long long QElapsedTimer::msecsSinceReference(void) const ?selectThread@QEventDispatcherSymbian@@AAEAAVQSelectThread@@XZ @ 4483 NONAME ; class QSelectThread & QEventDispatcherSymbian::selectThread(void) ?qt_symbian_SetupThreadHeap@@YAHHAAUSStdEpocThreadCreateInfo@@@Z @ 4484 NONAME ; int qt_symbian_SetupThreadHeap(int, struct SStdEpocThreadCreateInfo &) + ?objectNameChanged@QAbstractDeclarativeData@@2P6AXPAV1@PAVQObject@@@ZA @ 4485 NONAME ; void (*QAbstractDeclarativeData::objectNameChanged)(class QAbstractDeclarativeData *, class QObject *) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index f496839..eb53dca 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3712,4 +3712,5 @@ EXPORTS _ZltRK13QElapsedTimerS1_ @ 3711 NONAME _ZrsR11QDataStreamR12QEasingCurve @ 3712 NONAME _Z26qt_symbian_SetupThreadHeapiR24SStdEpocThreadCreateInfo @ 3713 NONAME + _ZN24QAbstractDeclarativeData17objectNameChangedE @ 3714 NONAME DATA 4 -- cgit v0.12 From c284a54ac24b6ff800b66c193016cc98d6305293 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Tue, 12 Oct 2010 17:14:33 +1000 Subject: Update QtDeclarative def files --- src/s60installs/bwins/QtDeclarativeu.def | 1 + src/s60installs/eabi/QtDeclarativeu.def | 1 + 2 files changed, 2 insertions(+) diff --git a/src/s60installs/bwins/QtDeclarativeu.def b/src/s60installs/bwins/QtDeclarativeu.def index cf0398a..b72147e 100644 --- a/src/s60installs/bwins/QtDeclarativeu.def +++ b/src/s60installs/bwins/QtDeclarativeu.def @@ -1838,4 +1838,5 @@ EXPORTS ?addChanged@QDeclarativeBasePositioner@@IAEXXZ @ 1837 NONAME ; void QDeclarativeBasePositioner::addChanged(void) ?start@QDeclarativeAbstractAnimation@@QAEXXZ @ 1838 NONAME ; void QDeclarativeAbstractAnimation::start(void) ?qt_metacall@QDeclarativeAbstractAnimation@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1839 NONAME ; int QDeclarativeAbstractAnimation::qt_metacall(enum QMetaObject::Call, int, void * *) + ?connect@QDeclarativePropertyPrivate@@SA_NPBVQObject@@H0HHPAH@Z @ 1840 NONAME ; bool QDeclarativePropertyPrivate::connect(class QObject const *, int, class QObject const *, int, int, int *) diff --git a/src/s60installs/eabi/QtDeclarativeu.def b/src/s60installs/eabi/QtDeclarativeu.def index d4084cc..cbfafdc 100644 --- a/src/s60installs/eabi/QtDeclarativeu.def +++ b/src/s60installs/eabi/QtDeclarativeu.def @@ -1883,4 +1883,5 @@ EXPORTS _ZThn8_N29QDeclarativeAbstractAnimation9setTargetERK20QDeclarativeProperty @ 1882 NONAME _ZThn8_N29QDeclarativeAbstractAnimationD0Ev @ 1883 NONAME _ZThn8_N29QDeclarativeAbstractAnimationD1Ev @ 1884 NONAME + _ZN27QDeclarativePropertyPrivate7connectEPK7QObjectiS2_iiPi @ 1885 NONAME -- cgit v0.12 From 1113344ece060bb7386ea540becbf59f9c8320ea Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 8 Oct 2010 11:39:49 +0200 Subject: Crash fix when using the runtime graphics system on Symbian. If QWidget::destroy() is called (perhaps by setParent) then the window surface is deleted by the destructor of QSymbianControl instead of in the "normal" place which is ~QWidget(). This means that we should not attempt to use the RWindow in the window surface because it is in the process of being destroyed. Reviewed-by: Jani Hautakangas --- src/gui/painting/qwindowsurface_s60.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp index 8bac1f5..ea19fcd 100644 --- a/src/gui/painting/qwindowsurface_s60.cpp +++ b/src/gui/painting/qwindowsurface_s60.cpp @@ -101,9 +101,11 @@ QS60WindowSurface::~QS60WindowSurface() // Issue empty redraw to clear the UI surface QWidget *w = window(); - RWindow *const window = static_cast(w->winId()->DrawableWindow()); - window->BeginRedraw(); - window->EndRedraw(); + if (w->testAttribute(Qt::WA_WState_Created)) { + RWindow *const window = static_cast(w->winId()->DrawableWindow()); + window->BeginRedraw(); + window->EndRedraw(); + } } } #endif -- cgit v0.12 From edddadd88950f22f6d813e50acdcf2711d3d5a84 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Tue, 12 Oct 2010 10:58:11 +0200 Subject: Add support for Qt::WA_TranslucentBackground with OpenVG on Symbian^3 S^3 does not have a client side API to support semi-transparent EGL surfaces so if this flag is enabled for a particular widget, then we should return a raster surface instead of a VG surface. Raster surfaces can still be semi-transparent but will be slower to render to. Task-number: QTBUG-14400 Reviewed-by: Jani Hautakangas Reviewed-by: Gareth Stockwell Reviewed-by: Sami Merila --- src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp index 2c7c0b7..9674233 100644 --- a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp +++ b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp @@ -42,6 +42,9 @@ #include "qgraphicssystem_vg_p.h" #include #include +#if defined(Q_OS_SYMBIAN) && !defined(Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE) +#include +#endif QT_BEGIN_NAMESPACE @@ -64,6 +67,11 @@ QPixmapData *QVGGraphicsSystem::createPixmapData(QPixmapData::PixelType type) co QWindowSurface *QVGGraphicsSystem::createWindowSurface(QWidget *widget) const { +#if defined(Q_OS_SYMBIAN) && !defined(Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE) + QWidgetPrivate *d = qt_widget_private(widget); + if (!d->isOpaque && widget->testAttribute(Qt::WA_TranslucentBackground)) + return d->createDefaultWindowSurface_sys(); +#endif return new QVGWindowSurface(widget); } -- cgit v0.12 From 71de6cd879f2f79900bda83cc4ba48f6df051d66 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Tue, 12 Oct 2010 12:41:26 +0300 Subject: Fix for CFbsBitmap to QPixmap conversion. Symbian bitmap formats may have different scanline length when compared to QImage formats. We need to define scanline length for intermediate QImage when converting from CFbsBitmap to QPixmap. Task-number: QTBUG-14218 Reviewed-by: Jason Barron --- src/gui/image/qpixmap_s60.cpp | 3 ++- src/openvg/qvg_symbian.cpp | 3 ++- tests/auto/qpixmap/tst_qpixmap.cpp | 11 +++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 47249d9..b7c8acb 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -968,11 +968,12 @@ void QS60PixmapData::fromNativeType(void* pixmap, NativeType nativeType) if (needsCopy) { TSize size = sourceBitmap->SizeInPixels(); + int bytesPerLine = sourceBitmap->ScanLineLength(size.iWidth, displayMode); QSymbianBitmapDataAccess da; da.beginDataAccess(sourceBitmap); uchar *bytes = (uchar*)sourceBitmap->DataAddress(); - QImage img = QImage(bytes, size.iWidth, size.iHeight, format); + QImage img = QImage(bytes, size.iWidth, size.iHeight, bytesPerLine, format); img = img.copy(); da.endDataAccess(sourceBitmap); diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp index a9625b2..41b35fc 100644 --- a/src/openvg/qvg_symbian.cpp +++ b/src/openvg/qvg_symbian.cpp @@ -185,10 +185,11 @@ void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) QImage::Format format = qt_TDisplayMode2Format(displayMode); TSize size = bitmap->SizeInPixels(); + int bytesPerLine = bitmap->ScanLineLength(size.iWidth, displayMode); bitmap->BeginDataAccess(); uchar *bytes = (uchar*)bitmap->DataAddress(); - QImage img = QImage(bytes, size.iWidth, size.iHeight, format); + QImage img = QImage(bytes, size.iWidth, size.iHeight, bytesPerLine, format); img = img.copy(); bitmap->EndDataAccess(); diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 24cbb21..fdf8311 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -1160,6 +1160,8 @@ void tst_QPixmap::fromSymbianCFbsBitmap_data() const int smallHeight = 20; const int largeWidth = 240; const int largeHeight = 320; + const int notAlignedWidth = 250; + const int notAlignedHeight = 250; // Indexed Color Formats - Disabled since images seem to be blank -> no palette? // QTest::newRow("EGray2 small") << EGray2 << smallWidth << smallHeight << QColor(Qt::black); @@ -1172,14 +1174,19 @@ void tst_QPixmap::fromSymbianCFbsBitmap_data() // Direct Color Formats QTest::newRow("EColor4K small") << EColor4K << smallWidth << smallHeight << QColor(Qt::red); QTest::newRow("EColor4K big") << EColor4K << largeWidth << largeHeight << QColor(Qt::red); + QTest::newRow("EColor4K not aligned") << EColor4K << notAlignedWidth << notAlignedHeight << QColor(Qt::red); QTest::newRow("EColor64K small") << EColor64K << smallWidth << smallHeight << QColor(Qt::green); QTest::newRow("EColor64K big") << EColor64K << largeWidth << largeHeight << QColor(Qt::green); + QTest::newRow("EColor64K not aligned") << EColor64K << notAlignedWidth << notAlignedHeight << QColor(Qt::green); QTest::newRow("EColor16M small") << EColor16M << smallWidth << smallHeight << QColor(Qt::yellow); QTest::newRow("EColor16M big") << EColor16M << largeWidth << largeHeight << QColor(Qt::yellow); + QTest::newRow("EColor16M not aligned") << EColor16M << notAlignedWidth << notAlignedHeight << QColor(Qt::yellow); QTest::newRow("EColor16MU small") << EColor16MU << smallWidth << smallHeight << QColor(Qt::red); QTest::newRow("EColor16MU big") << EColor16MU << largeWidth << largeHeight << QColor(Qt::red); + QTest::newRow("EColor16MU not aligned") << EColor16MU << notAlignedWidth << notAlignedHeight << QColor(Qt::red); QTest::newRow("EColor16MA small opaque") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0); QTest::newRow("EColor16MA big opaque") << EColor16MA << largeWidth << largeHeight << QColor(255, 255, 0); + QTest::newRow("EColor16MA not aligned opaque") << EColor16MA << notAlignedWidth << notAlignedHeight << QColor(255, 255, 0); // Semi-transparent Colors - Disabled for now, since the QCOMPARE fails, but visually confirmed to work // QTest::newRow("EColor16MA small semi") << EColor16MA << smallWidth << smallHeight << QColor(255, 255, 0, 127); @@ -1237,6 +1244,10 @@ void tst_QPixmap::fromSymbianCFbsBitmap() QColor actualColor(image.pixel(1, 1)); QCOMPARE(actualColor, color); + + QImage shouldBe(pixmap.width(), pixmap.height(), image.format()); + shouldBe.fill(color.rgba()); + QCOMPARE(image, shouldBe); } __UHEAP_MARKEND; -- cgit v0.12 From 61d23b1740780b3c7970c9dd5d089002a35f339e Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 Oct 2010 13:01:42 +0200 Subject: Fix memory leak in QFontEngineS60::addGlyphsToPath() An "Open()"ed RGlyphOutlineIterator needs to be "Close()"d before destroying the iterator. Otherwise some allocated memory does not get freed. The RGlyphOutlineIterator destructor does not close an open iterator. Task-Number: QTBUG-14408 Done-by: Colleague from Nokia, Oulu Reviewed-by: Alessandro Portale --- src/gui/text/qfontengine_s60.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 5980f20..653965e 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -308,6 +308,7 @@ void QFontEngineS60::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, parseGlyphPathData(outlineChar, outlineEnd, *path, fontSizeInPixels, positions[count++].toPointF(), false); } while(KErrNone == iterator.Next() && count <= nglyphs); + iterator.Close(); #else // Q_SYMBIAN_HAS_GLYPHOUTLINE_API QFontEngine::addGlyphsToPath(glyphs, positions, nglyphs, path, flags); #endif //Q_SYMBIAN_HAS_GLYPHOUTLINE_API -- cgit v0.12 From 7cd0a90344d340f22b6b2d3afeef092dbaf2cd51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 12 Oct 2010 12:54:15 +0200 Subject: Revert "Don't define highp/mediump/lowp if desktop GL has them" This reverts commit 6155050f68cc86c445552da61a5f240c16f5e2cd. The GL_ARB_ES2_compatibility extension does not mention the lowp, mediump or highp keywords. Task-number: QTBUG-14384 Reviewed-by: Samuel Reviewed-by: Prasanth --- dist/changes-4.6.4 | 4 +--- src/opengl/qgl.cpp | 3 --- src/opengl/qgl_p.h | 3 +-- src/opengl/qglshaderprogram.cpp | 10 ++-------- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/dist/changes-4.6.4 b/dist/changes-4.6.4 index 389aa3a..3949b9a 100644 --- a/dist/changes-4.6.4 +++ b/dist/changes-4.6.4 @@ -66,8 +66,6 @@ QtOpenGL - QGLShaderProgram * [QTBUG-12478] Don't resolve GLSL extensions if no shaders. * [QTBUG-12591] setUniformValue(QSize) was setting (w,w) not (w,h). - * [QTBUG-12862] Don't #define highp/mediump/lowp if the desktop OpenGL - implementation has the GL_ARB_ES2_compatibility extension. * [QTBUG-12554] Wrong OpenGLVersionFlags on OpenGL 4.0 systems. QtScript @@ -109,7 +107,7 @@ Third party components Qt for Unix (X11 and Mac OS X) ------------------------------ - - + - Qt for Linux/X11 ---------------- diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 9e74e04..7f25887 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -5264,8 +5264,6 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions() glExtensions |= FragmentShader; if (extensions.match("GL_ARB_shader_objects")) glExtensions |= FragmentShader; - if (extensions.match("GL_ARB_ES2_compatibility")) - glExtensions |= ES2Compatibility; if (extensions.match("GL_ARB_texture_mirrored_repeat")) glExtensions |= MirroredRepeat; if (extensions.match("GL_EXT_framebuffer_object")) @@ -5286,7 +5284,6 @@ QGLExtensions::Extensions QGLExtensions::currentContextExtensions() glExtensions |= FramebufferObject; glExtensions |= GenerateMipmap; glExtensions |= FragmentShader; - glExtensions |= ES2Compatibility; #endif #if defined(QT_OPENGL_ES_1) if (extensions.match("GL_OES_framebuffer_object")) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 623eeaf..387c8f7 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -284,8 +284,7 @@ public: DDSTextureCompression = 0x00008000, ETC1TextureCompression = 0x00010000, PVRTCTextureCompression = 0x00020000, - FragmentShader = 0x00040000, - ES2Compatibility = 0x00080000 + FragmentShader = 0x00040000 }; Q_DECLARE_FLAGS(Extensions, Extension) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index bc1c009..74382b0 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -97,10 +97,6 @@ QT_BEGIN_NAMESPACE to just features that are present in GLSL/ES, and avoid standard variable names that only work on the desktop. - If the \c{GL_ARB_ES2_compatibility} extension is present, - then the above prefix is not added because the desktop OpenGL - implementation supports precision qualifiers. - \section1 Simple shader example \snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 1 @@ -398,10 +394,8 @@ bool QGLShader::compileSourceCode(const char *source) srclen.append(GLint(headerLen)); } #ifdef QGL_DEFINE_QUALIFIERS - if (!(QGLExtensions::glExtensions() & QGLExtensions::ES2Compatibility)) { - src.append(qualifierDefines); - srclen.append(GLint(sizeof(qualifierDefines) - 1)); - } + src.append(qualifierDefines); + srclen.append(GLint(sizeof(qualifierDefines) - 1)); #endif #ifdef QGL_REDEFINE_HIGHP if (d->shaderType == Fragment) { -- cgit v0.12 From ab057be7228d20d909246183505b72e821cc440f Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 Oct 2010 14:00:38 +0200 Subject: Remove unnecessary calls to GetHorizBounds() + boundingBox() QFontEngineS60::boundingBox_const(): The metrics that CFont::getCharacterData() returns is equivalent to what TOpenFontCharMetrics::GetHorizBounds() returns. So, remove the use of TRect glyphBounds, and TOpenFontCharMetrics::GetHorizBounds(). Implementation of TOpenFontCharMetrics::GetHorizBounds(): http://developer.symbian.org/oss/API_REF/Public_API/file/837f303aceeb/epoc32/include/openfont.h#l1352 QRasterPaintEngine::drawGlyphsS60(): The metrics that QFontEngineS60::getCharacterData() returns are equivalent to what QFontEngineS60::boundingBox() returns. So, remove the use of glyph_metrics_t metrics, and QFontEngineS60::boundingBox(). These changes increase the Fps in qt\tests\manual\textrendering\textperformance "Latin" from 16.2 to 16.5 Fps on an XM5800. And they do that by removing code :) Task-number: QTBUG-14378 Reviewed-by: Jason Barron --- src/gui/painting/qpaintengine_raster.cpp | 6 ++---- src/gui/text/qfontengine_s60.cpp | 10 ++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 9749244..c92d291 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3164,10 +3164,8 @@ void QRasterPaintEngine::drawGlyphsS60(const QPointF &p, const QTextItemInt &ti) const TUint8 *glyphBitmapBytes; TSize glyphBitmapSize; fe->getCharacterData(glyphs[i], tmetrics, glyphBitmapBytes, glyphBitmapSize); - const glyph_metrics_t metrics = ti.fontEngine->boundingBox(glyphs[i]); - const int x = qFloor(positions[i].x + metrics.x + aliasDelta); - const int y = qFloor(positions[i].y + metrics.y + aliasDelta); - + const int x = qFloor(positions[i].x + tmetrics.HorizBearingX() + aliasDelta); + const int y = qFloor(positions[i].y - tmetrics.HorizBearingY() + aliasDelta); alphaPenBlt(glyphBitmapBytes, glyphBitmapSize.iWidth, 8, x, y, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight); } diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 653965e..32fcb82 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -360,13 +360,11 @@ glyph_metrics_t QFontEngineS60::boundingBox_const(glyph_t glyph) const const TUint8 *glyphBitmapBytes; TSize glyphBitmapSize; getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize); - TRect glyphBounds; - metrics.GetHorizBounds(glyphBounds); const glyph_metrics_t result( - glyphBounds.iTl.iX, - glyphBounds.iTl.iY, - glyphBounds.Width(), - glyphBounds.Height(), + metrics.HorizBearingX(), + -metrics.HorizBearingY(), + metrics.Width(), + metrics.Height(), metrics.HorizAdvance(), 0 ); -- cgit v0.12 From ea5281e6cd1ebc63e080f7232d4eb28f1610539e Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 Oct 2010 14:18:54 +0200 Subject: Implement QFontEngineS60::emSquareSize() Some glyph position tweaks during the shaping phase require the "Units per Em" information for the font. QFontEngineS60 did not reimplement emSquareSize(), therefore, some combined glyphs were rendered incorrectly (see QTBUG-10725) This patch implements QFontEngineS60::emSquareSize() Since Symbian does not provide the "Units per Em" via public Api, we have to pick that out of the 'head' font table. The value is cached per font. Task-Number: QTBUG-10725 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_s60.cpp | 26 ++++++++++++++++++++++++++ src/gui/text/qfontengine_s60_p.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 32fcb82..824a8e2 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -41,6 +41,7 @@ #include "qfontengine_s60_p.h" #include "qtextengine_p.h" +#include "qendian.h" #include "qglobal.h" #include #include "qimage.h" @@ -176,6 +177,24 @@ CFont *QSymbianTypeFaceExtras::fontOwner() const return m_cFont; } +QFixed QSymbianTypeFaceExtras::unitsPerEm() const +{ + if (m_unitsPerEm.value() != 0) + return m_unitsPerEm; + const QByteArray head = getSfntTable(MAKE_TAG('h', 'e', 'a', 'd')); + const int unitsPerEmOffset = 18; + if (head.size() > unitsPerEmOffset + sizeof(quint16)) { + const uchar* tableData = reinterpret_cast(head.constData()); + const uchar* unitsPerEm = tableData + unitsPerEmOffset; + m_unitsPerEm = qFromBigEndian(unitsPerEm); + } else { + // Bitmap font? Corrupt font? + // We return -1 and let the QFontEngineS60 return the pixel size. + m_unitsPerEm = -1; + } + return m_unitsPerEm; +} + // duplicated from qfontengine_xyz.cpp static inline unsigned int getChar(const QChar *str, int &i, const int len) { @@ -248,6 +267,13 @@ QFontEngineS60::~QFontEngineS60() releaseFont(m_scaledFont); } +QFixed QFontEngineS60::emSquareSize() const +{ + const QFixed unitsPerEm = m_extras->unitsPerEm(); + return unitsPerEm.toInt() == -1 ? + QFixed::fromReal(m_originalFontSizeInPixels) : unitsPerEm; +} + bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const { if (*nglyphs < len) { diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index d05c23c..c65ce55 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -82,11 +82,13 @@ public: const uchar *cmap() const; CFont *fontOwner() const; bool isSymbolCMap() const; + QFixed unitsPerEm() const; private: CFont* m_cFont; mutable bool m_symbolCMap; mutable QByteArray m_cmapTable; + mutable QFixed m_unitsPerEm; #ifndef Q_SYMBIAN_HAS_FONTTABLE_API COpenFont *m_openFont; mutable MOpenFontTrueTypeExtension *m_trueTypeExtension; @@ -99,6 +101,7 @@ public: QFontEngineS60(const QFontDef &fontDef, const QSymbianTypeFaceExtras *extras); ~QFontEngineS60(); + QFixed emSquareSize() const; bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const; void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const; -- cgit v0.12 From 0b3402f2ff0db1de747e9d38021a5c9300c8a011 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 12 Oct 2010 15:33:44 +0300 Subject: Added bearer plugin deployment to qt.iby Reviewed-by: TrustMe --- src/s60installs/qt.iby | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/s60installs/qt.iby b/src/s60installs/qt.iby index b6cdce9..4afbf05 100644 --- a/src/s60installs/qt.iby +++ b/src/s60installs/qt.iby @@ -53,6 +53,9 @@ file=ABI_DIR\BUILD_DIR\qaudio.dll SHARED_LIB_DIR\qaudio.dll file=ABI_DIR\BUILD_DIR\qvggraphicssystem.dll SHARED_LIB_DIR\qvggraphicssystem.dll file=ABI_DIR\BUILD_DIR\qglgraphicssystem.dll SHARED_LIB_DIR\qglgraphicssystem.dll +// bearer +file=ABI_DIR\BUILD_DIR\qsymbianbearer.dll SHARED_LIB_DIR\qsymbianbearer.dll + // S60 version compatibility plugins for 5.0 (3.1 and 3.2 devices are never likely to have this in ROM, // so don't bother including those plugins file=ABI_DIR\BUILD_DIR\qts60plugin_5_0.dll SHARED_LIB_DIR\qts60plugin_5_0.dll @@ -99,6 +102,9 @@ data=\epoc32\data\qt\qtlibspluginstubs\qaudio.qtplugin resource\qt\plugins\audio data=\epoc32\data\z\resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin resource\qt\plugins\graphicssystems\qvggraphicssystem.qtplugin data=\epoc32\data\z\resource\qt\plugins\graphicssystems\qglgraphicssystem.qtplugin resource\qt\plugins\graphicssystems\qglgraphicssystem.qtplugin +// bearer stub +data=\epoc32\data\z\resource\qt\plugins\bearer\qsymbianbearer.qtplugin resource\qt\plugins\bearer\qsymbianbearer.qtplugin + // Stub sis file data=ZSYSTEM\install\qt_stub.sis System\Install\qt_stub.sis data=ZSYSTEM\install\qtwebkit_stub.sis System\Install\qtwebkit_stub.sis -- cgit v0.12 From e39f273b921a36b307b2b2adddd7135f0c5a8858 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Tue, 12 Oct 2010 14:39:12 +0200 Subject: Delete qtdemoapps.iby. This file was used to deploy certain Qt demo applications to a Symbian ROM image and was always being exported to the epoc32 tree when Qt was compiled. This doesn't make sense since these will never (hopefully) be deployed on any real device. If someone wants demo apps deployed, they should create their own IBY file. Reviewed-by: Shane Kearns Reviewed-by: Miikka Heikkinen --- src/s60installs/qtdemoapps.iby | 15 --------------- src/s60installs/s60installs.pro | 1 - 2 files changed, 16 deletions(-) delete mode 100644 src/s60installs/qtdemoapps.iby diff --git a/src/s60installs/qtdemoapps.iby b/src/s60installs/qtdemoapps.iby deleted file mode 100644 index d888135..0000000 --- a/src/s60installs/qtdemoapps.iby +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef QTDEMOAPPS_IBY -#define QTDEMOAPPS_IBY - -// A subset of Qt demo & example applications - -// Note that star requires OpenVG and the Qt OpenVG paint engine -S60_APP_EXE(star) -S60_APP_RESOURCE(star) -data=\epoc32\data\Z\private\10003a3f\import\Apps\star_reg.rsc \private\10003a3f\import\apps\star_reg.rsc - -S60_APP_EXE(wiggly) -S60_APP_RESOURCE(wiggly) -data=\epoc32\data\Z\private\10003a3f\import\Apps\wiggly_reg.rsc \private\10003a3f\import\apps\wiggly_reg.rsc - -#endif // QTDEMOAPPS_IBY diff --git a/src/s60installs/s60installs.pro b/src/s60installs/s60installs.pro index c73ed06..d63b97c 100644 --- a/src/s60installs/s60installs.pro +++ b/src/s60installs/s60installs.pro @@ -200,5 +200,4 @@ symbian: { } BLD_INF_RULES.prj_exports += "qt.iby $$CORE_MW_LAYER_IBY_EXPORT_PATH(qt.iby)" - BLD_INF_RULES.prj_exports += "qtdemoapps.iby $$CUSTOMER_VARIANT_APP_LAYER_IBY_EXPORT_PATH(qtdemoapps.iby)" } -- cgit v0.12 From 92fb7e405a93785af162e5dff0a6b2a2d40060bc Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 Oct 2010 16:27:31 +0200 Subject: Optimize QFontEngineS60::recalcAdvances() (Addition to ab057be7228d20d909246183505b72e821cc440f) Instead of using a glyph_metrics_t (which gets filled with data from a TOpenFontCharMetrics), we use a TOpenFontCharMetrics, directly. Also, the advances_y gets set to 0. Like on the other platforms. These change increases the Fps in qt\tests\manual\textrendering\textperformance "Latin" from 16.5 to 16.6 Fps on an XM5800. I am sure that I can construct a benchmark where the speed gain is bigger. Task-number: QTBUG-14378 Reviewed-by: TrustMe --- src/gui/text/qfontengine_s60.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 824a8e2..3705136 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -303,10 +303,13 @@ bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout void QFontEngineS60::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const { Q_UNUSED(flags); + TOpenFontCharMetrics metrics; + const TUint8 *glyphBitmapBytes; + TSize glyphBitmapSize; for (int i = 0; i < glyphs->numGlyphs; i++) { - const glyph_metrics_t bbox = boundingBox_const(glyphs->glyphs[i]); - glyphs->advances_x[i] = bbox.xoff; - glyphs->advances_y[i] = bbox.yoff; + getCharacterData(glyphs->glyphs[i], metrics, glyphBitmapBytes, glyphBitmapSize); + glyphs->advances_x[i] = metrics.HorizAdvance(); + glyphs->advances_y[i] = 0; } } -- cgit v0.12 From 087414e3ee4dd4c9f8f13c5a9eb69c5f70fb3d59 Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Tue, 12 Oct 2010 17:19:46 +0200 Subject: Doc - remove disclaimer Task-number: QTBUG-14407 Reviewed-by: Friedemann Kleint Reviewed-by: Henry Haverinen --- doc/src/porting/qt4-designer.qdoc | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/doc/src/porting/qt4-designer.qdoc b/doc/src/porting/qt4-designer.qdoc index fff3e89..ea5147a 100644 --- a/doc/src/porting/qt4-designer.qdoc +++ b/doc/src/porting/qt4-designer.qdoc @@ -36,18 +36,14 @@ \QD has been completely re-written based on our experience with the previous versions of the product for Qt 3. One of the main new - ideas behind this new version is to release the application as a + ideas is to release the application as a collection of interchangeable components that include the property editor, the widget box, and other useful tools for creating graphical user interfaces with Qt. These components can either be used together in the \QD application, or independently integrated into other systems. As a result, certain features such as the project editor and code editor have been removed from the version - included with this release. - - The current version of \QD is near feature complete and can be used for - many tasks. However, it is still under continuous development. This - document will explain what is already in place. + included with release 4. See also the \l{Qt Designer Manual}. @@ -128,7 +124,7 @@ \row \i \bold{Widget Editing Mode} - The new \QD allows widgets to be dropped into existing layouts on + \QD now allows widgets to be dropped into existing layouts on the form. Previously, it was necessary to break layouts in order to add new widgets to them. @@ -189,7 +185,7 @@ \row \i \bold{The Resource Editor} - The new \QD fully supports The Qt Resource System, and provide the + \QD now fully supports The Qt Resource System, and provides the Resource Editor to help designers and developers manage the resources that are needed by their applications. @@ -210,8 +206,8 @@ \i \inlineimage designer-action-editor.png \i \bold{The Action Editor} - With the release of Qt 4.1, \QD introduces the Action Editor - simplifying the management of actions when creating main window + With the release of Qt 4.1, \QD the Action Editor was introduced + to simplify the management of actions when creating main window applications. When creating a main window, you can add a menu bar and toolbars @@ -261,7 +257,7 @@ \section1 Run-Time Support for Forms - With the Qt 4.1 release, the new QtUiTools module is introduced to + With the Qt 4.1 release, the new QtUiTools module was introduced to provide classes handling forms created with \QD. Currently the module only contains the QUiLoader class. -- cgit v0.12 From 7d21b598d299ee61d61f15c69b41b8b38daf9bea Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 Oct 2010 22:55:20 +0200 Subject: Remove obsolete tweak in QFontEngineS60::alphaMapForGlyph On some Symbian versions (apparently <= Symbian^1), CFont::GetCharacterData() returns 8-bit data with gray values 0x00, 0x10 ... 0xe0, 0xf0 due to a bug. The glyphs are nowhere perfectly opaque, which is bad for blitting. This has been however been fixed for Symbian^3. The funny thing about this tweak was that it was only executed on Symbian^3 (with the OpenVG/OpenGL paintengines). On Symbian^1 and below (rasterpaintengine), QFontEngineS60::alphaMapForGlyph() does not get called at all, anymore. Therefore, the removal of this tweak should not be noticable anywhere, except that on Symbian^3, quite a few CPU cycles are now saved. See the attachments in QTBUG-14419 for details. Task-Number: QTBUG-14419 Reviewed-By: TrustMe --- src/gui/text/qfontengine_s60.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 3705136..bf30e1c 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -345,29 +345,17 @@ void QFontEngineS60::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, QImage QFontEngineS60::alphaMapForGlyph(glyph_t glyph) { + // Note: On some Symbian versions (apparently <= Symbian^1), this + // function will return gray values 0x00, 0x10 ... 0xe0, 0xf0 due + // to a bug. The glyphs are nowhere perfectly opaque. + // This has been fixed for Symbian^3. + TOpenFontCharMetrics metrics; const TUint8 *glyphBitmapBytes; TSize glyphBitmapSize; getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize); QImage result(glyphBitmapBytes, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight, glyphBitmapSize.iWidth, QImage::Format_Indexed8); result.setColorTable(grayPalette()); - - // The above setColorTable() call detached the image data anyway, so why not shape tha data a bit, while we can. - // CFont::GetCharacterData() returns 8-bit data that obviously was 4-bit data before, and converted to 8-bit incorrectly. - // The data values are 0x00, 0x10 ... 0xe0, 0xf0. So, a real opaque 0xff is never reached, which we get punished - // for every time we want to blit this glyph in the raster paint engine. - // "Fix" is to convert all 0xf0 to 0xff. Is fine, quality wise, and I assume faster than correcting all values. - // Blitting is however, evidentially faster now. - const int bpl = result.bytesPerLine(); - for (int row = 0; row < result.height(); ++row) { - uchar *scanLine = result.scanLine(row); - for (int column = 0; column < bpl; ++column) { - if (*scanLine == 0xf0) - *scanLine = 0xff; - scanLine++; - } - } - return result; } -- cgit v0.12 From a311b854e0886f0498c068af5b489af36a96b845 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 13 Oct 2010 10:52:16 +1000 Subject: Compile on WinCE --- src/declarative/qml/qdeclarativeengine.cpp | 4 ++-- .../declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp | 4 ++-- .../qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index ec583f9..8e1416e 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -2193,14 +2193,14 @@ const QMetaObject *QDeclarativeEnginePrivate::metaObjectForType(int t) const bool QDeclarative_isFileCaseCorrect(const QString &fileName) { -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) +#if defined(Q_OS_MAC) || defined(Q_OS_WIN32) QFileInfo info(fileName); QString absolute = info.absoluteFilePath(); #if defined(Q_OS_MAC) QString canonical = info.canonicalFilePath(); -#elif defined(Q_OS_WIN) +#elif defined(Q_OS_WIN32) wchar_t buffer[1024]; DWORD rv = ::GetLongPathName((wchar_t*)absolute.utf16(), buffer, 1024); diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index be04dee..061ac48 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -387,7 +387,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("singularProperty") << "singularProperty.qml" << "singularProperty.errors.txt" << false; QTest::newRow("singularProperty.2") << "singularProperty.2.qml" << "singularProperty.2.errors.txt" << false; QTest::newRow("incorrectCase") << "incorrectCase.qml" -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) +#if defined(Q_OS_MAC) || defined(Q_OS_WIN32) << "incorrectCase.errors.insensitive.txt" #else << "incorrectCase.errors.sensitive.txt" @@ -1784,7 +1784,7 @@ void tst_qdeclarativelanguage::importIncorrectCase() QList errors = component.errors(); QCOMPARE(errors.count(), 1); -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) +#if defined(Q_OS_MAC) || defined(Q_OS_WIN32) QString expectedError = QLatin1String("cannot load module \"com.Nokia.installedtest\": File name case mismatch for \"") + QFileInfo(__FILE__).absoluteDir().filePath("data/lib/com/Nokia/installedtest/qmldir") + QLatin1String("\""); #else QString expectedError = QLatin1String("module \"com.Nokia.installedtest\" is not installed"); diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index 51f66a5..85fa718 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -131,10 +131,10 @@ void tst_qdeclarativemoduleplugin::incorrectPluginCase() QList errors = component.errors(); QCOMPARE(errors.count(), 1); -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) +#if defined(Q_OS_MAC) || defined(Q_OS_WIN32) #if defined(Q_OS_MAC) QString libname = "libPluGin.dylib"; -#elif defined(Q_OS_WIN) +#elif defined(Q_OS_WIN32) QString libname = "PluGin.dll"; #endif QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QFileInfo(__FILE__).absoluteDir().filePath("imports/com/nokia/WrongCase/" + libname) + QLatin1String("\""); -- cgit v0.12 From 2553ca41a05afb28e49d813a1aebed12474f6b00 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 13 Oct 2010 14:55:07 +1000 Subject: Remove debug code added by 650a0078e2cef43eff107fe8d2505f64a0bfedf0 Task-number: QT-4093 --- .../auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 7a58773..2649c0d 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -989,9 +989,6 @@ void tst_QDeclarativeListView::sections() listview->setContentY(0); model.modifyItem(0, "changed", "2"); - canvas->show(); - qApp->exec(); - item = findItem(contentItem, "wrapper", 1); QTRY_VERIFY(item); QTRY_COMPARE(item->height(), 40.0); -- cgit v0.12 From cdcc5bc1a82b70d27752370d83b4b21c912f6153 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 13 Oct 2010 15:01:19 +1000 Subject: Fix alignment bugs in Text element Task-number: QTBUG-14374 --- src/declarative/graphicsitems/qdeclarativetext.cpp | 961 +++++++++++---------- .../graphicsitems/qdeclarativetext_p_p.h | 48 +- 2 files changed, 526 insertions(+), 483 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 54cb062..308aefa 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -85,12 +85,13 @@ private: DEFINE_BOOL_CONFIG_OPTION(enableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE); QDeclarativeTextPrivate::QDeclarativeTextPrivate() -: color((QRgb)0), style(QDeclarativeText::Normal), - hAlign(QDeclarativeText::AlignLeft), vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone), - imgDirty(true), dirty(true), richText(false), singleline(false), cache(true), internalWidthUpdate(false), doc(0), - format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap) +: color((QRgb)0), style(QDeclarativeText::Normal), hAlign(QDeclarativeText::AlignLeft), + vAlign(QDeclarativeText::AlignTop), elideMode(QDeclarativeText::ElideNone), + format(QDeclarativeText::AutoText), wrapMode(QDeclarativeText::NoWrap), imageCacheDirty(true), + updateOnComponentComplete(true), richText(false), singleline(false), cacheAllTextAsImage(true), + internalWidthUpdate(false), doc(0) { - cache = enableImageCache(); + cacheAllTextAsImage = enableImageCache(); QGraphicsItemPrivate::acceptedMouseButtons = Qt::LeftButton; QGraphicsItemPrivate::flags = QGraphicsItemPrivate::flags & ~QGraphicsItem::ItemHasNoContents; } @@ -151,7 +152,6 @@ void QTextDocumentWithImageResources::requestFinished() #endif QDeclarativeTextPrivate *d = QDeclarativeTextPrivate::get(textItem); d->updateLayout(); - d->markImgDirty(); } } @@ -172,6 +172,382 @@ void QTextDocumentWithImageResources::setText(const QString &text) QSet QTextDocumentWithImageResources::errors; +QDeclarativeTextPrivate::~QDeclarativeTextPrivate() +{ +} + +void QDeclarativeTextPrivate::updateLayout() +{ + Q_Q(QDeclarativeText); + if (!q->isComponentComplete()) { + updateOnComponentComplete = true; + return; + } + + // Setup instance of QTextLayout for all cases other than richtext + if (!richText) { + layout.clearLayout(); + layout.setFont(font); + if (format != QDeclarativeText::StyledText) { + QString tmp = text; + tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); + singleline = !tmp.contains(QChar::LineSeparator); + if (singleline && elideMode != QDeclarativeText::ElideNone && q->widthValid()) { + QFontMetrics fm(font); + tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...? + } + layout.setText(tmp); + } else { + singleline = false; + QDeclarativeStyledText::parse(text, layout); + } + } + + updateSize(); +} + +void QDeclarativeTextPrivate::updateSize() +{ + Q_Q(QDeclarativeText); + + if (!q->isComponentComplete()) { + updateOnComponentComplete = true; + return; + } + + invalidateImageCache(); + + QFontMetrics fm(font); + if (text.isEmpty()) { + q->setImplicitHeight(fm.height()); + emit q->paintedSizeChanged(); + return; + } + + int dy = q->height(); + QSize size(0, 0); + + //setup instance of QTextLayout for all cases other than richtext + if (!richText) { + size = setupTextLayout(); + if (layedOutTextSize != size) { + q->prepareGeometryChange(); + layedOutTextSize = size; + } + dy -= size.height(); + } else { + singleline = false; // richtext can't elide or be optimized for single-line case + ensureDoc(); + doc->setDefaultFont(font); + QTextOption option((Qt::Alignment)int(hAlign | vAlign)); + option.setWrapMode(QTextOption::WrapMode(wrapMode)); + doc->setDefaultTextOption(option); + if (wrapMode != QDeclarativeText::NoWrap && q->widthValid()) + doc->setTextWidth(q->width()); + else + doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) + dy -= (int)doc->size().height(); + QSize dsize = doc->size().toSize(); + if (dsize != layedOutTextSize) { + q->prepareGeometryChange(); + layedOutTextSize = dsize; + } + size = QSize(int(doc->idealWidth()),dsize.height()); + } + int yoff = 0; + + if (q->heightValid()) { + if (vAlign == QDeclarativeText::AlignBottom) + yoff = dy; + else if (vAlign == QDeclarativeText::AlignVCenter) + yoff = dy/2; + } + q->setBaselineOffset(fm.ascent() + yoff); + + //### need to comfirm cost of always setting these for richText + internalWidthUpdate = true; + q->setImplicitWidth(size.width()); + internalWidthUpdate = false; + q->setImplicitHeight(size.height()); + emit q->paintedSizeChanged(); +} + +/*! + Lays out the QDeclarativeTextPrivate::layout QTextLayout in the constraints of the QDeclarativeText. + + Returns the size of the final text. This can be used to position the text vertically (the text is + already absolutely positioned horizontally). +*/ +QSize QDeclarativeTextPrivate::setupTextLayout() +{ + // ### text layout handling should be profiled and optimized as needed + // what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine); + + Q_Q(QDeclarativeText); + layout.setCacheEnabled(true); + + int height = 0; + qreal widthUsed = 0; + qreal lineWidth = 0; + + //set manual width + if ((wrapMode != QDeclarativeText::NoWrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid()) + lineWidth = q->width(); + + QTextOption textOption = layout.textOption(); + textOption.setWrapMode(QTextOption::WrapMode(wrapMode)); + layout.setTextOption(textOption); + + layout.beginLayout(); + while (1) { + QTextLine line = layout.createLine(); + if (!line.isValid()) + break; + + if ((wrapMode != QDeclarativeText::NoWrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid()) + line.setLineWidth(lineWidth); + } + layout.endLayout(); + + for (int i = 0; i < layout.lineCount(); ++i) { + QTextLine line = layout.lineAt(i); + widthUsed = qMax(widthUsed, line.naturalTextWidth()); + } + + qreal layoutWidth = q->widthValid()?q->width():widthUsed; + + int x = 0; + for (int i = 0; i < layout.lineCount(); ++i) { + QTextLine line = layout.lineAt(i); + line.setPosition(QPointF(0, height)); + height += int(line.height()); + + if (!cacheAllTextAsImage) { + if (hAlign == QDeclarativeText::AlignLeft) { + x = 0; + } else if (hAlign == QDeclarativeText::AlignRight) { + x = layoutWidth - (int)line.naturalTextWidth(); + } else if (hAlign == QDeclarativeText::AlignHCenter) { + x = (layoutWidth - (int)line.naturalTextWidth()) / 2; + } + line.setPosition(QPoint(x, (int)line.y())); + } + } + + return QSize(qCeil(widthUsed), height); +} + +/*! + Returns a painted version of the QDeclarativeTextPrivate::layout QTextLayout. + If \a drawStyle is true, the style color overrides all colors in the document. +*/ +QPixmap QDeclarativeTextPrivate::textLayoutImage(bool drawStyle) +{ + //do layout + QSize size = layedOutTextSize; + + int x = 0; + for (int i = 0; i < layout.lineCount(); ++i) { + QTextLine line = layout.lineAt(i); + if (hAlign == QDeclarativeText::AlignLeft) { + x = 0; + } else if (hAlign == QDeclarativeText::AlignRight) { + x = size.width() - (int)line.naturalTextWidth(); + } else if (hAlign == QDeclarativeText::AlignHCenter) { + x = (size.width() - (int)line.naturalTextWidth()) / 2; + } + line.setPosition(QPoint(x, (int)line.y())); + } + + //paint text + QPixmap img(size); + if (!size.isEmpty()) { + img.fill(Qt::transparent); +#ifdef Q_WS_MAC + bool oldSmooth = qt_applefontsmoothing_enabled; + qt_applefontsmoothing_enabled = false; +#endif + QPainter p(&img); +#ifdef Q_WS_MAC + qt_applefontsmoothing_enabled = oldSmooth; +#endif + drawTextLayout(&p, QPointF(0,0), drawStyle); + } + return img; +} + +/*! + Paints the QDeclarativeTextPrivate::layout QTextLayout into \a painter at \a pos. If + \a drawStyle is true, the style color overrides all colors in the document. +*/ +void QDeclarativeTextPrivate::drawTextLayout(QPainter *painter, const QPointF &pos, bool drawStyle) +{ + if (drawStyle) + painter->setPen(styleColor); + else + painter->setPen(color); + painter->setFont(font); + layout.draw(painter, pos); +} + +/*! + Returns a painted version of the QDeclarativeTextPrivate::doc QTextDocument. + If \a drawStyle is true, the style color overrides all colors in the document. +*/ +QPixmap QDeclarativeTextPrivate::textDocumentImage(bool drawStyle) +{ + QSize size = doc->size().toSize(); + + //paint text + QPixmap img(size); + img.fill(Qt::transparent); +#ifdef Q_WS_MAC + bool oldSmooth = qt_applefontsmoothing_enabled; + qt_applefontsmoothing_enabled = false; +#endif + QPainter p(&img); +#ifdef Q_WS_MAC + qt_applefontsmoothing_enabled = oldSmooth; +#endif + + QAbstractTextDocumentLayout::PaintContext context; + + QTextOption oldOption(doc->defaultTextOption()); + if (drawStyle) { + context.palette.setColor(QPalette::Text, styleColor); + QTextOption colorOption(doc->defaultTextOption()); + colorOption.setFlags(QTextOption::SuppressColors); + doc->setDefaultTextOption(colorOption); + } else { + context.palette.setColor(QPalette::Text, color); + } + doc->documentLayout()->draw(&p, context); + if (drawStyle) + doc->setDefaultTextOption(oldOption); + return img; +} + +/*! + Mark the image cache as dirty. +*/ +void QDeclarativeTextPrivate::invalidateImageCache() +{ + Q_Q(QDeclarativeText); + + if (imageCacheDirty) + return; + + imageCacheDirty = true; + imageCache = QPixmap(); + + if (q->isComponentComplete()) + q->update(); +} + +/*! + Tests if the image cache is dirty, and repaints it if it is. +*/ +void QDeclarativeTextPrivate::checkImageCache() +{ + if (!imageCacheDirty) + return; + + if (text.isEmpty()) { + + imageCache = QPixmap(); + + } else { + + QPixmap textImage; + QPixmap styledImage; + + if (richText) { + textImage = textDocumentImage(false); + if (style != QDeclarativeText::Normal) + styledImage = textDocumentImage(true); //### should use styleColor + } else { + textImage = textLayoutImage(false); + if (style != QDeclarativeText::Normal) + styledImage = textLayoutImage(true); //### should use styleColor + } + + switch (style) { + case QDeclarativeText::Outline: + imageCache = drawOutline(textImage, styledImage); + break; + case QDeclarativeText::Sunken: + imageCache = drawOutline(textImage, styledImage, -1); + break; + case QDeclarativeText::Raised: + imageCache = drawOutline(textImage, styledImage, 1); + break; + default: + imageCache = textImage; + break; + } + + } + + imageCacheDirty = false; +} + +/*! + Ensures the QDeclarativeTextPrivate::doc variable is set to a valid text document +*/ +void QDeclarativeTextPrivate::ensureDoc() +{ + if (!doc) { + Q_Q(QDeclarativeText); + doc = new QTextDocumentWithImageResources(q); + doc->setDocumentMargin(0); + } +} + +/*! + Draw \a styleSource as an outline around \a source and return the new image. +*/ +QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixmap &styleSource) +{ + QPixmap img = QPixmap(styleSource.width() + 2, styleSource.height() + 2); + img.fill(Qt::transparent); + + QPainter ppm(&img); + + QPoint pos(0, 0); + pos += QPoint(-1, 0); + ppm.drawPixmap(pos, styleSource); + pos += QPoint(2, 0); + ppm.drawPixmap(pos, styleSource); + pos += QPoint(-1, -1); + ppm.drawPixmap(pos, styleSource); + pos += QPoint(0, 2); + ppm.drawPixmap(pos, styleSource); + + pos += QPoint(0, -1); + ppm.drawPixmap(pos, source); + ppm.end(); + + return img; +} + +/*! + Draw \a styleSource below \a source at \a yOffset and return the new image. +*/ +QPixmap QDeclarativeTextPrivate::drawOutline(const QPixmap &source, const QPixmap &styleSource, int yOffset) +{ + QPixmap img = QPixmap(styleSource.width() + 2, styleSource.height() + 2); + img.fill(Qt::transparent); + + QPainter ppm(&img); + + ppm.drawPixmap(QPoint(0, yOffset), styleSource); + ppm.drawPixmap(0, 0, source); + + ppm.end(); + + return img; +} + /*! \qmlclass Text QDeclarativeText \ingroup qml-basic-visual-elements @@ -211,10 +587,44 @@ QDeclarativeText::~QDeclarativeText() { } +/*! + \qmlproperty bool Text::clip + This property holds whether the text is clipped. -QDeclarativeTextPrivate::~QDeclarativeTextPrivate() -{ -} + Note that if the text does not fit in the bounding rectangle it will be abruptly chopped. + + If you want to display potentially long text in a limited space, you probably want to use \c elide instead. +*/ + +/*! + \qmlproperty bool Text::smooth + + This property holds whether the text is smoothly scaled or transformed. + + Smooth filtering gives better visual quality, but is slower. If + the item is displayed at its natural size, this property has no visual or + performance effect. + + \note Generally scaling artifacts are only visible if the item is stationary on + the screen. A common pattern when animating an item is to disable smooth + filtering at the beginning of the animation and reenable it at the conclusion. +*/ + +/*! + \qmlsignal Text::onLinkActivated(string link) + + This handler is called when the user clicks on a link embedded in the text. + The link must be in rich text or HTML format and the + \a link string provides access to the particular link. + + \snippet doc/src/snippets/declarative/text/onLinkActivated.qml 0 + + The example code will display the text + "The main website is at \l{http://qt.nokia.com}{Nokia Qt DF}." + + Clicking on the highlighted link will output + \tt{http://qt.nokia.com link activated} to the console. +*/ /*! \qmlproperty string Text::font.family @@ -320,7 +730,6 @@ QDeclarativeTextPrivate::~QDeclarativeTextPrivate() Text { text: "Hello"; font.capitalization: Font.AllLowercase } \endqml */ - QFont QDeclarativeText::font() const { Q_D(const QDeclarativeText); @@ -334,30 +743,9 @@ void QDeclarativeText::setFont(const QFont &font) return; d->font = font; - d->updateLayout(); - d->markImgDirty(); - emit fontChanged(d->font); -} - -void QDeclarativeText::setText(const QString &n) -{ - Q_D(QDeclarativeText); - if (d->text == n) - return; - d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(n)); - if (d->richText) { - if (isComponentComplete()) { - d->ensureDoc(); - d->doc->setText(n); - } - } - - d->text = n; - d->updateLayout(); - d->markImgDirty(); - emit textChanged(d->text); + emit fontChanged(d->font); } /*! @@ -374,17 +762,25 @@ QString QDeclarativeText::text() const return d->text; } -void QDeclarativeText::setColor(const QColor &color) +void QDeclarativeText::setText(const QString &n) { Q_D(QDeclarativeText); - if (d->color == color) + if (d->text == n) return; - d->color = color; - d->markImgDirty(); - emit colorChanged(d->color); + d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(n)); + if (d->richText && isComponentComplete()) { + d->ensureDoc(); + d->doc->setText(n); + } + + d->text = n; + d->updateLayout(); + + emit textChanged(d->text); } + /*! \qmlproperty color Text::color @@ -398,13 +794,23 @@ void QDeclarativeText::setColor(const QColor &color) Text { color: "steelblue"; ... } \endqml */ - QColor QDeclarativeText::color() const { Q_D(const QDeclarativeText); return d->color; } +void QDeclarativeText::setColor(const QColor &color) +{ + Q_D(QDeclarativeText); + if (d->color == color) + return; + + d->color = color; + d->invalidateImageCache(); + emit colorChanged(d->color); +} + /*! \qmlproperty enumeration Text::style @@ -445,21 +851,10 @@ void QDeclarativeText::setStyle(QDeclarativeText::TextStyle style) if (isComponentComplete() && (d->style == Normal || style == Normal)) prepareGeometryChange(); d->style = style; - d->markImgDirty(); + d->invalidateImageCache(); emit styleChanged(d->style); } -void QDeclarativeText::setStyleColor(const QColor &color) -{ - Q_D(QDeclarativeText); - if (d->styleColor == color) - return; - - d->styleColor = color; - d->markImgDirty(); - emit styleColorChanged(d->styleColor); -} - /*! \qmlproperty color Text::styleColor @@ -481,6 +876,18 @@ QColor QDeclarativeText::styleColor() const return d->styleColor; } +void QDeclarativeText::setStyleColor(const QColor &color) +{ + Q_D(QDeclarativeText); + if (d->styleColor == color) + return; + + d->styleColor = color; + d->invalidateImageCache(); + emit styleColorChanged(d->styleColor); +} + + /*! \qmlproperty enumeration Text::horizontalAlignment \qmlproperty enumeration Text::verticalAlignment @@ -511,7 +918,10 @@ void QDeclarativeText::setHAlign(HAlignment align) if (isComponentComplete()) prepareGeometryChange(); + d->hAlign = align; + d->updateLayout(); + emit horizontalAlignmentChanged(align); } @@ -559,9 +969,8 @@ void QDeclarativeText::setWrapMode(WrapMode mode) return; d->wrapMode = mode; - d->updateLayout(); - d->markImgDirty(); + emit wrapModeChanged(); } @@ -621,7 +1030,6 @@ Column { \o \image declarative-textformat.png \endtable */ - QDeclarativeText::TextFormat QDeclarativeText::textFormat() const { Q_D(const QDeclarativeText); @@ -635,21 +1043,15 @@ void QDeclarativeText::setTextFormat(TextFormat format) return; d->format = format; bool wasRich = d->richText; - d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text)); - - if (wasRich && !d->richText) { - //### delete control? (and vice-versa below) - d->updateLayout(); - d->markImgDirty(); - } else if (!wasRich && d->richText) { - if (isComponentComplete()) { - d->ensureDoc(); - d->doc->setText(d->text); - } - d->updateLayout(); - d->markImgDirty(); + d->richText = format == RichText || (format == AutoText && Qt::mightBeRichText(d->text)); + + if (!wasRich && d->richText && isComponentComplete()) { + d->ensureDoc(); + d->doc->setText(d->text); } + d->updateLayout(); + emit textFormatChanged(d->format); } @@ -688,12 +1090,12 @@ void QDeclarativeText::setElideMode(QDeclarativeText::TextElideMode mode) return; d->elideMode = mode; - d->updateLayout(); - d->markImgDirty(); + emit elideModeChanged(d->elideMode); } +/*! \internal */ QRectF QDeclarativeText::boundingRect() const { Q_D(const QDeclarativeText); @@ -704,7 +1106,7 @@ QRectF QDeclarativeText::boundingRect() const int x = 0; int y = 0; - QSize size = d->cachedLayoutSize; + QSize size = d->layedOutTextSize; if (d->style != Normal) size += QSize(2,2); @@ -737,117 +1139,23 @@ QRectF QDeclarativeText::boundingRect() const return QRectF(x,y,size.width(),size.height()); } -void QDeclarativeText::geometryChanged(const QRectF &newGeometry, - const QRectF &oldGeometry) +/*! \internal */ +void QDeclarativeText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { Q_D(QDeclarativeText); - if (!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width()) { - if (d->wrapMode != QDeclarativeText::NoWrap || d->elideMode != QDeclarativeText::ElideNone) { - //re-elide if needed - if (d->singleline && d->elideMode != QDeclarativeText::ElideNone && - isComponentComplete() && widthValid()) { - - QFontMetrics fm(d->font); - QString tmp = fm.elidedText(d->text,(Qt::TextElideMode)d->elideMode,width()); // XXX still worth layout...? - d->layout.setText(tmp); - } + if (!d->internalWidthUpdate && newGeometry.width() != oldGeometry.width() && + (d->wrapMode != QDeclarativeText::NoWrap || d->elideMode != QDeclarativeText::ElideNone)) { - d->imgDirty = true; + if (d->singleline && d->elideMode != QDeclarativeText::ElideNone && widthValid()) { + // We need to re-elide + d->updateLayout(); + } else { + // We just need to re-layout d->updateSize(); } } - QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); -} - -void QDeclarativeTextPrivate::updateLayout() -{ - Q_Q(QDeclarativeText); - if (q->isComponentComplete()) { - //setup instance of QTextLayout for all cases other than richtext - if (!richText) { - layout.clearLayout(); - layout.setFont(font); - if (format != QDeclarativeText::StyledText) { - QString tmp = text; - tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); - singleline = !tmp.contains(QChar::LineSeparator); - if (singleline && elideMode != QDeclarativeText::ElideNone && q->widthValid()) { - QFontMetrics fm(font); - tmp = fm.elidedText(tmp,(Qt::TextElideMode)elideMode,q->width()); // XXX still worth layout...? - } - layout.setText(tmp); - } else { - singleline = false; - QDeclarativeStyledText::parse(text, layout); - } - } - updateSize(); - } else { - dirty = true; - } -} - - -void QDeclarativeTextPrivate::updateSize() -{ - Q_Q(QDeclarativeText); - if (q->isComponentComplete()) { - QFontMetrics fm(font); - if (text.isEmpty()) { - q->setImplicitHeight(fm.height()); - emit q->paintedSizeChanged(); - return; - } - - int dy = q->height(); - QSize size(0, 0); - - //setup instance of QTextLayout for all cases other than richtext - if (!richText) { - size = setupTextLayout(); - if (cachedLayoutSize != size) { - q->prepareGeometryChange(); - cachedLayoutSize = size; - } - dy -= size.height(); - } else { - singleline = false; // richtext can't elide or be optimized for single-line case - ensureDoc(); - doc->setDefaultFont(font); - QTextOption option((Qt::Alignment)int(hAlign | vAlign)); - option.setWrapMode(QTextOption::WrapMode(wrapMode)); - doc->setDefaultTextOption(option); - if (wrapMode != QDeclarativeText::NoWrap && q->widthValid()) - doc->setTextWidth(q->width()); - else - doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) - dy -= (int)doc->size().height(); - QSize dsize = doc->size().toSize(); - if (dsize != cachedLayoutSize) { - q->prepareGeometryChange(); - cachedLayoutSize = dsize; - } - size = QSize(int(doc->idealWidth()),dsize.height()); - } - int yoff = 0; - if (q->heightValid()) { - if (vAlign == QDeclarativeText::AlignBottom) - yoff = dy; - else if (vAlign == QDeclarativeText::AlignVCenter) - yoff = dy/2; - } - q->setBaselineOffset(fm.ascent() + yoff); - - //### need to comfirm cost of always setting these for richText - internalWidthUpdate = true; - q->setImplicitWidth(size.width()); - internalWidthUpdate = false; - q->setImplicitHeight(size.height()); - emit q->paintedSizeChanged(); - } else { - dirty = true; - } + QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); } /*! @@ -872,228 +1180,6 @@ qreal QDeclarativeText::paintedHeight() const return implicitHeight(); } - - -// ### text layout handling should be profiled and optimized as needed -// what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine); - -void QDeclarativeTextPrivate::drawOutline() -{ - QPixmap img = QPixmap(imgStyleCache.width()+2,imgStyleCache.height()+2); - img.fill(Qt::transparent); - - QPainter ppm(&img); - - QPoint pos(imgCache.rect().topLeft()); - pos += QPoint(-1, 0); - ppm.drawPixmap(pos, imgStyleCache); - pos += QPoint(2, 0); - ppm.drawPixmap(pos, imgStyleCache); - pos += QPoint(-1, -1); - ppm.drawPixmap(pos, imgStyleCache); - pos += QPoint(0, 2); - ppm.drawPixmap(pos, imgStyleCache); - - pos += QPoint(0, -1); - ppm.drawPixmap(pos, imgCache); - ppm.end(); - - imgCache = img; -} - -void QDeclarativeTextPrivate::drawOutline(int yOffset) -{ - QPixmap img = QPixmap(imgStyleCache.width()+2,imgStyleCache.height()+2); - img.fill(Qt::transparent); - - QPainter ppm(&img); - - QPoint pos(imgCache.rect().topLeft()); - pos += QPoint(0, yOffset); - ppm.drawPixmap(pos, imgStyleCache); - - pos += QPoint(0, -yOffset); - ppm.drawPixmap(pos, imgCache); - ppm.end(); - - imgCache = img; -} - -QSize QDeclarativeTextPrivate::setupTextLayout() -{ - Q_Q(QDeclarativeText); - layout.setCacheEnabled(true); - - int height = 0; - qreal widthUsed = 0; - qreal lineWidth = 0; - - //set manual width - if ((wrapMode != QDeclarativeText::NoWrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid()) - lineWidth = q->width(); - - QTextOption textOption = layout.textOption(); - textOption.setWrapMode(QTextOption::WrapMode(wrapMode)); - layout.setTextOption(textOption); - - layout.beginLayout(); - - while (1) { - QTextLine line = layout.createLine(); - if (!line.isValid()) - break; - - if ((wrapMode != QDeclarativeText::NoWrap || elideMode != QDeclarativeText::ElideNone) && q->widthValid()) - line.setLineWidth(lineWidth); - } - layout.endLayout(); - - int x = 0; - for (int i = 0; i < layout.lineCount(); ++i) { - QTextLine line = layout.lineAt(i); - widthUsed = qMax(widthUsed, line.naturalTextWidth()); - line.setPosition(QPointF(0, height)); - height += int(line.height()); - - if (!cache) { - if (hAlign == QDeclarativeText::AlignLeft) { - x = 0; - } else if (hAlign == QDeclarativeText::AlignRight) { - x = q->width() - (int)line.naturalTextWidth(); - } else if (hAlign == QDeclarativeText::AlignHCenter) { - x = (q->width() - (int)line.naturalTextWidth()) / 2; - } - line.setPosition(QPoint(x, (int)line.y())); - } - } - - return QSize(qCeil(widthUsed), height); -} - -QPixmap QDeclarativeTextPrivate::wrappedTextImage(bool drawStyle) -{ - //do layout - QSize size = cachedLayoutSize; - - int x = 0; - for (int i = 0; i < layout.lineCount(); ++i) { - QTextLine line = layout.lineAt(i); - if (hAlign == QDeclarativeText::AlignLeft) { - x = 0; - } else if (hAlign == QDeclarativeText::AlignRight) { - x = size.width() - (int)line.naturalTextWidth(); - } else if (hAlign == QDeclarativeText::AlignHCenter) { - x = (size.width() - (int)line.naturalTextWidth()) / 2; - } - line.setPosition(QPoint(x, (int)line.y())); - } - - //paint text - QPixmap img(size); - if (!size.isEmpty()) { - img.fill(Qt::transparent); -#ifdef Q_WS_MAC - bool oldSmooth = qt_applefontsmoothing_enabled; - qt_applefontsmoothing_enabled = false; -#endif - QPainter p(&img); -#ifdef Q_WS_MAC - qt_applefontsmoothing_enabled = oldSmooth; -#endif - drawWrappedText(&p, QPointF(0,0), drawStyle); - } - return img; -} - -void QDeclarativeTextPrivate::drawWrappedText(QPainter *p, const QPointF &pos, bool drawStyle) -{ - if (drawStyle) - p->setPen(styleColor); - else - p->setPen(color); - p->setFont(font); - layout.draw(p , pos); -} - -QPixmap QDeclarativeTextPrivate::richTextImage(bool drawStyle) -{ - QSize size = doc->size().toSize(); - - //paint text - QPixmap img(size); - img.fill(Qt::transparent); -#ifdef Q_WS_MAC - bool oldSmooth = qt_applefontsmoothing_enabled; - qt_applefontsmoothing_enabled = false; -#endif - QPainter p(&img); -#ifdef Q_WS_MAC - qt_applefontsmoothing_enabled = oldSmooth; -#endif - - QAbstractTextDocumentLayout::PaintContext context; - - QTextOption oldOption(doc->defaultTextOption()); - if (drawStyle) { - context.palette.setColor(QPalette::Text, styleColor); - QTextOption colorOption(doc->defaultTextOption()); - colorOption.setFlags(QTextOption::SuppressColors); - doc->setDefaultTextOption(colorOption); - } else { - context.palette.setColor(QPalette::Text, color); - } - doc->documentLayout()->draw(&p, context); - if (drawStyle) - doc->setDefaultTextOption(oldOption); - return img; -} - -void QDeclarativeTextPrivate::checkImgCache() -{ - if (!imgDirty) - return; - - bool empty = text.isEmpty(); - QPixmap newImgCache; - if (empty) { - imgStyleCache = QPixmap(); - } else if (richText) { - newImgCache = richTextImage(false); - if (style != QDeclarativeText::Normal) - imgStyleCache = richTextImage(true); //### should use styleColor - } else { - newImgCache = wrappedTextImage(false); - if (style != QDeclarativeText::Normal) - imgStyleCache = wrappedTextImage(true); //### should use styleColor - } - imgCache = newImgCache; - if (!empty) - switch (style) { - case QDeclarativeText::Outline: - drawOutline(); - break; - case QDeclarativeText::Sunken: - drawOutline(-1); - break; - case QDeclarativeText::Raised: - drawOutline(1); - break; - default: - break; - } - - imgDirty = false; -} - -void QDeclarativeTextPrivate::ensureDoc() -{ - if (!doc) { - Q_Q(QDeclarativeText); - doc = new QTextDocumentWithImageResources(q); - doc->setDocumentMargin(0); - } -} - /*! Returns the number of resources (images) that are being loaded asynchronously. */ @@ -1103,22 +1189,14 @@ int QDeclarativeText::resourcesLoading() const return d->doc ? d->doc->resourcesLoading() : 0; } -/*! - \qmlproperty bool Text::clip - This property holds whether the text is clipped. - - Note that if the text does not fit in the bounding rectangle it will be abruptly chopped. - - If you want to display potentially long text in a limited space, you probably want to use \c elide instead. -*/ - +/*! \internal */ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativeText); - if (d->cache || d->style != Normal) { - d->checkImgCache(); - if (d->imgCache.isNull()) + if (d->cacheAllTextAsImage || d->style != Normal) { + d->checkImageCache(); + if (d->imageCache.isNull()) return; bool oldAA = p->testRenderHint(QPainter::Antialiasing); @@ -1128,23 +1206,23 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid QRect br = boundingRect().toRect(); - bool needClip = clip() && (d->imgCache.width() > width() || - d->imgCache.height() > height()); + bool needClip = clip() && (d->imageCache.width() > width() || + d->imageCache.height() > height()); if (needClip) - p->drawPixmap(0, 0, width(), height(), d->imgCache, -br.x(), -br.y(), width(), height()); + p->drawPixmap(0, 0, width(), height(), d->imageCache, -br.x(), -br.y(), width(), height()); else - p->drawPixmap(br.x(), br.y(), d->imgCache); + p->drawPixmap(br.x(), br.y(), d->imageCache); if (d->smooth) { p->setRenderHint(QPainter::Antialiasing, oldAA); p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth); } } else { - qreal y = boundingRect().y(); + QRectF bounds = boundingRect(); - bool needClip = clip() && (d->cachedLayoutSize.width() > width() || - d->cachedLayoutSize.height() > height()); + bool needClip = clip() && (d->layedOutTextSize.width() > width() || + d->layedOutTextSize.height() > height()); if (needClip) { p->save(); @@ -1153,49 +1231,35 @@ void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid if (d->richText) { QAbstractTextDocumentLayout::PaintContext context; context.palette.setColor(QPalette::Text, d->color); - p->translate(0, y); + p->translate(bounds.x(), bounds.y()); d->doc->documentLayout()->draw(p, context); - p->translate(0, -y); + p->translate(-bounds.x(), -bounds.y()); } else { - d->drawWrappedText(p, QPointF(0,y), false); + d->drawTextLayout(p, QPointF(0, bounds.y()), false); } - if (needClip) + + if (needClip) { p->restore(); + } } } -/*! - \qmlproperty bool Text::smooth - - This property holds whether the text is smoothly scaled or transformed. - - Smooth filtering gives better visual quality, but is slower. If - the item is displayed at its natural size, this property has no visual or - performance effect. - - \note Generally scaling artifacts are only visible if the item is stationary on - the screen. A common pattern when animating an item is to disable smooth - filtering at the beginning of the animation and reenable it at the conclusion. -*/ - +/*! \internal */ void QDeclarativeText::componentComplete() { Q_D(QDeclarativeText); QDeclarativeItem::componentComplete(); - if (d->dirty) { + if (d->updateOnComponentComplete) { + d->updateOnComponentComplete = false; if (d->richText) { d->ensureDoc(); d->doc->setText(d->text); } d->updateLayout(); - d->dirty = false; } } -/*! - \overload - Handles the given mouse \a event. - */ +/*! \internal */ void QDeclarativeText::mousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeText); @@ -1214,26 +1278,7 @@ void QDeclarativeText::mousePressEvent(QGraphicsSceneMouseEvent *event) } -/*! - \qmlsignal Text::onLinkActivated(string link) - - This handler is called when the user clicks on a link embedded in the text. - The link must be in rich text or HTML format and the - \a link string provides access to the particular link. - - \snippet doc/src/snippets/declarative/text/onLinkActivated.qml 0 - - The example code will display the text - "The main website is at \l{http://qt.nokia.com}{Nokia Qt DF}." - - Clicking on the highlighted link will output - \tt{http://qt.nokia.com link activated} to the console. -*/ - -/*! - \overload - Handles the given mouse \a event. - */ +/*! \internal */ void QDeclarativeText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_D(QDeclarativeText); diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h index db68558..e37f477 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h @@ -74,24 +74,8 @@ public: ~QDeclarativeTextPrivate(); - void ensureDoc(); void updateSize(); void updateLayout(); - void markImgDirty() { - Q_Q(QDeclarativeText); - imgDirty = true; - if (q->isComponentComplete()) - q->update(); - } - void checkImgCache(); - - void drawOutline(); - void drawOutline(int yOffset); - - QPixmap wrappedTextImage(bool drawStyle); - void drawWrappedText(QPainter *p, const QPointF &pos, bool drawStyle); - QPixmap richTextImage(bool drawStyle); - QSize setupTextLayout(); QString text; QFont font; @@ -99,23 +83,37 @@ public: QDeclarativeText::TextStyle style; QColor styleColor; QString activeLink; - QPixmap imgCache; - QPixmap imgStyleCache; QDeclarativeText::HAlignment hAlign; QDeclarativeText::VAlignment vAlign; QDeclarativeText::TextElideMode elideMode; - bool imgDirty:1; - bool dirty:1; + QDeclarativeText::TextFormat format; + QDeclarativeText::WrapMode wrapMode; + + void invalidateImageCache(); + void checkImageCache(); + QPixmap imageCache; + + bool imageCacheDirty:1; + bool updateOnComponentComplete:1; bool richText:1; bool singleline:1; - bool cache:1; + bool cacheAllTextAsImage:1; bool internalWidthUpdate:1; + + QSize layedOutTextSize; + + void ensureDoc(); + QPixmap textDocumentImage(bool drawStyle); QTextDocumentWithImageResources *doc; + + QSize setupTextLayout(); + QPixmap textLayoutImage(bool drawStyle); + void drawTextLayout(QPainter *p, const QPointF &pos, bool drawStyle); QDeclarativeTextLayout layout; - QSize cachedLayoutSize; - QDeclarativeText::TextFormat format; - QDeclarativeText::WrapMode wrapMode; - + + static QPixmap drawOutline(const QPixmap &source, const QPixmap &styleSource); + static QPixmap drawOutline(const QPixmap &source, const QPixmap &styleSource, int yOffset); + static inline QDeclarativeTextPrivate *get(QDeclarativeText *t) { return t->d_func(); } -- cgit v0.12 From befbf33a0170de28631adb01c49491197595d20c Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Wed, 13 Oct 2010 15:12:28 +1000 Subject: Update reference bitmaps used in bitmap comparison tests to follow changes in Text painting Task-number: QTBUG-14374 --- .../declarative/qdeclarativetext/data/alignments_cb.png | Bin 496 -> 496 bytes .../declarative/qdeclarativetext/data/alignments_cc.png | Bin 556 -> 556 bytes .../declarative/qdeclarativetext/data/alignments_ct.png | Bin 533 -> 533 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png index 99de219..cf6199a 100644 Binary files a/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png and b/tests/auto/declarative/qdeclarativetext/data/alignments_cb.png differ diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png index cb85251..f81ccb4 100644 Binary files a/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png and b/tests/auto/declarative/qdeclarativetext/data/alignments_cc.png differ diff --git a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png index ddca549..9ba6412 100644 Binary files a/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png and b/tests/auto/declarative/qdeclarativetext/data/alignments_ct.png differ -- cgit v0.12 From deb92145c5bc69b7ee252687cf5b763b33f17775 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 28 Sep 2010 10:40:49 +1000 Subject: Update color type docs to mention transparency --- doc/src/declarative/basictypes.qdoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index e327d4a..e8aceb3 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -156,8 +156,10 @@ Example: \qml Rectangle { color: "steelblue" } + Rectangle { color: "transparent" } Rectangle { color: "#FF0000" } Rectangle { color: "#800000FF" } + Rectangle { color: "#00000000" } // ARGB fully transparent \endqml Or with the \l{QML:Qt::rgba()}{Qt.rgba()}, \l{QML:Qt::hsla()}{Qt.hsla()}, \l{QML:Qt::darker()}{Qt.darker()}, -- cgit v0.12 From a47835bf8cabffc127c2879b758f6730aca3d52b Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 13 Oct 2010 16:47:03 +1000 Subject: Fix worker ListModels to property emit countChanged() Task-number: QT-4094 --- src/declarative/util/qdeclarativelistmodelworkeragent.cpp | 2 +- .../qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp index 6804d4a..852b055 100644 --- a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp +++ b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp @@ -208,7 +208,7 @@ bool QDeclarativeListModelWorkerAgent::event(QEvent *e) const QList &changes = s->data.changes; if (m_copy) { - bool cc = m_copy->count() != s->list->count(); + bool cc = m_orig->count() != s->list->count(); FlatListModel *orig = m_orig->m_flat; FlatListModel *copy = s->list->m_flat; diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp index be77f8e..4b8d772 100644 --- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp +++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp @@ -320,11 +320,16 @@ void tst_qdeclarativelistmodel::dynamic() if (!warning.isEmpty()) QTest::ignoreMessage(QtWarningMsg, warning.toLatin1()); + QSignalSpy spyCount(&model, SIGNAL(countChanged())); + int actual = e.evaluate().toInt(); if (e.hasError()) qDebug() << e.error(); // errors not expected QCOMPARE(actual,result); + + if (model.count() > 0) + QVERIFY(spyCount.count() > 0); } void tst_qdeclarativelistmodel::dynamic_worker_data() @@ -351,6 +356,8 @@ void tst_qdeclarativelistmodel::dynamic_worker() QDeclarativeItem *item = createWorkerTest(&eng, &component, &model); QVERIFY(item != 0); + QSignalSpy spyCount(&model, SIGNAL(countChanged())); + if (script[0] == QLatin1Char('{') && script[script.length()-1] == QLatin1Char('}')) script = script.mid(1, script.length() - 2); QVariantList operations; @@ -367,6 +374,9 @@ void tst_qdeclarativelistmodel::dynamic_worker() waitForWorker(item); QCOMPARE(QDeclarativeProperty(item, "result").read().toInt(), result); + if (model.count() > 0) + QVERIFY(spyCount.count() > 0); + delete item; qApp->processEvents(); } -- cgit v0.12 From 1eb194d0b29e1bb3c5bafe711cea2c116cb2ea16 Mon Sep 17 00:00:00 2001 From: Morten Engvoldsen Date: Wed, 13 Oct 2010 09:48:18 +0200 Subject: Doc: adjusting the search field width --- doc/src/template/style/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index ec0202a..12d297d 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -650,7 +650,7 @@ margin-top: 5px; _margin: 0 0 0 -20px; padding: 10px; - width: 220px; + width: 30%; _width: 196px; height: 250px; overflow: auto; -- cgit v0.12 From 9abacb24b4e88e6811b90881d9e55764061607b2 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 13 Oct 2010 11:42:57 +0300 Subject: Added --remove-destination to qmake_emulator_deployment.flm This will fix the issue with deploying files when destination is owned by another user. Reviewed-by: TrustMe --- mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm b/mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm index 3877edb..a557cbb 100644 --- a/mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm +++ b/mkspecs/symbian-sbsv2/flm/qt/qmake_emulator_deployment.flm @@ -21,7 +21,7 @@ CLEAN_TARGET:=$(1) $(1): $(2) $(call startrule,qmake_emulator_deployment) \ - $(GNUCP) --no-preserve=mode $(2) "$$@" && \ + $(GNUCP) --remove-destination --no-preserve=mode $(2) "$$@" && \ $(GNUCHMOD) a+rw "$$@" \ $(call endrule,qmake_emulator_deployment) endef -- cgit v0.12 From 0f81945563441082551c65f964531c16e185d3de Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 13 Oct 2010 18:50:46 +1000 Subject: Fix autotest on windows --- src/declarative/qml/qdeclarativeengine.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 8e1416e..c3fdf36 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -2203,7 +2203,9 @@ bool QDeclarative_isFileCaseCorrect(const QString &fileName) #elif defined(Q_OS_WIN32) wchar_t buffer[1024]; - DWORD rv = ::GetLongPathName((wchar_t*)absolute.utf16(), buffer, 1024); + DWORD rv = ::GetShortPathName((wchar_t*)absolute.utf16(), buffer, 1024); + if (rv == 0 || rv >= 1024) return true; + rv = ::GetLongPathName(buffer, buffer, 1024); if (rv == 0 || rv >= 1024) return true; QString canonical((QChar *)buffer); -- cgit v0.12 From 1c86defda1d9cd3577898ec5f63c4d9bd250564b Mon Sep 17 00:00:00 2001 From: Jerome Pasion Date: Wed, 13 Oct 2010 13:12:34 +0200 Subject: Fixed statement about const_iterator and some whitespace fixes. Task-number: QTBUG-14252 Reviewed-by: David Boddie --- src/corelib/tools/qlinkedlist.cpp | 4 ++-- src/corelib/tools/qlist.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp index 909d940..7213c6e 100644 --- a/src/corelib/tools/qlinkedlist.cpp +++ b/src/corelib/tools/qlinkedlist.cpp @@ -254,7 +254,7 @@ QLinkedListData QLinkedListData::shared_null = { \sa insert() */ -/*! +/*! \fn bool QLinkedList::removeOne(const T &value) \since 4.4 @@ -830,7 +830,7 @@ QLinkedListData QLinkedListData::shared_null = { QLinkedList\::const_iterator allows you to iterate over a QLinkedList\. If you want modify the QLinkedList as you iterate - over it, you must use QLinkedList::const_iterator instead. It is + over it, you must use QLinkedList::iterator instead. It is generally good practice to use QLinkedList::const_iterator on a non-const QLinkedList as well, unless you need to change the QLinkedList through the iterator. Const iterators are slightly diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp index 6cc6fc1..9ba3768 100644 --- a/src/corelib/tools/qlist.cpp +++ b/src/corelib/tools/qlist.cpp @@ -936,7 +936,7 @@ void **QListData::erase(void **xi) This function requires the value type to have an implementation of \c operator==(). - Note that QList uses 0-based indexes, just like C++ arrays. Negative + Note that QList uses 0-based indexes, just like C++ arrays. Negative indexes are not supported with the exception of the value mentioned above. -- cgit v0.12