Qt: add button to playlist entry dialog to change the path to the content

This commit is contained in:
Brad Parker 2018-07-30 21:18:34 -04:00
parent e1b2d752ab
commit e63edfa6d2
2 changed files with 41 additions and 3 deletions

View File

@ -393,7 +393,14 @@ PlaylistEntryDialog::PlaylistEntryDialog(MainWindow *mainwindow, QWidget *parent
QFormLayout *form = new QFormLayout();
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QVBoxLayout *databaseVBoxLayout = new QVBoxLayout();
QHBoxLayout *pathHBoxLayout = new QHBoxLayout();
QLabel *databaseLabel = new QLabel(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS), this);
QToolButton *pathPushButton = new QToolButton(this);
pathPushButton->setText("...");
pathHBoxLayout->addWidget(m_pathLineEdit);
pathHBoxLayout->addWidget(pathPushButton);
databaseVBoxLayout->addWidget(m_databaseComboBox);
databaseVBoxLayout->addWidget(databaseLabel);
@ -412,13 +419,25 @@ PlaylistEntryDialog::PlaylistEntryDialog(MainWindow *mainwindow, QWidget *parent
connect(this, SIGNAL(rejected()), this, SLOT(onRejected()));
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_NAME), m_nameLineEdit);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_PATH), m_pathLineEdit);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_PATH), pathHBoxLayout);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_CORE), m_coreComboBox);
form->addRow(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLAYLIST_ENTRY_DATABASE), databaseVBoxLayout);
qobject_cast<QVBoxLayout*>(layout())->addLayout(form);
layout()->addItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
layout()->addWidget(buttonBox);
connect(pathPushButton, SIGNAL(clicked()), this, SLOT(onPathClicked()));
}
void PlaylistEntryDialog::onPathClicked()
{
QString filePath = QFileDialog::getOpenFileName(this);
if (filePath.isEmpty())
return;
m_pathLineEdit->setText(filePath);
}
void PlaylistEntryDialog::loadPlaylistOptions()
@ -1605,10 +1624,10 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
return false;
playlistPathArray = playlistPath.toUtf8();
pathArray = path.toUtf8();
pathArray = QDir::toNativeSeparators(path).toUtf8();
labelArray = label.toUtf8();
coreNameArray = coreName.toUtf8();
corePathArray = corePath.toUtf8();
corePathArray = QDir::toNativeSeparators(corePath).toUtf8();
dbNameArray = (dbName + file_path_str(FILE_PATH_LPL_EXTENSION)).toUtf8();
crc32Array = crc32.toUtf8();
@ -1620,6 +1639,23 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
dbNameData = dbNameArray.constData();
crc32Data = crc32Array.constData();
if (path_is_compressed_file(pathData))
{
struct string_list *list = file_archive_get_file_list(pathData, NULL);
if (list)
{
if (list->size == 1)
{
/* assume archives with one file should have that file loaded directly */
pathArray = QDir::toNativeSeparators(QString(pathData) + "#" + list->elems[0].data).toUtf8();
pathData = pathArray.constData();
}
string_list_free(list);
}
}
playlist = playlist_init(playlistPathData, COLLECTION_SIZE);
playlist_update(playlist, index, pathData, labelData,

View File

@ -197,6 +197,8 @@ public slots:
void hideDialog();
void onAccepted();
void onRejected();
private slots:
void onPathClicked();
private:
void loadPlaylistOptions();