]> git.sur5r.net Git - fstl/blob - src/window.h
8619b4d96d323a1deaeda786636279c602b04884
[fstl] / src / window.h
1 #ifndef WINDOW_H
2 #define WINDOW_H
3
4 #include <QMainWindow>
5 #include <QActionGroup>
6 #include <QFileSystemWatcher>
7 #include <QCollator>
8
9 class Canvas;
10
11 class Window : public QMainWindow
12 {
13     Q_OBJECT
14 public:
15     explicit Window(QWidget* parent=0);
16     bool load_stl(const QString& filename, bool is_reload=false);
17     bool load_prev(void);
18     bool load_next(void);
19
20 protected:
21     void dragEnterEvent(QDragEnterEvent* event) override;
22     void dropEvent(QDropEvent* event) override;
23     void keyPressEvent(QKeyEvent* event) override;
24
25 public slots:
26     void on_open();
27     void on_about();
28     void on_bad_stl();
29     void on_empty_mesh();
30     void on_missing_file();
31     void on_confusing_stl();
32
33     void enable_open();
34     void disable_open();
35
36     void set_watched(const QString& filename);
37
38 private slots:
39     void on_projection(QAction* proj);
40     void on_drawMode(QAction* mode);
41     void on_watched_change(const QString& filename);
42     void on_reload();
43     void on_autoreload_triggered(bool r);
44     void on_clear_recent();
45     void on_load_recent(QAction* a);
46     void on_loaded(const QString& filename);
47     void on_save_screenshot();
48         
49 private:
50     void rebuild_recent_files();
51     void sorted_insert(QStringList& list, const QCollator& collator, const QString& value);
52     void build_folder_file_list();
53     QPair<QString, QString> get_file_neighbors();
54
55     QAction* const open_action;
56     QAction* const about_action;
57     QAction* const quit_action;
58     QAction* const perspective_action;
59     QAction* const orthogonal_action;
60     QAction* const shaded_action;
61     QAction* const wireframe_action;
62     QAction* const reload_action;
63     QAction* const autoreload_action;
64     QAction* const save_screenshot_action;
65
66     QMenu* const recent_files;
67     QActionGroup* const recent_files_group;
68     QAction* const recent_files_clear_action;
69     const static int MAX_RECENT_FILES=8;
70     const static QString RECENT_FILE_KEY;
71     QString current_file;
72     QString lookup_folder;
73     QStringList lookup_folder_files;
74
75     QFileSystemWatcher* watcher;
76
77     Canvas* canvas;
78 };
79
80 #endif // WINDOW_H