cool-retro-term/app/qml/ColorButton.qml

65 lines
2.0 KiB
QML
Raw Normal View History

2013-12-28 14:52:10 +01:00
/*******************************************************************************
* Copyright (c) 2013 "Filippo Scognamiglio"
* https://github.com/Swordfish90/cool-retro-term
2013-12-28 14:52:10 +01:00
*
* This file is part of cool-retro-term.
2013-12-28 14:52:10 +01:00
*
* cool-retro-term is free software: you can redistribute it and/or modify
2013-12-28 14:52:10 +01:00
* 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.
*
* 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
import QtQuick 2.2
2013-12-23 00:13:47 +01:00
import QtQuick.Dialogs 1.1
Item {
id: rootItem
2014-07-16 00:38:16 +02:00
signal colorSelected (color color)
property color color
property string name
2013-12-23 00:13:47 +01:00
ColorDialog {
id: colorDialog
title: qsTr("Choose a color")
modality: Qt.ApplicationModal
visible: false
//This is a workaround to a Qt 5.2 bug.
onColorChanged: if (Qt.platform.os !== "osx") colorSelected(color)
onAccepted: if (Qt.platform.os === "osx") colorSelected(color)
2013-12-23 00:13:47 +01:00
}
Rectangle{
anchors.fill: parent
radius: 10
color: rootItem.color
border.color: "black"
Glossy {}
Rectangle {
anchors.fill: parent
anchors.margins: parent.height * 0.25
radius: parent.radius
color: "white"
opacity: 0.5
2013-12-23 00:13:47 +01:00
}
Text{
2013-12-23 00:13:47 +01:00
anchors.centerIn: parent
z: parent.z + 1
text: name + ": " + rootItem.color
2013-12-23 00:13:47 +01:00
}
}
MouseArea{
anchors.fill: parent
onClicked: colorDialog.visible = true;
}
}