Skip to content

Commit

Permalink
WIP left menu bar wit tools & short cuts.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvorka committed Nov 19, 2023
1 parent af6551e commit 934d229
Show file tree
Hide file tree
Showing 22 changed files with 325 additions and 128 deletions.
2 changes: 2 additions & 0 deletions app/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ HEADERS += \
src/qt/kanban_column_view.h \
src/qt/kanban_presenter.h \
src/qt/kanban_view.h \
src/qt/left_toolbar_view.h \
src/qt/note_smart_editor.h \
src/qt/organizer_view.h \
src/qt/organizer_presenter.h \
Expand Down Expand Up @@ -412,6 +413,7 @@ SOURCES += \
src/qt/kanban_column_view.cpp \
src/qt/kanban_presenter.cpp \
src/qt/kanban_view.cpp \
src/qt/left_toolbar_view.cpp \
src/qt/note_smart_editor.cpp \
src/qt/organizer_view.cpp \
src/qt/organizer_presenter.cpp \
Expand Down
5 changes: 5 additions & 0 deletions app/mf-resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
<file alias="think.svg">resources/icons/flat-think.svg</file>
<file alias="adapt.svg">resources/icons/flat-adapt.svg</file>
<file alias="help.svg">resources/icons/flat-help.svg</file>
<file alias="arxiv.png">resources/icons/arxiv.png</file>
<file alias="wikipedia.png">resources/icons/wikipedia.png</file>
<file alias="stackoverflow.png">resources/icons/stackoverflow.png</file>
<file alias="duckduckgo.png">resources/icons/duckduckgo.png</file>
<file alias="h2oai.png">resources/icons/h2oai.png</file>
</qresource>
<qresource prefix="/translations">
<file alias="mindforger_cs_CZ.qm">resources/qt/translations/mindforger_cs.qm</file>
Expand Down
Binary file added app/resources/icons/arxiv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/resources/icons/duckduckgo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/resources/icons/h2oai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/resources/icons/stackoverflow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/resources/icons/wikipedia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 7 additions & 3 deletions app/src/qt/dialogs/run_tool_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,18 @@ void RunToolDialog::show()
QDialog::show();
}

QString RunToolDialog::getTemplateTextForToolName(QString selectedTool) const
QString RunToolDialog::getTemplateTextForToolName(string selectedTool) const
{
if(selectedTool == TOOL_ARXIV) {
QString templateText{"https://arxiv.org/search/?query="};
templateText.append(TOOL_PHRASE);
return templateText;
} else if(selectedTool == TOOL_DEEPL) {
return QString{"https://www.deepl.com/en/translator"};
} else if(selectedTool == TOOL_STACK_OVERFLOW) {
QString templateText{"https://stackoverflow.com/search?q="};
templateText.append(TOOL_PHRASE);
return templateText;
} else if(selectedTool == TOOL_DUCKDUCKGO) {
QString templateText{"https://www.duckduckgo.com/?q="};
templateText.append(TOOL_PHRASE);
Expand Down Expand Up @@ -148,7 +152,7 @@ QString RunToolDialog::getTemplateTextForToolName(QString selectedTool) const
}

string msg{
"Tool '" + selectedTool.toStdString() + "' to search/explain/process "
"Tool '" + selectedTool + "' to search/explain/process "
"the phrase is not supported."};
QMessageBox msgBox{
QMessageBox::Critical,
Expand All @@ -162,7 +166,7 @@ QString RunToolDialog::getTemplateTextForToolName(QString selectedTool) const
void RunToolDialog::handleChangeToolCombo(const QString& text) {
MF_DEBUG("Tool changed: " << text.toStdString() << endl);

this->templateEdit->setText(getTemplateTextForToolName(text));
this->templateEdit->setText(getTemplateTextForToolName(text.toStdString()));
}

} // m8r namespace
2 changes: 1 addition & 1 deletion app/src/qt/dialogs/run_tool_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RunToolDialog : public QDialog

void show();

QString getTemplateTextForToolName(QString selectedTool) const;
QString getTemplateTextForToolName(std::string selectedTool) const;

QPushButton* getRunButton() const { return runButton; }
QString getSelectedTool() const {
Expand Down
60 changes: 60 additions & 0 deletions app/src/qt/left_toolbar_view.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
left_toolbar_view.cpp MindForger thinking notebook
Copyright (C) 2016-2023 Martin Dvorak <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "left_toolbar_view.h"

namespace m8r {

LeftToolbarView::LeftToolbarView(MainWindowView* mainWindowView)
: QToolBar{tr("Tool Bar"), mainWindowView},
mainWindow{mainWindowView}
{
actionLeftToolbarArxiv = addAction(
QIcon(":/icons/arxiv.png"),
"Open arXiv and find papers related to the current context... (Alt-1)");

actionLeftToolbarWikipedia = addAction(
QIcon(":/icons/wikipedia.png"),
"Open Wikipedia and find entry related to the current context... (Alt-2)");

actionLeftToolbarStackOverflow = addAction(
QIcon(":/icons/stackoverflow.png"),
"Open StackOverflow and find entry related to the current context... (Alt-3)");

actionLeftToolbarH2oGpt= addAction(
QIcon(":/icons/h2oai.png"),
"Open h2oGPT and chat about entry related to the current context... (Alt-4)");

actionLeftToolbarDuckDuckGo = addAction(
QIcon(":/icons/duckduckgo.png"),
"Open DuckDuckGo and find entry related to the current context... (Alt-5)");

// TODO "Open DuckDuckGo and search web for the selected entity..."

// TODO "Let chatGPT to explaine in simple terms..."
// TODO "Use Gramarly to check to grammar..."
// TODO "Use Pandoc to convert MindForger's Markdown documents..."
// TODO "Build your web with MindForger's Markdown documents and Docusaurus..."

}

LeftToolbarView::~LeftToolbarView()
{
}

} // m8r namespace
72 changes: 72 additions & 0 deletions app/src/qt/left_toolbar_view.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
left_toolbar_view.h MindForger thinking notebook
Copyright (C) 2016-2023 Martin Dvorak <[email protected]>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef M8RUI_LEFT_TOOLBAR_VIEW_H
#define M8RUI_LEFT_TOOLBAR_VIEW_H

#include <QtWidgets>

#include "main_window_view.h"

namespace m8r {

class MainWindowView;

class LeftToolbarView : public QToolBar
{
Q_OBJECT

MainWindowView* mainWindow;

public:
QAction* actionLeftToolbarArxiv;
QAction* actionLeftToolbarWikipedia;
QAction* actionLeftToolbarStackOverflow;
QAction* actionLeftToolbarH2oGpt;
QAction* actionLeftToolbarDuckDuckGo;

// IMPORTANT: hide event hidden as it was causing undesired configuration
// changes and toolbar hiding on Qt's spontaneous hide/show events. Citation
// from Qt doc:
//
// "Note: A widget receives spontaneous show and hide events when its mapping
// status is changed by the window system, e.g. a spontaneous hide event when
// the user minimizes the window, and a spontaneous show event when the window
// is restored again. After receiving a spontaneous hide event, a widget is
// still considered visible in the sense of isVisible()."
//
// Even use of this->isVisible() within the event didn't fixed the problem.
//
// @see https://github.com/dvorka/mindforger/issues/1437
//
// void hideEvent(QHideEvent *) override;

public:
explicit LeftToolbarView(MainWindowView* mainWindowView);
LeftToolbarView(const LeftToolbarView&) = delete;
LeftToolbarView(const LeftToolbarView&&) = delete;
LeftToolbarView &operator=(const LeftToolbarView&) = delete;
LeftToolbarView &operator=(const LeftToolbarView&&) = delete;
~LeftToolbarView();

signals:
void signalLeftToolbarVisibilityChanged(bool visibility);
};

}
#endif // M8RUI_LEFT_TOOLBAR_VIEW_H
8 changes: 0 additions & 8 deletions app/src/qt/main_menu_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,6 @@ MainMenuPresenter::MainMenuPresenter(MainWindowPresenter* mwp)
QObject::connect(view->actionFormatTable, SIGNAL(triggered()), mwp, SLOT(doActionFormatTable()));
QObject::connect(view->actionFormatHr, SIGNAL(triggered()), mwp, SLOT(doActionFormatHr()));

// menu: tools
QObject::connect(view->actionToolsArxiv, SIGNAL(triggered()), mwp, SLOT(doActionToolsArxiv()));
QObject::connect(view->actionToolsPandoc, SIGNAL(triggered()), mwp, SLOT(doActionToolsPandoc()));
QObject::connect(view->actionToolsChatGpt, SIGNAL(triggered()), mwp, SLOT(doActionToolsChatGpt()));
QObject::connect(view->actionToolsWikipedia, SIGNAL(triggered()), mwp, SLOT(doActionToolsWikipedia()));
QObject::connect(view->actionToolsDocusaurus, SIGNAL(triggered()), mwp, SLOT(doActionToolsDocusaurus()));
QObject::connect(view->actionToolsDuckDuckGo, SIGNAL(triggered()), mwp, SLOT(doActionToolsDucDuckGo()));

// menu: help
QObject::connect(view->actionHelpDocumentation, SIGNAL(triggered()), mwp, SLOT(doActionHelpDocumentation()));
QObject::connect(view->actionHelpWeb, SIGNAL(triggered()), mwp, SLOT(doActionHelpWeb()));
Expand Down
53 changes: 0 additions & 53 deletions app/src/qt/main_menu_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,59 +957,6 @@ MainMenuView::MainMenuView(MainWindowView& mainWindowView)
menuFormat->addAction(actionFormatImage);
menuFormat->setEnabled(false);


#ifdef MF_WIP
// menu: tools

/*
menuTools = qMenuBar->addMenu(tr("&Tools"));
actionToolsWikipedia = new QAction(
QIcon(":/menu-icons/link.svg"), tr("&Wikipedia"), mainWindow);
actionToolsWikipedia->setStatusTip(
tr("Open Wikipadia and find entry of the selected entity..."));
menuTools->addAction(actionToolsWikipedia);
actionToolsArxiv = new QAction(
QIcon(":/menu-icons/link.svg"), tr("&arXiv"), mainWindow);
actionToolsArxiv->setStatusTip(tr(
"Open arXiv and find papers related to the selected entity..."));
menuTools->addAction(actionToolsArxiv);
actionToolsChatGpt = new QAction(
QIcon(":/menu-icons/link.svg"),
tr("&ChatGPT: Explain ... in simple terms."),
mainWindow);
actionToolsChatGpt->setStatusTip(
tr("Let ChatGPT to explain the selected entry..."));
menuTools->addAction(actionToolsChatGpt);
actionToolsGramarly= new QAction(
QIcon(":/menu-icons/link.svg"), tr("&Gramarly"), mainWindow);
actionToolsGramarly->setStatusTip(tr(
"Use Gramarly to check to grammar..."));
menuTools->addAction(actionToolsGramarly);
actionToolsDuckDuckGo = new QAction(
QIcon(":/menu-icons/link.svg"), tr("&DuckDuckGo"), mainWindow);
actionToolsDuckDuckGo->setStatusTip(
tr("Open DuckDuckGo and search web for the selected entity..."));
menuTools->addAction(actionToolsDuckDuckGo);
actionToolsPandoc = new QAction(
QIcon(":/menu-icons/link.svg"), tr("&Pandoc"), mainWindow);
actionToolsPandoc ->setStatusTip(
tr("Use Pandoc to convert MindForger's Markdown documents..."));
menuTools->addAction(actionToolsPandoc);
actionToolsDocusaurus = new QAction(
QIcon(":/menu-icons/link.svg"), tr("D&ocusaurus"), mainWindow);
actionToolsDocusaurus->setStatusTip(
tr("Build your web with MindForger's Markdown documents and Docusaurus..."));
menuTools->addAction(actionToolsDocusaurus);
*/
#endif

// menu: help

actionHelpDocumentation = new QAction(
Expand Down
9 changes: 0 additions & 9 deletions app/src/qt/main_menu_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,6 @@ class MainMenuView : public QObject
QAction* actionFormatHr;
QAction* actionFormatTimestamp;

// menu: Tools
QAction* actionToolsWikipedia;
QAction* actionToolsArxiv;
QAction* actionToolsChatGpt;
QAction* actionToolsGramarly;
QAction* actionToolsDuckDuckGo;
QAction* actionToolsPandoc;
QAction* actionToolsDocusaurus;

// menu: Help
QAction* actionHelpDocumentation;
QAction* actionHelpWeb;
Expand Down
Loading

0 comments on commit 934d229

Please sign in to comment.