mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
UniversalEntry: add ? to show help information
This commit is contained in:
parent
0749ce178e
commit
764c0acfe5
@ -64,10 +64,7 @@ void VUpdater::setupUI()
|
|||||||
m_proLabel->hide();
|
m_proLabel->hide();
|
||||||
m_proBar->hide();
|
m_proBar->hide();
|
||||||
|
|
||||||
m_descriptionWV->setMaximumSize(600, 400);
|
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
|
||||||
setWindowTitle(tr("VNote Update"));
|
setWindowTitle(tr("VNote Update"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual ~IUniversalEntry()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// Return a description string for the entry.
|
// Return a description string for the entry.
|
||||||
virtual QString description(int p_id) const = 0;
|
virtual QString description(int p_id) const = 0;
|
||||||
|
|
||||||
@ -52,7 +56,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Select next item.
|
// 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.
|
// Select parent item.
|
||||||
virtual void selectParentItem(int p_id)
|
virtual void selectParentItem(int p_id)
|
||||||
@ -61,7 +69,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Activate current item.
|
// 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.
|
// Ask the UE to stop asynchronously.
|
||||||
virtual void askToStop(int p_id)
|
virtual void askToStop(int p_id)
|
||||||
|
@ -122,7 +122,8 @@ SOURCES += main.cpp\
|
|||||||
vlistwidgetdoublerows.cpp \
|
vlistwidgetdoublerows.cpp \
|
||||||
vdoublerowitemwidget.cpp \
|
vdoublerowitemwidget.cpp \
|
||||||
vsearchue.cpp \
|
vsearchue.cpp \
|
||||||
voutlineue.cpp
|
voutlineue.cpp \
|
||||||
|
vhelpue.cpp
|
||||||
|
|
||||||
HEADERS += vmainwindow.h \
|
HEADERS += vmainwindow.h \
|
||||||
vdirectorytree.h \
|
vdirectorytree.h \
|
||||||
@ -235,7 +236,8 @@ HEADERS += vmainwindow.h \
|
|||||||
vlistwidgetdoublerows.h \
|
vlistwidgetdoublerows.h \
|
||||||
vdoublerowitemwidget.h \
|
vdoublerowitemwidget.h \
|
||||||
vsearchue.h \
|
vsearchue.h \
|
||||||
voutlineue.h
|
voutlineue.h \
|
||||||
|
vhelpue.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
vnote.qrc \
|
vnote.qrc \
|
||||||
|
77
src/vhelpue.cpp
Normal file
77
src/vhelpue.cpp
Normal file
@ -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;
|
||||||
|
}
|
31
src/vhelpue.h
Normal file
31
src/vhelpue.h
Normal file
@ -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
|
@ -42,6 +42,7 @@
|
|||||||
#include "vuniversalentry.h"
|
#include "vuniversalentry.h"
|
||||||
#include "vsearchue.h"
|
#include "vsearchue.h"
|
||||||
#include "voutlineue.h"
|
#include "voutlineue.h"
|
||||||
|
#include "vhelpue.h"
|
||||||
|
|
||||||
extern VConfigManager *g_config;
|
extern VConfigManager *g_config;
|
||||||
|
|
||||||
@ -3213,4 +3214,5 @@ void VMainWindow::initUniversalEntry()
|
|||||||
m_ue->registerEntry('y', new VOutlineUE(this), 0);
|
m_ue->registerEntry('y', new VOutlineUE(this), 0);
|
||||||
m_ue->registerEntry('h', searchUE, VSearchUE::Path_FolderNote_AllNotebook);
|
m_ue->registerEntry('h', searchUE, VSearchUE::Path_FolderNote_AllNotebook);
|
||||||
m_ue->registerEntry('n', searchUE, VSearchUE::Path_FolderNote_CurrentNotebook);
|
m_ue->registerEntry('n', searchUE, VSearchUE::Path_FolderNote_CurrentNotebook);
|
||||||
|
m_ue->registerEntry('?', new VHelpUE(this), 0);
|
||||||
}
|
}
|
||||||
|
@ -353,6 +353,8 @@ void VUniversalEntry::keyPressEvent(QKeyEvent *p_event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case Qt::Key_S:
|
case Qt::Key_S:
|
||||||
if (VUtils::isControlModifierForVim(modifiers)) {
|
if (VUtils::isControlModifierForVim(modifiers)) {
|
||||||
// Ctrl+S to sort the items.
|
// Ctrl+S to sort the items.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user