Skip to content

Commit

Permalink
Port to Plasma 6
Browse files Browse the repository at this point in the history
There are a few features missing, but this works well enough that I've
been using it for months.
  • Loading branch information
Elizabeth Loss-Cutler-Hull committed Oct 31, 2024
1 parent 05f9539 commit 133c13d
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 209 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ upload-locale-fr: ## Upload fr locale to Transifex
plasmoid: ## Make the .plasmoid file
rm -f com.aehallh.webslice.plasmoid
cd ./com.aehallh.webslice/; \
zip -9 -r com.aehallh.webslice.plasmoid.zip contents/ metadata.desktop
zip -9 -r com.aehallh.webslice.plasmoid.zip contents/ metadata.json
mv ./com.aehallh.webslice/com.aehallh.webslice.plasmoid.zip ./com.aehallh.webslice.plasmoid

update: ## Update the installed package
Expand Down
4 changes: 2 additions & 2 deletions com.aehallh.webslice/contents/code/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ function navTypeString(navType) {
}
}

function debug(entry) {
function debug(...entry) {
if (cfg_debug) {
console.log(entry)
console.log(...entry)
}
}
5 changes: 3 additions & 2 deletions com.aehallh.webslice/contents/ui/ConfigAdvanced.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.10
import org.kde.kquickcontrols 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kcmutils as KCMUtils
import org.kde.kirigami as Kirigami

Item {

KCMUtils.SimpleKCM {
property alias cfg_enableScrollTo: enableScrollTo.checked
property alias cfg_scrollToX: scrollToX.text
property alias cfg_scrollToY: scrollToY.text
Expand Down
4 changes: 3 additions & 1 deletion com.aehallh.webslice/contents/ui/ConfigExperimental.qml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.10
import org.kde.kquickcontrols 2.0
import org.kde.kcmutils as KCMUtils
import org.kde.kirigami as Kirigami

Item {
KCMUtils.SimpleKCM {

property alias cfg_keysSeqBack: keysSeqBack.keySequence
property alias cfg_keysSeqForward: keysSeqForward.keySequence
Expand Down
15 changes: 8 additions & 7 deletions com.aehallh.webslice/contents/ui/ConfigGeneral.qml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.10
import org.kde.kquickcontrols 2.0

Item {

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.kde.kquickcontrols
import org.kde.kcmutils as KCMUtils
import org.kde.kirigami as Kirigami

KCMUtils.SimpleKCM {
property alias cfg_websliceUrl: websliceUrl.text
property alias cfg_zoomFactor: zoomFactor.value
property alias cfg_enableReload: enableReload.checked
Expand Down
128 changes: 87 additions & 41 deletions com.aehallh.webslice/contents/ui/ConfigMultipleURLs.qml
Original file line number Diff line number Diff line change
@@ -1,85 +1,130 @@
import QtQuick 2.12
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.10
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.kde.plasma.components as PlasmaComponents
import "../code/utils.js" as ConfigUtils
import org.kde.kcmutils as KCMUtils
import org.kde.kirigami as Kirigami

Item {
KCMUtils.SimpleKCM {
id: rootItem

property string cfg_urlsModel


/*
property int textfieldWidth:parent.width-(buttonAdd.width+5)*4
property double tableWidth: parent.width
*/


/*
ListModel {
id: urlsModel
}
*/


Grid{
columns:1
spacing:6

ColumnLayout {
Label {
text: i18n('List of URL accessible throught the context menu to switch to others websites.')
text: i18n('List of URLs accessible throught the context menu to switch to others websites.')
}

TableView {
ListView {
id: table
model: urlsModel
width: tableWidth
TableViewColumn {
role: 'url'
title: i18n('URL')
}
height:300
width: parent.parent.width; height: 200;
model: ListModel {
id: urlsModel
}
orientation: ListView.Vertical
verticalLayoutDirection: ListView.TopToBottom
highlightFollowsCurrentItem: true
// width: tableWidth
delegate: Component {
id: urlComponent
PlasmaComponents.ItemDelegate {
id: urlText
required property string url
text: "URL: " + url
highlighted: ListView.isCurrentItem
onClicked: {
console.log("index:", index);
}
// color: ListView.isCurrentItem ? Kirigami.Theme.activeTextColor : Kirigami.Theme.textColor

/*
MouseArea {
anchors.fill: parent
onClicked: {
urlText.forceActiveFocus()
console.log("urlText.index: ", urlText.index)
console.log("parent.index: ", parent.index)
console.log("index: ", index)
table.currentIndex = parent.index
}
}
*/
}
}
//height:300
focus: true
}


RowLayout {
TextField {
id: addedUrl
placeholderText: i18n('URL')
Layout.preferredWidth: textfieldWidth
}
TextField {
id: addedUrl
placeholderText: i18n('URL to add')
Keys.onReturnPressed: {
urlsModel.append({"url": addedUrl.text});
cfg_urlsModel = ConfigUtils.stringifyModel(urlsModel)
}
// Layout.preferredWidth: textfieldWidth
}

RowLayout {
id: buttons
Button {
id:buttonAdd
iconName: 'list-add'
tooltip: i18n('Add a URL')
icon.name: 'list-add'
text: i18n('Add a URL')
onClicked: {
urlsModel.append({"url":addedUrl.text});
urlsModel.append({"url": addedUrl.text});
cfg_urlsModel = ConfigUtils.stringifyModel(urlsModel)
}
}

Button {
iconName: 'list-remove'
tooltip: i18n('Remove the selected URL')
icon.name: 'list-remove'
text: i18n('Remove the selected URL')
onClicked: {
urlsModel.remove(table.currentRow);
urlsModel.remove(table.currentIndex);
cfg_urlsModel = ConfigUtils.stringifyModel(urlsModel)
}
}
Button {
iconName: 'go-up'
tooltip: i18n('Move the selected URL up')
icon.name: 'go-up'
text: i18n('Move the selected URL up')
onClicked: {
urlsModel.move(table.currentRow,table.currentRow-1, 1);
table.selection.clear();
table.selection.select(table.currentRow-1,table.currentRow-1)
cfg_urlsModel = ConfigUtils.stringifyModel(urlsModel)
var current = table.currentIndex

if (current > 0) {
urlsModel.move(table.currentIndex, table.currentIndex - 1, 1);
table.currentIndex = Math.max(current - 1, 0)
cfg_urlsModel = ConfigUtils.stringifyModel(urlsModel)
}
}
}
Button {
iconName: 'go-down'
tooltip: i18n('Move the selected URL down')
icon.name: 'go-down'
text: i18n('Move the selected URL down')
onClicked: {
urlsModel.move(table.currentRow, table.currentRow+1, 1);
table.selection.clear();
table.selection.select(table.currentRow+1,table.currentRow+1)
cfg_urlsModel = ConfigUtils.stringifyModel(urlsModel)
var current = table.currentIndex

if (current < (table.count - 1)) {
urlsModel.move(table.currentIndex, table.currentIndex + 1, 1);
table.currentIndex = Math.min(current + 1, table.count)
cfg_urlsModel = ConfigUtils.stringifyModel(urlsModel)
}
}
}
}
Expand All @@ -88,6 +133,7 @@ Item {
Component.onCompleted: {
var arrayURLs = ConfigUtils.getURLsObjectArray();
for (var index in arrayURLs) {
console.log("URL: ", arrayURLs[index]);
urlsModel.append({"url":arrayURLs[index]});
}
}
Expand Down
Loading

0 comments on commit 133c13d

Please sign in to comment.