mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-08-01 01:07:33 +00:00
Refactor dialer code
This commit is contained in:
parent
73af5c54ef
commit
3d9e43b190
19 changed files with 48 additions and 55 deletions
|
|
@ -3,9 +3,9 @@ set(plasmaphonedialer_SRCS
|
||||||
dialerutils.cpp
|
dialerutils.cpp
|
||||||
call-handler.cpp
|
call-handler.cpp
|
||||||
call-manager.cpp
|
call-manager.cpp
|
||||||
|
resources.qrc
|
||||||
)
|
)
|
||||||
qt5_add_resources(RESOURCES resources.qrc)
|
add_executable(plasmaphonedialer ${plasmaphonedialer_SRCS})
|
||||||
add_executable(plasmaphonedialer ${plasmaphonedialer_SRCS} ${RESOURCES})
|
|
||||||
target_compile_definitions(plasmaphonedialer PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
|
target_compile_definitions(plasmaphonedialer PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
|
||||||
|
|
||||||
find_package(PhoneNumber COMPONENTS PhoneNumber REQUIRED)
|
find_package(PhoneNumber COMPONENTS PhoneNumber REQUIRED)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include <TelepathyQt/PendingReady>
|
#include <TelepathyQt/PendingReady>
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
#include <KLocalizedContext>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QCommandLineOption>
|
#include <QCommandLineOption>
|
||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
|
|
@ -162,19 +163,15 @@ int main(int argc, char **argv)
|
||||||
qCritical() << "Unable to get SIM account";
|
qCritical() << "Unable to get SIM account";
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const QString packagePath("org.kde.phone.dialer");
|
|
||||||
|
|
||||||
//usually we have an ApplicationWindow here, so we do not need to create a window by ourselves
|
QQmlApplicationEngine engine;
|
||||||
auto *obj = new KDeclarative::QmlObject();
|
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
|
||||||
obj->setTranslationDomain(packagePath);
|
|
||||||
obj->setInitializationDelayed(true);
|
|
||||||
obj->setSource(QUrl("qrc:///main.qml"));
|
|
||||||
obj->engine()->rootContext()->setContextProperty("commandlineArguments", parser.positionalArguments());
|
|
||||||
|
|
||||||
auto *dialerUtils = new DialerUtils(simAccount);
|
auto *dialerUtils = new DialerUtils(simAccount);
|
||||||
obj->engine()->rootContext()->setContextProperty("dialerUtils", QVariant::fromValue(dialerUtils));
|
engine.rootContext()->setContextProperty("dialerUtils", QVariant::fromValue(dialerUtils));
|
||||||
|
engine.rootContext()->setContextProperty("commandlineArguments", parser.positionalArguments());
|
||||||
|
|
||||||
obj->completeInitialization();
|
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||||
|
|
||||||
Tp::SharedPtr<CallHandler> callHandler(new CallHandler(dialerUtils));
|
Tp::SharedPtr<CallHandler> callHandler(new CallHandler(dialerUtils));
|
||||||
registrar->registerClient(Tp::AbstractClientPtr::dynamicCast(callHandler), "Plasma.Dialer");
|
registrar->registerClient(Tp::AbstractClientPtr::dynamicCast(callHandler), "Plasma.Dialer");
|
||||||
|
|
@ -184,39 +181,33 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
KAboutData::setApplicationData(aboutData);
|
KAboutData::setApplicationData(aboutData);
|
||||||
|
|
||||||
//The root is not a window?
|
QWindow *window = qobject_cast<QWindow *>(engine.rootObjects()[0]);
|
||||||
//have to use a normal QQuickWindow since the root item is already created
|
|
||||||
QWindow *window = qobject_cast<QWindow *>(obj->rootObject());
|
|
||||||
if (window) {
|
|
||||||
QObject::connect(&service, &KDBusService::activateRequested, [=](const QStringList &arguments, const QString &workingDirectory) {
|
|
||||||
Q_UNUSED(workingDirectory);
|
|
||||||
window->show();
|
|
||||||
window->requestActivate();
|
|
||||||
if (arguments.length() > 0) {
|
|
||||||
QString numberArg = arguments[1];
|
|
||||||
if (numberArg.startsWith("call://")) {
|
|
||||||
numberArg = numberArg.mid(7);
|
|
||||||
}
|
|
||||||
obj->rootObject()->metaObject()->invokeMethod(obj->rootObject(), "call", Q_ARG(QVariant, numberArg));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!parser.isSet(daemonOption)) {
|
|
||||||
window->show();
|
|
||||||
window->requestActivate();
|
|
||||||
}
|
|
||||||
window->setTitle(obj->package().metadata().name());
|
|
||||||
window->setIcon(QIcon::fromTheme(obj->package().metadata().iconName()));
|
|
||||||
|
|
||||||
if (!parser.positionalArguments().isEmpty()) {
|
Q_ASSERT(window);
|
||||||
QString numberArg = parser.positionalArguments().first();
|
|
||||||
|
QObject::connect(&service, &KDBusService::activateRequested, [=](const QStringList &arguments, const QString &workingDirectory) {
|
||||||
|
Q_UNUSED(workingDirectory);
|
||||||
|
window->show();
|
||||||
|
window->requestActivate();
|
||||||
|
if (arguments.length() > 0) {
|
||||||
|
QString numberArg = arguments[1];
|
||||||
if (numberArg.startsWith("call://")) {
|
if (numberArg.startsWith("call://")) {
|
||||||
numberArg = numberArg.mid(7);
|
numberArg = numberArg.mid(7);
|
||||||
}
|
}
|
||||||
qWarning() << "Calling" << numberArg;
|
dialerUtils->dial(numberArg);
|
||||||
obj->rootObject()->metaObject()->invokeMethod(obj->rootObject(), "call", Q_ARG(QVariant, numberArg));
|
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
qWarning() << "Error loading the ApplicationWindow";
|
if (!parser.isSet(daemonOption)) {
|
||||||
|
window->show();
|
||||||
|
window->requestActivate();
|
||||||
|
}
|
||||||
|
if (!parser.positionalArguments().isEmpty()) {
|
||||||
|
QString numberArg = parser.positionalArguments().first();
|
||||||
|
if (numberArg.startsWith("call://")) {
|
||||||
|
numberArg = numberArg.mid(7);
|
||||||
|
}
|
||||||
|
qWarning() << "Calling" << numberArg;
|
||||||
|
dialerUtils->dial(numberArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ ApplicationWindow {
|
||||||
width: 1080
|
width: 1080
|
||||||
height: 800
|
height: 800
|
||||||
|
|
||||||
|
visible: false
|
||||||
|
|
||||||
//keep track if we were visible when ringing
|
//keep track if we were visible when ringing
|
||||||
property bool wasVisible
|
property bool wasVisible
|
||||||
//was the last call an incoming one?
|
//was the last call an incoming one?
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file alias="main.qml">contents/ui/main.qml</file>
|
<file alias="main.qml">qml/main.qml</file>
|
||||||
<file alias="Call/AnswerSwipe.qml">contents/ui/Call/AnswerSwipe.qml</file>
|
<file alias="Call/AnswerSwipe.qml">qml/Call/AnswerSwipe.qml</file>
|
||||||
<file alias="Call/CallPage.qml">contents/ui/Call/CallPage.qml</file>
|
<file alias="Call/CallPage.qml">qml/Call/CallPage.qml</file>
|
||||||
<file alias="Call/Avatar.qml">contents/ui/Call/Avatar.qml</file>
|
<file alias="Call/Avatar.qml">qml/Call/Avatar.qml</file>
|
||||||
<file alias="Dialer/Dialer.qml">contents/ui/Dialer/Dialer.qml</file>
|
<file alias="Dialer/Dialer.qml">qml/Dialer/Dialer.qml</file>
|
||||||
<file alias="Dialer/ContactsList.qml">contents/ui/Dialer/ContactsList.qml</file>
|
<file alias="Dialer/ContactsList.qml">qml/Dialer/ContactsList.qml</file>
|
||||||
<file alias="Dialer/DialPage.qml">contents/ui/Dialer/DialPage.qml</file>
|
<file alias="Dialer/DialPage.qml">qml/Dialer/DialPage.qml</file>
|
||||||
<file alias="Dialer/private/SectionScroller.js">contents/ui/Dialer/private/SectionScroller.js</file>
|
<file alias="Dialer/private/SectionScroller.js">qml/Dialer/private/SectionScroller.js</file>
|
||||||
<file alias="Dialer/RoundImage.qml">contents/ui/Dialer/RoundImage.qml</file>
|
<file alias="Dialer/RoundImage.qml">qml/Dialer/RoundImage.qml</file>
|
||||||
<file alias="Dialer/History.qml">contents/ui/Dialer/History.qml</file>
|
<file alias="Dialer/History.qml">qml/Dialer/History.qml</file>
|
||||||
<file alias="Dialer/CustomSectionScroller.qml">contents/ui/Dialer/CustomSectionScroller.qml</file>
|
<file alias="Dialer/CustomSectionScroller.qml">qml/Dialer/CustomSectionScroller.qml</file>
|
||||||
<file alias="Dialer/HistoryDelegate.qml">contents/ui/Dialer/HistoryDelegate.qml</file>
|
<file alias="Dialer/HistoryDelegate.qml">qml/Dialer/HistoryDelegate.qml</file>
|
||||||
<file alias="Dialpad/Dialpad.qml">contents/ui/Dialpad/Dialpad.qml</file>
|
<file alias="Dialpad/Dialpad.qml">qml/Dialpad/Dialpad.qml</file>
|
||||||
<file alias="Dialpad/PhoneNumberInput.qml">contents/ui/Dialpad/PhoneNumberInput.qml</file>
|
<file alias="Dialpad/PhoneNumberInput.qml">qml/Dialpad/PhoneNumberInput.qml</file>
|
||||||
<file alias="Dialpad/DialerButton.qml">contents/ui/Dialpad/DialerButton.qml</file>
|
<file alias="Dialpad/DialerButton.qml">qml/Dialpad/DialerButton.qml</file>
|
||||||
<file alias="Dialpad/DialerIconButton.qml">contents/ui/Dialpad/DialerIconButton.qml</file>
|
<file alias="Dialpad/DialerIconButton.qml">qml/Dialpad/DialerIconButton.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue