1 /*
2  edit_buttons_panel.h     MindForger thinking notebook
3 
4  Copyright (C) 2016-2020 Martin Dvorak <martin.dvorak@mindforger.com>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
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  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef M8R_EDIT_BUTTONS_PANEL_H
20 #define M8R_EDIT_BUTTONS_PANEL_H
21 
22 #include <QtWidgets>
23 
24 #include "mf_widgets.h"
25 #include "../dialogs/note_edit_dialog.h"
26 #include "../dialogs/outline_header_edit_dialog.h"
27 
28 namespace m8r {
29 
30 class EditButtonsPanel : public QWidget
31 {
32     Q_OBJECT
33 
34 private:
35     MfWidgetMode mode;
36 
37     QHBoxLayout* layout;
38     QPushButton* previewButton;
39     QPushButton* moreButton;
40     QPushButton* rememberButton;
41     QPushButton* cancelButton;
42 
43     OutlineHeaderEditDialog* outlineHeaderEditDialog;
44     NoteEditDialog* noteEditDialog;
45 
46 public:
47     explicit EditButtonsPanel(MfWidgetMode mode, QWidget* parent);
48     EditButtonsPanel(const EditButtonsPanel&) = delete;
49     EditButtonsPanel(const EditButtonsPanel&&) = delete;
50     EditButtonsPanel &operator=(const EditButtonsPanel&) = delete;
51     EditButtonsPanel &operator=(const EditButtonsPanel&&) = delete;
52     ~EditButtonsPanel();
53 
54 signals:
55     void signalShowLivePreview();
56 
57 public:
58 /*
59  * NOTE mode
60  */
61 
setNoteEditDialog(NoteEditDialog * dialog)62     void setNoteEditDialog(NoteEditDialog* dialog) {
63         this->noteEditDialog = dialog;
64         // signals can be set after dialog instance is available
65         // IMPROVE wiring to QDialog::accept doesn't from some reason :-/
66         QObject::connect(dialog, SIGNAL(acceptedSignal()), this, SLOT(handleCloseNoteEditDialog()));
67     }
setNote(Note * note)68     void setNote(Note* note) {
69         noteEditDialog->setNote(note);
70     }
71 
72 public slots:
73     void handleShowNoteEditDialog();
74     void handleCloseNoteEditDialog();
75 
76 /*
77  * OUTLINE mode
78  */
79 
80 public:
setOutlineHeaderEditDialog(OutlineHeaderEditDialog * dialog)81     void setOutlineHeaderEditDialog(OutlineHeaderEditDialog* dialog) {
82         this->outlineHeaderEditDialog = dialog;
83         // signals can be set after dialog instance is available
84         // IMPROVE wiring to QDialog::accept doesn't from some reason :-/
85         QObject::connect(dialog, SIGNAL(acceptedSignal()), this, SLOT(handleCloseOutlineHeaderEditDialog()));
86     }
setOutline(Outline * outline)87     void setOutline(Outline* outline) {
88         outlineHeaderEditDialog->setOutline(outline);
89     }
90 
91 public slots:
92     void handleShowLivePreview();
93     void handleShowOutlineHeaderEditDialog();
94     void handleCloseOutlineHeaderEditDialog();
95 
96 public:
getRememberButton()97     QPushButton* getRememberButton() const { return rememberButton; }
getCancelButton()98     QPushButton* getCancelButton() const { return cancelButton; }
99 
100 };
101 
102 }
103 #endif // M8R_EDIT_BUTTONS_PANEL_H
104