summaryrefslogtreecommitdiffstats
path: root/demos
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-05-22 09:28:05 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-05-22 09:28:05 (GMT)
commitd0ac49ec731f0781ba48f8f5d8ce04e19ce0010d (patch)
treeba6df139b3c343bb9352423770a99f218f62bd45 /demos
parent72798fc4dfc1af73cde542f9017dfec5cb020173 (diff)
parent8ad5020940f10d4ecc5c5e8b3b9656531cb84ef3 (diff)
downloadQt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.zip
Qt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.tar.gz
Qt-d0ac49ec731f0781ba48f8f5d8ce04e19ce0010d.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into kinetic-animations
Conflicts: src/corelib/kernel/kernel.pri src/corelib/kernel/qvariant_p.h src/corelib/tools/tools.pri src/gui/graphicsview/qgraphicsitem.cpp src/gui/graphicsview/qgraphicsitem.h src/gui/graphicsview/qgraphicswidget.h src/gui/gui.pro
Diffstat (limited to 'demos')
-rw-r--r--demos/arthurplugin/plugin.cpp74
-rw-r--r--demos/boxes/glextensions.h7
-rw-r--r--demos/chip/chip.cpp17
-rw-r--r--demos/demos.pro2
-rw-r--r--demos/qtdemo/colors.cpp31
-rw-r--r--demos/qtdemo/colors.h4
-rw-r--r--demos/qtdemo/mainwindow.cpp15
-rw-r--r--demos/spreadsheet/spreadsheet.cpp2
8 files changed, 80 insertions, 72 deletions
diff --git a/demos/arthurplugin/plugin.cpp b/demos/arthurplugin/plugin.cpp
index e2bf54e..c26aae7 100644
--- a/demos/arthurplugin/plugin.cpp
+++ b/demos/arthurplugin/plugin.cpp
@@ -55,7 +55,26 @@
QT_FORWARD_DECLARE_CLASS(QDesignerFormEditorInterface)
-static inline QString customWidgetDomXml(const QString &className)
+// Specify "text" to be a singleline property (no richtext)
+static inline QString textSingleLinePropertyDeclaration(const QString &className)
+{
+ QString rc = QLatin1String(
+ "<customwidgets>\n"
+ " <customwidget>\n"
+ " <class>");
+ rc += className;
+ rc += QLatin1String("</class>\n"
+ " <propertyspecifications>\n"
+ " <stringpropertyspecification name=\"text\" type=\"singleline\"/>\n"
+ " </propertyspecifications>\n"
+ " </customwidget>\n"
+ "</customwidgets>\n");
+ return rc;
+}
+
+// Plain XML for a custom widget
+static inline QString customWidgetDomXml(const QString &className,
+ const QString &customSection = QString())
{
QString rc = QLatin1String("<ui language=\"c++\"><widget class=\"");
rc += className;
@@ -63,7 +82,9 @@ static inline QString customWidgetDomXml(const QString &className)
QString objectName = className;
objectName[0] = objectName.at(0).toLower();
rc += objectName;
- rc += QLatin1String("\"/></ui>");
+ rc += QLatin1String("\"/>");
+ rc += customSection;
+ rc += QLatin1String("</ui>");
return rc;
}
@@ -80,7 +101,7 @@ class DemoPlugin : public QDesignerCustomWidgetInterface
Q_INTERFACES(QDesignerCustomWidgetInterface)
protected:
- DemoPlugin(const QString &className);
+ explicit DemoPlugin(const QString &className, const QString &customSection = QString());
public:
QString name() const { return m_className; }
@@ -105,9 +126,9 @@ private:
bool m_initialized;
};
-DemoPlugin::DemoPlugin(const QString &className) :
+DemoPlugin::DemoPlugin(const QString &className, const QString &customSection) :
m_className(className),
- m_domXml(customWidgetDomXml(className)),
+ m_domXml(customWidgetDomXml(className, customSection)),
m_initialized(false)
{
}
@@ -117,8 +138,8 @@ class DeformPlugin : public QObject, public DemoPlugin
Q_OBJECT
public:
- DeformPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("PathDeformRendererEx")) { }
- QString includeFile() const { return "deform.h"; }
+ explicit DeformPlugin(QObject *parent = 0);
+ QString includeFile() const { return QLatin1String("deform.h"); }
QWidget *createWidget(QWidget *parent)
{
@@ -126,12 +147,19 @@ public:
deform->setRadius(70);
deform->setAnimated(false);
deform->setFontSize(20);
- deform->setText("Arthur Widgets Demo");
+ deform->setText(QLatin1String("Arthur Widgets Demo"));
return deform;
}
};
+DeformPlugin::DeformPlugin(QObject *parent) :
+ QObject(parent),
+ DemoPlugin(QLatin1String("PathDeformRendererEx"),
+ textSingleLinePropertyDeclaration(QLatin1String("PathDeformRendererEx")))
+{
+}
+
class XFormRendererEx : public XFormView
{
Q_OBJECT
@@ -144,24 +172,30 @@ class XFormPlugin : public QObject, public DemoPlugin
{
Q_OBJECT
public:
- XFormPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("XFormRendererEx")) { }
- QString includeFile() const { return "xform.h"; }
+ explicit XFormPlugin(QObject *parent = 0);
+ QString includeFile() const { return QLatin1String("xform.h"); }
QWidget *createWidget(QWidget *parent)
{
XFormRendererEx *xform = new XFormRendererEx(parent);
- xform->setText("Qt - Hello World!!");
- xform->setPixmap(QPixmap(":/trolltech/arthurplugin/bg1.jpg"));
+ xform->setText(QLatin1String("Qt - Hello World!!"));
+ xform->setPixmap(QPixmap(QLatin1String(":/trolltech/arthurplugin/bg1.jpg")));
return xform;
}
};
+XFormPlugin::XFormPlugin(QObject *parent) :
+ QObject(parent),
+ DemoPlugin(QLatin1String("XFormRendererEx"),
+ textSingleLinePropertyDeclaration(QLatin1String("XFormRendererEx")))
+{
+}
class GradientEditorPlugin : public QObject, public DemoPlugin
{
Q_OBJECT
public:
- GradientEditorPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("GradientEditor")) { }
+ explicit GradientEditorPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("GradientEditor")) { }
QString includeFile() const { return "gradients.h"; }
QWidget *createWidget(QWidget *parent)
@@ -184,7 +218,7 @@ class GradientRendererPlugin : public QObject, public DemoPlugin
Q_OBJECT
public:
GradientRendererPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("GradientRendererEx")) { }
- QString includeFile() const { return "gradients.h"; }
+ QString includeFile() const { return QLatin1String("gradients.h"); }
QWidget *createWidget(QWidget *parent)
{
@@ -198,7 +232,7 @@ class PathStrokeRendererEx : public PathStrokeRenderer
{
Q_OBJECT
public:
- PathStrokeRendererEx(QWidget *p) : PathStrokeRenderer(p) { }
+ explicit PathStrokeRendererEx(QWidget *p) : PathStrokeRenderer(p) { }
QSize sizeHint() const { return QSize(300, 200); }
};
@@ -206,8 +240,8 @@ class StrokeRenderPlugin : public QObject, public DemoPlugin
{
Q_OBJECT
public:
- StrokeRenderPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("PathStrokeRendererEx")) { }
- QString includeFile() const { return "pathstroke.h"; }
+ explicit StrokeRenderPlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("PathStrokeRendererEx")) { }
+ QString includeFile() const { return QLatin1String("pathstroke.h"); }
QWidget *createWidget(QWidget *parent)
{
@@ -221,8 +255,8 @@ class CompositionModePlugin : public QObject, public DemoPlugin
{
Q_OBJECT
public:
- CompositionModePlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("CompositionRenderer")) { }
- QString includeFile() const { return "composition.h"; }
+ explicit CompositionModePlugin(QObject *parent = 0) : QObject(parent), DemoPlugin(QLatin1String("CompositionRenderer")) { }
+ QString includeFile() const { return QLatin1String("composition.h"); }
QWidget *createWidget(QWidget *parent)
{
@@ -239,7 +273,7 @@ class ArthurPlugins : public QObject, public QDesignerCustomWidgetCollectionInte
Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
public:
- ArthurPlugins(QObject *parent = 0);
+ explicit ArthurPlugins(QObject *parent = 0);
QList<QDesignerCustomWidgetInterface*> customWidgets() const { return m_plugins; }
private:
diff --git a/demos/boxes/glextensions.h b/demos/boxes/glextensions.h
index 74617d6..7ba3b32 100644
--- a/demos/boxes/glextensions.h
+++ b/demos/boxes/glextensions.h
@@ -120,8 +120,11 @@ glUnmapBuffer
//#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
#endif
+#ifndef GL_ARB_vertex_buffer_object
+typedef ptrdiff_t GLsizeiptrARB;
+#endif
+
#ifndef GL_VERSION_1_5
-typedef ptrdiff_t GLsizeiptr;
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_READ_WRITE 0x88BA
@@ -185,7 +188,7 @@ typedef void (APIENTRY *_glTexImage3D) (GLenum, GLint, GLenum, GLsizei, GLsizei,
typedef void (APIENTRY *_glGenBuffers) (GLsizei, GLuint *);
typedef void (APIENTRY *_glBindBuffer) (GLenum, GLuint);
-typedef void (APIENTRY *_glBufferData) (GLenum, GLsizeiptr, const GLvoid *, GLenum);
+typedef void (APIENTRY *_glBufferData) (GLenum, GLsizeiptrARB, const GLvoid *, GLenum);
typedef void (APIENTRY *_glDeleteBuffers) (GLsizei, const GLuint *);
typedef void *(APIENTRY *_glMapBuffer) (GLenum, GLenum);
typedef GLboolean (APIENTRY *_glUnmapBuffer) (GLenum);
diff --git a/demos/chip/chip.cpp b/demos/chip/chip.cpp
index c2b22da..4b6579e 100644
--- a/demos/chip/chip.cpp
+++ b/demos/chip/chip.cpp
@@ -74,8 +74,9 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
if (option->state & QStyle::State_MouseOver)
fillColor = fillColor.light(125);
- if (option->levelOfDetail < 0.2) {
- if (option->levelOfDetail < 0.125) {
+ const qreal lod = option->levelOfDetailFromTransform(painter->worldTransform());
+ if (lod < 0.2) {
+ if (lod < 0.125) {
painter->fillRect(QRectF(0, 0, 110, 70), fillColor);
return;
}
@@ -100,7 +101,7 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
painter->drawRect(QRect(14, 14, 79, 39));
painter->setBrush(b);
- if (option->levelOfDetail >= 1) {
+ if (lod >= 1) {
painter->setPen(QPen(Qt::gray, 1));
painter->drawLine(15, 54, 94, 54);
painter->drawLine(94, 53, 94, 15);
@@ -108,7 +109,7 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
}
// Draw text
- if (option->levelOfDetail >= 2) {
+ if (lod >= 2) {
QFont font("Times", 10);
font.setStyleStrategy(QFont::ForceOutline);
painter->setFont(font);
@@ -122,17 +123,17 @@ void Chip::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWid
// Draw lines
QVarLengthArray<QLineF, 36> lines;
- if (option->levelOfDetail >= 0.5) {
- for (int i = 0; i <= 10; i += (option->levelOfDetail > 0.5 ? 1 : 2)) {
+ if (lod >= 0.5) {
+ for (int i = 0; i <= 10; i += (lod > 0.5 ? 1 : 2)) {
lines.append(QLineF(18 + 7 * i, 13, 18 + 7 * i, 5));
lines.append(QLineF(18 + 7 * i, 54, 18 + 7 * i, 62));
}
- for (int i = 0; i <= 6; i += (option->levelOfDetail > 0.5 ? 1 : 2)) {
+ for (int i = 0; i <= 6; i += (lod > 0.5 ? 1 : 2)) {
lines.append(QLineF(5, 18 + i * 5, 13, 18 + i * 5));
lines.append(QLineF(94, 18 + i * 5, 102, 18 + i * 5));
}
}
- if (option->levelOfDetail >= 0.4) {
+ if (lod >= 0.4) {
const QLineF lineData[] = {
QLineF(25, 35, 35, 35),
QLineF(35, 30, 35, 40),
diff --git a/demos/demos.pro b/demos/demos.pro
index 9248ab8..6084550 100644
--- a/demos/demos.pro
+++ b/demos/demos.pro
@@ -30,7 +30,7 @@ contains(QT_BUILD_PARTS, tools):{
wince*: SUBDIRS += demos_sqlbrowser
}
}
-contains(QT_CONFIG, phonon)!static:SUBDIRS += demos_mediaplayer
+contains(QT_CONFIG, phonon):!static:SUBDIRS += demos_mediaplayer
contains(QT_CONFIG, webkit):contains(QT_CONFIG, svg):SUBDIRS += demos_browser
# install
diff --git a/demos/qtdemo/colors.cpp b/demos/qtdemo/colors.cpp
index 41bbfb3..733b285 100644
--- a/demos/qtdemo/colors.cpp
+++ b/demos/qtdemo/colors.cpp
@@ -72,10 +72,8 @@ int Colors::contentHeight = 510;
// Properties:
bool Colors::openGlRendering = false;
-bool Colors::direct3dRendering = false;
bool Colors::softwareRendering = false;
-bool Colors::openGlAwailable = true;
-bool Colors::direct3dAwailable = true;
+bool Colors::openGlAvailable = true;
bool Colors::xRenderPresent = true;
bool Colors::noTicker = false;
@@ -206,8 +204,6 @@ void Colors::parseArgs(int argc, char *argv[])
QString s(argv[i]);
if (s == "-opengl")
Colors::openGlRendering = true;
- else if (s == "-direct3d")
- Colors::direct3dRendering = true;
else if (s == "-software")
Colors::softwareRendering = true;
else if (s == "-no-opengl") // support old style
@@ -270,7 +266,7 @@ void Colors::parseArgs(int argc, char *argv[])
Colors::fps = int(parseFloat(s, "-fps"));
else if (s.startsWith("-h") || s.startsWith("-help")){
QMessageBox::warning(0, "Arguments",
- QString("Usage: qtdemo [-verbose] [-no-adapt] [-opengl] [-direct3d] [-software] [-fullscreen] [-ticker[0|1]] ")
+ QString("Usage: qtdemo [-verbose] [-no-adapt] [-opengl] [-software] [-fullscreen] [-ticker[0|1]] ")
+ "[-animations[0|1]] [-no-blending] [-no-sync] [-use-timer-update[0|1]] [-pause[0|1]] "
+ "[-use-window-mask] [-no-rescale] "
+ "[-use-pixmaps] [-show-fps] [-show-br] [-8bit[0|1]] [-menu<int>] [-use-loop] [-use-balls] "
@@ -290,7 +286,6 @@ void Colors::parseArgs(int argc, char *argv[])
void Colors::setLowSettings()
{
Colors::openGlRendering = false;
- Colors::direct3dRendering = false;
Colors::softwareRendering = true;
Colors::noTicker = true;
Colors::noTimerUpdate = true;
@@ -325,15 +320,11 @@ void Colors::detectSystemResources()
qDebug() << "- OpenGL not supported by current build of Qt";
#endif
{
- Colors::openGlAwailable = false;
+ Colors::openGlAvailable = false;
if (Colors::verbose)
qDebug("- OpenGL not recommended on this system");
}
-#if defined(Q_WS_WIN)
- Colors::direct3dAwailable = false; // for now.
-#endif
-
#if defined(Q_WS_X11)
// check if X render is present:
QPixmap tmp(1, 1);
@@ -369,21 +360,9 @@ void Colors::postConfigure()
}
}
-#if !defined(Q_WS_WIN)
- if (Colors::direct3dRendering){
- Colors::direct3dRendering = false;
- qDebug() << "- WARNING: Direct3D specified, but not supported on this platform";
- }
-#endif
-
- if (!Colors::openGlRendering && !Colors::direct3dRendering && !Colors::softwareRendering){
+ if (!Colors::openGlRendering && !Colors::softwareRendering){
// The user has not decided rendering system. So we do it instead:
-#if defined(Q_WS_WIN)
- if (Colors::direct3dAwailable)
- Colors::direct3dRendering = true;
- else
-#endif
- if (Colors::openGlAwailable)
+ if (Colors::openGlAvailable)
Colors::openGlRendering = true;
else
Colors::softwareRendering = true;
diff --git a/demos/qtdemo/colors.h b/demos/qtdemo/colors.h
index 58865c6..31eb93b 100644
--- a/demos/qtdemo/colors.h
+++ b/demos/qtdemo/colors.h
@@ -81,11 +81,9 @@ public:
static int contentHeight;
// properties:
+ static bool openGlAvailable;
static bool openGlRendering;
- static bool direct3dRendering;
static bool softwareRendering;
- static bool openGlAwailable;
- static bool direct3dAwailable;
static bool xRenderPresent;
static bool noAdapt;
static bool noTicker;
diff --git a/demos/qtdemo/mainwindow.cpp b/demos/qtdemo/mainwindow.cpp
index 8723823..0da69b2 100644
--- a/demos/qtdemo/mainwindow.cpp
+++ b/demos/qtdemo/mainwindow.cpp
@@ -100,14 +100,8 @@ void MainWindow::setRenderingSystem()
{
QWidget *viewport = 0;
- if (Colors::direct3dRendering){
- viewport->setAttribute(Qt::WA_MSWindowsUseDirect3D);
- setCacheMode(QGraphicsView::CacheNone);
- if (Colors::verbose)
- qDebug() << "- using Direct3D";
- }
#ifndef QT_NO_OPENGL
- else if (Colors::openGlRendering){
+ if (Colors::openGlRendering) {
QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers));
if (Colors::noScreenSync)
glw->format().setSwapInterval(0);
@@ -116,9 +110,10 @@ void MainWindow::setRenderingSystem()
setCacheMode(QGraphicsView::CacheNone);
if (Colors::verbose)
qDebug() << "- using OpenGL";
- }
+ } else // software rendering
#endif
- else{ // software rendering
+ {
+ // software rendering
viewport = new QWidget;
setCacheMode(QGraphicsView::CacheBackground);
if (Colors::verbose)
@@ -389,8 +384,6 @@ void MainWindow::keyPressEvent(QKeyEvent *event)
s += "Rendering system: ";
if (Colors::openGlRendering)
s += "OpenGL";
- else if (Colors::direct3dRendering)
- s += "Direct3D";
else
s += "software";
diff --git a/demos/spreadsheet/spreadsheet.cpp b/demos/spreadsheet/spreadsheet.cpp
index 742855e..d740aee 100644
--- a/demos/spreadsheet/spreadsheet.cpp
+++ b/demos/spreadsheet/spreadsheet.cpp
@@ -481,7 +481,7 @@ void SpreadSheet::setupContents()
table->setItem(3, 0, new SpreadSheetItem("Lunch"));
table->setItem(4, 0, new SpreadSheetItem("Flight (LA)"));
table->setItem(5, 0, new SpreadSheetItem("Taxi"));
- table->setItem(6, 0, new SpreadSheetItem("Diinner"));
+ table->setItem(6, 0, new SpreadSheetItem("Dinner"));
table->setItem(7, 0, new SpreadSheetItem("Hotel"));
table->setItem(8, 0, new SpreadSheetItem("Flight (Oslo)"));
table->setItem(9, 0, new SpreadSheetItem("Total:"));