SGL
gfilechooser.h
1 /*
2  * File: gfilechooser.h
3  * --------------------
4  * This file defines the <code>GFileChooser</code> class which supports
5  * popping up graphical dialog boxes to select file names.
6  *
7  * @author Marty Stepp
8  * @version 2018/09/07
9  * - added doc comments for new documentation generation
10  * - added overloads that accept GWindow* parent
11  * @version 2018/08/23
12  * - renamed to gfilechooser.h to replace Java version
13  * @version 2018/06/28
14  * - initial version
15  */
16 
17 
18 #ifndef _gfilechooser_h
19 #define _gfilechooser_h
20 
21 #include <string>
22 #include <QWidget>
23 
24 #include "gwindow.h"
25 
32 class GFileChooser {
33 public:
41  static string showOpenDialog(const string& title = "Open file", const string& currentDir = "", const string& fileFilter = "");
42 
51  static string showOpenDialog(GWindow* parent, const string& title = "Open file", const string& currentDir = "", const string& fileFilter = "");
52 
61  static string showOpenDialog(QWidget* parent, const string& title = "Open file", const string& currentDir = "", const string& fileFilter = "");
62 
78  static string showSaveDialog(const string& title = "Save file", const string& currentDir = "", const string& fileFilter = "");
79 
96  static string showSaveDialog(GWindow* parent, const string& title = "Save file", const string& currentDir = "", const string& fileFilter = "");
97 
114  static string showSaveDialog(QWidget* parent, const string& title = "Save file", const string& currentDir = "", const string& fileFilter = "");
115 
116 private:
117  GFileChooser(); // prevent construction
118 
119  /*
120  * Constants for dialog types, similar to those in Java's JFileChooser
121  */
122  enum DialogType {
123  OPEN_DIALOG = 0,
124  SAVE_DIALOG = 1
125  };
126 
127  /*
128  * Converts between our comma-separated file filter format to the one
129  * used by Qt that uses ;; as its separator.
130  * @param fileFilter a file filter string such as "*.gif,*.jpg,*.png".
131  */
132  static string normalizeFileFilter(const string& fileFilter);
133 };
134 
135 #endif // _gfilechooser_h
static string showOpenDialog(string title="Open file", string currentDir="", string fileFilter="")
Pops up a file "Open" chooser dialog with the given top title text, current directory, and file filter.
Definition: gfilechooser.cpp:28
The GFileChooser class contains static methods for popping up file-choosing dialog boxes that allow t...
Definition: gfilechooser.h:32
static string showSaveDialog(string title="Save file", string currentDir="", string fileFilter="")
Pops up a file "Save" chooser dialog with the given top title text, current directory, and file filter.
Definition: gfilechooser.cpp:51
This class represents a graphics window that supports simple graphics.
Definition: gwindow.h:98