mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
backport QML code changes from awesome-widgets to deskop-panel
This commit is contained in:
parent
82dda14260
commit
22586811de
@ -84,7 +84,7 @@ Item {
|
|||||||
// ui
|
// ui
|
||||||
Text {
|
Text {
|
||||||
id: text
|
id: text
|
||||||
anchors.fill: Layout
|
anchors.fill: Plasmoid.Layout
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
wrapMode: plasmoid.configuration.wrapText ? Text.WordWrap : Text.NoWrap
|
wrapMode: plasmoid.configuration.wrapText ? Text.WordWrap : Text.NoWrap
|
||||||
|
@ -71,7 +71,9 @@ Item {
|
|||||||
title: i18n("Select a color")
|
title: i18n("Select a color")
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
var text = textPattern.text
|
var text = textPattern.text
|
||||||
textPattern.text = "<body bgcolor=\"" + backgroundDialog.color + "\">" + text + "</body>"
|
textPattern.text = "<body bgcolor=\"" +
|
||||||
|
backgroundDialog.color + "\">" +
|
||||||
|
text + "</body>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,10 +294,9 @@ Item {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
if (!tags.currentText) return
|
if (!tags.currentText) return
|
||||||
if (debug) console.debug("Add tag button")
|
if (debug) console.debug("Add tag button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, selected + "$" + tags.currentText)
|
textPattern.insert(textPattern.cursorPosition, selected + "$" + tags.currentText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
@ -57,7 +57,7 @@ Item {
|
|||||||
|
|
||||||
// ui
|
// ui
|
||||||
GridLayout {
|
GridLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: Plasmoid.Layout
|
||||||
columns: plasmoid.configuration.verticalLayout ? 1 : dpAdds.numberOfDesktops()
|
columns: plasmoid.configuration.verticalLayout ? 1 : dpAdds.numberOfDesktops()
|
||||||
rows: plasmoid.configuration.verticalLayout ? dpAdds.numberOfDesktops() : 1
|
rows: plasmoid.configuration.verticalLayout ? dpAdds.numberOfDesktops() : 1
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import QtQuick.Controls 1.3 as QtControls
|
import QtQuick.Controls 1.3 as QtControls
|
||||||
|
import QtQuick.Dialogs 1.2 as QtDialogs
|
||||||
|
|
||||||
import org.kde.plasma.private.desktoppanel 1.0
|
import org.kde.plasma.private.desktoppanel 1.0
|
||||||
|
|
||||||
@ -54,7 +55,24 @@ Item {
|
|||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
width: parent.width
|
width: parent.width
|
||||||
QtControls.Button {
|
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 = "<body bgcolor=\"" +
|
||||||
|
backgroundDialog.color + "\">" +
|
||||||
|
text + "</body>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QtControls.Button {
|
||||||
|
width: parent.width * 3 / 15
|
||||||
text: i18n("Font")
|
text: i18n("Font")
|
||||||
iconName: "font"
|
iconName: "font"
|
||||||
|
|
||||||
@ -66,123 +84,119 @@ Item {
|
|||||||
"size": plasmoid.configuration.fontSize
|
"size": plasmoid.configuration.fontSize
|
||||||
}
|
}
|
||||||
var font = dpAdds.getFont(defaultFont)
|
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
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, "<span style=\"color:" + font.color +
|
textPattern.insert(textPattern.cursorPosition,
|
||||||
|
"<span style=\"color:" + font.color +
|
||||||
"; font-family:'" + font.family +
|
"; font-family:'" + font.family +
|
||||||
"'; font-size:" + font.size + "pt;\">" +
|
"'; font-size:" + font.size + "pt;\">" +
|
||||||
selected + "</span>")
|
selected + "</span>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width / 12
|
width: parent.width / 15
|
||||||
iconName: "format-indent-more"
|
iconName: "format-indent-more"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Indent button")
|
if (debug) console.debug("Indent button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, selected + "<br>\n")
|
textPattern.insert(textPattern.cursorPosition, selected + "<br>\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width / 12
|
width: parent.width / 15
|
||||||
iconName: "format-text-bold"
|
iconName: "format-text-bold"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Bold button")
|
if (debug) console.debug("Bold button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, "<b>" + selected + "</b>")
|
textPattern.insert(textPattern.cursorPosition, "<b>" + selected + "</b>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width / 12
|
width: parent.width / 15
|
||||||
iconName: "format-text-italic"
|
iconName: "format-text-italic"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Italic button")
|
if (debug) console.debug("Italic button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, "<i>" + selected + "</i>")
|
textPattern.insert(textPattern.cursorPosition, "<i>" + selected + "</i>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width / 12
|
width: parent.width / 15
|
||||||
iconName: "format-text-underline"
|
iconName: "format-text-underline"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Underline button")
|
if (debug) console.debug("Underline button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, "<u>" + selected + "</u>")
|
textPattern.insert(textPattern.cursorPosition, "<u>" + selected + "</u>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width / 12
|
width: parent.width / 15
|
||||||
iconName: "format-text-strikethrough"
|
iconName: "format-text-strikethrough"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Strike button")
|
if (debug) console.debug("Strike button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, "<s>" + selected + "</s>")
|
textPattern.insert(textPattern.cursorPosition, "<s>" + selected + "</s>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width / 12
|
width: parent.width / 15
|
||||||
iconName: "format-justify-left"
|
iconName: "format-justify-left"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Left button")
|
if (debug) console.debug("Left button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, "<p align=\"left\">" + selected + "</p>")
|
textPattern.insert(textPattern.cursorPosition, "<p align=\"left\">" + selected + "</p>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width / 12
|
width: parent.width / 15
|
||||||
iconName: "format-justify-center"
|
iconName: "format-justify-center"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Center button")
|
if (debug) console.debug("Center button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, "<p align=\"center\">" + selected + "</p>")
|
textPattern.insert(textPattern.cursorPosition, "<p align=\"center\">" + selected + "</p>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width / 12
|
width: parent.width / 15
|
||||||
iconName: "format-justify-right"
|
iconName: "format-justify-right"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Right button")
|
if (debug) console.debug("Right button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, "<p align=\"right\">" + selected + "</p>")
|
textPattern.insert(textPattern.cursorPosition, "<p align=\"right\">" + selected + "</p>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
width: parent.width / 12
|
width: parent.width / 15
|
||||||
iconName: "format-justify-fill"
|
iconName: "format-justify-fill"
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Justify button")
|
if (debug) console.debug("Justify button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, "<p align=\"justify\">" + selected + "</p>")
|
textPattern.insert(textPattern.cursorPosition, "<p align=\"justify\">" + selected + "</p>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,10 +215,9 @@ Item {
|
|||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (debug) console.debug("Add tag button")
|
if (debug) console.debug("Add tag button")
|
||||||
var pos = textPattern.cursorPosition
|
|
||||||
var selected = textPattern.selectedText
|
var selected = textPattern.selectedText
|
||||||
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
textPattern.remove(textPattern.selectionStart, textPattern.selectionEnd)
|
||||||
textPattern.insert(pos, selected + "$" + tags.currentText)
|
textPattern.insert(textPattern.cursorPosition, selected + "$" + tags.currentText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QtControls.Button {
|
QtControls.Button {
|
||||||
|
@ -318,11 +318,14 @@ QVariantMap DPAdds::getFont(const QVariantMap defaultFont) const
|
|||||||
qCDebug(LOG_DP) << "Default font is" << defaultFont;
|
qCDebug(LOG_DP) << "Default font is" << defaultFont;
|
||||||
|
|
||||||
QVariantMap fontMap;
|
QVariantMap fontMap;
|
||||||
|
int ret = 0;
|
||||||
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
CFont defaultCFont = CFont(defaultFont[QString("family")].toString(),
|
||||||
defaultFont[QString("size")].toInt(), 400, false,
|
defaultFont[QString("size")].toInt(), 400, false,
|
||||||
defaultFont[QString("color")].toString());
|
defaultFont[QString("color")].toString());
|
||||||
CFont font
|
CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false,
|
||||||
= CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false);
|
false, &ret);
|
||||||
|
|
||||||
|
fontMap[QString("applied")] = ret;
|
||||||
fontMap[QString("color")] = font.color().name();
|
fontMap[QString("color")] = font.color().name();
|
||||||
fontMap[QString("family")] = font.family();
|
fontMap[QString("family")] = font.family();
|
||||||
fontMap[QString("size")] = font.pointSize();
|
fontMap[QString("size")] = font.pointSize();
|
||||||
|
Loading…
Reference in New Issue
Block a user