Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #11 from nemomobile/staging
declarative components, use cor macros, actor is moved to qtaround
  • Loading branch information
Denis Zalevskiy committed Feb 9, 2015
2 parents 2161095 + 4d8a41b commit d6acdf3
Show file tree
Hide file tree
Showing 20 changed files with 719 additions and 286 deletions.
72 changes: 15 additions & 57 deletions CMakeLists.txt
Expand Up @@ -5,73 +5,26 @@ IF(NOT DEFINED VERSION)
message(fatal_error "define VERSION")
ENDIF(NOT DEFINED VERSION)

option(ENABLE_QT4 "Build Qt4 version of libraries" OFF)

option(ENABLE_MULTIARCH "enable support for multi-arch distros (lib64)" OFF)
IF(ENABLE_MULTIARCH)
IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
SET(LIB_SUFFIX "")
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4)
SET(LIB_SUFFIX 64)
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
ELSE()
SET(LIB_SUFFIX "")
ENDIF()
SET(DST_LIB lib${LIB_SUFFIX})

find_package(PkgConfig REQUIRED)
pkg_check_modules(COR cor REQUIRED)

set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -O2 -g -feliminate-unused-debug-types -std=c++0x -fPIC"
)

#-Wno-psabi is to remove next g++ warning/note:
#the mangling of 'va_list' has changed in GCC 4.4
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wno-psabi"
)

#pkg_check_modules(STATEFS statefs-cpp REQUIRED)
find_package(Cor REQUIRED)
pkg_check_modules(QTAROUND qtaround REQUIRED)

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
# ${STATEFS_INCLUDES}
${COR_INCLUDES}
${COR_INCLUDE_DIRS}
${QTAROUND_INCLUDE_DIRS}
)

link_directories(
# ${STATEFS_LIBS}
${COR_LIBRARY_DIRS}
${QTAROUND_LIBRARY_DIRS}
)

add_custom_target(doc
COMMAND doxygen ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile)


if(ENABLE_QT4)

find_package(Qt4 4.7.0 REQUIRED)
include(${QT_USE_FILE})
add_definitions(-DQT_SHARED)

include_directories(
${QT_INCLUDE_DIR}
)
link_directories(
${QT_LIBRARY_DIRS}
)

install(DIRECTORY include/statefs DESTINATION include/qt4)

pkg_check_modules(CONTEXTSUBSCRIBER contextsubscriber-1.0 REQUIRED)
pkg_check_modules(CONTEXTPROVIDER contextprovider-1.0 REQUIRED)
include_directories(
${CONTEXTSUBSCRIBER_INCLUDE_DIRS}
${CONTEXTPROVIDER_INCLUDE_DIRS}
)

else(ENABLE_QT4)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION share/doc/statefs-qt5)

find_package(Qt5Core REQUIRED)

Expand All @@ -84,15 +37,20 @@ link_directories(
)

install(DIRECTORY include/statefs DESTINATION include/qt5)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/contextsubscriber)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include/contextsubscriber
# ${CMAKE_CURRENT_SOURCE_DIR}/include
)
install(FILES include/contextsubscriber/contextproperty.h DESTINATION include)

endif(ENABLE_QT4)
set(STATEFS_QT_MOC_HEADERS
${CMAKE_SOURCE_DIR}/include/contextsubscriber/contextproperty.h
${CMAKE_SOURCE_DIR}/include/statefs/qt/client.hpp
)

add_subdirectory(src/util)
add_subdirectory(src/contextkit-subscriber)
add_subdirectory(src/qml)
add_subdirectory(tests)
add_subdirectory(tools/monitor)

MESSAGE(STATUS "QT4=${ENABLE_QT4}")
MESSAGE(STATUS "VERSION=${VERSION}")
51 changes: 51 additions & 0 deletions include/statefs/qt/client.hpp
@@ -0,0 +1,51 @@
#ifndef _STATEFS_QT_CLIENT_HPP_
#define _STATEFS_QT_CLIENT_HPP_
/**
* @file client.hpp
* @brief Statefs Qt client interface
* @copyright (C) 2013-2014 Jolla Ltd.
* @par License: LGPL 2.1 http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
*/

#include <QObject>
#include <QVariant>

namespace statefs { namespace qt {

class DiscretePropertyImpl;

class DiscreteProperty : public QObject
{
Q_OBJECT;
public:
DiscreteProperty(QString const &, QObject *parent = nullptr);
~DiscreteProperty();

void refresh() const;

signals:
void changed(QVariant);

private:
DiscretePropertyImpl *impl_;
};

class PropertyWriterImpl;

class PropertyWriter : public QObject
{
Q_OBJECT;
public:
PropertyWriter(QString const &, QObject *parent = nullptr);
~PropertyWriter();

void set(QVariant);
signals:
void updated(bool);
private:
PropertyWriterImpl *impl_;
};

}}

#endif // _STATEFS_QT_CLIENT_HPP_
5 changes: 0 additions & 5 deletions include/statefs/qt/util.hpp
Expand Up @@ -17,12 +17,7 @@

namespace statefs { namespace qt {

#if QT_VERSION < 0x050000
typedef QFile FileErrorNs;
#else
typedef QFileDevice FileErrorNs;
#endif

class WriterImpl;

/**
Expand Down
18 changes: 11 additions & 7 deletions rpm/statefs-qt5.spec
@@ -1,3 +1,7 @@
%{!?cmake_install: %global cmake_install make install DESTDIR=%{buildroot}}
%{!?_libqt5_includedir: %global _libqt5_includedir %{_qt5_headerdir}}


Summary: Statefs Qt bindings
Name: statefs-qt5
Version: x.x.x
Expand All @@ -9,9 +13,10 @@ Source0: %{name}-%{version}.tar.bz2
BuildRequires: cmake >= 2.8
BuildRequires: statefs >= 0.3.18
BuildRequires: pkgconfig(statefs-cpp) >= 0.3.18
BuildRequires: pkgconfig(cor) >= 0.1.11
BuildRequires: pkgconfig(cor) >= 0.1.17
BuildRequires: pkgconfig(qtaround) >= 0.2.4
BuildRequires: pkgconfig(Qt5Core)
#BuildRequires: contextkit-devel
BuildRequires: pkgconfig(Qt5Qml)

%description
%{summary}
Expand Down Expand Up @@ -62,10 +67,8 @@ make doc

%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}

install -d -D -p -m755 %{buildroot}%{_datarootdir}/doc/statefs-qt5/html
cp -R doc/html/ %{buildroot}%{_datarootdir}/doc/statefs-qt5/
%cmake_install
make doc

%clean
rm -rf %{buildroot}
Expand All @@ -76,7 +79,7 @@ rm -rf %{buildroot}

%files devel
%defattr(-,root,root,-)
%{_qt5_headerdir}/statefs/qt/*.hpp
%{_libqt5_includedir}/statefs/qt/*.hpp
%{_libdir}/pkgconfig/statefs-qt5.pc

%files doc
Expand All @@ -87,6 +90,7 @@ rm -rf %{buildroot}
%defattr(-,root,root,-)
%{_libdir}/libcontextkit-statefs-qt5.so
%{_bindir}/contextkit-monitor
%{_libdir}/qt5/qml/Mer/State/*

%files %{subscriber_devel}
%defattr(-,root,root,-)
Expand Down
43 changes: 9 additions & 34 deletions src/contextkit-subscriber/CMakeLists.txt
@@ -1,50 +1,25 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC TRUE)
find_package(Qt5Core REQUIRED)

if(ENABLE_QT4)

configure_file(contextkit-statefs-qt4.pc.in contextkit-statefs-qt4.pc @ONLY)
configure_file(contextsubscriber-1.0.pc.in contextsubscriber-1.0.pc @ONLY)

# dirty hack: absolute path, moc is $$$
qt4_wrap_cpp(LIB_MOC_SRC
/usr/include/contextsubscriber/contextproperty.h property.hpp actor.hpp
)

add_library(contextkit-statefs-qt4
SHARED property.cpp
${LIB_MOC_SRC}
)
target_link_libraries(contextkit-statefs-qt4
${QT_QTCORE_LIBRARY}
statefs-qt4
${COR_LIBRARIES}
)

install(TARGETS contextkit-statefs-qt4 DESTINATION ${DST_LIB})
install(FILES contextkit-statefs-qt4.pc DESTINATION ${DST_LIB}/pkgconfig)
install(FILES contextsubscriber-1.0.pc DESTINATION ${DST_LIB}/pkgconfig)

else(ENABLE_QT4)

configure_file(contextkit-statefs.pc.in contextkit-statefs.pc @ONLY)
configure_file(contextsubscriber-1.0.pc.in contextsubscriber-1.0.pc @ONLY)
configure_install_pkgconfig(contextkit-statefs)
configure_install_pkgconfig(contextsubscriber-1.0)

qt5_wrap_cpp(LIB_MOC_SRC
${CMAKE_SOURCE_DIR}/include/contextsubscriber/contextproperty.h actor.hpp
${STATEFS_QT_MOC_HEADERS}
actor.hpp
)

add_library(contextkit-statefs-qt5
SHARED property.cpp
SHARED
property.cpp
${LIB_MOC_SRC}
)
target_link_libraries(contextkit-statefs-qt5
${Qt5Core_LIBRARIES}
statefs-qt5
${COR_LIBRARIES}
${QTAROUND_LIBRARIES}
)

install(TARGETS contextkit-statefs-qt5 DESTINATION ${DST_LIB})
install(FILES contextkit-statefs.pc DESTINATION ${DST_LIB}/pkgconfig)
install(FILES contextsubscriber-1.0.pc DESTINATION ${DST_LIB}/pkgconfig)

endif(ENABLE_QT4)
11 changes: 7 additions & 4 deletions src/contextkit-subscriber/actor.hpp
Expand Up @@ -9,6 +9,8 @@
#include <QScopedPointer>
#include <QDebug>

#include <qtaround/debug.hpp>

namespace cor { namespace qt {

class Actor_ : public QThread
Expand All @@ -32,16 +34,17 @@ class Actor : public Actor_

virtual ~Actor() {
if (obj_ && this != QThread::currentThread())
qWarning() << "Managed object is not deleted in a right thread"
<< "Current:" << QThread::currentThread()
<< ", Need:" << this;
qtaround::debug::warning
("Managed object is not deleted in a right thread"
, "Current:", QThread::currentThread()
, ", Need:", this);
auto app = QCoreApplication::instance();
if (app) {
if (isRunning())
quit();
if (QThread::currentThread() != this)
if (!wait(10000))
qWarning() << "Timeout: no quit from thread!";
qtaround::debug::warning("Timeout: no quit from thread!");
}
}

Expand Down

0 comments on commit d6acdf3

Please sign in to comment.