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 UM 1.2 as UM
import Cura 1.6 as Cura
import Cura 1.7 as Cura
import DigitalFactory 1.0 as DF
@ -44,32 +44,12 @@ Item
height: childrenRect.height
spacing: UM.Theme.getSize("default_margin").width
Cura.TextField
Cura.SearchBar
{
id: searchBar
Layout.fillWidth: true
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.
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

View File

@ -32,7 +32,10 @@ class RemotePackageList(PackageList):
self._scope = JsonDecoratorScope(UltimakerCloudScope(CuraApplication.getInstance()))
self._package_type_filter = ""
self._requested_search_string = ""
self._current_search_string = ""
self._request_url = self._initialRequestUrl()
self.isLoadingChanged.connect(self._onLoadingChanged)
self.isLoadingChanged.emit()
def __del__(self) -> None:
@ -69,6 +72,7 @@ class RemotePackageList(PackageList):
self._request_url = self._initialRequestUrl()
packageTypeFilterChanged = pyqtSignal()
searchStringChanged = pyqtSignal()
def setPackageTypeFilter(self, new_filter: str) -> None:
if new_filter != self._package_type_filter:
@ -76,6 +80,10 @@ class RemotePackageList(PackageList):
self.reset()
self.packageTypeFilterChanged.emit()
def setSearchString(self, new_search: str) -> None:
self._requested_search_string = new_search
self._onLoadingChanged()
@pyqtProperty(str, fset = setPackageTypeFilter, notify = packageTypeFilterChanged)
def packageTypeFilter(self) -> str:
"""
@ -84,14 +92,33 @@ class RemotePackageList(PackageList):
"""
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:
"""
Get the URL to request the first paginated page with.
:return: A URL to request.
"""
request_url = f"{Marketplace.PACKAGES_URL}?limit={self.ITEMS_PER_PAGE}"
if self._package_type_filter != "":
return f"{Marketplace.PACKAGES_URL}?package_type={self._package_type_filter}&limit={self.ITEMS_PER_PAGE}"
return f"{Marketplace.PACKAGES_URL}?limit={self.ITEMS_PER_PAGE}"
request_url += f"&package_type={self._package_type_filter}"
if self._current_search_string != "":
request_url += f"&search={self._current_search_string}"
return request_url
def _parseResponse(self, reply: "QNetworkReply") -> None:
"""

View File

@ -14,6 +14,8 @@ Window
id: marketplaceDialog
property variant catalog: UM.I18nCatalog { name: "cura" }
signal searchStringChanged(string new_search)
minimumWidth: UM.Theme.getSize("modal_window_minimum").width
minimumHeight: UM.Theme.getSize("modal_window_minimum").height
width: minimumWidth
@ -70,36 +72,82 @@ Window
}
}
// Search & Top-Level Tabs
Item
{
Layout.preferredWidth: parent.width
Layout.preferredHeight: childrenRect.height
// Page selection.
TabBar
Layout.preferredWidth: parent.width - 2 * UM.Theme.getSize("thin_margin").width
RowLayout
{
id: pageSelectionTabBar
anchors.right: parent.right
anchors.rightMargin: UM.Theme.getSize("default_margin").width
height: UM.Theme.getSize("button_icon").height
spacing: 0
width: parent.width
height: UM.Theme.getSize("button_icon").height + UM.Theme.getSize("default_margin").height
spacing: UM.Theme.getSize("thin_margin").width
PackageTypeTab
Rectangle
{
width: implicitWidth
text: catalog.i18nc("@button", "Plugins")
onClicked: content.source = "Plugins.qml"
Layout.preferredHeight: parent.height
Layout.preferredWidth: searchBar.visible ? UM.Theme.getSize("thin_margin").width : 0
Layout.fillWidth: ! searchBar.visible
}
PackageTypeTab
Cura.SearchBar
{
width: implicitWidth
text: catalog.i18nc("@button", "Materials")
onClicked: content.source = "Materials.qml"
id: searchBar
Layout.preferredHeight: parent.height
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()
{
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
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
color: UM.Theme.getColor("main_background")
@ -109,12 +109,17 @@ Rectangle
visible: parent.hovered
}
UM.RecolorImage
Rectangle
{
anchors.fill: parent
color: UM.Theme.getColor("primary")
source: UM.Theme.getIcon("CheckCircle")
color: UM.Theme.getColor("action_button_hovered")
radius: width
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):
@ -159,7 +164,7 @@ Rectangle
color: UM.Theme.getColor("text")
}
Button
UM.SimpleButton
{
id: externalLinkButton
@ -167,19 +172,10 @@ Rectangle
Layout.preferredHeight: UM.Theme.getSize("card_tiny_icon").height
Layout.alignment: Qt.AlignTop
Rectangle
{
anchors.fill: parent
color: externalLinkButton.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("detail_background")
UM.RecolorImage
{
anchors.fill: parent
color: externalLinkButton.hovered ? UM.Theme.getColor("text_link") : UM.Theme.getColor("text")
source: UM.Theme.getIcon("LinkExternal")
}
}
iconSource: UM.Theme.getIcon("LinkExternal")
hoverColor: UM.Theme.getColor("text_link")
backgroundColor: UM.Theme.getColor("detail_background")
hoverBackgroundColor: UM.Theme.getColor("action_button_hovered")
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
}
Cura.TextField
Cura.SearchBar
{
id: filter
height: parent.height
anchors.left: parent.left
anchors.right: parent.right
leftPadding: searchIcon.width + UM.Theme.getSize("default_margin").width * 2
placeholderText: catalog.i18nc("@label:textbox", "Search settings")
font.italic: true
placeholderText: catalog.i18nc("@label:textbox", "Search settings") // Overwrite
property var expandedCategories
property bool lastFindingSettings: false
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")
}
onTextChanged:
{
settingsSearchTimer.restart()
}
onTextChanged: settingsSearchTimer.restart()
onEditingFinished:
{
@ -86,10 +66,7 @@ Item
}
}
Keys.onEscapePressed:
{
filter.text = ""
}
Keys.onEscapePressed: filter.text = ""
function updateDefinitionModel()
{