mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 04:37:51 -06:00
Show welcome page in marketplace window when not logged in
TODO: marketplace logo CURA-6569
This commit is contained in:
parent
ad85e29c0a
commit
3d352b3585
4 changed files with 82 additions and 5 deletions
|
@ -1,6 +1,8 @@
|
||||||
// Copyright (c) 2018 Ultimaker B.V.
|
// Copyright (c) 2018 Ultimaker B.V.
|
||||||
// Toolbox is released under the terms of the LGPLv3 or higher.
|
// Toolbox is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
// Main window for the Toolbox
|
||||||
|
|
||||||
import QtQuick 2.2
|
import QtQuick 2.2
|
||||||
import QtQuick.Dialogs 1.1
|
import QtQuick.Dialogs 1.1
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
|
@ -29,9 +31,16 @@ Window
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
|
WelcomePage
|
||||||
|
{
|
||||||
|
visible: toolbox.viewPage === "welcome"
|
||||||
|
}
|
||||||
|
|
||||||
ToolboxHeader
|
ToolboxHeader
|
||||||
{
|
{
|
||||||
id: header
|
id: header
|
||||||
|
visible: toolbox.viewPage !== "welcome"
|
||||||
}
|
}
|
||||||
|
|
||||||
Item
|
Item
|
||||||
|
|
53
plugins/Toolbox/resources/qml/WelcomePage.qml
Normal file
53
plugins/Toolbox/resources/qml/WelcomePage.qml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
// Copyright (c) 2018 Ultimaker B.V.
|
||||||
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
import QtQuick 2.7
|
||||||
|
import QtQuick.Controls 2.1
|
||||||
|
import QtQuick.Window 2.2
|
||||||
|
|
||||||
|
import UM 1.3 as UM
|
||||||
|
import Cura 1.1 as Cura
|
||||||
|
|
||||||
|
Column
|
||||||
|
{
|
||||||
|
id: welcomePage
|
||||||
|
spacing: UM.Theme.getSize("wide_margin").height
|
||||||
|
width: parent.width
|
||||||
|
height: childrenRect.height
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
Image
|
||||||
|
{
|
||||||
|
id: profileImage
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
source: "../images/logobot.svg"
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
width: Math.round(parent.width / 4)
|
||||||
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
id: welcomeTextLabel
|
||||||
|
text: catalog.i18nc("@description", "Get plugins and materials verified by Ultimaker")
|
||||||
|
width: Math.round(parent.width / 2)
|
||||||
|
font: UM.Theme.getFont("default")
|
||||||
|
color: UM.Theme.getColor("text")
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
wrapMode: Label.WordWrap
|
||||||
|
renderType: Text.NativeRendering
|
||||||
|
}
|
||||||
|
|
||||||
|
Cura.PrimaryButton
|
||||||
|
{
|
||||||
|
id: loginButton
|
||||||
|
width: UM.Theme.getSize("account_button").width
|
||||||
|
height: UM.Theme.getSize("account_button").height
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
text: catalog.i18nc("@button", "Sign in")
|
||||||
|
onClicked: Cura.API.account.login()
|
||||||
|
fixedWidthMode: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ class Toolbox(QObject, Extension):
|
||||||
|
|
||||||
# View page defines which type of page layout to use. For example,
|
# View page defines which type of page layout to use. For example,
|
||||||
# possible values include "overview", "detail" or "author".
|
# possible values include "overview", "detail" or "author".
|
||||||
self._view_page = "loading" # type: str
|
self._view_page = "welcome" # type: str
|
||||||
|
|
||||||
# Active package refers to which package is currently being downloaded,
|
# Active package refers to which package is currently being downloaded,
|
||||||
# installed, or otherwise modified.
|
# installed, or otherwise modified.
|
||||||
|
@ -105,7 +105,6 @@ class Toolbox(QObject, Extension):
|
||||||
self._restart_dialog_message = "" # type: str
|
self._restart_dialog_message = "" # type: str
|
||||||
|
|
||||||
self._application.initializationFinished.connect(self._onAppInitialized)
|
self._application.initializationFinished.connect(self._onAppInitialized)
|
||||||
self._application.getCuraAPI().account.loginStateChanged.connect(self._updateRequestHeader)
|
|
||||||
self._application.getCuraAPI().account.accessTokenChanged.connect(self._updateRequestHeader)
|
self._application.getCuraAPI().account.accessTokenChanged.connect(self._updateRequestHeader)
|
||||||
|
|
||||||
# Signals:
|
# Signals:
|
||||||
|
@ -126,6 +125,14 @@ class Toolbox(QObject, Extension):
|
||||||
showLicenseDialog = pyqtSignal()
|
showLicenseDialog = pyqtSignal()
|
||||||
uninstallVariablesChanged = pyqtSignal()
|
uninstallVariablesChanged = pyqtSignal()
|
||||||
|
|
||||||
|
def _loginStateChanged(self):
|
||||||
|
self._updateRequestHeader()
|
||||||
|
if self._application.getCuraAPI().account.isLoggedIn:
|
||||||
|
self.setViewPage("loading")
|
||||||
|
self._fetchPackageData()
|
||||||
|
else:
|
||||||
|
self.setViewPage("welcome")
|
||||||
|
|
||||||
def _updateRequestHeader(self):
|
def _updateRequestHeader(self):
|
||||||
self._request_headers = [
|
self._request_headers = [
|
||||||
(b"User-Agent",
|
(b"User-Agent",
|
||||||
|
@ -191,6 +198,8 @@ class Toolbox(QObject, Extension):
|
||||||
"packages": QUrl("{base_url}/packages".format(base_url = self._api_url))
|
"packages": QUrl("{base_url}/packages".format(base_url = self._api_url))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self._application.getCuraAPI().account.loginStateChanged.connect(self._loginStateChanged)
|
||||||
|
|
||||||
if CuraApplication.getInstance().getPreferences().getValue("info/automatic_update_check"):
|
if CuraApplication.getInstance().getPreferences().getValue("info/automatic_update_check"):
|
||||||
# Request the latest and greatest!
|
# Request the latest and greatest!
|
||||||
self._fetchPackageData()
|
self._fetchPackageData()
|
||||||
|
@ -213,9 +222,9 @@ class Toolbox(QObject, Extension):
|
||||||
# Gather installed packages:
|
# Gather installed packages:
|
||||||
self._updateInstalledModels()
|
self._updateInstalledModels()
|
||||||
|
|
||||||
|
# Displays the toolbox
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def browsePackages(self) -> None:
|
def launch(self) -> None:
|
||||||
self._fetchPackageData()
|
|
||||||
|
|
||||||
if not self._dialog:
|
if not self._dialog:
|
||||||
self._dialog = self._createDialog("Toolbox.qml")
|
self._dialog = self._createDialog("Toolbox.qml")
|
||||||
|
@ -224,6 +233,12 @@ class Toolbox(QObject, Extension):
|
||||||
Logger.log("e", "Unexpected error trying to create the 'Marketplace' dialog.")
|
Logger.log("e", "Unexpected error trying to create the 'Marketplace' dialog.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self._application.getCuraAPI().account.isLoggedIn:
|
||||||
|
self.setViewPage("loading")
|
||||||
|
self._fetchPackageData()
|
||||||
|
else:
|
||||||
|
self.setViewPage("welcome")
|
||||||
|
|
||||||
self._dialog.show()
|
self._dialog.show()
|
||||||
|
|
||||||
# Apply enabled/disabled state to installed plugins
|
# Apply enabled/disabled state to installed plugins
|
||||||
|
|
|
@ -160,7 +160,7 @@ Item
|
||||||
target: Cura.Actions.browsePackages
|
target: Cura.Actions.browsePackages
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
curaExtensions.callExtensionMethod("Toolbox", "browsePackages")
|
curaExtensions.callExtensionMethod("Toolbox", "launch")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue