diff --git a/src/dialog/vupdater.cpp b/src/dialog/vupdater.cpp index bd4871ba..5460c206 100644 --- a/src/dialog/vupdater.cpp +++ b/src/dialog/vupdater.cpp @@ -64,10 +64,7 @@ void VUpdater::setupUI() m_proLabel->hide(); m_proBar->hide(); - m_descriptionWV->setMaximumSize(600, 400); - setLayout(mainLayout); - mainLayout->setSizeConstraint(QLayout::SetFixedSize); setWindowTitle(tr("VNote Update")); } diff --git a/src/iuniversalentry.h b/src/iuniversalentry.h index 40f55c95..4369047f 100644 --- a/src/iuniversalentry.h +++ b/src/iuniversalentry.h @@ -27,6 +27,10 @@ public: { } + virtual ~IUniversalEntry() + { + } + // Return a description string for the entry. virtual QString description(int p_id) const = 0; @@ -52,7 +56,11 @@ public: } // Select next item. - virtual void selectNextItem(int p_id, bool p_forward) = 0; + virtual void selectNextItem(int p_id, bool p_forward) + { + Q_UNUSED(p_id); + Q_UNUSED(p_forward); + } // Select parent item. virtual void selectParentItem(int p_id) @@ -61,7 +69,10 @@ public: } // Activate current item. - virtual void activate(int p_id) = 0; + virtual void activate(int p_id) + { + Q_UNUSED(p_id); + } // Ask the UE to stop asynchronously. virtual void askToStop(int p_id) diff --git a/src/src.pro b/src/src.pro index f8b9ff99..a2a97324 100644 --- a/src/src.pro +++ b/src/src.pro @@ -122,7 +122,8 @@ SOURCES += main.cpp\ vlistwidgetdoublerows.cpp \ vdoublerowitemwidget.cpp \ vsearchue.cpp \ - voutlineue.cpp + voutlineue.cpp \ + vhelpue.cpp HEADERS += vmainwindow.h \ vdirectorytree.h \ @@ -235,7 +236,8 @@ HEADERS += vmainwindow.h \ vlistwidgetdoublerows.h \ vdoublerowitemwidget.h \ vsearchue.h \ - voutlineue.h + voutlineue.h \ + vhelpue.h RESOURCES += \ vnote.qrc \ diff --git a/src/vhelpue.cpp b/src/vhelpue.cpp new file mode 100644 index 00000000..f9dcba54 --- /dev/null +++ b/src/vhelpue.cpp @@ -0,0 +1,77 @@ +#include "vhelpue.h" + +#include "vlistwidget.h" + + +VHelpUE::VHelpUE(QObject *p_parent) + : IUniversalEntry(p_parent), + m_listWidget(NULL) +{ +} + +void VHelpUE::init() +{ + if (m_initialized) { + return; + } + + m_initialized = true; + + m_listWidget = new VListWidget(m_widgetParent); + m_listWidget->setFitContent(true); +} + +QString VHelpUE::description(int p_id) const +{ + Q_UNUSED(p_id); + return tr("View help information about Universal Entry"); +} + +QWidget *VHelpUE::widget(int p_id) +{ + Q_UNUSED(p_id); + + init(); + + return m_listWidget; +} + +void VHelpUE::processCommand(int p_id, const QString &p_cmd) +{ + Q_UNUSED(p_id); + Q_UNUSED(p_cmd); + + init(); + + if (initListWidget()) { + m_listWidget->updateGeometry(); + emit widgetUpdated(); + } + + emit stateUpdated(State::Success); +} + +void VHelpUE::clear(int p_id) +{ + Q_UNUSED(p_id); + m_listWidget->clearAll(); +} + +bool VHelpUE::initListWidget() +{ + if (m_listWidget->count() == 0) { + m_listWidget->addItem(tr("Esc/Ctrl+[: Hide Universal Entry")); + m_listWidget->addItem(tr("Ctrl+U: Clear the command input")); + m_listWidget->addItem(tr("Ctrl+E: Clear the command input except the entry key")); + m_listWidget->addItem(tr("Ctrl+J: Select next item")); + m_listWidget->addItem(tr("Ctrl+K: Select previous item")); + m_listWidget->addItem(tr("Enter: Activate current item")); + m_listWidget->addItem(tr("Ctrl+R: Select current item's parent item")); + m_listWidget->addItem(tr("Ctrl+T: Expand/Collapse current item")); + m_listWidget->addItem(tr("Ctrl+S: Sort the items")); + + return true; + } + + return false; +} diff --git a/src/vhelpue.h b/src/vhelpue.h new file mode 100644 index 00000000..8a5ac1cb --- /dev/null +++ b/src/vhelpue.h @@ -0,0 +1,31 @@ +#ifndef VHELPUE_H +#define VHELPUE_H + +#include "iuniversalentry.h" + +class VListWidget; + +class VHelpUE : public IUniversalEntry +{ + Q_OBJECT +public: + explicit VHelpUE(QObject *p_parent = nullptr); + + QString description(int p_id) const Q_DECL_OVERRIDE; + + QWidget *widget(int p_id) Q_DECL_OVERRIDE; + + void processCommand(int p_id, const QString &p_cmd) Q_DECL_OVERRIDE; + + void clear(int p_id) Q_DECL_OVERRIDE; + +protected: + void init() Q_DECL_OVERRIDE; + +private: + bool initListWidget(); + + VListWidget *m_listWidget; +}; + +#endif // VHELPUE_H diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index 7ae197c5..758ed8e7 100644 --- a/src/vmainwindow.cpp +++ b/src/vmainwindow.cpp @@ -42,6 +42,7 @@ #include "vuniversalentry.h" #include "vsearchue.h" #include "voutlineue.h" +#include "vhelpue.h" extern VConfigManager *g_config; @@ -3213,4 +3214,5 @@ void VMainWindow::initUniversalEntry() m_ue->registerEntry('y', new VOutlineUE(this), 0); m_ue->registerEntry('h', searchUE, VSearchUE::Path_FolderNote_AllNotebook); m_ue->registerEntry('n', searchUE, VSearchUE::Path_FolderNote_CurrentNotebook); + m_ue->registerEntry('?', new VHelpUE(this), 0); } diff --git a/src/vuniversalentry.cpp b/src/vuniversalentry.cpp index f0e6049c..8cc67f5d 100644 --- a/src/vuniversalentry.cpp +++ b/src/vuniversalentry.cpp @@ -353,6 +353,8 @@ void VUniversalEntry::keyPressEvent(QKeyEvent *p_event) return; } + break; + case Qt::Key_S: if (VUtils::isControlModifierForVim(modifiers)) { // Ctrl+S to sort the items.