2 * Copyright (C) 2016-2017 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17#include "URLDispatcher.h"
19#include <QDBusConnection>
22class URLDispatcherInterface : public QObject
25 Q_CLASSINFO("D-Bus Interface", "com.canonical.URLDispatcher")
28 explicit URLDispatcherInterface(URLDispatcher *parent);
30 Q_SCRIPTABLE void DispatchURL(const QString &url, const QString &package);
33URLDispatcherInterface::URLDispatcherInterface(URLDispatcher *parent)
38void URLDispatcherInterface::DispatchURL(const QString &url, const QString &package)
41 Q_EMIT static_cast<URLDispatcher *>(parent())->urlRequested(url);
44URLDispatcher::URLDispatcher(QObject *parent)
46 , m_dispatcher(nullptr)
50bool URLDispatcher::active() const
52 return m_dispatcher != nullptr;
55void URLDispatcher::setActive(bool value)
57 if (value == active())
60 QDBusConnection connection = QDBusConnection::sessionBus();
63 URLDispatcherInterface *dispatcher = new URLDispatcherInterface(this);
64 connection.registerObject(QStringLiteral("/com/canonical/URLDispatcher"),
66 QDBusConnection::ExportScriptableContents);
67 if (!connection.registerService(QStringLiteral("com.canonical.URLDispatcher"))) {
68 qWarning() << "Unable to register DBus service com.canonical.URLDispatcher";
70 m_dispatcher = dispatcher;
72 connection.unregisterService(QStringLiteral("com.canonical.URLDispatcher"));
74 m_dispatcher = nullptr;
77 Q_EMIT activeChanged();
80#include "URLDispatcher.moc"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list