mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Consolidate accepted decklist file extensions (#5749)
* Consolidate accepted decklist file extensions * rename the other const
This commit is contained in:
parent
42301d4f1a
commit
0fa744f6ec
5 changed files with 17 additions and 7 deletions
|
|
@ -355,7 +355,7 @@ bool AbstractTabDeckEditor::actSaveDeckAs()
|
|||
dialog.setDirectory(SettingsCache::instance().getDeckPath());
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
dialog.setDefaultSuffix("cod");
|
||||
dialog.setNameFilters(DeckLoader::fileNameFilters);
|
||||
dialog.setNameFilters(DeckLoader::FILE_NAME_FILTERS);
|
||||
dialog.selectFile(getDeckList()->getName().trimmed());
|
||||
if (!dialog.exec())
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ static QStringList getAllFiles(const QString &filePath, bool recursive)
|
|||
// QDirIterator with QDir::Files ensures only files are listed (no directories)
|
||||
auto flags =
|
||||
recursive ? QDirIterator::Subdirectories | QDirIterator::FollowSymlinks : QDirIterator::NoIteratorFlags;
|
||||
QDirIterator it(filePath, {"*.txt", "*.cod"}, QDir::Files, flags);
|
||||
QDirIterator it(filePath, DeckLoader::ACCEPTED_FILE_EXTENSIONS, QDir::Files, flags);
|
||||
|
||||
while (it.hasNext()) {
|
||||
allFiles << it.next(); // Add each file path to the list
|
||||
|
|
|
|||
|
|
@ -16,9 +16,10 @@
|
|||
#include <QStringList>
|
||||
#include <QtConcurrentRun>
|
||||
|
||||
const QStringList DeckLoader::fileNameFilters = QStringList()
|
||||
<< QObject::tr("Common deck formats (*.cod *.dec *.dek *.txt *.mwDeck)")
|
||||
<< QObject::tr("All files (*.*)");
|
||||
const QStringList DeckLoader::ACCEPTED_FILE_EXTENSIONS = {"*.cod", "*.dec", "*.dek", "*.txt", "*.mwDeck"};
|
||||
|
||||
const QStringList DeckLoader::FILE_NAME_FILTERS = {
|
||||
tr("Common deck formats (%1)").arg(ACCEPTED_FILE_EXTENSIONS.join(" ")), tr("All files (*.*)")};
|
||||
|
||||
DeckLoader::DeckLoader() : DeckList(), lastFileName(QString()), lastFileFormat(CockatriceFormat), lastRemoteDeckId(-1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,16 @@ public:
|
|||
PlainTextFormat,
|
||||
CockatriceFormat
|
||||
};
|
||||
static const QStringList fileNameFilters;
|
||||
|
||||
/**
|
||||
* Supported file extensions for decklist files
|
||||
*/
|
||||
static const QStringList ACCEPTED_FILE_EXTENSIONS;
|
||||
|
||||
/**
|
||||
* For use with `QFileDialog::setNameFilters`
|
||||
*/
|
||||
static const QStringList FILE_NAME_FILTERS;
|
||||
|
||||
private:
|
||||
QString lastFileName;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ DlgLoadDeck::DlgLoadDeck(QWidget *parent) : QFileDialog(parent, tr("Load Deck"))
|
|||
}
|
||||
|
||||
setDirectory(startingDir);
|
||||
setNameFilters(DeckLoader::fileNameFilters);
|
||||
setNameFilters(DeckLoader::FILE_NAME_FILTERS);
|
||||
|
||||
connect(this, &DlgLoadDeck::accepted, this, &DlgLoadDeck::actAccepted);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue