KNewStuff

ErrorDisplayer.qml
1 /*
2  * Copyright 2020 Dan Leinir Turthra Jensen <[email protected]>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Library General Public License as
6  * published by the Free Software Foundation; either version 2 or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Library General Public License for more details
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 import QtQuick 2.12
21 
22 MessageBoxSheet {
23  id: component
24  title: i18ndc("knewstuff5", "Title for a dialog box which shows error messages", "An Error Occurred");
25  property bool active: true;
26  property QtObject engine;
27  property QtObject connection: Connections {
28  target: engine
29  onErrorMessage: { component.showError(message); }
30  }
31  property var errorsToShow: []
32  function showError(errorMessage) {
33  if (active === true) {
34  errorsToShow.push(errorMessage);
35  if (sheetOpen === false) {
36  text = errorsToShow.shift();
37  open();
38  }
39  }
40  }
41  onSheetOpenChanged: {
42  if (sheetOpen === false && errorsToShow.length > 0) {
43  text = errorsToShow.shift();
44  open();
45  }
46  }
47 }
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
KIOCORE_EXPORT FileJob * open(const QUrl &url, QIODevice::OpenMode mode)
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.