Skip to content

Commit

Permalink
Emojis in the new O and N dialog; WIP Wingman preferences.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvorka committed Jan 26, 2024
1 parent 5667a8b commit c665d0a
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 5 deletions.
63 changes: 63 additions & 0 deletions app/src/qt/dialogs/configuration_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ ConfigurationDialog::ConfigurationDialog(QWidget* parent)
markdownTab = new MarkdownTab{this};
navigatorTab = new NavigatorTab{this};
mindTab = new MindTab{this};
wingmanTab = new WingmanTab{this};

tabWidget->addTab(appTab, tr("Application"));
tabWidget->addTab(viewerTab, tr("Viewer"));
tabWidget->addTab(editorTab, tr("Editor"));
tabWidget->addTab(markdownTab, tr("Markdown"));
tabWidget->addTab(navigatorTab, tr("Navigator"));
tabWidget->addTab(mindTab, tr("Mind"));
tabWidget->addTab(wingmanTab, tr("Wingman"));

buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);

Expand Down Expand Up @@ -75,6 +77,7 @@ void ConfigurationDialog::show()
markdownTab->refresh();
navigatorTab->refresh();
mindTab->refresh();
wingmanTab->refresh();

QDialog::show();
}
Expand All @@ -87,6 +90,7 @@ void ConfigurationDialog::saveSlot()
markdownTab->save();
navigatorTab->save();
mindTab->save();
wingmanTab->save();

emit saveConfigSignal();
}
Expand Down Expand Up @@ -656,6 +660,65 @@ void ConfigurationDialog::MindTab::save()
config.setDistributorSleepInterval(distributorSleepIntervalSpin->value());
}

/*
* Wingman tab
*/

ConfigurationDialog::WingmanTab::WingmanTab(QWidget* parent)
: QWidget(parent), config(Configuration::getInstance())
{
llmProvidersLabel = new QLabel(tr("LLM provider:"), this);

llmProvidersCombo = new QComboBox{this};
llmProvidersCombo->addItem(""); // disable Wingman
// TODO enable OpenAI ONLY if ENV_VAR_OPENAI_API_KEY is set
llmProvidersCombo->addItem(
QString{"OpenAI"}, WingmanLlmProviders::WINGMAN_PROVIDER_OPENAI);

// set the last selected provider
llmProvidersCombo->setCurrentIndex(
llmProvidersCombo->findData(config.getWingmanLlmProvider()));

llmHelpLabel = new QLabel(
tr(
"To configure <a href='https://openai.com'>OpenAI</a> LLM provider, "
"<a href='https://platform.openai.com/api-keys'>generate OpenAI API key</a> "
"and set"
"<br/>"
"%1 shell environment variable with the key."
).arg(ENV_VAR_OPENAI_API_KEY));

// assembly
QVBoxLayout* nLayout = new QVBoxLayout{this};
nLayout->addWidget(llmProvidersLabel);
nLayout->addWidget(llmProvidersCombo);
nLayout->addWidget(llmHelpLabel);
QGroupBox* nGroup = new QGroupBox{tr("Large language model (LLM) providers"), this};
nGroup->setLayout(nLayout);

QVBoxLayout* boxesLayout = new QVBoxLayout{this};
boxesLayout->addWidget(nGroup);
boxesLayout->addStretch();
setLayout(boxesLayout);
}

ConfigurationDialog::WingmanTab::~WingmanTab()
{
delete llmProvidersLabel;
delete llmProvidersCombo;
delete llmHelpLabel;
}

void ConfigurationDialog::WingmanTab::refresh()
{
// TODO to be implemented - use App
}

void ConfigurationDialog::WingmanTab::save()
{
// TODO to be implemented - use App
}

/*
* Navigator tab
*/
Expand Down
26 changes: 26 additions & 0 deletions app/src/qt/dialogs/configuration_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ConfigurationDialog : public QDialog
class MarkdownTab;
class NavigatorTab;
class MindTab;
class WingmanTab;

private:
QTabWidget* tabWidget;
Expand All @@ -47,6 +48,7 @@ class ConfigurationDialog : public QDialog
MarkdownTab* markdownTab;
NavigatorTab* navigatorTab;
MindTab* mindTab;
WingmanTab* wingmanTab;

QDialogButtonBox *buttonBox;

Expand All @@ -68,6 +70,30 @@ private slots:
void saveConfigSignal();
};

/**
* @brief Wingman tab.
*/
class ConfigurationDialog::WingmanTab : public QWidget
{
Q_OBJECT

private:
Configuration& config;

QLabel* llmProvidersLabel;
QComboBox* llmProvidersCombo;

QLabel* llmHelpLabel;

public:
explicit WingmanTab(QWidget* parent);
~WingmanTab();

// there and back is handled by Dialog's access to this class & Config singleton
void refresh();
void save();
};

/**
* @brief Mind tab.
*/
Expand Down
14 changes: 13 additions & 1 deletion app/src/qt/dialogs/note_new_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ NoteNewDialog::GeneralTab::GeneralTab(Ontology& ontology, QWidget *parent)
nameLabel = new QLabel(tr("Name")+":", this),
nameEdit = new QLineEdit(tr("Note"), this);

emojisButton = new QPushButton(tr("&Emojis"), this);

// moving edit tags to this position changes TAB ORDER ~ it's selected as 2nd field
editTagsGroup = new EditTagsPanel{MfWidgetMode::CREATE_MODE, ontology, this};
editTagsGroup->refreshOntologyTags();
Expand All @@ -58,7 +60,12 @@ NoteNewDialog::GeneralTab::GeneralTab(Ontology& ontology, QWidget *parent)
// assembly
QVBoxLayout* basicLayout = new QVBoxLayout{this};
basicLayout->addWidget(nameLabel);
basicLayout->addWidget(nameEdit);

QHBoxLayout* nameLayout = new QHBoxLayout{this};
nameLayout->addWidget(nameEdit);
nameLayout->addWidget(emojisButton);
basicLayout->addLayout(nameLayout);

basicLayout->addWidget(positionLabel);
basicLayout->addWidget(positionCombo);
basicLayout->addWidget(viewEditLabel);
Expand Down Expand Up @@ -231,6 +238,11 @@ int NoteNewDialog::getProgress() const
return generalTab->getProgressSpin()->value();
}

QPushButton* NoteNewDialog::getEmojisButton() const
{
return generalTab->getEmojisButton();
}

void NoteNewDialog::show(
const QString& path,
vector<Stencil*>& stencils,
Expand Down
5 changes: 4 additions & 1 deletion app/src/qt/dialogs/note_new_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class NoteNewDialog : public QDialog
GeneralTab* generalTab;
AdvancedTab* advancedTab;

QDialogButtonBox *buttonBox;
QDialogButtonBox* buttonBox;

public:
explicit NoteNewDialog(Ontology& ontology, QWidget* parent);
Expand All @@ -65,6 +65,7 @@ class NoteNewDialog : public QDialog
const NoteType* getNoteType() const;
const std::vector<const Tag*>& getTags() const;
int getProgress() const;
QPushButton* getEmojisButton() const;
bool isPositionBelow() const;
bool isPositionAbove() const { return !isPositionBelow(); }
bool isOpenInEditor() const;
Expand All @@ -88,6 +89,7 @@ class NoteNewDialog::GeneralTab : public QWidget

QLabel* nameLabel;
QLineEdit* nameEdit;
QPushButton* emojisButton;
QLabel* typeLabel;
QComboBox* typeCombo;
QLabel* progressLabel;
Expand All @@ -109,6 +111,7 @@ class NoteNewDialog::GeneralTab : public QWidget
QComboBox* getTypeCombo() const { return typeCombo; }
const std::vector<const Tag*>& getTags() { return editTagsGroup->getTags(); }
QSpinBox* getProgressSpin() const { return progressSpin; }
QPushButton* getEmojisButton() const { return emojisButton; }
QComboBox* getStencilCombo() const { return stencilCombo; }
QComboBox* getPositionCombo() const { return positionCombo; }
QComboBox* getViewEditCombo() const { return viewEditCombo; }
Expand Down
14 changes: 13 additions & 1 deletion app/src/qt/dialogs/outline_new_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ OutlineNewDialog::GeneralTab::GeneralTab(Ontology& ontology, QWidget *parent)
nameLabel = new QLabel(tr("Name")+":", this);
nameEdit = new QLineEdit(tr("Notebook"), this);

emojisButton = new QPushButton(tr("&Emojis"), this);

typeLabel = new QLabel(tr("Type")+":", this);
typeCombo = new QComboBox{this};

Expand All @@ -58,7 +60,12 @@ OutlineNewDialog::GeneralTab::GeneralTab(Ontology& ontology, QWidget *parent)
// assembly
QVBoxLayout* basicLayout = new QVBoxLayout{this};
basicLayout->addWidget(nameLabel);
basicLayout->addWidget(nameEdit);

QHBoxLayout* nameLayout = new QHBoxLayout{this};
nameLayout->addWidget(nameEdit);
nameLayout->addWidget(emojisButton);
basicLayout->addLayout(nameLayout);

basicLayout->addWidget(typeLabel);
basicLayout->addWidget(typeCombo);
QWidget* wiu = new QWidget{this};
Expand Down Expand Up @@ -302,6 +309,11 @@ int OutlineNewDialog::getProgress() const
return generalTab->getProgressSpin()->value();
}

QPushButton* OutlineNewDialog::getEmojisButton() const
{
return generalTab->getEmojisButton();
}

const std::vector<const Tag*>& OutlineNewDialog::getTags() const
{
return generalTab->getTags();
Expand Down
3 changes: 3 additions & 0 deletions app/src/qt/dialogs/outline_new_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class OutlineNewDialog : public QDialog
int8_t getImportance() const;
int8_t getUrgency() const;
int getProgress() const;
QPushButton* getEmojisButton() const;
const std::vector<const Tag*>& getTags() const;

void show(
Expand All @@ -96,6 +97,7 @@ class OutlineNewDialog::GeneralTab : public QWidget

QLabel* nameLabel;
QLineEdit* nameEdit;
QPushButton* emojisButton;
QLabel* typeLabel;
QComboBox* typeCombo;
QLabel* importanceLabel;
Expand All @@ -119,6 +121,7 @@ class OutlineNewDialog::GeneralTab : public QWidget
UrgencyComboBox* getUrgencyCombo() const { return urgencyCombo; }
QComboBox* getStencilCombo() const { return stencilCombo; }
QSpinBox* getProgressSpin() const { return progressSpin; }
QPushButton* getEmojisButton() const { return emojisButton; }
const std::vector<const Tag*>& getTags() { return editTagsGroup->getTags(); }

void showFacet(Repository::RepositoryType repositoryType);
Expand Down
11 changes: 9 additions & 2 deletions app/src/qt/main_window_presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,14 @@ MainWindowPresenter::MainWindowPresenter(MainWindowView& view)
QObject::connect(
newOutlineDialog, SIGNAL(accepted()), this, SLOT(handleOutlineNew()));
QObject::connect(
newNoteDialog, SIGNAL(accepted()), this, SLOT(handleNoteNew()));
newNoteDialog, SIGNAL(accepted()),
this, SLOT(handleNoteNew()));
QObject::connect(
newNoteDialog->getEmojisButton(), SIGNAL(clicked()),
this, SLOT(doActionEmojisDialog()));
QObject::connect(
newOutlineDialog->getEmojisButton(), SIGNAL(clicked()),
this, SLOT(doActionEmojisDialog()));
QObject::connect(
findOutlineByNameDialog, SIGNAL(searchFinished()), this, SLOT(handleFindOutlineByName()));
QObject::connect(
Expand Down Expand Up @@ -3882,7 +3889,7 @@ void MainWindowPresenter::doActionEmojisDialog()
QString{tr("Emojis")},
QString{
"<html>"
"Copy character from below and paste it to the text:"
"Copy character from below to paste it:"
"<br>"
"<br>Emoji:"
"<br>🐞 πŸš€ 🌟 πŸ”§ πŸ§ͺ πŸ“š πŸ”— β›‘ 🚧 ❗ ❌ βœ”"
Expand Down

0 comments on commit c665d0a

Please sign in to comment.