diff --git a/CMakeLists.txt b/CMakeLists.txt index 99e1bc5..d42cc75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,86 +1,86 @@ cmake_minimum_required(VERSION 3.1) # KDE Application Version, managed by release script set (RELEASE_SERVICE_VERSION_MAJOR "20") set (RELEASE_SERVICE_VERSION_MINOR "07") set (RELEASE_SERVICE_VERSION_MICRO "70") set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}") project(print-manager VERSION ${RELEASE_SERVICE_VERSION}) set(QT_MIN_VERSION "5.9.0") -set(KF5_MIN_VERSION "5.62.0") +set(KF5_MIN_VERSION "5.70.0") ################# set KDE specific information ################# find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMPackageConfigHelpers) include(ECMOptionalAddSubdirectory) include(FeatureSummary) find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core DBus Network Widgets Qml Quick ) 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(CupsSmb) set_package_properties(CupsSmb PROPERTIES TYPE RUNTIME DESCRIPTION "SMB backend for CUPS (aka smbspool)" PURPOSE "Required for CUPS to be able to print to printers shared over SMB" URL "https://samba.org" ) add_definitions( -DQT_DISABLE_DEPRECATED_BEFORE=0x050900 -DQT_USE_FAST_OPERATOR_PLUS -DQT_NO_URL_CAST_FROM_STRING -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_CAST_FROM_ASCII ) remove_definitions(-DQT_NO_KEYWORDS) # Generate config.h configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h) include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libkcups ${CUPS_INCLUDE_DIR} ) install(FILES org.kde.print-manager.metainfo.xml DESTINATION "${KDE_INSTALL_METAINFODIR}") add_definitions(-DTRANSLATION_DOMAIN="print-manager") add_subdirectory(libkcups) add_subdirectory(configure-printer) add_subdirectory(add-printer) add_subdirectory(printer-manager-kcm) add_subdirectory(printqueue) add_subdirectory(print-manager-kded) add_subdirectory(plasmoid) add_subdirectory(declarative-plugins) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/plasmoid/package/contents/ui/PopupDialog.qml b/plasmoid/package/contents/ui/PopupDialog.qml index 746c877..a676d95 100644 --- a/plasmoid/package/contents/ui/PopupDialog.qml +++ b/plasmoid/package/contents/ui/PopupDialog.qml @@ -1,109 +1,109 @@ /* * Copyright 2012-2013 Daniel Nicoletti * Copyright 2014-2015 Jan Grulich * * 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 QtQuick.Controls 1.3 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 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 anchors { left: parent.left right: parent.right top: parent.top rightMargin: Math.round(units.gridUnit / 2) } visible: searchBarVisible placeholderText: i18n("Search for a printer...") onTextChanged: { printersFilterModel.setFilterWildcard(text) } } PrintManager.ProcessRunner { id: processRunner } PrintManager.PrinterSortFilterModel { id: printersFilterModel sourceModel: printersModel } PlasmaExtras.ScrollArea { id: scrollArea anchors { bottom: parent.bottom left: parent.left right: parent.right top: searchBarVisible ? searchBar.bottom : parent.top } ListView { id: printersView - property int currentExpanded: -1 - anchors.fill: parent opacity: 0 focus: true currentIndex: -1 clip: true model: printersFilterModel highlight: PlasmaComponents.Highlight{ } + 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") } 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 } } ] } diff --git a/plasmoid/package/contents/ui/PrinterItem.qml b/plasmoid/package/contents/ui/PrinterItem.qml index 3ceb6e1..f1925f8 100644 --- a/plasmoid/package/contents/ui/PrinterItem.qml +++ b/plasmoid/package/contents/ui/PrinterItem.qml @@ -1,292 +1,73 @@ /* * Copyright 2012-2013 Daniel Nicoletti * Copyright 2014-2015 Jan Grulich + * Copyright 2020 Nate Graham * * 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.kquickcontrolsaddons 2.0 -import org.kde.plasma.core 2.0 as PlasmaCore +import QtQuick.Controls 2.9 + import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons import org.kde.plasma.printmanager 0.2 as PrintManager -Item { - id: printerItem - - readonly property bool isPaused: printerState === 5 - readonly property bool expanded: ListView.view.currentExpanded == index - - height: container.childrenRect.height + Math.round(units.gridUnit / 2) - width: parent.width - Math.round(units.gridUnit / 2) - - MouseArea { - id: container - anchors.fill: parent - - hoverEnabled: true - onEntered: { - printerItem.ListView.view.currentIndex = index; - - //this is done to hide the highlight if the mouse moves out of the list view - //and we are not mouseoverring anything - if (printerItem.ListView.view.highlightItem) { - printerItem.ListView.view.highlightItem.opacity = 1 - } - } - onExited: { - if (printerItem.ListView.view.highlightItem) { - printerItem.ListView.view.highlightItem.opacity = 0 - } - } - onClicked: { - // the order is important, don't change since the last - // line resets the value of expanded and makes the code hard to read - // if it's not the last one - jobsFilterModel.filteredPrinters = expanded ? "" : printerName - printerItem.ListView.view.currentExpanded = expanded ? -1 : index; - } - - KQuickControlsAddons.QIconItem { - id: printerIcon - - anchors { - left: parent.left - leftMargin: units.smallSpacing - verticalCenter: labelsColumn.verticalCenter - } - - height: units.iconSizes.medium - width: height - icon: iconName - Behavior on opacity { PropertyAnimation {} } - } - - Column { - id: labelsColumn - - anchors { - top: parent.top - left: printerIcon.right - right: stateChangeButton.left - topMargin: units.smallSpacing - leftMargin: units.smallSpacing - rightMargin: units.smallSpacing - } - - PlasmaComponents.Label { - id: printerNameLabel - - anchors { - left: parent.left - right: parent.right - } - - height: paintedHeight - elide: Text.ElideRight - font.weight: isDefault ? Font.DemiBold : Font.Normal - text: printerName - } - - PlasmaComponents.Label { - id: printerStatusLabel - - anchors { - left: parent.left - right: parent.right - } - - height: paintedHeight - elide: Text.ElideRight - font.pointSize: theme.smallestFont.pointSize - opacity: 0.6 - text: stateMessage - } - } - - PlasmaComponents.ToolButton { - id: stateChangeButton - - anchors { - right: parent.right - rightMargin: Math.round(units.gridUnit / 2) - verticalCenter: printerIcon.verticalCenter - } - - iconSource: isPaused ? "media-playback-start" : "media-playback-pause" - tooltip: isPaused ? i18n("Resume printing") : i18n("Pause printing") - opacity: container.containsMouse ? 1 : 0 - visible: opacity != 0 +PlasmaExtras.ExpandableListItem { + readonly property bool isPaused: model.printerState === 5 - onClicked: toggleSelection() - } - - ListView { - id: actionsList - - anchors { - top: labelsColumn.bottom - left: printerIcon.right - right: stateChangeButton.left - leftMargin: Math.round(units.gridUnit / 2) - rightMargin: Math.round(units.gridUnit / 2) - } - interactive: false - model: ListModel { - Component.onCompleted: { - append({"name":i18n("Configure printer"), "icon":"configure", "actionType":1}) - append({"name":i18n("Open print queue"), "icon":"view-list-details", "actionType":2}) - } - } - property int actionIconHeight: units.iconSizes.medium * 0.8 - height: expanded ? ((actionIconHeight + Math.round(units.gridUnit / 2)) * 2) + Math.round(units.gridUnit / 4) : 0 - opacity: expanded ? 1 : 0 - highlight: PlasmaComponents.Highlight{} - delegate: actionItem - - - Behavior on opacity { NumberAnimation { duration: units.shortDuration * 3 } } - - Component.onCompleted: currentIndex = -1 - - Component { - id: actionItem - - Item { - height: Math.max(actionIcon.height, actionText.height + jobsCountText.height) + Math.round(units.gridUnit / 3) - width: actionsList.width - - PlasmaCore.IconItem { - id: actionIcon - - source: icon - height: actionsList.actionIconHeight - width: actionsList.actionIconHeight - - anchors { - left: parent.left - leftMargin: 3 - verticalCenter: actionLabels.verticalCenter - } - } - - Column { - id: actionLabels - - anchors { - left: actionIcon.right - leftMargin: 5 - right: parent.right - rightMargin: 3 - verticalCenter: parent.verticalCenter - } - - PlasmaComponents.Label { - id: actionText - - anchors { - left: parent.left - right: parent.right - } - - height: paintedHeight - verticalAlignment: Text.AlignVCenter - wrapMode: Text.WordWrap - text: name - } - - PlasmaComponents.Label { - id: jobsCountText - - anchors { - left: parent.left - right: parent.right - } - - height: actionType == 2 ? paintedHeight : 0 - elide: Text.ElideRight - font.pointSize: theme.smallestFont.pointSize - opacity: 0.6 - text: getJobsLabel() - } - } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - - onEntered: { - actionsList.currentIndex = index; - actionsList.highlightItem.opacity = 1; - } - onExited: { - actionsList.highlightItem.opacity = 0; - } - onClicked: { - // Configure printer - if (actionType == 1) { - processRunner.configurePrinter(printerName) - // Open print queue - } else { - processRunner.openPrintQueue(printerName) - } - } - } - } - } - } - } - - states: [ - State { - name: "NORMAL" - when: !isPaused - }, - - State { - name: "PAUSED" - when: isPaused - PropertyChanges { target: printerNameLabel; opacity: 0.6 } - PropertyChanges { target: printerIcon; opacity: 0.6 } - } - ] - - function getJobsLabel() { + icon: model.iconName + iconEmblem: isPaused ? "emblem-pause" : "" + title: model.printerName + subtitle: { if (printmanager.jobsFilter == PrintManager.JobModel.WhichActive) { if (jobsFilterModel.count == 0) { - return i18n("No active jobs"); + return i18n("%1, no active jobs", model.stateMessage); } else { - return i18np("One active job", "%1 active jobs", jobsFilterModel.count); + return i18np("%1, %2 active job", "%1, %2 active jobs", model.stateMessage, jobsFilterModel.count); } } else { if (jobsFilterModel.count == 0) { - return i18n("No jobs"); + return i18n("%1, no jobs", model.stateMessage); } else { - return i18np("One job", "%1 jobs", jobsFilterModel.count); + return i18np("%1, %2 job", "%1, %2 jobs", model.stateMessage, jobsFilterModel.count); } } } - - function toggleSelection() { - if (isPaused) { - printersModel.resumePrinter(printerName) - } else { - printersModel.pausePrinter(printerName) + isDefault: model.isDefault + defaultActionButtonAction: Action { + icon.name: isPaused ? "media-playback-start" : "media-playback-pause" + text: isPaused ? i18n("Resume printing") : i18n("Pause printing") + onTriggered: { + if (isPaused) { + printersModel.resumePrinter(model.printerName); + } else { + printersModel.pausePrinter(model.printerName); + } } } + contextualActionsModel: [ + Action { + icon.name: "configure" + text: i18n("Configure printer...") + onTriggered: processRunner.configurePrinter(model.printerName); + }, + Action { + icon.name: "view-list-details" + text: i18n("View print queue") + onTriggered: processRunner.openPrintQueue(printerName); + } + ] }