plasma: remove unused plasmacomponents types

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-09-12 03:54:27 +03:00
parent 8bc19ef8a4
commit cf717fd344
6 changed files with 0 additions and 1199 deletions

View file

@ -1,186 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2011 Marco Martin <mart@kde.org>
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Components project.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
** the names of its contributors may be used to endorse or promote
** products derived from this software without specific prior written
** permission.
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
** $QT_END_LICENSE$
**
****************************************************************************/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import "." 0.1
/**
* A plasma themed SelectionDialog, which can be customized by overriding the
* ListView delegate.
*
* By default SelectionDialog provides a scrollable list of textual menu items.
* The user can choose one item from the list at a time.
*/
CommonDialog {
id: root
// Common API
/**
* type:QtObject
* The model of selectionDialog. Can be a simple model or a custom
* QAbstractItemModel
*/
property alias model: listView.model
/**
* Selected index.
*
* The default value is -1.
*/
property int selectedIndex: -1
/**
* The delegate used to render the items.
*/
property Component delegate: defaultDelegate
Component {
id: defaultDelegate
Label {
visible: modelData.search(RegExp(filterField.filterText, "i")) != -1
height: visible? paintedHeight*2 : 0
text: modelData
MouseArea {
anchors.fill: parent
onClicked: {
selectedIndex = index
root.accept()
}
}
Keys.onPressed: {
if (event.key == Qt.Key_Up || event.key == Qt.Key_Down)
scrollBar.flash()
}
}
}
content: Item {
id: contentItem
property alias filterText: filterField.filterText
implicitWidth: theme.defaultFont.mSize.width * 40
implicitHeight: theme.defaultFont.mSize.height * 12
height: implicitHeight
TextField {
id: filterField
property string filterText
onTextChanged: searchTimer.restart()
clearButtonShown: true
anchors {
top: parent.top
left: parent.left
right: parent.right
}
Timer {
id: searchTimer
running: false
repeat: false
interval: 500
onTriggered: filterField.filterText = filterField.text
}
}
ListView {
id: listView
anchors {
top: filterField.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
currentIndex : -1
delegate: root.delegate
clip: true
Keys.onPressed: {
if (event.key == Qt.Key_Up || event.key == Qt.Key_Down
|| event.key == Qt.Key_Left || event.key == Qt.Key_Right
|| event.key == Qt.Key_Select || event.key == Qt.Key_Enter
|| event.key == Qt.Key_Return) {
listView.currentIndex = 0
event.accepted = true
}
}
}
ScrollBar {
id: scrollBar
flickableItem: listView
visible: listView.contentHeight > contentItem.height
//platformInverted: root.platformInverted
anchors { top: contentItem.top; right: contentItem.right }
}
}
onClickedOutside: {
reject()
}
Timer {
id: focusTimer
interval: 100
onTriggered: {
filterField.forceActiveFocus()
}
}
onStatusChanged: {
//FIXME: why needs focus deactivation then activation?
if (status == DialogStatus.Open) {
filterField.focus = false
focusTimer.running = true
}
if (status == DialogStatus.Opening) {
if (listView.currentItem != null) {
listView.currentItem.focus = false
}
listView.currentIndex = -1
listView.positionViewAtIndex(0, ListView.Beginning)
} else if (status == DialogStatus.Open) {
listView.focus = true
}
}
}

View file

@ -1,419 +0,0 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program 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 Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import "private" as Private
/**
* A plasma theme based text area.
*/
Item {
id: textArea
// Common API
/**
* type:font
* Font used in the text field.
*
* The default font value is the font from plasma desktop theme.
*/
property alias font: textEdit.font
/**
* Whether the text field is highlighted or not.
*
* If it is true then the problematic lines will be highlighted.
*
* @warning unimplemented in plasma components.
*/
property bool errorHighlight
/**
* type:int
* Current cursor position.
*/
property alias cursorPosition: textEdit.cursorPosition
/**
* type:enum
* Sets the horizontal alignment of the text within the TextArea item's
* width and height.
*
* By default, the text alignment follows the natural alignment of the
* text, for example text that is read from left to right will be aligned
* to the left.
*
* Valid values:
*
* - TextEdit.AlignLeft (default)
* - TextEdit.AlignRight
* - TextEdit.AlignHCenter
* - TextEdit.AlignJustify
*/
property alias horizontalAlignment: textEdit.horizontalAlignment
/**
* type:enum
* Sets the vertical alignment of the text within the TextArea item's width
* and height.
*
* Valid values:
*
* - TextEdit.AlignTop (default)
* - TextEdit.AlignBottom
* - TextEdit.AlignVCenter
*/
property alias verticalAlignment: textEdit.verticalAlignment
/**
* type:bool
* Whether the TextArea is in read-only mode, and cannot be modified by the
* user.
*
* The default value is false.
*/
property alias readOnly: textEdit.readOnly
/**
* type:string
* The text selected by the user. If no text is selected it holds an empty
* string.
*
* This property is read-only.
*/
property alias selectedText: textEdit.selectedText
/**
* type:int
* The cursor position after the last character in the current selection.
*
* This property is read-only.
*/
property alias selectionEnd: textEdit.selectionEnd
/**
* type:int
* The cursor position before the first character in the current selection.
*
* This property is read-only.
*/
property alias selectionStart: textEdit.selectionStart
/**
* type:string
* The text in the TextArea.
*/
property alias text: textEdit.text
/**
* type:enum
* The way the text property should be displayed.
*
* Valid values:
*
* - TextEdit.AutoText
* - TextEdit.PlainText
* - TextEdit.RichText
* - TextEdit.StyledText
*
* The default is TextEdit.AutoText. If the text format is
* TextEdit.AutoText the text edit will automatically determine whether the
* text should be treated as rich text. This determination is made using
* Qt::mightBeRichText().
*/
property alias textFormat: textEdit.textFormat
/**
* type:enum
* Set this property to wrap the text to the TextArea item's width. The
* text will only wrap if an explicit width has been set.
*
* Valid values:
*
* - TextEdit.NoWrap: no wrapping will be performed. If the text contains
* insufficient newlines, then implicitWidth will exceed a set width.
* - TextEdit.WordWrap: wrapping is done on word boundaries only. If a
* word is too long, implicitWidth will exceed a set width.
* - TextEdit.WrapAnywhere: wrapping is done at any point on a line, even
* if it occurs in the middle of a word.
* - TextEdit.Wrap: if possible, wrapping occurs at a word boundary;
* otherwise it will occur at the appropriate point on the line, even in
* the middle of a word.
*
* The default is TextEdit.NoWrap. If you set a width, consider using
* TextEdit.Wrap.
*/
property alias wrapMode: textEdit.wrapMode
/**
* The text displayed when the text property is empty.
*
* The default value is an empty string, meaning no placeholderText shown.
*/
property string placeholderText
// functions
/**
* Copies the currently selected text to the system clipboard.
*/
function copy() {
textEdit.copy();
}
/**
* Replaces the currently selected text by the contents of the system
* clipboard.
*/
function paste() {
textEdit.paste();
}
/**
* Moves the currently selected text to the system clipboard.
*/
function cut() {
textEdit.cut();
}
/**
* Causes the text from start to end to be selected.
*
* If either start or end is out of range, the selection is not changed.
* After calling this, selectionStart will become the lesser and
* selectionEnd will become the greater (regardless of the order passed to
* this method).
*
* @param type:int start Start of selection
* @param type:int end End of selection
*/
function select(start, end) {
textEdit.select(start, end);
}
/**
* Causes all text to be selected.
*/
function selectAll() {
textEdit.selectAll();
}
/**
* Causes the word closest to the current cursor position to be selected.
*/
function selectWord() {
textEdit.selectWord();
}
/**
* This function returns the character position at x pixels from the left
* of the TextArea.
*
* Position 0 is before the first character, position 1 is after the first
* character but before the second, and so on until position text.length,
* which is after all characters. This means that for all x values before
* the first character this function returns 0, and for all x values after
* the last character this function returns text.length.
*
* @param type:int pos x-coordinate we are interested in.
* @return type:int the character position
*/
// Does this work at all? doc for TextEdit says positionAt() accepts two
// ints: x and y
function positionAt(pos) {
return textEdit.positionAt(pos);
}
/**
* Returns the rectangle at the given position in the text.
*
* The x, y, and height properties correspond to the cursor that would
* describe that position.
*
* @param type:int pos the text position
* @return type:rectangle the cursor rectangle
*/
function positionToRectangle(pos) {
return textEdit.positionToRectangle(pos);
}
// Plasma API
/**
* type:bool
* This property describes whether the user can interact with the TextArea
* flicking content. A user cannot drag or flick a TextArea that is not
* interactive. This property is useful for temporarily disabling
* flicking.
*/
property alias interactive: flickArea.interactive
/**
* type:int
* Maximum width that the text content can have.
*/
property alias contentMaxWidth: textEdit.width
/**
* type:int
* Maximum height that the text content can have.
*/
property alias contentMaxHeight: textEdit.height
// Set active focus to it's internal textInput.
// Overriding QtQuick.Item forceActiveFocus function.
function forceActiveFocus() {
textEdit.forceActiveFocus();
}
// Overriding QtQuick.Item activeFocus property.
property alias activeFocus: textEdit.activeFocus
opacity: enabled ? 1.0 : 0.5
Private.TextFieldFocus {
id: hover
state: textArea.activeFocus ? "focus" : (mouseWatcher.containsMouse ? "hover" : "hidden")
anchors.fill: base
}
MouseArea {
id: mouseWatcher
anchors.fill: hover
hoverEnabled: true
}
PlasmaCore.FrameSvgItem {
id: base
// TODO: see what is the best policy for margins
anchors {
fill: parent
}
imagePath: "widgets/lineedit"
prefix: "base"
}
Flickable {
id: flickArea
anchors {
fill: parent
leftMargin: 2 * base.margins.left
rightMargin: 2 * base.margins.right + (verticalScroll.visible ? verticalScroll.width : 0)
topMargin: 2 * base.margins.top
bottomMargin: 2 * base.margins.bottom + (horizontalScroll.visible ? verticalScroll.width : 0)
}
interactive: !verticalScroll.interactive //textArea.activeFocus
contentWidth: {
if (textEdit.wrapMode == TextEdit.NoWrap)
return textEdit.paintedWidth;
return Math.min(textEdit.paintedWidth, textEdit.width);
}
contentHeight: Math.min(textEdit.paintedHeight, textEdit.height)
clip: true
TextEdit {
id: textEdit
width: flickArea.width
height: flickArea.height
clip: true
wrapMode: TextEdit.Wrap
enabled: textArea.enabled
font.family: theme.defaultFont.family
font.italic: theme.defaultFont.italic
font.pointSize: theme.defaultFont.pointSize
font.strikeout: theme.defaultFont.strikeout
font.underline: theme.defaultFont.underline
font.weight: theme.defaultFont.weight
color: theme.buttonTextColor
selectByMouse: verticalScroll.interactive
onCursorPositionChanged: {
if (cursorRectangle.x < flickArea.contentX) {
flickArea.contentX = cursorRectangle.x;
return;
}
if (cursorRectangle.x > flickArea.contentX +
flickArea.width - cursorRectangle.width) {
flickArea.contentX = cursorRectangle.x -
cursorRectangle.width;
return;
}
if (cursorRectangle.y < flickArea.contentY) {
flickArea.contentY = cursorRectangle.y;
return;
}
if (cursorRectangle.y > flickArea.contentY +
flickArea.height - cursorRectangle.height) {
flickArea.contentY = cursorRectangle.y -
cursorRectangle.height;
return;
}
}
// Proxying keys events is not required by the
// common API but is desired in the plasma API.
Keys.onPressed: textArea.Keys.pressed(event);
Keys.onReleased: textArea.Keys.released(event);
Text {
anchors.fill: parent
text: textArea.placeholderText
visible: textEdit.text == "" && !textArea.activeFocus
color: theme.buttonTextColor
opacity: 0.5
}
onActiveFocusChanged: {
if (!textEdit.activeFocus) {
textEdit.closeSoftwareInputPanel()
}
}
}
}
ScrollBar {
id: horizontalScroll
anchors {
bottom: parent.bottom
left: parent.left
right: flickArea.right
}
enabled: parent.enabled
flickableItem: flickArea
orientation: Qt.Horizontal
stepSize: textEdit.font.pixelSize
}
ScrollBar {
id: verticalScroll
anchors {
right: parent.right
top: parent.top
bottom: flickArea.bottom
}
enabled: parent.enabled
flickableItem: flickArea
orientation: Qt.Vertical
stepSize: textEdit.font.pixelSize
}
}

View file

@ -1,376 +0,0 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program 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 Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import "private" as Private
/**
* A plasma theme based text field widget.
*/
FocusScope {
id: textField
// Common API
/**
* Whether the text field is highlighted or not
*
* If it is true then the problematic lines will be highlighted.
*
* @warning Not implemented in Plasma components.
*/
property bool errorHighlight: false // TODO
/**
* type:string
*
* The text displayed in when the text is empty.
*
* The default value is an empty string, meaning no placeholderText shown.
*/
property string placeholderText
/**
* type:font
* The font used in the text field.
*
* The default font value is the font from plasma desktop theme.
*/
property alias font: textInput.font
/**
* type:int
* This property holds the current cursor position.
*/
property alias cursorPosition: textInput.cursorPosition
/**
* type:bool
* This property holds if the text field can be modified by the user interaction.
*
* The default value is false.
*/
property alias readOnly: textInput.readOnly
/**
* type:enum
*
* Specifies how the text should be displayed in the TextField.
*
* The acceptable values are:
* - TextInput.Normal: Displays the text as it is. (Default)
* - TextInput.Password: Displays asterixes instead of characters.
* - TextInput.NoEcho: Displays nothing.
* - TextInput.PasswordEchoOnEdit: Displays all but the current character
* as asterixes.
*
* The default value is TextInput.Normal
*/
property alias echoMode: textInput.echoMode
property alias passwordCharacter: textInput.passwordCharacter
property alias acceptableInput: textInput.acceptableInput // read-only
/**
* type:string
*
* Allows you to set an input mask on the TextField, restricting the
* allowable text inputs.
*
* See QLineEdit::inputMask for further details, as the exact same mask
* strings are used by TextInput.
*/
property alias inputMask: textInput.inputMask
/**
* type:QtObject
*
* Allows you to set a validator on the TextField. When a validator is set
* the TextField will only accept input which leaves the text property in
* an acceptable or intermediate state. The accepted signal will only be
* sent if the text is in an acceptable state when enter is pressed.
*
* Currently supported validators are IntValidator, DoubleValidator and
* RegExpValidator.
*
* An example of using validators is shown below, which allows input of
* integers between 11 and 31 into the text input:
*
* @code
* import QtQuick 1.0
* TextInput {
* validator: IntValidator { bottom: 11; top: 31 }
* focus: true
* }
* @endcode
*/
property alias validator: textInput.validator
/**
* type:string
* The text selected by the user. If no text is selected it holds an empty string.
*
* This property is read-only.
*/
property alias selectedText: textInput.selectedText
/**
* type:int
* The cursor position after the last character in the current selection.
*
* This property is read-only.
*/
property alias selectionEnd: textInput.selectionEnd
/**
* type:int
* The cursor position before the first character in the current selection.
*
* This property is read-only.
*/
property alias selectionStart: textInput.selectionStart
/**
* type:string
* The text in the text field.
*/
property alias text: textInput.text
/**
* type:int
*
* The maximum permitted length of the text in the TextField. If the text
* is too long, it is truncated at the limit.
*
* Default value is 32767.
*/
property alias maximumLength: textInput.maximumLength
/**
* Emitted when the text input is accepted.
*/
signal accepted()
//Plasma api
/**
* Whether the button to clear the text from TextField is visible.
*/
property bool clearButtonShown: false
/**
* Copies the currently selected text to the system clipboard.
*/
function copy() {
textInput.copy();
}
/**
* Replaces the currently selected text by the contents of the system
* clipboard.
*/
function paste() {
textInput.paste();
}
/**
* Moves the currently selected text to the system clipboard.
*/
function cut() {
textInput.cut();
}
/**
* Causes the text from start to end to be selected.
*
* If either start or end is out of range, the selection is not changed.
* After calling this, selectionStart will become the lesser and
* selectionEnd will become the greater (regardless of the order passed to
* this method).
*
* @param type:int start Start of selection
* @param type:int end End of selection
*/
function select(start, end) {
textInput.select(start, end);
}
/**
* Causes all text to be selected.
*/
function selectAll() {
textInput.selectAll();
}
/**
* Causes the word closest to the current cursor position to be selected.
*/
function selectWord() {
textInput.selectWord();
}
/**
* This function returns the character position at x pixels from the left
* of the TextField.
*
* Position 0 is before the first character, position 1 is after the first
* character but before the second, and so on until position text.length,
* which is after all characters. This means that for all x values before
* the first character this function returns 0, and for all x values after
* the last character this function returns text.length.
*
* @param type:int pos x-coordinate we are interested in.
* @return type:int the character position
*/
function positionAt(pos) {
return textInput.positionAt(pos);
}
/**
* Returns the rectangle at the given position in the text.
*
* The x, y, and height properties correspond to the cursor that would
* describe that position.
*
* @param type:int pos the text position
* @param type:rectangle the cursor rectangle
*/
function positionToRectangle(pos) {
return textInput.positionToRectangle(pos);
}
// Set active focus to it's internal textInput.
// Overriding QtQuick.Item forceActiveFocus function.
function forceActiveFocus() {
textInput.forceActiveFocus();
}
// Overriding QtQuick.Item activeFocus property.
property alias activeFocus: textInput.activeFocus
// TODO: fix default size
implicitWidth: theme.defaultFont.mSize.width*12 + base.internalPadding*2
implicitHeight: theme.defaultFont.mSize.height + base.internalPadding*2
// TODO: needs to define if there will be specific graphics for
// disabled text fields
opacity: enabled ? 1.0 : 0.5
Private.TextFieldFocus {
id: hover
state: textInput.activeFocus ? "focus" : (mouseWatcher.containsMouse ? "hover" : "hidden")
anchors.fill: base
}
PlasmaCore.FrameSvgItem {
id: base
// TODO: see what is the correct policy for margins
anchors.fill: parent
imagePath: "widgets/lineedit"
prefix: "base"
property real internalPadding: theme.defaultFont.mSize.height*0.3
}
MouseArea {
id: mouseWatcher
anchors.fill: hover
hoverEnabled: true
onClicked: {
// If we don't set focus on click here then clicking between the
// line of text and the bottom or top of the widget will not focus
// it.
textInput.forceActiveFocus();
}
}
Text {
anchors {
left: parent.left
right: parent.right
verticalCenter: parent.verticalCenter
leftMargin: base.margins.left + base.internalPadding
rightMargin: base.margins.right + base.internalPadding
}
text: placeholderText
visible: textInput.text == ""
// XXX: using textColor and low opacity for theming placeholderText
color: theme.buttonTextColor
opacity: 0.5
elide: Text.ElideRight
clip: true
font.family: theme.defaultFont.family
font.italic: theme.defaultFont.italic
font.pointSize: theme.defaultFont.pointSize
font.strikeout: theme.defaultFont.strikeout
font.underline: theme.defaultFont.underline
font.weight: theme.defaultFont.weight
}
TextInput {
id: textInput
anchors {
left: parent.left
right: parent.right
verticalCenter: parent.verticalCenter
// TODO: see what is the correct policy for margins
leftMargin: base.margins.left + base.internalPadding
rightMargin: base.margins.right + (clearButton.opacity > 0 ? clearButton.width : 0) + base.internalPadding
}
passwordCharacter: "•"
selectByMouse: true
color: theme.buttonTextColor
enabled: textField.enabled
clip: true
focus: true
onActiveFocusChanged: {
if (!textField.activeFocus) {
textInput.closeSoftwareInputPanel()
}
}
onAccepted: textField.accepted()
Keys.forwardTo: textField
}
PlasmaCore.IconItem {
id: clearButton
source: "edit-clear-locationbar-rtl"
height: Math.max(textInput.height, theme.smallIconSize)
width: height
opacity: (textInput.text != "" && clearButtonShown) ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: 250
easing.type: Easing.InOutQuad
}
}
anchors {
right: parent.right
rightMargin: y
verticalCenter: textInput.verticalCenter
}
MouseArea {
anchors.fill: parent
onClicked: {
textInput.text = ""
textInput.forceActiveFocus()
}
}
}
}

View file

@ -1,117 +0,0 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 1.0
import org.kde.plasma.core 0.1 as PlasmaCore
/**
* Private base component for several public components. Any element documented here
* can be used in components inheriting from DualStateButton.
*/
Item {
id: dualButton
// Common API
/**
* If the button is checked, its checked property is true; otherwise false. The property is false by default.
*/
property bool checked
/**
* type:bool
* If the button is pressed, its pressed property is true.
* @see clicked
*/
property alias pressed: mouseArea.pressed
/**
* Emitted when the user clicked a mouse button over the button (or
* tapped on the touch screen)
*/
signal clicked()
// Plasma API
/**
* The text is shown beside the button. By default text is an empty string.
*/
property alias text: label.text // TODO: Not yet part of the common API
property alias view: surfaceLoader.sourceComponent
property alias shadow: shadowLoader.sourceComponent
width: surfaceLoader.width + label.paintedWidth
height: theme.defaultFont.mSize.height*1.6
// TODO: needs to define if there will be specific graphics for
// disabled buttons
opacity: dualButton.enabled ? 1.0 : 0.5
function released() {
if (dualButton.enabled) {
dualButton.checked = !dualButton.checked;
dualButton.clicked();
}
}
Keys.onReleased: {
if(event.key == Qt.Key_Space ||
event.key == Qt.Key_Return)
released();
}
Loader {
id: shadowLoader
anchors.fill: surfaceLoader
state: (dualButton.enabled && (dualButton.activeFocus || mouseArea.containsMouse)) ? "hover" : "shadow"
}
Loader {
id: surfaceLoader
anchors {
verticalCenter: parent.verticalCenter
left: text ? parent.left : undefined
horizontalCenter: text ? undefined : parent.horizontalCenter
}
}
Text {
id: label
text: dualButton.text
anchors {
top: parent.top
bottom: parent.bottom
left: surfaceLoader.right
right: parent.right
//FIXME: see how this margin will be set
leftMargin: height/4
}
color: theme.textColor
verticalAlignment: Text.AlignVCenter
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onReleased: dualButton.released();
onPressed: dualButton.forceActiveFocus();
}
}

View file

@ -1,98 +0,0 @@
/*
* Copyright (C) 2011 by Daker Fernandes Pinheiro <dakerfp@gmail.com>
* Copyright (C) 2011 by Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program 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 Library General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 1.0
import org.kde.plasma.core 0.1 as PlasmaCore
Item {
id: main
state: parent.state
PlasmaCore.Svg {
id: lineEditSvg
imagePath: "widgets/lineedit"
onRepaintNeeded: {
if (lineEditSvg.hasElement("hint-focus-over-base")) {
main.z = 800
} else {
main.z = 0
}
}
Component.onCompleted: {
if (lineEditSvg.hasElement("hint-focus-over-base")) {
main.z = 800
} else {
main.z = 0
}
}
}
PlasmaCore.FrameSvgItem {
id: hover
anchors {
fill: parent
leftMargin: -margins.left
topMargin: -margins.top
rightMargin: -margins.right
bottomMargin: -margins.bottom
}
opacity: 0
imagePath: "widgets/lineedit"
prefix: "hover"
}
states: [
State {
name: "hover"
PropertyChanges {
target: hover
opacity: 1
prefix: "hover"
}
},
State {
name: "focus"
PropertyChanges {
target: hover
opacity: 1
prefix: "focus"
}
},
State {
name: "hidden"
PropertyChanges {
target: hover
opacity: 0
prefix: "hover"
}
}
]
transitions: [
Transition {
PropertyAnimation {
properties: "opacity"
duration: 250
easing.type: Easing.OutQuad
}
}
]
}

View file

@ -15,13 +15,10 @@ ProgressBar 0.1 ProgressBar.qml
QueryDialog 0.1 QueryDialog.qml
ScrollBar 0.1 ScrollBar.qml
SectionScroller 0.1 SectionScroller.qml
SelectionDialog 0.1 SelectionDialog.qml
Sheet 0.1 Sheet.qml
TabBar 0.1 TabBar.qml
TabButton 0.1 TabButton.qml
TabGroup 0.1 TabGroup.qml
TextArea 0.1 TextArea.qml
TextField 0.1 TextField.qml
ToolBar 0.1 ToolBar.qml
ToolBarLayout 0.1 ToolBarLayout.qml
ToolButton 0.1 ToolButton.qml