Verified Commit 7840b51c authored by Daniel Vrátil's avatar Daniel Vrátil 🤖
Browse files

Add --view option to open contact

Summary:
Opens KAddressbook and selects the contact or contact group
matching the given Akonadi URL. Also introduces kaddresbook-view
desktop file to allow opening the URL through a desktop service.

Test Plan: kaddressbook --view "akonadi://?item=<some-contact-akonadi-id>"

Reviewers: #kde_pim, winterz

Reviewed By: #kde_pim, winterz

Subscribers: winterz, kde-pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D29531
parent 9a66987d
......@@ -38,7 +38,7 @@ endif()
set(KDEPIM_VERSION "${PIM_VERSION}${KDEPIM_DEV_VERSION} (${RELEASE_SERVICE_VERSION})")
set(KPIMTEXTEDIT_LIB_VERSION "5.14.40")
set(AKONADI_VERSION "5.14.40")
set(AKONADI_VERSION "5.14.43")
set(KONTACTINTERFACE_LIB_VERSION "5.14.42")
set(KDEPIM_LIB_VERSION "${PIM_VERSION}")
......
......@@ -139,7 +139,11 @@ target_link_libraries(kaddressbook
)
install(TARGETS kaddressbook ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
install(PROGRAMS data/org.kde.kaddressbook.desktop data/kaddressbook-importer.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(PROGRAMS
data/org.kde.kaddressbook.desktop
data/kaddressbook-view.desktop
data/kaddressbook-importer.desktop
DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES data/org.kde.kaddressbook.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
set(kaddressbook_PART_SRCS kaddressbookpart.cpp kaddressbook_debug.cpp ${kaddressbook_qrc_SRCS})
......
[Desktop Entry]
Name=KAddressBook View
Comment=Display contact specified by URL
Type=Application
Exec=kaddressbook --view %u
Icon=kaddressbook
Terminal=false
StartupNotify=true
MimeType=text/directory;application/x-vnd.kde.contactgroup
X-KDE-StartupNotify=true
X-DBUS-StartupType=Unique
X-DBUS-ServiceName=org.kde.kaddressbook
......@@ -36,6 +36,11 @@ static void kaddressbook_options(QCommandLineParser *parser)
QStringLiteral("newcontact"),
i18n("Open the 'New Contact' dialog")));
parser->addOption(
QCommandLineOption(
QStringLiteral("view"),
i18n("Display the specified contact (by URL)"), QStringLiteral("url")));
parser->addPositionalArgument(
QStringLiteral("urls"),
i18n("Files or URLs. The user will be asked whether to import."),
......
......@@ -402,6 +402,9 @@ void MainWidget::handleCommandLine(const QStringList &arguments)
}
} else if (parser.isSet(QStringLiteral("newcontact"))) {
newContact();
} else if (parser.isSet(QStringLiteral("view"))) {
const auto url = QUrl{parser.value(QStringLiteral("view"))};
mPendingSelection = Akonadi::Item::fromUrl(url);
}
}
......@@ -472,8 +475,14 @@ void MainWidget::restoreState()
saver->setView(mItemView);
saver->setSelectionModel(mItemView->selectionModel());
const KConfigGroup group(Settings::self()->config(), "ItemViewState");
saver->restoreState(group);
if (mPendingSelection.isValid()) {
saver->selectItems({mPendingSelection});
saver->setCurrentItem(mPendingSelection);
mPendingSelection = {};
} else {
const KConfigGroup group(Settings::self()->config(), "ItemViewState");
saver->restoreState(group);
}
}
}
......
......@@ -168,6 +168,8 @@ private:
KAddressBookImportExport::KAddressBookImportExportPluginManager *mImportExportPluginManager = nullptr;
QList<KAddressBookImportExport::KAddressBookImportExportPluginInterface *> mImportExportPluginInterfaceList;
ManageShowCollectionProperties *mManageShowCollectionProperties = nullptr;
Akonadi::Item mPendingSelection;
};
#endif
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