Properly initialize kded dbus object
- kded module uses underscore instead of a dash - dbus interface is based on the generated adapter - added the d_ptr template class
This commit is contained in:
parent
7c5e2e49ae
commit
b78db9acd6
@ -1,10 +1,27 @@
|
||||
set(kded_platformstatus_SRCS platformstatus.cpp )
|
||||
set(
|
||||
kded_platformstatus_SRCS
|
||||
platformstatus.cpp
|
||||
)
|
||||
|
||||
kde4_add_plugin(kded_platformstatus ${kded_platformstatus_SRCS})
|
||||
include_directories("../utils")
|
||||
|
||||
target_link_libraries(kded_platformstatus ${KDE4_KDECORE_LIBS} ${KCoreAddons_LIBRARIES} Qt5::DBus)
|
||||
qt4_add_dbus_adaptor (
|
||||
kded_platformstatus_SRCS
|
||||
org.kde.platformstatus.xml
|
||||
platformstatus.h PlatformStatus
|
||||
)
|
||||
|
||||
install(TARGETS kded_platformstatus DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||
install( FILES kded-platformstatus.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded )
|
||||
install( FILES org.kde.platformstatus.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR} )
|
||||
kde4_add_plugin( kded_platformstatus ${kded_platformstatus_SRCS} )
|
||||
|
||||
target_link_libraries(
|
||||
kded_platformstatus
|
||||
${KDE4_KDECORE_LIBS}
|
||||
${KCoreAddons_LIBRARIES}
|
||||
Qt5::DBus
|
||||
Qt5::Quick
|
||||
)
|
||||
|
||||
install( TARGETS kded_platformstatus DESTINATION ${PLUGIN_INSTALL_DIR} )
|
||||
install( FILES kded_platformstatus.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded )
|
||||
install( FILES org.kde.platformstatus.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR} )
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <KDirWatch>
|
||||
#include <KPluginFactory>
|
||||
|
||||
#include "platformstatusadaptor.h"
|
||||
|
||||
const char *defaultPackage = "org.kde.desktop";
|
||||
|
||||
K_PLUGIN_FACTORY(PlatformStatusFactory, registerPlugin<PlatformStatus>();)
|
||||
@ -16,10 +18,11 @@ K_EXPORT_PLUGIN(PlatformStatusFactory("platformstatus"))
|
||||
PlatformStatus::PlatformStatus(QObject *parent, const QVariantList &)
|
||||
: KDEDModule(parent)
|
||||
{
|
||||
QDBusConnection::sessionBus().registerObject("/PlatformStatus", this,
|
||||
QDBusConnection::ExportAllProperties |
|
||||
QDBusConnection::ExportAllSignals);
|
||||
new PlatformStatusAdaptor(this);
|
||||
QDBusConnection::sessionBus().registerObject("/PlatformStatus", this);
|
||||
|
||||
findShellPackage(false);
|
||||
|
||||
const QString globalrcPath = QStandardPaths::locate(QStandardPaths::ConfigLocation, "kdeglobals");
|
||||
connect(KDirWatch::self(), SIGNAL(dirty(QString)), this, SLOT(fileDirtied(QString)));
|
||||
KDirWatch::self()->addFile(globalrcPath);
|
||||
|
52
src/utils/d_ptr.h
Normal file
52
src/utils/d_ptr.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Ivan Cukic <ivan.cukic(at)kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 2,
|
||||
* or (at your option) any later version, as published by the Free
|
||||
* Software Foundation
|
||||
*
|
||||
* This program 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 program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef D_PTR_H
|
||||
#define D_PTR_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace utils {
|
||||
|
||||
template <typename T>
|
||||
class d_ptr {
|
||||
private:
|
||||
std::unique_ptr<T> d;
|
||||
|
||||
public:
|
||||
d_ptr();
|
||||
|
||||
template <typename ...Args>
|
||||
d_ptr(Args && ...);
|
||||
|
||||
~d_ptr();
|
||||
|
||||
T * operator->() const;
|
||||
|
||||
T * get() const;
|
||||
};
|
||||
|
||||
#define D_PTR \
|
||||
class Private; \
|
||||
friend class Private; \
|
||||
const ::utils::d_ptr<Private> d \
|
||||
|
||||
} // namespace utils
|
||||
|
||||
#endif
|
59
src/utils/d_ptr_implementation.h
Normal file
59
src/utils/d_ptr_implementation.h
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Ivan Cukic <ivan.cukic(at)kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License version 2,
|
||||
* or (at your option) any later version, as published by the Free
|
||||
* Software Foundation
|
||||
*
|
||||
* This program 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 program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef D_PTR_IMPLEMENTATION_H
|
||||
#define D_PTR_IMPLEMENTATION_H
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace utils {
|
||||
|
||||
template <typename T>
|
||||
d_ptr<T>::d_ptr() : d(new T())
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename ...Args>
|
||||
d_ptr<T>::d_ptr(Args && ... args)
|
||||
: d(new T(std::forward<Args>(args)... ))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
d_ptr<T>::~d_ptr()
|
||||
{
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T * d_ptr<T>::operator->() const
|
||||
{
|
||||
return d.get();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T * d_ptr<T>::get() const
|
||||
{
|
||||
return d.get();
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user