Try to suggest a useful name for new folders.
This commit is contained in:
parent
18bed9ea38
commit
9cbb8b0d73
@ -25,7 +25,7 @@
|
||||
#define VER_LAMEXP_MAJOR 4
|
||||
#define VER_LAMEXP_MINOR_HI 0
|
||||
#define VER_LAMEXP_MINOR_LO 0
|
||||
#define VER_LAMEXP_BUILD 138
|
||||
#define VER_LAMEXP_BUILD 139
|
||||
#define VER_LAMEXP_SUFFIX TechPreview
|
||||
|
||||
/*
|
||||
|
@ -839,42 +839,91 @@ void MainWindow::makeFolderButtonClicked(void)
|
||||
ABORT_IF_BUSY;
|
||||
|
||||
QDir basePath(m_fileSystemModel->fileInfo(outputFolderView->currentIndex()).absoluteFilePath());
|
||||
|
||||
bool bApplied = true;
|
||||
QString folderName = QInputDialog::getText(this, "New Folder", "Enter the name of the new folder:", QLineEdit::Normal, "New folder", &bApplied, Qt::WindowStaysOnTopHint).simplified();
|
||||
QString suggestedName = "New Folder";
|
||||
|
||||
if(bApplied)
|
||||
if(!m_metaData->fileArtist().isEmpty() && !m_metaData->fileAlbum().isEmpty())
|
||||
{
|
||||
folderName.remove(":", Qt::CaseInsensitive);
|
||||
folderName.remove("/", Qt::CaseInsensitive);
|
||||
folderName.remove("\\", Qt::CaseInsensitive);
|
||||
folderName.remove("?", Qt::CaseInsensitive);
|
||||
folderName.remove("*", Qt::CaseInsensitive);
|
||||
folderName.remove("<", Qt::CaseInsensitive);
|
||||
folderName.remove(">", Qt::CaseInsensitive);
|
||||
|
||||
int i = 1;
|
||||
QString newFolder = folderName;
|
||||
|
||||
while(basePath.exists(newFolder))
|
||||
suggestedName = QString("%1 - %2").arg(m_metaData->fileArtist(), m_metaData->fileAlbum());
|
||||
}
|
||||
else if(!m_metaData->fileArtist().isEmpty())
|
||||
{
|
||||
suggestedName = m_metaData->fileArtist();
|
||||
}
|
||||
else if(!m_metaData->fileAlbum().isEmpty())
|
||||
{
|
||||
suggestedName = m_metaData->fileAlbum();
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i = 0; i < m_fileListModel->rowCount(); i++)
|
||||
{
|
||||
newFolder = QString(folderName).append(QString().sprintf(" (%d)", ++i));
|
||||
}
|
||||
|
||||
if(basePath.mkdir(newFolder))
|
||||
{
|
||||
QDir createdDir = basePath;
|
||||
if(createdDir.cd(newFolder))
|
||||
AudioFileModel audioFile = m_fileListModel->getFile(m_fileListModel->index(i, 0));
|
||||
if(!audioFile.fileAlbum().isEmpty() || !audioFile.fileArtist().isEmpty())
|
||||
{
|
||||
outputFolderView->setCurrentIndex(m_fileSystemModel->index(createdDir.canonicalPath()));
|
||||
outputFolderViewClicked(outputFolderView->currentIndex());
|
||||
outputFolderView->setFocus();
|
||||
if(!audioFile.fileArtist().isEmpty() && !audioFile.fileAlbum().isEmpty())
|
||||
{
|
||||
suggestedName = QString("%1 - %2").arg(audioFile.fileArtist(), audioFile.fileAlbum());
|
||||
}
|
||||
else if(!audioFile.fileArtist().isEmpty())
|
||||
{
|
||||
suggestedName = audioFile.fileArtist();
|
||||
}
|
||||
else if(!audioFile.fileAlbum().isEmpty())
|
||||
{
|
||||
suggestedName = audioFile.fileAlbum();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
|
||||
while(true)
|
||||
{
|
||||
bool bApplied = false;
|
||||
QString folderName = QInputDialog::getText(this, "New Folder", QString("Enter the name of the new folder:").leftJustified(96, ' '), QLineEdit::Normal, suggestedName, &bApplied, Qt::WindowStaysOnTopHint).simplified();
|
||||
|
||||
if(bApplied)
|
||||
{
|
||||
QMessageBox::warning(this, "Failed to create folder", QString("The new folder could not be created:<br><nobr>%1</nobr><br><br>Drive is read-only or insufficient access rights!").arg(basePath.absoluteFilePath(newFolder)));
|
||||
folderName.remove(":", Qt::CaseInsensitive);
|
||||
folderName.remove("/", Qt::CaseInsensitive);
|
||||
folderName.remove("\\", Qt::CaseInsensitive);
|
||||
folderName.remove("?", Qt::CaseInsensitive);
|
||||
folderName.remove("*", Qt::CaseInsensitive);
|
||||
folderName.remove("<", Qt::CaseInsensitive);
|
||||
folderName.remove(">", Qt::CaseInsensitive);
|
||||
|
||||
folderName = folderName.simplified();
|
||||
|
||||
if(folderName.isEmpty())
|
||||
{
|
||||
MessageBeep(MB_ICONERROR);
|
||||
continue;
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
QString newFolder = folderName;
|
||||
|
||||
while(basePath.exists(newFolder))
|
||||
{
|
||||
newFolder = QString(folderName).append(QString().sprintf(" (%d)", ++i));
|
||||
}
|
||||
|
||||
if(basePath.mkdir(newFolder))
|
||||
{
|
||||
QDir createdDir = basePath;
|
||||
if(createdDir.cd(newFolder))
|
||||
{
|
||||
outputFolderView->setCurrentIndex(m_fileSystemModel->index(createdDir.canonicalPath()));
|
||||
outputFolderViewClicked(outputFolderView->currentIndex());
|
||||
outputFolderView->setFocus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this, "Failed to create folder", QString("The new folder could not be created:<br><nobr>%1</nobr><br><br>Drive is read-only or insufficient access rights!").arg(basePath.absoluteFilePath(newFolder)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
#define CHECK3(STR) (STR.isEmpty() ? Qt::darkGray : QVariant())
|
||||
#define CHECK4(VAL) ((VAL == 0) ? Qt::darkGray : QVariant())
|
||||
|
||||
#define EXPAND(STR) QString(STR).leftJustified(96, ' ')
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Constructor & Destructor
|
||||
////////////////////////////////////////////////////////////
|
||||
@ -249,7 +251,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
|
||||
switch(index.row() + m_offset)
|
||||
{
|
||||
case 5:
|
||||
temp = QInputDialog::getText(parent, "Edit Title", "Please enter the title for this file:", QLineEdit::Normal, m_audioFile->fileName(), &ok).simplified();
|
||||
temp = QInputDialog::getText(parent, "Edit Title", EXPAND("Please enter the title for this file:"), QLineEdit::Normal, m_audioFile->fileName(), &ok).simplified();
|
||||
if(ok)
|
||||
{
|
||||
if(temp.isEmpty())
|
||||
@ -265,7 +267,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
temp = QInputDialog::getText(parent, "Edit Artist", "Please enter the artist for this file:", QLineEdit::Normal, m_audioFile->fileArtist(), &ok).simplified();
|
||||
temp = QInputDialog::getText(parent, "Edit Artist", EXPAND("Please enter the artist for this file:"), QLineEdit::Normal, m_audioFile->fileArtist(), &ok).simplified();
|
||||
if(ok)
|
||||
{
|
||||
beginResetModel();
|
||||
@ -274,7 +276,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
temp = QInputDialog::getText(parent, "Edit Album", "Please enter the album for this file:", QLineEdit::Normal, m_audioFile->fileAlbum(), &ok).simplified();
|
||||
temp = QInputDialog::getText(parent, "Edit Album", EXPAND("Please enter the album for this file:"), QLineEdit::Normal, m_audioFile->fileAlbum(), &ok).simplified();
|
||||
if(ok)
|
||||
{
|
||||
beginResetModel();
|
||||
@ -284,7 +286,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
|
||||
break;
|
||||
case 8:
|
||||
for(int i = 0; g_lamexp_generes[i]; i++) generes << g_lamexp_generes[i];
|
||||
temp = QInputDialog::getItem(parent, "Edit Genre", "Please enter the genre for this file:", generes, (m_audioFile->fileGenre().isEmpty() ? 1 : generes.indexOf(m_audioFile->fileGenre())), false, &ok);
|
||||
temp = QInputDialog::getItem(parent, "Edit Genre", EXPAND("Please enter the genre for this file:"), generes, (m_audioFile->fileGenre().isEmpty() ? 1 : generes.indexOf(m_audioFile->fileGenre())), false, &ok);
|
||||
if(ok)
|
||||
{
|
||||
beginResetModel();
|
||||
@ -293,7 +295,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
val = QInputDialog::getInt(parent, "Edit Year", "Please enter the year for this file:", (m_audioFile->fileYear() ? m_audioFile->fileYear() : 1900), 0, 2100, 1, &ok);
|
||||
val = QInputDialog::getInt(parent, "Edit Year", EXPAND("Please enter the year for this file:"), (m_audioFile->fileYear() ? m_audioFile->fileYear() : 1900), 0, 2100, 1, &ok);
|
||||
if(ok)
|
||||
{
|
||||
beginResetModel();
|
||||
@ -304,7 +306,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
|
||||
case 10:
|
||||
if(!m_offset)
|
||||
{
|
||||
val = QInputDialog::getInt(parent, "Edit Position", "Please enter the position (track no.) for this file:", (m_audioFile->filePosition() ? m_audioFile->filePosition() : 1), 0, 99, 1, &ok);
|
||||
val = QInputDialog::getInt(parent, "Edit Position", EXPAND("Please enter the position (track no.) for this file:"), (m_audioFile->filePosition() ? m_audioFile->filePosition() : 1), 0, 99, 1, &ok);
|
||||
if(ok)
|
||||
{
|
||||
beginResetModel();
|
||||
@ -317,7 +319,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
|
||||
QStringList options;
|
||||
options << "Unspecified (copy from source file)";
|
||||
options << "Generate from list position";
|
||||
temp = QInputDialog::getItem(parent, "Edit Position", "Please enter the position (track no.) for this file:", options, ((m_audioFile->filePosition() == UINT_MAX) ? 1 : 0), false, &ok);
|
||||
temp = QInputDialog::getItem(parent, "Edit Position", EXPAND("Please enter the position (track no.) for this file:"), options, ((m_audioFile->filePosition() == UINT_MAX) ? 1 : 0), false, &ok);
|
||||
if(ok)
|
||||
{
|
||||
beginResetModel();
|
||||
@ -327,7 +329,7 @@ void MetaInfoModel::editItem(const QModelIndex &index, QWidget *parent)
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
temp = QInputDialog::getText(parent, "Edit Comment", "Please enter the comment for this file:", QLineEdit::Normal, (m_audioFile->fileComment().isEmpty() ? "Encoded with LameXP" : m_audioFile->fileComment()), &ok).simplified();
|
||||
temp = QInputDialog::getText(parent, "Edit Comment", EXPAND("Please enter the comment for this file:"), QLineEdit::Normal, (m_audioFile->fileComment().isEmpty() ? "Encoded with LameXP" : m_audioFile->fileComment()), &ok).simplified();
|
||||
if(ok)
|
||||
{
|
||||
beginResetModel();
|
||||
|
Loading…
Reference in New Issue
Block a user