small fixes

1. Show Full Screen tips;
2. Show Rich Paste and Paste To Markdown tips;
This commit is contained in:
Le Tan 2021-03-15 20:20:17 +08:00
parent 24131ffa77
commit df33ee6770
15 changed files with 143 additions and 20 deletions

@ -1 +1 @@
Subproject commit 279cfe3bced0b614915a6531a4bf01278c89532c Subproject commit c86f8bfbf6140b67290ca9229f1145dba5bfc092

View File

@ -14,6 +14,8 @@
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/pathutils.h> #include <utils/pathutils.h>
#include <exception.h> #include <exception.h>
#include <core/configmgr.h>
#include <core/editorconfig.h>
#include <utils/contentmediautils.h> #include <utils/contentmediautils.h>
@ -803,8 +805,12 @@ QString VXNotebookConfigMgr::fetchNodeAttachmentFolder(const QString &p_nodePath
bool VXNotebookConfigMgr::isBuiltInFile(const Node *p_node, const QString &p_name) const bool VXNotebookConfigMgr::isBuiltInFile(const Node *p_node, const QString &p_name) const
{ {
static const QString backupFileExtension = ConfigMgr::getInst().getEditorConfig().getBackupFileExtension().toLower();
const auto name = p_name.toLower(); const auto name = p_name.toLower();
if (name == c_nodeConfigName || name == "_vnote.json") { if (name == c_nodeConfigName
|| name == QStringLiteral("_vnote.json")
|| name.endsWith(backupFileExtension)) {
return true; return true;
} }
return BundleNotebookConfigMgr::isBuiltInFile(p_node, p_name); return BundleNotebookConfigMgr::isBuiltInFile(p_node, p_name);

View File

@ -98,9 +98,9 @@ BufferMgr &VNoteX::getBufferMgr() const
return *m_bufferMgr; return *m_bufferMgr;
} }
void VNoteX::showStatusMessage(const QString &p_message, int timeoutMilliseconds) void VNoteX::showStatusMessage(const QString &p_message, int p_timeoutMilliseconds)
{ {
emit statusMessageRequested(p_message, timeoutMilliseconds); emit statusMessageRequested(p_message, p_timeoutMilliseconds);
} }
void VNoteX::showStatusMessageShort(const QString &p_message) void VNoteX::showStatusMessageShort(const QString &p_message)
@ -108,6 +108,11 @@ void VNoteX::showStatusMessageShort(const QString &p_message)
showStatusMessage(p_message, 3000); showStatusMessage(p_message, 3000);
} }
void VNoteX::showTips(const QString &p_message, int p_timeoutMilliseconds)
{
emit tipsRequested(p_message, p_timeoutMilliseconds);
}
ID VNoteX::getInstanceId() const ID VNoteX::getInstanceId() const
{ {
return m_instanceId; return m_instanceId;

View File

@ -46,10 +46,12 @@ namespace vnotex
ID getInstanceId() const; ID getInstanceId() const;
public slots: public slots:
void showStatusMessage(const QString &p_message, int timeoutMilliseconds = 0); void showStatusMessage(const QString &p_message, int p_timeoutMilliseconds = 0);
void showStatusMessageShort(const QString &p_message); void showStatusMessageShort(const QString &p_message);
void showTips(const QString &p_message, int p_timeoutMilliseconds = 3000);
signals: signals:
// Requested to new a notebook. // Requested to new a notebook.
void newNotebookRequested(); void newNotebookRequested();
@ -77,7 +79,9 @@ namespace vnotex
void newFolderRequested(); void newFolderRequested();
// Requested to show status message. // Requested to show status message.
void statusMessageRequested(const QString &p_message, int timeoutMilliseconds); void statusMessageRequested(const QString &p_message, int p_timeoutMilliseconds);
void tipsRequested(const QString &p_message, int p_timeoutMilliseconds);
// Requested to open @p_node. // Requested to open @p_node.
void openNodeRequested(Node *p_node, const QSharedPointer<FileOpenParameters> &p_paras); void openNodeRequested(Node *p_node, const QSharedPointer<FileOpenParameters> &p_paras);

View File

@ -406,6 +406,11 @@ vnotex--DragDropAreaIndicator QLabel {
font-weight: bold; font-weight: bold;
} }
vnotex--MainWindow QLabel#MainWindowTipsLabel {
font-size: 18pt;
font-weight: bold;
}
/* QLineEdit */ /* QLineEdit */
QLineEdit { QLineEdit {
border: 1px solid @widgets#qlineedit#border; border: 1px solid @widgets#qlineedit#border;

View File

@ -118,3 +118,8 @@ vnotex--DragDropAreaIndicator QLabel {
font-size: 12pt; font-size: 12pt;
font-weight: bold; font-weight: bold;
} }
vnotex--MainWindow QLabel#MainWindowTipsLabel {
font-size: 18pt;
font-weight: bold;
}

View File

@ -406,6 +406,11 @@ vnotex--DragDropAreaIndicator QLabel {
font-weight: bold; font-weight: bold;
} }
vnotex--MainWindow QLabel#MainWindowTipsLabel {
font-size: 18pt;
font-weight: bold;
}
/* QLineEdit */ /* QLineEdit */
QLineEdit { QLineEdit {
border: 1px solid @widgets#qlineedit#border; border: 1px solid @widgets#qlineedit#border;

View File

@ -19,6 +19,7 @@
#include "exception.h" #include "exception.h"
#include "../propertydefs.h" #include "../propertydefs.h"
#include "../listwidget.h" #include "../listwidget.h"
#include <core/configmgr.h>
using namespace vnotex; using namespace vnotex;
@ -69,7 +70,7 @@ void ManageNotebooksDialog::setupUI()
closeNotebook(m_notebookInfoWidget->getNotebook()); closeNotebook(m_notebookInfoWidget->getNotebook());
}); });
m_deleteNotebookBtn = new QPushButton(tr("Delete"), infoWidget); m_deleteNotebookBtn = new QPushButton(tr("Delete (DANGER)"), infoWidget);
WidgetUtils::setPropertyDynamically(m_deleteNotebookBtn, PropertyDefs::s_dangerButton, true); WidgetUtils::setPropertyDynamically(m_deleteNotebookBtn, PropertyDefs::s_dangerButton, true);
btnLayout->addWidget(m_deleteNotebookBtn); btnLayout->addWidget(m_deleteNotebookBtn);
connect(m_deleteNotebookBtn, &QPushButton::clicked, connect(m_deleteNotebookBtn, &QPushButton::clicked,
@ -218,7 +219,7 @@ void ManageNotebooksDialog::closeNotebook(const Notebook *p_notebook)
{ {
Q_ASSERT(p_notebook); Q_ASSERT(p_notebook);
int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Question, int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Question,
tr("Close notebook %1?") tr("Close notebook (%1)?")
.arg(p_notebook->getName()), .arg(p_notebook->getName()),
tr("The notebook could be imported again later."), tr("The notebook could be imported again later."),
tr("Notebook location: %1").arg(p_notebook->getRootFolderAbsolutePath()), tr("Notebook location: %1").arg(p_notebook->getRootFolderAbsolutePath()),
@ -245,10 +246,12 @@ void ManageNotebooksDialog::removeNotebook(const Notebook *p_notebook)
{ {
Q_ASSERT(p_notebook); Q_ASSERT(p_notebook);
int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Warning, int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Warning,
tr("Delete notebook %1 from disk?").arg(p_notebook->getName()), tr("Delete notebook (%1) from disk?").arg(p_notebook->getName()),
tr("It will delete all files belonging to this notebook from disk. " tr("CALM DOWN! CALM DOWN! CALM DOWN! It will delete all files belonging to this notebook from disk. "
"It is dangerous since it will bypass system's recycle bin!"), "It is dangerous since it will bypass system's recycle bin!"),
tr("Notebook location: %1").arg(p_notebook->getRootFolderAbsolutePath()), tr("Notebook location: %1\nUse the \"Close\" button if you just want to remove it from %2.")
.arg(p_notebook->getRootFolderAbsolutePath())
.arg(ConfigMgr::c_appName),
this); this);
if (ret != QMessageBox::Ok) { if (ret != QMessageBox::Ok) {
return; return;

View File

@ -42,6 +42,7 @@
#include <core/texteditorconfig.h> #include <core/texteditorconfig.h>
#include <core/configmgr.h> #include <core/configmgr.h>
#include <core/editorconfig.h> #include <core/editorconfig.h>
#include <core/vnotex.h>
#include "previewhelper.h" #include "previewhelper.h"
#include "../outlineprovider.h" #include "../outlineprovider.h"
@ -443,6 +444,9 @@ void MarkdownEditor::handleInsertFromMimeData(const QMimeData *p_source, bool *p
QClipboard *clipboard = QApplication::clipboard(); QClipboard *clipboard = QApplication::clipboard();
if (!clipboard->property(c_clipboardPropertyMark).toBool()) { if (!clipboard->property(c_clipboardPropertyMark).toBool()) {
// Default paste. // Default paste.
// Give tips about the Rich Paste and Parse As Markdown And Paste features.
VNoteX::getInst().showStatusMessageShort(
tr("For advanced paste, try the \"Rich Paste\" and \"Parse To Markdown And Paste\" on the editor's context menu"));
return; return;
} else { } else {
clipboard->setProperty(c_clipboardPropertyMark, false); clipboard->setProperty(c_clipboardPropertyMark, false);

View File

@ -25,6 +25,7 @@ FullScreenToggleAction::FullScreenToggleAction(QWidget *p_window,
if ((p_checked && !m_window->isFullScreen()) if ((p_checked && !m_window->isFullScreen())
|| (!p_checked && m_window->isFullScreen())) { || (!p_checked && m_window->isFullScreen())) {
setWindowFullScreen(m_window, p_checked); setWindowFullScreen(m_window, p_checked);
emit fullScreenToggled(p_checked);
} }
}); });
} }

View File

@ -13,13 +13,16 @@ namespace vnotex
const QIcon &p_icon, const QIcon &p_icon,
QObject *p_parent = nullptr); QObject *p_parent = nullptr);
static void setWindowFullScreen(QWidget *p_window, bool p_set); signals:
bool fullScreenToggled(bool p_fullScreen);
protected: protected:
bool eventFilter(QObject *p_object, QEvent *p_event) Q_DECL_OVERRIDE; bool eventFilter(QObject *p_object, QEvent *p_event) Q_DECL_OVERRIDE;
private: private:
QWidget *m_window; static void setWindowFullScreen(QWidget *p_window, bool p_set);
QWidget *m_window = nullptr;
}; };
} // ns vnotex } // ns vnotex

View File

@ -17,6 +17,7 @@
#include <QShortcut> #include <QShortcut>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QWindowStateChangeEvent> #include <QWindowStateChangeEvent>
#include <QTimer>
#include "toolbox.h" #include "toolbox.h"
#include "notebookexplorer.h" #include "notebookexplorer.h"
@ -86,6 +87,7 @@ void MainWindow::setupUI()
setupDocks(); setupDocks();
setupToolBar(); setupToolBar();
setupStatusBar(); setupStatusBar();
setupTipsArea();
setupSystemTray(); setupSystemTray();
activateDock(m_docks[DockIndex::NavigationDock]); activateDock(m_docks[DockIndex::NavigationDock]);
@ -98,6 +100,24 @@ void MainWindow::setupStatusBar()
statusBar(), &QStatusBar::showMessage); statusBar(), &QStatusBar::showMessage);
} }
void MainWindow::setupTipsArea()
{
m_tipsLabel = new QLabel(this);
m_tipsLabel->setObjectName("MainWindowTipsLabel");
m_tipsLabel->hide();
m_tipsTimer = new QTimer(this);
m_tipsTimer->setSingleShot(true);
m_tipsTimer->setInterval(3000);
connect(m_tipsTimer, &QTimer::timeout,
this, [this]() {
setTipsAreaVisible(false);
});
connect(&VNoteX::getInst(), &VNoteX::tipsRequested,
this, &MainWindow::showTips);
}
void MainWindow::setupCentralWidget() void MainWindow::setupCentralWidget()
{ {
m_viewArea = new ViewArea(this); m_viewArea = new ViewArea(this);
@ -600,3 +620,41 @@ void MainWindow::exportNotes()
this); this);
dialog.exec(); dialog.exec();
} }
void MainWindow::showTips(const QString &p_message, int p_timeoutMilliseconds)
{
m_tipsTimer->stop();
setTipsAreaVisible(false);
if (p_message.isEmpty()) {
return;
}
m_tipsLabel->setText(p_message);
setTipsAreaVisible(true);
m_tipsTimer->start(p_timeoutMilliseconds);
}
void MainWindow::setTipsAreaVisible(bool p_visible)
{
if (p_visible) {
m_tipsLabel->adjustSize();
int labelW = m_tipsLabel->width();
int labelH = m_tipsLabel->height();
int x = (width() - labelW) / 2;
int y = (height() - labelH) / 2;
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
m_tipsLabel->move(x, y);
m_tipsLabel->show();
} else {
m_tipsLabel->hide();
}
}

View File

@ -9,6 +9,8 @@
class QDockWidget; class QDockWidget;
class QSystemTrayIcon; class QSystemTrayIcon;
class QTimer;
class QLabel;
namespace vnotex namespace vnotex
{ {
@ -74,6 +76,8 @@ namespace vnotex
void exportNotes(); void exportNotes();
void showTips(const QString &p_message, int p_timeoutMilliseconds);
private: private:
// Index in m_docks. // Index in m_docks.
enum DockIndex enum DockIndex
@ -100,6 +104,8 @@ namespace vnotex
void setupStatusBar(); void setupStatusBar();
void setupTipsArea();
void saveStateAndGeometry(); void saveStateAndGeometry();
void loadStateAndGeometry(); void loadStateAndGeometry();
@ -117,6 +123,8 @@ namespace vnotex
void setupSystemTray(); void setupSystemTray();
void setTipsAreaVisible(bool p_visible);
ToolBarHelper m_toolBarHelper; ToolBarHelper m_toolBarHelper;
StatusBarHelper m_statusBarHelper; StatusBarHelper m_statusBarHelper;
@ -142,6 +150,10 @@ namespace vnotex
Qt::WindowStates m_windowOldState = Qt::WindowMinimized; Qt::WindowStates m_windowOldState = Qt::WindowMinimized;
QSystemTrayIcon *m_trayIcon = nullptr; QSystemTrayIcon *m_trayIcon = nullptr;
QLabel *m_tipsLabel = nullptr;
QTimer *m_tipsTimer = nullptr;
}; };
} // ns vnotex } // ns vnotex

View File

@ -122,12 +122,13 @@ int MessageBoxHelper::questionOkCancel(MessageBoxHelper::Type p_type,
const QString &p_detailedText, const QString &p_detailedText,
QWidget *p_parent) QWidget *p_parent)
{ {
bool dangerous = p_type == Type::Warning || p_type == Type::Critical;
int ret = showMessageBox(p_type, int ret = showMessageBox(p_type,
p_text, p_text,
p_informationText, p_informationText,
p_detailedText, p_detailedText,
QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok, dangerous ? QMessageBox::Cancel : QMessageBox::Ok,
p_parent); p_parent);
return ret; return ret;
} }

View File

@ -224,12 +224,23 @@ QToolBar *ToolBarHelper::setupSettingsToolBar(MainWindow *p_win, QToolBar *p_too
}); });
btn->setDefaultAction(expandAct); btn->setDefaultAction(expandAct);
{
auto fullScreenAct = new FullScreenToggleAction(p_win, auto fullScreenAct = new FullScreenToggleAction(p_win,
generateIcon("fullscreen.svg"), generateIcon("fullscreen.svg"),
menu); menu);
WidgetUtils::addActionShortcut(fullScreenAct, const auto shortcut = coreConfig.getShortcut(CoreConfig::Shortcut::FullScreen);
coreConfig.getShortcut(CoreConfig::Shortcut::FullScreen)); WidgetUtils::addActionShortcut(fullScreenAct, shortcut);
MainWindow::connect(fullScreenAct, &FullScreenToggleAction::fullScreenToggled,
p_win, [shortcut](bool p_fullScreen) {
if (p_fullScreen) {
VNoteX::getInst().showTips(
MainWindow::tr("Press %1 To Exit Full Screen").arg(shortcut));
} else {
VNoteX::getInst().showTips("");
}
});
menu->addAction(fullScreenAct); menu->addAction(fullScreenAct);
}
auto stayOnTopAct = menu->addAction(generateIcon("stay_on_top.svg"), MainWindow::tr("Stay On Top"), auto stayOnTopAct = menu->addAction(generateIcon("stay_on_top.svg"), MainWindow::tr("Stay On Top"),
p_win, &MainWindow::setStayOnTop); p_win, &MainWindow::setStayOnTop);