fixed conflicts

This commit is contained in:
10r3n20 2021-11-17 10:07:42 +01:00
commit cc401e107e
6 changed files with 158 additions and 90 deletions

View File

@ -9,7 +9,7 @@ import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import UM 1.2 as UM import UM 1.2 as UM
import Cura 1.6 as Cura import Cura 1.7 as Cura
import DigitalFactory 1.0 as DF import DigitalFactory 1.0 as DF
@ -44,32 +44,12 @@ Item
height: childrenRect.height height: childrenRect.height
spacing: UM.Theme.getSize("default_margin").width spacing: UM.Theme.getSize("default_margin").width
Cura.TextField Cura.SearchBar
{ {
id: searchBar id: searchBar
Layout.fillWidth: true Layout.fillWidth: true
implicitHeight: createNewProjectButton.height implicitHeight: createNewProjectButton.height
leftPadding: searchIcon.width + UM.Theme.getSize("default_margin").width * 2
onTextEdited: manager.projectFilter = text //Update the search filter when editing this text field. onTextEdited: manager.projectFilter = text //Update the search filter when editing this text field.
placeholderText: "Search"
UM.RecolorImage
{
id: searchIcon
anchors
{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: UM.Theme.getSize("default_margin").width
}
source: UM.Theme.getIcon("search")
height: UM.Theme.getSize("small_button_icon").height
width: height
color: UM.Theme.getColor("text")
}
} }
Cura.SecondaryButton Cura.SecondaryButton

View File

@ -32,7 +32,10 @@ class RemotePackageList(PackageList):
self._scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance())) self._scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance()))
self._package_type_filter = "" self._package_type_filter = ""
self._requested_search_string = ""
self._current_search_string = ""
self._request_url = self._initialRequestUrl() self._request_url = self._initialRequestUrl()
self.isLoadingChanged.connect(self._onLoadingChanged)
self.isLoadingChanged.emit() self.isLoadingChanged.emit()
def __del__(self) -> None: def __del__(self) -> None:
@ -69,6 +72,7 @@ class RemotePackageList(PackageList):
self._request_url = self._initialRequestUrl() self._request_url = self._initialRequestUrl()
packageTypeFilterChanged = pyqtSignal() packageTypeFilterChanged = pyqtSignal()
searchStringChanged = pyqtSignal()
def setPackageTypeFilter(self, new_filter: str) -> None: def setPackageTypeFilter(self, new_filter: str) -> None:
if new_filter != self._package_type_filter: if new_filter != self._package_type_filter:
@ -76,6 +80,10 @@ class RemotePackageList(PackageList):
self.reset() self.reset()
self.packageTypeFilterChanged.emit() self.packageTypeFilterChanged.emit()
def setSearchString(self, new_search: str) -> None:
self._requested_search_string = new_search
self._onLoadingChanged()
@pyqtProperty(str, fset = setPackageTypeFilter, notify = packageTypeFilterChanged) @pyqtProperty(str, fset = setPackageTypeFilter, notify = packageTypeFilterChanged)
def packageTypeFilter(self) -> str: def packageTypeFilter(self) -> str:
""" """
@ -84,14 +92,33 @@ class RemotePackageList(PackageList):
""" """
return self._package_type_filter return self._package_type_filter
@pyqtProperty(str, fset = setSearchString, notify = searchStringChanged)
def searchString(self) -> str:
"""
Get the string the user is currently searching for (as in: the list is updating) within the packages,
or an empty string if no extra search filter has to be applied. Does not override package-type filter!
:return: String the user is searching for. Empty denotes 'no search filter'.
"""
return self._current_search_string
def _onLoadingChanged(self) -> None:
if self._requested_search_string != self._current_search_string and not self._is_loading:
self._current_search_string = self._requested_search_string
self.reset()
self.updatePackages()
self.searchStringChanged.emit()
def _initialRequestUrl(self) -> str: def _initialRequestUrl(self) -> str:
""" """
Get the URL to request the first paginated page with. Get the URL to request the first paginated page with.
:return: A URL to request. :return: A URL to request.
""" """
request_url = f"{Marketplace.PACKAGES_URL}?limit={self.ITEMS_PER_PAGE}"
if self._package_type_filter != "": if self._package_type_filter != "":
return f"{Marketplace.PACKAGES_URL}?package_type={self._package_type_filter}&limit={self.ITEMS_PER_PAGE}" request_url += f"&package_type={self._package_type_filter}"
return f"{Marketplace.PACKAGES_URL}?limit={self.ITEMS_PER_PAGE}" if self._current_search_string != "":
request_url += f"&search={self._current_search_string}"
return request_url
def _parseResponse(self, reply: "QNetworkReply") -> None: def _parseResponse(self, reply: "QNetworkReply") -> None:
""" """

View File

@ -14,6 +14,8 @@ Window
id: marketplaceDialog id: marketplaceDialog
property variant catalog: UM.I18nCatalog { name: "cura" } property variant catalog: UM.I18nCatalog { name: "cura" }
signal searchStringChanged(string new_search)
minimumWidth: UM.Theme.getSize("modal_window_minimum").width minimumWidth: UM.Theme.getSize("modal_window_minimum").width
minimumHeight: UM.Theme.getSize("modal_window_minimum").height minimumHeight: UM.Theme.getSize("modal_window_minimum").height
width: minimumWidth width: minimumWidth
@ -70,36 +72,82 @@ Window
} }
} }
// Search & Top-Level Tabs
Item Item
{ {
Layout.preferredWidth: parent.width
Layout.preferredHeight: childrenRect.height Layout.preferredHeight: childrenRect.height
Layout.preferredWidth: parent.width - 2 * UM.Theme.getSize("thin_margin").width
// Page selection. RowLayout
TabBar
{ {
id: pageSelectionTabBar width: parent.width
anchors.right: parent.right height: UM.Theme.getSize("button_icon").height + UM.Theme.getSize("default_margin").height
anchors.rightMargin: UM.Theme.getSize("default_margin").width spacing: UM.Theme.getSize("thin_margin").width
height: UM.Theme.getSize("button_icon").height
spacing: 0
PackageTypeTab Rectangle
{ {
width: implicitWidth Layout.preferredHeight: parent.height
text: catalog.i18nc("@button", "Plugins") Layout.preferredWidth: searchBar.visible ? UM.Theme.getSize("thin_margin").width : 0
onClicked: content.source = "Plugins.qml" Layout.fillWidth: ! searchBar.visible
} }
PackageTypeTab
Cura.SearchBar
{ {
width: implicitWidth id: searchBar
text: catalog.i18nc("@button", "Materials") Layout.preferredHeight: parent.height
onClicked: content.source = "Materials.qml" Layout.fillWidth: true
onTextEdited: searchStringChanged(text)
} }
ManagePackagesButton
// Page selection.
TabBar
{ {
onClicked: content.source = "ManagedPackages.qml" id: pageSelectionTabBar
anchors.right: parent.right
height: UM.Theme.getSize("button_icon").height
spacing: 0
PackageTypeTab
{
id: pluginTabText
width: implicitWidth
text: catalog.i18nc("@button", "Plugins")
onClicked:
{
searchBar.text = ""
searchBar.visible = true
content.source = "Plugins.qml"
}
}
PackageTypeTab
{
id: materialsTabText
width: implicitWidth
text: catalog.i18nc("@button", "Materials")
onClicked:
{
searchBar.text = ""
searchBar.visible = true
content.source = "Materials.qml"
}
}
ManagePackagesButton
{
onClicked: content.source = "ManagedPackages.qml"
}
} }
TextMetrics
{
id: pluginTabTextMetrics
text: pluginTabText.text
font: pluginTabText.font
}
TextMetrics
{
id: materialsTabTextMetrics
text: materialsTabText.text
font: materialsTabText.font
}
} }
} }
@ -124,6 +172,11 @@ Window
function onLoaded() function onLoaded()
{ {
pageTitle.text = content.item.pageTitle pageTitle.text = content.item.pageTitle
searchStringChanged.connect(handleSearchStringChanged)
}
function handleSearchStringChanged(new_search)
{
content.item.model.searchString = new_search
} }
} }
} }

View File

@ -12,7 +12,7 @@ Rectangle
{ {
property var packageData property var packageData
width: parent ? parent.width - UM.Theme.getSize("default_margin").width : 0 width: parent ? parent.width - UM.Theme.getSize("thin_margin").width : 0
height: childrenRect.height height: childrenRect.height
color: UM.Theme.getColor("main_background") color: UM.Theme.getColor("main_background")
@ -109,12 +109,17 @@ Rectangle
visible: parent.hovered visible: parent.hovered
} }
UM.RecolorImage Rectangle
{ {
anchors.fill: parent anchors.fill: parent
color: UM.Theme.getColor("action_button_hovered")
color: UM.Theme.getColor("primary") radius: width
source: UM.Theme.getIcon("CheckCircle") UM.RecolorImage
{
anchors.fill: parent
color: UM.Theme.getColor("primary")
source: UM.Theme.getIcon("CheckCircle")
}
} }
//NOTE: Can we link to something here? (Probably a static link explaining what verified is): //NOTE: Can we link to something here? (Probably a static link explaining what verified is):
@ -159,7 +164,7 @@ Rectangle
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
} }
Button UM.SimpleButton
{ {
id: externalLinkButton id: externalLinkButton
@ -167,19 +172,10 @@ Rectangle
Layout.preferredHeight: UM.Theme.getSize("card_tiny_icon").height Layout.preferredHeight: UM.Theme.getSize("card_tiny_icon").height
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
Rectangle iconSource: UM.Theme.getIcon("LinkExternal")
{ hoverColor: UM.Theme.getColor("text_link")
anchors.fill: parent backgroundColor: UM.Theme.getColor("detail_background")
color: externalLinkButton.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("detail_background") hoverBackgroundColor: UM.Theme.getColor("action_button_hovered")
UM.RecolorImage
{
anchors.fill: parent
color: externalLinkButton.hovered ? UM.Theme.getColor("text_link") : UM.Theme.getColor("text")
source: UM.Theme.getIcon("LinkExternal")
}
}
onClicked: Qt.openUrlExternally(packageData.packageInfoUrl) onClicked: Qt.openUrlExternally(packageData.packageInfoUrl)
} }
} }

View File

@ -0,0 +1,35 @@
// Copyright (C) 2021 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.1
import UM 1.6 as UM
import Cura 1.7 as Cura
Cura.TextField
{
UM.I18nCatalog { id: catalog; name: "cura" }
leftPadding: searchIcon.width + UM.Theme.getSize("default_margin").width * 2
placeholderText: catalog.i18nc("@placeholder", "Search")
font.italic: true
UM.RecolorImage
{
id: searchIcon
anchors
{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: UM.Theme.getSize("default_margin").width
}
source: UM.Theme.getIcon("Magnifier")
height: UM.Theme.getSize("small_button_icon").height
width: height
color: UM.Theme.getColor("text")
}
}

View File

@ -41,39 +41,19 @@ Item
repeat: false repeat: false
} }
Cura.TextField Cura.SearchBar
{ {
id: filter id: filter
height: parent.height height: parent.height
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
leftPadding: searchIcon.width + UM.Theme.getSize("default_margin").width * 2
placeholderText: catalog.i18nc("@label:textbox", "Search settings") placeholderText: catalog.i18nc("@label:textbox", "Search settings") // Overwrite
font.italic: true
property var expandedCategories property var expandedCategories
property bool lastFindingSettings: false property bool lastFindingSettings: false
UM.RecolorImage onTextChanged: settingsSearchTimer.restart()
{
id: searchIcon
anchors
{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: UM.Theme.getSize("default_margin").width
}
source: UM.Theme.getIcon("search")
height: UM.Theme.getSize("small_button_icon").height
width: height
color: UM.Theme.getColor("text")
}
onTextChanged:
{
settingsSearchTimer.restart()
}
onEditingFinished: onEditingFinished:
{ {
@ -86,10 +66,7 @@ Item
} }
} }
Keys.onEscapePressed: Keys.onEscapePressed: filter.text = ""
{
filter.text = ""
}
function updateDefinitionModel() function updateDefinitionModel()
{ {