1 /*
2 edit_buttons_panel.cpp 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 #include "edit_buttons_panel.h"
20
21 namespace m8r {
22
23 using namespace std;
24
EditButtonsPanel(MfWidgetMode mode,QWidget * parent)25 EditButtonsPanel::EditButtonsPanel(MfWidgetMode mode, QWidget* parent)
26 : QWidget(parent), mode(mode)
27 {
28 // widgets
29 previewButton = new QPushButton{tr("Preview"), this};
30 #ifdef __APPLE__
31 previewButton->setToolTip("⇧⌘P");
32 #else
33 previewButton->setToolTip("Ctrl+Shift+P");
34 #endif
35 moreButton = new QPushButton{tr("Properties"), this};
36 #ifdef __APPLE__
37 moreButton->setToolTip("⌥↩");
38 #else
39 moreButton->setToolTip("Alt+Enter");
40 #endif
41 rememberButton = new QPushButton{tr("Remember"), this};
42 #ifdef __APPLE__
43 rememberButton->setToolTip("⌘L");
44 #else
45 rememberButton->setToolTip("Alt+Left");
46 #endif
47 cancelButton = new QPushButton{tr("Cancel"), this};
48 #ifdef __APPLE__
49 cancelButton->setToolTip("⌘G");
50 #else
51 cancelButton->setToolTip("Ctrl+G");
52 #endif
53
54 // assembly
55 layout = new QHBoxLayout{this};
56 layout->addStretch(1);
57 layout->addWidget(cancelButton);
58 layout->addWidget(moreButton);
59 layout->addWidget(previewButton);
60 layout->addWidget(rememberButton);
61 setLayout(layout);
62
63 // signals
64 QObject::connect(previewButton, SIGNAL(clicked()), this, SLOT(handleShowLivePreview()));
65 if(mode==MfWidgetMode::OUTLINE_MODE) {
66 QObject::connect(moreButton, SIGNAL(clicked()), this, SLOT(handleShowOutlineHeaderEditDialog()));
67 } else {
68 QObject::connect(moreButton, SIGNAL(clicked()), this, SLOT(handleShowNoteEditDialog()));
69 }
70 }
71
~EditButtonsPanel()72 EditButtonsPanel::~EditButtonsPanel()
73 {
74 delete moreButton;
75 delete previewButton;
76 delete rememberButton;
77 delete cancelButton;
78 delete layout;
79 }
80
handleShowLivePreview()81 void EditButtonsPanel::handleShowLivePreview()
82 {
83 emit signalShowLivePreview();
84 }
85
handleShowOutlineHeaderEditDialog()86 void EditButtonsPanel::handleShowOutlineHeaderEditDialog()
87 {
88 outlineHeaderEditDialog->show();
89 }
90
handleCloseOutlineHeaderEditDialog()91 void EditButtonsPanel::handleCloseOutlineHeaderEditDialog()
92 {
93 outlineHeaderEditDialog->toOutline();
94 }
95
handleShowNoteEditDialog()96 void EditButtonsPanel::handleShowNoteEditDialog()
97 {
98 noteEditDialog->show();
99 }
100
handleCloseNoteEditDialog()101 void EditButtonsPanel::handleCloseNoteEditDialog()
102 {
103 noteEditDialog->toNote();
104 }
105
106 } // m8r namespace
107