add font dialog, some color dialog improvements

This commit is contained in:
Evgenii Alekseev 2016-10-02 01:43:12 +03:00
parent a326ebdabf
commit f7094ca187
7 changed files with 69 additions and 64 deletions

View File

@ -25,6 +25,7 @@ Row {
property alias text: label.text
property alias value: button.text
property alias style: button.style
signal buttonActivated
@ -32,6 +33,8 @@ Row {
id: label
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
}
QtControls.Button {
id: button

View File

@ -16,7 +16,6 @@
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
import QtQuick.Controls.Styles 1.3 as QtStyles
import QtQuick.Dialogs 1.1 as QtDialogs
@ -25,25 +24,17 @@ Row {
height: implicitHeight
width: parent.width
property alias text: label.text
property alias value: colorButton.text
property alias text: selector.text
property alias value: selector.value
QtControls.Label {
id: label
height: parent.height
width: parent.width * 2 / 5
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
}
QtControls.Button {
id: colorButton
width: parent.width * 3 / 5
ButtonSelector {
id: selector
style: QtStyles.ButtonStyle {
background: Rectangle {
color: value
}
}
onClicked: colorDialog.visible = true
onButtonActivated: colorDialog.visible = true
}
QtDialogs.ColorDialog {

View File

@ -0,0 +1,54 @@
/***************************************************************************
* 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.0
import QtQuick.Dialogs 1.1 as QtDialogs
Row {
height: implicitHeight
width: parent.width
property alias text: selector.text
property alias value: selector.value
ButtonSelector {
id: selector
text: label.text
onButtonActivated: {
fontDialog.setFont()
fontDialog.visible = true
}
}
QtDialogs.FontDialog {
id: fontDialog
title: i18n("Select a font")
signal setFont
onAccepted: value = fontDialog.font.family
onSetFont: {
fontDialog.font = Qt.font({
family: value,
pointSize: 12,
italic: false,
weight: Font.Normal,
})
}
}
}

View File

@ -16,8 +16,6 @@
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
import QtQuick.Dialogs 1.2 as QtDialogs
import org.kde.plasma.private.awesomewidget 1.0

View File

@ -16,8 +16,6 @@
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
import QtQuick.Dialogs 1.1 as QtDialogs
import org.kde.plasma.private.awesomewidget 1.0
@ -43,7 +41,7 @@ Item {
87: 5
}
property alias cfg_fontFamily: selectFont.text
property alias cfg_fontFamily: font.value
property alias cfg_fontSize: fontSize.value
property string cfg_fontWeight: fontWeight.value
property string cfg_fontStyle: fontStyle.value
@ -55,26 +53,11 @@ Item {
Column {
id: pageColumn
anchors.fill: parent
Row {
height: implicitHeight
width: parent.width
QtControls.Label {
height: parent.height
width: parent.width / 3
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
text: i18n("Font")
}
QtControls.Button {
id: selectFont
width: parent.width * 2 / 3
text: plasmoid.configuration.fontFamily
onClicked: {
if (debug) console.debug()
fontDialog.setFont()
fontDialog.visible = true
}
}
FontSelector {
id: font
text: i18n("Font")
value: plasmoid.configuration.fontFamily
}
IntegerSelector {
@ -170,29 +153,6 @@ Item {
}
}
QtDialogs.FontDialog {
id: fontDialog
title: i18n("Select a font")
signal setFont
onAccepted: {
if (debug) console.debug()
selectFont.text = fontDialog.font.family
fontSize.value = fontDialog.font.pointSize
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
fontWeight.currentIndex = weight[fontDialog.font.weight]
}
onSetFont: {
if (debug) console.debug()
fontDialog.font = Qt.font({
family: selectFont.text,
pointSize: fontSize.value > 0 ? fontSize.value : 12,
italic: fontStyle.currentIndex == 1,
weight: Font.Normal,
})
}
}
Component.onCompleted: {
if (debug) console.debug()

View File

@ -5,6 +5,7 @@ CheckBoxSelector ./CheckBoxSelector.qml
ColorSelector ./ColorSelector.qml
ComboBoxSelector ./ComboBoxSelector.qml
ExportDialog ./ExportDialog.qml
FontSelector ./FontSelector.qml
ImportDialog ./ImportDialog.qml
IntegerSelector ./IntegerSelector.qml
LineSelector ./LineSelector.qml

View File

@ -17,8 +17,6 @@
import QtQuick 2.0
import QtQuick.Controls 1.3 as QtControls
import QtQuick.Controls.Styles 1.3 as QtStyles
import QtQuick.Dialogs 1.1 as QtDialogs
import org.kde.plasma.private.awesomewidget 1.0