Commit 8057071b authored by Carson Black's avatar Carson Black

Montages

parent 6e22b4ee
import QtQuick 2.12
import QtQuick.Layouts 1.12
import org.kde.kirigami 2.5 as Kirigami
import QtQuick.Controls 2.5
import QtQuick.Dialogs 1.3
import me.appadeia.Ikona 1.0
Item {
id: screenRoot
visible: false
width: 800
height: 400 + (400 * 1/3)
Item {
anchors.fill: parent
Row {
anchors.fill: parent
Rectangle {
height: parent.height
width: parent.width / 2
color: root.leftColor
Behavior on color {
ColorAnimation {
duration: 500
}
}
}
Rectangle {
height: parent.height
width: parent.width / 2
color: root.rightColor
Behavior on color {
ColorAnimation {
duration: 500
}
}
}
}
Row {
anchors.fill: parent
spacing: 0
Column {
width: parent.width / 2
anchors.verticalCenter: parent.verticalCenter
Spacer {}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
LightIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: "file:/tmp/ikonalight.svg"
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
LightIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: root.symIcons[0]
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
LightIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: root.symIcons[1]
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
LightIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: root.symIcons[2]
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
LightIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: root.symIcons[3]
}
}
}
}
Column {
width: parent.width / 2
anchors.verticalCenter: parent.verticalCenter
Spacer {}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
DarkIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: "file:/tmp/ikonadark.svg"
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
DarkIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: root.symIcons[0]
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
DarkIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: root.symIcons[1]
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
DarkIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: root.symIcons[2]
}
}
}
Row {
anchors.horizontalCenter: parent.horizontalCenter
spacing: 16
Repeater {
model: symSizesModel
DarkIcon {
size: model["size"]
anchors.bottom: parent.bottom
source: root.symIcons[3]
}
}
}
}
}
}
Row {
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: Kirigami.Units.smallSpacing
LightIcon {
size: 32
source: "qrc:/ikona.svg"
}
Label {
anchors.verticalCenter: parent.verticalCenter
color: root.rightColor
text: "Montage made with Ikona"
}
}
IconManipulator {
id: manip
}
function open() {
manip.prepMono(root.imageSource);
screenshotSavePicker.open()
}
FileDialog {
id: screenshotSavePicker
selectExisting: false
selectMultiple: false
selectFolder: false
onAccepted: {
screenRoot.grabToImage(function(result) {
res = result.saveToFile(screenshotSavePicker.fileUrl.toString().slice(7));
console.log(res);
});
}
nameFilters: [ "PNG screenshot files (*.png)" ]
}
}
\ No newline at end of file
import QtQuick 2.12
import QtQuick.Layouts 1.12
import org.kde.kirigami 2.5 as Kirigami
import QtQuick.Controls 2.5
import QtQuick.Dialogs 1.3
Item {
id: screenRoot
visible: false
width: 800
height: 400 + (400 * 1/3)
Item {
anchors.fill: parent
Row {
anchors.fill: parent
ColumnLayout {
spacing: 0
height: parent.height
width: parent.width / 2
Image {
Layout.fillHeight: true
Layout.fillWidth: true
source: "qrc:/bg.jpg"
Grid {
anchors.fill: parent
columns: 3
rows: 3
Repeater {
model: 4
GridRect {
LightIcon {
anchors.centerIn: parent
source: root.icons[index]
}
}
}
GridRect {
LightIcon {
anchors.centerIn: parent
source: root.imageSource
}
}
Repeater {
model: 4
GridRect {
LightIcon {
anchors.centerIn: parent
source: root.icons[index+4]
}
}
}
}
}
Rectangle {
height: 400 * 1/3
Layout.fillWidth: true
color: root.leftColor
Grid {
anchors.fill: parent
columns: 4
rows: 2
Repeater {
model: sizesModel
SmallGridRect {
LightIcon {
anchors.bottomMargin: -Kirigami.Units.largeSpacing
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
source: root.imageSource
size: model["size"]
}
}
}
Repeater {
model: sizesModel
SmallGridRect {
Label {
anchors.centerIn: parent
color: root.rightColor
text: model["size"]
}
}
}
}
Behavior on color {
ColorAnimation {
duration: Kirigami.Units.longDuration
}
}
}
}
ColumnLayout {
spacing: 0
height: parent.height
width: parent.width / 2
Image {
Layout.fillHeight: true
Layout.fillWidth: true
source: "qrc:/bg-dark.jpg"
Grid {
anchors.fill: parent
columns: 3
rows: 3
Repeater {
model: 4
GridRect {
DarkIcon {
anchors.centerIn: parent
source: root.icons[index]
}
}
}
GridRect {
DarkIcon {
anchors.centerIn: parent
source: root.imageSource
}
}
Repeater {
model: 4
GridRect {
DarkIcon {
anchors.centerIn: parent
source: root.icons[index+4]
}
}
}
}
}
Rectangle {
color: root.rightColor
height: 400 * 1/3
Layout.fillWidth: true
Grid {
anchors.fill: parent
columns: 4
rows: 2
Repeater {
model: sizesModel
SmallGridRect {
DarkIcon {
anchors.bottomMargin: -Kirigami.Units.largeSpacing
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
source: root.imageSource
size: model["size"]
}
}
}
Repeater {
model: sizesModel
SmallGridRect {
Label {
anchors.centerIn: parent
color: root.leftColor
text: model["size"]
}
}
}
}
Behavior on color {
ColorAnimation {
duration: Kirigami.Units.longDuration
}
}
}
}
}
}
Row {
anchors.top: parent.top
anchors.left: parent.left
anchors.margins: Kirigami.Units.smallSpacing
LightIcon {
size: 32
source: "qrc:/ikona.svg"
}
Label {
anchors.verticalCenter: parent.verticalCenter
color: root.rightColor
text: "Montage made with Ikona"
}
}
function open() {
screenshotSavePicker.open()
}
FileDialog {
id: screenshotSavePicker
selectExisting: false
selectMultiple: false
selectFolder: false
onAccepted: {
screenRoot.grabToImage(function(result) {
res = result.saveToFile(screenshotSavePicker.fileUrl.toString().slice(7));
console.log(res);
});
}
nameFilters: [ "PNG screenshot files (*.png)" ]
}
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ import Qt.labs.platform 1.1 as QNative
import QtWebEngine 1.1
Kirigami.ApplicationWindow {
Screenshot { id: colorShot }
MonochromaticScreenshot { id: monoShot }
id: root
visible: true
width: 800
......@@ -150,12 +152,16 @@ Kirigami.ApplicationWindow {
}
}
QNative.Menu {
title: "View"
title: "Screenshot"
QNative.MenuItem {
shortcut: StandardKey.NextChild
iconName: "exchange-positions"
text: swipe.currentIndex == 0 ? "Go to Small View" : "Return to Large View"
onTriggered: swipe.currentIndex == 0 ? swipe.incrementCurrentIndex() : swipe.decrementCurrentIndex()
iconName: "camera-photo-symbolic"
text: "Take Screenshot (Default View)"
onTriggered: colorShot.open()
}
QNative.MenuItem {
iconName: "camera-photo-symbolic"
text: "Take Screenshot (Small View)"
onTriggered: monoShot.open()
}
}
}
......@@ -344,6 +350,18 @@ Kirigami.ApplicationWindow {
}
}
},
Kirigami.Action {
iconSource: "camera-photo-symbolic"
text: "Export Montage"
Kirigami.Action {
text: "Default View"
onTriggered: colorShot.open()
}
Kirigami.Action {
text: "Small View"
onTriggered: monoShot.open()
}
},
Kirigami.Action {
iconSource: "palette-symbolic"
text: "View Palettes"
......
......@@ -9,5 +9,7 @@
<file>Spacer.qml</file>
<file>RowSpacer.qml</file>
<file>DropDown.qml</file>
<file>Screenshot.qml</file>
<file>MonochromaticScreenshot.qml</file>
</qresource>
</RCC>
......@@ -15,12 +15,44 @@
IconManipulator::IconManipulator(QObject *parent) : QObject(parent)
{
}
bool IconManipulator::prepMono(QString inputPath)
{
QString path;
if (inputPath.startsWith("file://")) {
path = inputPath.replace("file://", "");
} else {
path = inputPath;
}
QFile file(path);
if (QFile::exists("/tmp/ikonalight.svg"))
QFile::remove("/tmp/ikonalight.svg");
if (QFile::exists("/tmp/ikonadark.svg"))
QFile::remove("/tmp/ikonadark.svg");
file.copy("/tmp/ikonalight.svg");
file.copy("/tmp/ikonadark.svg");
this->injectStylesheet("file:///tmp/ikonalight.svg");
this->injectStylesheet("file:///tmp/ikonadark.svg");
this->classIcon("file:///tmp/ikonalight.svg");
this->classIcon("file:///tmp/ikonadark.svg");
this->toDark("file:///tmp/ikonalight.svg");
this->toLight("file:///tmp/ikonadark.svg");
return true;
}
bool IconManipulator::tidyIcon(QString inputPath)
{
QString path;
if (inputPath.startsWith("file://")) {
path = inputPath.replace("file://", "");
} else {
path = inputPath;
}
QStringList args = { "--set-precision=8", "--enable-viewboxing", "--enable-comment-stripping", "--remove-descriptive-elements", "--create-groups", "--strip-xml-space", "--nindent=4", path };
QProcess *proc = new QProcess();
......@@ -50,6 +82,8 @@ bool IconManipulator::classIcon(QString inputPath)
QString path;
if (inputPath.startsWith("file://")) {
path = inputPath.replace("file://", "");
} else {
path = inputPath;
}
QFile icon(path);
if (icon.open( QFile::ReadWrite ))
......@@ -78,6 +112,8 @@ bool IconManipulator::toDark(QString inputPath)
QString path;
if (inputPath.startsWith("file://")) {
path = inputPath.replace("file://", "");
} else {
path = inputPath;
}
QFile icon(path);
if (icon.open( QFile::ReadWrite ))
......
......@@ -10,6 +10,7 @@ public:
Q_INVOKABLE bool injectStylesheet(QString inputPath);
Q_INVOKABLE bool toDark(QString inputPath);
Q_INVOKABLE bool toLight(QString inputPath);
Q_INVOKABLE bool prepMono(QString inputPath);
signals:
......
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