From 2960cba12b578686602fcee2ae089e374e927178 Mon Sep 17 00:00:00 2001 From: Ira Aspen Date: Fri, 5 Feb 2016 21:09:24 +0000 Subject: [PATCH] Added a file picker to the add set menu item. --- cockatrice/src/tab_deck_editor.cpp | 20 ++++++++++++++++++++ cockatrice/src/tab_deck_editor.h | 1 + 2 files changed, 21 insertions(+) diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index 55beba78..3138e8e1 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -45,6 +45,10 @@ #include "cardframe.h" #include "filterbuilder.h" +const QStringList TabDeckEditor::fileNameFilters = QStringList() + << QObject::tr("Cockatrice set format (*.xml)") + << QObject::tr("All files (*.*)"); + void SearchLineEdit::keyPressEvent(QKeyEvent *event) { if (treeView && ((event->key() == Qt::Key_Up) || (event->key() == Qt::Key_Down))) @@ -871,6 +875,22 @@ void TabDeckEditor::actOpenCustomsetsFolder() { void TabDeckEditor::actAddCustomSet() { +#if QT_VERSION < 0x050000 + QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#else + QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first(); +#endif + + if (!confirmClose()) + return; + + QFileDialog dialog(this, tr("Load set")); + dialog.setDirectory(dataDir); + dialog.setNameFilters(TabDeckEditor::fileNameFilters); + if (!dialog.exec()) + return; + + QString fileName = dialog.selectedFiles().at(0); } void TabDeckEditor::actEditSets() diff --git a/cockatrice/src/tab_deck_editor.h b/cockatrice/src/tab_deck_editor.h index 6e580ca8..57152408 100644 --- a/cockatrice/src/tab_deck_editor.h +++ b/cockatrice/src/tab_deck_editor.h @@ -89,6 +89,7 @@ class TabDeckEditor : public Tab { void dockFloatingTriggered(); void dockTopLevelChanged(bool topLevel); private: + static const QStringList fileNameFilters; CardInfo *currentCardInfo() const; void addCardHelper(QString zoneName); void offsetCountAtIndex(const QModelIndex &idx, int offset);