trying to make a slide editing system

This commit is contained in:
Chris Cochrun 2024-04-17 15:58:25 -05:00
parent df956af536
commit defb73c0af
8 changed files with 220 additions and 128 deletions

View file

@ -124,141 +124,38 @@ Item {
} }
Rectangle { Presenter.LibraryItem {
id: slideLibraryPanel id: slideLibrary
Layout.preferredHeight: 40
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
color: Kirigami.Theme.backgroundColor
Controls.Label {
anchors.centerIn: parent
text: "Slides"
}
MouseArea {
anchors.fill: parent
onClicked: {
if (selectedLibrary == "slides")
selectedLibrary = ""
else
selectedLibrary = "slides"
console.log(selectedLibrary)
}
}
}
Rectangle {
id: slideLibraryHeader
z: 2
Layout.preferredHeight: 40
Layout.fillWidth: true Layout.fillWidth: true
/* width: parent.width */ Layout.preferredHeight: parent.height - 280
color: Kirigami.Theme.backgroundColor /* proxyModel: presProxyModel */
opacity: 1 innerModel: slideModel
state: "deselected" libraryType: "slide"
headerLabel: "Slides"
states: [ itemIcon: "x-office-presentation-symbolic"
State { /* itemSubtitle: model.path */
name: "deselected" count: innerModel.count
when: (selectedLibrary !== "slides") newItemFunction: (function() {
PropertyChanges { target: slideLibraryHeader if (!editMode)
Layout.preferredHeight: 0 editMode = true;
editSwitch(0, libraryType);
})
} }
},
State {
name: "selected"
when: (selectedLibrary == "slides")
PropertyChanges { target: slideLibraryHeader }
}
]
transitions: Transition { ListModel {
to: "*" id: slideModel
NumberAnimation { ListElement {
target: slideLibraryList title: "test"
properties: "preferredHeight" items: []
easing.type: Easing.OutCubic }
duration: 300
ListElement {
title: "Cool Slide"
items: []
} }
} }
Kirigami.ActionToolBar {
height: parent.height
width: parent.width
display: Controls.Button.IconOnly
visible: selectedLibrary == "slides"
actions: [
Kirigami.Action {
icon.name: "document-new"
text: "New Slide"
tooltip: "Add a new slide"
onTriggered: slideLibraryList.newSlide()
/* visible: selectedLibrary == "slides" */
},
Kirigami.Action {
displayComponent: Component {
Kirigami.SearchField {
id: searchField
height: parent.height
width: parent.width - 40
onAccepted: showPassiveNotification(searchField.text, 3000)
}
}
/* visible: selectedLibrary == "slides" */
}
]
Behavior on height {
NumberAnimation {
easing.type: Easing.OutCubic
duration: 300
}
}
}
}
ListView {
id: slideLibraryList
Layout.preferredHeight: parent.height - 240
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop
state: "deselected"
states: [
State {
name: "deselected"
when: (selectedLibrary !== "slides")
PropertyChanges { target: slideLibraryList
Layout.preferredHeight: 0
}
},
State {
name: "selected"
when: (selectedLibrary == "slides")
PropertyChanges { target: slideLibraryList }
}
]
transitions: Transition {
to: "*"
NumberAnimation {
target: slideLibraryList
properties: "preferredHeight"
easing.type: Easing.OutCubic
duration: 300
}
}
Controls.ScrollBar.vertical: Controls.ScrollBar {
/* anchors.right: videoLibraryList.right */
/* anchors.leftMargin: 10 */
/* anchors.left: videoLibraryList.right */
active: hovered || pressed
}
}
} }
DropArea { DropArea {

View file

@ -133,6 +133,12 @@ Controls.Page {
visible: false visible: false
anchors.fill: parent anchors.fill: parent
} }
Presenter.SlideEditor {
id: slideEditor
visible: false
anchors.fill: parent
}
} }
Presenter.Library { Presenter.Library {
@ -284,6 +290,7 @@ Controls.Page {
videoEditor.stop(); videoEditor.stop();
imageEditor.visible = false; imageEditor.visible = false;
presentationEditor.visible = false; presentationEditor.visible = false;
slideEditor.visible = false;
songEditor.visible = true; songEditor.visible = true;
songEditor.changeSong(item); songEditor.changeSong(item);
currentWindow = songEditor; currentWindow = songEditor;
@ -293,6 +300,7 @@ Controls.Page {
songEditor.visible = false; songEditor.visible = false;
imageEditor.visible = false; imageEditor.visible = false;
presentationEditor.visible = false; presentationEditor.visible = false;
slideEditor.visible = false;
videoEditor.visible = true; videoEditor.visible = true;
videoEditor.changeVideo(item); videoEditor.changeVideo(item);
currentWindow = videoEditor; currentWindow = videoEditor;
@ -303,6 +311,7 @@ Controls.Page {
videoEditor.stop(); videoEditor.stop();
songEditor.visible = false; songEditor.visible = false;
presentationEditor.visible = false; presentationEditor.visible = false;
slideEditor.visible = false;
imageEditor.visible = true; imageEditor.visible = true;
imageEditor.changeImage(item); imageEditor.changeImage(item);
currentWindow = imageEditor; currentWindow = imageEditor;
@ -313,10 +322,21 @@ Controls.Page {
videoEditor.stop(); videoEditor.stop();
songEditor.visible = false; songEditor.visible = false;
imageEditor.visible = false; imageEditor.visible = false;
slideEditor.visible = false;
presentationEditor.visible = true; presentationEditor.visible = true;
presentationEditor.changePresentation(item); presentationEditor.changePresentation(item);
currentWindow = presentationEditor; currentWindow = presentationEditor;
break; break;
case "slide" :
presentation.visible = false;
videoEditor.visible = false;
videoEditor.stop();
songEditor.visible = false;
imageEditor.visible = false;
presentationEditor.visible = false;
slideEditor.visible = true;
currentWindow = slideEditor;
break;
default: default:
videoEditor.visible = false; videoEditor.visible = false;
videoEditor.stop(); videoEditor.stop();

View file

@ -0,0 +1,155 @@
import QtQuick 2.15
import QtQuick.Controls 2.15 as Controls
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.15
import QtWebEngine 1.10
import org.kde.kirigami 2.13 as Kirigami
import "./" as Presenter
import org.presenter 1.0
Item {
id: root
property var creationObject
GridLayout {
id: mainLayout
anchors.fill: parent
columns: 2
rowSpacing: 5
columnSpacing: 0
Controls.ToolBar {
Layout.fillWidth: true
Layout.columnSpan: 2
id: toolbar
RowLayout {
anchors.fill: parent
Controls.TextField {
id: slideTitleField
implicitWidth: 300
placeholderText: "Title..."
text: "idk"
padding: 10
onEditingFinished: updateTitle(text);
background: Presenter.TextBackground {
control: fontBox
}
}
Controls.ComboBox {
id: alignBox
model: ["Left", "Center", "Right", "Justify"]
implicitWidth: 100
hoverEnabled: true
background: Presenter.TextBackground {
control: alignBox
}
indicator: Kirigami.Icon {
anchors {right: parent.right
verticalCenter: parent.verticalCenter
rightMargin: 2}
source: "arrow-down"
rotation: fontBox.down ? 180 : 0
color: fontBox.pressed ? Kirigami.Theme.focusColor : Kirigami.Theme.textColor
Behavior on rotation {
NumberAnimation {
easing.type: Easing.OutCubic
duration: 300
}
}
}
}
Controls.ToolSeparator {}
Item { Layout.fillWidth: true }
Controls.ToolSeparator {}
Controls.ToolButton {
text: "Text Box"
icon.name: "insert-text-frame"
hoverEnabled: true
onClicked: creationObject = "text"
}
Controls.ToolButton {
id: backgroundButton
text: "Image"
icon.name: "insert-image"
hoverEnabled: true
onClicked: creationObject = "image"
}
Controls.Popup {
id: backgroundType
x: backgroundButton.x
y: backgroundButton.y + backgroundButton.height + 20
modal: true
focus: true
dim: false
background: Rectangle {
Kirigami.Theme.colorSet: Kirigami.Theme.Tooltip
color: Kirigami.Theme.backgroundColor
radius: 10
border.color: Kirigami.Theme.activeBackgroundColor
border.width: 2
}
closePolicy: Controls.Popup.CloseOnEscape | Controls.Popup.CloseOnPressOutsideParent
ColumnLayout {
anchors.fill: parent
Controls.ToolButton {
Layout.fillHeight: true
Layout.fillWidth: true
text: "Slide"
icon.name: "emblem-presentations-symbolic"
/* onClicked: slideFileDialog.open() & backgroundType.close() */
}
Controls.ToolButton {
Layout.fillWidth: true
Layout.fillHeight: true
text: "Slide"
icon.name: "folder-pictures-symbolic"
/* onClicked: slideFileDialog.open() & backgroundType.close() */
}
}
}
}
}
Rectangle {
id: slideCanvas
Layout.fillHeight: true
Layout.fillWidth: true
/* Layout.minimumWidth: 300 */
Layout.alignment: Qt.AlignCenter
Layout.columnSpan: 2
color: "white"
MouseArea {
id: canvasMouse
anchors.fill: parent
}
}
}
function createObject(objectType) {
let component = Qt.createComponent("TextBox.qml");
if (component.status === Component.Ready || component.status === Component.Error) {
finishCreation(component);
} else {
component.statusChanged.connect(finishCreation);
}
}
function finishCreation(component) {
if (component.status === Component.Ready) {
var image = component.createObject(slideCanvas, {"x": 100, "y": 100});
if (image === null) {
console.log("Error creating image");
}
} else if (component.status === Component.Error) {
console.log("Error loading component:", component.errorString());
}
}
}

View file

@ -0,0 +1,13 @@
import QtQuick 2.15
import QtQuick.Controls 2.15 as Controls
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.15
import org.kde.kirigami 2.13 as Kirigami
import "./" as Presenter
import org.presenter 1.0
Controls.TextArea {
id: root
padding: 10
textFormat: TextEdit.PlainText
}

View file

@ -14,6 +14,7 @@
<file>qml/presenter/VideoEditor.qml</file> <file>qml/presenter/VideoEditor.qml</file>
<file>qml/presenter/ImageEditor.qml</file> <file>qml/presenter/ImageEditor.qml</file>
<file>qml/presenter/PresentationEditor.qml</file> <file>qml/presenter/PresentationEditor.qml</file>
<file>qml/presenter/SlideEditor.qml</file>
<file>qml/presenter/Slide.qml</file> <file>qml/presenter/Slide.qml</file>
<file>qml/presenter/SlidesListView.qml</file> <file>qml/presenter/SlidesListView.qml</file>
<file>qml/presenter/SongEditorSlideList.qml</file> <file>qml/presenter/SongEditorSlideList.qml</file>
@ -26,6 +27,7 @@
<file>qml/presenter/RangedSlider.qml</file> <file>qml/presenter/RangedSlider.qml</file>
<file>qml/presenter/NewVideo.qml</file> <file>qml/presenter/NewVideo.qml</file>
<file>qml/presenter/TextBackground.qml</file> <file>qml/presenter/TextBackground.qml</file>
<file>qml/presenter/TextBox.qml</file>
<file>qml/presenter/LoadingSpinner.qml</file> <file>qml/presenter/LoadingSpinner.qml</file>
<file>assets/parallel.jpg</file> <file>assets/parallel.jpg</file>
<file>assets/black.jpg</file> <file>assets/black.jpg</file>

1
src/rust/slides/mod.rs Normal file
View file

@ -0,0 +1 @@
pub use slide;

4
src/rust/slides/slide.rs Normal file
View file

@ -0,0 +1,4 @@
pub struct Slide {}
#[cxx_qt::bridge]
mod slide {}

View file

@ -8,7 +8,7 @@ use tracing_subscriber::{
EnvFilter, EnvFilter,
}; };
use self::utilities::QString; use self::utilities::{QString, QUrl};
mod db { mod db {
use diesel::{Connection, SqliteConnection}; use diesel::{Connection, SqliteConnection};