mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-13 13:55:50 +00:00
add html bar
This commit is contained in:
107
sources/qml/HtmlDefaultFunctionsBar.qml
Normal file
107
sources/qml/HtmlDefaultFunctionsBar.qml
Normal file
@ -0,0 +1,107 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
|
||||
|
||||
Row {
|
||||
height: implicitHeight
|
||||
width: parent.width
|
||||
|
||||
property var textArea
|
||||
|
||||
// selectors
|
||||
HtmlEditorColor {
|
||||
width: parent.width * 3 / 15
|
||||
text: i18n("Bgcolor")
|
||||
textField: textArea
|
||||
}
|
||||
HtmlEditorFont {
|
||||
width: parent.width * 3 / 15
|
||||
textField: textArea
|
||||
defaultFontColor: plasmoid.configuration.fontColor
|
||||
defaultFontFamily: plasmoid.configuration.fontFamily
|
||||
defaultFontSize: plasmoid.configuration.fontSize
|
||||
}
|
||||
|
||||
// new line
|
||||
HtmlEditorButton {
|
||||
width: parent.width / 15
|
||||
iconName: "format-indent-more"
|
||||
textField: textArea
|
||||
end: "<br>\n"
|
||||
}
|
||||
// font properties
|
||||
HtmlEditorButton {
|
||||
width: parent.width / 15
|
||||
iconName: "format-text-bold"
|
||||
textField: textArea
|
||||
start: "<b>"
|
||||
end: "</b>"
|
||||
}
|
||||
HtmlEditorButton {
|
||||
width: parent.width / 15
|
||||
iconName: "format-text-italic"
|
||||
textField: textArea
|
||||
start: "<i>"
|
||||
end: "</i>"
|
||||
}
|
||||
HtmlEditorButton {
|
||||
width: parent.width / 15
|
||||
iconName: "format-text-underline"
|
||||
textField: textArea
|
||||
start: "<u>"
|
||||
end: "</u>"
|
||||
}
|
||||
HtmlEditorButton {
|
||||
width: parent.width / 15
|
||||
iconName: "format-text-strikethrough"
|
||||
textField: textArea
|
||||
start: "<s>"
|
||||
end: "</s>"
|
||||
}
|
||||
|
||||
// indentation
|
||||
HtmlEditorButton {
|
||||
width: parent.width / 15
|
||||
iconName: "format-justify-left"
|
||||
textField: textArea
|
||||
start: "<p align=\"left\">"
|
||||
end: "</p>"
|
||||
}
|
||||
HtmlEditorButton {
|
||||
width: parent.width / 15
|
||||
iconName: "format-justify-center"
|
||||
textField: textArea
|
||||
start: "<p align=\"center\">"
|
||||
end: "</p>"
|
||||
}
|
||||
HtmlEditorButton {
|
||||
width: parent.width / 15
|
||||
iconName: "format-justify-right"
|
||||
textField: textArea
|
||||
start: "<p align=\"right\">"
|
||||
end: "</p>"
|
||||
}
|
||||
HtmlEditorButton {
|
||||
width: parent.width / 15
|
||||
iconName: "format-justify-fill"
|
||||
textField: textArea
|
||||
start: "<p align=\"justify\">"
|
||||
end: "</p>"
|
||||
}
|
||||
}
|
40
sources/qml/HtmlEditorButton.qml
Normal file
40
sources/qml/HtmlEditorButton.qml
Normal file
@ -0,0 +1,40 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
|
||||
|
||||
QtControls.Button {
|
||||
// parent object in which text will be replaced
|
||||
property var textField
|
||||
// start and end tags
|
||||
property string start: ""
|
||||
property string end: ""
|
||||
|
||||
property var clickedEvent: function() { return updateText() }
|
||||
onClicked: clickedEvent()
|
||||
|
||||
function updateText() {
|
||||
// get selected text
|
||||
var selected = textField.selectedText
|
||||
// remove it from widget
|
||||
textField.remove(textField.selectionStart, textField.selectionEnd)
|
||||
// insert edited text
|
||||
textField.insert(textField.cursorPosition, start + selected + end)
|
||||
}
|
||||
}
|
38
sources/qml/HtmlEditorColor.qml
Normal file
38
sources/qml/HtmlEditorColor.qml
Normal file
@ -0,0 +1,38 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||
|
||||
|
||||
HtmlEditorButton {
|
||||
end: "</body>"
|
||||
|
||||
clickedEvent: function() { return colorDialog.open() }
|
||||
|
||||
QtDialogs.ColorDialog {
|
||||
id: colorDialog
|
||||
title: i18n("Select a color")
|
||||
|
||||
onAccepted: {
|
||||
start = "<body bgcolor=\"" +
|
||||
colorDialog.color + "\">"
|
||||
textField.selectAll()
|
||||
updateText()
|
||||
}
|
||||
}
|
||||
}
|
57
sources/qml/HtmlEditorFont.qml
Normal file
57
sources/qml/HtmlEditorFont.qml
Normal file
@ -0,0 +1,57 @@
|
||||
/***************************************************************************
|
||||
* This file is part of awesome-widgets *
|
||||
* *
|
||||
* awesome-widgets is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* awesome-widgets is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with awesome-widgets. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
import QtQuick 2.2
|
||||
|
||||
import org.kde.plasma.private.awesomewidget 1.0
|
||||
|
||||
|
||||
HtmlEditorButton {
|
||||
end: "</span>"
|
||||
iconName: "font"
|
||||
text: i18n("Font")
|
||||
|
||||
// backend
|
||||
AWActions {
|
||||
id: awActions
|
||||
}
|
||||
// default font properties
|
||||
property string defaultFontColor
|
||||
property string defaultFontFamily
|
||||
property int defaultFontSize
|
||||
|
||||
clickedEvent: function() {
|
||||
// get new font
|
||||
var defaultFont = {
|
||||
"color": defaultFontColor,
|
||||
"family": defaultFontFamily,
|
||||
"size": defaultFontSize
|
||||
}
|
||||
// we are using custom selector as soon as we need to select color as well
|
||||
var font = awActions.getFont(defaultFont)
|
||||
|
||||
// check status
|
||||
if (!font.applied)
|
||||
return
|
||||
|
||||
// apply font
|
||||
start = "<span style=\"color:" + font.color +
|
||||
"; font-family:'" + font.family +
|
||||
"'; font-size:" + font.size + "pt;\">"
|
||||
updateText()
|
||||
}
|
||||
}
|
@ -14,6 +14,10 @@ ColorSelector file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qm
|
||||
ComboBoxSelector file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/ComboBoxSelector.qml
|
||||
ExportDialog file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/ExportDialog.qml
|
||||
FontSelector file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/FontSelector.qml
|
||||
HtmlDefaultFunctionsBar file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/HtmlDefaultFunctionsBar.qml
|
||||
HtmlEditorButton file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/HtmlEditorButton.qml
|
||||
HtmlEditorColor file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/HtmlEditorColor.qml
|
||||
HtmlEditorFont file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/HtmlEditorFont.qml
|
||||
ImportDialog file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/ImportDialog.qml
|
||||
IntegerSelector file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/IntegerSelector.qml
|
||||
LineSelector file://@CMAKE_INSTALL_PREFIX@/@DATA_INSTALL_DIR@/@PROJECT_NAME@/qml/LineSelector.qml
|
||||
|
Reference in New Issue
Block a user