1 /*
2 main_menu_presenter.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 "main_menu_presenter.h"
20
21 namespace m8r {
22
MainMenuPresenter(MainWindowPresenter * mwp)23 MainMenuPresenter::MainMenuPresenter(MainWindowPresenter* mwp)
24 : config(Configuration::getInstance())
25 {
26 this->view = new MainMenuView(mwp->getView());
27 this->mainWindowPresenter = mwp;
28
29 // menu: mind
30 QObject::connect(view->actionMindNewRepository, SIGNAL(triggered()), mwp, SLOT(doActionMindNewRepository()));
31 QObject::connect(view->actionMindNewFile, SIGNAL(triggered()), mwp, SLOT(doActionMindNewFile()));
32 QObject::connect(view->actionMindThink, SIGNAL(triggered()), mwp, SLOT(doActionMindToggleThink()));
33 QObject::connect(view->actionMindAutolink, SIGNAL(triggered()), mwp, SLOT(doActionMindToggleAutolink()));
34 QObject::connect(view->actionMindLearnRepository, SIGNAL(triggered()), mwp, SLOT(doActionMindLearnRepository()));
35 QObject::connect(view->actionMindLearnFile, SIGNAL(triggered()), mwp, SLOT(doActionMindLearnFile()));
36 for(auto& r:config.getRepositories()) {
37 view->submenuMindRelearn->addFile(QString::fromStdString(r.first));
38 }
39 QObject::connect(view->submenuMindRelearn, SIGNAL(recentFileTriggered(QString)), mwp, SLOT(doActionMindRelearn(QString)));
40 QObject::connect(view->actionMindScope, SIGNAL(triggered()), mwp, SLOT(doActionMindTimeTagScope()));
41 QObject::connect(view->actionMindRemember, SIGNAL(triggered()), mwp, SLOT(doActionMindRemember()));
42 // TODO QObject::connect(view->actionMindForget, SIGNAL(triggered()), mwp, SLOT(doActionMindForgetting()));
43 QObject::connect(view->actionMindPreferences, SIGNAL(triggered()), mwp, SLOT(doActionMindPreferences()));
44 QObject::connect(view->actionMindSnapshot, SIGNAL(triggered()), mwp, SLOT(doActionMindSnapshot()));
45 QObject::connect(view->actionMindExportCsv, SIGNAL(triggered()), mwp, SLOT(doActionMindCsvExport()));
46 QObject::connect(view->actionExit, SIGNAL(triggered()), mwp, SLOT(doActionExit()));
47 #ifdef DO_MF_DEBUG
48 QObject::connect(view->actionMindHack, SIGNAL(triggered()), mwp, SLOT(doActionMindHack()));
49 #endif
50
51 // menu: recall
52 QObject::connect(view->actionFindFts, SIGNAL(triggered()), mwp, SLOT(doActionFts()));
53 QObject::connect(view->actionFindOutlineByName, SIGNAL(triggered()), mwp, SLOT(doActionFindOutlineByName()));
54 QObject::connect(view->actionFindNoteByName, SIGNAL(triggered()), mwp, SLOT(doActionFindNoteByName()));
55 QObject::connect(view->actionFindOutlineByTag, SIGNAL(triggered()), mwp, SLOT(doActionFindOutlineByTag()));
56 QObject::connect(view->actionFindNoteByTag, SIGNAL(triggered()), mwp, SLOT(doActionFindNoteByTag()));
57 #ifdef MF_NER
58 QObject::connect(view->actionFindNerPersons, SIGNAL(triggered()), mwp, SLOT(doActionFindNerPersons()));
59 QObject::connect(view->actionFindNerLocations, SIGNAL(triggered()), mwp, SLOT(doActionFindNerLocations()));
60 QObject::connect(view->actionFindNerOrganizations, SIGNAL(triggered()), mwp, SLOT(doActionFindNerOrganizations()));
61 QObject::connect(view->actionFindNerMisc, SIGNAL(triggered()), mwp, SLOT(doActionFindNerMisc()));
62 #endif
63
64 // menu: view
65 QObject::connect(view->actionViewDashboard, SIGNAL(triggered()), mwp, SLOT(doActionViewDashboard()));
66 QObject::connect(view->actionViewHome, SIGNAL(triggered()), mwp, SLOT(doActionViewHome()));
67 QObject::connect(view->actionViewOrganizer, SIGNAL(triggered()), mwp, SLOT(doActionViewOrganizer()));
68 QObject::connect(view->actionViewOutlines, SIGNAL(triggered()), mwp, SLOT(doActionViewOutlines()));
69 QObject::connect(view->actionViewTags, SIGNAL(triggered()), mwp, SLOT(doActionViewTagCloud()));
70 QObject::connect(view->actionViewNavigator, SIGNAL(triggered()), mwp, SLOT(doActionViewKnowledgeGraphNavigator()));
71 QObject::connect(view->actionViewCli, SIGNAL(triggered()), mwp, SLOT(doActionCli()));
72 QObject::connect(view->actionViewRecentNotes, SIGNAL(triggered()), mwp, SLOT(doActionViewRecentNotes()));
73 QObject::connect(view->actionViewHoist, SIGNAL(triggered()), mwp, SLOT(doActionNoteHoist()));
74 QObject::connect(view->actionViewDistractionFree, SIGNAL(triggered()), mwp, SLOT(doActionViewDistractionFree()));
75 QObject::connect(view->actionViewFullscreen, SIGNAL(triggered()), mwp, SLOT(doActionViewFullscreen()));
76
77 // menu: navigator
78 // IMPROVE complete edge shrinking & zooming (skipped as shortcut/mouse wheel is the much more reasonable)
79 QObject::connect(view->actionNavigatorShuffle, SIGNAL(triggered()), mwp, SLOT(doActionNavigatorShuffle()));
80
81 // menu: Outline
82 QObject::connect(view->actionOutlineNew, SIGNAL(triggered()), mwp, SLOT(doActionOutlineNew()));
83 QObject::connect(view->actionOutlineEdit, SIGNAL(triggered()), mwp, SLOT(doActionOutlineEdit()));
84 QObject::connect(view->actionOutlineForget, SIGNAL(triggered()), mwp, SLOT(doActionOutlineForget()));
85 QObject::connect(view->actionOutlineHome, SIGNAL(triggered()), mwp, SLOT(doActionOutlineHome()));
86 QObject::connect(view->actionOutlineClone, SIGNAL(triggered()), mwp, SLOT(doActionOutlineClone()));
87 QObject::connect(view->actionOutlineHtmlExport, SIGNAL(triggered()), mwp, SLOT(doActionOutlineHtmlExport()));
88 QObject::connect(view->actionOutlineTWikiImport, SIGNAL(triggered()), mwp, SLOT(doActionOutlineTWikiImport()));
89
90 // menu: Note
91 QObject::connect(view->actionNoteNew, SIGNAL(triggered()), mwp, SLOT(doActionNoteNew()));
92 QObject::connect(view->actionNoteEdit, SIGNAL(triggered()), mwp, SLOT(doActionNoteEdit()));
93 QObject::connect(view->actionNoteClose, SIGNAL(triggered()), mwp, SLOT(doActionNoteLeave()));
94 QObject::connect(view->actionNoteForget, SIGNAL(triggered()), mwp, SLOT(doActionNoteForget()));
95 QObject::connect(view->actionNotePromote, SIGNAL(triggered()), mwp, SLOT(doActionNotePromote()));
96 QObject::connect(view->actionNoteDemote, SIGNAL(triggered()), mwp, SLOT(doActionNoteDemote()));
97 QObject::connect(view->actionNoteFirst, SIGNAL(triggered()), mwp, SLOT(doActionNoteFirst()));
98 QObject::connect(view->actionNoteUp, SIGNAL(triggered()), mwp, SLOT(doActionNoteUp()));
99 QObject::connect(view->actionNoteDown, SIGNAL(triggered()), mwp, SLOT(doActionNoteDown()));
100 QObject::connect(view->actionNoteLast, SIGNAL(triggered()), mwp, SLOT(doActionNoteLast()));
101 QObject::connect(view->actionNoteRefactor, SIGNAL(triggered()), mwp, SLOT(doActionRefactorNoteToOutline()));
102 QObject::connect(view->actionNoteClone, SIGNAL(triggered()), mwp, SLOT(doActionNoteClone()));
103
104 // menu: edit
105 QObject::connect(view->actionEditFind, SIGNAL(triggered()), mwp, SLOT(doActionEditFind()));
106 QObject::connect(view->actionEditFindNext, SIGNAL(triggered()), mwp, SLOT(doActionEditFindAgain()));
107 // no other bindings needed - it's already bound in the editor ~ menu is rather a documentation
108 QObject::connect(view->actionEditWordWrap, SIGNAL(triggered()), mwp, SLOT(doActionEditWordWrapToggle()));
109 QObject::connect(view->actionEditNameDescFocusSwap, SIGNAL(triggered()), mwp, SLOT(doActionNameDescFocusSwap()));
110 QObject::connect(view->actionEditLiveNotePreview, SIGNAL(triggered()), mwp, SLOT(doActionToggleLiveNotePreview()));
111 QObject::connect(view->actionEditExtract, SIGNAL(triggered()), mwp, SLOT(doActionNoteExtract()));
112
113 // menu: format
114 QObject::connect(view->actionFormatBold, SIGNAL(triggered()), mwp, SLOT(doActionFormatBold()));
115 QObject::connect(view->actionFormatItalic, SIGNAL(triggered()), mwp, SLOT(doActionFormatItalic()));
116 QObject::connect(view->actionFormatCode, SIGNAL(triggered()), mwp, SLOT(doActionFormatCode()));
117 QObject::connect(view->actionFormatMath, SIGNAL(triggered()), mwp, SLOT(doActionFormatMath()));
118 QObject::connect(view->actionFormatMathFraction, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathFrac()));
119 QObject::connect(view->actionFormatMathSum, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathSum()));
120 QObject::connect(view->actionFormatMathInt, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathInt()));
121 QObject::connect(view->actionFormatMathIiint, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathIiint()));
122 QObject::connect(view->actionFormatMathAlpha, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathAlpha()));
123 QObject::connect(view->actionFormatMathBeta, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathBeta()));
124 QObject::connect(view->actionFormatMathDelta, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathDelta()));
125 QObject::connect(view->actionFormatMathGama, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathGama()));
126 QObject::connect(view->actionFormatMathText, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathText()));
127 QObject::connect(view->actionFormatMathBar, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathBar()));
128 QObject::connect(view->actionFormatMathHat, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathHat()));
129 QObject::connect(view->actionFormatMathDot, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathDot()));
130 QObject::connect(view->actionFormatMathOverrightarrow, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathOverrightarrow()));
131 QObject::connect(view->actionFormatMathCup, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathCup()));
132 QObject::connect(view->actionFormatMathCap, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathCap()));
133 QObject::connect(view->actionFormatMathEmptyset, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathEmptyset()));
134 QObject::connect(view->actionFormatMathIn, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathIn()));
135 QObject::connect(view->actionFormatMathNotin, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathNotin()));
136 QObject::connect(view->actionFormatMathSqrt, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathSqrt()));
137 QObject::connect(view->actionFormatStrikethrough, SIGNAL(triggered()), mwp, SLOT(doActionFormatStrikethrough()));
138 QObject::connect(view->actionFormatKeyboard, SIGNAL(triggered()), mwp, SLOT(doActionFormatKeyboard()));
139 QObject::connect(view->actionFormatListBullet, SIGNAL(triggered()), mwp, SLOT(doActionFormatListBullet()));
140 QObject::connect(view->actionFormatListNumber, SIGNAL(triggered()), mwp, SLOT(doActionFormatListNumber()));
141 QObject::connect(view->actionFormatListTask, SIGNAL(triggered()), mwp, SLOT(doActionFormatListTask()));
142 QObject::connect(view->actionFormatListTaskItem, SIGNAL(triggered()), mwp, SLOT(doActionFormatListTaskItem()));
143 QObject::connect(view->actionFormatToc, SIGNAL(triggered()), mwp, SLOT(doActionFormatToc()));
144 QObject::connect(view->actionFormatTimestamp, SIGNAL(triggered()), mwp, SLOT(doActionFormatTimestamp()));
145 QObject::connect(view->actionFormatCodeBlock, SIGNAL(triggered()), mwp, SLOT(doActionFormatCodeBlock()));
146 QObject::connect(view->actionFormatMathBlock, SIGNAL(triggered()), mwp, SLOT(doActionFormatMathBlock()));
147 QObject::connect(view->actionFormatDiagramBlock, SIGNAL(triggered()), mwp, SLOT(doActionFormatDiagramBlock()));
148 QObject::connect(view->actionFormatDiagramsPie, SIGNAL(triggered()), mwp, SLOT(doActionFormatDiagramPie()));
149 QObject::connect(view->actionFormatDiagramsFlow, SIGNAL(triggered()), mwp, SLOT(doActionFormatDiagramFlow()));
150 QObject::connect(view->actionFormatDiagramsClass, SIGNAL(triggered()), mwp, SLOT(doActionFormatDiagramClass()));
151 QObject::connect(view->actionFormatDiagramsGantt, SIGNAL(triggered()), mwp, SLOT(doActionFormatDiagramGantt()));
152 QObject::connect(view->actionFormatDiagramsState, SIGNAL(triggered()), mwp, SLOT(doActionFormatDiagramState()));
153 QObject::connect(view->actionFormatDiagramsSequence, SIGNAL(triggered()), mwp, SLOT(doActionFormatDiagramSequence()));
154 QObject::connect(view->actionFormatBlockQuote, SIGNAL(triggered()), mwp, SLOT(doActionFormatBlockquote()));
155 QObject::connect(view->actionFormatLink, SIGNAL(triggered()), mwp, SLOT(doActionFormatLink()));
156 QObject::connect(view->actionFormatImage, SIGNAL(triggered()), mwp, SLOT(doActionFormatImage()));
157 QObject::connect(view->actionFormatTable, SIGNAL(triggered()), mwp, SLOT(doActionFormatTable()));
158 QObject::connect(view->actionFormatHr, SIGNAL(triggered()), mwp, SLOT(doActionFormatHr()));
159
160 // menu: help
161 QObject::connect(view->actionHelpDocumentation, SIGNAL(triggered()), mwp, SLOT(doActionHelpDocumentation()));
162 QObject::connect(view->actionHelpWeb, SIGNAL(triggered()), mwp, SLOT(doActionHelpWeb()));
163 QObject::connect(view->actionHelpReportBug, SIGNAL(triggered()), mwp, SLOT(doActionHelpReportBug()));
164 QObject::connect(view->actionHelpCheckForUpdates, SIGNAL(triggered()), mwp, SLOT(doActionHelpCheckForUpdates()));
165 QObject::connect(view->actionHelpMarkdown, SIGNAL(triggered()), mwp, SLOT(doActionHelpMarkdown()));
166 QObject::connect(view->actionHelpMathQuickReference, SIGNAL(triggered()), mwp, SLOT(doActionHelpMathQuickReference()));
167 QObject::connect(view->actionHelpMathLivePreview, SIGNAL(triggered()), mwp, SLOT(doActionHelpMathLivePreview()));
168 QObject::connect(view->actionHelpDiagrams, SIGNAL(triggered()), mwp, SLOT(doActionHelpDiagrams()));
169 QObject::connect(view->actionHelpAbout, SIGNAL(triggered()), mwp, SLOT(doActionHelpAboutMindForger()));
170
171 switch(config.getDesiredMindState()) {
172 case Configuration::MindState::THINKING:
173 showFacetMindThink();
174 break;
175 case Configuration::MindState::SLEEPING:
176 showFacetMindSleep();
177 break;
178 default:
179 ; // do nothing for dreaming
180 }
181 }
182
~MainMenuPresenter()183 MainMenuPresenter::~MainMenuPresenter()
184 {
185 // TODO deletes: actions
186 }
187
showFacetDashboard()188 void MainMenuPresenter::showFacetDashboard()
189 {
190 view->showFacetOutlineList(config.getActiveRepository()->getMode()==Repository::RepositoryMode::REPOSITORY);
191 }
192
showFacetOrganizer()193 void MainMenuPresenter::showFacetOrganizer()
194 {
195 view->showFacetOutlineList(config.getActiveRepository()->getMode()==Repository::RepositoryMode::REPOSITORY);
196 }
197
showFacetNavigator()198 void MainMenuPresenter::showFacetNavigator()
199 {
200 view->showFacetNavigator();
201 }
202
showFacetOutlineList()203 void MainMenuPresenter::showFacetOutlineList()
204 {
205 view->showFacetOutlineList(config.getActiveRepository()->getMode()==Repository::RepositoryMode::REPOSITORY);
206 }
207
showFacetOutlineView()208 void MainMenuPresenter::showFacetOutlineView()
209 {
210 view->showFacetOutlineView(config.getActiveRepository()->getMode()==Repository::RepositoryMode::REPOSITORY);
211 }
212
showFacetNoteEdit()213 void MainMenuPresenter::showFacetNoteEdit()
214 {
215 view->showFacetNoteEdit(config.getActiveRepository()->getMode()==Repository::RepositoryMode::REPOSITORY);
216 }
217
showFacetMindThink()218 void MainMenuPresenter::showFacetMindThink()
219 {
220 view->showFacetMindThink();
221 }
showFacetMindSleep()222 void MainMenuPresenter::showFacetMindSleep()
223 {
224 view->showFacetMindSleep();
225 }
226
showFacetMindAutolink(bool enabled)227 void MainMenuPresenter::showFacetMindAutolink(bool enabled)
228 {
229 view->showFacetMindAutolink(enabled);
230 }
231
showFacetLiveNotePreview(bool enabled)232 void MainMenuPresenter::showFacetLiveNotePreview(bool enabled)
233 {
234 view->showFacetLiveNotePreview(enabled);
235 }
236
addRecentDirectoryOrFile(const QString & path)237 void MainMenuPresenter::addRecentDirectoryOrFile(const QString& path)
238 {
239 view->addRepositoryOrFileToRelearn(path);
240 }
241
242 } // namespace
243