]> git.sur5r.net Git - fstl/blob - src/window.h
New upstream version 0.10.0
[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 resizeEvent(QResizeEvent *event) override;
24     void moveEvent(QMoveEvent *event) override;
25     void keyPressEvent(QKeyEvent* event) override;
26
27 public slots:
28     void on_open();
29     void on_about();
30     void on_bad_stl();
31     void on_empty_mesh();
32     void on_missing_file();
33
34     void enable_open();
35     void disable_open();
36
37     void set_watched(const QString& filename);
38
39 private slots:
40     void on_projection(QAction* proj);
41     void on_drawMode(QAction* mode);
42     void on_drawAxes(bool d);
43     void on_invertZoom(bool d);
44     void on_watched_change(const QString& filename);
45     void on_reload();
46     void on_autoreload_triggered(bool r);
47     void on_clear_recent();
48     void on_load_recent(QAction* a);
49     void on_loaded(const QString& filename);
50     void on_save_screenshot();
51     void on_hide_menuBar();
52
53 private:
54     void rebuild_recent_files();
55     void load_persist_settings();
56     void sorted_insert(QStringList& list, const QCollator& collator, const QString& value);
57     void build_folder_file_list();
58     QPair<QString, QString> get_file_neighbors();
59
60     QAction* const open_action;
61     QAction* const about_action;
62     QAction* const quit_action;
63     QAction* const perspective_action;
64     QAction* const orthographic_action;
65     QAction* const shaded_action;
66     QAction* const wireframe_action;
67     QAction* const surfaceangle_action;
68     QAction* const axes_action;
69     QAction* const invert_zoom_action;
70     QAction* const reload_action;
71     QAction* const autoreload_action;
72     QAction* const save_screenshot_action;
73     QAction* const hide_menuBar_action;
74
75     QMenu* const recent_files;
76     QActionGroup* const recent_files_group;
77     QAction* const recent_files_clear_action;
78     const static int MAX_RECENT_FILES=8;
79     const static QString RECENT_FILE_KEY;
80     const static QString INVERT_ZOOM_KEY;
81     const static QString AUTORELOAD_KEY;
82     const static QString DRAW_AXES_KEY;
83     const static QString PROJECTION_KEY;
84     const static QString DRAW_MODE_KEY;
85     const static QString WINDOW_GEOM_KEY;
86
87     QString current_file;
88     QString lookup_folder;
89     QStringList lookup_folder_files;
90
91     QFileSystemWatcher* watcher;
92
93     Canvas* canvas;
94 };
95
96 #endif // WINDOW_H