Hypnotoad90 / RocketLauncher2

Rocket Launcher 2.0 - A cross platform front end for all DOOM source ports.
GNU General Public License v3.0
55 stars 13 forks source link

Add filename filters for the file-open dialogs, e.g. "Add a pwad" #3

Closed duganchen closed 8 years ago

duganchen commented 8 years ago

ZDL includes filename filters for the file-open dialogs. For ZDL's "add a WAD" dialog, the filtering options are:

WAD/PK3/ZIP/PK7/PKZ/P7Z (*.wad *.pk3 *.zip *.pk7 *.pkz *.p7z)
WAD Files (*.wad)
PK3 Files (*.pk3)
Patch Files (*bex *.deh)
PK7 Files (*.pk7)
PKZ File (*.pkz)
P7Z Files (*.p7z)

As RocketLauncher 2 is using QFileDialog.getOpenFileName, this is easily implemented by changing

QFileDialog::getOpenFileName(this,tr("Add a pwad")

to

const QString filters = "...";
QFileDialog::getOpenFileName(this,tr("Add a pwad","",filters)

Where the filter string is documented here:

http://doc.qt.io/qt-5/qfiledialog.html#getOpenFileName

I've found, testing on Linux, that I can get a case-insensitive filter like this, but I haven't tested it on Windows yet and it also looks ugly in the UI:

const QString filters = "WAD Files (*.[Ww][Aa]][Dd])";

Anyway, implementing this would actually make RocketLauncher 2 much more usable and friendly to me.

Hypnotoad90 commented 8 years ago

Good idea, also since you seem familiar with the code feel free to send a pull request. Otherwise, I'll update it when I get time.