From 946c00a01ac43634c7c183dfca499931e348828d 2012-08-29 13:08:33 From: Tero Ahola Date: 2012-08-29 13:08:33 Subject: [PATCH] Disabled anti-aliasing by default in declarative impl --- diff --git a/demos/qmlchart/main.cpp b/demos/qmlchart/main.cpp index 46e6c95..c24846d 100644 --- a/demos/qmlchart/main.cpp +++ b/demos/qmlchart/main.cpp @@ -29,6 +29,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer->setSource(QUrl("qrc:/qml/qmlchart/loader.qml")); + viewer->setRenderHint(QPainter::Antialiasing, true); viewer->showExpanded(); return app->exec(); diff --git a/demos/qmlcustomizations/main.cpp b/demos/qmlcustomizations/main.cpp index adb8f56..ed2aeb4 100644 --- a/demos/qmlcustomizations/main.cpp +++ b/demos/qmlcustomizations/main.cpp @@ -29,6 +29,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer->setSource(QUrl("qrc:/qml/qmlcustomizations/loader.qml")); + viewer->setRenderHint(QPainter::Antialiasing, true); viewer->showExpanded(); return app->exec(); diff --git a/demos/qmlcustommodel/main.cpp b/demos/qmlcustommodel/main.cpp index 670f407..b6fd3e1 100644 --- a/demos/qmlcustommodel/main.cpp +++ b/demos/qmlcustommodel/main.cpp @@ -41,6 +41,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer->setSource(QUrl("qrc:/qml/qmlcustommodel/loader.qml")); + viewer->setRenderHint(QPainter::Antialiasing, true); viewer->showExpanded(); return app->exec(); diff --git a/demos/qmlf1legends/main.cpp b/demos/qmlf1legends/main.cpp index 111c3ba..c03a4f0 100644 --- a/demos/qmlf1legends/main.cpp +++ b/demos/qmlf1legends/main.cpp @@ -30,6 +30,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) QmlApplicationViewer viewer; viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer.setSource(QUrl("qrc:/qml/qmlf1legends/main.qml")); + viewer.setRenderHint(QPainter::Antialiasing, true); viewer.showExpanded(); return app->exec(); } diff --git a/demos/qmloscilloscope/datasource.cpp b/demos/qmloscilloscope/datasource.cpp index 65ce532..340dc9a 100644 --- a/demos/qmloscilloscope/datasource.cpp +++ b/demos/qmloscilloscope/datasource.cpp @@ -21,14 +21,14 @@ #include "datasource.h" #include #include -#include +#include #include #include #include QTCOMMERCIALCHART_USE_NAMESPACE -DataSource::DataSource(QAbstractScrollArea *appViewer, QObject *parent) : +DataSource::DataSource(QDeclarativeView *appViewer, QObject *parent) : QObject(parent), m_appViewer(appViewer), m_index(-1) @@ -94,3 +94,8 @@ void DataSource::setOpenGL(bool enabled) else m_appViewer->setViewport(0); } + +void DataSource::setAntialiasing(bool enabled) +{ + m_appViewer->setRenderHint(QPainter::Antialiasing, enabled); +} diff --git a/demos/qmloscilloscope/datasource.h b/demos/qmloscilloscope/datasource.h index 1a51815..0bde577 100644 --- a/demos/qmloscilloscope/datasource.h +++ b/demos/qmloscilloscope/datasource.h @@ -24,7 +24,7 @@ #include #include -class QAbstractScrollArea; +class QDeclarativeView; QTCOMMERCIALCHART_USE_NAMESPACE @@ -32,7 +32,7 @@ class DataSource : public QObject { Q_OBJECT public: - explicit DataSource(QAbstractScrollArea *appViewer, QObject *parent = 0); + explicit DataSource(QDeclarativeView *appViewer, QObject *parent = 0); signals: @@ -40,9 +40,10 @@ public slots: void generateData(int type, int rowCount, int colCount); void update(QAbstractSeries *series); void setOpenGL(bool enabled); + void setAntialiasing(bool enabled); private: - QAbstractScrollArea *m_appViewer; + QDeclarativeView *m_appViewer; QList > m_data; int m_index; }; diff --git a/demos/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml b/demos/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml index 5a47283..5567d9b 100644 --- a/demos/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml +++ b/demos/qmloscilloscope/qml/qmloscilloscope/ControlPanel.qml @@ -27,6 +27,7 @@ Column { signal seriesTypeChanged(string type) signal refreshRateChanged(variant rate); signal signalSourceChanged(string source, int signalCount, int sampleCount); + signal antialiasingEnabled(bool enabled) Text { text: "Oscilloscope" @@ -82,4 +83,11 @@ Column { currentSelection: 0 onSelectionChanged: animationsEnabled(currentSelection == 1); } + + MultiButton { + text: "Antialias: " + items: ["OFF", "ON"] + currentSelection: 0 + onSelectionChanged: antialiasingEnabled(currentSelection == 1); + } } diff --git a/demos/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml b/demos/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml index eedefb6..9509e84 100644 --- a/demos/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml +++ b/demos/qmloscilloscope/qml/qmloscilloscope/MultiButton.qml @@ -23,7 +23,7 @@ import QtQuick 1.0 Rectangle { id: button width: 120 - height: 35 + height: 30 border.color: "gray" radius: 7 property string text: "Option: " diff --git a/demos/qmloscilloscope/qml/qmloscilloscope/main.qml b/demos/qmloscilloscope/qml/qmloscilloscope/main.qml index bce675e..01f9735 100644 --- a/demos/qmloscilloscope/qml/qmloscilloscope/main.qml +++ b/demos/qmloscilloscope/qml/qmloscilloscope/main.qml @@ -46,6 +46,7 @@ Rectangle { onAnimationsEnabled: scopeView.setAnimations(enabled); onSeriesTypeChanged: scopeView.changeSeriesType(type); onRefreshRateChanged: scopeView.changeRefreshRate(rate); + onAntialiasingEnabled: dataSource.setAntialiasing(enabled); } //![2] diff --git a/demos/qmlweather/main.cpp b/demos/qmlweather/main.cpp index 6141bf2..1382601 100644 --- a/demos/qmlweather/main.cpp +++ b/demos/qmlweather/main.cpp @@ -38,6 +38,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) } viewer.rootContext()->setContextProperty("weatherAppKey", appKey); viewer.setSource(QUrl("qrc:/qml/qmlweather/main.qml")); + viewer.setRenderHint(QPainter::Antialiasing, true); viewer.showExpanded(); return app->exec(); } diff --git a/examples/qmlpiechart/main.cpp b/examples/qmlpiechart/main.cpp index a00f6c1..6f90968 100644 --- a/examples/qmlpiechart/main.cpp +++ b/examples/qmlpiechart/main.cpp @@ -29,6 +29,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer->setSource(QUrl("qrc:/qml/qmlpiechart/main.qml")); + viewer->setRenderHint(QPainter::Antialiasing, true); viewer->showExpanded(); return app->exec(); diff --git a/plugins/declarative/declarativechart.cpp b/plugins/declarative/declarativechart.cpp index 60f9dc3..b8688e3 100644 --- a/plugins/declarative/declarativechart.cpp +++ b/plugins/declarative/declarativechart.cpp @@ -223,7 +223,6 @@ DeclarativeChart::DeclarativeChart(QDeclarativeItem *parent) m_chart(new QChart(this)) { setFlag(QGraphicsItem::ItemHasNoContents, false); -// m_chart->axisX()->setNiceNumbersEnabled(false); //TODO: check what should be really here margins or platArea ?! m_chartMargins = m_chart->minimumMargins(); connect(m_chart, SIGNAL(marginsChanged(QRectF)), this, SLOT(handleMarginsChanged(QRectF))); @@ -366,15 +365,6 @@ void DeclarativeChart::geometryChanged(const QRectF &newGeometry, const QRectF & QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); } -void DeclarativeChart::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(option) - Q_UNUSED(widget) - - // TODO: optimized? - painter->setRenderHint(QPainter::Antialiasing, true); -} - void DeclarativeChart::setTheme(DeclarativeChart::Theme theme) { QChart::ChartTheme chartTheme = (QChart::ChartTheme) theme; diff --git a/plugins/declarative/declarativechart.h b/plugins/declarative/declarativechart.h index 5769143..94e76e4 100644 --- a/plugins/declarative/declarativechart.h +++ b/plugins/declarative/declarativechart.h @@ -90,7 +90,6 @@ public: // From QDeclarativeItem/QGraphicsItem void childEvent(QChildEvent *event); void componentComplete(); void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); - void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); public: void setTheme(DeclarativeChart::Theme theme); diff --git a/tests/qmlchartproperties/main.cpp b/tests/qmlchartproperties/main.cpp index dab33c8..2689717 100644 --- a/tests/qmlchartproperties/main.cpp +++ b/tests/qmlchartproperties/main.cpp @@ -29,6 +29,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[]) viewer->setOrientation(QmlApplicationViewer::ScreenOrientationAuto); viewer->setSource(QUrl("qrc:/qml/qmlchartproperties/loader.qml")); + viewer->setRenderHint(QPainter::Antialiasing, true); viewer->showExpanded(); return app->exec();