From 2ebcae816b0124bcb47d261e8182b6b6d3647b9c Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 8 Oct 2012 10:52:20 +0200 Subject: Make libqmenumodel a shared library. --- .bzrignore | 2 ++ libqmenumodel/src/CMakeLists.txt | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.bzrignore b/.bzrignore index 13a6812..46cf366 100644 --- a/.bzrignore +++ b/.bzrignore @@ -6,6 +6,8 @@ Testing/ cmake_install.cmake install_manifest.txt +libqmenumodel/src/libqmenumodel.so* + moc_*.cpp *_automoc.cpp diff --git a/libqmenumodel/src/CMakeLists.txt b/libqmenumodel/src/CMakeLists.txt index 373d11b..af08b1f 100644 --- a/libqmenumodel/src/CMakeLists.txt +++ b/libqmenumodel/src/CMakeLists.txt @@ -10,11 +10,15 @@ set(QMENUMODEL_SRC qstateaction.cpp ) -add_library(qmenumodel STATIC +add_library(qmenumodel SHARED ${QMENUMODEL_SRC} ) -set_target_properties(qmenumodel PROPERTIES COMPILE_FLAGS -fPIC) +set_target_properties(qmenumodel PROPERTIES + COMPILE_FLAGS -fPIC + SOVERSION 0 + VERSION 0.1.1 +) include_directories( ${GLIB_INCLUDE_DIRS} -- cgit v1.2.3 From 1fec6fd6a8dc1b50098c62701416b149be57198f Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 8 Oct 2012 11:13:55 +0200 Subject: Install the shared library and dev headers. --- libqmenumodel/src/CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libqmenumodel/src/CMakeLists.txt b/libqmenumodel/src/CMakeLists.txt index af08b1f..435b412 100644 --- a/libqmenumodel/src/CMakeLists.txt +++ b/libqmenumodel/src/CMakeLists.txt @@ -26,3 +26,18 @@ include_directories( qt5_use_modules(qmenumodel Core Widgets) +install(TARGETS qmenumodel LIBRARY DESTINATION lib${LIB_SUFFIX}) + +set(QMENUMODEL_HEADERS + dbus-enums.h + qdbusactiongroup.h + qdbusmenumodel.h + qdbusobject.h + qmenumodel.h + qstateaction.h +) + +install(FILES ${QMENUMODEL_HEADERS} + DESTINATION include/qmenumodel +) + -- cgit v1.2.3 From 0186c4ae77edeeb5ccbb9fd889c2fae625cd9f13 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 8 Oct 2012 11:43:21 +0200 Subject: Add a pkgconfig file for developers. --- .bzrignore | 1 + CMakeLists.txt | 3 +++ libqmenumodel/src/CMakeLists.txt | 18 +++++++++++++----- libqmenumodel/src/qmenumodel.pc.in | 13 +++++++++++++ 4 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 libqmenumodel/src/qmenumodel.pc.in diff --git a/.bzrignore b/.bzrignore index 46cf366..b81357f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -7,6 +7,7 @@ cmake_install.cmake install_manifest.txt libqmenumodel/src/libqmenumodel.so* +libqmenumodel/src/qmenumodel.pc moc_*.cpp *_automoc.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f51f637..261335a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,9 @@ project(qmenumodel) cmake_minimum_required(VERSION 2.8.9) +# Standard install paths +include(GNUInstallDirs) + find_package(Qt5Core REQUIRED) include(FindPkgConfig) pkg_check_modules(GLIB REQUIRED glib-2.0>=2.32) diff --git a/libqmenumodel/src/CMakeLists.txt b/libqmenumodel/src/CMakeLists.txt index 435b412..e3d65a1 100644 --- a/libqmenumodel/src/CMakeLists.txt +++ b/libqmenumodel/src/CMakeLists.txt @@ -10,11 +10,12 @@ set(QMENUMODEL_SRC qstateaction.cpp ) -add_library(qmenumodel SHARED +set(SHAREDLIBNAME qmenumodel) +add_library(${SHAREDLIBNAME} SHARED ${QMENUMODEL_SRC} ) -set_target_properties(qmenumodel PROPERTIES +set_target_properties(${SHAREDLIBNAME} PROPERTIES COMPILE_FLAGS -fPIC SOVERSION 0 VERSION 0.1.1 @@ -24,9 +25,9 @@ include_directories( ${GLIB_INCLUDE_DIRS} ) -qt5_use_modules(qmenumodel Core Widgets) +qt5_use_modules(${SHAREDLIBNAME} Core Widgets) -install(TARGETS qmenumodel LIBRARY DESTINATION lib${LIB_SUFFIX}) +install(TARGETS ${SHAREDLIBNAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) set(QMENUMODEL_HEADERS dbus-enums.h @@ -37,7 +38,14 @@ set(QMENUMODEL_HEADERS qstateaction.h ) +set(INCLUDEDIR qmenumodel) install(FILES ${QMENUMODEL_HEADERS} - DESTINATION include/qmenumodel + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${INCLUDEDIR} +) + +set(PCFILE qmenumodel.pc) +configure_file(${PCFILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${PCFILE} @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PCFILE} + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig ) diff --git a/libqmenumodel/src/qmenumodel.pc.in b/libqmenumodel/src/qmenumodel.pc.in new file mode 100644 index 0000000..1c410bc --- /dev/null +++ b/libqmenumodel/src/qmenumodel.pc.in @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: qmenumodel +Description: Qt binding for GMenuModel. +Version: 0.1 + +Requires.private: QtCore QtWidgets gio-2.0 +Libs: -L${libdir} -l@SHAREDLIBNAME@ +Cflags: -I${includedir}/@INCLUDEDIR@ + -- cgit v1.2.3 From a7852eabec9bcce2f93b30b9ea1c88ca2ab8d790 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 8 Oct 2012 12:37:52 +0200 Subject: Cosmetics: remove trailing spaces. --- libqmenumodel/src/qdbusmenumodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libqmenumodel/src/qdbusmenumodel.h b/libqmenumodel/src/qdbusmenumodel.h index fdf23f7..767451a 100644 --- a/libqmenumodel/src/qdbusmenumodel.h +++ b/libqmenumodel/src/qdbusmenumodel.h @@ -37,7 +37,7 @@ class QDBusMenuModel : public QMenuModel, public QDBusObject public: QDBusMenuModel(QObject *parent=0); - ~QDBusMenuModel(); + ~QDBusMenuModel(); Q_SIGNALS: void busTypeChanged(DBusEnums::BusType type); -- cgit v1.2.3 From fa5d7c1aa69ee8b4cf49c5e3cfe291e2f503f815 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 8 Oct 2012 13:44:24 +0200 Subject: =?UTF-8?q?Call=20g=5Ftype=5Finit()=20in=20the=20constructor=20for?= =?UTF-8?q?=20QDBusObject.=20This=20ensures=20it=20is=20always=20called=20?= =?UTF-8?q?where=20needed:=20clients=20don=E2=80=99t=20need=20to=20invoke?= =?UTF-8?q?=20it=20themselves.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libqmenumodel/QMenuModel/plugin.cpp | 5 ----- libqmenumodel/src/qdbusobject.cpp | 5 +++++ tests/client/actiongrouptest.cpp | 5 ----- tests/client/menuchangestest.cpp | 5 ----- tests/client/modeltest.cpp | 5 ----- tests/client/servicetest.cpp | 5 ----- 6 files changed, 5 insertions(+), 25 deletions(-) diff --git a/libqmenumodel/QMenuModel/plugin.cpp b/libqmenumodel/QMenuModel/plugin.cpp index 26650eb..ee05fff 100644 --- a/libqmenumodel/QMenuModel/plugin.cpp +++ b/libqmenumodel/QMenuModel/plugin.cpp @@ -17,10 +17,6 @@ * Renato Araujo Oliveira Filho */ -extern "C" { -#include -} - #include "plugin.h" #include "qmenumodel.h" #include "qdbusmenumodel.h" @@ -31,7 +27,6 @@ extern "C" { void QMenuModelQmlPlugin::registerTypes(const char *uri) { - g_type_init(); qmlRegisterUncreatableType(uri, 0, 1, "QMenuModel", "QMenuModel is a interface"); qmlRegisterUncreatableType(uri, 0, 1, "QStateAction", diff --git a/libqmenumodel/src/qdbusobject.cpp b/libqmenumodel/src/qdbusobject.cpp index 63be580..ba348ad 100644 --- a/libqmenumodel/src/qdbusobject.cpp +++ b/libqmenumodel/src/qdbusobject.cpp @@ -17,6 +17,10 @@ * Renato Araujo Oliveira Filho */ +extern "C" { +#include +} + #include "qdbusobject.h" #include @@ -73,6 +77,7 @@ QDBusObject::QDBusObject() m_busType(DBusEnums::None), m_status(DBusEnums::Disconnected) { + g_type_init(); qRegisterMetaType("DBusEnums::ConnectionStatus"); } diff --git a/tests/client/actiongrouptest.cpp b/tests/client/actiongrouptest.cpp index 958ddc7..116bd44 100644 --- a/tests/client/actiongrouptest.cpp +++ b/tests/client/actiongrouptest.cpp @@ -17,10 +17,6 @@ * Renato Araujo Oliveira Filho */ -extern "C" { -#include -} - #include "qdbusmenumodel.h" #include "qdbusactiongroup.h" #include "dbusmenuscript.h" @@ -42,7 +38,6 @@ private: private Q_SLOTS: void initTestCase() { - g_type_init(); Q_ASSERT(m_script.connect()); } diff --git a/tests/client/menuchangestest.cpp b/tests/client/menuchangestest.cpp index bc7dcbd..2015582 100644 --- a/tests/client/menuchangestest.cpp +++ b/tests/client/menuchangestest.cpp @@ -17,10 +17,6 @@ * Renato Araujo Oliveira Filho */ -extern "C" { -#include -} - #include "qdbusmenumodel.h" #include "dbusmenuscript.h" @@ -39,7 +35,6 @@ private: private Q_SLOTS: void initTestCase() { - g_type_init(); Q_ASSERT(m_script.connect()); } diff --git a/tests/client/modeltest.cpp b/tests/client/modeltest.cpp index 542b38a..9f6ee76 100644 --- a/tests/client/modeltest.cpp +++ b/tests/client/modeltest.cpp @@ -17,10 +17,6 @@ * Renato Araujo Oliveira Filho */ -extern "C" { -#include -} - #include "qdbusmenumodel.h" #include "dbusmenuscript.h" @@ -39,7 +35,6 @@ private: private Q_SLOTS: void initTestCase() { - g_type_init(); Q_ASSERT(m_script.connect()); } diff --git a/tests/client/servicetest.cpp b/tests/client/servicetest.cpp index d34ba79..a8b0c2a 100644 --- a/tests/client/servicetest.cpp +++ b/tests/client/servicetest.cpp @@ -17,10 +17,6 @@ * Renato Araujo Oliveira Filho */ -extern "C" { -#include -} - #include "qdbusmenumodel.h" #include "dbusmenuscript.h" @@ -46,7 +42,6 @@ private: private Q_SLOTS: void initTestCase() { - g_type_init(); Q_ASSERT(m_script.connect()); } -- cgit v1.2.3 From 07c325213712202f6398f62e8dbdc915b7da72e6 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 8 Oct 2012 13:45:00 +0200 Subject: Ensure libqmenumodel is linked against libglib and libgio. --- libqmenumodel/src/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libqmenumodel/src/CMakeLists.txt b/libqmenumodel/src/CMakeLists.txt index e3d65a1..8edb3e1 100644 --- a/libqmenumodel/src/CMakeLists.txt +++ b/libqmenumodel/src/CMakeLists.txt @@ -23,6 +23,12 @@ set_target_properties(${SHAREDLIBNAME} PROPERTIES include_directories( ${GLIB_INCLUDE_DIRS} + ${GIO_INCLUDE_DIRS} +) + +target_link_libraries(${SHAREDLIBNAME} + ${GLIB_LDFLAGS} + ${GIO_LDFLAGS} ) qt5_use_modules(${SHAREDLIBNAME} Core Widgets) -- cgit v1.2.3 From bc7eb612da5fb089c84840e8a1fc4bc0f20784ad Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 8 Oct 2012 16:25:10 +0200 Subject: Use the Q_EMIT keyword to emit signals. --- libqmenumodel/src/qdbusobject.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libqmenumodel/src/qdbusobject.cpp b/libqmenumodel/src/qdbusobject.cpp index ba348ad..4ee568f 100644 --- a/libqmenumodel/src/qdbusobject.cpp +++ b/libqmenumodel/src/qdbusobject.cpp @@ -100,7 +100,7 @@ void QDBusObject::setBusType(DBusEnums::BusType type) if (m_status != DBusEnums::Disconnected) disconnect(); m_busType = type; - busTypeChanged(m_busType); + Q_EMIT busTypeChanged(m_busType); } } @@ -115,7 +115,7 @@ void QDBusObject::setBusName(const QString &busName) if (m_status != DBusEnums::Disconnected) disconnect(); m_busName = busName; - busNameChanged(m_busName); + Q_EMIT busNameChanged(m_busName); } } @@ -130,7 +130,7 @@ void QDBusObject::setObjectPath(const QString &objectPath) if (m_status != DBusEnums::Disconnected) disconnect(); m_objectPath = objectPath; - objectPathChanged(m_objectPath); + Q_EMIT objectPathChanged(m_objectPath); } } @@ -138,7 +138,7 @@ void QDBusObject::setStatus(DBusEnums::ConnectionStatus status) { if (m_status != status) { m_status = status; - statusChanged(m_status); + Q_EMIT statusChanged(m_status); } } -- cgit v1.2.3 From d2ec6532acec6b555ec43354e3f1ed30bd7501c1 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 8 Oct 2012 16:25:49 +0200 Subject: Ensure the model is set before advertising the status as 'Connected'. --- libqmenumodel/src/qdbusobject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libqmenumodel/src/qdbusobject.cpp b/libqmenumodel/src/qdbusobject.cpp index 4ee568f..ecb8ee9 100644 --- a/libqmenumodel/src/qdbusobject.cpp +++ b/libqmenumodel/src/qdbusobject.cpp @@ -180,8 +180,8 @@ void QDBusObject::onServiceAppeared(GDBusConnection *connection, const gchar *, { QDBusObject *self = reinterpret_cast(data); - self->setStatus(DBusEnums::Connected); self->serviceAppear(connection); + self->setStatus(DBusEnums::Connected); } void QDBusObject::onServiceVanished(GDBusConnection *connection, const gchar *, gpointer data) -- cgit v1.2.3 From 93c81bd636991d15cd3d599a7c1dc5984163ace1 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 8 Oct 2012 17:01:04 +0200 Subject: Split the package into 3 packages: libqmenumodel0, libqmenumodel-dev, qmenumodel-qml. --- .bzrignore | 5 ++++- debian/control | 20 +++++++++++++++++++- debian/libqmenumodel-dev.install | 4 ++++ debian/libqmenumodel0.install | 2 ++ debian/qmenumodel-qml.install | 2 ++ 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 debian/libqmenumodel-dev.install create mode 100644 debian/libqmenumodel0.install create mode 100644 debian/qmenumodel-qml.install diff --git a/.bzrignore b/.bzrignore index b81357f..7722c4c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -26,7 +26,10 @@ doc/qmenumodel.qdocconf obj-* debian/files -debian/qmenumodel-qml +debian/tmp +debian/libqmenumodel0/ +debian/libqmenumodel-dev/ +debian/qmenumodel-qml/ debian/*.debhelper debian/*.debhelper.log debian/*.substvars diff --git a/debian/control b/debian/control index 211a3c1..9e83194 100644 --- a/debian/control +++ b/debian/control @@ -10,10 +10,28 @@ Build-Depends: debhelper (>= 8.0.0), qtdeclarative (>= 5.0), Standards-Version: 3.9.2 +Package: libqmenumodel0 +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends}, +Description: Qt binding for GMenuModel - shared library + +Package: libqmenumodel-dev +Section: libdevel +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends}, + libqmenumodel0 (= ${binary:Version}), + qtbase (>= 5.0), +Description: Qt binding for GMenuModel - development files + + Package: qmenumodel-qml Section: libs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, -Description: QML bindings for GMenuModel + libqmenumodel0 (= ${binary:Version}), +Description: Qt binding for GMenuModel - QML module diff --git a/debian/libqmenumodel-dev.install b/debian/libqmenumodel-dev.install new file mode 100644 index 0000000..31c0d09 --- /dev/null +++ b/debian/libqmenumodel-dev.install @@ -0,0 +1,4 @@ +usr/include/qmenumodel/*.h +usr/lib/*/pkgconfig/qmenumodel.pc +usr/lib/*/libqmenumodel.so + diff --git a/debian/libqmenumodel0.install b/debian/libqmenumodel0.install new file mode 100644 index 0000000..bea61ce --- /dev/null +++ b/debian/libqmenumodel0.install @@ -0,0 +1,2 @@ +usr/lib/*/libqmenumodel.so.* + diff --git a/debian/qmenumodel-qml.install b/debian/qmenumodel-qml.install new file mode 100644 index 0000000..58ec19a --- /dev/null +++ b/debian/qmenumodel-qml.install @@ -0,0 +1,2 @@ +opt/qt5/imports/QMenuModel/* + -- cgit v1.2.3 From 3ba2b418dee9416fbf38a50071b371ca7770c99d Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 9 Oct 2012 13:32:52 +0200 Subject: Add extended descriptions for all packages. Fixes lintian errors. --- debian/control | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 9e83194..b99db70 100644 --- a/debian/control +++ b/debian/control @@ -16,6 +16,8 @@ Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, Description: Qt binding for GMenuModel - shared library + Qt binding for GMenuModel that allows connecting to a menu model exposed on + D-Bus and presents it as a list model. Package: libqmenumodel-dev Section: libdevel @@ -25,7 +27,10 @@ Depends: ${shlibs:Depends}, libqmenumodel0 (= ${binary:Version}), qtbase (>= 5.0), Description: Qt binding for GMenuModel - development files - + Qt binding for GMenuModel that allows connecting to a menu model exposed on + D-Bus and presents it as a list model. + . + This package contains the development headers for libqmenumodel. Package: qmenumodel-qml Section: libs @@ -34,4 +39,6 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, libqmenumodel0 (= ${binary:Version}), Description: Qt binding for GMenuModel - QML module + QML module that allows connecting to a menu model exposed on D-Bus and presents + it as a list model. -- cgit v1.2.3 From b81741d8cc97e3c7c00436eba8fe53360542d721 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 9 Oct 2012 13:34:42 +0200 Subject: Ensure dh_makeshlibs ignores the QML module. Fixes an error and two warnings in lintian. --- debian/rules | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/rules b/debian/rules index 2756628..7e8093d 100755 --- a/debian/rules +++ b/debian/rules @@ -2,6 +2,7 @@ # -*- makefile -*- DEB_CMAKE_EXTRA_FLAGS = -DCMAKE_PREFIX_PATH=/opt/qt5/lib/cmake +DEB_DH_MAKESHLIBS_ARGS_qmenumodel-qml = -Xlibqmenumodel-qml.so include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/rules/utils.mk -- cgit v1.2.3 From b3dc371d27100dc838a01ab4c48c8b5724133273 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 9 Oct 2012 13:57:16 +0200 Subject: Add a missing Pre-Depends field to the control file. Fixes a lintian error. --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index b99db70..0e5d4c1 100644 --- a/debian/control +++ b/debian/control @@ -15,6 +15,7 @@ Section: libs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, +Pre-Depends: ${misc:Pre-Depends} Description: Qt binding for GMenuModel - shared library Qt binding for GMenuModel that allows connecting to a menu model exposed on D-Bus and presents it as a list model. -- cgit v1.2.3 From 35dfc73fc832d83bd1ef0caa583fbdbe0d6a397b Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 9 Oct 2012 15:24:38 +0200 Subject: Update TODO list. --- TODO | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/TODO b/TODO index cb3cfe6..85d962a 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ = TODO = - • Expose a plain Qt library as well as the QML plugin, so that QDBusMenuModel - can be used from C++ too - • Use PIMPLs to clean up the headers (see point above) + • Use PIMPLs to clean up the headers • Add a server-side API to allow applications to export their menus on the bus • … -- cgit v1.2.3 From 69538ac36e10b514576bcb61d413ebac45b63f0d Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 9 Oct 2012 15:52:06 +0200 Subject: Add a C++ example that demonstrates the use of libqmenumodel. --- examples/CMakeLists.txt | 20 +++++++++++ examples/README | 16 +++++++-- examples/info-menumodel.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 examples/CMakeLists.txt create mode 100644 examples/info-menumodel.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..028c6ef --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,20 @@ +# Standalone CMakeLists.txt to generate the info-menumodel executable. +# This is not built as part of libqmenumodel, it has to be built separately +# and it assumes libqmenumodel-dev is installed on the system. + +cmake_minimum_required(VERSION 2.8.9) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) + +find_package(Qt5Core REQUIRED) + +include(FindPkgConfig) +pkg_check_modules(QMENUMODEL REQUIRED qmenumodel) + +add_executable(info-menumodel info-menumodel.cpp) + +qt5_use_modules(info-menumodel Core) +include_directories(${QMENUMODEL_INCLUDE_DIRS}) +target_link_libraries(info-menumodel ${QMENUMODEL_LDFLAGS}) + diff --git a/examples/README b/examples/README index 1ecac0e..ab683f3 100644 --- a/examples/README +++ b/examples/README @@ -1,11 +1,23 @@ This directory contains examples that demonstrate how to use the QMenuModel -QML binding in applications. +binding in Qt and QML applications. + To export an example menu model on the bus, run 'exportmenu.py'. + To render this menu in a QML application, run 'render-menumodel.qml' in qmlscene. You will need to inform qmlscene of the location of the QMenuModel plugin if it’s not installed system-wide, e.g.: - qmlscene -I libqmenumodel examples/render-menumodel.qml + $ qmlscene -I libqmenumodel examples/render-menumodel.qml + + +To compile a C++ executable that uses libqmenumodel to monitor and print +information about the exported menu, run `cmake` and then `make` from this +directory. This assumes that libqmenumodel-dev is installed on the system +(it won’t work with a local copy). Then, run the executable generated: + + $ cmake . + $ make + $ ./info-menumodel diff --git a/examples/info-menumodel.cpp b/examples/info-menumodel.cpp new file mode 100644 index 0000000..d370731 --- /dev/null +++ b/examples/info-menumodel.cpp @@ -0,0 +1,87 @@ +/* + * Example executable that links against libqmenumodel to monitor + * and print information about a menu model exported on D-Bus. + */ + +// QMenuModel +#include "qmenumodel/qdbusmenumodel.h" + +// stdlib +#include + +// Qt +#include +#include + + +#define BUS_NAME "com.canonical.testmenu" +#define BUS_OBJECT_PATH "/com/canonical/testmenu" + + +class MenuModelMonitor : public QDBusMenuModel +{ + Q_OBJECT + +public: + MenuModelMonitor(QObject* parent=0) + : QDBusMenuModel(parent) + { + setProperty("busType", DBusEnums::SessionBus); + setProperty("busName", BUS_NAME); + setProperty("objectPath", BUS_OBJECT_PATH); + QObject::connect(this, SIGNAL(statusChanged(DBusEnums::ConnectionStatus)), + SLOT(onStatusChanged(DBusEnums::ConnectionStatus))); + QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex&, int, int)), + SLOT(onModelChanged())); + QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex&, int, int)), + SLOT(onModelChanged())); + std::cout << "Monitoring menu model " + << property("objectPath").toString().toUtf8().constData() + << " on the well-known name " + << property("busName").toString().toUtf8().constData() + << std::endl; + } + +private Q_SLOTS: + void onStatusChanged(DBusEnums::ConnectionStatus status) + { + std::cout << "Status of menu model changed to " << status << std::endl; + if (status == DBusEnums::Connected) { + printModel(this); + } + } + + void onModelChanged() + { + printModel(this); + } + +private: + void printModel(QMenuModel* model, int indent=0) + { + int count = model->rowCount(); + for (int i = 0; i < count; ++i) { + QModelIndex index = model->index(i, 0); + QString label = model->data(index, QMenuModel::Label).toString(); + QVariant submenu = model->data(index, QMenuModel::LinkSubMenu); + for (int j = 0; j < indent * 2; ++j) std::cout << " "; + std::cout << " > " << label.toUtf8().constData() << std::endl; + if (submenu.isValid()) { + printModel(qobject_cast(submenu.value()), indent + 1); + } + } + } +}; + +#include "info-menumodel.moc" + + +int main(int argc, char** argv) +{ + MenuModelMonitor monitor; + monitor.start(); + int result = QCoreApplication(argc, argv).exec(); + monitor.stop(); + return result; +} + -- cgit v1.2.3 From a3c6400a93152d5cf4dc63f9c90955f6245ceacd Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 9 Oct 2012 16:03:11 +0200 Subject: Add a changelog entry to explain the split into 3 binary packages. --- debian/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debian/changelog b/debian/changelog index 5cc0dbf..d47d38a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,10 @@ qmenumodel (0.1.1) UNRELEASED; urgency=low * Renaming source package to qmenumodel * Port to Qt5 + * Expose a C++ library, and separate into 3 binary packages: + - libqmenumodel0: C++ library + - libqmenumodel-dev: development headers for the C++ library + - qmenumodel-qml: QML module -- Olivier Tilloy Thu, 04 Oct 2012 17:37:23 +0200 -- cgit v1.2.3 From f04b6920ce1b7067e0da45ed05a8fc5e30f5122e Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Thu, 11 Oct 2012 11:04:59 +0200 Subject: =?UTF-8?q?Updated=20the=20TODO=20list:=20upon=20Renato=E2=80=99s?= =?UTF-8?q?=20suggestion,=20it=20would=20be=20interesting=20to=20add=20a?= =?UTF-8?q?=20ProjectConfig.cmake=20file.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TODO | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO b/TODO index 85d962a..e3880fb 100644 --- a/TODO +++ b/TODO @@ -2,5 +2,8 @@ • Use PIMPLs to clean up the headers • Add a server-side API to allow applications to export their menus on the bus + • [optional] Add a ProjectConfig.cmake file to allow other projects using + cmake to express a dependency on libqmenumodel without requesting pkgconfig + (see http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file) • … -- cgit v1.2.3