All Classes Namespaces Functions Variables Enumerations Properties Pages
filedialog.h
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5 Copyright (C) 2012-2020 Matthew Chiawen Chang
6 
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2 of the License.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15 
16 */
17 
18 #ifndef FILEDIALOG_H
19 #define FILEDIALOG_H
20 
21 #include <QObject>
22 
23 #include "filetype.h"
24 
28 class FileDialog : public QObject
29 {
30  Q_OBJECT
31 public:
41  static QString getOpenFileName( QWidget* parent, FileType fileType, const QString& caption = QString() );
42 
52  static QStringList getOpenFileNames( QWidget* parent, FileType fileType, const QString& caption = QString() );
53 
62  static QString getSaveFileName( QWidget* parent, FileType fileType, const QString& caption = QString() );
63 
72  static QString getLastOpenPath( FileType fileType );
73 
81  static void setLastOpenPath( FileType fileType, const QString& openPath );
82 
91  static QString getLastSavePath( FileType fileType );
92 
100  static void setLastSavePath( FileType fileType, const QString& savePath );
101 
102 private:
103  static QString openDialogCaption( FileType fileType );
104  static QString saveDialogCaption( FileType fileType );
105  static QString openFileFilters( FileType fileType );
106  static QString saveFileFilters( FileType fileType );
107  static QString getFilterForFile( const QString& fileType, QString filePath );
108  static QString defaultFileName( FileType fileType );
109 
110  static QString addDefaultExtensionSuffix(FileType fileType);
111 
112  static QString toSettingKey( FileType fileType );
113 };
114 
115 #endif // FILEDIALOG_H
A wrapper around QFileDialog which remembers selected paths.
Definition: filedialog.h:28
static QString getLastSavePath(FileType fileType)
Retrieves the last used save path for a given file type.
Definition: filedialog.cpp:120
static void setLastSavePath(FileType fileType, const QString &savePath)
Saves the last used save path for a given file type.
Definition: filedialog.cpp:129
static QStringList getOpenFileNames(QWidget *parent, FileType fileType, const QString &caption=QString())
Shows a file dialog which allows the user to select multiple files to open.
Definition: filedialog.cpp:46
Q_OBJECTQ_OBJECT
static QString getLastOpenPath(FileType fileType)
Retrieves the last opened file of a given type.
Definition: filedialog.cpp:104
static QString getOpenFileName(QWidget *parent, FileType fileType, const QString &caption=QString())
Shows a file dialog which allows the user to select a file to open.
Definition: filedialog.cpp:27
static void setLastOpenPath(FileType fileType, const QString &openPath)
Saves the last opened file of a given type.
Definition: filedialog.cpp:112
static QString getSaveFileName(QWidget *parent, FileType fileType, const QString &caption=QString())
Shows a file dialog which allows the user to select a file save path.
Definition: filedialog.cpp:65
QObject * parent() const const