KNewStuff

Button.qml
1 /*
2  SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6 
15 import QtQuick 2.11
16 import QtQuick.Controls 2.11 as QtControls
17 
18 import org.kde.newstuff 1.62 as NewStuff
19 
20 QtControls.Button {
21  id: component
22 
23  /*
24  * The configuration file is not aliased, because then we end up initialising the
25  * KNSCore::Engine immediately the Button is shown, which we want to avoid (as that
26  * is effectively a phone-home scenario, and causes internet traffic in situations
27  * where it would not seem likely that there should be any).
28  * If we want, in the future, to add some status display to Button (such as "there
29  * are updates to be had" or somesuch, then we can do this, but until that choice is
30  * made, let's not)
31  */
35  property string configFile: ghnsDialog.configFile
36 
43  property string downloadNewWhat: i18ndc("knewstuff5", "Used to construct the button's label (which will become Download New 'this value'...)", "Stuff")
44  text: i18nd("knewstuff5", "Download New %1...", downloadNewWhat)
45 
46 
51  property alias viewMode: ghnsDialog.viewMode
52 
57  signal aboutToShowDialog();
58 
62  property alias engine: ghnsDialog.engine
63 
70  property var changedEntries
71  Binding {
72  target: component
73  property: "changedEntries"
74  value: ghnsDialog.engine.changedEntries
75  }
76 
83  property bool visibleWhenDisabled: false
84 
88  function showDialog() {
89  if (ghnsDialog.engine.allowedByKiosk) {
90  ghnsDialog.engine.configFile = component.configFile
91  component.aboutToShowDialog();
92  ghnsDialog.engine.engine.revalidateCacheEntries();
93  ghnsDialog.open();
94  } else {
95  // make some noise, because silently doing nothing is a bit annoying
96  }
97  }
98 
99  onClicked: { showDialog(); }
100 
101  icon.name: "get-hot-new-stuff"
102  visible: enabled || visibleWhenDisabled
103  enabled: ghnsDialog.engine.allowedByKiosk
104  onEnabledChanged: {
105  // If the user resets this when kiosk has disallowed ghns, force enabled back to false
106  if (enabled === true && ghnsDialog.engine.allowedByKiosk === false) {
107  enabled = false;
108  }
109  }
110 
111  NewStuff.Dialog {
112  id: ghnsDialog
113  }
114 }
A button which when clicked will open a dialog with a NewStuff.Page at the base.
Definition: Button.qml:18
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Jan 18 2021 22:43:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.