123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- // Copyright (c) 2017 Ultimaker B.V.
- // PluginBrowser is released under the terms of the LGPLv3 or higher.
- import QtQuick 2.2
- import QtQuick.Dialogs 1.1
- import QtQuick.Window 2.2
- import QtQuick.Controls 1.4
- import QtQuick.Controls.Styles 1.4
- // TODO: Switch to QtQuick.Controls 2.x and remove QtQuick.Controls.Styles
- import UM 1.1 as UM
- Window {
- id: base
- title: catalog.i18nc("@title:tab", "Plugins");
- width: 800 * screenScaleFactor
- height: 640 * screenScaleFactor
- minimumWidth: 350 * screenScaleFactor
- minimumHeight: 350 * screenScaleFactor
- color: UM.Theme.getColor("sidebar")
- Item {
- id: view
- anchors {
- fill: parent
- leftMargin: UM.Theme.getSize("default_margin").width
- rightMargin: UM.Theme.getSize("default_margin").width
- topMargin: UM.Theme.getSize("default_margin").height
- bottomMargin: UM.Theme.getSize("default_margin").height
- }
- Rectangle {
- id: topBar
- width: parent.width
- color: "transparent"
- height: childrenRect.height
- Row {
- spacing: 12
- height: childrenRect.height
- width: childrenRect.width
- anchors.horizontalCenter: parent.horizontalCenter
- Button {
- text: "Install"
- style: ButtonStyle {
- background: Rectangle {
- color: "transparent"
- implicitWidth: 96
- implicitHeight: 48
- Rectangle {
- visible: manager.viewing == "available" ? true : false
- color: UM.Theme.getColor("primary")
- anchors.bottom: parent.bottom
- width: parent.width
- height: 3
- }
- }
- label: Text {
- text: control.text
- color: UM.Theme.getColor("text")
- font {
- pixelSize: 15
- }
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- }
- }
- onClicked: manager.setView("available")
- }
- Button {
- text: "Manage"
- style: ButtonStyle {
- background: Rectangle {
- color: "transparent"
- implicitWidth: 96
- implicitHeight: 48
- Rectangle {
- visible: manager.viewing == "installed" ? true : false
- color: UM.Theme.getColor("primary")
- anchors.bottom: parent.bottom
- width: parent.width
- height: 3
- }
- }
- label: Text {
- text: control.text
- color: UM.Theme.getColor("text")
- font {
- pixelSize: 15
- }
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- }
- }
- onClicked: manager.setView("installed")
- }
- }
- }
- // Scroll view breaks in QtQuick.Controls 2.x
- ScrollView {
- id: installedPluginList
- width: parent.width
- height: 400
- anchors {
- top: topBar.bottom
- topMargin: UM.Theme.getSize("default_margin").height
- bottom: bottomBar.top
- bottomMargin: UM.Theme.getSize("default_margin").height
- }
- frameVisible: true
- ListView {
- id: pluginList
- property var activePlugin
- property var filter: "installed"
- anchors.fill: parent
- model: manager.pluginsModel
- delegate: PluginEntry {}
- }
- }
- Rectangle {
- id: bottomBar
- width: parent.width
- height: childrenRect.height
- color: "transparent"
- anchors.bottom: parent.bottom
- Label {
- visible: manager.restartRequired
- text: "You will need to restart Cura before changes in plugins have effect."
- height: 30
- verticalAlignment: Text.AlignVCenter
- }
- Button {
- id: restartChangedButton
- text: "Quit Cura"
- anchors.right: closeButton.left
- anchors.rightMargin: UM.Theme.getSize("default_margin").width
- visible: manager.restartRequired
- iconName: "dialog-restart"
- onClicked: manager.restart()
- style: ButtonStyle {
- background: Rectangle {
- implicitWidth: 96
- implicitHeight: 30
- color: UM.Theme.getColor("primary")
- }
- label: Text {
- verticalAlignment: Text.AlignVCenter
- color: UM.Theme.getColor("button_text")
- font {
- pixelSize: 13
- bold: true
- }
- text: control.text
- horizontalAlignment: Text.AlignHCenter
- }
- }
- }
- Button {
- id: closeButton
- text: catalog.i18nc("@action:button", "Close")
- iconName: "dialog-close"
- onClicked: {
- if ( manager.isDownloading ) {
- manager.cancelDownload()
- }
- base.close();
- }
- anchors.right: parent.right
- style: ButtonStyle {
- background: Rectangle {
- color: "transparent"
- implicitWidth: 96
- implicitHeight: 30
- border {
- width: 1
- color: UM.Theme.getColor("lining")
- }
- }
- label: Text {
- verticalAlignment: Text.AlignVCenter
- color: UM.Theme.getColor("text")
- text: control.text
- horizontalAlignment: Text.AlignHCenter
- }
- }
- }
- }
- UM.I18nCatalog { id: catalog; name: "cura" }
- Connections {
- target: manager
- onShowLicenseDialog: {
- licenseDialog.pluginName = manager.getLicenseDialogPluginName();
- licenseDialog.licenseContent = manager.getLicenseDialogLicenseContent();
- licenseDialog.pluginFileLocation = manager.getLicenseDialogPluginFileLocation();
- licenseDialog.show();
- }
- }
- UM.Dialog {
- id: licenseDialog
- title: catalog.i18nc("@title:window", "Plugin License Agreement")
- minimumWidth: UM.Theme.getSize("license_window_minimum").width
- minimumHeight: UM.Theme.getSize("license_window_minimum").height
- width: minimumWidth
- height: minimumHeight
- property var pluginName;
- property var licenseContent;
- property var pluginFileLocation;
- Item
- {
- anchors.fill: parent
- Label
- {
- id: licenseTitle
- anchors.top: parent.top
- anchors.left: parent.left
- anchors.right: parent.right
- text: licenseDialog.pluginName + catalog.i18nc("@label", "This plugin contains a license.\nYou need to accept this license to install this plugin.\nDo you agree with the terms below?")
- wrapMode: Text.Wrap
- }
- TextArea
- {
- id: licenseText
- anchors.top: licenseTitle.bottom
- anchors.bottom: parent.bottom
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.topMargin: UM.Theme.getSize("default_margin").height
- readOnly: true
- text: licenseDialog.licenseContent != null ? licenseDialog.licenseContent : ""
- }
- }
- rightButtons: [
- Button
- {
- id: acceptButton
- anchors.margins: UM.Theme.getSize("default_margin").width
- text: catalog.i18nc("@action:button", "Accept")
- onClicked:
- {
- licenseDialog.close();
- manager.installPlugin(licenseDialog.pluginFileLocation);
- }
- },
- Button
- {
- id: declineButton
- anchors.margins: UM.Theme.getSize("default_margin").width
- text: catalog.i18nc("@action:button", "Decline")
- onClicked:
- {
- licenseDialog.close();
- }
- }
- ]
- }
- Connections {
- target: manager
- onShowRestartDialog: {
- restartDialog.message = manager.getRestartDialogMessage();
- restartDialog.show();
- }
- }
- Window {
- id: restartDialog
- // title: catalog.i18nc("@title:tab", "Plugins");
- width: 360 * screenScaleFactor
- height: 120 * screenScaleFactor
- minimumWidth: 360 * screenScaleFactor
- minimumHeight: 120 * screenScaleFactor
- color: UM.Theme.getColor("sidebar")
- property var message;
- Text {
- id: message
- anchors {
- left: parent.left
- leftMargin: UM.Theme.getSize("default_margin").width
- top: parent.top
- topMargin: UM.Theme.getSize("default_margin").height
- }
- text: restartDialog.message != null ? restartDialog.message : ""
- }
- Button {
- id: laterButton
- text: "Later"
- onClicked: restartDialog.close();
- anchors {
- left: parent.left
- leftMargin: UM.Theme.getSize("default_margin").width
- bottom: parent.bottom
- bottomMargin: UM.Theme.getSize("default_margin").height
- }
- style: ButtonStyle {
- background: Rectangle {
- color: "transparent"
- implicitWidth: 96
- implicitHeight: 30
- border {
- width: 1
- color: UM.Theme.getColor("lining")
- }
- }
- label: Text {
- verticalAlignment: Text.AlignVCenter
- color: UM.Theme.getColor("text")
- text: control.text
- horizontalAlignment: Text.AlignHCenter
- }
- }
- }
- Button {
- id: restartButton
- text: "Quit Cura"
- anchors {
- right: parent.right
- rightMargin: UM.Theme.getSize("default_margin").width
- bottom: parent.bottom
- bottomMargin: UM.Theme.getSize("default_margin").height
- }
- onClicked: manager.restart()
- style: ButtonStyle {
- background: Rectangle {
- implicitWidth: 96
- implicitHeight: 30
- color: UM.Theme.getColor("primary")
- }
- label: Text {
- verticalAlignment: Text.AlignVCenter
- color: UM.Theme.getColor("button_text")
- font {
- pixelSize: 13
- bold: true
- }
- text: control.text
- horizontalAlignment: Text.AlignHCenter
- }
- }
- }
- }
- }
- }
|