mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
minor-fix
- Move Insert Image to tool bar; - Fix Captain mode MagicWrod;
This commit is contained in:
parent
92bc044cac
commit
da027e9fd9
@ -942,7 +942,7 @@ void VEditArea::evaluateMagicWordsByCaptain(void *p_target, void *p_data)
|
||||
Q_UNUSED(p_data);
|
||||
VEditArea *obj = static_cast<VEditArea *>(p_target);
|
||||
VEditTab *tab = obj->getCurrentTab();
|
||||
if (tab) {
|
||||
if (tab && tab->tabHasFocus()) {
|
||||
tab->evaluateMagicWords();
|
||||
}
|
||||
}
|
||||
|
@ -114,3 +114,9 @@ void VEditTab::updateStatus()
|
||||
void VEditTab::evaluateMagicWords()
|
||||
{
|
||||
}
|
||||
|
||||
bool VEditTab::tabHasFocus() const
|
||||
{
|
||||
QWidget *wid = QApplication::focusWidget();
|
||||
return wid == this || isAncestorOf(wid);
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ public:
|
||||
|
||||
void focusTab();
|
||||
|
||||
// Whether this tab has focus.
|
||||
bool tabHasFocus() const;
|
||||
|
||||
// Scroll to @p_header.
|
||||
// Will emit currentHeaderChanged() if @p_header is valid.
|
||||
virtual void scrollToHeader(const VHeaderPointer &p_header) { Q_UNUSED(p_header) }
|
||||
|
@ -463,6 +463,20 @@ void VMainWindow::initEditToolBar(QSize p_iconSize)
|
||||
|
||||
m_editToolBar->addAction(inlineCodeAct);
|
||||
|
||||
// Insert image.
|
||||
QAction *insertImageAct = new QAction(QIcon(":/resources/icons/insert_image.svg"),
|
||||
tr("Insert Image"),
|
||||
this);
|
||||
insertImageAct->setStatusTip(tr("Insert an image from file or URL"));
|
||||
connect(insertImageAct, &QAction::triggered,
|
||||
this, [this]() {
|
||||
if (m_curTab) {
|
||||
m_curTab->insertImage();
|
||||
}
|
||||
});
|
||||
|
||||
m_editToolBar->addAction(insertImageAct);
|
||||
|
||||
QAction *toggleAct = m_editToolBar->toggleViewAction();
|
||||
toggleAct->setToolTip(tr("Toggle the edit toolbar"));
|
||||
viewMenu->addAction(toggleAct);
|
||||
@ -873,20 +887,15 @@ void VMainWindow::initFileMenu()
|
||||
|
||||
fileMenu->addAction(settingsAct);
|
||||
|
||||
QAction *editConfigAct = new QAction(tr("Edit Configuration File"), this);
|
||||
editConfigAct->setToolTip(tr("View and edit configuration file of VNote (vnote.ini)"));
|
||||
connect(editConfigAct, &QAction::triggered,
|
||||
QAction *openConfigAct = new QAction(tr("Open Configuration Folder"), this);
|
||||
openConfigAct->setToolTip(tr("Open configuration folder of VNote"));
|
||||
connect(openConfigAct, &QAction::triggered,
|
||||
this, [this](){
|
||||
#if defined(Q_OS_MACOS) || defined(Q_OS_MAC)
|
||||
// On macOS, it seems that we could not open that ini file directly.
|
||||
QUrl url = QUrl::fromLocalFile(g_config->getConfigFolder());
|
||||
#else
|
||||
QUrl url = QUrl::fromLocalFile(g_config->getConfigFilePath());
|
||||
#endif
|
||||
QDesktopServices::openUrl(url);
|
||||
});
|
||||
|
||||
fileMenu->addAction(editConfigAct);
|
||||
fileMenu->addAction(openConfigAct);
|
||||
|
||||
QAction *customShortcutAct = new QAction(tr("Custom Shortcuts"), this);
|
||||
customShortcutAct->setToolTip(tr("Custom some standard shortcuts"));
|
||||
@ -940,13 +949,6 @@ void VMainWindow::initEditMenu()
|
||||
QMenu *editMenu = menuBar()->addMenu(tr("&Edit"));
|
||||
editMenu->setToolTipsVisible(true);
|
||||
|
||||
// Insert image.
|
||||
m_insertImageAct = newAction(QIcon(":/resources/icons/insert_image.svg"),
|
||||
tr("Insert &Image"), this);
|
||||
m_insertImageAct->setToolTip(tr("Insert an image from file into current note"));
|
||||
connect(m_insertImageAct, &QAction::triggered,
|
||||
this, &VMainWindow::insertImage);
|
||||
|
||||
// Find/Replace.
|
||||
m_findReplaceAct = newAction(QIcon(":/resources/icons/find_replace.svg"),
|
||||
tr("Find/Replace"), this);
|
||||
@ -1069,10 +1071,6 @@ void VMainWindow::initEditMenu()
|
||||
connect(trailingSapceAct, &QAction::triggered,
|
||||
this, &VMainWindow::changeHighlightTrailingSapce);
|
||||
|
||||
editMenu->addAction(m_insertImageAct);
|
||||
editMenu->addSeparator();
|
||||
m_insertImageAct->setEnabled(false);
|
||||
|
||||
QMenu *findReplaceMenu = editMenu->addMenu(tr("Find/Replace"));
|
||||
findReplaceMenu->setToolTipsVisible(true);
|
||||
findReplaceMenu->addAction(m_findReplaceAct);
|
||||
@ -1775,8 +1773,6 @@ void VMainWindow::updateActionsStateFromTab(const VEditTab *p_tab)
|
||||
|
||||
m_attachmentBtn->setEnabled(file && file->getType() == FileType::Note);
|
||||
|
||||
m_insertImageAct->setEnabled(file && editMode);
|
||||
|
||||
setActionsEnabled(m_editToolBar, file && editMode);
|
||||
|
||||
// Handle heading sequence act independently.
|
||||
@ -2145,15 +2141,6 @@ void VMainWindow::repositionAvatar()
|
||||
m_avatar->show();
|
||||
}
|
||||
|
||||
void VMainWindow::insertImage()
|
||||
{
|
||||
if (!m_curTab) {
|
||||
return;
|
||||
}
|
||||
Q_ASSERT(m_curTab == editArea->getCurrentTab());
|
||||
m_curTab->insertImage();
|
||||
}
|
||||
|
||||
bool VMainWindow::locateFile(VFile *p_file)
|
||||
{
|
||||
bool ret = false;
|
||||
|
@ -123,7 +123,6 @@ private slots:
|
||||
void deleteCurNote();
|
||||
void handleCurrentDirectoryChanged(const VDirectory *p_dir);
|
||||
void handleCurrentNotebookChanged(const VNotebook *p_notebook);
|
||||
void insertImage();
|
||||
void handleFindDialogTextChanged(const QString &p_text, uint p_options);
|
||||
void openFindDialog();
|
||||
void enableMermaid(bool p_checked);
|
||||
@ -311,7 +310,6 @@ private:
|
||||
QAction *m_printAct;
|
||||
QAction *m_exportAsPDFAct;
|
||||
|
||||
QAction *m_insertImageAct;
|
||||
QAction *m_findReplaceAct;
|
||||
QAction *m_findNextAct;
|
||||
QAction *m_findPreviousAct;
|
||||
|
Loading…
x
Reference in New Issue
Block a user