Commit b74aeee6 authored by Marco Martin's avatar Marco Martin
Browse files

hack checkbox for coloring tiles

parent 3b56a6c0
......@@ -40,8 +40,13 @@ void ImagePalette::setSourceItem(QQuickItem *source)
if (m_window) {
disconnect(m_window.data(), nullptr, this, nullptr);
}
if (m_source) {
disconnect(m_source, nullptr, this, nullptr);
m_source->removeEventFilter(this);
}
m_source = source;
update();
m_source->installEventFilter(this);
if (m_source) {
auto syncWindow = [this] () {
......@@ -68,6 +73,12 @@ QQuickItem *ImagePalette::sourceItem() const
return m_source;
}
bool ImagePalette::eventFilter(QObject *watched, QEvent *event)
{
qWarning()<<event;
return QObject::eventFilter(watched, event);
}
void ImagePalette::update()
{
if (!m_source || !m_window) {
......@@ -214,8 +225,8 @@ void ImagePalette::generatePalette()
entry["color"] = color;
entry["ratio"] = stat.ratio;
const int distance = squareDistance(m_suggestedContrast.rgb(), stat.centroid);qWarning()<<distance;
entry["distance"] = distance;
const int distance = squareDistance(m_suggestedContrast.rgb(), stat.centroid);
if (distance < minimumDistance) {
tempContrast = QColor(stat.centroid);
minimumDistance = distance;
......
......@@ -60,6 +60,9 @@ Q_SIGNALS:
void closestToBlackChanged();
void closestToWhiteChanged();
protected:
bool eventFilter(QObject *watched, QEvent *event) override;
private:
inline void positionColor(QRgb rgb);
void generatePalette();
......
......@@ -24,6 +24,7 @@ import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 3.0 as PlasmaComponents
import org.kde.kirigami 2.11 as Kirigami
import org.kde.mycroft.bigscreen 1.0 as BigScreen
PlasmaComponents.ItemDelegate {
id: delegate
......@@ -59,6 +60,23 @@ PlasmaComponents.ItemDelegate {
clicked();
}
BigScreen.ImagePalette {
id: imagePalette
sourceItem: icon
property bool useColors: BigScreen.Hack.coloredTiles
property color backgroundColor: useColors ? suggestedContrast : PlasmaCore.ColorScope.backgroundColor
property color accentColor: useColors ? mostSaturated : PlasmaCore.ColorScope.highlightColor
property color textColor: useColors
? (0.2126 * suggestedContrast.r + 0.7152 * suggestedContrast.g + 0.0722 * suggestedContrast.b > 0.6 ? Qt.rgba(0.2,0.2,0.2,1) : Qt.rgba(0.9,0.9,0.9,1))
: PlasmaCore.ColorScope.textColor
readonly property bool inView: listView.width - delegate.x - icon.x < listView.contentX
onInViewChanged: {
if (inView) {
imagePalette.update();
}
}
}
background: Item {
id: background
......@@ -80,7 +98,7 @@ PlasmaComponents.ItemDelegate {
margins: units.largeSpacing
}
radius: units.gridUnit/5
color: delegate.isCurrent ? theme.highlightColor : theme.backgroundColor
color: delegate.isCurrent ? imagePalette.accentColor : imagePalette.backgroundColor
Behavior on color {
ColorAnimation {
duration: Kirigami.Units.longDuration
......@@ -93,7 +111,7 @@ PlasmaComponents.ItemDelegate {
margins: units.smallSpacing
}
radius: units.gridUnit/5
color: theme.backgroundColor
color: imagePalette.backgroundColor
}
}
}
......@@ -139,7 +157,7 @@ PlasmaComponents.ItemDelegate {
horizontalAlignment: Text.AlignHCenter
maximumLineCount: 2
elide: Text.ElideRight
//color: PlasmaCore.ColorScope.textColor
color: imagePalette.textColor
text: delegate.text
}
......@@ -158,7 +176,7 @@ PlasmaComponents.ItemDelegate {
horizontalAlignment: Text.AlignHCenter
maximumLineCount: 2
elide: Text.ElideRight
//color: PlasmaCore.ColorScope.textColor
color: imagePalette.textColor
text: delegate.comment
}
......
/*
* Copyright 2019 Aditya Mehra <aix.m@outlook.com>
* Copyright 2019 Marco Martin <mart@kde.org>
*
* This program 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 2 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/
import QtQuick 2.9
pragma Singleton
QtObject {
property bool coloredTiles: false
}
......@@ -3,3 +3,4 @@ plugin bigscreenplugin
TileView 1.0 TileView.qml
AbstractDelegate 1.0 AbstractDelegate.qml
singleton Hack 1.0 Hack.qml
......@@ -30,14 +30,24 @@ import Mycroft 1.0 as Mycroft
import "launcher"
import "indicators" as Indicators
import org.kde.mycroft.bigscreen 1.0 as BigScreen
Item {
id: root
Layout.minimumWidth: Screen.desktopAvailableWidth
Layout.minimumHeight: Screen.desktopAvailableHeight * 0.6
property Item wallpaper
Controls.CheckBox {
z: 999
anchors {
top: topBar.bottom
right: parent.right
}
text: "Use Colored Tiles"
checked: BigScreen.Hack.coloredTiles
onCheckedChanged: BigScreen.Hack.coloredTiles = checked
}
Containment.onAppletAdded: {
addApplet(applet, x, y);
......@@ -158,6 +168,70 @@ Item {
margins: units.smallSpacing
}
Kirigami.Heading {
id: inputQuery
Kirigami.Theme.colorSet: mainView.Kirigami.Theme.colorSet
level: 3
opacity: 0
onTextChanged: {
opacity = 1;
utteranceTimer.restart();
}
Timer {
id: utteranceTimer
interval: 8000
onTriggered: {
inputQuery.text = "";
inputQuery.opacity = 0
}
}
Behavior on opacity {
OpacityAnimator {
duration: Kirigami.units.longDuration
easing.type: Easing.InOutQuad
}
}
Connections {
target: Mycroft.MycroftController
onIntentRecevied: {
if(type == "recognizer_loop:utterance") {
inputQuery.text = data.utterances[0]
}
}
onServerReadyChanged: {
if (Mycroft.MycroftController.serverReady) {
inputQuery.text = "";
} else {
inputQuery.text = i18n("Not Ready");
utteranceTimer.running = false;
}
}
onStatusChanged: {
switch (Mycroft.MycroftController.status) {
case Mycroft.MycroftController.Connecting:
case Mycroft.MycroftController.Error:
case Mycroft.MycroftController.Stopped:
inputQuery.text = i18n("Not Ready");
utteranceTimer.running = false;
break;
default:
if (Mycroft.MycroftController.serverReady) {
inputQuery.text = "";
}
break;
}
}
}
}
Mycroft.StatusIndicator {
id: si
z: 2
visible: !mycroftWindow.visible
Layout.preferredWidth: height
Layout.fillHeight: true
}
Indicators.Volume {
id: volumeIndicator
Layout.fillHeight: true
......@@ -262,77 +336,4 @@ Item {
}
]
}
Mycroft.StatusIndicator {
id: si
z: 2
visible: !mycroftWindow.visible
anchors {
right: parent.right
top: parent.top
margins: Kirigami.Units.largeSpacing
topMargin: Kirigami.Units.largeSpacing * 3 + plasmoid.availableScreenRect.y
}
}
Kirigami.Heading {
id: inputQuery
Kirigami.Theme.colorSet: mainView.Kirigami.Theme.colorSet
anchors.right: si.left
anchors.rightMargin: Kirigami.Units.largeSpacing
anchors.verticalCenter: si.verticalCenter
level: 3
opacity: 0
onTextChanged: {
opacity = 1;
utteranceTimer.restart();
}
Timer {
id: utteranceTimer
interval: 8000
onTriggered: {
inputQuery.text = "";
inputQuery.opacity = 0
}
}
Behavior on opacity {
OpacityAnimator {
duration: Kirigami.units.longDuration
easing.type: Easing.InOutQuad
}
}
Connections {
target: Mycroft.MycroftController
onIntentRecevied: {
if(type == "recognizer_loop:utterance") {
inputQuery.text = data.utterances[0]
}
}
onServerReadyChanged: {
if (Mycroft.MycroftController.serverReady) {
inputQuery.text = "";
} else {
inputQuery.text = i18n("Not Ready");
utteranceTimer.running = false;
}
}
onStatusChanged: {
switch (Mycroft.MycroftController.status) {
case Mycroft.MycroftController.Connecting:
case Mycroft.MycroftController.Error:
case Mycroft.MycroftController.Stopped:
inputQuery.text = i18n("Not Ready");
utteranceTimer.running = false;
break;
default:
if (Mycroft.MycroftController.serverReady) {
inputQuery.text = "";
}
break;
}
}
}
}
}
......@@ -51,7 +51,6 @@ RowLayout {
implicitWidth: 10 + 300 * modelData.ratio
implicitHeight: 30
color: modelData.color
Text{text:modelData.distance}
}
}
}
......
......@@ -33,6 +33,12 @@ Image {
BigScreen.ImagePalette {
id: palette
sourceItem: icon
readonly property bool inView: view.height - delegate.y - icon.y < view.contentY
onInViewChanged: {
if (inView) {
palette.update();
}
}
}
RowLayout {
anchors.fill: parent
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment