add appearance.qml

This commit is contained in:
arcan1s 2014-12-27 03:50:31 +03:00
parent a35e9b0164
commit 6fb7da4b5b
7 changed files with 309 additions and 582 deletions

View File

@ -29,7 +29,6 @@ include_directories (${CMAKE_SOURCE_DIR}
set (PLUGIN_NAME ${SUBPROJECT})
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
message (STATUS ${SUBPROJECT_DESKTOP_IN})
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)

View File

@ -1,488 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AppearanceWindow</class>
<widget class="QWidget" name="AppearanceWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>341</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>480</width>
<height>320</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Configuration Window</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="9" column="0">
<spacer name="verticalSpacer_appearance">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="8" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_inactiveIcon">
<item>
<widget class="QLabel" name="label_inactiveIcon">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Inactive icon</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_inactiveIcon"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_inactiveIcon">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="layout_fontColor">
<item>
<widget class="QLabel" name="label_fontColor">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font color</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontColor">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_fontColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font color</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<widget class="Line" name="line_appearance">
<property name="lineWidth">
<number>5</number>
</property>
<property name="midLineWidth">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="layout_fontSize">
<item>
<widget class="QLabel" name="label_fontSize">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font size</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontSize">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font size</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>7</number>
</property>
<property name="maximum">
<number>48</number>
</property>
<property name="value">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="layout_fontWeight">
<item>
<widget class="QLabel" name="label_fontWeight">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font weight</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontWeight">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontWeight">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font weight</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>300</number>
</property>
<property name="maximum">
<number>600</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>400</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="layout_fontStyle">
<item>
<widget class="QLabel" name="label_fontStyle">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font style</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontStyle">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboBox_fontStyle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font style</string>
</property>
<item>
<property name="text">
<string notr="true">normal</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">italic</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="layout_font">
<item>
<widget class="QLabel" name="label_font">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_font">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFontComboBox" name="fontComboBox_font">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font family</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="7" column="0">
<layout class="QHBoxLayout" name="layout_activeIcon">
<item>
<widget class="QLabel" name="label_activeIcon">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Active icon</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_activeIcon"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_activeIcon">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="layout_textAlign">
<item>
<widget class="QLabel" name="label_textAlign">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Text align</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_textAlign">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboBox_textAlign">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set text align</string>
</property>
<item>
<property name="text">
<string notr="true">center</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">right</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">left</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">justify</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorCombo</class>
<extends>QComboBox</extends>
<header>kcolorcombo.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>fontComboBox_font</tabstop>
<tabstop>spinBox_fontSize</tabstop>
<tabstop>kcolorcombo_fontColor</tabstop>
<tabstop>spinBox_fontWeight</tabstop>
<tabstop>comboBox_fontStyle</tabstop>
<tabstop>lineEdit_activeIcon</tabstop>
<tabstop>pushButton_activeIcon</tabstop>
<tabstop>lineEdit_inactiveIcon</tabstop>
<tabstop>pushButton_inactiveIcon</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,35 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
import QtQuick 2.0
import org.kde.plasma.configuration 2.0
ConfigModel {
// ConfigCategory {
// name: i18n("Netctl plasmoid")
// icon: Plasmoid.icon
// source: "appearance.qml"
// }
ConfigCategory {
name: i18n("Appearance")
icon: "preferences-desktop-theme"
source: "appearance.qml"
}
}

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<!-- appearance -->
<group name="Appearance">
<entry name="textAlign" type="string">
<default>center</default>
</entry>
<entry name="fontFamily" type="string">
<default>Terminus</default>
</entry>
<entry name="fontSize" type="int">
<default>12</default>
</entry>
<entry name="fontColor" type="string">
<default>#000000</default>
</entry>
<entry name="fontWeight" type="int">
<default>400</default>
</entry>
<entry name="fontStyle" type="string">
<default>normal</default>
</entry>
<entry name="activeIconPath" type="string">
<default>/usr/share/icons/hicolor/64x64/apps/netctl-idle.png</default>
</entry>
<entry name="inactiveIconPath" type="string">
<default>/usr/share/icons/hicolor/64x64/apps/netctl-offline.png</default>
</entry>
</group>
</kcfg>

View File

@ -0,0 +1,229 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls
import QtQuick.Dialogs 1.1 as QtDialogs
import QtQuick.Layouts 1.0 as QtLayouts
Item {
id: appearancePage
width: childrenRect.width
height: childrenRect.height
property string cfg_textAlign: textAlign.currentText
property alias cfg_fontFamily: selectFont.text
property alias cfg_fontSize: fontSize.value
property alias cfg_fontWeight: fontWeight.value
property string cfg_fontStyle: fontStyle.currentText
property alias cfg_fontColor: selectColor.text
property alias cfg_activeIconPath: activeIcon.text
property alias cfg_inactiveIconPath: inactiveIcon.text
QtLayouts.ColumnLayout {
QtLayouts.RowLayout {
QtControls.Label {
text: i18n("Text align")
}
QtControls.ComboBox {
id: textAlign
textRole: "label"
model: [
{
'label': i18n("center"),
'name': "center"
},
{
'label': i18n("right"),
'name': "right"
},
{
'label': i18n("left"),
'name': "left"
},
{
'label': i18n("justify"),
'name': "justify"
}
]
onCurrentIndexChanged: cfg_textAlign = model[currentIndex]["name"]
Component.onCompleted: {
for (var i = 0; i < model.length; i++) {
if (model[i]["name"] == plasmoid.configuration.textAlign) {
textAlign.currentIndex = i;
}
}
}
}
}
QtLayouts.RowLayout {
QtControls.Label {
text: i18n("Font")
}
QtControls.Button {
id: selectFont
text: plasmoid.configuration.fontFamily
onClicked: fontDialog.visible = true
}
}
QtLayouts.RowLayout {
QtControls.Label {
text: i18n("Font size")
}
QtControls.SpinBox {
id: fontSize
minimumValue: 8
maximumValue: 24
stepSize: 1
value: plasmoid.configuration.fontSize
}
}
QtLayouts.RowLayout {
QtControls.Label {
text: i18n("Font weight")
}
QtControls.SpinBox {
id: fontWeight
minimumValue: 100
maximumValue: 900
stepSize: 100
value: plasmoid.configuration.fontWeight
}
}
QtLayouts.RowLayout {
QtControls.Label {
text: i18n("Font style")
}
QtControls.ComboBox {
id: fontStyle
textRole: "label"
model: [
{
'label': i18n("normal"),
'name': "normal"
},
{
'label': i18n("italic"),
'name': "italic"
}
]
onCurrentIndexChanged: cfg_fontStyle = model[currentIndex]["name"]
Component.onCompleted: {
for (var i = 0; i < model.length; i++) {
if (model[i]["name"] == plasmoid.configuration.fontStyle) {
fontStyle.currentIndex = i;
}
}
}
}
}
QtLayouts.RowLayout {
QtControls.Label {
text: i18n("Font color")
}
QtControls.Button {
id: selectColor
text: plasmoid.configuration.fontColor
onClicked: colorDialog.visible = true
}
}
QtLayouts.RowLayout {
QtControls.Label {
text: i18n("Active icon")
}
QtControls.TextField {
id: activeIcon
QtLayouts.Layout.fillWidth: true
text: plasmoid.configuration.activeIconPath
}
QtControls.Button {
text: i18n("Browse")
onClicked: {
// FIXME: more clean directory definition
var list = inactiveIcon.text.split('/')
list.pop()
activeFileDialog.folder = "/" + list.join('/')
activeFileDialog.visible = true
}
}
QtDialogs.FileDialog {
id: activeFileDialog
title: "Select a path"
nameFilters: [ "Image files (*.jpeg *.jpg *.png)", "All files (*)" ]
selectExisting: true
onAccepted: activeIcon.text = activeFileDialog.fileUrl
}
}
QtLayouts.RowLayout {
QtControls.Label {
text: i18n("Inactive icon")
}
QtControls.TextField {
id: inactiveIcon
QtLayouts.Layout.fillWidth: true
text: plasmoid.configuration.inactiveIconPath
}
QtControls.Button {
text: i18n("Browse")
onClicked: {
// FIXME: more clean directory definition
var list = inactiveIcon.text.split('/')
list.pop()
inactiveFileDialog.folder = "/" + list.join('/')
inactiveFileDialog.visible = true
}
}
QtDialogs.FileDialog {
id: inactiveFileDialog
title: "Select a path"
nameFilters: [ "Image files (*.jpeg *.jpg *.png)", "All files (*)" ]
selectExisting: true
onAccepted: inactiveIcon.text = inactiveFileDialog.fileUrl
}
}
}
QtDialogs.ColorDialog {
id: colorDialog
title: "Select a color"
color: selectColor.text
onAccepted: {
selectColor.text = colorDialog.color
}
}
QtDialogs.FontDialog {
id: fontDialog
title: "Select a font"
font: Qt.font({ family: selectFont.text, pointSize: fontSize.value, weight: Font.Normal })
onAccepted: {
selectFont.text = fontDialog.font.family
fontSize.value = fontDialog.font.pointSize
}
}
}

View File

@ -18,6 +18,7 @@
import QtQuick 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.plasmoid 2.0
Item {
@ -26,6 +27,7 @@ Item {
// variables
Text {
id: info
property string current: "N\\A"
property string extip4: "127.0.0.1"
property string extip6: "::1"
property string intip4: "127.0.0.1"
@ -42,6 +44,9 @@ Item {
property int interval: 1000
property bool status: false
// init
Plasmoid.icon: icon.source
PlasmaCore.DataSource {
id: mainData
engine: "netctl"
@ -59,7 +64,8 @@ Item {
icon.source = iconPath.inactive
}
} else if (sourceName == "current") {
text.text = data.value
info.current= data.value
// text update
} else if (sourceName == "extip4") {
info.extip4 = data.value
} else if (sourceName == "extip6") {
@ -84,9 +90,11 @@ Item {
Image {
id: icon
source: iconPath.inactive
}
Text {
id: text
text: "N\\A"
}
}
}

View File

@ -1,92 +0,0 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
import QtQuick 2.2
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
Item {
id: main
// variables
Text {
id: info
property string extip4: "127.0.0.1"
property string extip6: "::1"
property string intip4: "127.0.0.1"
property string intip6: "::1"
property var interfaces: ["lo"]
property var profiles: []
property string status: "N\\A"
}
Text {
id: iconPath
property string active: "/usr/share/icons/hicolor/64x64/apps/netctl-idle.png"
property string inactive: "/usr/share/icons/hicolor/64x64/apps/netctl-offline.png"
}
property int interval: 1000
property bool status: false
PlasmaCore.DataSource {
id: mainData
engine: ""
connectedSources: ["active", "current", "extip4", "extip6", "interfaces", "intip4", "intip6", "profiles", "status"]
interval: main.interval
onNewData: {
if (data.isEmpty) return
if (sourceName == "active") {
if (data.value == "true") {
main.status = true
icon.source = iconPath.active
} else {
main.status = false
icon.source = iconPath.inactive
}
} else if (sourceName == "current") {
text.text = data.value
} else if (sourceName == "extip4") {
info.extip4 = data.value
} else if (sourceName == "extip6") {
info.extip6 = data.value
} else if (sourceName == "interfaces") {
info.interfaces = data.value
} else if (sourceName == "intip4") {
info.intip4 = data.value
} else if (sourceName == "intip6") {
info.intip6 = data.value
} else if (sourceName == "profiles") {
info.profiles = data.value
} else if (sourceName == "status") {
info.status = data.value
}
}
}
Grid {
id: mainGrid
columns: 2
Image {
id: icon
}
Text {
id: text
}
}
}