mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
small fixes
1. Show Full Screen tips; 2. Show Rich Paste and Paste To Markdown tips;
This commit is contained in:
parent
24131ffa77
commit
df33ee6770
@ -1 +1 @@
|
||||
Subproject commit 279cfe3bced0b614915a6531a4bf01278c89532c
|
||||
Subproject commit c86f8bfbf6140b67290ca9229f1145dba5bfc092
|
@ -14,6 +14,8 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/pathutils.h>
|
||||
#include <exception.h>
|
||||
#include <core/configmgr.h>
|
||||
#include <core/editorconfig.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
|
||||
{
|
||||
static const QString backupFileExtension = ConfigMgr::getInst().getEditorConfig().getBackupFileExtension().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 BundleNotebookConfigMgr::isBuiltInFile(p_node, p_name);
|
||||
|
@ -98,9 +98,9 @@ BufferMgr &VNoteX::getBufferMgr() const
|
||||
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)
|
||||
@ -108,6 +108,11 @@ void VNoteX::showStatusMessageShort(const QString &p_message)
|
||||
showStatusMessage(p_message, 3000);
|
||||
}
|
||||
|
||||
void VNoteX::showTips(const QString &p_message, int p_timeoutMilliseconds)
|
||||
{
|
||||
emit tipsRequested(p_message, p_timeoutMilliseconds);
|
||||
}
|
||||
|
||||
ID VNoteX::getInstanceId() const
|
||||
{
|
||||
return m_instanceId;
|
||||
|
@ -46,10 +46,12 @@ namespace vnotex
|
||||
ID getInstanceId() const;
|
||||
|
||||
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 showTips(const QString &p_message, int p_timeoutMilliseconds = 3000);
|
||||
|
||||
signals:
|
||||
// Requested to new a notebook.
|
||||
void newNotebookRequested();
|
||||
@ -77,7 +79,9 @@ namespace vnotex
|
||||
void newFolderRequested();
|
||||
|
||||
// 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.
|
||||
void openNodeRequested(Node *p_node, const QSharedPointer<FileOpenParameters> &p_paras);
|
||||
|
@ -406,6 +406,11 @@ vnotex--DragDropAreaIndicator QLabel {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
vnotex--MainWindow QLabel#MainWindowTipsLabel {
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* QLineEdit */
|
||||
QLineEdit {
|
||||
border: 1px solid @widgets#qlineedit#border;
|
||||
|
@ -118,3 +118,8 @@ vnotex--DragDropAreaIndicator QLabel {
|
||||
font-size: 12pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
vnotex--MainWindow QLabel#MainWindowTipsLabel {
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
@ -406,6 +406,11 @@ vnotex--DragDropAreaIndicator QLabel {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
vnotex--MainWindow QLabel#MainWindowTipsLabel {
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* QLineEdit */
|
||||
QLineEdit {
|
||||
border: 1px solid @widgets#qlineedit#border;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "exception.h"
|
||||
#include "../propertydefs.h"
|
||||
#include "../listwidget.h"
|
||||
#include <core/configmgr.h>
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
@ -69,7 +70,7 @@ void ManageNotebooksDialog::setupUI()
|
||||
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);
|
||||
btnLayout->addWidget(m_deleteNotebookBtn);
|
||||
connect(m_deleteNotebookBtn, &QPushButton::clicked,
|
||||
@ -218,7 +219,7 @@ void ManageNotebooksDialog::closeNotebook(const Notebook *p_notebook)
|
||||
{
|
||||
Q_ASSERT(p_notebook);
|
||||
int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Question,
|
||||
tr("Close notebook %1?")
|
||||
tr("Close notebook (%1)?")
|
||||
.arg(p_notebook->getName()),
|
||||
tr("The notebook could be imported again later."),
|
||||
tr("Notebook location: %1").arg(p_notebook->getRootFolderAbsolutePath()),
|
||||
@ -245,10 +246,12 @@ void ManageNotebooksDialog::removeNotebook(const Notebook *p_notebook)
|
||||
{
|
||||
Q_ASSERT(p_notebook);
|
||||
int ret = MessageBoxHelper::questionOkCancel(MessageBoxHelper::Warning,
|
||||
tr("Delete notebook %1 from disk?").arg(p_notebook->getName()),
|
||||
tr("It will delete all files belonging to this notebook from disk. "
|
||||
tr("Delete notebook (%1) from disk?").arg(p_notebook->getName()),
|
||||
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!"),
|
||||
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);
|
||||
if (ret != QMessageBox::Ok) {
|
||||
return;
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <core/texteditorconfig.h>
|
||||
#include <core/configmgr.h>
|
||||
#include <core/editorconfig.h>
|
||||
#include <core/vnotex.h>
|
||||
|
||||
#include "previewhelper.h"
|
||||
#include "../outlineprovider.h"
|
||||
@ -443,6 +444,9 @@ void MarkdownEditor::handleInsertFromMimeData(const QMimeData *p_source, bool *p
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
if (!clipboard->property(c_clipboardPropertyMark).toBool()) {
|
||||
// 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;
|
||||
} else {
|
||||
clipboard->setProperty(c_clipboardPropertyMark, false);
|
||||
|
@ -25,6 +25,7 @@ FullScreenToggleAction::FullScreenToggleAction(QWidget *p_window,
|
||||
if ((p_checked && !m_window->isFullScreen())
|
||||
|| (!p_checked && m_window->isFullScreen())) {
|
||||
setWindowFullScreen(m_window, p_checked);
|
||||
emit fullScreenToggled(p_checked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -13,13 +13,16 @@ namespace vnotex
|
||||
const QIcon &p_icon,
|
||||
QObject *p_parent = nullptr);
|
||||
|
||||
static void setWindowFullScreen(QWidget *p_window, bool p_set);
|
||||
signals:
|
||||
bool fullScreenToggled(bool p_fullScreen);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *p_object, QEvent *p_event) Q_DECL_OVERRIDE;
|
||||
|
||||
private:
|
||||
QWidget *m_window;
|
||||
static void setWindowFullScreen(QWidget *p_window, bool p_set);
|
||||
|
||||
QWidget *m_window = nullptr;
|
||||
};
|
||||
} // ns vnotex
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <QShortcut>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QWindowStateChangeEvent>
|
||||
#include <QTimer>
|
||||
|
||||
#include "toolbox.h"
|
||||
#include "notebookexplorer.h"
|
||||
@ -86,6 +87,7 @@ void MainWindow::setupUI()
|
||||
setupDocks();
|
||||
setupToolBar();
|
||||
setupStatusBar();
|
||||
setupTipsArea();
|
||||
setupSystemTray();
|
||||
|
||||
activateDock(m_docks[DockIndex::NavigationDock]);
|
||||
@ -98,6 +100,24 @@ void MainWindow::setupStatusBar()
|
||||
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()
|
||||
{
|
||||
m_viewArea = new ViewArea(this);
|
||||
@ -600,3 +620,41 @@ void MainWindow::exportNotes()
|
||||
this);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
class QDockWidget;
|
||||
class QSystemTrayIcon;
|
||||
class QTimer;
|
||||
class QLabel;
|
||||
|
||||
namespace vnotex
|
||||
{
|
||||
@ -74,6 +76,8 @@ namespace vnotex
|
||||
|
||||
void exportNotes();
|
||||
|
||||
void showTips(const QString &p_message, int p_timeoutMilliseconds);
|
||||
|
||||
private:
|
||||
// Index in m_docks.
|
||||
enum DockIndex
|
||||
@ -100,6 +104,8 @@ namespace vnotex
|
||||
|
||||
void setupStatusBar();
|
||||
|
||||
void setupTipsArea();
|
||||
|
||||
void saveStateAndGeometry();
|
||||
|
||||
void loadStateAndGeometry();
|
||||
@ -117,6 +123,8 @@ namespace vnotex
|
||||
|
||||
void setupSystemTray();
|
||||
|
||||
void setTipsAreaVisible(bool p_visible);
|
||||
|
||||
ToolBarHelper m_toolBarHelper;
|
||||
|
||||
StatusBarHelper m_statusBarHelper;
|
||||
@ -142,6 +150,10 @@ namespace vnotex
|
||||
Qt::WindowStates m_windowOldState = Qt::WindowMinimized;
|
||||
|
||||
QSystemTrayIcon *m_trayIcon = nullptr;
|
||||
|
||||
QLabel *m_tipsLabel = nullptr;
|
||||
|
||||
QTimer *m_tipsTimer = nullptr;
|
||||
};
|
||||
} // ns vnotex
|
||||
|
||||
|
@ -122,12 +122,13 @@ int MessageBoxHelper::questionOkCancel(MessageBoxHelper::Type p_type,
|
||||
const QString &p_detailedText,
|
||||
QWidget *p_parent)
|
||||
{
|
||||
bool dangerous = p_type == Type::Warning || p_type == Type::Critical;
|
||||
int ret = showMessageBox(p_type,
|
||||
p_text,
|
||||
p_informationText,
|
||||
p_detailedText,
|
||||
QMessageBox::Ok | QMessageBox::Cancel,
|
||||
QMessageBox::Ok,
|
||||
dangerous ? QMessageBox::Cancel : QMessageBox::Ok,
|
||||
p_parent);
|
||||
return ret;
|
||||
}
|
||||
|
@ -224,12 +224,23 @@ QToolBar *ToolBarHelper::setupSettingsToolBar(MainWindow *p_win, QToolBar *p_too
|
||||
});
|
||||
btn->setDefaultAction(expandAct);
|
||||
|
||||
{
|
||||
auto fullScreenAct = new FullScreenToggleAction(p_win,
|
||||
generateIcon("fullscreen.svg"),
|
||||
menu);
|
||||
WidgetUtils::addActionShortcut(fullScreenAct,
|
||||
coreConfig.getShortcut(CoreConfig::Shortcut::FullScreen));
|
||||
const auto shortcut = 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);
|
||||
}
|
||||
|
||||
auto stayOnTopAct = menu->addAction(generateIcon("stay_on_top.svg"), MainWindow::tr("Stay On Top"),
|
||||
p_win, &MainWindow::setStayOnTop);
|
||||
|
Loading…
x
Reference in New Issue
Block a user