From 65acb111b085568597ebf8a83241f4b0ab63a037 2013-05-06 10:59:32 From: Miikka Heikkinen Date: 2013-05-06 10:59:32 Subject: [PATCH] Bring back the once removed demoLauncher. Since it is bit of a quick-and-dirty application, it now resides under tools dir, which is not included in releases. Change-Id: Iecfcbd761fc8e1ae371836fbd4f95d2489fbe39a Reviewed-by: Tomi Korpipää --- diff --git a/tools/demoLauncher/demoLauncher.pro b/tools/demoLauncher/demoLauncher.pro new file mode 100644 index 0000000..a8b8b12 --- /dev/null +++ b/tools/demoLauncher/demoLauncher.pro @@ -0,0 +1,9 @@ +!include( ../../demos/demos.pri ):error( "Couldn't find the demos.pri file!" ) + +TARGET = demoLauncher +SOURCES += main.cpp\ + widget.cpp \ + graphicsbutton.cpp + +HEADERS += widget.h \ + graphicsbutton.h diff --git a/tools/demoLauncher/graphicsbutton.cpp b/tools/demoLauncher/graphicsbutton.cpp new file mode 100644 index 0000000..4ec16f4 --- /dev/null +++ b/tools/demoLauncher/graphicsbutton.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "graphicsbutton.h" +#include +#include +#include + +GraphicsButton::GraphicsButton(const QString &path, QDir appFolder, const QString &app, QWidget *parent) : + QWidget(parent), + m_path(path), + m_appFolder(appFolder), + m_app(app), + m_demoApp(0) +{ + m_pixmap = QPixmap(path); +} + +GraphicsButton::~GraphicsButton() +{ + if (m_demoApp) + m_demoApp->close(); +} + +void GraphicsButton::mousePressEvent(QMouseEvent *event) +{ + QString program = m_appFolder.absolutePath() + QDir::separator() + m_app; + m_demoApp = new QProcess(this); + m_demoApp->start(program); + event->accept(); +} + +void GraphicsButton::paintEvent(QPaintEvent *event) +{ + QPainter painter(this); + painter.drawPixmap(0, 0, this->width(), this->height(), m_pixmap); + QWidget::paintEvent(event); +} diff --git a/tools/demoLauncher/graphicsbutton.h b/tools/demoLauncher/graphicsbutton.h new file mode 100644 index 0000000..4fd0ab4 --- /dev/null +++ b/tools/demoLauncher/graphicsbutton.h @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef GRAPHICSBUTTON_H +#define GRAPHICSBUTTON_H + +#include +#include + +class QProcess; + +class GraphicsButton : public QWidget +{ + Q_OBJECT +public: + explicit GraphicsButton(const QString &path, QDir appFolder, const QString &app, QWidget *parent = 0); + ~GraphicsButton(); +q +protected: + void mousePressEvent(QMouseEvent *event); + void paintEvent(QPaintEvent *event); + +private: + QPixmap m_pixmap; + QString m_path; + QDir m_appFolder; + QString m_app; + QProcess *m_demoApp; +}; + +#endif // GRAPHICSBUTTON_H diff --git a/tools/demoLauncher/main.cpp b/tools/demoLauncher/main.cpp new file mode 100644 index 0000000..dcf3dba --- /dev/null +++ b/tools/demoLauncher/main.cpp @@ -0,0 +1,31 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include "widget.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Widget w; + w.show(); + + return a.exec(); +} diff --git a/tools/demoLauncher/widget.cpp b/tools/demoLauncher/widget.cpp new file mode 100644 index 0000000..01b21f9 --- /dev/null +++ b/tools/demoLauncher/widget.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "widget.h" +#include +#include +#include +#include "graphicsbutton.h" + +Widget::Widget(QWidget *parent) + : QWidget(parent) +{ + setMinimumSize(800, 600); + + m_appFolder = QDir(QApplication::applicationDirPath()); +#ifdef Q_OS_MAC + // The executable is inside an application bundle (a folder) on OSX + m_appFolder.cdUp(); + m_appFolder.cdUp(); + m_appFolder.cdUp(); +#endif + + QDir imageFolder = m_appFolder; + imageFolder.cdUp(); + imageFolder.cdUp(); + imageFolder.cd("doc"); + imageFolder.cd("images"); + + // Create push buttons for starting the executables + QGridLayout* demosLayout = new QGridLayout; + + GraphicsButton *button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() + "demos_audio.png", m_appFolder, "audio", this); + demosLayout->addWidget(button, 0, 0); + + button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"demos_callout.png", m_appFolder, "callout", this); + demosLayout->addWidget(button, 0, 1); + + button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"demo_chartthemes_blue_cerulean.png", m_appFolder, "chartthemes", this); + demosLayout->addWidget(button, 0, 2); + + button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"demos_nesteddonuts.png", m_appFolder, "nesteddonuts", this); + demosLayout->addWidget(button, 1, 0); + + button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_zoomlinechart1.png", m_appFolder, "zoomlinechart", this); + demosLayout->addWidget(button, 1, 1); + + button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_stackedbarchartdrilldown1.png", m_appFolder, "stackedbarchartdrilldown", this); + demosLayout->addWidget(button, 1, 2); + + button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"piechart_customization.png", m_appFolder, "piechartcustomization", this); + demosLayout->addWidget(button, 2, 0); + + button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_datetimeaxis.png", m_appFolder, "datetimeaxis", this); + demosLayout->addWidget(button, 2, 1); + + button = new GraphicsButton(imageFolder.absolutePath() + QDir::separator() +"examples_donutbreakdown.png", m_appFolder, "donutbreakdown", this); + demosLayout->addWidget(button, 2, 2); + + setLayout(demosLayout); +} + +Widget::~Widget() +{ +} diff --git a/tools/demoLauncher/widget.h b/tools/demoLauncher/widget.h new file mode 100644 index 0000000..dc95762 --- /dev/null +++ b/tools/demoLauncher/widget.h @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the Qt Commercial Charts Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef WIDGET_H +#define WIDGET_H + +#include +#include + +class Widget : public QWidget +{ + Q_OBJECT + +public: + Widget(QWidget *parent = 0); + ~Widget(); + +private: + QDir m_appFolder; +}; + +#endif // WIDGET_H