mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add print action item
Print support of QWebEngineView is incomplete in Qt5.7. Need to figure out another way to print documents. Just hide the action Item.
This commit is contained in:
parent
f43f9c4afc
commit
871c53743f
14
src/resources/icons/print.svg
Normal file
14
src/resources/icons/print.svg
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="512px" height="512px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||
<g>
|
||||
<path d="M423.8,128H384V64H128v64H88.2C60.3,128,32,144.9,32,182.6v123.8c0,38,28.3,61.6,56.2,61.6c0,0,30.4,0,39.8,0v112h5h11h224
|
||||
h8h8V368c10.3,0,39.8,0,39.8,0c27.9,0,56.2-22.6,56.2-53.6V182.6C480,146.9,451.8,128,423.8,128z M368,464H144V288h224V464z
|
||||
M368,128H144V80h224V128z M416,192h-17v-16h17V192z"/>
|
||||
<rect x="160" y="320" width="192" height="16"/>
|
||||
<rect x="160" y="368" width="192" height="16"/>
|
||||
<rect x="160" y="416" width="192" height="16"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 961 B |
@ -4,7 +4,7 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui webenginewidgets webchannel network svg
|
||||
QT += core gui webenginewidgets webchannel network svg printsupport
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
|
@ -727,3 +727,9 @@ void VEditTab::zoomWebPage(bool p_zoomIn, qreal p_step)
|
||||
}
|
||||
webPreviewer->setZoomFactor(newFactor);
|
||||
}
|
||||
|
||||
VWebView *VEditTab::getWebViewer() const
|
||||
{
|
||||
return webPreviewer;
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
QString getSelectedText() const;
|
||||
void clearSearchedWordHighlight();
|
||||
|
||||
VWebView *getWebViewer() const;
|
||||
|
||||
public slots:
|
||||
// Enter edit mode
|
||||
void editFile();
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include <QtWidgets>
|
||||
#include <QList>
|
||||
#include <QPrinter>
|
||||
#include <QPrintDialog>
|
||||
#include <QPainter>
|
||||
#include "vmainwindow.h"
|
||||
#include "vdirectorytree.h"
|
||||
#include "vnote.h"
|
||||
@ -13,6 +16,8 @@
|
||||
#include "dialog/vfindreplacedialog.h"
|
||||
#include "dialog/vsettingsdialog.h"
|
||||
#include "vcaptain.h"
|
||||
#include "vedittab.h"
|
||||
#include "vwebview.h"
|
||||
|
||||
extern VConfigManager vconfig;
|
||||
|
||||
@ -438,30 +443,42 @@ void VMainWindow::initFileMenu()
|
||||
|
||||
// Import notes from files.
|
||||
m_importNoteAct = new QAction(QIcon(":/resources/icons/import_note.svg"),
|
||||
tr("&Import Notes From Files"), this);
|
||||
tr("&Import Notes From Files"), this);
|
||||
m_importNoteAct->setToolTip(tr("Import notes from files into current directory"));
|
||||
connect(m_importNoteAct, &QAction::triggered,
|
||||
this, &VMainWindow::importNoteFromFile);
|
||||
m_importNoteAct->setEnabled(false);
|
||||
|
||||
fileMenu->addAction(m_importNoteAct);
|
||||
|
||||
fileMenu->addSeparator();
|
||||
|
||||
// Print.
|
||||
m_printAct = new QAction(QIcon(":/resources/icons/print.svg"),
|
||||
tr("&Print"), this);
|
||||
m_printAct->setToolTip(tr("Print current note"));
|
||||
connect(m_printAct, &QAction::triggered,
|
||||
this, &VMainWindow::printNote);
|
||||
m_printAct->setEnabled(false);
|
||||
|
||||
// Settings.
|
||||
QAction *settingsAct = new QAction(QIcon(":/resources/icons/settings.svg"),
|
||||
tr("Settings"), this);
|
||||
tr("&Settings"), this);
|
||||
settingsAct->setToolTip(tr("View and change settings for VNote"));
|
||||
connect(settingsAct, &QAction::triggered,
|
||||
this, &VMainWindow::viewSettings);
|
||||
|
||||
fileMenu->addAction(settingsAct);
|
||||
|
||||
fileMenu->addSeparator();
|
||||
|
||||
// Exit.
|
||||
QAction *exitAct = new QAction(tr("Exit"), this);
|
||||
QAction *exitAct = new QAction(tr("&Exit"), this);
|
||||
exitAct->setToolTip(tr("Exit VNote"));
|
||||
exitAct->setShortcut(QKeySequence("Ctrl+Q"));
|
||||
connect(exitAct, &QAction::triggered,
|
||||
this, &VMainWindow::close);
|
||||
|
||||
fileMenu->addAction(m_importNoteAct);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(settingsAct);
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(exitAct);
|
||||
}
|
||||
|
||||
@ -998,6 +1015,8 @@ void VMainWindow::setEditorStyle(QAction *p_action)
|
||||
void VMainWindow::updateActionStateFromTabStatusChange(const VFile *p_file,
|
||||
bool p_editMode)
|
||||
{
|
||||
m_printAct->setEnabled(p_file && p_file->getDocType() == DocType::Markdown);
|
||||
|
||||
editNoteAct->setVisible(p_file && p_file->isModifiable() && !p_editMode);
|
||||
discardExitAct->setVisible(p_file && p_editMode);
|
||||
saveExitAct->setVisible(p_file && p_editMode);
|
||||
@ -1352,3 +1371,25 @@ void VMainWindow::shortcutHelp()
|
||||
VFile *file = vnote->getOrphanFile(docName);
|
||||
editArea->openFile(file, OpenFileMode::Read);
|
||||
}
|
||||
|
||||
void VMainWindow::printNote()
|
||||
{
|
||||
QPrinter printer;
|
||||
QPrintDialog dialog(&printer, this);
|
||||
dialog.setWindowTitle(tr("Print Note"));
|
||||
|
||||
V_ASSERT(m_curTab);
|
||||
|
||||
VWebView *webView = m_curTab->getWebViewer();
|
||||
|
||||
V_ASSERT(webView);
|
||||
|
||||
if (webView->hasSelection()) {
|
||||
dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection);
|
||||
}
|
||||
|
||||
if (dialog.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ private slots:
|
||||
void enableImagePreviewConstraint(bool p_checked);
|
||||
void enableImageConstraint(bool p_checked);
|
||||
void enableImageCaption(bool p_checked);
|
||||
void printNote();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||
@ -153,6 +154,7 @@ private:
|
||||
QAction *discardExitAct;
|
||||
QAction *expandViewAct;
|
||||
QAction *m_importNoteAct;
|
||||
QAction *m_printAct;
|
||||
|
||||
QAction *m_insertImageAct;
|
||||
QAction *m_findReplaceAct;
|
||||
|
@ -104,5 +104,6 @@
|
||||
<file>utils/showdown/showdown.min.js</file>
|
||||
<file>resources/showdown.js</file>
|
||||
<file>utils/showdown/showdown-headinganchor.js</file>
|
||||
<file>resources/icons/print.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Loading…
x
Reference in New Issue
Block a user