using rfd in more places and fixing non hovering buttons
This commit is contained in:
parent
c0aceca02d
commit
301306c9f2
2 changed files with 32 additions and 4 deletions
|
@ -126,7 +126,8 @@ Item {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: "Video"
|
text: "Video"
|
||||||
icon.name: "emblem-videos-symbolic"
|
icon.name: "emblem-videos-symbolic"
|
||||||
onClicked: videoFileDialog.open() & backgroundTypePopup.close()
|
onClicked: updateBackground("video") & backgroundTypePopup.close()
|
||||||
|
hoverEnabled: true
|
||||||
}
|
}
|
||||||
Controls.ToolButton {
|
Controls.ToolButton {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
@ -134,6 +135,7 @@ Item {
|
||||||
text: "Image"
|
text: "Image"
|
||||||
icon.name: "folder-pictures-symbolic"
|
icon.name: "folder-pictures-symbolic"
|
||||||
onClicked: updateBackground("image") & backgroundTypePopup.close()
|
onClicked: updateBackground("image") & backgroundTypePopup.close()
|
||||||
|
hoverEnabled: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,6 +357,7 @@ Item {
|
||||||
text: "Audio"
|
text: "Audio"
|
||||||
icon.name: "folder-music-symbolic"
|
icon.name: "folder-music-symbolic"
|
||||||
onClicked: updateAudioFile()
|
onClicked: updateAudioFile()
|
||||||
|
hoverEnabled: true
|
||||||
/* background: Presenter.TextBackground { */
|
/* background: Presenter.TextBackground { */
|
||||||
/* control: audioPickerButton */
|
/* control: audioPickerButton */
|
||||||
/* } */
|
/* } */
|
||||||
|
@ -498,13 +501,13 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateAudioFile() {
|
function updateAudioFile() {
|
||||||
const file = fileHelper.loadFile("Pick Audio");
|
const file = fileHelper.loadFile("Pick Audio", "audio");
|
||||||
songProxyModel.songModel.updateAudio(songIndex, file);
|
songProxyModel.songModel.updateAudio(songIndex, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateBackground(backgroundType) {
|
function updateBackground(backgroundType) {
|
||||||
song.backgroundType = backgroundType;
|
song.backgroundType = backgroundType;
|
||||||
const file = fileHelper.loadFile("Pick Background");
|
const file = fileHelper.loadFile("Pick Background", backgroundType);
|
||||||
song.background = file;
|
song.background = file;
|
||||||
songProxyModel.songModel.updateBackground(songIndex, file);
|
songProxyModel.songModel.updateBackground(songIndex, file);
|
||||||
songProxyModel.songModel.updateBackgroundType(songIndex, backgroundType);
|
songProxyModel.songModel.updateBackgroundType(songIndex, backgroundType);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
mod file_helper {
|
mod file_helper {
|
||||||
use rfd::FileDialog;
|
use rfd::FileDialog;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use tracing::{debug, debug_span, error, info, instrument};
|
||||||
|
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
include!("cxx-qt-lib/qstring.h");
|
include!("cxx-qt-lib/qstring.h");
|
||||||
|
@ -95,9 +96,33 @@ mod file_helper {
|
||||||
pub fn load_file(
|
pub fn load_file(
|
||||||
self: Pin<&mut Self>,
|
self: Pin<&mut Self>,
|
||||||
title: QString,
|
title: QString,
|
||||||
|
filter: QString,
|
||||||
) -> QUrl {
|
) -> QUrl {
|
||||||
|
let video_filters = [
|
||||||
|
"mp4", "webm", "avi", "mkv", "MP4", "WEBM", "AVI",
|
||||||
|
"MKV",
|
||||||
|
];
|
||||||
|
let image_filters = [
|
||||||
|
"jpg", "png", "gif", "jpeg", "JPG", "PNG", "webp",
|
||||||
|
"gif",
|
||||||
|
];
|
||||||
|
let audio_filters = ["mp3", "opus", "ogg", "flac", "wav"];
|
||||||
let title = title.to_string();
|
let title = title.to_string();
|
||||||
let file = FileDialog::new().set_title(title).pick_file();
|
let filter = filter.to_string();
|
||||||
|
let mut file = FileDialog::new().set_title(title);
|
||||||
|
match filter.as_str() {
|
||||||
|
"video" => {
|
||||||
|
file = file.add_filter(filter, &video_filters);
|
||||||
|
}
|
||||||
|
"image" => {
|
||||||
|
file = file.add_filter(filter, &image_filters);
|
||||||
|
}
|
||||||
|
"audio" => {
|
||||||
|
file = file.add_filter(filter, &audio_filters);
|
||||||
|
}
|
||||||
|
_ => debug!("nothing"),
|
||||||
|
};
|
||||||
|
let file = file.pick_file();
|
||||||
if let Some(file) = file {
|
if let Some(file) = file {
|
||||||
println!("loading-file: {:?}", file);
|
println!("loading-file: {:?}", file);
|
||||||
let mut string =
|
let mut string =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue