add html bar

This commit is contained in:
2016-10-12 10:23:20 +03:00
parent 65141ff528
commit eea636c6f1
8 changed files with 269 additions and 148 deletions

View 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>"
}
}

View 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)
}
}

View 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()
}
}
}

View 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()
}
}

View File

@ -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