Changeset View
Changeset View
Standalone View
Standalone View
greeter/greeterapp.cpp
Show All 13 Lines | |||||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. | ||
17 | 17 | | |||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | *********************************************************************/ | 20 | *********************************************************************/ | ||
21 | #include "greeterapp.h" | 21 | #include "greeterapp.h" | ||
22 | #include "greeteradapter.h" | ||||
22 | #include "kscreensaversettingsbase.h" | 23 | #include "kscreensaversettingsbase.h" | ||
23 | #include "authenticator.h" | 24 | #include "authenticator.h" | ||
24 | #include "noaccessnetworkaccessmanagerfactory.h" | 25 | #include "noaccessnetworkaccessmanagerfactory.h" | ||
25 | #include "wallpaper_integration.h" | 26 | #include "wallpaper_integration.h" | ||
26 | #include "lnf_integration.h" | 27 | #include "lnf_integration.h" | ||
27 | 28 | | |||
28 | #include <config-kscreenlocker.h> | 29 | #include <config-kscreenlocker.h> | ||
29 | 30 | | |||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 127 | { | |||
128 | connect(m_authenticator, &Authenticator::succeeded, this, &QCoreApplication::quit); | 129 | connect(m_authenticator, &Authenticator::succeeded, this, &QCoreApplication::quit); | ||
129 | initialize(); | 130 | initialize(); | ||
130 | connect(this, &UnlockApp::screenAdded, this, &UnlockApp::desktopResized); | 131 | connect(this, &UnlockApp::screenAdded, this, &UnlockApp::desktopResized); | ||
131 | connect(this, &UnlockApp::screenRemoved, this, &UnlockApp::desktopResized); | 132 | connect(this, &UnlockApp::screenRemoved, this, &UnlockApp::desktopResized); | ||
132 | 133 | | |||
133 | if (QX11Info::isPlatformX11()) { | 134 | if (QX11Info::isPlatformX11()) { | ||
134 | installNativeEventFilter(new FocusOutEventFilter); | 135 | installNativeEventFilter(new FocusOutEventFilter); | ||
135 | } | 136 | } | ||
137 | | ||||
138 | (void) new GreeterAdapter(this); | ||||
139 | QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.screensaver.Greeter")); | ||||
davidedmundson: Register objects before registering a service.
DBus receiving is in another thread so you… | |||||
140 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/Greeter"), this); | ||||
136 | } | 141 | } | ||
137 | 142 | | |||
138 | UnlockApp::~UnlockApp() | 143 | UnlockApp::~UnlockApp() | ||
139 | { | 144 | { | ||
140 | //workaround QTBUG-55460 | 145 | //workaround QTBUG-55460 | ||
141 | //will be fixed when themes port to QQC2 | 146 | //will be fixed when themes port to QQC2 | ||
142 | for (auto view: qAsConst(m_views)) { | 147 | for (auto view: qAsConst(m_views)) { | ||
143 | if (QQuickItem *focusItem = view->activeFocusItem()) { | 148 | if (QQuickItem *focusItem = view->activeFocusItem()) { | ||
▲ Show 20 Lines • Show All 330 Lines • ▼ Show 20 Line(s) | 477 | { | |||
474 | m_delayedLockTimer = nullptr; | 479 | m_delayedLockTimer = nullptr; | ||
475 | 480 | | |||
476 | for (KQuickAddons::QuickViewSharedEngine *view : qAsConst(m_views)) { | 481 | for (KQuickAddons::QuickViewSharedEngine *view : qAsConst(m_views)) { | ||
477 | QQmlProperty lockProperty(view->rootObject(), QStringLiteral("locked")); | 482 | QQmlProperty lockProperty(view->rootObject(), QStringLiteral("locked")); | ||
478 | lockProperty.write(true); | 483 | lockProperty.write(true); | ||
479 | } | 484 | } | ||
480 | } | 485 | } | ||
481 | 486 | | |||
487 | void UnlockApp::Notify(uint id, const QString &app_name, uint replaces_id, const QString &app_icon, | ||||
488 | const QString &summary, const QString &body, const QStringList &actions, | ||||
489 | const QVariantMap &hints, int timeout) | ||||
490 | { | ||||
491 | for (auto v : qAsConst(m_views)) { | ||||
492 | auto rootObject = v->rootObject(); | ||||
493 | if (!rootObject) { | ||||
494 | continue; | ||||
495 | } | ||||
496 | // we invoke the notify method of the greeter root object | ||||
497 | QMetaObject::invokeMethod(rootObject, "Notify", Qt::QueuedConnection, | ||||
This pattern of fetching and poking the root object of a scene isn't one I like, it's better to expose an object to the view that then has normal signals and slots - but this does follow the convention already here, so I can't really object. davidedmundson: This pattern of fetching and poking the root object of a scene isn't one I like, it's better to… | |||||
Let's add a todo for future? Once this is done, I do have plan to change the OSD bit to also use greeter directly, instead of wayland protocol bit. That time I can update that. bshah: Let's add a todo for future? Once this is done, I do have plan to change the OSD bit to also… | |||||
498 | Q_ARG(uint, id), | ||||
499 | Q_ARG(QString, app_name), | ||||
500 | Q_ARG(uint, replaces_id), | ||||
501 | Q_ARG(QString, app_icon), | ||||
502 | Q_ARG(QString, summary), | ||||
503 | Q_ARG(QString, body), | ||||
504 | Q_ARG(QStringList, actions), | ||||
505 | Q_ARG(QVariantMap, hints), | ||||
506 | Q_ARG(int, timeout)); | ||||
507 | } | ||||
508 | } | ||||
509 | | ||||
510 | void UnlockApp::CloseNotification(uint id) | ||||
511 | { | ||||
512 | for (auto v : qAsConst(m_views)) { | ||||
513 | auto rootObject = v->rootObject(); | ||||
514 | if (!rootObject) { | ||||
515 | continue; | ||||
516 | } | ||||
517 | QMetaObject::invokeMethod(rootObject, "CloseNotification", | ||||
518 | Qt::QueuedConnection, Q_ARG(uint, id)); | ||||
519 | } | ||||
520 | } | ||||
521 | | ||||
482 | void UnlockApp::resetRequestIgnore() | 522 | void UnlockApp::resetRequestIgnore() | ||
483 | { | 523 | { | ||
484 | m_ignoreRequests = false; | 524 | m_ignoreRequests = false; | ||
485 | } | 525 | } | ||
486 | 526 | | |||
487 | void UnlockApp::suspendToRam() | 527 | void UnlockApp::suspendToRam() | ||
488 | { | 528 | { | ||
489 | if (m_ignoreRequests) { | 529 | if (m_ignoreRequests) { | ||
▲ Show 20 Lines • Show All 283 Lines • Show Last 20 Lines |
Register objects before registering a service.
DBus receiving is in another thread so you could hypothetically get a message between the two events.
Doesn't really matter if we lose a notification in this case, but it's a good practice