Commit 15171577 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Port KAddressBook to new PimUniqueApplication API

parent 58c49dd4
......@@ -27,7 +27,7 @@
AboutData::AboutData()
: KAboutData(QLatin1String("kaddressbook"),
i18n("KAddressBook"),
KDEPIM_VERSION,
QLatin1String(KDEPIM_VERSION),
i18n("The KDE Address Book Application"),
KAboutLicense::GPL_V2,
i18n("Copyright © 2007–2015 KAddressBook authors"))
......
......@@ -24,13 +24,15 @@
static void kaddressbook_options(QCommandLineParser *parser)
{
parser->addOption(QCommandLineOption(QLatin1String("import"),
i18n("Import the given file")));
parser->addPositionalArgument(QLatin1String("urls"),
i18n("Files or URLs. THe user will be asked whether to import."),
QLatin1String("[urls...]"));
parser->addHelpOption();
parser->addVersionOption();
parser->addOption(
QCommandLineOption(
QLatin1String("import"),
i18n("Import the given file")));
parser->addPositionalArgument(
QLatin1String("urls"),
i18n("Files or URLs. THe user will be asked whether to import."),
QLatin1String("[urls...]"));
}
#endif // KADDRESSBOOK_OPTIONS_H
include_directories(${CMAKE_SOURCE_DIR}/kaddressbook)
set(kontact_kaddressbookplugin_PART_SRCS kaddressbookplugin_debug.cpp
kaddressbook_plugin.cpp
set(kontact_kaddressbookplugin_PART_SRCS
kaddressbookplugin_debug.cpp
kaddressbook_plugin.cpp
)
qt5_add_dbus_interfaces(kontact_kaddressbookplugin_PART_SRCS ${CMAKE_SOURCE_DIR}/kaddressbook/org.kde.kaddressbook.xml)
qt5_add_dbus_interfaces(kontact_kaddressbookplugin_PART_SRCS ../org.kde.kaddressbook.xml)
add_library(kontact_kaddressbookplugin MODULE ${kontact_kaddressbookplugin_PART_SRCS})
target_link_libraries(kontact_kaddressbookplugin KF5::KontactInterface)
target_link_libraries(kontact_kaddressbookplugin
KF5::KontactInterface
)
install(TARGETS kontact_kaddressbookplugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES kaddressbookplugin.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}/kontact)
install(FILES kaddressbook.setdlg DESTINATION ${KDE_INSTALL_DATADIR}/kontact/ksettingsdialog)
......@@ -189,13 +189,14 @@ void KAddressBookUniqueAppHandler::loadCommandLineOptions(QCommandLineParser *pa
kaddressbook_options(parser);
}
int KAddressBookUniqueAppHandler::newInstance(const QStringList &arguments)
int KAddressBookUniqueAppHandler::activate(const QStringList &arguments)
{
// Ensure part is loaded
(void)plugin()->part();
org::kde::kaddressbook kaddressbook(QStringLiteral("org.kde.kaddressbook"), QStringLiteral("/KAddressBook"), QDBusConnection::sessionBus());
QDBusReply<bool> reply = kaddressbook.handleCommandLine(arguments);
return KontactInterface::UniqueAppHandler::newInstance();
return KontactInterface::UniqueAppHandler::activate(arguments);
}
#include "kaddressbook_plugin.moc"
......@@ -33,8 +33,8 @@ class KAddressBookUniqueAppHandler : public KontactInterface::UniqueAppHandler
public:
explicit KAddressBookUniqueAppHandler(KontactInterface::Plugin *plugin)
: KontactInterface::UniqueAppHandler(plugin) {}
void loadCommandLineOptions() Q_DECL_OVERRIDE;
int newInstance() Q_DECL_OVERRIDE;
void loadCommandLineOptions(QCommandLineParser *parser) Q_DECL_OVERRIDE;
int activate(const QStringList &args) Q_DECL_OVERRIDE;
};
class KAddressBookPlugin : public KontactInterface::Plugin
......
......@@ -33,18 +33,18 @@
class KAddressBookApplication : public KontactInterface::PimUniqueApplication
{
public:
KAddressBookApplication()
: KontactInterface::PimUniqueApplication(),
KAddressBookApplication(int &argc, char **argv[])
: KontactInterface::PimUniqueApplication(argc, argv),
mMainWindow(Q_NULLPTR)
{
}
int newInstance(const QStringList &arguments) Q_DECL_OVERRIDE;
int activate(const QStringList &arguments) Q_DECL_OVERRIDE;
private:
MainWindow *mMainWindow;
};
int KAddressBookApplication::newInstance(const QStringList &arguments)
int KAddressBookApplication::activate(const QStringList &arguments)
{
qCDebug(KADDRESSBOOK_LOG) << "Launching new instance of KAddressBook";
if (!mMainWindow) {
......@@ -58,19 +58,24 @@ int KAddressBookApplication::newInstance(const QStringList &arguments)
int main(int argc, char **argv)
{
KLocalizedString::setApplicationDomain("kaddressbook");
KAddressBookApplication app(argc, &argv);
const QStringList args = QCoreApplication::arguments();
AboutData about;
AboutData::setApplicationData(about);
QCommandLineParser parser;
about.setupCommandLine(&parser);
kaddressbook_options(&parser);
// Handle --help, --version
parser.process(QCoreApplication::arguments());
if (!KAddressBookApplication::start()) {
parser.process(args);
about.processCommandLine(&parser);
if (!KAddressBookApplication::start(args)) {
return 0;
}
KAddressBookApplication app;
return app.exec();
}
......@@ -7,7 +7,8 @@
<method name="print"/>
<method name="printPreview"/>
<method name="configure"/>
<method name="handleCommandLine"/>
</method>
<method name="handleCommandLine">
<arg name="arguments" type="as" direction="in" />
</method>
</interface>
</node>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment