mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
autofmt
This commit is contained in:
@@ -739,7 +739,7 @@ Singleton {
|
||||
if (parsed.general && parsed.general.dimDesktop === true) {
|
||||
// Check if dimmerOpacity exists in raw JSON (not adapter default)
|
||||
var dimmerOpacityInJson = parsed.general.dimmerOpacity
|
||||
|
||||
|
||||
// If dimmerOpacity wasn't explicitly set in JSON or was 0, set it to 0.8 (80% dimming)
|
||||
if (dimmerOpacityInJson === undefined || dimmerOpacityInJson === 0) {
|
||||
adapter.general.dimmerOpacity = 0.8
|
||||
|
||||
@@ -27,7 +27,7 @@ Popup {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
y: {
|
||||
if (anchorItem) {
|
||||
var itemPos = anchorItem.mapToItem(parent, 0, 0)
|
||||
@@ -43,19 +43,19 @@ Popup {
|
||||
anchorItem = item
|
||||
open()
|
||||
Qt.callLater(() => {
|
||||
// Try to focus the first input if available
|
||||
if (resolutionWidthInput.inputItem) {
|
||||
resolutionWidthInput.inputItem.forceActiveFocus()
|
||||
}
|
||||
})
|
||||
// Try to focus the first input if available
|
||||
if (resolutionWidthInput.inputItem) {
|
||||
resolutionWidthInput.inputItem.forceActiveFocus()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
onOpened: {
|
||||
Qt.callLater(() => {
|
||||
if (resolutionWidthInput.inputItem) {
|
||||
resolutionWidthInput.inputItem.forceActiveFocus()
|
||||
}
|
||||
})
|
||||
if (resolutionWidthInput.inputItem) {
|
||||
resolutionWidthInput.inputItem.forceActiveFocus()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function hide() {
|
||||
@@ -153,22 +153,33 @@ Popup {
|
||||
NComboBox {
|
||||
id: sortingComboBox
|
||||
Layout.fillWidth: true
|
||||
model: [
|
||||
{ "key": "date_added", "name": I18n.tr("wallpaper.panel.sorting.date_added") },
|
||||
{ "key": "relevance", "name": I18n.tr("wallpaper.panel.sorting.relevance") },
|
||||
{ "key": "random", "name": I18n.tr("wallpaper.panel.sorting.random") },
|
||||
{ "key": "views", "name": I18n.tr("wallpaper.panel.sorting.views") },
|
||||
{ "key": "favorites", "name": I18n.tr("wallpaper.panel.sorting.favorites") },
|
||||
{ "key": "toplist", "name": I18n.tr("wallpaper.panel.sorting.toplist") }
|
||||
]
|
||||
model: [{
|
||||
"key": "date_added",
|
||||
"name": I18n.tr("wallpaper.panel.sorting.date_added")
|
||||
}, {
|
||||
"key": "relevance",
|
||||
"name": I18n.tr("wallpaper.panel.sorting.relevance")
|
||||
}, {
|
||||
"key": "random",
|
||||
"name": I18n.tr("wallpaper.panel.sorting.random")
|
||||
}, {
|
||||
"key": "views",
|
||||
"name": I18n.tr("wallpaper.panel.sorting.views")
|
||||
}, {
|
||||
"key": "favorites",
|
||||
"name": I18n.tr("wallpaper.panel.sorting.favorites")
|
||||
}, {
|
||||
"key": "toplist",
|
||||
"name": I18n.tr("wallpaper.panel.sorting.toplist")
|
||||
}]
|
||||
currentKey: Settings.data.wallpaper.wallhavenSorting || "date_added"
|
||||
onSelected: key => {
|
||||
Settings.data.wallpaper.wallhavenSorting = key
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.sorting = key
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
}
|
||||
}
|
||||
Settings.data.wallpaper.wallhavenSorting = key
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.sorting = key
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,18 +199,21 @@ Popup {
|
||||
NComboBox {
|
||||
id: orderComboBox
|
||||
Layout.fillWidth: true
|
||||
model: [
|
||||
{ "key": "desc", "name": I18n.tr("wallpaper.panel.order.desc") },
|
||||
{ "key": "asc", "name": I18n.tr("wallpaper.panel.order.asc") }
|
||||
]
|
||||
model: [{
|
||||
"key": "desc",
|
||||
"name": I18n.tr("wallpaper.panel.order.desc")
|
||||
}, {
|
||||
"key": "asc",
|
||||
"name": I18n.tr("wallpaper.panel.order.asc")
|
||||
}]
|
||||
currentKey: Settings.data.wallpaper.wallhavenOrder || "desc"
|
||||
onSelected: key => {
|
||||
Settings.data.wallpaper.wallhavenOrder = key
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.order = key
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
}
|
||||
}
|
||||
Settings.data.wallpaper.wallhavenOrder = key
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.order = key
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,19 +232,24 @@ Popup {
|
||||
NComboBox {
|
||||
id: purityComboBox
|
||||
Layout.fillWidth: true
|
||||
model: [
|
||||
{ "key": "111", "name": I18n.tr("wallpaper.panel.purity.all") },
|
||||
{ "key": "100", "name": I18n.tr("wallpaper.panel.purity.sfw") },
|
||||
{ "key": "010", "name": I18n.tr("wallpaper.panel.purity.sketchy") }
|
||||
]
|
||||
model: [{
|
||||
"key": "111",
|
||||
"name": I18n.tr("wallpaper.panel.purity.all")
|
||||
}, {
|
||||
"key": "100",
|
||||
"name": I18n.tr("wallpaper.panel.purity.sfw")
|
||||
}, {
|
||||
"key": "010",
|
||||
"name": I18n.tr("wallpaper.panel.purity.sketchy")
|
||||
}]
|
||||
currentKey: Settings.data.wallpaper.wallhavenPurity
|
||||
onSelected: key => {
|
||||
Settings.data.wallpaper.wallhavenPurity = key
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.purity = key
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
}
|
||||
}
|
||||
Settings.data.wallpaper.wallhavenPurity = key
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.purity = key
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,8 +459,8 @@ Popup {
|
||||
property bool checked: false
|
||||
signal toggled(bool checked)
|
||||
onToggled: checked => {
|
||||
categoriesRow.updateCategories(checked, categoriesRow.getCategoryValue(1), categoriesRow.getCategoryValue(2))
|
||||
}
|
||||
categoriesRow.updateCategories(checked, categoriesRow.getCategoryValue(1), categoriesRow.getCategoryValue(2))
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
@@ -449,8 +468,8 @@ Popup {
|
||||
property bool checked: false
|
||||
signal toggled(bool checked)
|
||||
onToggled: checked => {
|
||||
categoriesRow.updateCategories(categoriesRow.getCategoryValue(0), checked, categoriesRow.getCategoryValue(2))
|
||||
}
|
||||
categoriesRow.updateCategories(categoriesRow.getCategoryValue(0), checked, categoriesRow.getCategoryValue(2))
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
@@ -458,8 +477,8 @@ Popup {
|
||||
property bool checked: false
|
||||
signal toggled(bool checked)
|
||||
onToggled: checked => {
|
||||
categoriesRow.updateCategories(categoriesRow.getCategoryValue(0), categoriesRow.getCategoryValue(1), checked)
|
||||
}
|
||||
categoriesRow.updateCategories(categoriesRow.getCategoryValue(0), categoriesRow.getCategoryValue(1), checked)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -489,12 +508,15 @@ Popup {
|
||||
NComboBox {
|
||||
id: resolutionModeComboBox
|
||||
Layout.fillWidth: true
|
||||
model: [
|
||||
{ "key": "atleast", "name": I18n.tr("wallpaper.panel.resolution.atleast") },
|
||||
{ "key": "exact", "name": I18n.tr("wallpaper.panel.resolution.exact") }
|
||||
]
|
||||
model: [{
|
||||
"key": "atleast",
|
||||
"name": I18n.tr("wallpaper.panel.resolution.atleast")
|
||||
}, {
|
||||
"key": "exact",
|
||||
"name": I18n.tr("wallpaper.panel.resolution.exact")
|
||||
}]
|
||||
currentKey: Settings.data.wallpaper.wallhavenResolutionMode || "atleast"
|
||||
|
||||
|
||||
Connections {
|
||||
target: Settings.data.wallpaper
|
||||
function onWallhavenResolutionModeChanged() {
|
||||
@@ -503,11 +525,11 @@ Popup {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSelected: key => {
|
||||
Settings.data.wallpaper.wallhavenResolutionMode = key
|
||||
updateResolution(false)
|
||||
}
|
||||
Settings.data.wallpaper.wallhavenResolutionMode = key
|
||||
updateResolution(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +543,7 @@ Popup {
|
||||
placeholderText: "Width"
|
||||
inputMethodHints: Qt.ImhDigitsOnly
|
||||
text: Settings.data.wallpaper.wallhavenResolutionWidth || ""
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
if (resolutionWidthInput.inputItem) {
|
||||
resolutionWidthInput.inputItem.focusPolicy = Qt.StrongFocus
|
||||
@@ -529,14 +551,14 @@ Popup {
|
||||
resolutionWidthInput.inputItem.activeFocusOnPress = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Ensure focus when clicked
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus && resolutionWidthInput.inputItem) {
|
||||
resolutionWidthInput.inputItem.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Connections {
|
||||
target: Settings.data.wallpaper
|
||||
function onWallhavenResolutionWidthChanged() {
|
||||
@@ -545,7 +567,7 @@ Popup {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onEditingFinished: {
|
||||
Settings.data.wallpaper.wallhavenResolutionWidth = text
|
||||
updateResolution(false)
|
||||
@@ -565,21 +587,21 @@ Popup {
|
||||
placeholderText: "Height"
|
||||
inputMethodHints: Qt.ImhDigitsOnly
|
||||
text: Settings.data.wallpaper.wallhavenResolutionHeight || ""
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
if (resolutionHeightInput.inputItem) {
|
||||
resolutionHeightInput.inputItem.focusPolicy = Qt.StrongFocus
|
||||
resolutionHeightInput.inputItem.activeFocusOnPress = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Ensure focus when clicked
|
||||
onActiveFocusChanged: {
|
||||
if (activeFocus && resolutionHeightInput.inputItem) {
|
||||
resolutionHeightInput.inputItem.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Connections {
|
||||
target: Settings.data.wallpaper
|
||||
function onWallhavenResolutionHeightChanged() {
|
||||
@@ -588,7 +610,7 @@ Popup {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onEditingFinished: {
|
||||
Settings.data.wallpaper.wallhavenResolutionHeight = text
|
||||
updateResolution(false)
|
||||
@@ -614,20 +636,19 @@ Popup {
|
||||
WallhavenService.purity = Settings.data.wallpaper.wallhavenPurity
|
||||
WallhavenService.sorting = Settings.data.wallpaper.wallhavenSorting
|
||||
WallhavenService.order = Settings.data.wallpaper.wallhavenOrder
|
||||
|
||||
|
||||
// Update resolution settings (without triggering search)
|
||||
updateResolution(false)
|
||||
|
||||
|
||||
// Refresh the wallpaper search with current settings
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
|
||||
|
||||
// Close the popup after applying (delay to prevent click propagation)
|
||||
Qt.callLater(() => {
|
||||
root.hide()
|
||||
})
|
||||
root.hide()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -278,7 +278,7 @@ SmartPanel {
|
||||
id: searchInput
|
||||
placeholderText: Settings.data.wallpaper.useWallhaven ? I18n.tr("placeholders.search-wallhaven") : I18n.tr("placeholders.search-wallpapers")
|
||||
Layout.fillWidth: true
|
||||
|
||||
|
||||
property bool initializing: true
|
||||
Component.onCompleted: {
|
||||
// Initialize text based on current mode
|
||||
@@ -292,11 +292,11 @@ SmartPanel {
|
||||
searchInput.inputItem.forceActiveFocus()
|
||||
}
|
||||
// Mark initialization as complete after a short delay
|
||||
Qt.callLater(function() {
|
||||
Qt.callLater(function () {
|
||||
searchInput.initializing = false
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Connections {
|
||||
target: Settings.data.wallpaper
|
||||
function onUseWallhavenChanged() {
|
||||
@@ -375,50 +375,53 @@ SmartPanel {
|
||||
NComboBox {
|
||||
id: sourceComboBox
|
||||
Layout.fillWidth: true
|
||||
model: [
|
||||
{ "key": "local", "name": I18n.tr("wallpaper.panel.source.local") },
|
||||
{ "key": "wallhaven", "name": I18n.tr("wallpaper.panel.source.wallhaven") }
|
||||
]
|
||||
model: [{
|
||||
"key": "local",
|
||||
"name": I18n.tr("wallpaper.panel.source.local")
|
||||
}, {
|
||||
"key": "wallhaven",
|
||||
"name": I18n.tr("wallpaper.panel.source.wallhaven")
|
||||
}]
|
||||
currentKey: Settings.data.wallpaper.useWallhaven ? "wallhaven" : "local"
|
||||
property bool skipNextSelected: false
|
||||
Component.onCompleted: {
|
||||
// Skip the first onSelected if it fires during initialization
|
||||
skipNextSelected = true
|
||||
Qt.callLater(function() {
|
||||
Qt.callLater(function () {
|
||||
skipNextSelected = false
|
||||
})
|
||||
}
|
||||
onSelected: key => {
|
||||
if (skipNextSelected) {
|
||||
return
|
||||
}
|
||||
var useWallhaven = (key === "wallhaven")
|
||||
Settings.data.wallpaper.useWallhaven = useWallhaven
|
||||
// Update search input text based on mode
|
||||
if (useWallhaven) {
|
||||
searchInput.text = Settings.data.wallpaper.wallhavenQuery || ""
|
||||
} else {
|
||||
searchInput.text = wallpaperPanel.filterText || ""
|
||||
}
|
||||
if (useWallhaven && typeof WallhavenService !== "undefined") {
|
||||
// Update service properties when switching to Wallhaven
|
||||
// Don't search here - Component.onCompleted will handle it when the component is created
|
||||
// This prevents duplicate searches
|
||||
WallhavenService.categories = Settings.data.wallpaper.wallhavenCategories
|
||||
WallhavenService.purity = Settings.data.wallpaper.wallhavenPurity
|
||||
WallhavenService.sorting = Settings.data.wallpaper.wallhavenSorting
|
||||
WallhavenService.order = Settings.data.wallpaper.wallhavenOrder
|
||||
|
||||
// Update resolution settings
|
||||
wallpaperPanel.updateWallhavenResolution()
|
||||
|
||||
// If the view is already initialized, trigger a new search when switching to it
|
||||
if (wallhavenView && wallhavenView.initialized && !WallhavenService.fetching) {
|
||||
wallhavenView.loading = true
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (skipNextSelected) {
|
||||
return
|
||||
}
|
||||
var useWallhaven = (key === "wallhaven")
|
||||
Settings.data.wallpaper.useWallhaven = useWallhaven
|
||||
// Update search input text based on mode
|
||||
if (useWallhaven) {
|
||||
searchInput.text = Settings.data.wallpaper.wallhavenQuery || ""
|
||||
} else {
|
||||
searchInput.text = wallpaperPanel.filterText || ""
|
||||
}
|
||||
if (useWallhaven && typeof WallhavenService !== "undefined") {
|
||||
// Update service properties when switching to Wallhaven
|
||||
// Don't search here - Component.onCompleted will handle it when the component is created
|
||||
// This prevents duplicate searches
|
||||
WallhavenService.categories = Settings.data.wallpaper.wallhavenCategories
|
||||
WallhavenService.purity = Settings.data.wallpaper.wallhavenPurity
|
||||
WallhavenService.sorting = Settings.data.wallpaper.wallhavenSorting
|
||||
WallhavenService.order = Settings.data.wallpaper.wallhavenOrder
|
||||
|
||||
// Update resolution settings
|
||||
wallpaperPanel.updateWallhavenResolution()
|
||||
|
||||
// If the view is already initialized, trigger a new search when switching to it
|
||||
if (wallhavenView && wallhavenView.initialized && !WallhavenService.fetching) {
|
||||
wallhavenView.loading = true
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Settings button (only visible for Wallhaven)
|
||||
@@ -862,7 +865,7 @@ SmartPanel {
|
||||
initialized = true
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// We're the first one - claim the search
|
||||
initialized = true
|
||||
WallhavenService.initialSearchScheduled = true
|
||||
@@ -870,7 +873,7 @@ SmartPanel {
|
||||
WallhavenService.purity = Settings.data.wallpaper.wallhavenPurity
|
||||
WallhavenService.sorting = Settings.data.wallpaper.wallhavenSorting
|
||||
WallhavenService.order = Settings.data.wallpaper.wallhavenOrder
|
||||
|
||||
|
||||
// Initialize resolution settings
|
||||
var width = Settings.data.wallpaper.wallhavenResolutionWidth || ""
|
||||
var height = Settings.data.wallpaper.wallhavenResolutionHeight || ""
|
||||
@@ -888,14 +891,13 @@ SmartPanel {
|
||||
WallhavenService.minResolution = ""
|
||||
WallhavenService.resolutions = ""
|
||||
}
|
||||
|
||||
|
||||
// Now check if we can actually search (fetching check is in WallhavenService.search)
|
||||
loading = true
|
||||
WallhavenService.search(Settings.data.wallpaper.wallhavenQuery || "", 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
spacing: Style.marginM
|
||||
@@ -918,182 +920,182 @@ SmartPanel {
|
||||
|
||||
model: wallpapers || []
|
||||
|
||||
property int columns: (screen.width > 1920) ? 5 : 4
|
||||
property int itemSize: cellWidth
|
||||
property int columns: (screen.width > 1920) ? 5 : 4
|
||||
property int itemSize: cellWidth
|
||||
|
||||
cellWidth: Math.floor((width - leftMargin - rightMargin) / columns)
|
||||
cellHeight: Math.floor(itemSize * 0.7) + Style.marginXS + Style.fontSizeXS + Style.marginM
|
||||
cellWidth: Math.floor((width - leftMargin - rightMargin) / columns)
|
||||
cellHeight: Math.floor(itemSize * 0.7) + Style.marginXS + Style.fontSizeXS + Style.marginM
|
||||
|
||||
leftMargin: Style.marginS
|
||||
rightMargin: Style.marginS
|
||||
topMargin: Style.marginS
|
||||
bottomMargin: Style.marginS
|
||||
leftMargin: Style.marginS
|
||||
rightMargin: Style.marginS
|
||||
topMargin: Style.marginS
|
||||
bottomMargin: Style.marginS
|
||||
|
||||
onCurrentIndexChanged: {
|
||||
if (currentIndex >= 0) {
|
||||
let row = Math.floor(currentIndex / columns)
|
||||
let itemY = row * cellHeight
|
||||
let viewportTop = contentY
|
||||
let viewportBottom = viewportTop + height
|
||||
onCurrentIndexChanged: {
|
||||
if (currentIndex >= 0) {
|
||||
let row = Math.floor(currentIndex / columns)
|
||||
let itemY = row * cellHeight
|
||||
let viewportTop = contentY
|
||||
let viewportBottom = viewportTop + height
|
||||
|
||||
if (itemY < viewportTop) {
|
||||
contentY = Math.max(0, itemY - cellHeight)
|
||||
} else if (itemY + cellHeight > viewportBottom) {
|
||||
contentY = itemY + cellHeight - height + cellHeight
|
||||
if (itemY < viewportTop) {
|
||||
contentY = Math.max(0, itemY - cellHeight)
|
||||
} else if (itemY + cellHeight > viewportBottom) {
|
||||
contentY = itemY + cellHeight - height + cellHeight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: event => {
|
||||
if (event.key === Qt.Key_Return || event.key === Qt.Key_Space) {
|
||||
if (currentIndex >= 0 && currentIndex < wallpapers.length) {
|
||||
let wallpaper = wallpapers[currentIndex]
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.downloadWallpaper(wallpaper, function (success, localPath) {
|
||||
if (success) {
|
||||
if (Settings.data.wallpaper.setWallpaperOnAllMonitors) {
|
||||
WallpaperService.changeWallpaper(localPath, undefined)
|
||||
} else {
|
||||
WallpaperService.changeWallpaper(localPath, screen.name)
|
||||
Keys.onPressed: event => {
|
||||
if (event.key === Qt.Key_Return || event.key === Qt.Key_Space) {
|
||||
if (currentIndex >= 0 && currentIndex < wallpapers.length) {
|
||||
let wallpaper = wallpapers[currentIndex]
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.downloadWallpaper(wallpaper, function (success, localPath) {
|
||||
if (success) {
|
||||
if (Settings.data.wallpaper.setWallpaperOnAllMonitors) {
|
||||
WallpaperService.changeWallpaper(localPath, undefined)
|
||||
} else {
|
||||
WallpaperService.changeWallpaper(localPath, screen.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
event.accepted = true
|
||||
}
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
policy: ScrollBar.AsNeeded
|
||||
parent: wallhavenGridView
|
||||
x: wallhavenGridView.mirrored ? 0 : wallhavenGridView.width - width
|
||||
y: 0
|
||||
height: wallhavenGridView.height
|
||||
ScrollBar.vertical: ScrollBar {
|
||||
policy: ScrollBar.AsNeeded
|
||||
parent: wallhavenGridView
|
||||
x: wallhavenGridView.mirrored ? 0 : wallhavenGridView.width - width
|
||||
y: 0
|
||||
height: wallhavenGridView.height
|
||||
|
||||
property color handleColor: Qt.alpha(Color.mHover, 0.8)
|
||||
property color handleHoverColor: handleColor
|
||||
property color handlePressedColor: handleColor
|
||||
property real handleWidth: 6
|
||||
property real handleRadius: Style.radiusM
|
||||
property color handleColor: Qt.alpha(Color.mHover, 0.8)
|
||||
property color handleHoverColor: handleColor
|
||||
property color handlePressedColor: handleColor
|
||||
property real handleWidth: 6
|
||||
property real handleRadius: Style.radiusM
|
||||
|
||||
contentItem: Rectangle {
|
||||
implicitWidth: parent.handleWidth
|
||||
implicitHeight: 100
|
||||
radius: parent.handleRadius
|
||||
color: parent.pressed ? parent.handlePressedColor : parent.hovered ? parent.handleHoverColor : parent.handleColor
|
||||
opacity: parent.policy === ScrollBar.AlwaysOn || parent.active ? 1.0 : 0.0
|
||||
contentItem: Rectangle {
|
||||
implicitWidth: parent.handleWidth
|
||||
implicitHeight: 100
|
||||
radius: parent.handleRadius
|
||||
color: parent.pressed ? parent.handlePressedColor : parent.hovered ? parent.handleHoverColor : parent.handleColor
|
||||
opacity: parent.policy === ScrollBar.AlwaysOn || parent.active ? 1.0 : 0.0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Style.animationFast
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
implicitWidth: parent.handleWidth
|
||||
implicitHeight: 100
|
||||
color: Color.transparent
|
||||
opacity: parent.policy === ScrollBar.AlwaysOn || parent.active ? 0.3 : 0.0
|
||||
radius: parent.handleRadius / 2
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delegate: ColumnLayout {
|
||||
id: wallhavenItem
|
||||
|
||||
required property var modelData
|
||||
required property int index
|
||||
property string thumbnailUrl: (modelData && typeof WallhavenService !== "undefined") ? WallhavenService.getThumbnailUrl(modelData, "large") : ""
|
||||
property string wallpaperId: (modelData && modelData.id) ? modelData.id : ""
|
||||
|
||||
width: wallhavenGridView.itemSize
|
||||
spacing: Style.marginXS
|
||||
|
||||
Rectangle {
|
||||
id: imageContainer
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: Math.round(wallhavenGridView.itemSize * 0.67)
|
||||
color: Color.transparent
|
||||
|
||||
Image {
|
||||
id: img
|
||||
source: thumbnailUrl
|
||||
anchors.fill: parent
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
cache: true
|
||||
smooth: true
|
||||
sourceSize.width: Math.round(wallhavenGridView.itemSize * 0.67)
|
||||
sourceSize.height: Math.round(wallhavenGridView.itemSize * 0.67)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
background: Rectangle {
|
||||
implicitWidth: parent.handleWidth
|
||||
implicitHeight: 100
|
||||
color: Color.transparent
|
||||
border.color: wallhavenGridView.currentIndex === index ? Color.mHover : Color.mSurface
|
||||
border.width: Math.max(1, Style.borderL * 1.5)
|
||||
}
|
||||
opacity: parent.policy === ScrollBar.AlwaysOn || parent.active ? 0.3 : 0.0
|
||||
radius: parent.handleRadius / 2
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Color.mSurface
|
||||
opacity: hoverHandler.hovered || wallhavenGridView.currentIndex === index ? 0 : 0.3
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: hoverHandler
|
||||
}
|
||||
delegate: ColumnLayout {
|
||||
id: wallhavenItem
|
||||
|
||||
TapHandler {
|
||||
onTapped: {
|
||||
wallhavenGridView.currentIndex = index
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.downloadWallpaper(modelData, function (success, localPath) {
|
||||
if (success) {
|
||||
if (Settings.data.wallpaper.setWallpaperOnAllMonitors) {
|
||||
WallpaperService.changeWallpaper(localPath, undefined)
|
||||
} else {
|
||||
WallpaperService.changeWallpaper(localPath, screen.name)
|
||||
required property var modelData
|
||||
required property int index
|
||||
property string thumbnailUrl: (modelData && typeof WallhavenService !== "undefined") ? WallhavenService.getThumbnailUrl(modelData, "large") : ""
|
||||
property string wallpaperId: (modelData && modelData.id) ? modelData.id : ""
|
||||
|
||||
width: wallhavenGridView.itemSize
|
||||
spacing: Style.marginXS
|
||||
|
||||
Rectangle {
|
||||
id: imageContainer
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: Math.round(wallhavenGridView.itemSize * 0.67)
|
||||
color: Color.transparent
|
||||
|
||||
Image {
|
||||
id: img
|
||||
source: thumbnailUrl
|
||||
anchors.fill: parent
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
cache: true
|
||||
smooth: true
|
||||
sourceSize.width: Math.round(wallhavenGridView.itemSize * 0.67)
|
||||
sourceSize.height: Math.round(wallhavenGridView.itemSize * 0.67)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Color.transparent
|
||||
border.color: wallhavenGridView.currentIndex === index ? Color.mHover : Color.mSurface
|
||||
border.width: Math.max(1, Style.borderL * 1.5)
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Color.mSurface
|
||||
opacity: hoverHandler.hovered || wallhavenGridView.currentIndex === index ? 0 : 0.3
|
||||
Behavior on opacity {
|
||||
NumberAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HoverHandler {
|
||||
id: hoverHandler
|
||||
}
|
||||
|
||||
TapHandler {
|
||||
onTapped: {
|
||||
wallhavenGridView.currentIndex = index
|
||||
if (typeof WallhavenService !== "undefined") {
|
||||
WallhavenService.downloadWallpaper(modelData, function (success, localPath) {
|
||||
if (success) {
|
||||
if (Settings.data.wallpaper.setWallpaperOnAllMonitors) {
|
||||
WallpaperService.changeWallpaper(localPath, undefined)
|
||||
} else {
|
||||
WallpaperService.changeWallpaper(localPath, screen.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NText {
|
||||
text: wallpaperId || I18n.tr("wallpaper.unknown")
|
||||
color: hoverHandler.hovered || wallhavenGridView.currentIndex === index ? Color.mOnSurface : Color.mOnSurfaceVariant
|
||||
pointSize: Style.fontSizeXS
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: Style.marginS
|
||||
Layout.rightMargin: Style.marginS
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
NText {
|
||||
text: wallpaperId || I18n.tr("wallpaper.unknown")
|
||||
color: hoverHandler.hovered || wallhavenGridView.currentIndex === index ? Color.mOnSurface : Color.mOnSurfaceVariant
|
||||
pointSize: Style.fontSizeXS
|
||||
Layout.fillWidth: true
|
||||
Layout.leftMargin: Style.marginS
|
||||
Layout.rightMargin: Style.marginS
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loading overlay - fills same space as GridView to prevent jumping
|
||||
Rectangle {
|
||||
|
||||
@@ -106,7 +106,7 @@ Singleton {
|
||||
currentResults = response.data
|
||||
currentMeta = response.meta || {}
|
||||
lastPage = currentMeta.last_page || 1
|
||||
|
||||
|
||||
// Store seed for random sorting
|
||||
if (currentMeta.seed) {
|
||||
seed = currentMeta.seed
|
||||
@@ -183,45 +183,48 @@ Singleton {
|
||||
var url = getWallpaperUrl(wallpaper)
|
||||
if (!url) {
|
||||
Logger.e("Wallhaven", "No URL available for wallpaper", wallpaper.id)
|
||||
if (callback) callback(false, "")
|
||||
if (callback)
|
||||
callback(false, "")
|
||||
return
|
||||
}
|
||||
|
||||
var wallpaperId = wallpaper.id
|
||||
|
||||
|
||||
// Get the user's wallpaper directory
|
||||
var wallpaperDir = Settings.preprocessPath(Settings.data.wallpaper.directory)
|
||||
if (!wallpaperDir || wallpaperDir === "") {
|
||||
wallpaperDir = Settings.defaultWallpapersDirectory
|
||||
}
|
||||
|
||||
|
||||
// Ensure directory ends with /
|
||||
if (!wallpaperDir.endsWith("/")) {
|
||||
wallpaperDir += "/"
|
||||
}
|
||||
|
||||
|
||||
var localPath = wallpaperDir + "wallhaven_" + wallpaperId + ".jpg"
|
||||
|
||||
Logger.d("Wallhaven", "Downloading wallpaper", wallpaperId, "to", localPath)
|
||||
|
||||
// Use curl or wget to download the file, ensuring directory exists first
|
||||
var downloadProcess = Qt.createQmlObject(`
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
id: downloadProcess
|
||||
command: ["sh", "-c", "mkdir -p '` + wallpaperDir + `' && (curl -L -s -o '` + localPath + `' '` + url + `' || wget -q -O '` + localPath + `' '` + url + `')"]
|
||||
}
|
||||
`, root, "DownloadProcess_" + wallpaperId)
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
Process {
|
||||
id: downloadProcess
|
||||
command: ["sh", "-c", "mkdir -p '` + wallpaperDir + `' && (curl -L -s -o '` + localPath + `' '` + url + `' || wget -q -O '` + localPath + `' '` + url + `')"]
|
||||
}
|
||||
`, root, "DownloadProcess_" + wallpaperId)
|
||||
|
||||
downloadProcess.exited.connect(function (exitCode) {
|
||||
if (exitCode === 0) {
|
||||
Logger.i("Wallhaven", "Wallpaper downloaded:", localPath)
|
||||
wallpaperDownloaded(wallpaperId, localPath)
|
||||
if (callback) callback(true, localPath)
|
||||
if (callback)
|
||||
callback(true, localPath)
|
||||
} else {
|
||||
Logger.e("Wallhaven", "Failed to download wallpaper, exit code:", exitCode)
|
||||
if (callback) callback(false, "")
|
||||
if (callback)
|
||||
callback(false, "")
|
||||
}
|
||||
downloadProcess.destroy()
|
||||
})
|
||||
@@ -254,4 +257,3 @@ Singleton {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user