Support for Plastik's configuration options

Adding a KConfigXT xml file and an ui file to configure the QML
variant of Plastik.

Currently supported options:
* title alignment
* title shadow
* animation of buttons

Missing option:
* colored borders
This commit is contained in:
Martin Gräßlin 2012-08-25 11:09:57 +02:00
parent 25ac108a76
commit d81df32a4f
4 changed files with 150 additions and 5 deletions

View file

@ -0,0 +1,28 @@
<?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=""/>
<group name="">
<entry name="titleAlignLeft" type="Bool">
<default>true</default>
</entry>
<entry name="titleAlignCenter" type="Bool">
<default>false</default>
</entry>
<entry name="titleAlignRight" type="Bool">
<default>false</default>
</entry>
<entry name="coloredBorder" type="Bool">
<default>true</default>
</entry>
<entry name="titleShadow" type="Bool">
<default>true</default>
</entry>
<entry name="animateButtons" type="Bool">
<default>true</default>
</entry>
</group>
</kcfg>

View file

@ -62,16 +62,16 @@ DecorationButton {
property color baseSurfaceTop: colorHelper.shade(options.titleBarColor, ColorHelper.MidlightShade, colorHelper.contrast - 0.4)
property color baseSurfaceBottom: colorHelper.shade(options.titleBarColor, ColorHelper.LightShade, colorHelper.contrast - 0.4)
Behavior on conturTop {
ColorAnimation { duration: root.animationDuration }
ColorAnimation { duration: root.animateButtons ? root.animationDuration : 0 }
}
Behavior on conturBottom {
ColorAnimation { duration: root.animationDuration }
ColorAnimation { duration: root.animateButtons ? root.animationDuration : 0 }
}
Behavior on surfaceTop {
ColorAnimation { duration: root.animationDuration }
ColorAnimation { duration: root.animateButtons ? root.animationDuration : 0 }
}
Behavior on surfaceBottom {
ColorAnimation { duration: root.animationDuration }
ColorAnimation { duration: root.animateButtons ? root.animationDuration : 0 }
}
width: size
height: size

View file

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlastikConfigDialog</class>
<widget class="QWidget" name="PlastikConfigDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>541</width>
<height>176</height>
</rect>
</property>
<property name="windowTitle">
<string>Config Dialog</string>
</property>
<layout class="QVBoxLayout">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="KButtonGroup" name="titleAlign">
<property name="title">
<string>Title &amp;Alignment</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="kcfg_titleAlignLeft">
<property name="text">
<string>Left</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="kcfg_titleAlignCenter">
<property name="text">
<string>Center</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="kcfg_titleAlignRight">
<property name="text">
<string>Right</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_coloredBorder">
<property name="whatsThis">
<string>Check this option if the window border should be painted in the titlebar color. Otherwise it will be painted in the background color.</string>
</property>
<property name="text">
<string>Colored window border</string>
</property>
<property name="shortcut">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_titleShadow">
<property name="whatsThis">
<string>Check this option if you want the titlebar text to have a 3D look with a shadow behind it.</string>
</property>
<property name="text">
<string>Use shadowed &amp;text</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_animateButtons">
<property name="whatsThis">
<string>Check this option if you want the buttons to fade in when the mouse pointer hovers over them and fade out again when it moves away.</string>
</property>
<property name="text">
<string>Animate buttons</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KButtonGroup</class>
<extends>QGroupBox</extends>
<header>kbuttongroup.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>kcfg_animateButtons</tabstop>
<tabstop>kcfg_titleShadow</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View file

@ -44,6 +44,21 @@ Decoration {
root.borderSize = 4;
break;
}
var titleAlignLeft = decoration.readConfig("titleAlignLeft", true);
var titleAlignCenter = decoration.readConfig("titleAlignCenter", false);
var titleAlignRight = decoration.readConfig("titleAlignRight", false);
if (titleAlignRight) {
root.titleAlignment = Text.AlignRight;
} else if (titleAlignCenter) {
root.titleAlignment = Text.AlignHCenter;
} else {
if (!titleAlignLeft) {
console.log("Error reading title alignment: all alignment options are false");
}
root.titleAlignment = Text.AlignLeft;
}
root.animateButtons = decoration.readConfig("animateButtons", true);
root.titleShadow = decoration.readConfig("titleShadow", true);
}
ColorHelper {
id: colorHelper
@ -53,8 +68,11 @@ Decoration {
deco: decoration
}
property alias buttonSize: titleRow.captionHeight
property alias titleAlignment: caption.horizontalAlignment
property color titleBarColor: options.titleBarColor
property int animationDuration: 150
property bool animateButtons: true
property bool titleShadow: true
Behavior on titleBarColor {
ColorAnimation {
duration: root.animationDuration
@ -256,7 +274,7 @@ Decoration {
}
text: decoration.caption
font: options.titleFont
style: Text.Raised
style: root.titleShadow ? Text.Raised : Text.Normal
styleColor: colorHelper.shade(color, ColorHelper.ShadowShade)
elide: Text.ElideMiddle
}