initial port to cxx_qt 6.0
This commit is contained in:
parent
62daf316a3
commit
744481587f
31 changed files with 1992 additions and 1860 deletions
|
@ -60,7 +60,6 @@ endif()
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
set(CRATE liblumina)
|
set(CRATE liblumina)
|
||||||
|
|
||||||
# Corrosion creates a CMake target with the same name as the crate.
|
# Corrosion creates a CMake target with the same name as the crate.
|
||||||
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES ${CRATE})
|
corrosion_import_crate(MANIFEST_PATH Cargo.toml CRATES ${CRATE})
|
||||||
|
|
||||||
|
@ -75,33 +74,35 @@ corrosion_set_env_vars(${CRATE}
|
||||||
"QMAKE=${QMAKE}"
|
"QMAKE=${QMAKE}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_library(${APP_NAME}_lib INTERFACE)
|
||||||
# Include the headers generated by the Rust library's build script. Each
|
# Include the headers generated by the Rust library's build script. Each
|
||||||
# crate gets its own subdirectory under CXXQT_EXPORT_DIR. This allows you
|
# crate gets its own subdirectory under CXXQT_EXPORT_DIR. This allows you
|
||||||
# to include headers generated by multiple crates without risk of one crate
|
# to include headers generated by multiple crates without risk of one crate
|
||||||
# overwriting another's files.
|
# overwriting another's files.
|
||||||
target_include_directories(${CRATE} INTERFACE "${CXXQT_EXPORT_DIR}/${CRATE}")
|
target_include_directories(${APP_NAME}_lib INTERFACE "${CXXQT_EXPORT_DIR}/${CRATE}")
|
||||||
|
|
||||||
# Link the Rust INTERFACE library target to Qt. Do this on the library target
|
# Link the Rust INTERFACE library target to Qt. Do this on the library target
|
||||||
# rather than the main executable. This way, CMake targets besides the main
|
# rather than the main executable. This way, CMake targets besides the main
|
||||||
# executable which link the Rust library, for example tests, will also link Qt.
|
# executable which link the Rust library, for example tests, will also link Qt.
|
||||||
target_link_libraries(${CRATE} INTERFACE
|
target_link_libraries(${APP_NAME}_lib INTERFACE
|
||||||
Qt5::Quick
|
"$<LINK_LIBRARY:WHOLE_ARCHIVE,${CRATE}-static>"
|
||||||
Qt5::Qml
|
Qt5::Quick
|
||||||
Qt5::Gui
|
Qt5::Qml
|
||||||
Qt5::QuickControls2
|
Qt5::Gui
|
||||||
Qt5::Widgets
|
Qt5::QuickControls2
|
||||||
Qt5::Sql
|
Qt5::Widgets
|
||||||
Qt5::X11Extras
|
Qt5::Sql
|
||||||
Qt5::WebEngine
|
Qt5::X11Extras
|
||||||
KF5::Kirigami2
|
Qt5::WebEngine
|
||||||
KF5::I18n
|
KF5::Kirigami2
|
||||||
KF5::Archive
|
KF5::I18n
|
||||||
KF5::CoreAddons
|
KF5::Archive
|
||||||
mpv
|
KF5::CoreAddons
|
||||||
|
mpv
|
||||||
)
|
)
|
||||||
|
|
||||||
# Link to the Rust library
|
# Link to the Rust library
|
||||||
target_link_libraries(${APP_NAME} PRIVATE ${CRATE})
|
target_link_libraries(${APP_NAME} PRIVATE ${APP_NAME}_lib)
|
||||||
|
|
||||||
# If we are using a statically linked Qt then we need to import any qml plugins
|
# If we are using a statically linked Qt then we need to import any qml plugins
|
||||||
qt_import_qml_plugins(${APP_NAME})
|
qt_import_qml_plugins(${APP_NAME})
|
||||||
|
|
16
TODO.org
16
TODO.org
|
@ -5,17 +5,21 @@
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
* Tasks [0%] [0/0]
|
* Tasks [0%] [0/0]
|
||||||
** TODO Port to CXX-QT 6.0 [37%] [3/8]
|
** TODO Port to CXX-QT 6.0 [90%] [9/10]
|
||||||
[[file:~/dev/lumina/src/rust/lib.rs]]
|
[[file:~/dev/lumina/src/rust/lib.rs]]
|
||||||
|
|
||||||
*** DONE image_model.rs
|
*** DONE image_model.rs
|
||||||
*** DONE video_model.rs
|
*** DONE video_model.rs
|
||||||
*** DONE presentation_model.rs
|
*** DONE presentation_model.rs
|
||||||
*** TODO songs/song_model.rs
|
*** DONE songs/song_model.rs
|
||||||
*** TODO songs/song_editor.rs
|
*** DONE songs/song_editor.rs
|
||||||
*** TODO ytdl.rs
|
*** DONE ytdl.rs
|
||||||
*** TODO utils.rs
|
*** DONE utils.rs
|
||||||
*** TODO obs.rs
|
*** DONE obs.rs
|
||||||
|
*** DONE 18000 errors.....
|
||||||
|
round 1 of errors done.....
|
||||||
|
*** TODO 237 errors...
|
||||||
|
now round 2
|
||||||
** TODO Write a function to handle switching to the next fragment in revealjs
|
** TODO Write a function to handle switching to the next fragment in revealjs
|
||||||
[[file:~/dev/lumina/src/qml/presenter/Slide.qml::WebEngineView {]]
|
[[file:~/dev/lumina/src/qml/presenter/Slide.qml::WebEngineView {]]
|
||||||
|
|
||||||
|
|
12
flake.lock
generated
12
flake.lock
generated
|
@ -38,11 +38,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699343069,
|
"lastModified": 1701040486,
|
||||||
"narHash": "sha256-s7BBhyLA6MI6FuJgs4F/SgpntHBzz40/qV0xLPW6A1Q=",
|
"narHash": "sha256-vawYwoHA5CwvjfqaT3A5CT9V36Eq43gxdwpux32Qkjw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "ec750fd01963ab6b20ee1f0cb488754e8036d89d",
|
"rev": "45827faa2132b8eade424f6bdd48d8828754341a",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -52,11 +52,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1699099776,
|
"lastModified": 1700794826,
|
||||||
"narHash": "sha256-X09iKJ27mGsGambGfkKzqvw5esP1L/Rf8H3u3fCqIiU=",
|
"narHash": "sha256-RyJTnTNKhO0yqRpDISk03I/4A67/dp96YRxc86YOPgU=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "85f1ba3e51676fa8cc604a3d863d729026a6b8eb",
|
"rev": "5a09cb4b393d58f9ed0d9ca1555016a8543c2ac8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
3
justfile
3
justfile
|
@ -8,3 +8,6 @@ run:
|
||||||
RUST_LOG=debug ./bld/bin/lumina
|
RUST_LOG=debug ./bld/bin/lumina
|
||||||
lint:
|
lint:
|
||||||
cargo clippy
|
cargo clippy
|
||||||
|
clean:
|
||||||
|
cargo clean
|
||||||
|
rm -rf bld/
|
|
@ -27,11 +27,11 @@
|
||||||
#include "cxx-qt-gen/slide_model.cxxqt.h"
|
#include "cxx-qt-gen/slide_model.cxxqt.h"
|
||||||
#include "cxx-qt-gen/service_item_model.cxxqt.h"
|
#include "cxx-qt-gen/service_item_model.cxxqt.h"
|
||||||
|
|
||||||
ServiceItemModel::ServiceItemModel(QObject *parent)
|
ServiceItemModelCpp::ServiceItemModelCpp(QObject *parent)
|
||||||
: QAbstractListModel(parent) {
|
: QAbstractListModel(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int ServiceItemModel::rowCount(const QModelIndex &parent) const {
|
int ServiceItemModelCpp::rowCount(const QModelIndex &parent) const {
|
||||||
// For list models only the root node (an invalid parent) should return the
|
// For list models only the root node (an invalid parent) should return the
|
||||||
// list's size. For all other (valid) parents, rowCount() should return 0 so
|
// list's size. For all other (valid) parents, rowCount() should return 0 so
|
||||||
// that it does not become a tree model.
|
// that it does not become a tree model.
|
||||||
|
@ -42,7 +42,7 @@ int ServiceItemModel::rowCount(const QModelIndex &parent) const {
|
||||||
return m_items.size();
|
return m_items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant ServiceItemModel::data(const QModelIndex &index, int role) const {
|
QVariant ServiceItemModelCpp::data(const QModelIndex &index, int role) const {
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ QVariant ServiceItemModel::data(const QModelIndex &index, int role) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> ServiceItemModel::roleNames() const {
|
QHash<int, QByteArray> ServiceItemModelCpp::roleNames() const {
|
||||||
static QHash<int, QByteArray> mapping{{NameRole, "name"},
|
static QHash<int, QByteArray> mapping{{NameRole, "name"},
|
||||||
{TypeRole, "type"},
|
{TypeRole, "type"},
|
||||||
{BackgroundRole, "background"},
|
{BackgroundRole, "background"},
|
||||||
|
@ -94,7 +94,7 @@ QHash<int, QByteArray> ServiceItemModel::roleNames() const {
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::setData(const QModelIndex &index, const QVariant &value,
|
bool ServiceItemModelCpp::setData(const QModelIndex &index, const QVariant &value,
|
||||||
int role) {
|
int role) {
|
||||||
|
|
||||||
ServiceItem *item = m_items[index.row()];
|
ServiceItem *item = m_items[index.row()];
|
||||||
|
@ -182,14 +182,14 @@ bool ServiceItemModel::setData(const QModelIndex &index, const QVariant &value,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags ServiceItemModel::flags(const QModelIndex &index) const {
|
Qt::ItemFlags ServiceItemModelCpp::flags(const QModelIndex &index) const {
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
return Qt::ItemIsEditable; // FIXME: Implement me!
|
return Qt::ItemIsEditable; // FIXME: Implement me!
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceItemModel::addItem(ServiceItem *item) {
|
void ServiceItemModelCpp::addItem(ServiceItem *item) {
|
||||||
const int index = m_items.size();
|
const int index = m_items.size();
|
||||||
qDebug() << index;
|
qDebug() << index;
|
||||||
// foreach (item, m_items) {
|
// foreach (item, m_items) {
|
||||||
|
@ -200,14 +200,14 @@ void ServiceItemModel::addItem(ServiceItem *item) {
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceItemModel::insertItem(const int &index, ServiceItem *item) {
|
void ServiceItemModelCpp::insertItem(const int &index, ServiceItem *item) {
|
||||||
beginInsertRows(this->index(index).parent(), index, index);
|
beginInsertRows(this->index(index).parent(), index, index);
|
||||||
m_items.insert(index, item);
|
m_items.insert(index, item);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
qDebug() << "Success";
|
qDebug() << "Success";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceItemModel::addItem(const QString &name, const QString &type,
|
void ServiceItemModelCpp::addItem(const QString &name, const QString &type,
|
||||||
const QString &background, const QString &backgroundType,
|
const QString &background, const QString &backgroundType,
|
||||||
const QStringList &text, const QString &audio,
|
const QStringList &text, const QString &audio,
|
||||||
const QString &font, const int &fontSize,
|
const QString &font, const int &fontSize,
|
||||||
|
@ -248,7 +248,7 @@ void ServiceItemModel::addItem(const QString &name, const QString &type,
|
||||||
qDebug() << "#################################";
|
qDebug() << "#################################";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceItemModel::insertItem(const int &index, const QString &name,
|
void ServiceItemModelCpp::insertItem(const int &index, const QString &name,
|
||||||
const QString &type,const QString &background,
|
const QString &type,const QString &background,
|
||||||
const QString &backgroundType,const QStringList &text,
|
const QString &backgroundType,const QStringList &text,
|
||||||
const QString &audio, const QString &font,
|
const QString &audio, const QString &font,
|
||||||
|
@ -289,13 +289,13 @@ void ServiceItemModel::insertItem(const int &index, const QString &name,
|
||||||
qDebug() << "#################################";
|
qDebug() << "#################################";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceItemModel::removeItem(int index) {
|
void ServiceItemModelCpp::removeItem(int index) {
|
||||||
beginRemoveRows(QModelIndex(), index, index);
|
beginRemoveRows(QModelIndex(), index, index);
|
||||||
m_items.removeAt(index);
|
m_items.removeAt(index);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceItemModel::removeItems() {
|
void ServiceItemModelCpp::removeItems() {
|
||||||
for (int i = m_items.length() - 1; i > -1; i--) {
|
for (int i = m_items.length() - 1; i > -1; i--) {
|
||||||
QModelIndex idx = index(i);
|
QModelIndex idx = index(i);
|
||||||
ServiceItem *item = m_items[idx.row()];
|
ServiceItem *item = m_items[idx.row()];
|
||||||
|
@ -313,7 +313,7 @@ void ServiceItemModel::removeItems() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::moveRows(int sourceIndex, int destIndex, int count) {
|
bool ServiceItemModelCpp::moveRows(int sourceIndex, int destIndex, int count) {
|
||||||
qDebug() << sourceIndex;
|
qDebug() << sourceIndex;
|
||||||
qDebug() << destIndex;
|
qDebug() << destIndex;
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ bool ServiceItemModel::moveRows(int sourceIndex, int destIndex, int count) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::moveDown(int id) {
|
bool ServiceItemModelCpp::moveDown(int id) {
|
||||||
qDebug() << index(id).row();
|
qDebug() << index(id).row();
|
||||||
qDebug() << index(id + 1).row();
|
qDebug() << index(id + 1).row();
|
||||||
QModelIndex parent = index(id).parent();
|
QModelIndex parent = index(id).parent();
|
||||||
|
@ -371,7 +371,7 @@ bool ServiceItemModel::moveDown(int id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::moveUp(int id) {
|
bool ServiceItemModelCpp::moveUp(int id) {
|
||||||
qDebug() << index(id).row();
|
qDebug() << index(id).row();
|
||||||
qDebug() << index(id - 1).row();
|
qDebug() << index(id - 1).row();
|
||||||
QModelIndex parent = index(id).parent();
|
QModelIndex parent = index(id).parent();
|
||||||
|
@ -394,7 +394,7 @@ bool ServiceItemModel::moveUp(int id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::moveRowsRust(int source, int dest, int count, ServiceItemMod *rustModel) {
|
bool ServiceItemModelCpp::moveRowsRust(int source, int dest, int count, ServiceItemModel *rustModel) {
|
||||||
const QModelIndex parent = index(source).parent();
|
const QModelIndex parent = index(source).parent();
|
||||||
const bool isMoveDown = dest > source;
|
const bool isMoveDown = dest > source;
|
||||||
|
|
||||||
|
@ -409,12 +409,12 @@ bool ServiceItemModel::moveRowsRust(int source, int dest, int count, ServiceItem
|
||||||
return moved;
|
return moved;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap ServiceItemModel::getRust(int index, ServiceItemMod *rustModel) const {
|
QVariantMap ServiceItemModelCpp::getRust(int index, ServiceItemModel *rustModel) const {
|
||||||
QVariantMap item = rustModel->getItem(index);
|
QVariantMap item = rustModel->getItem(index);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap ServiceItemModel::getItem(int index) const {
|
QVariantMap ServiceItemModelCpp::getItem(int index) const {
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
const QModelIndex idx = this->index(index,0);
|
const QModelIndex idx = this->index(index,0);
|
||||||
// qDebug() << idx;
|
// qDebug() << idx;
|
||||||
|
@ -431,7 +431,7 @@ QVariantMap ServiceItemModel::getItem(int index) const {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList ServiceItemModel::getItems() {
|
QVariantList ServiceItemModelCpp::getItems() {
|
||||||
QVariantList data;
|
QVariantList data;
|
||||||
ServiceItem * item;
|
ServiceItem * item;
|
||||||
foreach (item, m_items) {
|
foreach (item, m_items) {
|
||||||
|
@ -457,7 +457,7 @@ QVariantList ServiceItemModel::getItems() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::select(int id) {
|
bool ServiceItemModelCpp::select(int id) {
|
||||||
for (int i = 0; i < m_items.length(); i++) {
|
for (int i = 0; i < m_items.length(); i++) {
|
||||||
QModelIndex idx = index(i);
|
QModelIndex idx = index(i);
|
||||||
ServiceItem *item = m_items[idx.row()];
|
ServiceItem *item = m_items[idx.row()];
|
||||||
|
@ -479,7 +479,7 @@ bool ServiceItemModel::select(int id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::selectItems(QVariantList items) {
|
bool ServiceItemModelCpp::selectItems(QVariantList items) {
|
||||||
qDebug() << "Let's select some items!";
|
qDebug() << "Let's select some items!";
|
||||||
for (int i = 0; i < m_items.length(); i++) {
|
for (int i = 0; i < m_items.length(); i++) {
|
||||||
QModelIndex idx = index(i);
|
QModelIndex idx = index(i);
|
||||||
|
@ -508,7 +508,7 @@ bool ServiceItemModel::selectItems(QVariantList items) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::activate(int id) {
|
bool ServiceItemModelCpp::activate(int id) {
|
||||||
QModelIndex idx = index(id);
|
QModelIndex idx = index(id);
|
||||||
ServiceItem *item = m_items[idx.row()];
|
ServiceItem *item = m_items[idx.row()];
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ bool ServiceItemModel::activate(int id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::deactivate(int id) {
|
bool ServiceItemModelCpp::deactivate(int id) {
|
||||||
QModelIndex idx = index(id);
|
QModelIndex idx = index(id);
|
||||||
ServiceItem *item = m_items[idx.row()];
|
ServiceItem *item = m_items[idx.row()];
|
||||||
|
|
||||||
|
@ -544,7 +544,7 @@ bool ServiceItemModel::deactivate(int id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::save(QUrl file) {
|
bool ServiceItemModelCpp::save(QUrl file) {
|
||||||
qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
|
qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
|
||||||
qDebug() << "Saving...";
|
qDebug() << "Saving...";
|
||||||
qDebug() << "File path is: " << file.toString();
|
qDebug() << "File path is: " << file.toString();
|
||||||
|
@ -661,7 +661,7 @@ bool ServiceItemModel::save(QUrl file) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::load(QUrl file) {
|
bool ServiceItemModelCpp::load(QUrl file) {
|
||||||
qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
|
qDebug() << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
|
||||||
qDebug() << "Loading...";
|
qDebug() << "Loading...";
|
||||||
qDebug() << "File path is: " << file.toString();
|
qDebug() << "File path is: " << file.toString();
|
||||||
|
@ -780,14 +780,14 @@ bool ServiceItemModel::load(QUrl file) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServiceItemModel::clearAll() {
|
void ServiceItemModelCpp::clearAll() {
|
||||||
for (int i = m_items.size(); i >= 0; i--) {
|
for (int i = m_items.size(); i >= 0; i--) {
|
||||||
removeItem(i);
|
removeItem(i);
|
||||||
}
|
}
|
||||||
emit allRemoved();
|
emit allRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceItemModel::loadLastSaved() {
|
bool ServiceItemModelCpp::loadLastSaved() {
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
return load(settings.value("lastSaveFile").toUrl());
|
return load(settings.value("lastSaveFile").toUrl());
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
|
|
||||||
#include "cxx-qt-gen/service_item_model.cxxqt.h"
|
#include "cxx-qt-gen/service_item_model.cxxqt.h"
|
||||||
|
|
||||||
class ServiceItemModel : public QAbstractListModel {
|
class ServiceItemModelCpp : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit ServiceItemModel(QObject *parent = nullptr);
|
explicit ServiceItemModelCpp(QObject *parent = nullptr);
|
||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
NameRole = Qt::UserRole,
|
NameRole = Qt::UserRole,
|
||||||
|
@ -66,7 +66,7 @@ public:
|
||||||
Q_INVOKABLE void removeItem(int index);
|
Q_INVOKABLE void removeItem(int index);
|
||||||
Q_INVOKABLE void removeItems();
|
Q_INVOKABLE void removeItems();
|
||||||
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
|
Q_INVOKABLE bool moveRows(int sourceIndex, int destIndex, int count);
|
||||||
Q_INVOKABLE bool moveRowsRust(int source, int dest, int count, ServiceItemMod *rustModel);
|
Q_INVOKABLE bool moveRowsRust(int source, int dest, int count, ServiceItemModel *rustModel);
|
||||||
Q_INVOKABLE bool moveDown(int index);
|
Q_INVOKABLE bool moveDown(int index);
|
||||||
Q_INVOKABLE bool moveUp(int index);
|
Q_INVOKABLE bool moveUp(int index);
|
||||||
Q_INVOKABLE bool select(int id);
|
Q_INVOKABLE bool select(int id);
|
||||||
|
@ -74,7 +74,7 @@ public:
|
||||||
Q_INVOKABLE bool activate(int id);
|
Q_INVOKABLE bool activate(int id);
|
||||||
Q_INVOKABLE bool deactivate(int id);
|
Q_INVOKABLE bool deactivate(int id);
|
||||||
Q_INVOKABLE QVariantMap getItem(int index) const;
|
Q_INVOKABLE QVariantMap getItem(int index) const;
|
||||||
Q_INVOKABLE QVariantMap getRust(int index, ServiceItemMod *rustModel) const;
|
Q_INVOKABLE QVariantMap getRust(int index, ServiceItemModel *rustModel) const;
|
||||||
Q_INVOKABLE QVariantList getItems();
|
Q_INVOKABLE QVariantList getItems();
|
||||||
Q_INVOKABLE void clearAll();
|
Q_INVOKABLE void clearAll();
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
const QDir writeDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||||
|
|
||||||
SlideModel::SlideModel(QObject *parent)
|
SlideModelCpp::SlideModelCpp(QObject *parent)
|
||||||
: QAbstractListModel(parent) {
|
: QAbstractListModel(parent) {
|
||||||
// if () {
|
// if () {
|
||||||
// addItem(new Slide("10,000 Reasons", "song",
|
// addItem(new Slide("10,000 Reasons", "song",
|
||||||
|
@ -43,7 +43,7 @@ SlideModel::SlideModel(QObject *parent)
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
int SlideModel::rowCount(const QModelIndex &parent) const {
|
int SlideModelCpp::rowCount(const QModelIndex &parent) const {
|
||||||
// For list models only the root node (an invalid parent) should return the
|
// For list models only the root node (an invalid parent) should return the
|
||||||
// list's size. For all other (valid) parents, rowCount() should return 0 so
|
// list's size. For all other (valid) parents, rowCount() should return 0 so
|
||||||
// that it does not become a tree model.
|
// that it does not become a tree model.
|
||||||
|
@ -54,7 +54,7 @@ int SlideModel::rowCount(const QModelIndex &parent) const {
|
||||||
return m_items.size();
|
return m_items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant SlideModel::data(const QModelIndex &index, int role) const {
|
QVariant SlideModelCpp::data(const QModelIndex &index, int role) const {
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ QVariant SlideModel::data(const QModelIndex &index, int role) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> SlideModel::roleNames() const {
|
QHash<int, QByteArray> SlideModelCpp::roleNames() const {
|
||||||
static QHash<int, QByteArray> mapping {
|
static QHash<int, QByteArray> mapping {
|
||||||
{TextRole, "text"},
|
{TextRole, "text"},
|
||||||
{TypeRole, "type"},
|
{TypeRole, "type"},
|
||||||
|
@ -117,7 +117,7 @@ QHash<int, QByteArray> SlideModel::roleNames() const {
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SlideModel::setData(const QModelIndex &index, const QVariant &value,
|
bool SlideModelCpp::setData(const QModelIndex &index, const QVariant &value,
|
||||||
int role) {
|
int role) {
|
||||||
|
|
||||||
Slide *item = m_items[index.row()];
|
Slide *item = m_items[index.row()];
|
||||||
|
@ -223,14 +223,14 @@ bool SlideModel::setData(const QModelIndex &index, const QVariant &value,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags SlideModel::flags(const QModelIndex &index) const {
|
Qt::ItemFlags SlideModelCpp::flags(const QModelIndex &index) const {
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return Qt::NoItemFlags;
|
return Qt::NoItemFlags;
|
||||||
|
|
||||||
return Qt::ItemIsEditable; // FIXME: Implement me!
|
return Qt::ItemIsEditable; // FIXME: Implement me!
|
||||||
}
|
}
|
||||||
|
|
||||||
// int SlideModel::index(int row, int column, const QModelIndex &parent) {
|
// int SlideyMod::index(int row, int column, const QModelIndex &parent) {
|
||||||
// if (!hasIndex(row, column, parent))
|
// if (!hasIndex(row, column, parent))
|
||||||
// return QModelIndex();
|
// return QModelIndex();
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ Qt::ItemFlags SlideModel::flags(const QModelIndex &index) const {
|
||||||
// return QModelIndex();
|
// return QModelIndex();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
void SlideModel::addItem(Slide *item) {
|
void SlideModelCpp::addItem(Slide *item) {
|
||||||
const int index = m_items.size();
|
const int index = m_items.size();
|
||||||
qDebug() << index;
|
qDebug() << index;
|
||||||
// foreach (item, m_items) {
|
// foreach (item, m_items) {
|
||||||
|
@ -258,14 +258,14 @@ void SlideModel::addItem(Slide *item) {
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::insertItem(const int &index, Slide *item) {
|
void SlideModelCpp::insertItem(const int &index, Slide *item) {
|
||||||
beginInsertRows(this->index(index).parent(), index, index);
|
beginInsertRows(this->index(index).parent(), index, index);
|
||||||
m_items.insert(index, item);
|
m_items.insert(index, item);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
qDebug() << "Success";
|
qDebug() << "Success";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::addItem(const QString &text, const QString &type,
|
void SlideModelCpp::addItem(const QString &text, const QString &type,
|
||||||
const QString &imageBackground, const QString &videoBackground,
|
const QString &imageBackground, const QString &videoBackground,
|
||||||
const QString &audio,
|
const QString &audio,
|
||||||
const QString &font, const int &fontSize,
|
const QString &font, const int &fontSize,
|
||||||
|
@ -286,7 +286,7 @@ void SlideModel::addItem(const QString &text, const QString &type,
|
||||||
qDebug() << "#################################";
|
qDebug() << "#################################";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::insertItem(const int &index,
|
void SlideModelCpp::insertItem(const int &index,
|
||||||
const QString &type, const QString &imageBackground,
|
const QString &type, const QString &imageBackground,
|
||||||
const QString &videoBackground, const QString &text,
|
const QString &videoBackground, const QString &text,
|
||||||
const QString &audio, const QString &font,
|
const QString &audio, const QString &font,
|
||||||
|
@ -307,13 +307,13 @@ void SlideModel::insertItem(const int &index,
|
||||||
qDebug() << "#################################";
|
qDebug() << "#################################";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::removeItem(int index) {
|
void SlideModelCpp::removeItem(int index) {
|
||||||
beginRemoveRows(QModelIndex(), index, index);
|
beginRemoveRows(QModelIndex(), index, index);
|
||||||
m_items.removeAt(index);
|
m_items.removeAt(index);
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::removeServiceItem(const int &index, const ServiceItem &item) {
|
void SlideModelCpp::removeServiceItem(const int &index, const ServiceItem &item) {
|
||||||
qDebug() << "Need to remove serviceItem:"
|
qDebug() << "Need to remove serviceItem:"
|
||||||
<< item.name()
|
<< item.name()
|
||||||
<< "with"
|
<< "with"
|
||||||
|
@ -345,7 +345,7 @@ void SlideModel::removeServiceItem(const int &index, const ServiceItem &item) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::removeItems() {
|
void SlideModelCpp::removeItems() {
|
||||||
for (int i = m_items.length() - 1; i > -1; i--) {
|
for (int i = m_items.length() - 1; i > -1; i--) {
|
||||||
QModelIndex idx = index(i);
|
QModelIndex idx = index(i);
|
||||||
Slide *item = m_items[idx.row()];
|
Slide *item = m_items[idx.row()];
|
||||||
|
@ -358,7 +358,7 @@ void SlideModel::removeItems() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SlideModel::moveRows(int sourceIndex, int destIndex, int count) {
|
bool SlideModelCpp::moveRows(int sourceIndex, int destIndex, int count) {
|
||||||
qDebug() << index(sourceIndex).row();
|
qDebug() << index(sourceIndex).row();
|
||||||
qDebug() << index(destIndex).row();
|
qDebug() << index(destIndex).row();
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ bool SlideModel::moveRows(int sourceIndex, int destIndex, int count) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SlideModel::moveDown(int id) {
|
bool SlideModelCpp::moveDown(int id) {
|
||||||
qDebug() << index(id).row();
|
qDebug() << index(id).row();
|
||||||
qDebug() << index(id + 1).row();
|
qDebug() << index(id + 1).row();
|
||||||
QModelIndex parent = index(id).parent();
|
QModelIndex parent = index(id).parent();
|
||||||
|
@ -413,7 +413,7 @@ bool SlideModel::moveDown(int id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SlideModel::moveUp(int id) {
|
bool SlideModelCpp::moveUp(int id) {
|
||||||
qDebug() << index(id).row();
|
qDebug() << index(id).row();
|
||||||
qDebug() << index(id - 1).row();
|
qDebug() << index(id - 1).row();
|
||||||
QModelIndex parent = index(id).parent();
|
QModelIndex parent = index(id).parent();
|
||||||
|
@ -436,7 +436,7 @@ bool SlideModel::moveUp(int id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap SlideModel::getItem(int index) const {
|
QVariantMap SlideModelCpp::getItem(int index) const {
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
const QModelIndex idx = this->index(index,0);
|
const QModelIndex idx = this->index(index,0);
|
||||||
// qDebug() << idx;
|
// qDebug() << idx;
|
||||||
|
@ -453,13 +453,13 @@ QVariantMap SlideModel::getItem(int index) const {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap SlideModel::getItemRust(int index, SlideyMod *slidemodel) const {
|
QVariantMap SlideModelCpp::getItemRust(int index, SlideModel *slidemodel) const {
|
||||||
QVariantMap data = slidemodel->getItem(index);
|
QVariantMap data = slidemodel->getItem(index);
|
||||||
qDebug() << data;
|
qDebug() << data;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList SlideModel::getItems() {
|
QVariantList SlideModelCpp::getItems() {
|
||||||
QVariantList data;
|
QVariantList data;
|
||||||
Slide * item;
|
Slide * item;
|
||||||
foreach (item, m_items) {
|
foreach (item, m_items) {
|
||||||
|
@ -486,7 +486,7 @@ QVariantList SlideModel::getItems() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SlideModel::select(int id) {
|
bool SlideModelCpp::select(int id) {
|
||||||
for (int i = 0; i < m_items.length(); i++) {
|
for (int i = 0; i < m_items.length(); i++) {
|
||||||
QModelIndex idx = index(i);
|
QModelIndex idx = index(i);
|
||||||
Slide *item = m_items[idx.row()];
|
Slide *item = m_items[idx.row()];
|
||||||
|
@ -508,7 +508,7 @@ bool SlideModel::select(int id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SlideModel::activate(int id) {
|
bool SlideModelCpp::activate(int id) {
|
||||||
QModelIndex idx = index(id);
|
QModelIndex idx = index(id);
|
||||||
Slide *item = m_items[idx.row()];
|
Slide *item = m_items[idx.row()];
|
||||||
qDebug() << item->type();
|
qDebug() << item->type();
|
||||||
|
@ -534,7 +534,7 @@ bool SlideModel::activate(int id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SlideModel::deactivate(int id) {
|
bool SlideModelCpp::deactivate(int id) {
|
||||||
QModelIndex idx = index(id);
|
QModelIndex idx = index(id);
|
||||||
Slide *item = m_items[idx.row()];
|
Slide *item = m_items[idx.row()];
|
||||||
|
|
||||||
|
@ -546,13 +546,13 @@ bool SlideModel::deactivate(int id) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::clearAll() {
|
void SlideModelCpp::clearAll() {
|
||||||
for (int i = m_items.size(); i >= 0; i--) {
|
for (int i = m_items.size(); i >= 0; i--) {
|
||||||
removeItem(i);
|
removeItem(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SlideModel::findSlideIdFromServItm(int index) {
|
int SlideModelCpp::findSlideIdFromServItm(int index) {
|
||||||
for (int i = 0; i < m_items.size(); i++) {
|
for (int i = 0; i < m_items.size(); i++) {
|
||||||
Slide *itm = m_items[i];
|
Slide *itm = m_items[i];
|
||||||
if (itm->serviceItemId() == index) {
|
if (itm->serviceItemId() == index) {
|
||||||
|
@ -562,7 +562,7 @@ int SlideModel::findSlideIdFromServItm(int index) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::addItemFromService(const int &index, const ServiceItem &item) {
|
void SlideModelCpp::addItemFromService(const int &index, const ServiceItem &item) {
|
||||||
qDebug() << "***INSERTING SLIDE FROM SERVICEITEM***";
|
qDebug() << "***INSERTING SLIDE FROM SERVICEITEM***";
|
||||||
if (item.type() == "song") {
|
if (item.type() == "song") {
|
||||||
for (int i = 0; i < item.text().size(); i++) {
|
for (int i = 0; i < item.text().size(); i++) {
|
||||||
|
@ -597,7 +597,7 @@ void SlideModel::addItemFromService(const int &index, const ServiceItem &item) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::insertItemFromService(const int &index, const ServiceItem &item) {
|
void SlideModelCpp::insertItemFromService(const int &index, const ServiceItem &item) {
|
||||||
qDebug() << "***INSERTING SLIDE FROM SERVICEITEM***";
|
qDebug() << "***INSERTING SLIDE FROM SERVICEITEM***";
|
||||||
int slideId = findSlideIdFromServItm(index);
|
int slideId = findSlideIdFromServItm(index);
|
||||||
// move all slides to the next serviceItem
|
// move all slides to the next serviceItem
|
||||||
|
@ -640,7 +640,7 @@ void SlideModel::insertItemFromService(const int &index, const ServiceItem &item
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SlideModel::moveRowFromService(const int &fromIndex,
|
void SlideModelCpp::moveRowFromService(const int &fromIndex,
|
||||||
const int &toIndex,
|
const int &toIndex,
|
||||||
const ServiceItem &item) {
|
const ServiceItem &item) {
|
||||||
const bool isMoveDown = toIndex > fromIndex;
|
const bool isMoveDown = toIndex > fromIndex;
|
||||||
|
@ -700,7 +700,7 @@ void SlideModel::moveRowFromService(const int &fromIndex,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SlideModel::thumbnailVideoRust(QString video, int serviceItemId, int index, SlideyMod *slideModel) {
|
QString SlideModelCpp::thumbnailVideoRust(QString video, int serviceItemId, int index, SlideModel *slideModel) {
|
||||||
|
|
||||||
QDir dir = writeDir.absolutePath() + "/librepresenter/thumbnails";
|
QDir dir = writeDir.absolutePath() + "/librepresenter/thumbnails";
|
||||||
QDir absDir = writeDir.absolutePath() + "/librepresenter";
|
QDir absDir = writeDir.absolutePath() + "/librepresenter";
|
||||||
|
@ -745,7 +745,7 @@ QString SlideModel::thumbnailVideoRust(QString video, int serviceItemId, int ind
|
||||||
return thumbnailInfo.filePath();
|
return thumbnailInfo.filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SlideModel::thumbnailVideo(QString video, int serviceItemId, int index) {
|
QString SlideModelCpp::thumbnailVideo(QString video, int serviceItemId, int index) {
|
||||||
|
|
||||||
QDir dir = writeDir.absolutePath() + "/librepresenter/thumbnails";
|
QDir dir = writeDir.absolutePath() + "/librepresenter/thumbnails";
|
||||||
QDir absDir = writeDir.absolutePath() + "/librepresenter";
|
QDir absDir = writeDir.absolutePath() + "/librepresenter";
|
||||||
|
@ -803,7 +803,7 @@ QString SlideModel::thumbnailVideo(QString video, int serviceItemId, int index)
|
||||||
return thumbnailInfo.filePath();
|
return thumbnailInfo.filePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage SlideModel::frameToImage(const QString &video, int width)
|
QImage SlideModelCpp::frameToImage(const QString &video, int width)
|
||||||
{
|
{
|
||||||
QImage image;
|
QImage image;
|
||||||
FrameDecoder frameDecoder(video, nullptr);
|
FrameDecoder frameDecoder(video, nullptr);
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
#include <qsize.h>
|
#include <qsize.h>
|
||||||
#include "cxx-qt-gen/slide_model.cxxqt.h"
|
#include "cxx-qt-gen/slide_model.cxxqt.h"
|
||||||
|
|
||||||
class SlideModel : public QAbstractListModel {
|
class SlideModelCpp : public QAbstractListModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SlideModel(QObject *parent = nullptr);
|
explicit SlideModelCpp(QObject *parent = nullptr);
|
||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
TypeRole = Qt::UserRole,
|
TypeRole = Qt::UserRole,
|
||||||
|
@ -82,11 +82,11 @@ public:
|
||||||
Q_INVOKABLE bool moveDown(int index);
|
Q_INVOKABLE bool moveDown(int index);
|
||||||
Q_INVOKABLE bool moveUp(int index);
|
Q_INVOKABLE bool moveUp(int index);
|
||||||
Q_INVOKABLE QVariantMap getItem(int index) const;
|
Q_INVOKABLE QVariantMap getItem(int index) const;
|
||||||
Q_INVOKABLE QVariantMap getItemRust(int index, SlideyMod *slidemodel) const;
|
Q_INVOKABLE QVariantMap getItemRust(int index, SlideModel *slidemodel) const;
|
||||||
Q_INVOKABLE QVariantList getItems();
|
Q_INVOKABLE QVariantList getItems();
|
||||||
Q_INVOKABLE int findSlideIdFromServItm(int index);
|
Q_INVOKABLE int findSlideIdFromServItm(int index);
|
||||||
Q_INVOKABLE QString thumbnailVideo(QString video, int serviceItemId, int index);
|
Q_INVOKABLE QString thumbnailVideo(QString video, int serviceItemId, int index);
|
||||||
Q_INVOKABLE QString thumbnailVideoRust(QString video, int serviceItemId, int index, SlideyMod *slideModel);
|
Q_INVOKABLE QString thumbnailVideoRust(QString video, int serviceItemId, int index, SlideModel *slideModel);
|
||||||
QImage frameToImage(const QString &video, int width);
|
QImage frameToImage(const QString &video, int width);
|
||||||
|
|
||||||
|
|
||||||
|
|
52
src/main.cpp
52
src/main.cpp
|
@ -140,19 +140,14 @@ int main(int argc, char *argv[])
|
||||||
qDebug() << QIcon::themeName();
|
qDebug() << QIcon::themeName();
|
||||||
qDebug() << QApplication::platformName();
|
qDebug() << QApplication::platformName();
|
||||||
|
|
||||||
// integrate with commandline argument handling
|
|
||||||
// QCommandLineParser parser;
|
|
||||||
// aboutData.setupCommandLine(&parser);
|
|
||||||
// setup of app specific commandline args
|
|
||||||
|
|
||||||
//Need to instantiate our slide
|
//Need to instantiate our slide
|
||||||
QScopedPointer<Utils> utils(new Utils);
|
QScopedPointer<Utils> utils(new Utils);
|
||||||
QScopedPointer<SlideModel> slideModel(new SlideModel);
|
QScopedPointer<SlideModel> slideModel(new SlideModel);
|
||||||
QScopedPointer<SlideyMod> slideMod(new SlideyMod);
|
QScopedPointer<SlideModelCpp> slideMod(new SlideModelCpp);
|
||||||
QScopedPointer<File> filemanager(new File);
|
QScopedPointer<File> filemanager(new File);
|
||||||
// QScopedPointer<QQuickView> preswin(new QQuickView);
|
// QScopedPointer<QQuickView> preswin(new QQuickView);
|
||||||
QScopedPointer<ServiceItemMod> serviceItemModel(new ServiceItemMod);
|
QScopedPointer<ServiceItemModel> serviceItemModel(new ServiceItemModel);
|
||||||
QScopedPointer<ServiceItemModel> serviceItemC(new ServiceItemModel);
|
QScopedPointer<ServiceItemModelCpp> serviceItemC(new ServiceItemModelCpp);
|
||||||
QScopedPointer<SlideObject> slideobject(new SlideObject);
|
QScopedPointer<SlideObject> slideobject(new SlideObject);
|
||||||
QScopedPointer<ObsModel> obsModel(new ObsModel);
|
QScopedPointer<ObsModel> obsModel(new ObsModel);
|
||||||
obsModel.get()->getObs();
|
obsModel.get()->getObs();
|
||||||
|
@ -167,41 +162,42 @@ int main(int argc, char *argv[])
|
||||||
// PresWindow->setSource(QUrl(QStringLiteral("qrc://qml/presenter/PresentationWindow.qml")));
|
// PresWindow->setSource(QUrl(QStringLiteral("qrc://qml/presenter/PresentationWindow.qml")));
|
||||||
qDebug() << PresWindow->isVisible();
|
qDebug() << PresWindow->isVisible();
|
||||||
|
|
||||||
QObject::connect(serviceItemModel.get(),
|
QObject::connect(serviceItemC.get(),
|
||||||
SIGNAL(itemInserted(const int&, const ServiceItem&)),
|
SIGNAL(itemInserted(const int&, const ServiceItem&)),
|
||||||
slideModel.get(),
|
slideMod.get(),
|
||||||
SLOT(insertItemFromService(const int&, const ServiceItem&)));
|
SLOT(insertItemFromService(const int&, const ServiceItem&)));
|
||||||
QObject::connect(serviceItemModel.get(),
|
QObject::connect(serviceItemC.get(),
|
||||||
SIGNAL(itemAdded(const int&, const ServiceItem&)),
|
SIGNAL(itemAdded(const int&, const ServiceItem&)),
|
||||||
slideModel.get(),
|
slideMod.get(),
|
||||||
SLOT(addItemFromService(const int&, const ServiceItem&)));
|
SLOT(addItemFromService(const int&, const ServiceItem&)));
|
||||||
|
|
||||||
QObject::connect(serviceItemModel.get(),
|
QObject::connect(serviceItemModel.get(),
|
||||||
&ServiceItemMod::itemAdded,
|
&ServiceItemModel::itemAdded,
|
||||||
slideMod.get(),
|
slideModel.get(),
|
||||||
&SlideyMod::addItemFromService);
|
&SlideModel::addItemFromService);
|
||||||
QObject::connect(serviceItemModel.get(),
|
QObject::connect(serviceItemModel.get(),
|
||||||
&ServiceItemMod::itemInserted,
|
&ServiceItemModel::itemInserted,
|
||||||
slideMod.get(),
|
slideModel.get(),
|
||||||
&SlideyMod::insertItemFromService);
|
&SlideModel::insertItemFromService);
|
||||||
QObject::connect(serviceItemModel.get(),
|
QObject::connect(serviceItemModel.get(),
|
||||||
&ServiceItemMod::itemMoved,
|
&ServiceItemModel::itemMoved,
|
||||||
slideMod.get(),
|
slideModel.get(),
|
||||||
&SlideyMod::moveItemFromService);
|
&SlideModel::moveItemFromService);
|
||||||
QObject::connect(serviceItemModel.get(),
|
QObject::connect(serviceItemModel.get(),
|
||||||
&ServiceItemMod::itemRemoved,
|
&ServiceItemModel::itemRemoved,
|
||||||
slideMod.get(),
|
slideModel.get(),
|
||||||
&SlideyMod::removeItemFromService);
|
&SlideModel::removeItemFromService);
|
||||||
QObject::connect(serviceItemModel.get(),
|
QObject::connect(serviceItemModel.get(),
|
||||||
&ServiceItemMod::cleared,
|
&ServiceItemModel::cleared,
|
||||||
slideMod.get(),
|
slideModel.get(),
|
||||||
&SlideyMod::clear);
|
&SlideModel::clear);
|
||||||
// QObject::connect(serviceItemModel.get(),
|
// QObject::connect(serviceItemModel.get(),
|
||||||
// SIGNAL(allRemoved()),
|
// SIGNAL(allRemoved()),
|
||||||
// slideMod.get(),
|
// slideMod.get(),
|
||||||
// SLOT(clear()));
|
// SLOT(clear()));
|
||||||
QObject::connect(slideobject.get(),
|
QObject::connect(slideobject.get(),
|
||||||
SIGNAL(slideChanged(int)),
|
SIGNAL(slideChanged(int)),
|
||||||
slideMod.get(),
|
slideModel.get(),
|
||||||
SLOT(activate(int)));
|
SLOT(activate(int)));
|
||||||
|
|
||||||
utils.get()->setup();
|
utils.get()->setup();
|
||||||
|
|
|
@ -121,12 +121,12 @@ Kirigami.ApplicationWindow {
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
Layout.rightMargin: Kirigami.Units.smallSpacing * 2
|
Layout.rightMargin: Kirigami.Units.smallSpacing * 2
|
||||||
text: "Total Service Items: " + ServiceItemModel.count()
|
text: "Total Service Items: " + ServiceItemModel.count
|
||||||
}
|
}
|
||||||
Controls.Label {
|
Controls.Label {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
Layout.rightMargin: Kirigami.Units.smallSpacing * 2
|
Layout.rightMargin: Kirigami.Units.smallSpacing * 2
|
||||||
text: "Total Slides: " + SlideMod.count()
|
text: "Total Slides: " + SlideModel.count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,11 +40,11 @@ Item {
|
||||||
headerLabel: "Songs"
|
headerLabel: "Songs"
|
||||||
itemIcon: "folder-music-symbolic"
|
itemIcon: "folder-music-symbolic"
|
||||||
/* itemSubtitle: model.author */
|
/* itemSubtitle: model.author */
|
||||||
count: innerModel.count()
|
count: innerModel.count
|
||||||
newItemFunction: (function() {
|
newItemFunction: (function() {
|
||||||
songProxyModel.setFilterRegularExpression("");
|
songProxyModel.setFilterRegularExpression("");
|
||||||
innerModel.newSong();
|
innerModel.newSong();
|
||||||
libraryList.currentIndex = innerModel.count() - 1;
|
libraryList.currentIndex = innerModel.count - 1;
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editSwitch(libraryList.currentIndex, "song");
|
editSwitch(libraryList.currentIndex, "song");
|
||||||
|
@ -67,7 +67,7 @@ Item {
|
||||||
headerLabel: "Videos"
|
headerLabel: "Videos"
|
||||||
itemIcon: "folder-videos-symbolic"
|
itemIcon: "folder-videos-symbolic"
|
||||||
/* itemSubtitle: model.path */
|
/* itemSubtitle: model.path */
|
||||||
count: innerModel.count()
|
count: innerModel.count
|
||||||
newItemFunction: (function() {
|
newItemFunction: (function() {
|
||||||
videoProxyModel.setFilterRegularExpression("");
|
videoProxyModel.setFilterRegularExpression("");
|
||||||
newVideo.open();
|
newVideo.open();
|
||||||
|
@ -102,7 +102,7 @@ Item {
|
||||||
headerLabel: "Images"
|
headerLabel: "Images"
|
||||||
itemIcon: "folder-pictures-symbolic"
|
itemIcon: "folder-pictures-symbolic"
|
||||||
/* itemSubtitle: model.path */
|
/* itemSubtitle: model.path */
|
||||||
count: innerModel.count()
|
count: innerModel.count
|
||||||
newItemFunction: (function() {
|
newItemFunction: (function() {
|
||||||
imageProxyModel.setFilterRegularExpression("");
|
imageProxyModel.setFilterRegularExpression("");
|
||||||
})
|
})
|
||||||
|
@ -123,7 +123,7 @@ Item {
|
||||||
headerLabel: "Presentations"
|
headerLabel: "Presentations"
|
||||||
itemIcon: "x-office-presentation-symbolic"
|
itemIcon: "x-office-presentation-symbolic"
|
||||||
/* itemSubtitle: model.path */
|
/* itemSubtitle: model.path */
|
||||||
count: innerModel.count()
|
count: innerModel.count
|
||||||
newItemFunction: (function() {
|
newItemFunction: (function() {
|
||||||
presProxyModel.setFilterRegularExpression("");
|
presProxyModel.setFilterRegularExpression("");
|
||||||
})
|
})
|
||||||
|
@ -320,7 +320,7 @@ Item {
|
||||||
function addVideo(url) {
|
function addVideo(url) {
|
||||||
videoProxyModel.videoModel.newItem(url);
|
videoProxyModel.videoModel.newItem(url);
|
||||||
selectedLibrary = "video";
|
selectedLibrary = "video";
|
||||||
videoLibrary.libraryList.currentIndex = videoProxyModel.videoModel.count() - 1;
|
videoLibrary.libraryList.currentIndex = videoProxyModel.videoModel.count - 1;
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editSwitch(videoLibrary.libraryList.currentIndex, "video");
|
editSwitch(videoLibrary.libraryList.currentIndex, "video");
|
||||||
|
@ -329,7 +329,7 @@ Item {
|
||||||
function addImg(url) {
|
function addImg(url) {
|
||||||
imageProxyModel.newItem(url);
|
imageProxyModel.newItem(url);
|
||||||
selectedLibrary = "image";
|
selectedLibrary = "image";
|
||||||
imageLibrary.libraryList.currentIndex = imageProxyModel.imageModel.count() - 1;
|
imageLibrary.libraryList.currentIndex = imageProxyModel.imageModel.count - 1;
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editSwitch(imageLibrary.libraryList.currentIndex, "image");
|
editSwitch(imageLibrary.libraryList.currentIndex, "image");
|
||||||
|
@ -350,7 +350,7 @@ Item {
|
||||||
|
|
||||||
presProxyModel.presentationModel.newItem(url, pageCount);
|
presProxyModel.presentationModel.newItem(url, pageCount);
|
||||||
selectedLibrary = "presentation";
|
selectedLibrary = "presentation";
|
||||||
presentationLibrary.libraryList.currentIndex = presProxyModel.presentationModel.count() - 1;
|
presentationLibrary.libraryList.currentIndex = presProxyModel.presentationModel.count - 1;
|
||||||
if (!editMode)
|
if (!editMode)
|
||||||
editMode = true;
|
editMode = true;
|
||||||
editSwitch(presentationLibrary.libraryList.currentIndex, "presentation");
|
editSwitch(presentationLibrary.libraryList.currentIndex, "presentation");
|
||||||
|
|
|
@ -15,8 +15,8 @@ Controls.Page {
|
||||||
// properties passed around for the slides
|
// properties passed around for the slides
|
||||||
property int currentServiceItem
|
property int currentServiceItem
|
||||||
property int currentSlide
|
property int currentSlide
|
||||||
property int totalServiceItems: ServiceItemModel.rowCount()
|
property int totalServiceItems: ServiceItemModel.rowCount
|
||||||
property int totalSlides: SlideMod.count()
|
property int totalSlides: SlideModel.count
|
||||||
property url imageBackground: presentation.imageBackground
|
property url imageBackground: presentation.imageBackground
|
||||||
property url videoBackground: presentation.vidBackground
|
property url videoBackground: presentation.vidBackground
|
||||||
property url webSource
|
property url webSource
|
||||||
|
@ -184,9 +184,9 @@ Controls.Page {
|
||||||
console.log("change-service-item: " + index);
|
console.log("change-service-item: " + index);
|
||||||
const item = ServiceItemC.getRust(index, ServiceItemModel);
|
const item = ServiceItemC.getRust(index, ServiceItemModel);
|
||||||
currentServiceItem = index;
|
currentServiceItem = index;
|
||||||
const slideId = SlideMod.getSlideFromService(index);
|
const slideId = SlideModel.getSlideFromService(index);
|
||||||
currentSlide = slideId;
|
currentSlide = slideId;
|
||||||
const slide = SlideModel.getItemRust(slideId, SlideMod);
|
const slide = SlideMod.getItemRust(slideId, SlideModel);
|
||||||
console.log("index grabbed: " + index);
|
console.log("index grabbed: " + index);
|
||||||
console.log(slideId);
|
console.log(slideId);
|
||||||
console.log("Time to start changing");
|
console.log("Time to start changing");
|
||||||
|
@ -217,8 +217,8 @@ Controls.Page {
|
||||||
|
|
||||||
function changeSlide(index) {
|
function changeSlide(index) {
|
||||||
console.log("index grabbed: " + index);
|
console.log("index grabbed: " + index);
|
||||||
const currentItem = SlideModel.getItemRust(currentServiceItem, SlideMod);
|
const currentItem = SlideMod.getItemRust(currentServiceItem, SlideModel);
|
||||||
const item = SlideModel.getItemRust(index, SlideMod);
|
const item = SlideMod.getItemRust(index, SlideModel);
|
||||||
const isMoveDown = currentSlide < index;
|
const isMoveDown = currentSlide < index;
|
||||||
console.log(item + " " + currentItem);
|
console.log(item + " " + currentItem);
|
||||||
currentSlide = index;
|
currentSlide = index;
|
||||||
|
@ -250,7 +250,7 @@ Controls.Page {
|
||||||
ServiceItemModel.activate(currentServiceItem);
|
ServiceItemModel.activate(currentServiceItem);
|
||||||
/* SlideObject.changeSlide(slide, slideId); */
|
/* SlideObject.changeSlide(slide, slideId); */
|
||||||
slideHelper.chngSlide(item, index, SlideObject);
|
slideHelper.chngSlide(item, index, SlideObject);
|
||||||
/* SlideMod.activate(index); */
|
/* SlideModel.activate(index); */
|
||||||
presentation.textIndex = 0;
|
presentation.textIndex = 0;
|
||||||
console.log("Slide changed to: ", item.imageBackground);
|
console.log("Slide changed to: ", item.imageBackground);
|
||||||
activeServiceItem = ServiceItemC.getRust(currentServiceItem, ServiceItemModel).name;
|
activeServiceItem = ServiceItemC.getRust(currentServiceItem, ServiceItemModel).name;
|
||||||
|
|
|
@ -202,7 +202,7 @@ FocusScope {
|
||||||
spacing: Kirigami.Units.smallSpacing * 2
|
spacing: Kirigami.Units.smallSpacing * 2
|
||||||
cacheBuffer: 900
|
cacheBuffer: 900
|
||||||
reuseItems: true
|
reuseItems: true
|
||||||
model: SlideMod
|
model: SlideModel
|
||||||
delegate: Presenter.PreviewSlideListDelegate {}
|
delegate: Presenter.PreviewSlideListDelegate {}
|
||||||
highlight: highlightBar
|
highlight: highlightBar
|
||||||
highlightFollowsCurrentItem: false
|
highlightFollowsCurrentItem: false
|
||||||
|
@ -233,7 +233,7 @@ FocusScope {
|
||||||
|
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: SlideMod
|
target: SlideModel
|
||||||
function onActiveChanged(index) {
|
function onActiveChanged(index) {
|
||||||
console.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
|
console.log("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
|
||||||
console.log(index);
|
console.log(index);
|
||||||
|
@ -282,7 +282,7 @@ FocusScope {
|
||||||
cacheBuffer: 800
|
cacheBuffer: 800
|
||||||
reuseItems: true
|
reuseItems: true
|
||||||
clip: true
|
clip: true
|
||||||
model: SlideMod
|
model: SlideModel
|
||||||
delegate: Presenter.PreviewSlideListDelegate { showVidBG: false }
|
delegate: Presenter.PreviewSlideListDelegate { showVidBG: false }
|
||||||
|
|
||||||
Kirigami.WheelHandler {
|
Kirigami.WheelHandler {
|
||||||
|
@ -355,8 +355,8 @@ FocusScope {
|
||||||
/* target: ServiceItemModel */
|
/* target: ServiceItemModel */
|
||||||
/* function onActivateChanged(index) { */
|
/* function onActivateChanged(index) { */
|
||||||
/* console.log("$$$$$$$$$$$$$$$$$$$$"); */
|
/* console.log("$$$$$$$$$$$$$$$$$$$$"); */
|
||||||
/* const slide = SlideModel.getSlideFromService(index); */
|
/* const slide = SlideMod.getSlideFromService(index); */
|
||||||
/* SlideMod.activate(slide); */
|
/* SlideModel.activate(slide); */
|
||||||
/* } */
|
/* } */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ Item {
|
||||||
/* property var previewSlidesList: parent */
|
/* property var previewSlidesList: parent */
|
||||||
/* Component.onCompleted: { */
|
/* Component.onCompleted: { */
|
||||||
/* if (model.videoBackground != "") */
|
/* if (model.videoBackground != "") */
|
||||||
/* SlideModel.thumbnailVideoRust(model.videoBackground, model.serviceItemId, index, SlideMod); */
|
/* SlideMod.thumbnailVideoRust(model.videoBackground, model.serviceItemId, index, SlideModel); */
|
||||||
/* } */
|
/* } */
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
|
@ -73,7 +73,7 @@ Item {
|
||||||
onEntered: (drag) => {
|
onEntered: (drag) => {
|
||||||
if (drag.keys[0] === "library") {
|
if (drag.keys[0] === "library") {
|
||||||
dropHighlightLine.visible = true;
|
dropHighlightLine.visible = true;
|
||||||
var lastItem = serviceItemList.itemAtIndex(ServiceItemModel.count() - 1);
|
var lastItem = serviceItemList.itemAtIndex(ServiceItemModel.count - 1);
|
||||||
dropHighlightLine.y = lastItem.y + lastItem.height;
|
dropHighlightLine.y = lastItem.y + lastItem.height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,8 +513,8 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeSong(index) {
|
function changeSong(index) {
|
||||||
console.log("Preparing to change song: " + index + 1 + " out of " + songProxyModel.songModel.count());
|
console.log("Preparing to change song: " + index + 1 + " out of " + songProxyModel.songModel.count);
|
||||||
if (songProxyModel.songModel.count() - 1 === index)
|
if (songProxyModel.songModel.count - 1 === index)
|
||||||
newSong(index)
|
newSong(index)
|
||||||
else {
|
else {
|
||||||
clearSlides();
|
clearSlides();
|
||||||
|
|
|
@ -36,8 +36,9 @@ mod file_helper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use cxx_qt_lib::{QString, QUrl};
|
||||||
use rfd::FileDialog;
|
use rfd::FileDialog;
|
||||||
use std::path::Path;
|
use std::{path::Path, pin::Pin};
|
||||||
use tracing::{debug, debug_span, error, info, instrument};
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -55,7 +56,7 @@ impl Default for FileHelperRust {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::FileHelper {
|
impl file_helper::FileHelper {
|
||||||
pub fn load(self: Pin<&mut Self>, file: QUrl) -> Vec<String> {
|
pub fn load(self: Pin<&mut Self>, file: QUrl) -> Vec<String> {
|
||||||
println!("{file}");
|
println!("{file}");
|
||||||
vec!["hi".to_string()]
|
vec!["hi".to_string()]
|
||||||
|
|
|
@ -25,7 +25,7 @@ mod image_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qenum(ImageModel)]
|
#[qenum(ImageModel)]
|
||||||
enum Role {
|
enum ImageRoles {
|
||||||
Id,
|
Id,
|
||||||
Path,
|
Path,
|
||||||
Title,
|
Title,
|
||||||
|
@ -35,7 +35,7 @@ mod image_model {
|
||||||
#[qobject]
|
#[qobject]
|
||||||
#[base = "QAbstractListModel"]
|
#[base = "QAbstractListModel"]
|
||||||
#[qml_element]
|
#[qml_element]
|
||||||
#[qproperty(i32, count_rows)]
|
#[qproperty(i32, count)]
|
||||||
type ImageModel = super::ImageModelRust;
|
type ImageModel = super::ImageModelRust;
|
||||||
|
|
||||||
#[inherit]
|
#[inherit]
|
||||||
|
@ -151,19 +151,24 @@ mod image_model {
|
||||||
#[cxx_override]
|
#[cxx_override]
|
||||||
fn row_count(self: &ImageModel, _parent: &QModelIndex)
|
fn row_count(self: &ImageModel, _parent: &QModelIndex)
|
||||||
-> i32;
|
-> i32;
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
fn count(self: &ImageModel) -> i32;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::image_model::image_model::Image;
|
|
||||||
use crate::schema::images::dsl::*;
|
use crate::schema::images::dsl::*;
|
||||||
|
use cxx_qt::{CxxQtType, Threading};
|
||||||
|
use cxx_qt_lib::{QModelIndex, QString, QUrl, QVariant};
|
||||||
use diesel::sqlite::SqliteConnection;
|
use diesel::sqlite::SqliteConnection;
|
||||||
use diesel::{delete, insert_into, prelude::*, update};
|
use diesel::{delete, insert_into, prelude::*, update};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::pin::Pin;
|
||||||
|
|
||||||
|
use self::image_model::{
|
||||||
|
ImageRoles, QHash_i32_QByteArray, QMap_QString_QVariant,
|
||||||
|
QVector_i32,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
|
/// Idk what this is but it's cool
|
||||||
pub struct Image {
|
pub struct Image {
|
||||||
id: i32,
|
id: i32,
|
||||||
title: QString,
|
title: QString,
|
||||||
|
@ -172,16 +177,16 @@ pub struct Image {
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct ImageModelRust {
|
pub struct ImageModelRust {
|
||||||
count_rows: i32,
|
count: i32,
|
||||||
highest_id: i32,
|
highest_id: i32,
|
||||||
images: Vec<self::Image>,
|
images: Vec<Image>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::ImageModel {
|
impl image_model::ImageModel {
|
||||||
pub fn clear(mut self: Pin<&mut Self>) {
|
pub fn clear(mut self: Pin<&mut Self>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_reset_model();
|
self.as_mut().begin_reset_model();
|
||||||
self.as_mut().images_mut().clear();
|
self.as_mut().rust_mut().images.clear();
|
||||||
self.as_mut().end_reset_model();
|
self.as_mut().end_reset_model();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,7 +196,7 @@ impl qobject::ImageModel {
|
||||||
let results = images
|
let results = images
|
||||||
.load::<crate::models::Image>(db)
|
.load::<crate::models::Image>(db)
|
||||||
.expect("Error loading images");
|
.expect("Error loading images");
|
||||||
self.as_mut().set_highest_id(0);
|
self.as_mut().rust_mut().highest_id = 0;
|
||||||
|
|
||||||
println!("SHOWING IMAGES");
|
println!("SHOWING IMAGES");
|
||||||
println!("--------------");
|
println!("--------------");
|
||||||
|
@ -200,8 +205,8 @@ impl qobject::ImageModel {
|
||||||
println!("{}", image.id);
|
println!("{}", image.id);
|
||||||
println!("{}", image.path);
|
println!("{}", image.path);
|
||||||
println!("--------------");
|
println!("--------------");
|
||||||
if self.as_mut().highest_id() < &image.id {
|
if &self.as_mut().highest_id < &image.id {
|
||||||
self.as_mut().set_highest_id(image.id);
|
self.as_mut().rust_mut().highest_id = image.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
let img = self::Image {
|
let img = self::Image {
|
||||||
|
@ -213,17 +218,17 @@ impl qobject::ImageModel {
|
||||||
self.as_mut().add_image(img);
|
self.as_mut().add_image(img);
|
||||||
}
|
}
|
||||||
println!("--------------------------------------");
|
println!("--------------------------------------");
|
||||||
println!("{:?}", self.as_mut().images());
|
println!("{:?}", self.as_mut().images);
|
||||||
println!("--------------------------------------");
|
println!("--------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
if index < 0 || (index as usize) >= self.images().len() {
|
if index < 0 || (index as usize) >= self.images.len() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
|
|
||||||
let image_id = self.images().get(index as usize).unwrap().id;
|
let image_id = self.images.get(index as usize).unwrap().id;
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
delete(images.filter(id.eq(image_id))).execute(db);
|
delete(images.filter(id.eq(image_id))).execute(db);
|
||||||
|
@ -236,11 +241,14 @@ impl qobject::ImageModel {
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut().images_mut().remove(index as usize);
|
self.as_mut()
|
||||||
|
.rust_mut()
|
||||||
|
.images
|
||||||
|
.remove(index as usize);
|
||||||
self.as_mut().end_remove_rows();
|
self.as_mut().end_remove_rows();
|
||||||
}
|
}
|
||||||
println!("removed-item-at-index: {:?}", image_id);
|
println!("removed-item-at-index: {:?}", image_id);
|
||||||
println!("new-Vec: {:?}", self.as_mut().images());
|
println!("new-Vec: {:?}", self.as_mut().images);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(_e) => {
|
Err(_e) => {
|
||||||
|
@ -273,7 +281,7 @@ impl qobject::ImageModel {
|
||||||
|
|
||||||
if self.as_mut().add_item(image_id, image_title, image_path) {
|
if self.as_mut().add_item(image_id, image_title, image_path) {
|
||||||
println!("filename: {:?}", name);
|
println!("filename: {:?}", name);
|
||||||
self.as_mut().set_highest_id(image_id);
|
self.as_mut().rust_mut().highest_id = image_id;
|
||||||
} else {
|
} else {
|
||||||
println!("Error in inserting item");
|
println!("Error in inserting item");
|
||||||
}
|
}
|
||||||
|
@ -306,7 +314,7 @@ impl qobject::ImageModel {
|
||||||
match result {
|
match result {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
self.as_mut().add_image(image);
|
self.as_mut().add_image(image);
|
||||||
println!("{:?}", self.as_mut().images());
|
println!("{:?}", self.as_mut().images);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(_e) => {
|
Err(_e) => {
|
||||||
|
@ -317,15 +325,17 @@ impl qobject::ImageModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_image(mut self: Pin<&mut Self>, image: self::Image) {
|
fn add_image(mut self: Pin<&mut Self>, image: self::Image) {
|
||||||
let index = self.as_ref().images().len() as i32;
|
let index = self.as_ref().images.len() as i32;
|
||||||
println!("{:?}", image);
|
println!("{:?}", image);
|
||||||
|
let count = self.as_ref().count;
|
||||||
|
self.as_mut().set_count(count + 1);
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_insert_rows(
|
self.as_mut().begin_insert_rows(
|
||||||
&QModelIndex::default(),
|
&QModelIndex::default(),
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut().images_mut().push(image);
|
self.as_mut().rust_mut().images.push(image);
|
||||||
self.as_mut().end_insert_rows();
|
self.as_mut().end_insert_rows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +347,7 @@ impl qobject::ImageModel {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role_id(Role::TitleRole));
|
.append(self.as_ref().get_role_id(ImageRoles::Title));
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.as_ref().index(index, 0, &QModelIndex::default());
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
|
|
||||||
|
@ -349,14 +359,15 @@ impl qobject::ImageModel {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
for image in self
|
for image in self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.images_mut()
|
.rust_mut()
|
||||||
|
.images
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
image.title = updated_title.clone();
|
image.title = updated_title.clone();
|
||||||
println!("rust-title: {:?}", image.title);
|
println!("rust-title: {:?}", image.title);
|
||||||
}
|
}
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
|
@ -374,7 +385,7 @@ impl qobject::ImageModel {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role_id(Role::PathRole));
|
.append(self.as_ref().get_role_id(ImageRoles::Path));
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.as_ref().index(index, 0, &QModelIndex::default());
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
|
|
||||||
|
@ -386,14 +397,15 @@ impl qobject::ImageModel {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
for image in self
|
for image in self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.images_mut()
|
.rust_mut()
|
||||||
|
.images
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
image.path = updated_file_path.clone();
|
image.path = updated_file_path.clone();
|
||||||
println!("rust-title: {:?}", image.path);
|
println!("rust-title: {:?}", image.path);
|
||||||
}
|
}
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
|
@ -427,25 +439,25 @@ impl qobject::ImageModel {
|
||||||
qvariantmap
|
qvariantmap
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_role_id(&self, role: Role) -> i32 {
|
fn get_role_id(&self, role: ImageRoles) -> i32 {
|
||||||
match role {
|
match role {
|
||||||
qobject::Role::Id => 0,
|
ImageRoles::Id => 0,
|
||||||
qobject::Role::Title => 1,
|
ImageRoles::Title => 1,
|
||||||
qobject::Role::Path => 2,
|
ImageRoles::Path => 2,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// QAbstractListModel implementation
|
// QAbstractListModel implementation
|
||||||
impl qobject::ImageModel {
|
impl image_model::ImageModel {
|
||||||
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
||||||
let role = qobject::Roles { repr: role };
|
let role = ImageRoles { repr: role };
|
||||||
if let Some(image) = self.images().get(index.row() as usize) {
|
if let Some(image) = self.images.get(index.row() as usize) {
|
||||||
return match role {
|
return match role {
|
||||||
qobject::Roles::Id => QVariant::from(&image.id),
|
ImageRoles::Id => QVariant::from(&image.id),
|
||||||
qobject::Roles::Title => QVariant::from(&image.title),
|
ImageRoles::Title => QVariant::from(&image.title),
|
||||||
qobject::Roles::Path => QVariant::from(&image.path),
|
ImageRoles::Path => QVariant::from(&image.path),
|
||||||
_ => QVariant::default(),
|
_ => QVariant::default(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -455,22 +467,22 @@ impl qobject::ImageModel {
|
||||||
|
|
||||||
// Example of overriding a C++ virtual method and calling the base class implementation.
|
// Example of overriding a C++ virtual method and calling the base class implementation.
|
||||||
|
|
||||||
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
// pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
||||||
self.base_can_fetch_more(parent)
|
// self.base_can_fetch_more(parent)
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
||||||
let mut roles = QHash_i32_QByteArray::default();
|
let mut roles = QHash_i32_QByteArray::default();
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Id.repr,
|
ImageRoles::Id.repr,
|
||||||
cxx_qt_lib::QByteArray::from("id"),
|
cxx_qt_lib::QByteArray::from("id"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Title.repr,
|
ImageRoles::Title.repr,
|
||||||
cxx_qt_lib::QByteArray::from("title"),
|
cxx_qt_lib::QByteArray::from("title"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Path.repr,
|
ImageRoles::Path.repr,
|
||||||
cxx_qt_lib::QByteArray::from("filePath"),
|
cxx_qt_lib::QByteArray::from("filePath"),
|
||||||
);
|
);
|
||||||
roles
|
roles
|
||||||
|
@ -482,10 +494,4 @@ impl qobject::ImageModel {
|
||||||
// println!("row count is {cnt}");
|
// println!("row count is {cnt}");
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn count(mut self: Pin<&mut Self>) -> i32 {
|
|
||||||
let cnt = self.rust().images.len() as i32;
|
|
||||||
self.as_mut().set_count_rows(cnt);
|
|
||||||
cnt
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
pub mod ffmpeg;
|
pub mod ffmpeg;
|
||||||
mod file_helper;
|
pub mod file_helper;
|
||||||
pub mod image_model;
|
pub mod image_model;
|
||||||
pub mod models;
|
pub mod models;
|
||||||
pub mod obs;
|
pub mod obs;
|
||||||
pub mod presentation_model;
|
pub mod presentation_model;
|
||||||
pub mod reveal_js;
|
pub mod reveal_js;
|
||||||
pub mod schema;
|
pub mod schema;
|
||||||
mod service_item_model;
|
pub mod service_item_model;
|
||||||
mod service_thing;
|
pub mod service_thing;
|
||||||
pub mod settings;
|
pub mod settings;
|
||||||
pub mod slide_model;
|
pub mod slide_model;
|
||||||
mod slide_object;
|
pub mod slide_object;
|
||||||
pub mod songs;
|
pub mod songs;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub mod video_model;
|
pub mod video_model;
|
||||||
|
|
146
src/rust/obs.rs
146
src/rust/obs.rs
|
@ -1,11 +1,14 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use std::error::Error;
|
use std::{error::Error, pin::Pin};
|
||||||
use std::thread::sleep;
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use cxx_qt::CxxQtType;
|
||||||
|
use cxx_qt_lib::{QStringList, QString};
|
||||||
use obws::responses::scenes::Scenes;
|
use obws::responses::scenes::Scenes;
|
||||||
use obws::Client;
|
use obws::Client;
|
||||||
use tracing::debug;
|
use tracing::{debug, error};
|
||||||
|
|
||||||
|
use crate::obs::obs_model::QList_QString;
|
||||||
|
|
||||||
pub struct Obs {
|
pub struct Obs {
|
||||||
scenes: Scenes,
|
scenes: Scenes,
|
||||||
|
@ -107,8 +110,6 @@ fn make_client() -> Client {
|
||||||
|
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod obs_model {
|
mod obs_model {
|
||||||
use tracing::{debug, error};
|
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!("cxx-qt-lib/qstring.h");
|
include!("cxx-qt-lib/qstring.h");
|
||||||
type QString = cxx_qt_lib::QString;
|
type QString = cxx_qt_lib::QString;
|
||||||
|
@ -118,75 +119,84 @@ mod obs_model {
|
||||||
type QList_QString = cxx_qt_lib::QList<QString>;
|
type QList_QString = cxx_qt_lib::QList<QString>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cxx_qt::qobject]
|
unsafe extern "RustQt" {
|
||||||
#[derive(Debug, Default)]
|
#[qobject]
|
||||||
pub struct ObsModel {
|
#[qml_element]
|
||||||
#[qproperty]
|
#[qproperty(QStringList, scenes)]
|
||||||
scenes: QStringList,
|
#[qproperty(QString, port)]
|
||||||
#[qproperty]
|
#[qproperty(bool, connected)]
|
||||||
port: QString,
|
type ObsModel = super::ObsModelRust;
|
||||||
#[qproperty]
|
|
||||||
connected: bool,
|
#[qinvokable]
|
||||||
obs: Option<super::Obs>,
|
fn update_scenes(self: Pin<&mut ObsModel>) -> QStringList;
|
||||||
|
#[qinvokable]
|
||||||
|
fn get_obs(self: Pin<&mut ObsModel>) -> bool;
|
||||||
|
#[qinvokable]
|
||||||
|
fn set_scene(self: Pin<&mut ObsModel>, scene: QString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default)]
|
||||||
|
pub struct ObsModelRust {
|
||||||
|
scenes: QStringList,
|
||||||
|
port: QString,
|
||||||
|
connected: bool,
|
||||||
|
obs: Option<Obs>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl obs_model::ObsModel {
|
||||||
|
pub fn update_scenes(
|
||||||
|
mut self: Pin<&mut Self>,
|
||||||
|
) -> QStringList {
|
||||||
|
debug!("updating scenes");
|
||||||
|
let mut scenes_list = QList_QString::default();
|
||||||
|
if let Some(obs) = &self.as_mut().rust_mut().obs {
|
||||||
|
debug!("found obs");
|
||||||
|
for scene in obs.scenes.scenes.iter().rev() {
|
||||||
|
debug!(?scene);
|
||||||
|
scenes_list.append(QString::from(&scene.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for s in scenes_list.iter() {
|
||||||
|
debug!(?s);
|
||||||
|
}
|
||||||
|
let list = QStringList::from(&scenes_list);
|
||||||
|
debug!(?list);
|
||||||
|
self.as_mut().set_scenes(list.clone());
|
||||||
|
list
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::ObsModel {
|
pub fn get_obs(mut self: Pin<&mut Self>) -> bool {
|
||||||
#[qinvokable]
|
debug!("getting obs");
|
||||||
pub fn update_scenes(
|
|
||||||
mut self: Pin<&mut Self>,
|
tokio::runtime::Runtime::new().unwrap().block_on(async {
|
||||||
) -> QStringList {
|
match Obs::new().await {
|
||||||
debug!("updating scenes");
|
Ok(o) => {
|
||||||
let mut scenes_list = QList_QString::default();
|
self.as_mut().set_connected(true);
|
||||||
if let Some(obs) = self.obs() {
|
self.as_mut().rust_mut().obs = Some(o);
|
||||||
debug!("found obs");
|
self.as_mut().update_scenes();
|
||||||
for scene in obs.scenes.scenes.iter().rev() {
|
}
|
||||||
debug!(?scene);
|
Err(e) => {
|
||||||
scenes_list.append(QString::from(&scene.name));
|
error!(e);
|
||||||
|
self.as_mut().set_connected(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for s in scenes_list.iter() {
|
});
|
||||||
debug!(?s);
|
|
||||||
}
|
if let Some(_obs) = &self.as_mut().rust_mut().obs {
|
||||||
let list = QStringList::from(&scenes_list);
|
true
|
||||||
debug!(?list);
|
} else {
|
||||||
self.as_mut().set_scenes(list.clone());
|
false
|
||||||
list
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[qinvokable]
|
pub fn set_scene(mut self: Pin<&mut Self>, scene: QString) {
|
||||||
pub fn get_obs(mut self: Pin<&mut Self>) -> bool {
|
let scene = scene.to_string();
|
||||||
debug!("getting obs");
|
if let Some(obs) = &self.as_mut().rust_mut().obs {
|
||||||
|
let obs = obs.clone();
|
||||||
tokio::runtime::Runtime::new().unwrap().block_on(async {
|
match obs.set_scene(scene) {
|
||||||
match super::Obs::new().await {
|
Ok(()) => debug!("Successfully set scene"),
|
||||||
Ok(o) => {
|
Err(e) => error!(e),
|
||||||
self.as_mut().set_connected(true);
|
|
||||||
self.as_mut().set_obs(Some(o));
|
|
||||||
self.as_mut().update_scenes();
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
error!(e);
|
|
||||||
self.as_mut().set_connected(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if let Some(_obs) = self.obs() {
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
pub fn set_scene(mut self: Pin<&mut Self>, scene: QString) {
|
|
||||||
let scene = scene.to_string();
|
|
||||||
if let Some(obs) = self.obs_mut() {
|
|
||||||
let obs = obs.clone();
|
|
||||||
match obs.set_scene(scene) {
|
|
||||||
Ok(()) => debug!("Successfully set scene"),
|
|
||||||
Err(e) => error!(e),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ mod presentation_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qenum(PresentationModel)]
|
#[qenum(PresentationModel)]
|
||||||
enum Role {
|
enum PresRoles {
|
||||||
Id,
|
Id,
|
||||||
Title,
|
Title,
|
||||||
Path,
|
Path,
|
||||||
|
@ -37,7 +37,7 @@ mod presentation_model {
|
||||||
#[qobject]
|
#[qobject]
|
||||||
#[base = "QAbstractListModel"]
|
#[base = "QAbstractListModel"]
|
||||||
#[qml_element]
|
#[qml_element]
|
||||||
#[qproperty(i32, count_rows)]
|
#[qproperty(i32, count)]
|
||||||
type PresentationModel = super::PresentationModelRust;
|
type PresentationModel = super::PresentationModelRust;
|
||||||
|
|
||||||
#[inherit]
|
#[inherit]
|
||||||
|
@ -64,24 +64,18 @@ mod presentation_model {
|
||||||
url: QUrl,
|
url: QUrl,
|
||||||
new_page_count: i32,
|
new_page_count: i32,
|
||||||
);
|
);
|
||||||
#[qinvokable]
|
// #[qinvokable]
|
||||||
fn update_path(
|
// fn update_path(
|
||||||
self: Pin<&mut PresentationModel>,
|
// self: Pin<&mut PresentationModel>,
|
||||||
index: i32,
|
// index: i32,
|
||||||
updated_path: QString,
|
// updated_path: QString,
|
||||||
) -> bool;
|
// ) -> bool;
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn get_item(
|
fn get_item(
|
||||||
self: Pin<&mut PresentationModel>,
|
self: Pin<&mut PresentationModel>,
|
||||||
index: i32,
|
index: i32,
|
||||||
) -> QMap_QString_QVariant;
|
) -> QMap_QString_QVariant;
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn update_loop(
|
|
||||||
self: Pin<&mut PresentationModel>,
|
|
||||||
index: i32,
|
|
||||||
loop_value: bool,
|
|
||||||
) -> bool;
|
|
||||||
#[qinvokable]
|
|
||||||
fn update_title(
|
fn update_title(
|
||||||
self: Pin<&mut PresentationModel>,
|
self: Pin<&mut PresentationModel>,
|
||||||
index: i32,
|
index: i32,
|
||||||
|
@ -93,12 +87,6 @@ mod presentation_model {
|
||||||
index: i32,
|
index: i32,
|
||||||
updated_page_count: i32,
|
updated_page_count: i32,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
#[qinvokable]
|
|
||||||
fn update_end_time(
|
|
||||||
self: Pin<&mut PresentationModel>,
|
|
||||||
index: i32,
|
|
||||||
updated_end_stime: QString,
|
|
||||||
) -> bool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl cxx_qt::Threading for PresentationModel {}
|
impl cxx_qt::Threading for PresentationModel {}
|
||||||
|
@ -181,21 +169,25 @@ mod presentation_model {
|
||||||
self: &PresentationModel,
|
self: &PresentationModel,
|
||||||
_parent: &QModelIndex,
|
_parent: &QModelIndex,
|
||||||
) -> i32;
|
) -> i32;
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
fn count(self: &PresentationModel) -> i32;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::presentation_model::presentation_model::Presentation;
|
use crate::presentation_model::presentation_model::QMap_QString_QVariant;
|
||||||
use crate::reveal_js;
|
use crate::reveal_js;
|
||||||
use crate::schema::presentations::dsl::*;
|
use crate::schema::presentations::dsl::*;
|
||||||
|
use cxx_qt::CxxQtType;
|
||||||
|
use cxx_qt_lib::{QModelIndex, QString, QUrl, QVariant};
|
||||||
use diesel::sqlite::SqliteConnection;
|
use diesel::sqlite::SqliteConnection;
|
||||||
use diesel::{delete, insert_into, prelude::*, update};
|
use diesel::{delete, insert_into, prelude::*, update};
|
||||||
// use sqlx::Connection;
|
// use sqlx::Connection;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::pin::Pin;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
|
use self::presentation_model::{
|
||||||
|
PresRoles, QHash_i32_QByteArray, QVector_i32,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
pub struct Presentation {
|
pub struct Presentation {
|
||||||
id: i32,
|
id: i32,
|
||||||
|
@ -207,15 +199,16 @@ pub struct Presentation {
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct PresentationModelRust {
|
pub struct PresentationModelRust {
|
||||||
|
count: i32,
|
||||||
highest_id: i32,
|
highest_id: i32,
|
||||||
presentations: Vec<self::Presentation>,
|
presentations: Vec<Presentation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::PresentationModel {
|
impl presentation_model::PresentationModel {
|
||||||
pub fn clear(mut self: Pin<&mut Self>) {
|
pub fn clear(mut self: Pin<&mut Self>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_reset_model();
|
self.as_mut().begin_reset_model();
|
||||||
self.as_mut().presentations_mut().clear();
|
self.as_mut().rust_mut().presentations.clear();
|
||||||
self.as_mut().end_reset_model();
|
self.as_mut().end_reset_model();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,7 +220,7 @@ impl qobject::PresentationModel {
|
||||||
let results = presentations
|
let results = presentations
|
||||||
.load::<crate::models::Presentation>(db)
|
.load::<crate::models::Presentation>(db)
|
||||||
.expect("Error loading presentations");
|
.expect("Error loading presentations");
|
||||||
self.as_mut().set_highest_id(0);
|
self.as_mut().rust_mut().highest_id = 0;
|
||||||
|
|
||||||
println!("SHOWING PRESENTATIONS");
|
println!("SHOWING PRESENTATIONS");
|
||||||
println!("--------------");
|
println!("--------------");
|
||||||
|
@ -237,8 +230,8 @@ impl qobject::PresentationModel {
|
||||||
println!("{}", presentation.path);
|
println!("{}", presentation.path);
|
||||||
println!("{}", presentation.html);
|
println!("{}", presentation.html);
|
||||||
println!("--------------");
|
println!("--------------");
|
||||||
if self.as_mut().highest_id() < &presentation.id {
|
if &self.as_mut().highest_id < &presentation.id {
|
||||||
self.as_mut().set_highest_id(presentation.id);
|
self.as_mut().rust_mut().highest_id = presentation.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pres = self::Presentation {
|
let pres = self::Presentation {
|
||||||
|
@ -249,22 +242,23 @@ impl qobject::PresentationModel {
|
||||||
page_count: presentation.page_count.unwrap(),
|
page_count: presentation.page_count.unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let count = self.as_ref().count;
|
||||||
|
self.as_mut().set_count(count + 1);
|
||||||
self.as_mut().add_presentation(pres);
|
self.as_mut().add_presentation(pres);
|
||||||
}
|
}
|
||||||
println!("--------------------------------------");
|
println!("--------------------------------------");
|
||||||
println!("{:?}", self.as_mut().presentations());
|
println!("{:?}", self.as_mut().presentations);
|
||||||
println!("--------------------------------------");
|
println!("--------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
if index < 0 || (index as usize) >= self.presentations().len()
|
if index < 0 || (index as usize) >= self.presentations.len() {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
|
|
||||||
let presentation_id =
|
let presentation_id =
|
||||||
self.presentations().get(index as usize).unwrap().id;
|
self.presentations.get(index as usize).unwrap().id;
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
delete(presentations.filter(id.eq(presentation_id)))
|
delete(presentations.filter(id.eq(presentation_id)))
|
||||||
|
@ -279,7 +273,8 @@ impl qobject::PresentationModel {
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut()
|
self.as_mut()
|
||||||
.presentations_mut()
|
.rust_mut()
|
||||||
|
.presentations
|
||||||
.remove(index as usize);
|
.remove(index as usize);
|
||||||
self.as_mut().end_remove_rows();
|
self.as_mut().end_remove_rows();
|
||||||
}
|
}
|
||||||
|
@ -289,7 +284,7 @@ impl qobject::PresentationModel {
|
||||||
);
|
);
|
||||||
println!(
|
println!(
|
||||||
"new-Vec: {:?}",
|
"new-Vec: {:?}",
|
||||||
self.as_mut().presentations()
|
self.as_mut().presentations
|
||||||
);
|
);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -321,7 +316,7 @@ impl qobject::PresentationModel {
|
||||||
println!("LETS INSERT THIS SUCKER!");
|
println!("LETS INSERT THIS SUCKER!");
|
||||||
let file_path = PathBuf::from(url.path().to_string());
|
let file_path = PathBuf::from(url.path().to_string());
|
||||||
let name = file_path.file_stem().unwrap().to_str().unwrap();
|
let name = file_path.file_stem().unwrap().to_str().unwrap();
|
||||||
let presentation_id = self.rust().highest_id + 1;
|
let presentation_id = self.highest_id + 1;
|
||||||
let presentation_title = QString::from(name);
|
let presentation_title = QString::from(name);
|
||||||
let presentation_path = url;
|
let presentation_path = url;
|
||||||
let presentation_html =
|
let presentation_html =
|
||||||
|
@ -336,7 +331,7 @@ impl qobject::PresentationModel {
|
||||||
new_page_count,
|
new_page_count,
|
||||||
) {
|
) {
|
||||||
println!("filename: {:?}", name);
|
println!("filename: {:?}", name);
|
||||||
self.as_mut().set_highest_id(presentation_id);
|
self.as_mut().rust_mut().highest_id = presentation_id;
|
||||||
} else {
|
} else {
|
||||||
println!("Error in inserting item");
|
println!("Error in inserting item");
|
||||||
}
|
}
|
||||||
|
@ -387,7 +382,7 @@ impl qobject::PresentationModel {
|
||||||
match result {
|
match result {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
self.as_mut().add_presentation(presentation);
|
self.as_mut().add_presentation(presentation);
|
||||||
println!("{:?}", self.as_mut().presentations());
|
println!("{:?}", self.as_mut().presentations);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(_e) => {
|
Err(_e) => {
|
||||||
|
@ -401,7 +396,7 @@ impl qobject::PresentationModel {
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
presentation: self::Presentation,
|
presentation: self::Presentation,
|
||||||
) {
|
) {
|
||||||
let index = self.as_ref().presentations().len() as i32;
|
let index = self.as_ref().presentations.len() as i32;
|
||||||
println!("{:?}", presentation);
|
println!("{:?}", presentation);
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_insert_rows(
|
self.as_mut().begin_insert_rows(
|
||||||
|
@ -409,7 +404,7 @@ impl qobject::PresentationModel {
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut().presentations_mut().push(presentation);
|
self.as_mut().rust_mut().presentations.push(presentation);
|
||||||
self.as_mut().end_insert_rows();
|
self.as_mut().end_insert_rows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,7 +422,7 @@ impl qobject::PresentationModel {
|
||||||
let role_names = self.as_ref().role_names();
|
let role_names = self.as_ref().role_names();
|
||||||
let role_names_iter = role_names.iter();
|
let role_names_iter = role_names.iter();
|
||||||
if let Some(presentation) =
|
if let Some(presentation) =
|
||||||
self.rust().presentations.get(index as usize)
|
self.presentations.get(index as usize)
|
||||||
{
|
{
|
||||||
for i in role_names_iter {
|
for i in role_names_iter {
|
||||||
qvariantmap.insert(
|
qvariantmap.insert(
|
||||||
|
@ -445,7 +440,7 @@ impl qobject::PresentationModel {
|
||||||
updated_title: QString,
|
updated_title: QString,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles.append(self.as_ref().get_role(Role::TitleRole));
|
vector_roles.append(self.as_ref().get_role(PresRoles::Title));
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.as_ref().index(index, 0, &QModelIndex::default());
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
|
|
||||||
|
@ -457,7 +452,8 @@ impl qobject::PresentationModel {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
for presentation in self
|
for presentation in self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.presentations_mut()
|
.rust_mut()
|
||||||
|
.presentations
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
|
@ -465,7 +461,7 @@ impl qobject::PresentationModel {
|
||||||
println!("rust-title: {:?}", presentation.title);
|
println!("rust-title: {:?}", presentation.title);
|
||||||
}
|
}
|
||||||
// TODO this seems to not be updating in the actual list
|
// TODO this seems to not be updating in the actual list
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
|
@ -485,7 +481,7 @@ impl qobject::PresentationModel {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role(Role::PageCountRole));
|
.append(self.as_ref().get_role(PresRoles::PageCount));
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.as_ref().index(index, 0, &QModelIndex::default());
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
|
|
||||||
|
@ -497,7 +493,8 @@ impl qobject::PresentationModel {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
for presentation in self
|
for presentation in self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.presentations_mut()
|
.rust_mut()
|
||||||
|
.presentations
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
|
@ -508,7 +505,7 @@ impl qobject::PresentationModel {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// TODO this seems to not be updating in the actual list
|
// TODO this seems to not be updating in the actual list
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
|
@ -521,37 +518,35 @@ impl qobject::PresentationModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_role(&self, role: Role) -> i32 {
|
fn get_role(&self, role: PresRoles) -> i32 {
|
||||||
match role {
|
match role {
|
||||||
Role::IdRole => 0,
|
PresRoles::Id => 0,
|
||||||
Role::TitleRole => 1,
|
PresRoles::Title => 1,
|
||||||
Role::PathRole => 2,
|
PresRoles::Path => 2,
|
||||||
Role::HtmlRole => 3,
|
PresRoles::Html => 3,
|
||||||
Role::PageCountRole => 4,
|
PresRoles::PageCount => 4,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// QAbstractListModel implementation
|
// QAbstractListModel implementation
|
||||||
impl qobject::PresentationModel {
|
impl presentation_model::PresentationModel {
|
||||||
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
||||||
let role = qobject::Roles { repr: role };
|
let role = PresRoles { repr: role };
|
||||||
if let Some(presentation) =
|
if let Some(presentation) =
|
||||||
self.presentations().get(index.row() as usize)
|
self.presentations.get(index.row() as usize)
|
||||||
{
|
{
|
||||||
return match role {
|
return match role {
|
||||||
qobject::Role::Id => QVariant::from(&presentation.id),
|
PresRoles::Id => QVariant::from(&presentation.id),
|
||||||
qobject::Role::Title => QVariant::from(
|
PresRoles::Title => QVariant::from(&QString::from(
|
||||||
&QString::from(&presentation.title),
|
&presentation.title,
|
||||||
),
|
)),
|
||||||
qobject::Role::Path => {
|
PresRoles::Path => {
|
||||||
QVariant::from(&QString::from(&presentation.path))
|
QVariant::from(&QString::from(&presentation.path))
|
||||||
}
|
}
|
||||||
qobject::Role::Html => {
|
PresRoles::Html => QVariant::from(&presentation.html),
|
||||||
QVariant::from(&presentation.html)
|
PresRoles::PageCount => {
|
||||||
}
|
|
||||||
qobject::Role::PageCount => {
|
|
||||||
QVariant::from(&presentation.page_count)
|
QVariant::from(&presentation.page_count)
|
||||||
}
|
}
|
||||||
_ => QVariant::default(),
|
_ => QVariant::default(),
|
||||||
|
@ -563,42 +558,38 @@ impl qobject::PresentationModel {
|
||||||
|
|
||||||
// Example of overriding a C++ virtual method and calling the base class implementation.
|
// Example of overriding a C++ virtual method and calling the base class implementation.
|
||||||
|
|
||||||
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
// pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
||||||
self.base_can_fetch_more(parent)
|
// self.base_can_fetch_more(parent)
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
||||||
let mut roles = QHash_i32_QByteArray::default();
|
let mut roles = QHash_i32_QByteArray::default();
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Id.repr,
|
PresRoles::Id.repr,
|
||||||
cxx_qt_lib::QByteArray::from("id"),
|
cxx_qt_lib::QByteArray::from("id"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Title.repr,
|
PresRoles::Title.repr,
|
||||||
cxx_qt_lib::QByteArray::from("title"),
|
cxx_qt_lib::QByteArray::from("title"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Path.repr,
|
PresRoles::Path.repr,
|
||||||
cxx_qt_lib::QByteArray::from("filePath"),
|
cxx_qt_lib::QByteArray::from("filePath"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Html.repr,
|
PresRoles::Html.repr,
|
||||||
cxx_qt_lib::QByteArray::from("html"),
|
cxx_qt_lib::QByteArray::from("html"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::PageCount.repr,
|
PresRoles::PageCount.repr,
|
||||||
cxx_qt_lib::QByteArray::from("pageCount"),
|
cxx_qt_lib::QByteArray::from("pageCount"),
|
||||||
);
|
);
|
||||||
roles
|
roles
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
||||||
let cnt = self.rust().presentations.len() as i32;
|
let cnt = self.presentations.len() as i32;
|
||||||
// println!("row count is {cnt}");
|
// println!("row count is {cnt}");
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn count(&self) -> i32 {
|
|
||||||
self.rust().presentations.len() as i32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ mod service_item_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qenum(ServiceItemModel)]
|
#[qenum(ServiceItemModel)]
|
||||||
enum Role {
|
enum ServiceRoles {
|
||||||
Name,
|
Name,
|
||||||
Type,
|
Type,
|
||||||
Audio,
|
Audio,
|
||||||
|
@ -46,6 +46,7 @@ mod service_item_model {
|
||||||
#[qobject]
|
#[qobject]
|
||||||
#[base = "QAbstractListModel"]
|
#[base = "QAbstractListModel"]
|
||||||
#[qml_element]
|
#[qml_element]
|
||||||
|
#[qproperty(i32, count)]
|
||||||
type ServiceItemModel = super::ServiceItemModelRust;
|
type ServiceItemModel = super::ServiceItemModelRust;
|
||||||
|
|
||||||
#[inherit]
|
#[inherit]
|
||||||
|
@ -134,7 +135,7 @@ mod service_item_model {
|
||||||
fn move_down(self: Pin<&mut ServiceItemModel>, index: i32) -> bool;
|
fn move_down(self: Pin<&mut ServiceItemModel>, index: i32) -> bool;
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn select(self: Pin<&mut ServiceItemModel>, index: i32) -> bool;
|
fn select(self: Pin<&mut ServiceItemModel>, index: i32);
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn select_items(
|
fn select_items(
|
||||||
|
@ -240,28 +241,32 @@ mod service_item_model {
|
||||||
fn row_count(self: &ServiceItemModel, _parent: &QModelIndex)
|
fn row_count(self: &ServiceItemModel, _parent: &QModelIndex)
|
||||||
-> i32;
|
-> i32;
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
fn count(self: &ServiceItemModel) -> i32;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
use cxx_qt::CxxQtType;
|
||||||
|
use cxx_qt_lib::{QModelIndex, QStringList, QString, QByteArray, QUrl, QVariant};
|
||||||
use dirs;
|
use dirs;
|
||||||
use serde_json::{json, Deserializer, Map, Serializer, Value};
|
use serde_json::{json, Deserializer, Map, Serializer, Value};
|
||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
use std::io::{self, Read, Write};
|
use std::io::{self, Read, Write};
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::pin::Pin;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::{fs, println};
|
use std::{fs, println};
|
||||||
use tar::{Archive, Builder};
|
use tar::{Archive, Builder};
|
||||||
use tracing::{debug, debug_span, error, info, instrument};
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
use zstd::{Decoder, Encoder};
|
use zstd::{Decoder, Encoder};
|
||||||
use crate::obs::Obs;
|
use crate::obs::Obs;
|
||||||
|
use crate::service_item_model::service_item_model::QList_QString;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use self::service_item_model::{QMap_QString_QVariant, QVector_i32, QHash_i32_QByteArray, ServiceRoles};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ServiceItm {
|
pub struct ServiceItem {
|
||||||
name: QString,
|
name: QString,
|
||||||
ty: QString,
|
ty: QString,
|
||||||
audio: QString,
|
audio: QString,
|
||||||
|
@ -279,7 +284,7 @@ pub struct ServiceItm {
|
||||||
obs_scene: QString,
|
obs_scene: QString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ServiceItm {
|
impl Default for ServiceItem {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
name: QString::default(),
|
name: QString::default(),
|
||||||
|
@ -304,8 +309,9 @@ impl Default for ServiceItm {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ServiceItemModelRust {
|
pub struct ServiceItemModelRust {
|
||||||
id: i32,
|
id: i32,
|
||||||
service_items: Vec<ServiceItm>,
|
service_items: Vec<ServiceItem>,
|
||||||
obs: Option<Obs>,
|
obs: Option<Obs>,
|
||||||
|
count: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ServiceItemModelRust {
|
impl Default for ServiceItemModelRust {
|
||||||
|
@ -325,11 +331,12 @@ impl Default for ServiceItemModelRust {
|
||||||
id: 0,
|
id: 0,
|
||||||
service_items: Vec::new(),
|
service_items: Vec::new(),
|
||||||
obs,
|
obs,
|
||||||
|
count: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::ServiceItemModel {
|
impl service_item_model::ServiceItemModel {
|
||||||
pub fn setup(mut self: Pin<&mut Self>) {
|
pub fn setup(mut self: Pin<&mut Self>) {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
@ -338,15 +345,15 @@ impl qobject::ServiceItemModel {
|
||||||
println!("CLEARING ALL ITEMS");
|
println!("CLEARING ALL ITEMS");
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_reset_model();
|
self.as_mut().begin_reset_model();
|
||||||
self.as_mut().service_items_mut().clear();
|
self.as_mut().rust_mut().service_items.clear();
|
||||||
self.as_mut().end_reset_model();
|
self.as_mut().end_reset_model();
|
||||||
}
|
}
|
||||||
self.emit(Signals::Cleared {});
|
self.as_mut().cleared();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
||||||
if index < 0
|
if index < 0
|
||||||
|| (index as usize) >= self.service_items().len()
|
|| (index as usize) >= self.service_items.len()
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -357,13 +364,13 @@ impl qobject::ServiceItemModel {
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut()
|
self.as_mut().rust_mut()
|
||||||
.service_items_mut()
|
.service_items
|
||||||
.remove(index as usize);
|
.remove(index as usize);
|
||||||
self.as_mut().end_remove_rows();
|
self.as_mut().end_remove_rows();
|
||||||
}
|
}
|
||||||
let item = self.as_mut().get_item(index);
|
let item = self.as_mut().get_item(index);
|
||||||
self.as_mut().emit_item_removed(&index, &item);
|
self.as_mut().item_removed(&index, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_item(
|
pub fn add_item(
|
||||||
|
@ -381,7 +388,7 @@ impl qobject::ServiceItemModel {
|
||||||
video_start_time: f32,
|
video_start_time: f32,
|
||||||
video_end_time: f32,
|
video_end_time: f32,
|
||||||
) {
|
) {
|
||||||
let service_item = ServiceItm {
|
let service_item = ServiceItem {
|
||||||
name,
|
name,
|
||||||
ty,
|
ty,
|
||||||
text,
|
text,
|
||||||
|
@ -402,22 +409,24 @@ impl qobject::ServiceItemModel {
|
||||||
|
|
||||||
fn add_service_item(
|
fn add_service_item(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
service_item: &ServiceItm,
|
service_item: &ServiceItem,
|
||||||
) {
|
) {
|
||||||
let index = self.as_ref().service_items().len() as i32;
|
let index = self.as_ref().service_items.len() as i32;
|
||||||
println!("{:?}", service_item);
|
println!("{:?}", service_item);
|
||||||
let service_item = service_item.clone();
|
let service_item = service_item.clone();
|
||||||
|
let count = self.as_ref().count;
|
||||||
|
self.as_mut().set_count(count + 1);
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_insert_rows(
|
self.as_mut().begin_insert_rows(
|
||||||
&QModelIndex::default(),
|
&QModelIndex::default(),
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut().service_items_mut().push(service_item);
|
self.as_mut().rust_mut().service_items.push(service_item);
|
||||||
self.as_mut().end_insert_rows();
|
self.as_mut().end_insert_rows();
|
||||||
}
|
}
|
||||||
let item = self.as_mut().get_item(index);
|
let item = self.as_mut().get_item(index);
|
||||||
self.as_mut().emit_item_added(&index, &item);
|
self.as_mut().item_added(&index, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_item(
|
pub fn insert_item(
|
||||||
|
@ -436,7 +445,7 @@ impl qobject::ServiceItemModel {
|
||||||
video_start_time: f32,
|
video_start_time: f32,
|
||||||
video_end_time: f32,
|
video_end_time: f32,
|
||||||
) {
|
) {
|
||||||
let service_item = ServiceItm {
|
let service_item = ServiceItem {
|
||||||
name,
|
name,
|
||||||
ty,
|
ty,
|
||||||
text,
|
text,
|
||||||
|
@ -457,7 +466,7 @@ impl qobject::ServiceItemModel {
|
||||||
|
|
||||||
fn insert_service_item(
|
fn insert_service_item(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
service_item: &ServiceItm,
|
service_item: &ServiceItem,
|
||||||
id: i32,
|
id: i32,
|
||||||
) {
|
) {
|
||||||
let service_item = service_item.clone();
|
let service_item = service_item.clone();
|
||||||
|
@ -467,13 +476,13 @@ impl qobject::ServiceItemModel {
|
||||||
id,
|
id,
|
||||||
id,
|
id,
|
||||||
);
|
);
|
||||||
self.as_mut()
|
self.as_mut().rust_mut()
|
||||||
.service_items_mut()
|
.service_items
|
||||||
.insert(id as usize, service_item);
|
.insert(id as usize, service_item);
|
||||||
self.as_mut().end_insert_rows();
|
self.as_mut().end_insert_rows();
|
||||||
}
|
}
|
||||||
let item = self.as_mut().get_item(id);
|
let item = self.as_mut().get_item(id);
|
||||||
self.as_mut().emit_item_inserted(&id, &item);
|
self.as_mut().item_inserted(&id, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_item(
|
pub fn get_item(
|
||||||
|
@ -489,7 +498,7 @@ impl qobject::ServiceItemModel {
|
||||||
let rn = self.as_ref().role_names();
|
let rn = self.as_ref().role_names();
|
||||||
let rn_iter = rn.iter();
|
let rn_iter = rn.iter();
|
||||||
if let Some(service_item) =
|
if let Some(service_item) =
|
||||||
self.rust().service_items.get(index as usize)
|
self.service_items.get(index as usize)
|
||||||
{
|
{
|
||||||
for i in rn_iter {
|
for i in rn_iter {
|
||||||
map.insert(
|
map.insert(
|
||||||
|
@ -541,7 +550,7 @@ impl qobject::ServiceItemModel {
|
||||||
|
|
||||||
if source_id < dest_id {
|
if source_id < dest_id {
|
||||||
let move_amount = dest_id - source_id - cnt + 1;
|
let move_amount = dest_id - source_id - cnt + 1;
|
||||||
self.as_mut().service_items_mut()
|
self.as_mut().rust_mut().service_items
|
||||||
[source_id..=dest_id]
|
[source_id..=dest_id]
|
||||||
.rotate_right(move_amount);
|
.rotate_right(move_amount);
|
||||||
println!("rust-move_amount: {:?}", move_amount);
|
println!("rust-move_amount: {:?}", move_amount);
|
||||||
|
@ -549,18 +558,14 @@ impl qobject::ServiceItemModel {
|
||||||
let move_amount =
|
let move_amount =
|
||||||
end_service_item - dest_id - cnt + 1;
|
end_service_item - dest_id - cnt + 1;
|
||||||
println!("rust-move_amount: {:?}", move_amount);
|
println!("rust-move_amount: {:?}", move_amount);
|
||||||
self.as_mut().service_items_mut()
|
self.as_mut().rust_mut().service_items
|
||||||
[dest_id..=end_service_item]
|
[dest_id..=end_service_item]
|
||||||
.rotate_left(move_amount);
|
.rotate_left(move_amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.as_mut().end_move_rows();
|
self.as_mut().end_move_rows();
|
||||||
let item = self.as_mut().get_item(dest_index);
|
let item = self.as_mut().get_item(dest_index);
|
||||||
self.as_mut().emit_item_moved(
|
self.as_mut().item_moved(&source_index, &dest_index, &item);
|
||||||
&source_index,
|
|
||||||
&dest_index,
|
|
||||||
&item,
|
|
||||||
);
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -573,38 +578,31 @@ impl qobject::ServiceItemModel {
|
||||||
self.move_rows(index, index + 1, 1)
|
self.move_rows(index, index + 1, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn select(mut self: Pin<&mut Self>, index: i32) -> bool {
|
pub fn select(mut self: Pin<&mut Self>, index: i32) {
|
||||||
let rc = self.as_ref().count() - 1;
|
let rc = self.as_ref().count() - 1;
|
||||||
let tl =
|
let tl =
|
||||||
&self.as_ref().index(0, 0, &QModelIndex::default());
|
&self.as_ref().index(0, 0, &QModelIndex::default());
|
||||||
let br =
|
let br =
|
||||||
&self.as_ref().index(rc, 0, &QModelIndex::default());
|
&self.as_ref().index(rc, 0, &QModelIndex::default());
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles.append(self.get_role(Role::SelectedRole));
|
vector_roles.append(self.get_role(ServiceRoles::Selected));
|
||||||
for service_item in
|
for service_item in
|
||||||
self.as_mut().service_items_mut().iter_mut()
|
self.as_mut().rust_mut().service_items.iter_mut()
|
||||||
{
|
{
|
||||||
debug!(deselecting = ?service_item);
|
debug!(deselecting = ?service_item);
|
||||||
service_item.selected = false;
|
service_item.selected = false;
|
||||||
}
|
}
|
||||||
if let Some(service_item) = self
|
if let Some(service_item) = self
|
||||||
.as_mut()
|
.as_mut().rust_mut()
|
||||||
.service_items_mut()
|
.service_items
|
||||||
.get_mut(index as usize)
|
.get_mut(index as usize)
|
||||||
{
|
{
|
||||||
debug!(selecting_item = index, item = ?service_item);
|
debug!(selecting_item = index, item = ?service_item);
|
||||||
service_item.selected = true;
|
service_item.selected = true;
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(tl, br, &vector_roles);
|
||||||
tl,
|
|
||||||
br,
|
|
||||||
&vector_roles,
|
|
||||||
);
|
|
||||||
// We use this signal generated by our signals enum to tell QML that
|
// We use this signal generated by our signals enum to tell QML that
|
||||||
// the selected service_item has changed which is used to reposition views.
|
// the selected service_item has changed which is used to reposition views.
|
||||||
// self.as_mut().emit_selected_changed();
|
// self.as_mut().emit_selected_changed();
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,11 +613,11 @@ impl qobject::ServiceItemModel {
|
||||||
// setup the roles we are using so that we can tell QML
|
// setup the roles we are using so that we can tell QML
|
||||||
// which properties to get again.
|
// which properties to get again.
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles.append(self.get_role(Role::SelectedRole));
|
vector_roles.append(self.get_role(ServiceRoles::Selected));
|
||||||
|
|
||||||
if let Some(current_index) = self
|
if let Some(current_index) = self
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.service_items()
|
.service_items
|
||||||
.iter()
|
.iter()
|
||||||
.position(|i| i.selected == true)
|
.position(|i| i.selected == true)
|
||||||
{
|
{
|
||||||
|
@ -644,8 +642,8 @@ impl qobject::ServiceItemModel {
|
||||||
&QModelIndex::default(),
|
&QModelIndex::default(),
|
||||||
);
|
);
|
||||||
for (index, item) in self
|
for (index, item) in self
|
||||||
.as_mut()
|
.as_mut().rust_mut()
|
||||||
.service_items_mut()
|
.service_items
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|i| {
|
.filter(|i| {
|
||||||
|
@ -656,11 +654,7 @@ impl qobject::ServiceItemModel {
|
||||||
item.selected = true;
|
item.selected = true;
|
||||||
debug!(selected_item = ?item, index = index);
|
debug!(selected_item = ?item, index = index);
|
||||||
}
|
}
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(top_left, bottom_right, &vector_roles);
|
||||||
top_left,
|
|
||||||
bottom_right,
|
|
||||||
&vector_roles,
|
|
||||||
);
|
|
||||||
// self.as_mut().emit_selected_changed();
|
// self.as_mut().emit_selected_changed();
|
||||||
} else {
|
} else {
|
||||||
let top_left = &self.as_ref().index(
|
let top_left = &self.as_ref().index(
|
||||||
|
@ -674,8 +668,8 @@ impl qobject::ServiceItemModel {
|
||||||
&QModelIndex::default(),
|
&QModelIndex::default(),
|
||||||
);
|
);
|
||||||
for (index, item) in self
|
for (index, item) in self
|
||||||
.as_mut()
|
.as_mut().rust_mut()
|
||||||
.service_items_mut()
|
.service_items
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|i| {
|
.filter(|i| {
|
||||||
|
@ -686,12 +680,7 @@ impl qobject::ServiceItemModel {
|
||||||
item.selected = true;
|
item.selected = true;
|
||||||
debug!(selected_item = ?item, index = index);
|
debug!(selected_item = ?item, index = index);
|
||||||
}
|
}
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(top_left, bottom_right, &vector_roles);
|
||||||
top_left,
|
|
||||||
bottom_right,
|
|
||||||
&vector_roles,
|
|
||||||
);
|
|
||||||
// self.as_mut().emit_selected_changed();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -711,8 +700,8 @@ impl qobject::ServiceItemModel {
|
||||||
&QModelIndex::default(),
|
&QModelIndex::default(),
|
||||||
);
|
);
|
||||||
for (index, item) in self
|
for (index, item) in self
|
||||||
.as_mut()
|
.as_mut().rust_mut()
|
||||||
.service_items_mut()
|
.service_items
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|i| i.0 <= final_index as usize)
|
.filter(|i| i.0 <= final_index as usize)
|
||||||
|
@ -720,12 +709,7 @@ impl qobject::ServiceItemModel {
|
||||||
item.selected = true;
|
item.selected = true;
|
||||||
debug!(selected_item = ?item, index = index);
|
debug!(selected_item = ?item, index = index);
|
||||||
}
|
}
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(top_left, bottom_right, &vector_roles);
|
||||||
top_left,
|
|
||||||
bottom_right,
|
|
||||||
&vector_roles,
|
|
||||||
);
|
|
||||||
// self.as_mut().emit_selected_changed();
|
|
||||||
debug!(
|
debug!(
|
||||||
first_item = 0,
|
first_item = 0,
|
||||||
final_item = final_index,
|
final_item = final_index,
|
||||||
|
@ -745,18 +729,18 @@ impl qobject::ServiceItemModel {
|
||||||
let br =
|
let br =
|
||||||
&self.as_ref().index(rc, 0, &QModelIndex::default());
|
&self.as_ref().index(rc, 0, &QModelIndex::default());
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles.append(self.get_role(Role::ActiveRole));
|
vector_roles.append(self.get_role(ServiceRoles::Active));
|
||||||
for service_item in
|
for service_item in
|
||||||
self.as_mut().service_items_mut().iter_mut()
|
self.as_mut().rust_mut().service_items.iter_mut()
|
||||||
{
|
{
|
||||||
// println!("service_item is deactivating {:?}", i);
|
// println!("service_item is deactivating {:?}", i);
|
||||||
service_item.active = false;
|
service_item.active = false;
|
||||||
}
|
}
|
||||||
let obs = self.as_mut().obs_mut().clone();
|
let obs = self.as_mut().obs.clone();
|
||||||
|
|
||||||
if let Some(service_item) = self
|
if let Some(service_item) = self
|
||||||
.as_mut()
|
.as_mut().rust_mut()
|
||||||
.service_items_mut()
|
.service_items
|
||||||
.get_mut(index as usize)
|
.get_mut(index as usize)
|
||||||
{
|
{
|
||||||
debug!(activating_item = index,
|
debug!(activating_item = index,
|
||||||
|
@ -772,14 +756,10 @@ impl qobject::ServiceItemModel {
|
||||||
// Err(e) => error!(e),
|
// Err(e) => error!(e),
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(tl, br, &vector_roles);
|
||||||
tl,
|
|
||||||
br,
|
|
||||||
&vector_roles,
|
|
||||||
);
|
|
||||||
// We use this signal generated by our signals enum to tell QML that
|
// We use this signal generated by our signals enum to tell QML that
|
||||||
// the active service_item has changed which is used to reposition views.
|
// the active service_item has changed which is used to reposition views.
|
||||||
self.as_mut().emit_active_changed(&index);
|
self.as_mut().active_changed(&index);
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -796,10 +776,10 @@ impl qobject::ServiceItemModel {
|
||||||
let br =
|
let br =
|
||||||
&self.as_ref().index(rc, 0, &QModelIndex::default());
|
&self.as_ref().index(rc, 0, &QModelIndex::default());
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles.append(self.get_role(Role::ActiveRole));
|
vector_roles.append(self.get_role(ServiceRoles::Active));
|
||||||
if let Some(service_item) = self
|
if let Some(service_item) = self
|
||||||
.as_mut()
|
.as_mut().rust_mut()
|
||||||
.service_items_mut()
|
.service_items
|
||||||
.get_mut(index as usize)
|
.get_mut(index as usize)
|
||||||
{
|
{
|
||||||
println!("service_item is activating {:?}", index);
|
println!("service_item is activating {:?}", index);
|
||||||
|
@ -816,11 +796,7 @@ impl qobject::ServiceItemModel {
|
||||||
service_item.background_type
|
service_item.background_type
|
||||||
);
|
);
|
||||||
service_item.active = false;
|
service_item.active = false;
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(tl, br, &vector_roles);
|
||||||
tl,
|
|
||||||
br,
|
|
||||||
&vector_roles,
|
|
||||||
);
|
|
||||||
// We use this signal generated by our signals enum to tell QML that
|
// We use this signal generated by our signals enum to tell QML that
|
||||||
// the active service_item has changed which is used to reposition views.
|
// the active service_item has changed which is used to reposition views.
|
||||||
// self.as_mut().emit_active_changed(index);
|
// self.as_mut().emit_active_changed(index);
|
||||||
|
@ -840,7 +816,7 @@ impl qobject::ServiceItemModel {
|
||||||
println!("archive: {:?}", lf);
|
println!("archive: {:?}", lf);
|
||||||
let encoder = Encoder::new(lf, 3).unwrap();
|
let encoder = Encoder::new(lf, 3).unwrap();
|
||||||
let mut tar = Builder::new(encoder);
|
let mut tar = Builder::new(encoder);
|
||||||
let items = self.service_items();
|
let items = &self.service_items;
|
||||||
let mut temp_dir = dirs::data_dir().unwrap();
|
let mut temp_dir = dirs::data_dir().unwrap();
|
||||||
temp_dir.push("lumina");
|
temp_dir.push("lumina");
|
||||||
let mut s: String =
|
let mut s: String =
|
||||||
|
@ -1244,7 +1220,7 @@ impl qobject::ServiceItemModel {
|
||||||
}
|
}
|
||||||
let text = QStringList::from(&text_list);
|
let text = QStringList::from(&text_list);
|
||||||
|
|
||||||
let service_item = ServiceItm {
|
let service_item = ServiceItem {
|
||||||
name,
|
name,
|
||||||
ty,
|
ty,
|
||||||
text,
|
text,
|
||||||
|
@ -1276,53 +1252,53 @@ impl qobject::ServiceItemModel {
|
||||||
// Don't actually need
|
// Don't actually need
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_role(&self, role: Role) -> i32 {
|
fn get_role(&self, role: ServiceRoles) -> i32 {
|
||||||
match role {
|
match role {
|
||||||
Role::NameRole => 0,
|
ServiceRoles::Name => 0,
|
||||||
Role::TyRole => 1,
|
ServiceRoles::Type => 1,
|
||||||
Role::AudioRole => 2,
|
ServiceRoles::Audio => 2,
|
||||||
Role::BackgroundRole => 3,
|
ServiceRoles::Background => 3,
|
||||||
Role::BackgroundTypeRole => 4,
|
ServiceRoles::BackgroundType => 4,
|
||||||
Role::TextRole => 5,
|
ServiceRoles::Text => 5,
|
||||||
Role::FontRole => 6,
|
ServiceRoles::Font => 6,
|
||||||
Role::FontSizeRole => 7,
|
ServiceRoles::FontSize => 7,
|
||||||
Role::SlideCountRole => 8,
|
ServiceRoles::SlideCount => 8,
|
||||||
Role::ActiveRole => 9,
|
ServiceRoles::Active => 9,
|
||||||
Role::SelectedRole => 10,
|
ServiceRoles::Selected => 10,
|
||||||
Role::LoopingRole => 11,
|
ServiceRoles::Looping => 11,
|
||||||
Role::VideoStartTimeRole => 12,
|
ServiceRoles::VideoStartTime => 12,
|
||||||
Role::VideoEndTimeRole => 13,
|
ServiceRoles::VideoEndTime => 13,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// QAbstractListModel implementation
|
// QAbstractListModel implementation
|
||||||
impl qobject::ServiceItemMod {
|
impl service_item_model::ServiceItemModel {
|
||||||
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
||||||
let role = qobject::Roles { repr: role };
|
let role = ServiceRoles { repr: role };
|
||||||
if let Some(service_item) =
|
if let Some(service_item) =
|
||||||
self.service_items().get(index.row() as usize)
|
self.service_items.get(index.row() as usize)
|
||||||
{
|
{
|
||||||
return match role {
|
return match role {
|
||||||
qobject::Roles::Name => QVariant::from(&service_item.name),
|
ServiceRoles::Name => QVariant::from(&service_item.name),
|
||||||
qobject::Roles::Type => QVariant::from(&service_item.ty),
|
ServiceRoles::Type => QVariant::from(&service_item.ty),
|
||||||
qobject::Roles::Audio => QVariant::from(&service_item.audio),
|
ServiceRoles::Audio => QVariant::from(&service_item.audio),
|
||||||
qobject::Roles::Background => QVariant::from(&service_item.background),
|
ServiceRoles::Background => QVariant::from(&service_item.background),
|
||||||
qobject::Roles::BackgroundType => {
|
ServiceRoles::BackgroundType => {
|
||||||
QVariant::from(&service_item.background_type)
|
QVariant::from(&service_item.background_type)
|
||||||
}
|
}
|
||||||
qobject::Roles::Text => QVariant::from(&service_item.text),
|
ServiceRoles::Text => QVariant::from(&service_item.text),
|
||||||
qobject::Roles::Font => QVariant::from(&service_item.font),
|
ServiceRoles::Font => QVariant::from(&service_item.font),
|
||||||
qobject::Roles::FontSize => QVariant::from(&service_item.font_size),
|
ServiceRoles::FontSize => QVariant::from(&service_item.font_size),
|
||||||
qobject::Roles::SlideCount => QVariant::from(&service_item.slide_count),
|
ServiceRoles::SlideCount => QVariant::from(&service_item.slide_count),
|
||||||
qobject::Roles::Active => QVariant::from(&service_item.active),
|
ServiceRoles::Active => QVariant::from(&service_item.active),
|
||||||
qobject::Roles::Selected => QVariant::from(&service_item.selected),
|
ServiceRoles::Selected => QVariant::from(&service_item.selected),
|
||||||
qobject::Roles::Looping => QVariant::from(&service_item.looping),
|
ServiceRoles::Looping => QVariant::from(&service_item.looping),
|
||||||
qobject::Roles::VideoStartTime => {
|
ServiceRoles::VideoStartTime => {
|
||||||
QVariant::from(&service_item.video_start_time)
|
QVariant::from(&service_item.video_start_time)
|
||||||
}
|
}
|
||||||
qobject::Roles::VideoEndTime => {
|
ServiceRoles::VideoEndTime => {
|
||||||
QVariant::from(&service_item.video_end_time)
|
QVariant::from(&service_item.video_end_time)
|
||||||
}
|
}
|
||||||
_ => QVariant::default(),
|
_ => QVariant::default(),
|
||||||
|
@ -1332,53 +1308,49 @@ impl qobject::ServiceItemMod {
|
||||||
QVariant::default()
|
QVariant::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example of overriding a C++ virtual method and calling the base class implementation.
|
// // Example of overriding a C++ virtual method and calling the base class implementation.
|
||||||
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
// pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
||||||
self.base_can_fetch_more(parent)
|
// self.base_can_fetch_more(parent)
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
||||||
let mut roles = QHash_i32_QByteArray::default();
|
let mut roles = QHash_i32_QByteArray::default();
|
||||||
roles.insert(qobject::Roles::Name.repr, cxx_qt_lib::QByteArray::from("name"));
|
roles.insert(ServiceRoles::Name.repr, QByteArray::from("name"));
|
||||||
roles.insert(qobject::Roles::Type.repr, cxx_qt_lib::QByteArray::from("ty"));
|
roles.insert(ServiceRoles::Type.repr, QByteArray::from("ty"));
|
||||||
roles.insert(qobject::Roles::Audio.repr, cxx_qt_lib::QByteArray::from("audio"));
|
roles.insert(ServiceRoles::Audio.repr, QByteArray::from("audio"));
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Background.repr,
|
ServiceRoles::Background.repr,
|
||||||
cxx_qt_lib::QByteArray::from("background"),
|
QByteArray::from("background"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::BackgroundType,
|
ServiceRoles::BackgroundType.repr,
|
||||||
cxx_qt_lib::QByteArray::from("backgroundType"),
|
QByteArray::from("backgroundType"),
|
||||||
);
|
);
|
||||||
roles.insert(qobject::Roles::Text.repr, cxx_qt_lib::QByteArray::from("text"));
|
roles.insert(ServiceRoles::Text.repr, QByteArray::from("text"));
|
||||||
roles.insert(qobject::Roles::Font.repr, cxx_qt_lib::QByteArray::from("font"));
|
roles.insert(ServiceRoles::Font.repr, QByteArray::from("font"));
|
||||||
roles.insert(qobject::Roles::FontSize.repr, cxx_qt_lib::QByteArray::from("fontSize"));
|
roles.insert(ServiceRoles::FontSize.repr, QByteArray::from("fontSize"));
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::SlideCount.repr,
|
ServiceRoles::SlideCount.repr,
|
||||||
cxx_qt_lib::QByteArray::from("slideCount"),
|
QByteArray::from("slideCount"),
|
||||||
);
|
);
|
||||||
roles.insert(qobject::Roles::Active.repr, cxx_qt_lib::QByteArray::from("active"));
|
roles.insert(ServiceRoles::Active.repr, QByteArray::from("active"));
|
||||||
roles
|
roles
|
||||||
.insert(qobject::Roles::Selected.repr, cxx_qt_lib::QByteArray::from("selected"));
|
.insert(ServiceRoles::Selected.repr, QByteArray::from("selected"));
|
||||||
roles.insert(qobject::Roles::Looping.repr, cxx_qt_lib::QByteArray::from("looping"));
|
roles.insert(ServiceRoles::Looping.repr, QByteArray::from("looping"));
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::VideoStartTime.repr,
|
ServiceRoles::VideoStartTime.repr,
|
||||||
cxx_qt_lib::QByteArray::from("videoStartTime"),
|
QByteArray::from("videoStartTime"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::VideoEndTime.repr,
|
ServiceRoles::VideoEndTime.repr,
|
||||||
cxx_qt_lib::QByteArray::from("videoEndTime"),
|
QByteArray::from("videoEndTime"),
|
||||||
);
|
);
|
||||||
roles
|
roles
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
pub fn row_count(&self, _parent: &QModelIndex) -> i32 {
|
||||||
let cnt = self.rust().service_items.len() as i32;
|
let cnt = self.service_items.len() as i32;
|
||||||
// println!("row count is {cnt}");
|
// println!("row count is {cnt}");
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn count(&self) -> i32 {
|
|
||||||
self.rust().service_items.len() as i32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ mod service_thing {
|
||||||
}
|
}
|
||||||
|
|
||||||
use cxx_qt_lib::QString;
|
use cxx_qt_lib::QString;
|
||||||
|
use std::pin::Pin;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct ServiceThingRust {
|
pub struct ServiceThingRust {
|
||||||
|
@ -63,7 +64,7 @@ impl Default for ServiceThingRust {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::ServiceThing {
|
impl service_thing::ServiceThing {
|
||||||
pub fn activate(self: Pin<&mut Self>) {
|
pub fn activate(self: Pin<&mut Self>) {
|
||||||
println!("{}", self.active());
|
println!("{}", self.active());
|
||||||
let active: bool = *self.active();
|
let active: bool = *self.active();
|
||||||
|
|
|
@ -25,8 +25,10 @@ mod settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
use configparser::ini::Ini;
|
use configparser::ini::Ini;
|
||||||
|
use cxx_qt::CxxQtType;
|
||||||
|
use cxx_qt_lib::{QString, QUrl};
|
||||||
use dirs;
|
use dirs;
|
||||||
use std::path::PathBuf;
|
use std::{path::PathBuf, pin::Pin};
|
||||||
|
|
||||||
// In order for settings to save to the ini file,
|
// In order for settings to save to the ini file,
|
||||||
// I'll need to create my own setting functions I think.
|
// I'll need to create my own setting functions I think.
|
||||||
|
@ -52,19 +54,19 @@ impl Default for SettingsRust {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::Settings {
|
impl settings::Settings {
|
||||||
pub fn setup(mut self: Pin<&mut Self>) {
|
pub fn setup(mut self: Pin<&mut Self>) {
|
||||||
let home = dirs::config_dir();
|
let home = dirs::config_dir();
|
||||||
println!("{:?}", home);
|
println!("{:?}", home);
|
||||||
if let Some(mut conf) = home {
|
if let Some(mut conf) = home {
|
||||||
conf.push("lumina");
|
conf.push("lumina");
|
||||||
conf.push("lumina.conf");
|
conf.push("lumina.conf");
|
||||||
match self.as_mut().config_mut().load(conf) {
|
match self.as_mut().rust_mut().config.load(conf) {
|
||||||
Ok(map) => {
|
Ok(map) => {
|
||||||
// println!("{:?}", self.rust().config);
|
// println!("{:?}", self.rust().config);
|
||||||
let sf = self
|
let sf = self
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.config()
|
.config
|
||||||
.get("General", "lastSaveFile");
|
.get("General", "lastSaveFile");
|
||||||
println!("{:?}", sf);
|
println!("{:?}", sf);
|
||||||
if let Some(s) = sf {
|
if let Some(s) = sf {
|
||||||
|
@ -87,7 +89,7 @@ impl qobject::Settings {
|
||||||
|
|
||||||
pub fn set_save_file(mut self: Pin<&mut Self>, file: QUrl) {
|
pub fn set_save_file(mut self: Pin<&mut Self>, file: QUrl) {
|
||||||
println!("{file}");
|
println!("{file}");
|
||||||
match self.as_mut().config_mut().set(
|
match self.as_mut().rust_mut().config.set(
|
||||||
"General",
|
"General",
|
||||||
"lastSaveFile",
|
"lastSaveFile",
|
||||||
Some(file.to_string()),
|
Some(file.to_string()),
|
||||||
|
@ -96,7 +98,7 @@ impl qobject::Settings {
|
||||||
println!(
|
println!(
|
||||||
"set-save-file: {:?}",
|
"set-save-file: {:?}",
|
||||||
self.as_mut()
|
self.as_mut()
|
||||||
.config_mut()
|
.config
|
||||||
.get("General", "lastSaveFile")
|
.get("General", "lastSaveFile")
|
||||||
);
|
);
|
||||||
if let Err(e) = self.as_mut().write() {
|
if let Err(e) = self.as_mut().write() {
|
||||||
|
@ -112,7 +114,7 @@ impl qobject::Settings {
|
||||||
let mut file = dirs::config_dir().unwrap();
|
let mut file = dirs::config_dir().unwrap();
|
||||||
file.push("lumina");
|
file.push("lumina");
|
||||||
file.push("lumina.conf");
|
file.push("lumina.conf");
|
||||||
match self.as_mut().config_mut().write(file) {
|
match self.as_mut().config.write(file) {
|
||||||
Ok(_s) => Ok("Saved File"),
|
Ok(_s) => Ok("Saved File"),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("error: {:?}", e);
|
println!("error: {:?}", e);
|
||||||
|
|
|
@ -27,7 +27,7 @@ mod slide_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qenum(SlideModel)]
|
#[qenum(SlideModel)]
|
||||||
enum Role {
|
enum SlideRoles {
|
||||||
Ty,
|
Ty,
|
||||||
Text,
|
Text,
|
||||||
Audio,
|
Audio,
|
||||||
|
@ -39,7 +39,7 @@ mod slide_model {
|
||||||
FontSize,
|
FontSize,
|
||||||
ServiceItemId,
|
ServiceItemId,
|
||||||
SlideIndex,
|
SlideIndex,
|
||||||
ImageCount,
|
SlideCount,
|
||||||
Active,
|
Active,
|
||||||
Selected,
|
Selected,
|
||||||
Looping,
|
Looping,
|
||||||
|
@ -53,6 +53,7 @@ mod slide_model {
|
||||||
#[qobject]
|
#[qobject]
|
||||||
#[base = "QAbstractListModel"]
|
#[base = "QAbstractListModel"]
|
||||||
#[qml_element]
|
#[qml_element]
|
||||||
|
#[qproperty(i32, count)]
|
||||||
type SlideModel = super::SlideModelRust;
|
type SlideModel = super::SlideModelRust;
|
||||||
|
|
||||||
#[inherit]
|
#[inherit]
|
||||||
|
@ -186,17 +187,25 @@ mod slide_model {
|
||||||
fn row_count(self: &SlideModel, _parent: &QModelIndex)
|
fn row_count(self: &SlideModel, _parent: &QModelIndex)
|
||||||
-> i32;
|
-> i32;
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
fn count(self: &SlideModel) -> i32;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::ffmpeg;
|
use crate::ffmpeg;
|
||||||
use cxx_qt_lib::CaseSensitivity;
|
use crate::slide_model::slide_model::QList_QString;
|
||||||
use std::path::PathBuf;
|
use cxx_qt::{CxxQtType, Threading};
|
||||||
|
use cxx_qt_lib::{
|
||||||
|
CaseSensitivity, QByteArray, QModelIndex, QString, QStringList,
|
||||||
|
QVariant,
|
||||||
|
};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
use std::{path::PathBuf, pin::Pin};
|
||||||
use tracing::{debug, debug_span, error, info, instrument};
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
|
|
||||||
|
use self::slide_model::{
|
||||||
|
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
|
||||||
|
SlideRoles,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Slide {
|
pub struct Slide {
|
||||||
text: QString,
|
text: QString,
|
||||||
|
@ -250,20 +259,22 @@ impl Default for Slide {
|
||||||
pub struct SlideModelRust {
|
pub struct SlideModelRust {
|
||||||
id: i32,
|
id: i32,
|
||||||
slides: Vec<Slide>,
|
slides: Vec<Slide>,
|
||||||
|
count: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::SlideModel {
|
impl slide_model::SlideModel {
|
||||||
pub fn add_video_thumbnail(
|
pub fn add_video_thumbnail(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles.append(self.get_role(Role::VideoThumbnailRole));
|
vector_roles
|
||||||
|
.append(self.get_role(SlideRoles::VideoThumbnail));
|
||||||
|
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.index(index, 0, &QModelIndex::default());
|
&self.index(index, 0, &QModelIndex::default());
|
||||||
if let Some(slide) =
|
if let Some(slide) =
|
||||||
self.as_mut().slides_mut().get_mut(index as usize)
|
self.as_mut().rust_mut().slides.get_mut(index as usize)
|
||||||
{
|
{
|
||||||
if !slide.video_background.is_empty() {
|
if !slide.video_background.is_empty() {
|
||||||
let path =
|
let path =
|
||||||
|
@ -274,7 +285,7 @@ impl qobject::SlideModel {
|
||||||
.insert(0, &QString::from("file://"))
|
.insert(0, &QString::from("file://"))
|
||||||
.to_owned();
|
.to_owned();
|
||||||
slide.video_thumbnail = video;
|
slide.video_thumbnail = video;
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
|
@ -288,7 +299,7 @@ impl qobject::SlideModel {
|
||||||
println!("CLEARING ALL SLIDES");
|
println!("CLEARING ALL SLIDES");
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_reset_model();
|
self.as_mut().begin_reset_model();
|
||||||
self.as_mut().slides_mut().clear();
|
self.as_mut().rust_mut().slides.clear();
|
||||||
self.as_mut().end_reset_model();
|
self.as_mut().end_reset_model();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,7 +310,7 @@ impl qobject::SlideModel {
|
||||||
_service_item: &QMap_QString_QVariant,
|
_service_item: &QMap_QString_QVariant,
|
||||||
) {
|
) {
|
||||||
println!("Rusty-Removal-Time: {:?}", index);
|
println!("Rusty-Removal-Time: {:?}", index);
|
||||||
let slides = self.slides().clone();
|
let slides = self.slides.clone();
|
||||||
let slides_iter = slides.iter();
|
let slides_iter = slides.iter();
|
||||||
for (i, slide) in slides_iter.enumerate().rev() {
|
for (i, slide) in slides_iter.enumerate().rev() {
|
||||||
if slide.service_item_id == index {
|
if slide.service_item_id == index {
|
||||||
|
@ -307,7 +318,7 @@ impl qobject::SlideModel {
|
||||||
println!("Removing-slide: {:?}", i);
|
println!("Removing-slide: {:?}", i);
|
||||||
} else if slide.service_item_id > index {
|
} else if slide.service_item_id > index {
|
||||||
if let Some(slide) =
|
if let Some(slide) =
|
||||||
self.as_mut().slides_mut().get_mut(i)
|
self.as_mut().rust_mut().slides.get_mut(i)
|
||||||
{
|
{
|
||||||
println!("changing-serviceid-of: {:?}", i);
|
println!("changing-serviceid-of: {:?}", i);
|
||||||
println!(
|
println!(
|
||||||
|
@ -322,7 +333,7 @@ impl qobject::SlideModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) {
|
||||||
if index < 0 || (index as usize) >= self.slides().len() {
|
if index < 0 || (index as usize) >= self.slides.len() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,24 +343,27 @@ impl qobject::SlideModel {
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut().slides_mut().remove(index as usize);
|
self.as_mut().rust_mut().slides.remove(index as usize);
|
||||||
self.as_mut().end_remove_rows();
|
self.as_mut().end_remove_rows();
|
||||||
}
|
}
|
||||||
println!("removed-row: {:?}", index);
|
println!("removed-row: {:?}", index);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_slide(mut self: Pin<&mut Self>, slide: &Slide) {
|
fn add_slide(mut self: Pin<&mut Self>, slide: &Slide) {
|
||||||
let index = self.as_ref().slides().len() as i32;
|
let index = self.as_ref().slides.len() as i32;
|
||||||
println!("{:?}", slide);
|
println!("{:?}", slide);
|
||||||
let slide = slide.clone();
|
let slide = slide.clone();
|
||||||
|
|
||||||
|
let count = self.as_ref().count;
|
||||||
|
self.as_mut().set_count(count + 1);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_insert_rows(
|
self.as_mut().begin_insert_rows(
|
||||||
&QModelIndex::default(),
|
&QModelIndex::default(),
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut().slides_mut().push(slide);
|
self.as_mut().rust_mut().slides.push(slide);
|
||||||
self.as_mut().end_insert_rows();
|
self.as_mut().end_insert_rows();
|
||||||
}
|
}
|
||||||
let thread = self.qt_thread();
|
let thread = self.qt_thread();
|
||||||
|
@ -377,7 +391,10 @@ impl qobject::SlideModel {
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut().slides_mut().insert(index as usize, slide);
|
self.as_mut()
|
||||||
|
.rust_mut()
|
||||||
|
.slides
|
||||||
|
.insert(index as usize, slide);
|
||||||
self.as_mut().end_insert_rows();
|
self.as_mut().end_insert_rows();
|
||||||
}
|
}
|
||||||
let thread = self.qt_thread();
|
let thread = self.qt_thread();
|
||||||
|
@ -503,7 +520,8 @@ impl qobject::SlideModel {
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
slide.video_thumbnail = QString::from("");
|
slide.video_thumbnail = QString::from("");
|
||||||
|
|
||||||
let slides_iter = self.as_mut().slides_mut().iter_mut();
|
let mut binding = self.as_mut().rust_mut();
|
||||||
|
let slides_iter = binding.slides.iter_mut();
|
||||||
let mut slide_index = 0;
|
let mut slide_index = 0;
|
||||||
for (i, slide) in slides_iter.enumerate().rev() {
|
for (i, slide) in slides_iter.enumerate().rev() {
|
||||||
if slide.service_item_id == index {
|
if slide.service_item_id == index {
|
||||||
|
@ -513,7 +531,7 @@ impl qobject::SlideModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need to move all the current slides service_item_id's up by one.
|
// We need to move all the current slides service_item_id's up by one.
|
||||||
let slides_iter = self.as_mut().slides_mut().iter_mut();
|
let slides_iter = binding.slides.iter_mut();
|
||||||
for slide in
|
for slide in
|
||||||
slides_iter.filter(|x| x.service_item_id >= index)
|
slides_iter.filter(|x| x.service_item_id >= index)
|
||||||
{
|
{
|
||||||
|
@ -747,7 +765,7 @@ impl qobject::SlideModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
let move_down = source_index < destination_index;
|
let move_down = source_index < destination_index;
|
||||||
let slides = self.slides().clone();
|
let slides = self.slides.clone();
|
||||||
let slides_iter = slides.iter();
|
let slides_iter = slides.iter();
|
||||||
|
|
||||||
let mut first_slide = 0;
|
let mut first_slide = 0;
|
||||||
|
@ -798,7 +816,7 @@ impl qobject::SlideModel {
|
||||||
println!("RUST_dest_slide: {:?}", dest_slide);
|
println!("RUST_dest_slide: {:?}", dest_slide);
|
||||||
println!("RUST_len: {:?}", self.rust().slides.len());
|
println!("RUST_len: {:?}", self.rust().slides.len());
|
||||||
|
|
||||||
let slides = self.slides().clone();
|
let slides = self.slides.clone();
|
||||||
let slides_iter = slides.iter();
|
let slides_iter = slides.iter();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -824,7 +842,7 @@ impl qobject::SlideModel {
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
if let Some(slide) =
|
if let Some(slide) =
|
||||||
self.as_mut().slides_mut().get_mut(i)
|
self.as_mut().rust_mut().slides.get_mut(i)
|
||||||
{
|
{
|
||||||
println!(
|
println!(
|
||||||
"rust: these ones right here officer. from {:?} to {:?}",
|
"rust: these ones right here officer. from {:?} to {:?}",
|
||||||
|
@ -841,7 +859,7 @@ impl qobject::SlideModel {
|
||||||
.filter(|x| x.0 < (dest_slide + count) as usize)
|
.filter(|x| x.0 < (dest_slide + count) as usize)
|
||||||
{
|
{
|
||||||
if let Some(slide) =
|
if let Some(slide) =
|
||||||
self.as_mut().slides_mut().get_mut(i)
|
self.as_mut().rust_mut().slides.get_mut(i)
|
||||||
{
|
{
|
||||||
println!(
|
println!(
|
||||||
"rust: these ones right here officer. from {:?} to {:?}",
|
"rust: these ones right here officer. from {:?} to {:?}",
|
||||||
|
@ -854,7 +872,8 @@ impl qobject::SlideModel {
|
||||||
} else {
|
} else {
|
||||||
if let Some(slide) = self
|
if let Some(slide) = self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.slides_mut()
|
.rust_mut()
|
||||||
|
.slides
|
||||||
.get_mut(dest_slide as usize)
|
.get_mut(dest_slide as usize)
|
||||||
{
|
{
|
||||||
println!(
|
println!(
|
||||||
|
@ -873,7 +892,7 @@ impl qobject::SlideModel {
|
||||||
.filter(|x| x.1.service_item_id >= source_index)
|
.filter(|x| x.1.service_item_id >= source_index)
|
||||||
{
|
{
|
||||||
if let Some(slide) =
|
if let Some(slide) =
|
||||||
self.as_mut().slides_mut().get_mut(i)
|
self.as_mut().rust_mut().slides.get_mut(i)
|
||||||
{
|
{
|
||||||
println!(
|
println!(
|
||||||
"rust-switching-service: {:?} to {:?}",
|
"rust-switching-service: {:?} to {:?}",
|
||||||
|
@ -894,7 +913,7 @@ impl qobject::SlideModel {
|
||||||
.filter(|x| x.1.service_item_id <= source_index)
|
.filter(|x| x.1.service_item_id <= source_index)
|
||||||
{
|
{
|
||||||
if let Some(slide) =
|
if let Some(slide) =
|
||||||
self.as_mut().slides_mut().get_mut(i)
|
self.as_mut().rust_mut().slides.get_mut(i)
|
||||||
{
|
{
|
||||||
println!(
|
println!(
|
||||||
"rust-switching-service-of: {:?} to {:?}",
|
"rust-switching-service-of: {:?} to {:?}",
|
||||||
|
@ -929,12 +948,14 @@ impl qobject::SlideModel {
|
||||||
let move_amount =
|
let move_amount =
|
||||||
dest_index - source_index - count + 1;
|
dest_index - source_index - count + 1;
|
||||||
// println!("rust-move_amount: {:?}", move_amount);
|
// println!("rust-move_amount: {:?}", move_amount);
|
||||||
self.as_mut().slides_mut()[source_index..=dest_index]
|
self.as_mut().rust_mut().slides
|
||||||
|
[source_index..=dest_index]
|
||||||
.rotate_right(move_amount);
|
.rotate_right(move_amount);
|
||||||
} else {
|
} else {
|
||||||
let move_amount = end_slide - dest_index - count + 1;
|
let move_amount = end_slide - dest_index - count + 1;
|
||||||
println!("rust-move_amount: {:?}", move_amount);
|
println!("rust-move_amount: {:?}", move_amount);
|
||||||
self.as_mut().slides_mut()[dest_index..=end_slide]
|
self.as_mut().rust_mut().slides
|
||||||
|
[dest_index..=end_slide]
|
||||||
.rotate_left(move_amount);
|
.rotate_left(move_amount);
|
||||||
}
|
}
|
||||||
self.as_mut().end_reset_model();
|
self.as_mut().end_reset_model();
|
||||||
|
@ -968,17 +989,17 @@ impl qobject::SlideModel {
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
index: i32,
|
index: i32,
|
||||||
) -> i32 {
|
) -> i32 {
|
||||||
let slides = self.slides().clone();
|
let slides = self.slides.clone();
|
||||||
let slides_iter = slides.iter();
|
let slides_iter = slides.iter();
|
||||||
debug!(service_item = index, "Getting slide from this item");
|
debug!(service_item = index, "Getting slide from this item");
|
||||||
let mut id = 0;
|
let mut id = 0;
|
||||||
for (i, slide) in slides_iter
|
if let Some((i, slide)) = slides_iter
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|(i, slide)| slide.service_item_id == index)
|
.filter(|(i, slide)| slide.service_item_id == index)
|
||||||
|
.next()
|
||||||
{
|
{
|
||||||
debug!(slide_id = i, ?slide);
|
debug!(slide_id = i, ?slide);
|
||||||
id = i as i32;
|
id = i as i32;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
@ -988,13 +1009,13 @@ impl qobject::SlideModel {
|
||||||
let tl = &self.as_ref().index(0, 0, &QModelIndex::default());
|
let tl = &self.as_ref().index(0, 0, &QModelIndex::default());
|
||||||
let br = &self.as_ref().index(rc, 0, &QModelIndex::default());
|
let br = &self.as_ref().index(rc, 0, &QModelIndex::default());
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles.append(self.get_role(Role::ActiveRole));
|
vector_roles.append(self.get_role(SlideRoles::Active));
|
||||||
for slide in self.as_mut().slides_mut().iter_mut() {
|
for slide in self.as_mut().rust_mut().slides.iter_mut() {
|
||||||
// println!("slide is deactivating {:?}", i);
|
// println!("slide is deactivating {:?}", i);
|
||||||
slide.active = false;
|
slide.active = false;
|
||||||
}
|
}
|
||||||
if let Some(slide) =
|
if let Some(slide) =
|
||||||
self.as_mut().slides_mut().get_mut(index as usize)
|
self.as_mut().rust_mut().slides.get_mut(index as usize)
|
||||||
{
|
{
|
||||||
debug!(
|
debug!(
|
||||||
slide = index,
|
slide = index,
|
||||||
|
@ -1012,83 +1033,79 @@ impl qobject::SlideModel {
|
||||||
// slide.video_background
|
// slide.video_background
|
||||||
// );
|
// );
|
||||||
slide.active = true;
|
slide.active = true;
|
||||||
self.as_mut().emit_data_changed(tl, br, &vector_roles);
|
self.as_mut().data_changed(tl, br, &vector_roles);
|
||||||
// We use this signal generated by our signals enum to tell QML that
|
// We use this signal generated by our signals enum to tell QML that
|
||||||
// the active slide has changed which is used to reposition views.
|
// the active slide has changed which is used to reposition views.
|
||||||
self.as_mut().emit_active_changed(&index);
|
self.as_mut().active_change(&index);
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_role(&self, role: Role) -> i32 {
|
fn get_role(&self, role: SlideRoles) -> i32 {
|
||||||
match role {
|
match role {
|
||||||
Role::TextRole => 1,
|
SlideRoles::Text => 1,
|
||||||
Role::ActiveRole => 12,
|
SlideRoles::Active => 12,
|
||||||
Role::SelectedRole => 13,
|
SlideRoles::Selected => 13,
|
||||||
Role::LoopingRole => 14,
|
SlideRoles::Looping => 14,
|
||||||
Role::VideoThumbnailRole => 15,
|
SlideRoles::VideoThumbnail => 15,
|
||||||
Role::VideoStartTimeRole => 16,
|
SlideRoles::VideoStartTime => 16,
|
||||||
Role::VideoEndTimeRole => 17,
|
SlideRoles::VideoEndTime => 17,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// QAbstractListModel implementation
|
// QAbstractListModel implementation
|
||||||
impl qobject::SlideModel {
|
impl slide_model::SlideModel {
|
||||||
pub fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
pub fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
||||||
let role = qobject::Roles { repr: role };
|
let role = SlideRoles { repr: role };
|
||||||
if let Some(slide) = self.slides().get(index.row() as usize) {
|
if let Some(slide) = self.slides.get(index.row() as usize) {
|
||||||
return match role {
|
return match role {
|
||||||
qobject::Roles::Ty => QVariant::from(&slide.ty),
|
SlideRoles::Ty => QVariant::from(&slide.ty),
|
||||||
qobject::Roles::Text => QVariant::from(&slide.text),
|
SlideRoles::Text => QVariant::from(&slide.text),
|
||||||
qobject::Roles::Audio => QVariant::from(&slide.audio),
|
SlideRoles::Audio => QVariant::from(&slide.audio),
|
||||||
qobject::Roles::ImageBackground => {
|
SlideRoles::ImageBackground => {
|
||||||
QVariant::from(&slide.image_background)
|
QVariant::from(&slide.image_background)
|
||||||
}
|
}
|
||||||
qobject::Roles::VideoBackground => {
|
SlideRoles::VideoBackground => {
|
||||||
QVariant::from(&slide.video_background)
|
QVariant::from(&slide.video_background)
|
||||||
}
|
}
|
||||||
qobject::Roles::HTextAlignment => {
|
SlideRoles::HTextAlignment => {
|
||||||
QVariant::from(&slide.htext_alignment)
|
QVariant::from(&slide.htext_alignment)
|
||||||
}
|
}
|
||||||
qobject::Roles::VTextAlignment => {
|
SlideRoles::VTextAlignment => {
|
||||||
QVariant::from(&slide.vtext_alignment)
|
QVariant::from(&slide.vtext_alignment)
|
||||||
}
|
}
|
||||||
qobject::Roles::Font => QVariant::from(&slide.font),
|
SlideRoles::Font => QVariant::from(&slide.font),
|
||||||
qobject::Roles::FontSize => {
|
SlideRoles::FontSize => {
|
||||||
QVariant::from(&slide.font_size)
|
QVariant::from(&slide.font_size)
|
||||||
}
|
}
|
||||||
qobject::Roles::ServiceItemId => {
|
SlideRoles::ServiceItemId => {
|
||||||
QVariant::from(&slide.service_item_id)
|
QVariant::from(&slide.service_item_id)
|
||||||
}
|
}
|
||||||
qobject::Roles::SlideIndex => {
|
SlideRoles::SlideIndex => {
|
||||||
QVariant::from(&slide.slide_index)
|
QVariant::from(&slide.slide_index)
|
||||||
}
|
}
|
||||||
qobject::Roles::SlideCount => {
|
SlideRoles::SlideCount => {
|
||||||
QVariant::from(&slide.slide_count)
|
QVariant::from(&slide.slide_count)
|
||||||
}
|
}
|
||||||
qobject::Roles::Active => {
|
SlideRoles::Active => QVariant::from(&slide.active),
|
||||||
QVariant::from(&slide.active)
|
SlideRoles::Selected => {
|
||||||
}
|
|
||||||
qobject::Roles::Selected => {
|
|
||||||
QVariant::from(&slide.selected)
|
QVariant::from(&slide.selected)
|
||||||
}
|
}
|
||||||
qobject::Roles::Looping => {
|
SlideRoles::Looping => QVariant::from(&slide.looping),
|
||||||
QVariant::from(&slide.looping)
|
SlideRoles::VideoThumbnail => {
|
||||||
}
|
|
||||||
qobject::Roles::VideoThumbnail => {
|
|
||||||
QVariant::from(&slide.video_thumbnail)
|
QVariant::from(&slide.video_thumbnail)
|
||||||
}
|
}
|
||||||
qobject::Roles::VideoStartTime => {
|
SlideRoles::VideoStartTime => {
|
||||||
QVariant::from(&slide.video_start_time)
|
QVariant::from(&slide.video_start_time)
|
||||||
}
|
}
|
||||||
qobject::Roles::VideoEndTime => {
|
SlideRoles::VideoEndTime => {
|
||||||
QVariant::from(&slide.video_end_time)
|
QVariant::from(&slide.video_end_time)
|
||||||
}
|
}
|
||||||
qobject::Roles::Html => QVariant::from(&slide.html),
|
SlideRoles::Html => QVariant::from(&slide.html),
|
||||||
_ => QVariant::default(),
|
_ => QVariant::default(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1096,89 +1113,77 @@ impl qobject::SlideModel {
|
||||||
QVariant::default()
|
QVariant::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example of overriding a C++ virtual method and calling the base class implementation.
|
// // Example of overriding a C++ virtual method and calling the base class implementation.
|
||||||
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
// pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
||||||
self.base_can_fetch_more(parent)
|
// self.base_can_fetch_more(parent)
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
||||||
let mut roles = QHash_i32_QByteArray::default();
|
let mut roles = QHash_i32_QByteArray::default();
|
||||||
|
roles.insert(SlideRoles::Ty.repr, QByteArray::from("type"));
|
||||||
|
roles.insert(SlideRoles::Text.repr, QByteArray::from("text"));
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Ty.repr,
|
SlideRoles::Audio.repr,
|
||||||
cxx_qt_lib::QByteArray::from("type"),
|
QByteArray::from("audio"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Text.repr,
|
SlideRoles::ImageBackground.repr,
|
||||||
cxx_qt_lib::QByteArray::from("text"),
|
QByteArray::from("imageBackground"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Audio.repr,
|
SlideRoles::VideoBackground.repr,
|
||||||
cxx_qt_lib::QByteArray::from("audio"),
|
QByteArray::from("videoBackground"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::ImageBackground.repr,
|
SlideRoles::HTextAlignment.repr,
|
||||||
cxx_qt_lib::QByteArray::from("imageBackground"),
|
QByteArray::from("hTextAlignment"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::VideoBackground.repr,
|
SlideRoles::VTextAlignment.repr,
|
||||||
cxx_qt_lib::QByteArray::from("videoBackground"),
|
QByteArray::from("vTextAlignment"),
|
||||||
|
);
|
||||||
|
roles.insert(SlideRoles::Font.repr, QByteArray::from("font"));
|
||||||
|
roles.insert(
|
||||||
|
SlideRoles::FontSize.repr,
|
||||||
|
QByteArray::from("fontSize"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::HTextAlignment.repr,
|
SlideRoles::ServiceItemId.repr,
|
||||||
cxx_qt_lib::QByteArray::from("hTextAlignment"),
|
QByteArray::from("serviceItemId"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::VTextAlignment.repr,
|
SlideRoles::SlideIndex.repr,
|
||||||
cxx_qt_lib::QByteArray::from("vTextAlignment"),
|
QByteArray::from("slideIndex"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Font.repr,
|
SlideRoles::SlideCount.repr,
|
||||||
cxx_qt_lib::QByteArray::from("font"),
|
QByteArray::from("imageCount"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::FontSize.repr,
|
SlideRoles::Active.repr,
|
||||||
cxx_qt_lib::QByteArray::from("fontSize"),
|
QByteArray::from("active"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::ServiceItemId.repr,
|
SlideRoles::Selected.repr,
|
||||||
cxx_qt_lib::QByteArray::from("serviceItemId"),
|
QByteArray::from("selected"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::SlideIndex.repr,
|
SlideRoles::Looping.repr,
|
||||||
cxx_qt_lib::QByteArray::from("slideIndex"),
|
QByteArray::from("looping"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::ImageCount.repr,
|
SlideRoles::VideoThumbnail.repr,
|
||||||
cxx_qt_lib::QByteArray::from("imageCount"),
|
QByteArray::from("videoThumbnail"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Active.repr,
|
SlideRoles::VideoStartTime.repr,
|
||||||
cxx_qt_lib::QByteArray::from("active"),
|
QByteArray::from("videoStartTime"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Selected.repr,
|
SlideRoles::VideoEndTime.repr,
|
||||||
cxx_qt_lib::QByteArray::from("selected"),
|
QByteArray::from("videoEndTime"),
|
||||||
);
|
|
||||||
roles.insert(
|
|
||||||
qobject::Roles::Looping.repr,
|
|
||||||
cxx_qt_lib::QByteArray::from("looping"),
|
|
||||||
);
|
|
||||||
roles.insert(
|
|
||||||
qobject::Roles::VideoThumbnail.repr,
|
|
||||||
cxx_qt_lib::QByteArray::from("videoThumbnail"),
|
|
||||||
);
|
|
||||||
roles.insert(
|
|
||||||
qobject::Roles::VideoStartTime.repr,
|
|
||||||
cxx_qt_lib::QByteArray::from("videoStartTime"),
|
|
||||||
);
|
|
||||||
roles.insert(
|
|
||||||
qobject::Roles::VideoEndTime.repr,
|
|
||||||
cxx_qt_lib::QByteArray::from("videoEndTime"),
|
|
||||||
);
|
|
||||||
roles.insert(
|
|
||||||
qobject::Roles::Html.repr,
|
|
||||||
cxx_qt_lib::QByteArray::from("html"),
|
|
||||||
);
|
);
|
||||||
|
roles.insert(SlideRoles::Html.repr, QByteArray::from("html"));
|
||||||
roles
|
roles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1187,8 +1192,4 @@ impl qobject::SlideModel {
|
||||||
// println!("row count is {cnt}");
|
// println!("row count is {cnt}");
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn count(&self) -> i32 {
|
|
||||||
self.rust().slides.len() as i32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ mod slide_object {
|
||||||
#[qproperty(QString, vtext_alignment)]
|
#[qproperty(QString, vtext_alignment)]
|
||||||
#[qproperty(QString, htext_alignment)]
|
#[qproperty(QString, htext_alignment)]
|
||||||
#[qproperty(QString, font)]
|
#[qproperty(QString, font)]
|
||||||
#[qproperty(bool, font_size)]
|
#[qproperty(i32, font_size)]
|
||||||
#[qproperty(f32, video_start_time)]
|
#[qproperty(f32, video_start_time)]
|
||||||
#[qproperty(f32, video_end_time)]
|
#[qproperty(f32, video_end_time)]
|
||||||
type SlideObject = super::SlideObjectRust;
|
type SlideObject = super::SlideObjectRust;
|
||||||
|
@ -81,8 +81,14 @@ mod slide_object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use std::pin::Pin;
|
||||||
|
|
||||||
|
use cxx_qt::CxxQtType;
|
||||||
|
use cxx_qt_lib::{QString, QVariant};
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
|
use self::slide_object::QMap_QString_QVariant;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct SlideObjectRust {
|
pub struct SlideObjectRust {
|
||||||
slide_index: i32,
|
slide_index: i32,
|
||||||
|
@ -128,7 +134,7 @@ impl Default for SlideObjectRust {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::SlideObject {
|
impl slide_object::SlideObject {
|
||||||
pub fn change_slide(
|
pub fn change_slide(
|
||||||
mut self: Pin<&mut Self>,
|
mut self: Pin<&mut Self>,
|
||||||
item: QMap_QString_QVariant,
|
item: QMap_QString_QVariant,
|
||||||
|
@ -153,12 +159,12 @@ impl qobject::SlideObject {
|
||||||
debug!(?html, count, slide_index);
|
debug!(?html, count, slide_index);
|
||||||
if slide_index > 0 && slide_index < count - 1 {
|
if slide_index > 0 && slide_index < count - 1 {
|
||||||
if current_index < &index {
|
if current_index < &index {
|
||||||
self.as_mut().emit(Signals::RevealNext);
|
self.as_mut().reveal_next();
|
||||||
debug!(signal = ?Signals::RevealNext);
|
debug!("RevealNext");
|
||||||
return;
|
return;
|
||||||
} else if slide_index > 0 {
|
} else if slide_index > 0 {
|
||||||
self.as_mut().emit(Signals::RevealPrev);
|
self.as_mut().reveal_prev();
|
||||||
debug!(signal = ?Signals::RevealPrev);
|
debug!("RevealPrev");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,9 +273,9 @@ impl qobject::SlideObject {
|
||||||
.get(&QString::from("fontSize"))
|
.get(&QString::from("fontSize"))
|
||||||
.unwrap_or(QVariant::from(&50));
|
.unwrap_or(QVariant::from(&50));
|
||||||
if let Some(font_size) = font_size.value::<i32>() {
|
if let Some(font_size) = font_size.value::<i32>() {
|
||||||
if &font_size != self.as_ref().font_size() {
|
if font_size != self.as_ref().font_size {
|
||||||
println!("font-size: {font_size}");
|
println!("font-size: {font_size}");
|
||||||
self.as_mut().set_font_size(font_size);
|
self.as_mut().rust_mut().font_size = font_size;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("font-size: empty");
|
println!("font-size: empty");
|
||||||
|
@ -282,8 +288,7 @@ impl qobject::SlideObject {
|
||||||
println!("looping: {looping}");
|
println!("looping: {looping}");
|
||||||
self.as_mut().set_looping(looping);
|
self.as_mut().set_looping(looping);
|
||||||
let lp = looping;
|
let lp = looping;
|
||||||
self.as_mut()
|
self.as_mut().loop_changed(lp)
|
||||||
.emit(Signals::LoopChanged { looping: &lp });
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
println!("looping: empty")
|
println!("looping: empty")
|
||||||
|
@ -308,7 +313,8 @@ impl qobject::SlideObject {
|
||||||
|
|
||||||
self.as_mut().set_slide_index(slide_index);
|
self.as_mut().set_slide_index(slide_index);
|
||||||
|
|
||||||
self.as_mut().emit(Signals::SlideChanged { slide: &index });
|
self.as_mut().slide_changed(index);
|
||||||
|
// self.as_mut().emit(Signals::SlideChanged { slide: &index });
|
||||||
println!("## Slide End ##");
|
println!("## Slide End ##");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,12 +336,12 @@ impl qobject::SlideObject {
|
||||||
}
|
}
|
||||||
pub fn play(mut self: Pin<&mut Self>) -> bool {
|
pub fn play(mut self: Pin<&mut Self>) -> bool {
|
||||||
self.as_mut().set_is_playing(true);
|
self.as_mut().set_is_playing(true);
|
||||||
self.as_mut().emit_playing_changed(&true);
|
self.as_mut().playing_changed(true);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
pub fn pause(mut self: Pin<&mut Self>) -> bool {
|
pub fn pause(mut self: Pin<&mut Self>) -> bool {
|
||||||
self.as_mut().set_is_playing(false);
|
self.as_mut().set_is_playing(false);
|
||||||
self.as_mut().emit_playing_changed(&false);
|
self.as_mut().playing_changed(false);
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
pub fn play_pause(mut self: Pin<&mut Self>) -> bool {
|
pub fn play_pause(mut self: Pin<&mut Self>) -> bool {
|
||||||
|
@ -344,7 +350,7 @@ impl qobject::SlideObject {
|
||||||
true => self.as_mut().set_is_playing(false),
|
true => self.as_mut().set_is_playing(false),
|
||||||
false => self.as_mut().set_is_playing(true),
|
false => self.as_mut().set_is_playing(true),
|
||||||
}
|
}
|
||||||
self.as_mut().emit_playing_changed(&!playing);
|
self.as_mut().playing_changed(!playing);
|
||||||
!playing
|
!playing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
pub mod song_editor {
|
pub mod song_editor {
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
use tracing::{debug, debug_span, error, info, instrument};
|
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!("cxx-qt-lib/qmap.h");
|
include!("cxx-qt-lib/qmap.h");
|
||||||
type QMap_QString_QVariant =
|
type QMap_QString_QVariant =
|
||||||
|
@ -22,108 +18,119 @@ pub mod song_editor {
|
||||||
// type CxxSongs = crate::songs::song_model::qobject::SongModel;
|
// type CxxSongs = crate::songs::song_model::qobject::SongModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
unsafe extern "RustQt" {
|
||||||
#[cxx_qt::qobject]
|
#[qobject]
|
||||||
pub struct SongEditor {
|
#[qml_element]
|
||||||
#[qproperty]
|
#[qproperty(QString, title)]
|
||||||
title: QString,
|
#[qproperty(QString, lyrics)]
|
||||||
#[qproperty]
|
#[qproperty(QString, author)]
|
||||||
lyrics: QString,
|
#[qproperty(QString, ccli)]
|
||||||
#[qproperty]
|
#[qproperty(QString, audio)]
|
||||||
author: QString,
|
#[qproperty(QString, verse_order)]
|
||||||
#[qproperty]
|
#[qproperty(bool, verse_order_error)]
|
||||||
ccli: QString,
|
#[qproperty(QString, background)]
|
||||||
#[qproperty]
|
#[qproperty(QString, background_type)]
|
||||||
audio: QString,
|
#[qproperty(QString, horizontal_text_alignment)]
|
||||||
#[qproperty]
|
#[qproperty(QString, vertical_text_alignment)]
|
||||||
verse_order: QString,
|
#[qproperty(QString, font)]
|
||||||
#[qproperty]
|
#[qproperty(i32, font_size)]
|
||||||
verse_order_error: bool,
|
#[qproperty(bool, background_exists)]
|
||||||
#[qproperty]
|
#[qproperty(bool, audio_exists)]
|
||||||
background: QString,
|
type SongEditor = super::SongEditorRust;
|
||||||
#[qproperty]
|
|
||||||
background_type: QString,
|
|
||||||
#[qproperty]
|
|
||||||
horizontal_text_alignment: QString,
|
|
||||||
#[qproperty]
|
|
||||||
vertical_text_alignment: QString,
|
|
||||||
#[qproperty]
|
|
||||||
font: QString,
|
|
||||||
#[qproperty]
|
|
||||||
font_size: i32,
|
|
||||||
#[qproperty]
|
|
||||||
background_exists: bool,
|
|
||||||
#[qproperty]
|
|
||||||
audio_exists: bool,
|
|
||||||
// #[qproperty]
|
|
||||||
// song_model: *mut CxxSongs,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for SongEditor {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
title: QString::default(),
|
|
||||||
lyrics: QString::default(),
|
|
||||||
author: QString::default(),
|
|
||||||
ccli: QString::default(),
|
|
||||||
audio: QString::default(),
|
|
||||||
verse_order: QString::default(),
|
|
||||||
verse_order_error: false,
|
|
||||||
background: QString::default(),
|
|
||||||
background_type: QString::default(),
|
|
||||||
horizontal_text_alignment: QString::default(),
|
|
||||||
vertical_text_alignment: QString::default(),
|
|
||||||
font: QString::default(),
|
|
||||||
font_size: 50,
|
|
||||||
background_exists: true,
|
|
||||||
audio_exists: true,
|
|
||||||
// song_model: std::ptr::null_mut(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl qobject::SongEditor {
|
|
||||||
fn idk(mut self: Pin<&mut Self>) {
|
|
||||||
// let mut model = self.song_model().as_mut().unwrap();
|
|
||||||
// let pinned_model = Pin::new_unchecked(model);
|
|
||||||
// pinned_model.update_ccli(0, QString::from("idk"));
|
|
||||||
todo!()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
pub fn check_verse_order(mut self: Pin<&mut Self>) {
|
fn check_verse_order(self: Pin<&mut SongEditor>);
|
||||||
let vo = self.verse_order().to_string();
|
|
||||||
let split = vo.split(" ");
|
|
||||||
debug!(verse_order = ?vo, iterator = ?split);
|
|
||||||
for s in split {
|
|
||||||
if s.contains(",") || s.is_empty() {
|
|
||||||
self.as_mut().set_verse_order_error(true);
|
|
||||||
} else {
|
|
||||||
self.as_mut().set_verse_order_error(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
pub fn check_files(mut self: Pin<&mut Self>) {
|
fn check_files(self: Pin<&mut SongEditor>);
|
||||||
let background = PathBuf::from(
|
}
|
||||||
self.background()
|
}
|
||||||
.clone()
|
|
||||||
.to_string()
|
use cxx_qt_lib::QString;
|
||||||
.trim_start_matches("file://"),
|
use std::{path::PathBuf, pin::Pin};
|
||||||
);
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
let audio = PathBuf::from(
|
|
||||||
self.audio()
|
#[derive(Clone, Debug)]
|
||||||
.clone()
|
pub struct SongEditorRust {
|
||||||
.to_string()
|
title: QString,
|
||||||
.trim_start_matches("file://"),
|
lyrics: QString,
|
||||||
);
|
author: QString,
|
||||||
debug!(
|
ccli: QString,
|
||||||
background = background.exists(),
|
audio: QString,
|
||||||
audio = audio.exists()
|
verse_order: QString,
|
||||||
);
|
verse_order_error: bool,
|
||||||
self.as_mut().set_background_exists(background.exists());
|
background: QString,
|
||||||
self.as_mut().set_audio_exists(audio.exists());
|
background_type: QString,
|
||||||
|
horizontal_text_alignment: QString,
|
||||||
|
vertical_text_alignment: QString,
|
||||||
|
font: QString,
|
||||||
|
font_size: i32,
|
||||||
|
background_exists: bool,
|
||||||
|
audio_exists: bool,
|
||||||
|
// song_model: *mut CxxSongs,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for SongEditorRust {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
title: QString::default(),
|
||||||
|
lyrics: QString::default(),
|
||||||
|
author: QString::default(),
|
||||||
|
ccli: QString::default(),
|
||||||
|
audio: QString::default(),
|
||||||
|
verse_order: QString::default(),
|
||||||
|
verse_order_error: false,
|
||||||
|
background: QString::default(),
|
||||||
|
background_type: QString::default(),
|
||||||
|
horizontal_text_alignment: QString::default(),
|
||||||
|
vertical_text_alignment: QString::default(),
|
||||||
|
font: QString::default(),
|
||||||
|
font_size: 50,
|
||||||
|
background_exists: true,
|
||||||
|
audio_exists: true,
|
||||||
|
// song_model: std::ptr::null_mut(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl song_editor::SongEditor {
|
||||||
|
fn idk(mut self: Pin<&mut Self>) {
|
||||||
|
// let mut model = self.song_model().as_mut().unwrap();
|
||||||
|
// let pinned_model = Pin::new_unchecked(model);
|
||||||
|
// pinned_model.update_ccli(0, QString::from("idk"));
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn check_verse_order(mut self: Pin<&mut Self>) {
|
||||||
|
let vo = self.verse_order().to_string();
|
||||||
|
let split = vo.split(" ");
|
||||||
|
debug!(verse_order = ?vo, iterator = ?split);
|
||||||
|
for s in split {
|
||||||
|
if s.contains(",") || s.is_empty() {
|
||||||
|
self.as_mut().set_verse_order_error(true);
|
||||||
|
} else {
|
||||||
|
self.as_mut().set_verse_order_error(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn check_files(mut self: Pin<&mut Self>) {
|
||||||
|
let background = PathBuf::from(
|
||||||
|
self.background()
|
||||||
|
.clone()
|
||||||
|
.to_string()
|
||||||
|
.trim_start_matches("file://"),
|
||||||
|
);
|
||||||
|
let audio = PathBuf::from(
|
||||||
|
self.audio()
|
||||||
|
.clone()
|
||||||
|
.to_string()
|
||||||
|
.trim_start_matches("file://"),
|
||||||
|
);
|
||||||
|
debug!(
|
||||||
|
background = background.exists(),
|
||||||
|
audio = audio.exists()
|
||||||
|
);
|
||||||
|
self.as_mut().set_background_exists(background.exists());
|
||||||
|
self.as_mut().set_audio_exists(audio.exists());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,7 @@
|
||||||
|
use std::pin::Pin;
|
||||||
|
|
||||||
use time::macros::format_description;
|
use time::macros::format_description;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
use tracing_subscriber::{
|
use tracing_subscriber::{
|
||||||
fmt::{self, time::LocalTime},
|
fmt::{self, time::LocalTime},
|
||||||
EnvFilter,
|
EnvFilter,
|
||||||
|
@ -47,30 +50,35 @@ mod db {
|
||||||
|
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod utilities {
|
mod utilities {
|
||||||
use tokio::runtime::Runtime;
|
unsafe extern "RustQt" {
|
||||||
|
#[qobject]
|
||||||
|
#[qml_element]
|
||||||
|
type Utils = super::UtilsRust;
|
||||||
|
|
||||||
#[cxx_qt::qobject]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Utils {
|
|
||||||
runtime: Runtime,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Utils {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
runtime: tokio::runtime::Runtime::new().unwrap(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl qobject::Utils {
|
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
pub fn setup(&self) {
|
fn setup(self: Pin<&mut Utils>);
|
||||||
crate::utils::setup();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct UtilsRust {
|
||||||
|
runtime: Runtime,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for UtilsRust {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
runtime: tokio::runtime::Runtime::new().unwrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl utilities::Utils {
|
||||||
|
pub fn setup(mut self: Pin<&mut Self>) {
|
||||||
|
crate::utils::setup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn setup() {
|
pub fn setup() {
|
||||||
tracing_subscriber::FmtSubscriber::builder()
|
tracing_subscriber::FmtSubscriber::builder()
|
||||||
.pretty()
|
.pretty()
|
||||||
|
|
|
@ -25,7 +25,7 @@ mod video_model {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[qenum(VideoModel)]
|
#[qenum(VideoModel)]
|
||||||
enum Role {
|
enum VideoRoles {
|
||||||
Id,
|
Id,
|
||||||
Title,
|
Title,
|
||||||
Path,
|
Path,
|
||||||
|
@ -38,7 +38,7 @@ mod video_model {
|
||||||
#[qobject]
|
#[qobject]
|
||||||
#[base = "QAbstractListModel"]
|
#[base = "QAbstractListModel"]
|
||||||
#[qml_element]
|
#[qml_element]
|
||||||
#[qproperty(i32, count_rows)]
|
#[qproperty(i32, count)]
|
||||||
type VideoModel = super::VideoModelRust;
|
type VideoModel = super::VideoModelRust;
|
||||||
|
|
||||||
#[inherit]
|
#[inherit]
|
||||||
|
@ -88,13 +88,13 @@ mod video_model {
|
||||||
fn update_start_time(
|
fn update_start_time(
|
||||||
self: Pin<&mut VideoModel>,
|
self: Pin<&mut VideoModel>,
|
||||||
index: i32,
|
index: i32,
|
||||||
updated_start_time: QString,
|
updated_start_time: f32,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
fn update_end_time(
|
fn update_end_time(
|
||||||
self: Pin<&mut VideoModel>,
|
self: Pin<&mut VideoModel>,
|
||||||
index: i32,
|
index: i32,
|
||||||
updated_end_time: QString,
|
updated_end_time: f32,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,17 +173,22 @@ mod video_model {
|
||||||
fn row_count(self: &VideoModel, _parent: &QModelIndex)
|
fn row_count(self: &VideoModel, _parent: &QModelIndex)
|
||||||
-> i32;
|
-> i32;
|
||||||
|
|
||||||
#[qinvokable]
|
|
||||||
fn count(self: &VideoModel) -> i32;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::models::*;
|
use crate::models::*;
|
||||||
use crate::schema::videos::dsl::*;
|
use crate::schema::videos::dsl::*;
|
||||||
use crate::video_model::video_model::Video;
|
use cxx_qt::CxxQtType;
|
||||||
|
use cxx_qt_lib::{QByteArray, QModelIndex, QString, QUrl, QVariant};
|
||||||
use diesel::sqlite::SqliteConnection;
|
use diesel::sqlite::SqliteConnection;
|
||||||
use diesel::{delete, insert_into, prelude::*, update};
|
use diesel::{delete, insert_into, prelude::*, update};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::pin::Pin;
|
||||||
|
|
||||||
|
use self::video_model::{
|
||||||
|
QHash_i32_QByteArray, QMap_QString_QVariant, QVector_i32,
|
||||||
|
VideoRoles,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
pub struct Video {
|
pub struct Video {
|
||||||
|
@ -197,15 +202,16 @@ pub struct Video {
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct VideoModelRust {
|
pub struct VideoModelRust {
|
||||||
|
count: i32,
|
||||||
highest_id: i32,
|
highest_id: i32,
|
||||||
videos: Vec<self::Video>,
|
videos: Vec<self::Video>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::VideoModel {
|
impl video_model::VideoModel {
|
||||||
pub fn clear(mut self: Pin<&mut Self>) {
|
pub fn clear(mut self: Pin<&mut Self>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_reset_model();
|
self.as_mut().begin_reset_model();
|
||||||
self.as_mut().videos_mut().clear();
|
self.as_mut().rust_mut().videos.clear();
|
||||||
self.as_mut().end_reset_model();
|
self.as_mut().end_reset_model();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,7 +221,7 @@ impl qobject::VideoModel {
|
||||||
let results = videos
|
let results = videos
|
||||||
.load::<crate::models::Video>(db)
|
.load::<crate::models::Video>(db)
|
||||||
.expect("Error loading videos");
|
.expect("Error loading videos");
|
||||||
self.as_mut().set_highest_id(0);
|
self.as_mut().rust_mut().highest_id = 0;
|
||||||
|
|
||||||
println!("SHOWING VIDEOS");
|
println!("SHOWING VIDEOS");
|
||||||
println!("--------------");
|
println!("--------------");
|
||||||
|
@ -224,8 +230,8 @@ impl qobject::VideoModel {
|
||||||
println!("{}", video.id);
|
println!("{}", video.id);
|
||||||
println!("{}", video.path);
|
println!("{}", video.path);
|
||||||
println!("--------------");
|
println!("--------------");
|
||||||
if self.as_mut().highest_id() < &video.id {
|
if self.as_mut().highest_id < video.id {
|
||||||
self.as_mut().set_highest_id(video.id);
|
self.as_mut().rust_mut().highest_id = video.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
let img = self::Video {
|
let img = self::Video {
|
||||||
|
@ -240,17 +246,17 @@ impl qobject::VideoModel {
|
||||||
self.as_mut().add_video(img);
|
self.as_mut().add_video(img);
|
||||||
}
|
}
|
||||||
println!("--------------------------------------");
|
println!("--------------------------------------");
|
||||||
println!("{:?}", self.as_mut().videos());
|
println!("{:?}", self.as_mut().videos);
|
||||||
println!("--------------------------------------");
|
println!("--------------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
pub fn remove_item(mut self: Pin<&mut Self>, index: i32) -> bool {
|
||||||
if index < 0 || (index as usize) >= self.videos().len() {
|
if index < 0 || (index as usize) >= self.videos.len() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let db = &mut self.as_mut().get_db();
|
let db = &mut self.as_mut().get_db();
|
||||||
|
|
||||||
let video_id = self.videos().get(index as usize).unwrap().id;
|
let video_id = self.videos.get(index as usize).unwrap().id;
|
||||||
|
|
||||||
let result =
|
let result =
|
||||||
delete(videos.filter(id.eq(video_id))).execute(db);
|
delete(videos.filter(id.eq(video_id))).execute(db);
|
||||||
|
@ -263,11 +269,14 @@ impl qobject::VideoModel {
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut().videos_mut().remove(index as usize);
|
self.as_mut()
|
||||||
|
.rust_mut()
|
||||||
|
.videos
|
||||||
|
.remove(index as usize);
|
||||||
self.as_mut().end_remove_rows();
|
self.as_mut().end_remove_rows();
|
||||||
}
|
}
|
||||||
println!("removed-item-at-index: {:?}", video_id);
|
println!("removed-item-at-index: {:?}", video_id);
|
||||||
println!("new-Vec: {:?}", self.as_mut().videos());
|
println!("new-Vec: {:?}", self.as_mut().videos);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(_e) => {
|
Err(_e) => {
|
||||||
|
@ -300,7 +309,7 @@ impl qobject::VideoModel {
|
||||||
|
|
||||||
if self.as_mut().add_item(video_id, video_title, video_path) {
|
if self.as_mut().add_item(video_id, video_title, video_path) {
|
||||||
println!("filename: {:?}", name);
|
println!("filename: {:?}", name);
|
||||||
self.as_mut().set_highest_id(video_id);
|
self.as_mut().rust_mut().highest_id = video_id;
|
||||||
} else {
|
} else {
|
||||||
println!("Error in inserting item");
|
println!("Error in inserting item");
|
||||||
}
|
}
|
||||||
|
@ -339,7 +348,7 @@ impl qobject::VideoModel {
|
||||||
match result {
|
match result {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
self.as_mut().add_video(video);
|
self.as_mut().add_video(video);
|
||||||
println!("{:?}", self.as_mut().videos());
|
println!("{:?}", self.as_mut().videos);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(_e) => {
|
Err(_e) => {
|
||||||
|
@ -352,15 +361,17 @@ impl qobject::VideoModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_video(mut self: Pin<&mut Self>, video: self::Video) {
|
fn add_video(mut self: Pin<&mut Self>, video: self::Video) {
|
||||||
let index = self.as_ref().videos().len() as i32;
|
let index = self.as_ref().videos.len() as i32;
|
||||||
println!("{:?}", video);
|
println!("{:?}", video);
|
||||||
|
let count = self.as_mut().count;
|
||||||
|
self.as_mut().set_count(count + 1);
|
||||||
unsafe {
|
unsafe {
|
||||||
self.as_mut().begin_insert_rows(
|
self.as_mut().begin_insert_rows(
|
||||||
&QModelIndex::default(),
|
&QModelIndex::default(),
|
||||||
index,
|
index,
|
||||||
index,
|
index,
|
||||||
);
|
);
|
||||||
self.as_mut().videos_mut().push(video);
|
self.as_mut().rust_mut().videos.push(video);
|
||||||
self.as_mut().end_insert_rows();
|
self.as_mut().end_insert_rows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -389,14 +400,14 @@ impl qobject::VideoModel {
|
||||||
qvariantmap
|
qvariantmap
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_role(&self, role: Role) -> i32 {
|
fn get_role(&self, role: VideoRoles) -> i32 {
|
||||||
match role {
|
match role {
|
||||||
Role::IdRole => 0,
|
VideoRoles::Id => 0,
|
||||||
Role::TitleRole => 1,
|
VideoRoles::Title => 1,
|
||||||
Role::PathRole => 2,
|
VideoRoles::Path => 2,
|
||||||
Role::StartTimeRole => 3,
|
VideoRoles::StartTime => 3,
|
||||||
Role::EndTimeRole => 4,
|
VideoRoles::EndTime => 4,
|
||||||
Role::LoopingRole => 5,
|
VideoRoles::Looping => 5,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -408,7 +419,7 @@ impl qobject::VideoModel {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role(Role::LoopingRole));
|
.append(self.as_ref().get_role(VideoRoles::Looping));
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.as_ref().index(index, 0, &QModelIndex::default());
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
println!("rust-video: {:?}", index);
|
println!("rust-video: {:?}", index);
|
||||||
|
@ -422,14 +433,15 @@ impl qobject::VideoModel {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
for video in self
|
for video in self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.videos_mut()
|
.rust_mut()
|
||||||
|
.videos
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
video.looping = loop_value.clone();
|
video.looping = loop_value.clone();
|
||||||
println!("rust-video: {:?}", video.title);
|
println!("rust-video: {:?}", video.title);
|
||||||
}
|
}
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
|
@ -448,7 +460,7 @@ impl qobject::VideoModel {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role(Role::EndTimeRole));
|
.append(self.as_ref().get_role(VideoRoles::EndTime));
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.as_ref().index(index, 0, &QModelIndex::default());
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
|
|
||||||
|
@ -460,13 +472,14 @@ impl qobject::VideoModel {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
for video in self
|
for video in self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.videos_mut()
|
.rust_mut()
|
||||||
|
.videos
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
video.end_time = updated_end_time.clone();
|
video.end_time = updated_end_time.clone();
|
||||||
}
|
}
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
|
@ -485,7 +498,7 @@ impl qobject::VideoModel {
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles
|
vector_roles
|
||||||
.append(self.as_ref().get_role(Role::StartTimeRole));
|
.append(self.as_ref().get_role(VideoRoles::StartTime));
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.as_ref().index(index, 0, &QModelIndex::default());
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
|
|
||||||
|
@ -497,13 +510,14 @@ impl qobject::VideoModel {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
for video in self
|
for video in self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.videos_mut()
|
.rust_mut()
|
||||||
|
.videos
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
video.start_time = updated_start_time.clone();
|
video.start_time = updated_start_time.clone();
|
||||||
}
|
}
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
|
@ -521,7 +535,8 @@ impl qobject::VideoModel {
|
||||||
updated_title: QString,
|
updated_title: QString,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles.append(self.as_ref().get_role(Role::TitleRole));
|
vector_roles
|
||||||
|
.append(self.as_ref().get_role(VideoRoles::Title));
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.as_ref().index(index, 0, &QModelIndex::default());
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
|
|
||||||
|
@ -533,7 +548,8 @@ impl qobject::VideoModel {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
for video in self
|
for video in self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.videos_mut()
|
.rust_mut()
|
||||||
|
.videos
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
|
@ -541,12 +557,11 @@ impl qobject::VideoModel {
|
||||||
println!("rust-title: {:?}", video.title);
|
println!("rust-title: {:?}", video.title);
|
||||||
}
|
}
|
||||||
// TODO this seems to not be updating in the actual list
|
// TODO this seems to not be updating in the actual list
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
);
|
);
|
||||||
// self.as_mut().emit_title_changed();
|
|
||||||
println!("rust-title: {:?}", updated_title);
|
println!("rust-title: {:?}", updated_title);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -560,7 +575,7 @@ impl qobject::VideoModel {
|
||||||
updated_path: QString,
|
updated_path: QString,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut vector_roles = QVector_i32::default();
|
let mut vector_roles = QVector_i32::default();
|
||||||
vector_roles.append(self.as_ref().get_role(Role::PathRole));
|
vector_roles.append(self.as_ref().get_role(VideoRoles::Path));
|
||||||
let model_index =
|
let model_index =
|
||||||
&self.as_ref().index(index, 0, &QModelIndex::default());
|
&self.as_ref().index(index, 0, &QModelIndex::default());
|
||||||
|
|
||||||
|
@ -572,14 +587,15 @@ impl qobject::VideoModel {
|
||||||
Ok(_i) => {
|
Ok(_i) => {
|
||||||
for video in self
|
for video in self
|
||||||
.as_mut()
|
.as_mut()
|
||||||
.videos_mut()
|
.rust_mut()
|
||||||
|
.videos
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter(|x| x.id == index)
|
.filter(|x| x.id == index)
|
||||||
{
|
{
|
||||||
video.path = updated_path.clone();
|
video.path = updated_path.clone();
|
||||||
println!("rust-title: {:?}", video.title);
|
println!("rust-title: {:?}", video.title);
|
||||||
}
|
}
|
||||||
self.as_mut().emit_data_changed(
|
self.as_mut().data_changed(
|
||||||
model_index,
|
model_index,
|
||||||
model_index,
|
model_index,
|
||||||
&vector_roles,
|
&vector_roles,
|
||||||
|
@ -593,23 +609,21 @@ impl qobject::VideoModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// QAbstractListModel implementation
|
// QAbstractListModel implementation
|
||||||
impl qobject::VideoModel {
|
impl video_model::VideoModel {
|
||||||
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
fn data(&self, index: &QModelIndex, role: i32) -> QVariant {
|
||||||
let role = qobject::Roles { repr: role };
|
let role = VideoRoles { repr: role };
|
||||||
if let Some(video) = self.videos().get(index.row() as usize) {
|
if let Some(video) = self.videos.get(index.row() as usize) {
|
||||||
return match role {
|
return match role {
|
||||||
qobject::Role::Id => QVariant::from(&video.id),
|
VideoRoles::Id => QVariant::from(&video.id),
|
||||||
qobject::Role::Title => QVariant::from(&video.title),
|
VideoRoles::Title => QVariant::from(&video.title),
|
||||||
qobject::Role::Path => QVariant::from(&video.path),
|
VideoRoles::Path => QVariant::from(&video.path),
|
||||||
qobject::Role::StartTime => {
|
VideoRoles::StartTime => {
|
||||||
QVariant::from(&video.start_time)
|
QVariant::from(&video.start_time)
|
||||||
}
|
}
|
||||||
qobject::Role::EndTime => {
|
VideoRoles::EndTime => {
|
||||||
QVariant::from(&video.end_time)
|
QVariant::from(&video.end_time)
|
||||||
}
|
}
|
||||||
qobject::Role::Looping => {
|
VideoRoles::Looping => QVariant::from(&video.looping),
|
||||||
QVariant::from(&video.looping)
|
|
||||||
}
|
|
||||||
_ => QVariant::default(),
|
_ => QVariant::default(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -619,35 +633,32 @@ impl qobject::VideoModel {
|
||||||
|
|
||||||
// Example of overriding a C++ virtual method and calling the base class implementation.
|
// Example of overriding a C++ virtual method and calling the base class implementation.
|
||||||
|
|
||||||
pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
// pub fn can_fetch_more(&self, parent: &QModelIndex) -> bool {
|
||||||
self.base_can_fetch_more(parent)
|
// self.base_can_fetch_more(parent)
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
pub fn role_names(&self) -> QHash_i32_QByteArray {
|
||||||
let mut roles = QHash_i32_QByteArray::default();
|
let mut roles = QHash_i32_QByteArray::default();
|
||||||
|
roles.insert(VideoRoles::Id.repr, QByteArray::from("id"));
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Id.repr,
|
VideoRoles::Title.repr,
|
||||||
cxx_qt_lib::QByteArray::from("id"),
|
QByteArray::from("title"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Title.repr,
|
VideoRoles::Path.repr,
|
||||||
cxx_qt_lib::QByteArray::from("title"),
|
QByteArray::from("filePath"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::Path.repr,
|
VideoRoles::StartTime.repr,
|
||||||
cxx_qt_lib::QByteArray::from("filePath"),
|
QByteArray::from("startTime"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::StartTime.repr,
|
VideoRoles::EndTime.repr,
|
||||||
cxx_qt_lib::QByteArray::from("startTime"),
|
QByteArray::from("endTime"),
|
||||||
);
|
);
|
||||||
roles.insert(
|
roles.insert(
|
||||||
qobject::Roles::EndTime.repr,
|
VideoRoles::Looping.repr,
|
||||||
cxx_qt_lib::QByteArray::from("endTime"),
|
QByteArray::from("loop"),
|
||||||
);
|
|
||||||
roles.insert(
|
|
||||||
qobject::Roles::Looping.repr,
|
|
||||||
cxx_qt_lib::QByteArray::from("loop"),
|
|
||||||
);
|
);
|
||||||
roles
|
roles
|
||||||
}
|
}
|
||||||
|
@ -657,8 +668,4 @@ impl qobject::VideoModel {
|
||||||
// println!("row count is {cnt}");
|
// println!("row count is {cnt}");
|
||||||
cnt
|
cnt
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn count(&self) -> i32 {
|
|
||||||
self.rust().videos.len() as i32
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
179
src/rust/ytdl.rs
179
src/rust/ytdl.rs
|
@ -1,9 +1,5 @@
|
||||||
#[cxx_qt::bridge]
|
#[cxx_qt::bridge]
|
||||||
mod ytdl {
|
mod ytdl {
|
||||||
use dirs;
|
|
||||||
use std::{fs, thread};
|
|
||||||
use youtube_dl::YoutubeDl;
|
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!("cxx-qt-lib/qurl.h");
|
include!("cxx-qt-lib/qurl.h");
|
||||||
type QUrl = cxx_qt_lib::QUrl;
|
type QUrl = cxx_qt_lib::QUrl;
|
||||||
|
@ -11,91 +7,106 @@ mod ytdl {
|
||||||
type QString = cxx_qt_lib::QString;
|
type QString = cxx_qt_lib::QString;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
unsafe extern "RustQt" {
|
||||||
#[cxx_qt::qobject]
|
#[qobject]
|
||||||
pub struct Ytdl {
|
#[qml_element]
|
||||||
#[qproperty]
|
#[qproperty(QString, title)]
|
||||||
title: QString,
|
#[qproperty(QUrl, thumbnail)]
|
||||||
#[qproperty]
|
#[qproperty(bool, loaded)]
|
||||||
thumbnail: QUrl,
|
#[qproperty(bool, loading)]
|
||||||
#[qproperty]
|
#[qproperty(QUrl, file)]
|
||||||
loaded: bool,
|
type Ytdl = super::YtdlRust;
|
||||||
#[qproperty]
|
|
||||||
loading: bool,
|
#[qinvokable]
|
||||||
#[qproperty]
|
fn get_video(self: Pin<&mut Ytdl>, url: QUrl) -> bool;
|
||||||
file: QUrl,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl qobject::Ytdl {
|
impl cxx_qt::Threading for Ytdl {}
|
||||||
#[qinvokable]
|
}
|
||||||
pub fn get_video(
|
|
||||||
mut self: Pin<&mut Self>,
|
|
||||||
url: QUrl,
|
|
||||||
) -> bool {
|
|
||||||
if !url.is_valid() {
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
let data_dir = dirs::data_local_dir().unwrap();
|
|
||||||
if let Some(mut data_dir) = dirs::data_local_dir() {
|
|
||||||
data_dir.push("librepresenter");
|
|
||||||
data_dir.push("ytdl");
|
|
||||||
if !data_dir.exists() {
|
|
||||||
fs::create_dir(&data_dir)
|
|
||||||
.expect("Could not create ytdl dir");
|
|
||||||
}
|
|
||||||
println!("{:?}", data_dir);
|
|
||||||
self.as_mut().set_loading(true);
|
|
||||||
let thread = self.qt_thread();
|
|
||||||
let runtime =
|
|
||||||
tokio::runtime::Runtime::new().unwrap();
|
|
||||||
runtime.spawn(async move {
|
|
||||||
let url = url.to_string();
|
|
||||||
let output_dirs = data_dir.to_str().unwrap();
|
|
||||||
println!("{output_dirs}");
|
|
||||||
let ytdl = YoutubeDl::new(url)
|
|
||||||
.socket_timeout("15")
|
|
||||||
.output_directory(output_dirs)
|
|
||||||
.output_template("%(title)s.%(ext)s")
|
|
||||||
.download(true)
|
|
||||||
.run()
|
|
||||||
.unwrap();
|
|
||||||
let output =
|
|
||||||
ytdl.into_single_video().unwrap();
|
|
||||||
println!("{:?}", output.title);
|
|
||||||
println!("{:?}", output.thumbnail);
|
|
||||||
println!("{:?}", output.url);
|
|
||||||
let title = QString::from(&output.title);
|
|
||||||
let thumbnail = QUrl::from(
|
|
||||||
&output.thumbnail.unwrap_or_default(),
|
|
||||||
);
|
|
||||||
let mut file = String::from(output_dirs);
|
|
||||||
file.push_str("/");
|
|
||||||
file.push_str(&output.title);
|
|
||||||
file.push_str(".");
|
|
||||||
file.push_str(
|
|
||||||
&output.ext.unwrap_or_default(),
|
|
||||||
);
|
|
||||||
println!("{:?}", file);
|
|
||||||
|
|
||||||
thread.queue(move |mut qobject_ytdl| {
|
use cxx_qt::{CxxQtType, Threading};
|
||||||
qobject_ytdl.as_mut().set_loaded(true);
|
use cxx_qt_lib::{QString, QUrl};
|
||||||
qobject_ytdl.as_mut().set_loading(false);
|
use dirs;
|
||||||
qobject_ytdl.as_mut().set_title(title);
|
use std::{fs, thread, pin::Pin};
|
||||||
qobject_ytdl
|
use youtube_dl::YoutubeDl;
|
||||||
.as_mut()
|
|
||||||
.set_thumbnail(thumbnail);
|
#[derive(Clone, Default)]
|
||||||
qobject_ytdl
|
pub struct YtdlRust {
|
||||||
.as_mut()
|
title: QString,
|
||||||
.set_file(QUrl::from(&file));
|
thumbnail: QUrl,
|
||||||
})
|
loaded: bool,
|
||||||
});
|
loading: bool,
|
||||||
true
|
file: QUrl,
|
||||||
} else {
|
}
|
||||||
false
|
|
||||||
|
impl ytdl::Ytdl {
|
||||||
|
pub fn get_video(
|
||||||
|
mut self: Pin<&mut Self>,
|
||||||
|
url: QUrl,
|
||||||
|
) -> bool {
|
||||||
|
if !url.is_valid() {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
let data_dir = dirs::data_local_dir().unwrap();
|
||||||
|
if let Some(mut data_dir) = dirs::data_local_dir() {
|
||||||
|
data_dir.push("librepresenter");
|
||||||
|
data_dir.push("ytdl");
|
||||||
|
if !data_dir.exists() {
|
||||||
|
fs::create_dir(&data_dir)
|
||||||
|
.expect("Could not create ytdl dir");
|
||||||
}
|
}
|
||||||
|
println!("{:?}", data_dir);
|
||||||
|
self.as_mut().set_loading(true);
|
||||||
|
let thread = self.qt_thread();
|
||||||
|
let runtime =
|
||||||
|
tokio::runtime::Runtime::new().unwrap();
|
||||||
|
runtime.spawn(async move {
|
||||||
|
let url = url.to_string();
|
||||||
|
let output_dirs = data_dir.to_str().unwrap();
|
||||||
|
println!("{output_dirs}");
|
||||||
|
let ytdl = YoutubeDl::new(url)
|
||||||
|
.socket_timeout("15")
|
||||||
|
.output_directory(output_dirs)
|
||||||
|
.output_template("%(title)s.%(ext)s")
|
||||||
|
.download(true)
|
||||||
|
.run()
|
||||||
|
.unwrap();
|
||||||
|
let output =
|
||||||
|
ytdl.into_single_video().unwrap();
|
||||||
|
println!("{:?}", output.title);
|
||||||
|
println!("{:?}", output.thumbnail);
|
||||||
|
println!("{:?}", output.url);
|
||||||
|
let title = QString::from(&output.title);
|
||||||
|
let thumbnail = QUrl::from(
|
||||||
|
&output.thumbnail.unwrap_or_default(),
|
||||||
|
);
|
||||||
|
let mut file = String::from(output_dirs);
|
||||||
|
file.push_str("/");
|
||||||
|
file.push_str(&output.title);
|
||||||
|
file.push_str(".");
|
||||||
|
file.push_str(
|
||||||
|
&output.ext.unwrap_or_default(),
|
||||||
|
);
|
||||||
|
println!("{:?}", file);
|
||||||
|
|
||||||
|
thread.queue(move |mut qobject_ytdl| {
|
||||||
|
qobject_ytdl.as_mut().set_loaded(true);
|
||||||
|
qobject_ytdl.as_mut().set_loading(false);
|
||||||
|
qobject_ytdl.as_mut().set_title(title);
|
||||||
|
qobject_ytdl
|
||||||
|
.as_mut()
|
||||||
|
.set_thumbnail(thumbnail);
|
||||||
|
qobject_ytdl
|
||||||
|
.as_mut()
|
||||||
|
.set_file(QUrl::from(&file));
|
||||||
|
})
|
||||||
|
});
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn dl_video() {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn dl_video() {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue