Qt: "add entry" option for starting a new custom playlist entry

This commit is contained in:
Brad Parker 2018-07-31 00:15:59 -04:00
parent d5ae00f3d8
commit ea05b0f3cb
4 changed files with 40 additions and 2 deletions

View File

@ -3672,6 +3672,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
"まずひとつのプレイリストを選択してください。") "まずひとつのプレイリストを選択してください。")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DELETE, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DELETE,
"削除") "削除")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_ENTRY,
"エントリー作成...")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_FILES, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_FILES,
"ファイルを追加...") "ファイルを追加...")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER,
@ -3686,3 +3688,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FIELD_MULTIPLE,
"<複数>") "<複数>")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_UPDATE_PLAYLIST_ENTRY, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_UPDATE_PLAYLIST_ENTRY,
"プレイリストエントリーを更新するに失敗しました。") "プレイリストエントリーを更新するに失敗しました。")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PLEASE_FILL_OUT_REQUIRED_FIELDS,
"必須フィールドがすべて入力されていることを確認してください。")

View File

@ -4188,6 +4188,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
"Please choose a single playlist first.") "Please choose a single playlist first.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DELETE, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_DELETE,
"Delete") "Delete")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_ENTRY,
"Add Entry...")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_FILES, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_FILES,
"Add File(s)...") "Add File(s)...")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER,
@ -4202,3 +4204,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_FIELD_MULTIPLE,
"<multiple>") "<multiple>")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_UPDATE_PLAYLIST_ENTRY, MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_UPDATE_PLAYLIST_ENTRY,
"Error updating playlist entry.") "Error updating playlist entry.")
MSG_HASH(MENU_ENUM_LABEL_VALUE_QT_PLEASE_FILL_OUT_REQUIRED_FIELDS,
"Please fill out all required fields.")

View File

@ -1953,6 +1953,7 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS, MENU_ENUM_LABEL_VALUE_QT_FOR_THUMBNAILS,
MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS, MENU_ENUM_LABEL_VALUE_QT_CANNOT_ADD_TO_ALL_PLAYLISTS,
MENU_ENUM_LABEL_VALUE_QT_DELETE, MENU_ENUM_LABEL_VALUE_QT_DELETE,
MENU_ENUM_LABEL_VALUE_QT_ADD_ENTRY,
MENU_ENUM_LABEL_VALUE_QT_ADD_FILES, MENU_ENUM_LABEL_VALUE_QT_ADD_FILES,
MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER, MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER,
MENU_ENUM_LABEL_VALUE_QT_EDIT, MENU_ENUM_LABEL_VALUE_QT_EDIT,
@ -1960,6 +1961,7 @@ enum msg_hash_enums
MENU_ENUM_LABEL_VALUE_QT_SELECT_FOLDER, MENU_ENUM_LABEL_VALUE_QT_SELECT_FOLDER,
MENU_ENUM_LABEL_VALUE_QT_FIELD_MULTIPLE, MENU_ENUM_LABEL_VALUE_QT_FIELD_MULTIPLE,
MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_UPDATE_PLAYLIST_ENTRY, MENU_ENUM_LABEL_VALUE_QT_COULD_NOT_UPDATE_PLAYLIST_ENTRY,
MENU_ENUM_LABEL_VALUE_QT_PLEASE_FILL_OUT_REQUIRED_FIELDS,
MENU_LABEL(MIDI_INPUT), MENU_LABEL(MIDI_INPUT),
MENU_LABEL(MIDI_OUTPUT), MENU_LABEL(MIDI_OUTPUT),

View File

@ -1178,7 +1178,14 @@ void MainWindow::addFilesToPlaylist(QStringList files)
playlist_t *playlist = NULL; playlist_t *playlist = NULL;
int i; int i;
if (files.count() == 1) /* Assume a blank list means we will manually enter in all fields. */
if (files.isEmpty())
{
/* Make sure hash isn't blank, that would mean there's multiple entries to add at once. */
itemToAdd["label"] = "";
itemToAdd["path"] = "";
}
else if (files.count() == 1)
{ {
QString path = files.at(0); QString path = files.at(0);
QFileInfo info(path); QFileInfo info(path);
@ -1224,6 +1231,16 @@ void MainWindow::addFilesToPlaylist(QStringList files)
dialog.reset(new QProgressDialog(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_GATHERING_LIST_OF_FILES), "Cancel", 0, 0, this)); dialog.reset(new QProgressDialog(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_GATHERING_LIST_OF_FILES), "Cancel", 0, 0, this));
dialog->setWindowModality(Qt::ApplicationModal); dialog->setWindowModality(Qt::ApplicationModal);
if (selectedName.isEmpty() || selectedPath.isEmpty() ||
selectedDatabase.isEmpty())
{
ui_window.qtWindow->showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_PLEASE_FILL_OUT_REQUIRED_FIELDS), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
return;
}
if (files.isEmpty())
files.append(selectedPath);
for (i = 0; i < files.count(); i++) for (i = 0; i < files.count(); i++)
{ {
QString path(files.at(i)); QString path(files.at(i));
@ -1243,8 +1260,12 @@ void MainWindow::addFilesToPlaylist(QStringList files)
} }
if (fileInfo.isFile()) if (fileInfo.isFile())
{
list.append(fileInfo.absoluteFilePath()); list.append(fileInfo.absoluteFilePath());
else if (files.count() == 1)
{
/* If adding a single file, tell user that it doesn't exist. */
ui_window.qtWindow->showMessageBox(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_FILE_DOES_NOT_EXIST), MainWindow::MSGBOX_TYPE_ERROR, Qt::ApplicationModal, false);
return;
} }
} }
@ -1671,6 +1692,7 @@ bool MainWindow::updateCurrentPlaylistEntry(const QHash<QString, QString> &conte
void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos) void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
{ {
QScopedPointer<QMenu> menu; QScopedPointer<QMenu> menu;
QScopedPointer<QAction> addEntryAction;
QScopedPointer<QAction> addFilesAction; QScopedPointer<QAction> addFilesAction;
QScopedPointer<QAction> addFolderAction; QScopedPointer<QAction> addFolderAction;
QScopedPointer<QAction> editAction; QScopedPointer<QAction> editAction;
@ -1681,11 +1703,13 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
menu.reset(new QMenu(this)); menu.reset(new QMenu(this));
addEntryAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_ENTRY)), this));
addFilesAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_FILES)), this)); addFilesAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_FILES)), this));
addFolderAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER)), this)); addFolderAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_ADD_FOLDER)), this));
editAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_EDIT)), this)); editAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_EDIT)), this));
deleteAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DELETE)), this)); deleteAction.reset(new QAction(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_DELETE)), this));
menu->addAction(addEntryAction.data());
menu->addAction(addFilesAction.data()); menu->addAction(addFilesAction.data());
menu->addAction(addFolderAction.data()); menu->addAction(addFolderAction.data());
@ -1707,6 +1731,10 @@ void MainWindow::onFileDropWidgetContextMenuRequested(const QPoint &pos)
if (!filePaths.isEmpty()) if (!filePaths.isEmpty())
addFilesToPlaylist(filePaths); addFilesToPlaylist(filePaths);
} }
else if (selectedAction == addEntryAction.data())
{
addFilesToPlaylist(QStringList());
}
else if (selectedAction == addFolderAction.data()) else if (selectedAction == addFolderAction.data())
{ {
QString dirPath = QFileDialog::getExistingDirectory(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_FOLDER), QString(), QFileDialog::ShowDirsOnly); QString dirPath = QFileDialog::getExistingDirectory(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_SELECT_FOLDER), QString(), QFileDialog::ShowDirsOnly);