Skip to content

Commit

Permalink
Adding more left-bart tools: bard, github, Python doc, C++ doc, ...
Browse files Browse the repository at this point in the history
  • Loading branch information
dvorka committed Nov 19, 2023
1 parent 934d229 commit 5344b17
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 12 deletions.
4 changes: 4 additions & 0 deletions app/mf-resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
<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>
<file alias="github.png">resources/icons/github.png</file>
<file alias="bard.png">resources/icons/bard.png</file>
<file alias="python.png">resources/icons/python.png</file>
<file alias="cpp.png">resources/icons/cpp.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/bard.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/cpp.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/github.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/python.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions app/src/qt/dialogs/run_tool_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RunToolDialog::RunToolDialog(QWidget* parent)
QString{TOOL_DUCKDUCKGO},
QString{TOOL_GOOGLE_BARD},
QString{TOOL_GOOGLE_SEARCH},
QString{TOOL_GH_PROJECTS},
QString{TOOL_GH_REPOS},
QString{TOOL_GH_TOPICS},
QString{TOOL_H2O_GPT_WEB},
QString{TOOL_H2O_GPT_API},
Expand Down Expand Up @@ -113,6 +113,14 @@ QString RunToolDialog::getTemplateTextForToolName(string selectedTool) const
return templateText;
} else if(selectedTool == TOOL_DEEPL) {
return QString{"https://www.deepl.com/en/translator"};
} else if(selectedTool == TOOL_DOC_PYTHON) {
QString templateText{"https://docs.python.org/3.10/search.html?q="};
templateText.append(TOOL_PHRASE);
return templateText;
} else if(selectedTool == TOOL_DOC_CPP) {
QString templateText{"https://duckduckgo.com/?sites=cppreference.com&ia=web&q="};
templateText.append(TOOL_PHRASE);
return templateText;
} else if(selectedTool == TOOL_STACK_OVERFLOW) {
QString templateText{"https://stackoverflow.com/search?q="};
templateText.append(TOOL_PHRASE);
Expand All @@ -126,7 +134,7 @@ QString RunToolDialog::getTemplateTextForToolName(string selectedTool) const
QString templateText{"https://www.github.com/search?q="};
templateText.append(TOOL_PHRASE);
return templateText;
} else if(selectedTool == TOOL_GH_PROJECTS) {
} else if(selectedTool == TOOL_GH_REPOS) {
// TODO fix search URL
QString templateText{"https://www.github.com/search?q="};
templateText.append(TOOL_PHRASE);
Expand Down
29 changes: 20 additions & 9 deletions app/src/qt/left_toolbar_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,38 @@ LeftToolbarView::LeftToolbarView(MainWindowView* mainWindowView)

actionLeftToolbarWikipedia = addAction(
QIcon(":/icons/wikipedia.png"),
"Open Wikipedia and find entry related to the current context... (Alt-2)");
"Open Wikipedia and find entries 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)");
"Open StackOverflow and find entries 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)");
"Open h2oGPT and chat about the current context... (Alt-4)");

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

// TODO "Open DuckDuckGo and search web for the selected entity..."
actionLeftToolbarGitHub = addAction(
QIcon(":/icons/github.png"),
"Open GitHub and find entries related to the current context... (Alt-6)");

// 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..."
actionLeftToolbarBard = addAction(
QIcon(":/icons/bard.png"),
"Open Bard and chat about the current context... (Alt-7)");

actionLeftToolbarPython = addAction(
QIcon(":/icons/python.png"),
"Open Python documentation and find entries related to the current context... (Alt-8)");

actionLeftToolbarCpp = addAction(
QIcon(":/icons/cpp.png"),
"Open C++ documentation and find entries related to the current context... (Alt-9)");

// TODO "Let chatGPT to explaine in simple terms..."
// TODO "Use Gramarly to check to grammar..." > bard/chatGPT can check grammar
}

LeftToolbarView::~LeftToolbarView()
Expand Down
4 changes: 4 additions & 0 deletions app/src/qt/left_toolbar_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class LeftToolbarView : public QToolBar
QAction* actionLeftToolbarStackOverflow;
QAction* actionLeftToolbarH2oGpt;
QAction* actionLeftToolbarDuckDuckGo;
QAction* actionLeftToolbarGitHub;
QAction* actionLeftToolbarBard;
QAction* actionLeftToolbarPython;
QAction* actionLeftToolbarCpp;

// IMPORTANT: hide event hidden as it was causing undesired configuration
// changes and toolbar hiding on Qt's spontaneous hide/show events. Citation
Expand Down
52 changes: 52 additions & 0 deletions app/src/qt/main_window_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,38 @@ MainWindowPresenter::MainWindowPresenter(MainWindowView& view)
view.getLeftToolBar()->actionLeftToolbarDuckDuckGo, SIGNAL(triggered()),
this, SLOT(doActionDuckDuckGoToolbar())
);
QObject::connect(
new QShortcut(QKeySequence("Alt+6"), view.getOrloj()), SIGNAL(activated()),
this, SLOT(doActionGitHubToolbar())
);
QObject::connect(
view.getLeftToolBar()->actionLeftToolbarGitHub, SIGNAL(triggered()),
this, SLOT(doActionGitHubToolbar())
);
QObject::connect(
new QShortcut(QKeySequence("Alt+7"), view.getOrloj()), SIGNAL(activated()),
this, SLOT(doActionBardToolbar())
);
QObject::connect(
view.getLeftToolBar()->actionLeftToolbarBard, SIGNAL(triggered()),
this, SLOT(doActionBardToolbar())
);
QObject::connect(
new QShortcut(QKeySequence("Alt+8"), view.getOrloj()), SIGNAL(activated()),
this, SLOT(doActionPythonToolbar())
);
QObject::connect(
view.getLeftToolBar()->actionLeftToolbarPython, SIGNAL(triggered()),
this, SLOT(doActionPythonToolbar())
);
QObject::connect(
new QShortcut(QKeySequence("Alt+9"), view.getOrloj()), SIGNAL(activated()),
this, SLOT(doActionCppToolbar())
);
QObject::connect(
view.getLeftToolBar()->actionLeftToolbarCpp, SIGNAL(triggered()),
this, SLOT(doActionCppToolbar())
);
// wire TOP toolbar signals
QObject::connect(
view.getToolBar()->actionNewOutlineOrNote, SIGNAL(triggered()),
Expand Down Expand Up @@ -2120,6 +2152,26 @@ void MainWindowPresenter::doActionDuckDuckGoToolbar()
handleLeftToolbarAction(TOOL_DUCKDUCKGO);
}

void MainWindowPresenter::doActionGitHubToolbar()
{
handleLeftToolbarAction(TOOL_GH_REPOS);
}

void MainWindowPresenter::doActionBardToolbar()
{
handleLeftToolbarAction(TOOL_GOOGLE_BARD);
}

void MainWindowPresenter::doActionPythonToolbar()
{
handleLeftToolbarAction(TOOL_DOC_PYTHON);
}

void MainWindowPresenter::doActionCppToolbar()
{
handleLeftToolbarAction(TOOL_DOC_CPP);
}

void MainWindowPresenter::handleLeftToolbarAction(string selectedTool)
{
// get PHRASE from the active context:
Expand Down
4 changes: 4 additions & 0 deletions app/src/qt/main_window_presenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,10 @@ public slots:
void doActionStackOverflowToolbar();
void doActionH2oGptToolbar();
void doActionDuckDuckGoToolbar();
void doActionGitHubToolbar();
void doActionBardToolbar();
void doActionPythonToolbar();
void doActionCppToolbar();
// help
void doActionHelpDocumentation();
void doActionHelpWeb();
Expand Down
4 changes: 3 additions & 1 deletion lib/src/config/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,16 @@ constexpr const auto TOOL_ARXIV = "arXiv";
constexpr const auto TOOL_DUCKDUCKGO = "DuckDuckGo";
constexpr const auto TOOL_DEEPL = "DeepL web";
constexpr const auto TOOL_STACK_OVERFLOW = "StackOverflow";
constexpr const auto TOOL_GH_PROJECTS = "GitHub projects";
constexpr const auto TOOL_GH_REPOS = "GitHub repositories";
constexpr const auto TOOL_GH_TOPICS = "GitHub topics";
constexpr const auto TOOL_GOOGLE_BARD = "Google Bard";
constexpr const auto TOOL_GOOGLE_SEARCH = "Google Search";
constexpr const auto TOOL_H2O_GPT_WEB = "h2oGPT web";
constexpr const auto TOOL_H2O_GPT_API = "h2oGPT API";
constexpr const auto TOOL_CHAT_GPT_WEB = "OpenAI chatGPT web";
constexpr const auto TOOL_WIKIPEDIA = "Wikipedia";
constexpr const auto TOOL_DOC_PYTHON = "Python documentation";
constexpr const auto TOOL_DOC_CPP = "C++ documentation";

// improve platform/language specific
constexpr const auto DEFAULT_NEW_OUTLINE = "# New Markdown File\n\nThis is a new Markdown file created by MindForger.\n\n#Section 1\nThe first section.\n\n";
Expand Down

0 comments on commit 5344b17

Please sign in to comment.