From 54324efd46ae66014ebc139686e1a47e8833e66f Mon Sep 17 00:00:00 2001 From: Zoltan Papp Date: Mon, 31 Jan 2011 12:07:10 +0200 Subject: [PATCH 1/1] first commit: set up basic project structure, created simple qt+qml application --- .gitignore | 15 ++++++++ README | 1 + common-installs-config.pri | 88 ++++++++++++++++++++++++++++++++++++++++++++ common-project-config.pri | 41 +++++++++++++++++++++ common-vars.pri | 43 ++++++++++++++++++++++ quickdice.pro | 39 ++++++++++++++++++++ src/main.cpp | 34 +++++++++++++++++ src/mainwindow.cpp | 56 ++++++++++++++++++++++++++++ src/mainwindow.h | 39 ++++++++++++++++++++ src/src.pro | 72 ++++++++++++++++++++++++++++++++++++ src/test.qml | 37 +++++++++++++++++++ 11 files changed, 465 insertions(+) create mode 100644 .gitignore create mode 100644 README create mode 100644 common-installs-config.pri create mode 100644 common-project-config.pri create mode 100644 common-vars.pri create mode 100644 quickdice.pro create mode 100644 src/main.cpp create mode 100644 src/mainwindow.cpp create mode 100644 src/mainwindow.h create mode 100644 src/src.pro create mode 100644 src/test.qml delete mode 100644 welcome diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f26d2f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +Makefile* +.moc +.obj +lib*.so* +*.a +*.prl +*~ +.project +.cproject +*.pro.user* +core +core.* +*-stamp +src/quickdice + diff --git a/README b/README new file mode 100644 index 0000000..5f3882f --- /dev/null +++ b/README @@ -0,0 +1 @@ +This is a readme file. It should contain something useful to read =) diff --git a/common-installs-config.pri b/common-installs-config.pri new file mode 100644 index 0000000..4d49820 --- /dev/null +++ b/common-installs-config.pri @@ -0,0 +1,88 @@ +############################################################################### +# +# This file is part of quickdice. +# +# Copyright (C) 2011 Digia Plc. and/or its subsidiary(-ies). +# Contact: Zoltan Papp +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License version 2.1 as +# published by the Free Software Foundation. +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +############################################################################### + +#------------------------------------------------------------------------------ +# Common installation configuration for all projects. +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# setup the installation prefix +#------------------------------------------------------------------------------ +!include( common-vars.pri ) : \ + error( "Unable to include common-vars.pri" ) + +INSTALL_PREFIX = /usr # default installation prefix + +# default prefix can be overriden by defining PREFIX when running qmake +isEmpty( PREFIX ) { + + message("====") + message("==== NOTE: To override the installation path run: `qmake PREFIX=/custom/path'") + message("==== (current installation path is `$${INSTALL_PREFIX}')") +} else { + + INSTALL_PREFIX = $${PREFIX} + message("====") + message("==== install prefix set to `$${INSTALL_PREFIX}'") +} + +#------------------------------------------------------------------------------ +# default installation target for applications +#------------------------------------------------------------------------------ +contains( TEMPLATE, app ) { + + target.path = $${INSTALL_PREFIX}/bin + INSTALLS += target + message("====") + message("==== INSTALLS += target") +} + +#------------------------------------------------------------------------------ +# default installation target for libraries +#------------------------------------------------------------------------------ +contains( TEMPLATE, lib ) { + + target.path = $${INSTALL_PREFIX}/lib + INSTALLS += target + message("====") + message("==== INSTALLS += target") +} + +#----------------------------------------------------------------------------- +# target for header files +#----------------------------------------------------------------------------- +!isEmpty( headers.files ) { + + headers.path = $${INSTALL_PREFIX}/include/$${PROJECT_FULL_NAME} + INSTALLS += headers + message("====") + message("==== INSTALLS += headers") +} else { + + message("====") + message("==== NOTE: Remember to add your API headers into `headers.files' for installation!") +} + +#------------------------------------------------------------------------------ +# End of File +#------------------------------------------------------------------------------ + diff --git a/common-project-config.pri b/common-project-config.pri new file mode 100644 index 0000000..bef7a7b --- /dev/null +++ b/common-project-config.pri @@ -0,0 +1,41 @@ +############################################################################### +# +# This file is part of quickdice. +# +# Copyright (C) 2011 Digia Plc. and/or its subsidiary(-ies). +# Contact: Zoltan Papp +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License version 2.1 as +# published by the Free Software Foundation. +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +############################################################################### + +#------------------------------------------------------------------------------ +# Common configuration for all projects. +#------------------------------------------------------------------------------ + +CONFIG += link_pkgconfig +MOC_DIR = .moc +OBJECTS_DIR = .obj +RCC_DIR = resources +UI_DIR = ui +UI_HEADERS_DIR = ui/include +UI_SOURCES_DIR = ui/src + +# we don't like warnings... +QMAKE_CXXFLAGS *= -Werror + +#------------------------------------------------------------------------------ +# End of File +#------------------------------------------------------------------------------ + diff --git a/common-vars.pri b/common-vars.pri new file mode 100644 index 0000000..baf3d67 --- /dev/null +++ b/common-vars.pri @@ -0,0 +1,43 @@ +############################################################################### +# +# This file is part of quickdice. +# +# Copyright (C) 2011 Digia Plc. and/or its subsidiary(-ies). +# Contact: Zoltan Papp +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License version 2.1 as +# published by the Free Software Foundation. +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +############################################################################### + +#------------------------------------------------------------------------------ +# Common variables for all projects. +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# Project name (used e.g. in include file and doc install path). +# remember to update debian/* files if you changes this +#------------------------------------------------------------------------------ +PROJECT_NAME = quickdice +PROJECT_FULL_NAME = QuickDice + +#------------------------------------------------------------------------------ +# Project version +# remember to update debian/* files if you changes this +#----------------------------------------------------------------------------- +PROJECT_VERSION = 0.0.1 + +#------------------------------------------------------------------------------ +# End of File +#------------------------------------------------------------------------------ + diff --git a/quickdice.pro b/quickdice.pro new file mode 100644 index 0000000..9900b55 --- /dev/null +++ b/quickdice.pro @@ -0,0 +1,39 @@ +############################################################################### +# +# This file is part of quickdice. +# +# Copyright (C) 2011 Digia Plc. and/or its subsidiary(-ies). +# Contact: Zoltan Papp +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License version 2.1 as +# published by the Free Software Foundation. +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +############################################################################### + +!include( common-vars.pri ) : \ + error( "Unable to include common-vars.pri" ) + +TEMPLATE = subdirs +CONFIG += ordered +SUBDIRS = src + +#------------------------------------------------------------------------------ +# installation setup +#------------------------------------------------------------------------------ +!include( common-installs-config.pri ) : \ + error( "Unable to include common-installs-config.pri!" ) + +#------------------------------------------------------------------------------ +# End of File +#------------------------------------------------------------------------------ + diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..8fca5d2 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,34 @@ +/****************************************************************************** +** +** This file is part of quickdice. +** +** Copyright (C) 2011 Digia Plc. and/or its subsidiary(-ies). +** Contact: Zoltan Papp +** +** This library is free software; you can redistribute it and/or modify it +** under the terms of the GNU Lesser General Public License version 2.1 as +** published by the Free Software Foundation. +** +** 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, write to the Free Software Foundation, Inc., +** 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +** +******************************************************************************/ + +#include +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..74beed8 --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,56 @@ +/****************************************************************************** +** +** This file is part of quickdice. +** +** Copyright (C) 2011 Digia Plc. and/or its subsidiary(-ies). +** Contact: Zoltan Papp +** +** This library is free software; you can redistribute it and/or modify it +** under the terms of the GNU Lesser General Public License version 2.1 as +** published by the Free Software Foundation. +** +** 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, write to the Free Software Foundation, Inc., +** 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +** +******************************************************************************/ + +#include "mainwindow.h" +#include +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + QDeclarativeView *view = new QDeclarativeView; + setCentralWidget(view); + + QDeclarativeEngine *engine = view->engine(); + QDeclarativeContext *context = engine->rootContext(); + context->setContextProperty(QLatin1String("message"), + QLatin1String("Hello World!")); + context->setContextProperty(QLatin1String("defaultColor"), + QColor(Qt::lightGray)); + + QAction *action = new QAction(this); + connect(action, + SIGNAL(triggered()), + this, + SLOT(close())); + context->setContextProperty(QLatin1String("action"), + action); + + // FIXME: load it properly from a resource file + QString fn = "test.qml"; + view->setSource(fn); +} + +MainWindow::~MainWindow() +{ +} + diff --git a/src/mainwindow.h b/src/mainwindow.h new file mode 100644 index 0000000..04ca51e --- /dev/null +++ b/src/mainwindow.h @@ -0,0 +1,39 @@ +/****************************************************************************** +** +** This file is part of quickdice. +** +** Copyright (C) 2011 Digia Plc. and/or its subsidiary(-ies). +** Contact: Zoltan Papp +** +** This library is free software; you can redistribute it and/or modify it +** under the terms of the GNU Lesser General Public License version 2.1 as +** published by the Free Software Foundation. +** +** 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, write to the Free Software Foundation, Inc., +** 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +** +******************************************************************************/ + +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +}; + +#endif // MAINWINDOW_H + diff --git a/src/src.pro b/src/src.pro new file mode 100644 index 0000000..20bac34 --- /dev/null +++ b/src/src.pro @@ -0,0 +1,72 @@ +############################################################################### +# +# This file is part of quickdice. +# +# Copyright (C) 2011 Digia Plc. and/or its subsidiary(-ies). +# Contact: Zoltan Papp +# +# This library is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License version 2.1 as +# published by the Free Software Foundation. +# +# 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, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +############################################################################### + +!include( ../common-project-config.pri ) : \ + error( "Unable to include common-project-config.pri" ) +!include( ../common-vars.pri ) : \ + error( "Unable to include common-vars.pri" ) + +# ----------------------------------------------------------------------------- +# Target setup +# ----------------------------------------------------------------------------- +TEMPLATE = app +TARGET = $${PROJECT_NAME} + +QT += core \ + gui \ + declarative + +# ----------------------------------------------------------------------------- +# Dependencies +# ----------------------------------------------------------------------------- +INCLUDEPATH += . + +DEPENDPATH += $$INCLUDEPATH + +# ----------------------------------------------------------------------------- +# Input +# ----------------------------------------------------------------------------- +HEADERS += mainwindow.h + +SOURCES += mainwindow.cpp \ + main.cpp + +# TODO: this should be a resource, but for now it will be fine here +OTHER_FILES += test.qml + +# ----------------------------------------------------------------------------- +# Common installation setup +# NOTE: remember to set headers.files before this include to have the headers +# properly setup. +# ----------------------------------------------------------------------------- +!include( ../common-installs-config.pri ) : \ + error( "Unable to include common-installs-config.pri" ) + +# ----------------------------------------------------------------------------- +# Installation target for the .desktop file +# ----------------------------------------------------------------------------- +# TODO: desktop file needed + +#------------------------------------------------------------------------------ +# End of File +#------------------------------------------------------------------------------ + diff --git a/src/test.qml b/src/test.qml new file mode 100644 index 0000000..b1af437 --- /dev/null +++ b/src/test.qml @@ -0,0 +1,37 @@ +import Qt 4.7 + +Rectangle { + width: 640 + height: 480 + color: defaultColor + + Text { + id: name + text: message + anchors.centerIn: parent + } + + Rectangle { + id: myButton + width: 250 + height: 25 + color: defaultColor + + MouseArea { + anchors.fill: parent + onClicked: { + console.log("onMyButtonClicked"); + action.trigger(); + } + + } + + Text { + id: myButtonText + text: ">> Close button <<" + font.pointSize: 16 + anchors.centerIn: parent + } + } + +} diff --git a/welcome b/welcome deleted file mode 100644 index e69de29..0000000 -- 1.7.9.5