KNewStuff

Button.qml
1 /*
2  * Copyright (C) 2019 Dan Leinir Turthra Jensen <[email protected]>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) version 3, or any
8  * later version accepted by the membership of KDE e.V. (or its
9  * successor approved by the membership of KDE e.V.), which shall
10  * act as a proxy defined in Section 6 of version 3 of the license.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
30 import QtQuick 2.11
31 import QtQuick.Controls 2.11 as QtControls
32 
33 import org.kde.newstuff 1.62 as NewStuff
34 
35 QtControls.Button {
36  id: component
37 
38  /*
39  * The configuration file is not aliased, because then we end up initialising the
40  * KNSCore::Engine immediately the Button is shown, which we want to avoid (as that
41  * is effectively a phone-home scenario, and causes internet traffic in situations
42  * where it would not seem likely that there should be any).
43  * If we want, in the future, to add some status display to Button (such as "there
44  * are updates to be had" or somesuch, then we can do this, but until that choice is
45  * made, let's not)
46  */
50  property string configFile: ghnsDialog.configFile
51 
58  property string downloadNewWhat: i18ndc("knewstuff5", "Used to construct the button's label (which will become Download New 'this value'...)", "Stuff")
59  text: i18nd("knewstuff5", "Download New %1...", downloadNewWhat)
60 
61 
66  property alias viewMode: ghnsDialog.viewMode
67 
72  signal aboutToShowDialog();
73 
77  property alias engine: ghnsDialog.engine
78 
85  property var changedEntries
86  Binding {
87  target: component
88  property: "changedEntries"
89  value: ghnsDialog.engine.changedEntries
90  }
91 
98  property bool visibleWhenDisabled: false
99 
103  function showDialog() {
104  if (ghnsDialog.engine.allowedByKiosk) {
105  ghnsDialog.engine.configFile = component.configFile
106  component.aboutToShowDialog();
107  ghnsDialog.open();
108  } else {
109  // make some noise, because silently doing nothing is a bit annoying
110  }
111  }
112 
113  onClicked: { showDialog(); }
114 
115  icon.name: "get-hot-new-stuff"
116  visible: enabled || visibleWhenDisabled
117  enabled: ghnsDialog.engine.allowedByKiosk
118  onEnabledChanged: {
119  // If the user resets this when kiosk has disallowed ghns, force enabled back to false
120  if (enabled === true && ghnsDialog.engine.allowedByKiosk === false) {
121  enabled = false;
122  }
123  }
124 
125  NewStuff.Dialog {
126  id: ghnsDialog
127  }
128 }
A button which when clicked will open a dialog with a NewStuff.Page at the base.
Definition: Button.qml:33
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-2020 The KDE developers.
Generated on Sun Aug 9 2020 22:43:40 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.