From 22586811de670bf1500796d498fc682574d021c9 Mon Sep 17 00:00:00 2001
From: arcan1s
Date: Fri, 22 Apr 2016 15:39:36 +0300
Subject: [PATCH] backport QML code changes from awesome-widgets to
deskop-panel
---
.../package/contents/ui/main.qml | 2 +-
.../package/contents/ui/widget.qml | 7 +-
.../package/contents/ui/main.qml | 2 +-
.../package/contents/ui/widget.qml | 83 +++++++++++--------
sources/desktop-panel/plugin/dpadds.cpp | 7 +-
5 files changed, 59 insertions(+), 42 deletions(-)
diff --git a/sources/awesome-widget/package/contents/ui/main.qml b/sources/awesome-widget/package/contents/ui/main.qml
index 5e1f77c..79c6ddf 100644
--- a/sources/awesome-widget/package/contents/ui/main.qml
+++ b/sources/awesome-widget/package/contents/ui/main.qml
@@ -84,7 +84,7 @@ Item {
// ui
Text {
id: text
- anchors.fill: Layout
+ anchors.fill: Plasmoid.Layout
renderType: Text.NativeRendering
textFormat: Text.RichText
wrapMode: plasmoid.configuration.wrapText ? Text.WordWrap : Text.NoWrap
diff --git a/sources/awesome-widget/package/contents/ui/widget.qml b/sources/awesome-widget/package/contents/ui/widget.qml
index cadc9e7..8b1d35b 100644
--- a/sources/awesome-widget/package/contents/ui/widget.qml
+++ b/sources/awesome-widget/package/contents/ui/widget.qml
@@ -71,7 +71,9 @@ Item {
title: i18n("Select a color")
onAccepted: {
var text = textPattern.text
- textPattern.text = "" + text + ""
+ textPattern.text = "" +
+ text + ""
}
}
}
@@ -292,10 +294,9 @@ Item {
onClicked: {
if (!tags.currentText) return
if (debug) console.debug("Add tag button")
- var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
- textPattern.insert(pos, selected + "$" + tags.currentText)
+ textPattern.insert(textPattern.cursorPosition, selected + "$" + tags.currentText)
}
}
QtControls.Button {
diff --git a/sources/desktop-panel/package/contents/ui/main.qml b/sources/desktop-panel/package/contents/ui/main.qml
index 20f8732..5a1e9b6 100644
--- a/sources/desktop-panel/package/contents/ui/main.qml
+++ b/sources/desktop-panel/package/contents/ui/main.qml
@@ -57,7 +57,7 @@ Item {
// ui
GridLayout {
- anchors.fill: parent
+ anchors.fill: Plasmoid.Layout
columns: plasmoid.configuration.verticalLayout ? 1 : dpAdds.numberOfDesktops()
rows: plasmoid.configuration.verticalLayout ? dpAdds.numberOfDesktops() : 1
diff --git a/sources/desktop-panel/package/contents/ui/widget.qml b/sources/desktop-panel/package/contents/ui/widget.qml
index cafccbf..77cd05c 100644
--- a/sources/desktop-panel/package/contents/ui/widget.qml
+++ b/sources/desktop-panel/package/contents/ui/widget.qml
@@ -17,6 +17,7 @@
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
+import QtQuick.Dialogs 1.2 as QtDialogs
import org.kde.plasma.private.desktoppanel 1.0
@@ -54,7 +55,24 @@ Item {
height: implicitHeight
width: parent.width
QtControls.Button {
- width: parent.width * 3 / 12
+ width: parent.width * 3 / 15
+ text: i18n("Bgcolor")
+
+ onClicked: backgroundDialog.visible = true
+
+ QtDialogs.ColorDialog {
+ id: backgroundDialog
+ title: i18n("Select a color")
+ onAccepted: {
+ var text = textPattern.text
+ textPattern.text = "" +
+ text + ""
+ }
+ }
+ }
+ QtControls.Button {
+ width: parent.width * 3 / 15
text: i18n("Font")
iconName: "font"
@@ -66,123 +84,119 @@ Item {
"size": plasmoid.configuration.fontSize
}
var font = dpAdds.getFont(defaultFont)
- var pos = textPattern.cursorPosition
+ if (font.applied != 1) {
+ if (debug) console.debug("No font selected")
+ return
+ }
+
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
- textPattern.insert(pos, "" +
- selected + "")
+ textPattern.insert(textPattern.cursorPosition,
+ "" +
+ selected + "")
}
}
QtControls.Button {
- width: parent.width / 12
+ width: parent.width / 15
iconName: "format-indent-more"
onClicked: {
if (debug) console.debug("Indent button")
- var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
- textPattern.insert(pos, selected + "
\n")
+ textPattern.insert(textPattern.cursorPosition, selected + "
\n")
}
}
QtControls.Button {
- width: parent.width / 12
+ width: parent.width / 15
iconName: "format-text-bold"
onClicked: {
if (debug) console.debug("Bold button")
- var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
- textPattern.insert(pos, "" + selected + "")
+ textPattern.insert(textPattern.cursorPosition, "" + selected + "")
}
}
QtControls.Button {
- width: parent.width / 12
+ width: parent.width / 15
iconName: "format-text-italic"
onClicked: {
if (debug) console.debug("Italic button")
- var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
- textPattern.insert(pos, "" + selected + "")
+ textPattern.insert(textPattern.cursorPosition, "" + selected + "")
}
}
QtControls.Button {
- width: parent.width / 12
+ width: parent.width / 15
iconName: "format-text-underline"
onClicked: {
if (debug) console.debug("Underline button")
- var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
- textPattern.insert(pos, "" + selected + "")
+ textPattern.insert(textPattern.cursorPosition, "" + selected + "")
}
}
QtControls.Button {
- width: parent.width / 12
+ width: parent.width / 15
iconName: "format-text-strikethrough"
onClicked: {
if (debug) console.debug("Strike button")
- var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
- textPattern.insert(pos, "" + selected + "")
+ textPattern.insert(textPattern.cursorPosition, "" + selected + "")
}
}
QtControls.Button {
- width: parent.width / 12
+ width: parent.width / 15
iconName: "format-justify-left"
onClicked: {
if (debug) console.debug("Left button")
- var pos = textPattern.cursorPosition
var selected = textPattern.selectedText
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
- textPattern.insert(pos, "
" + selected + "
") + textPattern.insert(textPattern.cursorPosition, "" + selected + "
") } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-justify-center" onClicked: { if (debug) console.debug("Center button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "" + selected + "
") + textPattern.insert(textPattern.cursorPosition, "" + selected + "
") } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-justify-right" onClicked: { if (debug) console.debug("Right button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "" + selected + "
") + textPattern.insert(textPattern.cursorPosition, "" + selected + "
") } } QtControls.Button { - width: parent.width / 12 + width: parent.width / 15 iconName: "format-justify-fill" onClicked: { if (debug) console.debug("Justify button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, "" + selected + "
") + textPattern.insert(textPattern.cursorPosition, "" + selected + "
") } } } @@ -201,10 +215,9 @@ Item { onClicked: { if (debug) console.debug("Add tag button") - var pos = textPattern.cursorPosition var selected = textPattern.selectedText textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd) - textPattern.insert(pos, selected + "$" + tags.currentText) + textPattern.insert(textPattern.cursorPosition, selected + "$" + tags.currentText) } } QtControls.Button { diff --git a/sources/desktop-panel/plugin/dpadds.cpp b/sources/desktop-panel/plugin/dpadds.cpp index 2c48887..f1e345c 100644 --- a/sources/desktop-panel/plugin/dpadds.cpp +++ b/sources/desktop-panel/plugin/dpadds.cpp @@ -318,11 +318,14 @@ QVariantMap DPAdds::getFont(const QVariantMap defaultFont) const qCDebug(LOG_DP) << "Default font is" << defaultFont; QVariantMap fontMap; + int ret = 0; CFont defaultCFont = CFont(defaultFont[QString("family")].toString(), defaultFont[QString("size")].toInt(), 400, false, defaultFont[QString("color")].toString()); - CFont font - = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false); + CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, + false, &ret); + + fontMap[QString("applied")] = ret; fontMap[QString("color")] = font.color().name(); fontMap[QString("family")] = font.family(); fontMap[QString("size")] = font.pointSize();