Add tools bar

pull/1/head
reionwong 5 years ago
parent 6677d8b883
commit ab00504a93

@ -0,0 +1,22 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<g transform="matrix(.039062 0 0 .039062 1.9999 2.0002)">
<path d="m284.29 256 221.86-221.86c7.811-7.811 7.811-20.475 0-28.285s-20.475-7.811-28.285 0l-221.86 221.86-221.86-221.86c-7.811-7.811-20.475-7.811-28.285 0s-7.811 20.475 0 28.285l221.86 221.86-221.86 221.86c-7.811 7.811-7.811 20.475 0 28.285 3.905 3.905 9.024 5.857 14.143 5.857s10.237-1.952 14.143-5.857l221.86-221.86 221.86 221.86c3.905 3.905 9.024 5.857 14.143 5.857s10.237-1.952 14.143-5.857c7.811-7.811 7.811-20.475 0-28.285z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 644 B

@ -0,0 +1,18 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<path d="m7.4111 20.823c-0.2709 0-0.54206-0.10314-0.74808-0.31045l-6.3528-6.3528c-0.41359-0.41385-0.41359-1.0844 0-1.498 0.4136-0.4136 1.0841-0.4136 1.4977 0l5.6047 5.6047 14.779-14.779c0.41386-0.41359 1.0844-0.41359 1.498 0 0.41359 0.41359 0.41359 1.0841 0 1.4977l-15.529 15.529c-0.20757 0.20602-0.47848 0.30916-0.74964 0.30916z" stroke-width=".066175"/></svg>

After

Width:  |  Height:  |  Size: 497 B

@ -0,0 +1,18 @@
<svg width="24" height="24" version="1.1" viewBox="0 0 24 24" xml:space="preserve" xmlns="http://www.w3.org/2000/svg">
<path d="m11.377 22.736c0.17151 0.17151 0.4024 0.26387 0.62669 0.26387s0.45517-0.08575 0.62669-0.26387l5.66-5.66c0.34962-0.34962 0.34962-0.91034 0-1.26s-0.91035-0.34962-1.26 0l-4.1361 4.1427v-18.068c0-0.49475-0.3958-0.89055-0.89056-0.89055-0.49476 0-0.89056 0.3958-0.89056 0.89055v18.068l-4.1427-4.1427c-0.34962-0.34962-0.91035-0.34962-1.26 0s-0.34962 0.91034 0 1.26z" stroke-width=".065967"/></svg>

After

Width:  |  Height:  |  Size: 535 B

@ -1,5 +1,9 @@
<RCC>
<qresource prefix="/">
<file>qml/main.qml</file>
<file>images/cancel.svg</file>
<file>qml/ImageButton.qml</file>
<file>images/ok.svg</file>
<file>images/save.svg</file>
</qresource>
</RCC>

@ -0,0 +1,69 @@
/*
* Copyright (C) 2021 CutefishOS Team.
*
* Author: Reion Wong <reionwong@gmail.com>
*
* 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 3 of the License, or
* 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.12
import QtQuick.Window 2.3
import QtQuick.Controls 2.4
import FishUI 1.0 as FishUI
Item {
id: control
property var size: 32
property var iconMargins: 0
height: size
width: size
property color hoveredColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.backgroundColor, 2)
: Qt.darker(FishUI.Theme.backgroundColor, 1.2)
property color pressedColor: FishUI.Theme.darkMode ? Qt.lighter(FishUI.Theme.backgroundColor, 1.5)
: Qt.darker(FishUI.Theme.backgroundColor, 1.3)
property alias source: _image.source
property alias image: _image
signal clicked()
Rectangle {
id: background
anchors.fill: parent
anchors.margins: size * 0.1
radius: control.height / 2
color: mouseArea.pressed ? pressedColor : mouseArea.containsMouse ? control.hoveredColor : "transparent"
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: control.clicked()
}
Image {
id: _image
objectName: "image"
anchors.fill: parent
anchors.margins: control.iconMargins
fillMode: Image.PreserveAspectFit
sourceSize: Qt.size(width, height)
cache: true
smooth: false
antialiasing: true
asynchronous: false
}
}

@ -20,6 +20,7 @@
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.0
import FishUI 1.0 as FishUI
@ -116,6 +117,60 @@ Item {
}
}
Rectangle {
id: tools
width: toolsLayout.implicitWidth + FishUI.Units.largeSpacing
height: 36 + FishUI.Units.smallSpacing
visible: sizeToolTip.visible
z: 999
x: selectLayer.x
y: selectLayer.y + selectLayer.height + FishUI.Units.smallSpacing
radius: FishUI.Theme.smallRadius
color: FishUI.Theme.backgroundColor
MouseArea {
anchors.fill: parent
}
RowLayout {
id: toolsLayout
anchors.fill: parent
anchors.leftMargin: FishUI.Units.smallSpacing
anchors.rightMargin: FishUI.Units.smallSpacing
anchors.topMargin: FishUI.Units.smallSpacing / 2
anchors.bottomMargin: FishUI.Units.smallSpacing / 2
ImageButton {
iconMargins: FishUI.Units.largeSpacing
size: 36
source: "qrc:/images/save.svg"
onClicked: view.saveFile(Qt.rect(selectLayer.x,
selectLayer.y,
selectLayer.width,
selectLayer.height))
}
ImageButton {
iconMargins: FishUI.Units.largeSpacing
size: 36
source: "qrc:/images/cancel.svg"
onClicked: view.quit()
}
ImageButton {
iconMargins: FishUI.Units.largeSpacing
size: 36
source: "qrc:/images/ok.svg"
}
}
}
// Global
MouseArea {
id: mouseArea

@ -19,8 +19,11 @@
#include "screenshotview.h"
#include <QGuiApplication>
#include <QQmlContext>
#include <QScreen>
#include <QPixmap>
#include <QStandardPaths>
#include <QDateTime>
ScreenshotView::ScreenshotView(QQuickView *parent)
: QQuickView(parent)
@ -29,7 +32,28 @@ ScreenshotView::ScreenshotView(QQuickView *parent)
QPixmap p = qGuiApp->primaryScreen()->grabWindow(0);
p.save("/tmp/cutefish-screenshot.png");
rootContext()->setContextProperty("view", this);
setResizeMode(QQuickView::SizeRootObjectToView);
setSource(QUrl("qrc:/qml/main.qml"));
showFullScreen();
}
void ScreenshotView::quit()
{
qGuiApp->quit();
}
void ScreenshotView::saveFile(QRect rect)
{
QString desktopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QString fileName = QString("%1/Screenshot_%2.png")
.arg(desktopPath)
.arg(QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss"));
QImage image("/tmp/cutefish-screenshot.png");
QImage cropped = image.copy(rect);
cropped.save(fileName);
this->quit();
}

@ -29,7 +29,8 @@ class ScreenshotView : public QQuickView
public:
explicit ScreenshotView(QQuickView *parent = nullptr);
signals:
Q_INVOKABLE void quit();
Q_INVOKABLE void saveFile(QRect rect);
};

Loading…
Cancel
Save