Schim
mainwindow.h
1 #ifndef MAINWINDOW_H
2 #define MAINWINDOW_H
3 
4 #include "model/project.h"
5 
7 #include "sheetview.h"
8 #include "ui/vim.h"
9 
10 #include <QAction>
11 #include <QMainWindow>
12 #include <QKeyEvent>
13 #include <QList>
14 
15 QT_BEGIN_NAMESPACE
16 namespace Ui { class MainWindow; }
17 QT_END_NAMESPACE
18 
24 class MainWindow : public QMainWindow
25 {
26  Q_OBJECT
27 public:
28  // CONSTRUCTORS
29  explicit MainWindow(QWidget *parent = nullptr);
30  ~MainWindow();
31  static MainWindow *getInstance();
32 
33  // GETTERS
35  QTabWidget *getTabWidget() const;
37  int getTabId() const;
42  SheetView *getTab(int index = -1);
43  SheetScene *scene();
48  Sheet *getSheet(int index = -1);
49  bool isOpen(Sheet *sheet);
50 
51  // SETTERS
52  void setTabId(int id);
53  void setVimStatus(const QString &status);
54  void setActiveProject(Project *project);
55 
56  // USER ACTIONS
57  void nextTab(Vim::N n = 1);
58  void prevTab(Vim::N n = 1);
59  void appendSheet(Vim::N n);
60  void newSheetBefore(Vim::N n = 1);
61  void newSheetAfter(Vim::N n = 1);
62  void closeTab(Vim::N = 0);
63  void sheetSettings(Vim::N = 0);
64  void newProject();
65  void open();
66  void save();
67  void saveAs();
68  void projectSettings();
69  void preferences();
70  void print();
71  void help();
72  void takeScreenshot();
73  void toggleDeveloperHints();
74  void openProjectsFromFiles(const QStringList &filenames, int active = -1);
75  int openSheet(Sheet *sheet, int index = -1);
76  void closeSheet(Sheet *sheet);
77  void closeProject(Project *project);
78  void closeSheetsForProject(Project *project);
79 
80 protected:
81  // EVENTS
82  bool eventFilter(QObject *obj, QEvent *event) override;
83  void keyPressEvent(QKeyEvent *event) override;
84  void closeEvent(QCloseEvent *event) override;
85 
86  // OVERRIDE QMainWindow
87  QMenu *createPopupMenu() override;
88 
89 private slots:
90  // SLOTS
91  void onTabCloseRequested(int index);
92 
93 private:
94  // HELPERS
95  bool processVimAction(const Vim::Action &action);
96  void setupActions();
97  void setupIcons();
102  QMenu *getPopupMenu();
104  void clearTabs();
105  void showMenubarPermanently(bool show);
106  void restoreSettings();
107  void saveSettings();
108 
109 private:
110  // ATTRIBUTES
111  Ui::MainWindow *ui;
112  ProjectManager *projects;
113  bool menuBarShownPermanently = true;
115  QMenu *popupMenu{};
116 
117  static MainWindow *instance;
118 };
119 #endif // MAINWINDOW_H
A model that manages open projects.
Definition: projectmanager.h:18
Definition: mainwindow.h:16
Count n()
The vim-count from the current key sequence.
A specialized QGraphicsScene containing a sheet of paper.
Definition: sheetscene.h:27
An action in vim-mode.
Definition: vim.h:81
A project is essentially a list of sheets, along with some project properties.
Definition: project.h:16
This class models a sheet of paper.
Definition: sheet.h:16
A specialized QGraphicsView that displays a sheet of paper.
Definition: sheetview.h:16
The main application window.
Definition: mainwindow.h:24
Representation of a vim-count.
Definition: vim.h:48