@@ -397,7 +397,7 @@ void ContextAlbumsView::EditTracks() {
|
|||||||
void ContextAlbumsView::CopyToDevice() {
|
void ContextAlbumsView::CopyToDevice() {
|
||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
if (!organize_dialog_)
|
if (!organize_dialog_)
|
||||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager()));
|
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), nullptr, this));
|
||||||
|
|
||||||
organize_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
organize_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
||||||
organize_dialog_->SetCopy(true);
|
organize_dialog_->SetCopy(true);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QGuiApplication>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
@@ -72,9 +73,8 @@
|
|||||||
# include "transcoder/transcoder.h"
|
# include "transcoder/transcoder.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char *OrganizeDialog::kDefaultFormat = "%albumartist/%album{ (Disc %disc)}/{%track - }{%albumartist - }%album{ (Disc %disc)} - %title.%extension";
|
|
||||||
|
|
||||||
const char *OrganizeDialog::kSettingsGroup = "OrganizeDialog";
|
const char *OrganizeDialog::kSettingsGroup = "OrganizeDialog";
|
||||||
|
const char *OrganizeDialog::kDefaultFormat = "%albumartist/%album{ (Disc %disc)}/{%track - }{%albumartist - }%album{ (Disc %disc)} - %title.%extension";
|
||||||
|
|
||||||
OrganizeDialog::OrganizeDialog(TaskManager *task_manager, CollectionBackend *backend, QWidget *parentwindow, QWidget *parent)
|
OrganizeDialog::OrganizeDialog(TaskManager *task_manager, CollectionBackend *backend, QWidget *parentwindow, QWidget *parent)
|
||||||
: QDialog(parent),
|
: QDialog(parent),
|
||||||
@@ -82,7 +82,8 @@ OrganizeDialog::OrganizeDialog(TaskManager *task_manager, CollectionBackend *bac
|
|||||||
ui_(new Ui_OrganizeDialog),
|
ui_(new Ui_OrganizeDialog),
|
||||||
task_manager_(task_manager),
|
task_manager_(task_manager),
|
||||||
backend_(backend),
|
backend_(backend),
|
||||||
total_size_(0) {
|
total_size_(0),
|
||||||
|
devices_(false) {
|
||||||
|
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
|
|
||||||
@@ -150,12 +151,14 @@ OrganizeDialog::~OrganizeDialog() {
|
|||||||
delete ui_;
|
delete ui_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrganizeDialog::SetDestinationModel(QAbstractItemModel *model, bool devices) {
|
void OrganizeDialog::SetDestinationModel(QAbstractItemModel *model, const bool devices) {
|
||||||
|
|
||||||
ui_->destination->setModel(model);
|
ui_->destination->setModel(model);
|
||||||
|
|
||||||
ui_->eject_after->setVisible(devices);
|
ui_->eject_after->setVisible(devices);
|
||||||
|
|
||||||
|
devices_ = devices;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrganizeDialog::showEvent(QShowEvent*) {
|
void OrganizeDialog::showEvent(QShowEvent*) {
|
||||||
@@ -167,7 +170,7 @@ void OrganizeDialog::showEvent(QShowEvent*) {
|
|||||||
|
|
||||||
void OrganizeDialog::closeEvent(QCloseEvent*) {
|
void OrganizeDialog::closeEvent(QCloseEvent*) {
|
||||||
|
|
||||||
SaveGeometry();
|
if (!devices_) SaveGeometry();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,15 +207,19 @@ void OrganizeDialog::reject() {
|
|||||||
|
|
||||||
void OrganizeDialog::LoadGeometry() {
|
void OrganizeDialog::LoadGeometry() {
|
||||||
|
|
||||||
if (parentwindow_) {
|
if (devices_) {
|
||||||
|
AdjustSize();
|
||||||
|
}
|
||||||
|
else {
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
if (s.contains("geometry")) {
|
if (s.contains("geometry")) {
|
||||||
restoreGeometry(s.value("geometry").toByteArray());
|
restoreGeometry(s.value("geometry").toByteArray());
|
||||||
}
|
}
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parentwindow_) {
|
||||||
// Center the window on the same screen as the parentwindow.
|
// Center the window on the same screen as the parentwindow.
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
QScreen *screen = parentwindow_->screen();
|
QScreen *screen = parentwindow_->screen();
|
||||||
@@ -240,6 +247,39 @@ void OrganizeDialog::SaveGeometry() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OrganizeDialog::AdjustSize() {
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||||
|
QScreen *screen = QWidget::screen();
|
||||||
|
#else
|
||||||
|
QScreen *screen = (window() && window()->windowHandle() ? window()->windowHandle()->screen() : QGuiApplication::primaryScreen());
|
||||||
|
#endif
|
||||||
|
int max_width = 0;
|
||||||
|
int max_height = 0;
|
||||||
|
if (screen) {
|
||||||
|
max_width = screen->geometry().size().width() / 0.5;
|
||||||
|
max_height = static_cast<int>(float(screen->geometry().size().height()) / float(1.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
int min_width = 0;
|
||||||
|
int min_height = 0;
|
||||||
|
if (ui_->preview->isVisible()) {
|
||||||
|
int h = ui_->layout_copying->sizeHint().height() +
|
||||||
|
ui_->button_box->sizeHint().height() +
|
||||||
|
ui_->eject_after->sizeHint().height() +
|
||||||
|
ui_->free_space->sizeHint().height() +
|
||||||
|
ui_->groupbox_naming->sizeHint().height();
|
||||||
|
if (ui_->preview->count() > 0) h += ui_->preview->sizeHintForRow(0) * ui_->preview->count();
|
||||||
|
else h += ui_->loading_page->sizeHint().height();
|
||||||
|
min_width = std::min(ui_->preview->sizeHintForColumn(0), max_width);
|
||||||
|
min_height = std::min(h, max_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
setMinimumSize(min_width, min_height);
|
||||||
|
adjustSize();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void OrganizeDialog::RestoreDefaults() {
|
void OrganizeDialog::RestoreDefaults() {
|
||||||
|
|
||||||
ui_->naming->setPlainText(kDefaultFormat);
|
ui_->naming->setPlainText(kDefaultFormat);
|
||||||
@@ -356,7 +396,7 @@ bool OrganizeDialog::SetFilenames(const QStringList &filenames) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrganizeDialog::SetLoadingSongs(bool loading) {
|
void OrganizeDialog::SetLoadingSongs(const bool loading) {
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
ui_->preview_stack->setCurrentWidget(ui_->loading_page);
|
ui_->preview_stack->setCurrentWidget(ui_->loading_page);
|
||||||
@@ -395,12 +435,11 @@ SongList OrganizeDialog::LoadSongsBlocking(const QStringList &filenames) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrganizeDialog::SetCopy(bool copy) {
|
void OrganizeDialog::SetCopy(const bool copy) {
|
||||||
ui_->aftercopying->setCurrentIndex(copy ? 0 : 1);
|
ui_->aftercopying->setCurrentIndex(copy ? 0 : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrganizeDialog::SetPlaylist(const QString &playlist)
|
void OrganizeDialog::SetPlaylist(const QString &playlist) {
|
||||||
{
|
|
||||||
playlist_ = playlist;
|
playlist_ = playlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,9 +536,10 @@ void OrganizeDialog::UpdatePreviews() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if (devices_)
|
||||||
|
AdjustSize();
|
||||||
|
|
||||||
QSize OrganizeDialog::sizeHint() const { return QSize(650, 0); }
|
}
|
||||||
|
|
||||||
void OrganizeDialog::OrganizeFinished(const QStringList files_with_errors, const QStringList log) {
|
void OrganizeDialog::OrganizeFinished(const QStringList files_with_errors, const QStringList log) {
|
||||||
if (files_with_errors.isEmpty()) return;
|
if (files_with_errors.isEmpty()) return;
|
||||||
@@ -508,6 +548,6 @@ void OrganizeDialog::OrganizeFinished(const QStringList files_with_errors, const
|
|||||||
error_dialog_->Show(OrganizeErrorDialog::Type_Copy, files_with_errors, log);
|
error_dialog_->Show(OrganizeErrorDialog::Type_Copy, files_with_errors, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OrganizeDialog::AllowExtASCII(bool checked) {
|
void OrganizeDialog::AllowExtASCII(const bool checked) {
|
||||||
ui_->allow_ascii_ext->setEnabled(checked);
|
ui_->allow_ascii_ext->setEnabled(checked);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,11 +59,7 @@ class OrganizeDialog : public QDialog {
|
|||||||
explicit OrganizeDialog(TaskManager *task_manager, CollectionBackend *backend = nullptr, QWidget *parentwindow = nullptr, QWidget *parent = nullptr);
|
explicit OrganizeDialog(TaskManager *task_manager, CollectionBackend *backend = nullptr, QWidget *parentwindow = nullptr, QWidget *parent = nullptr);
|
||||||
~OrganizeDialog() override;
|
~OrganizeDialog() override;
|
||||||
|
|
||||||
static const char *kDefaultFormat;
|
void SetDestinationModel(QAbstractItemModel *model, const bool devices = false);
|
||||||
|
|
||||||
QSize sizeHint() const override;
|
|
||||||
|
|
||||||
void SetDestinationModel(QAbstractItemModel *model, bool devices = false);
|
|
||||||
|
|
||||||
// These functions return true if any songs were actually added to the dialog.
|
// These functions return true if any songs were actually added to the dialog.
|
||||||
// SetSongs returns immediately, SetUrls and SetFilenames load the songs in the background.
|
// SetSongs returns immediately, SetUrls and SetFilenames load the songs in the background.
|
||||||
@@ -71,7 +67,7 @@ class OrganizeDialog : public QDialog {
|
|||||||
bool SetUrls(const QList<QUrl> &urls);
|
bool SetUrls(const QList<QUrl> &urls);
|
||||||
bool SetFilenames(const QStringList &filenames);
|
bool SetFilenames(const QStringList &filenames);
|
||||||
|
|
||||||
void SetCopy(bool copy);
|
void SetCopy(const bool copy);
|
||||||
|
|
||||||
static Organize::NewSongInfoList ComputeNewSongsFilenames(const SongList &songs, const OrganizeFormat &format, const QString &extension = QString());
|
static Organize::NewSongInfoList ComputeNewSongsFilenames(const SongList &songs, const OrganizeFormat &format, const QString &extension = QString());
|
||||||
|
|
||||||
@@ -85,9 +81,10 @@ class OrganizeDialog : public QDialog {
|
|||||||
void LoadGeometry();
|
void LoadGeometry();
|
||||||
void SaveGeometry();
|
void SaveGeometry();
|
||||||
void LoadSettings();
|
void LoadSettings();
|
||||||
|
void AdjustSize();
|
||||||
|
|
||||||
SongList LoadSongsBlocking(const QStringList &filenames);
|
SongList LoadSongsBlocking(const QStringList &filenames);
|
||||||
void SetLoadingSongs(bool loading);
|
void SetLoadingSongs(const bool loading);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void FileCopied(int);
|
void FileCopied(int);
|
||||||
@@ -105,10 +102,11 @@ class OrganizeDialog : public QDialog {
|
|||||||
|
|
||||||
void OrganizeFinished(const QStringList files_with_errors, const QStringList log);
|
void OrganizeFinished(const QStringList files_with_errors, const QStringList log);
|
||||||
|
|
||||||
void AllowExtASCII(bool checked);
|
void AllowExtASCII(const bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char *kSettingsGroup;
|
static const char *kSettingsGroup;
|
||||||
|
static const char *kDefaultFormat;
|
||||||
|
|
||||||
QWidget *parentwindow_;
|
QWidget *parentwindow_;
|
||||||
Ui_OrganizeDialog *ui_;
|
Ui_OrganizeDialog *ui_;
|
||||||
@@ -125,6 +123,8 @@ class OrganizeDialog : public QDialog {
|
|||||||
|
|
||||||
std::unique_ptr<OrganizeErrorDialog> error_dialog_;
|
std::unique_ptr<OrganizeErrorDialog> error_dialog_;
|
||||||
|
|
||||||
|
bool devices_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ORGANISEDIALOG_H
|
#endif // ORGANISEDIALOG_H
|
||||||
|
|||||||
@@ -18,8 +18,14 @@
|
|||||||
<normaloff>:/icons/64x64/strawberry.png</normaloff>:/icons/64x64/strawberry.png</iconset>
|
<normaloff>:/icons/64x64/strawberry.png</normaloff>:/icons/64x64/strawberry.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="layout_organizedialog">
|
<layout class="QVBoxLayout" name="layout_organizedialog">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QFormLayout" name="layout_copying">
|
<layout class="QFormLayout" name="layout_copying">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_destination">
|
<widget class="QLabel" name="label_destination">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -62,8 +68,14 @@
|
|||||||
<string>Naming options</string>
|
<string>Naming options</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="LineTextEdit" name="naming">
|
<widget class="LineTextEdit" name="naming">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@@ -156,6 +168,9 @@
|
|||||||
<string>Preview</string>
|
<string>Preview</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="preview_stack">
|
<widget class="QStackedWidget" name="preview_stack">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
@@ -166,6 +181,9 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
@@ -188,6 +206,9 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeConstraint">
|
||||||
|
<enum>QLayout::SetMinimumSize</enum>
|
||||||
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ void PlaylistListContainer::CopyToDevice() {
|
|||||||
|
|
||||||
// Reuse the organize dialog, but set the detail about the playlist name
|
// Reuse the organize dialog, but set the detail about the playlist name
|
||||||
if (!organize_dialog_) {
|
if (!organize_dialog_) {
|
||||||
organize_dialog_.reset(new OrganizeDialog(app_->task_manager()));
|
organize_dialog_.reset(new OrganizeDialog(app_->task_manager(), nullptr, this));
|
||||||
}
|
}
|
||||||
organize_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
organize_dialog_->SetDestinationModel(app_->device_manager()->connected_devices_model(), true);
|
||||||
organize_dialog_->SetCopy(true);
|
organize_dialog_->SetCopy(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user