Commit 1b634007 authored by Nate Graham's avatar Nate Graham 💤
Browse files

[applet] Port to Kirigami.PlaceholderMessage

Summary:
Port the applet to the newly-introduced Kirigami.PlaceholderMessage, which replaces a
homegrown implementation as well as the complicated and redundant state machine (half of
whose logic was already set declaratively on the main page).

Test Plan: {F8254228}

Reviewers: #vdg, #plasma, dantti, niccolove

Reviewed By: dantti

Subscribers: kde-utils-devel

Maniphest Tasks: T13021

Differential Revision: https://phabricator.kde.org/D29112
parent 61784564
......@@ -40,6 +40,12 @@ find_package(CUPS "1.5" REQUIRED)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED Config ConfigWidgets CoreAddons DBusAddons IconThemes I18n KCMUtils KIO
Notifications Plasma WidgetsAddons WindowSystem)
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} CONFIG)
set_package_properties(KF5Kirigami2 PROPERTIES
DESCRIPTION "A QtQuick based components set"
TYPE RUNTIME
)
find_package(CupsSmb)
set_package_properties(CupsSmb PROPERTIES
TYPE RUNTIME
......
......@@ -24,13 +24,14 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.printmanager 0.2 as PrintManager
import org.kde.kirigami 2.12 as Kirigami
FocusScope {
id: dialog
property bool scrollBarVisible: printersView.contentHeight > scrollArea.height
property bool searchBarVisible: scrollBarVisible || searchBar.text.length !== 0
state: printersFilterModel.count > 0 ? "JOBS_PRINTER" : "NO_PRINTER"
TextField {
id: searchBar
......@@ -72,7 +73,6 @@ FocusScope {
id: printersView
anchors.fill: parent
opacity: 0
focus: true
currentIndex: -1
clip: true
......@@ -81,29 +81,17 @@ FocusScope {
highlightMoveDuration: units.longDuration
highlightResizeDuration: units.longDuration
delegate: PrinterItem { }
}
}
StatusView {
id: statusNoPrinter
anchors.fill: parent
opacity: 0
iconName: serverUnavailable ? "dialog-error" : "dialog-information"
title: serverUnavailable ?
printersModelError :
i18n("No printers have been configured or discovered")
}
Kirigami.PlaceholderMessage {
anchors.fill: parent
anchors.margins: units.largeSpacing
states: [
State {
name: "NO_PRINTER"
PropertyChanges { target: statusNoPrinter; opacity: 1 }
PropertyChanges { target: printmanager; tooltipText: statusNoPrinter.title }
},
State {
name: "JOBS_PRINTER"
PropertyChanges { target: printersView; opacity: 1 }
PropertyChanges { target: printmanager; tooltipText: jobsTooltipText }
visible: printersFilterModel.count === 0 || serverUnavailable
text: serverUnavailable ?
printersModelError :
i18n("No printers have been configured or discovered")
icon.name: serverUnavailable ? "dialog-error" : undefined
}
}
]
}
}
/*
* Copyright 2012-2013 Daniel Nicoletti <dantti12@gmail.com>
* Copyright 2014 Jan Grulich <jgrulich@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.2
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons
Item {
id: statusView
property alias title: titleText.text
property string iconName: ""
property int iconSize: 128
property alias preferedHeight: column.height
Column {
id: column
width: parent.width
anchors.centerIn: parent
spacing: 4
Item {
id: image
width: iconSize
height: iconSize
anchors.horizontalCenter: parent.horizontalCenter
KQuickControlsAddons.QIconItem {
id: statusIcon
anchors.fill: parent
icon: iconName
}
}
PlasmaComponents.Label {
id: titleText
width: parent.width
height: paintedHeight
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment