Skip to content

Commit 348e397

Browse files
nephrosnephros
andauthored
Show list of things to be restarted on the "Restart Services" dialog (#136)
* [ui] add display of services to be restarted See Issue #23 #23 * implement getting list of services to be toggled * fixup! [ui] add display of services to be restarted * fixup! [ui] add display of services to be restarted * fixup! Merge branch 'master' into issue-23 * cleanup: remove dead code * translate category strings * move dbus call to getter * update translation source * fixup! translate category strings * Add warning icon and message to apply/unapply notification * update translations * add missing noop source string for "keyboard" * Fix wording according to https://github.com/sailfishos-patches/patchmanager/wiki/Terms-and-wording https://github.com/sailfishos-patches/patchmanager/pull/136/files#r745053026 Co-authored-by: nephros <nemo@pgxperia10>
1 parent 9de0569 commit 348e397

File tree

7 files changed

+130
-31
lines changed

7 files changed

+130
-31
lines changed

src/bin/patchmanager-daemon/dbus/org.SfietKonstantin.patchmanager.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
<arg name="patch" type="s" direction="in" />
9292
<arg name="activate" type="b" direction="in" />
9393
</method>
94+
<method name="getToggleServicesList">
95+
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QStringList"/>
96+
<arg name="services" type="a{s}" direction="out" />
97+
</method>
9498
<method name="getToggleServices">
9599
<arg name="toggle" type="b" direction="out" />
96100
</method>

src/bin/patchmanager-daemon/patchmanagerobject.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,20 @@ void PatchManagerObject::notify(const QString &patch, NotifyAction action)
231231
case NotifyActionSuccessApply:
232232
summary = qApp->translate("", "Patch installed");
233233
body = qApp->translate("", "Patch %1 installed").arg(patch);
234+
if (getToggleServices()) {
235+
body.append( ", " );
236+
body.append( qApp->translate("", "Services need restart!") );
237+
notification.setHintValue("icon", "icon-lock-warning");
238+
};
234239
break;
235240
case NotifyActionSuccessUnapply:
236241
summary = qApp->translate("", "Patch removed");
237242
body = qApp->translate("", "Patch %1 removed").arg(patch);
243+
if (getToggleServices()) {
244+
body.append( ", " );
245+
body.append( qApp->translate("", "Services need restart!") );
246+
notification.setHintValue("icon", "icon-lock-warning");
247+
};
238248
break;
239249
case NotifyActionFailedApply:
240250
summary = qApp->translate("", "Failed to install patch");
@@ -1274,6 +1284,11 @@ void PatchManagerObject::patchToggleService(const QString &patch)
12741284
}
12751285
}
12761286

1287+
QStringList PatchManagerObject::getToggleServicesList() const
1288+
{
1289+
return m_toggleServices.keys();
1290+
}
1291+
12771292
bool PatchManagerObject::getToggleServices() const
12781293
{
12791294
return !m_toggleServices.isEmpty();

src/bin/patchmanager-daemon/patchmanagerobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public slots:
124124
void patchToggleService(const QString &patch);
125125

126126
bool getToggleServices() const;
127+
QStringList getToggleServicesList() const;
127128
bool getFailure() const;
128129
bool getLoaded() const;
129130
void resolveFailure();

src/qml/RestartServicesDialog.qml

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/*
22
* Copyright (C) 2013 Lucien XU <[email protected]>
33
* Copyright (C) 2016 Andrey Kozhevnikov <[email protected]>
4+
* Copyright (c) 2021, Patchmanger for SailfishOS contributors:
5+
* - olf "Olf0" <https://github.com/Olf0>
6+
* - Peter G. "nephros" <[email protected]>
7+
* - Vlad G. "b100dian" <https://github.com/b100dian>
48
*
59
* You may use this file under the terms of the BSD license as follows:
610
*
@@ -39,21 +43,46 @@ Dialog {
3943
id: container
4044
onAccepted: PatchManager.restartServices()
4145

42-
SilicaFlickable {
43-
anchors.fill: parent
44-
Column {
45-
spacing: Theme.paddingMedium
46-
anchors.left: parent.left; anchors.right: parent.right
47-
DialogHeader {
48-
acceptText: qsTranslate("", "Restart services")
49-
}
46+
Component.onCompleted: console.info("Will restart " + PatchManager.appsToRestart);
5047

51-
Label {
52-
anchors.left: parent.left; anchors.leftMargin: Theme.paddingMedium
53-
anchors.right: parent.right; anchors.rightMargin: Theme.paddingMedium
54-
wrapMode: Text.WordWrap
55-
color: Theme.highlightColor
56-
text: qsTranslate("", "Some services will be restarted now. Reloading the homescreen of the device might take a little time.")
48+
Column {
49+
spacing: Theme.paddingSmall
50+
width: parent.width
51+
DialogHeader {
52+
acceptText: qsTranslate("", "Restart")
53+
}
54+
Label {
55+
anchors.horizontalCenter: parent.horizontalCenter
56+
width: parent.width - Theme.horizontalPageMargin * 2
57+
color: Theme.highlightColor
58+
text: qsTranslate("", "Some services will be restarted now. Reloading the homescreen of the device might take a little time.")
59+
wrapMode: Text.WordWrap
60+
horizontalAlignment: Text.AlignJustify
61+
}
62+
SectionHeader { text: qsTranslate("", "List of services:" ); color: Theme.secondaryHighlightColor }
63+
Column {
64+
id: col
65+
anchors.horizontalCenter: parent.horizontalCenter
66+
width: parent.width - Theme.horizontalPageMargin * 2
67+
Repeater {
68+
model: PatchManager.appsToRestart
69+
delegate: Component { TextSwitch {
70+
text: qsTranslate("Sections", modelData)
71+
automaticCheck: false
72+
checked: true
73+
enabled: true
74+
description: {
75+
if ((modelData == "homescreen")
76+
|| (modelData == "silica"))
77+
{ return qsTranslate("","Note: this will close all apps."); }
78+
else if (modelData == "settings") { return qsTranslate("","Note: this will close %1.").arg(qsTranslate("", "Patchmanager")); }
79+
else if (modelData == "keyboard") { return "" }
80+
else if (modelData == "other") { return "" }
81+
else { return qsTranslate("","Note: this will close the %1 app.").arg(text); }
82+
}
83+
TouchBlocker { anchors.fill: parent}
84+
}
85+
}
5786
}
5887
}
5988
}

src/qml/patchmanager.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static const char *noop_strings[] = {
6161
QT_TRANSLATE_NOOP("Sections", "silica"),
6262
QT_TRANSLATE_NOOP("Sections", "settings"),
6363
QT_TRANSLATE_NOOP("Sections", "other"),
64+
QT_TRANSLATE_NOOP("Sections", "keyboard"),
6465
};
6566

6667
PatchManager::PatchManager(QObject *parent)
@@ -233,6 +234,20 @@ QString PatchManager::patchmanagerVersion() const
233234
return m_patchmanagerVersion;
234235
}
235236

237+
QStringList PatchManager::toggleServicesList() const
238+
{
239+
QStringList list;
240+
241+
QDBusPendingReply<QStringList> reply = m_interface->getToggleServicesList();
242+
reply.waitForFinished();
243+
if (reply.isFinished()) {
244+
qDebug() << Q_FUNC_INFO << "dbus replied:" << reply.value();
245+
list = reply.value();;
246+
return list;
247+
}
248+
return list;
249+
}
250+
236251
bool PatchManager::toggleServices() const
237252
{
238253
return m_toggleServices;

src/qml/patchmanager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class PatchManager: public QObject
6969
Q_PROPERTY(PatchManagerModel *installedModel READ installedModel CONSTANT)
7070
Q_PROPERTY(QVariantMap updates READ getUpdates NOTIFY updatesChanged)
7171
Q_PROPERTY(QStringList updatesNames READ getUpdatesNames NOTIFY updatesChanged)
72+
Q_PROPERTY(QStringList appsToRestart READ toggleServicesList NOTIFY toggleServicesListChanged)
7273
Q_PROPERTY(bool appsNeedRestart READ toggleServices NOTIFY toggleServicesChanged)
7374
Q_PROPERTY(bool failure READ failure NOTIFY failureChanged)
7475
Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
@@ -88,6 +89,7 @@ class PatchManager: public QObject
8889
QVariantMap getUpdates() const;
8990
QStringList getUpdatesNames() const;
9091
QString patchmanagerVersion() const;
92+
QStringList toggleServicesList() const;
9193

9294
bool toggleServices() const;
9395
bool failure() const;
@@ -161,6 +163,7 @@ public slots:
161163
void failureChanged(bool failed);
162164
void loadedChanged(bool loaded);
163165
void patchmanagerVersionChanged(const QString &patchmanagerVersion);
166+
void toggleServicesListChanged(const QStringList &servicesToBeToggled);
164167

165168
private:
166169
void successCall(QJSValue callback, const QVariant &value);

translations/settings-patchmanager.ts

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="222"/>
4444
<location filename="../src/bin/dialog/dialog.qml" line="165"/>
4545
<location filename="../src/qml/AboutPage.qml" line="63"/>
46+
<location filename="../src/qml/RestartServicesDialog.qml" line="78"/>
4647
<source>Patchmanager</source>
4748
<translation type="unfinished"></translation>
4849
</message>
@@ -128,8 +129,8 @@
128129
<translation type="unfinished"></translation>
129130
</message>
130131
<message>
131-
<location filename="../src/qml/WebPatchPage.qml" line="85"/>
132132
<location filename="../src/qml/PatchManagerPage.qml" line="490"/>
133+
<location filename="../src/qml/WebPatchPage.qml" line="85"/>
133134
<source>Patch details</source>
134135
<translation type="unfinished"></translation>
135136
</message>
@@ -143,11 +144,6 @@
143144
<source>Maintainer</source>
144145
<translation type="unfinished"></translation>
145146
</message>
146-
<message>
147-
<location filename="../src/qml/UnifiedPatchPage.qml" line="165"/>
148-
<source>This patch uses the legacy format for its patch.json file. If you are its maintainer, please do consider updating to the new format; if you are using the Web Catalog you shall not include a patch.json file in your upload!&lt;br /&gt;See the developer section in the &lt;a href=&quot;%1&quot;&gt;README&lt;/a&gt; for details.</source>
149-
<translation type="unfinished"></translation>
150-
</message>
151147
<message>
152148
<location filename="../src/qml/UnifiedPatchPage.qml" line="171"/>
153149
<source>Description</source>
@@ -214,6 +210,11 @@
214210
<source>May conflict with:</source>
215211
<translation type="unfinished"></translation>
216212
</message>
213+
<message>
214+
<location filename="../src/qml/UnifiedPatchPage.qml" line="165"/>
215+
<source>This patch uses the legacy format for its patch.json file. If you are its maintainer, please do consider updating to the new format; if you are using the Web Catalog you shall not include a patch.json file in your upload!&amp;lt;br /&amp;gt;See the developer section in the &amp;lt;a href=&amp;quot;%1&amp;quot;&amp;gt;README&amp;lt;/a&amp;gt; for details.</source>
216+
<translation type="unfinished"></translation>
217+
</message>
217218
<message>
218219
<location filename="../src/qml/PatchManagerPage.qml" line="147"/>
219220
<source>Unapply all patches</source>
@@ -298,15 +299,35 @@
298299
<translation type="unfinished"></translation>
299300
</message>
300301
<message>
301-
<location filename="../src/qml/RestartServicesDialog.qml" line="48"/>
302-
<source>Restart services</source>
302+
<location filename="../src/qml/RestartServicesDialog.qml" line="52"/>
303+
<source>Restart</source>
303304
<translation type="unfinished"></translation>
304305
</message>
305306
<message>
306-
<location filename="../src/qml/RestartServicesDialog.qml" line="56"/>
307+
<location filename="../src/qml/RestartServicesDialog.qml" line="58"/>
307308
<source>Some services will be restarted now. Reloading the homescreen of the device might take a little time.</source>
308309
<translation type="unfinished"></translation>
309310
</message>
311+
<message>
312+
<location filename="../src/qml/RestartServicesDialog.qml" line="62"/>
313+
<source>List of services:</source>
314+
<translation type="unfinished"></translation>
315+
</message>
316+
<message>
317+
<location filename="../src/qml/RestartServicesDialog.qml" line="77"/>
318+
<source>Note: this will close all apps.</source>
319+
<translation type="unfinished"></translation>
320+
</message>
321+
<message>
322+
<location filename="../src/qml/RestartServicesDialog.qml" line="78"/>
323+
<source>Note: this will close %1.</source>
324+
<translation type="unfinished"></translation>
325+
</message>
326+
<message>
327+
<location filename="../src/qml/RestartServicesDialog.qml" line="81"/>
328+
<source>Note: this will close the %1 app.</source>
329+
<translation type="unfinished"></translation>
330+
</message>
310331
<message>
311332
<location filename="../src/qml/ScreenshotsPage.qml" line="71"/>
312333
<location filename="../src/qml/WebPatchPage.qml" line="272"/>
@@ -427,41 +448,47 @@
427448
</message>
428449
<message>
429450
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="236"/>
451+
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="245"/>
452+
<source>Services need restart!</source>
453+
<translation type="unfinished"></translation>
454+
</message>
455+
<message>
456+
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="241"/>
430457
<source>Patch removed</source>
431458
<translation type="unfinished"></translation>
432459
</message>
433460
<message>
434-
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="237"/>
461+
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="242"/>
435462
<source>Patch %1 removed</source>
436463
<translation type="unfinished"></translation>
437464
</message>
438465
<message>
439-
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="240"/>
466+
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="250"/>
440467
<source>Failed to install patch</source>
441468
<translation type="unfinished"></translation>
442469
</message>
443470
<message>
444-
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="241"/>
471+
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="251"/>
445472
<source>Patch %1 installation failed</source>
446473
<translation type="unfinished"></translation>
447474
</message>
448475
<message>
449-
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="244"/>
476+
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="254"/>
450477
<source>Failed to remove patch</source>
451478
<translation type="unfinished"></translation>
452479
</message>
453480
<message>
454-
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="245"/>
481+
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="255"/>
455482
<source>Patch %1 removal failed</source>
456483
<translation type="unfinished"></translation>
457484
</message>
458485
<message>
459-
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="248"/>
486+
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="258"/>
460487
<source>Update available</source>
461488
<translation type="unfinished"></translation>
462489
</message>
463490
<message>
464-
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="249"/>
491+
<location filename="../src/bin/patchmanager-daemon/patchmanagerobject.cpp" line="259"/>
465492
<source>Patch %1 have update candidate</source>
466493
<translation type="unfinished"></translation>
467494
</message>
@@ -561,9 +588,14 @@
561588
</message>
562589
<message>
563590
<location filename="../src/qml/patchmanager.cpp" line="63"/>
564-
<location filename="../src/qml/patchmanager.cpp" line="216"/>
591+
<location filename="../src/qml/patchmanager.cpp" line="217"/>
565592
<source>other</source>
566593
<translation>Other</translation>
567594
</message>
595+
<message>
596+
<location filename="../src/qml/patchmanager.cpp" line="64"/>
597+
<source>keyboard</source>
598+
<translation>Keyboard</translation>
599+
</message>
568600
</context>
569601
</TS>

0 commit comments

Comments
 (0)