Text information about tool processing

This commit is contained in:
Jakub Melka 2020-02-29 14:40:29 +01:00
parent 475103f5d5
commit 7db167eea3
3 changed files with 21 additions and 0 deletions

View File

@ -714,6 +714,7 @@ PDFToolManager::PDFToolManager(PDFDrawWidgetProxy* proxy, Actions actions, QObje
for (PDFWidgetTool* tool : m_predefinedTools)
{
m_tools.insert(tool);
connect(tool, &PDFWidgetTool::messageDisplayRequest, this, &PDFToolManager::messageDisplayRequest);
if (QAction* action = tool->getAction())
{
@ -1172,6 +1173,7 @@ void PDFScreenshotTool::onRectanglePicked(PDFInteger pageIndex, QRectF pageRecta
}
QApplication::clipboard()->setImage(image, QClipboard::Clipboard);
emit messageDisplayRequest(tr("Page contents of size %1 x %2 pixels were copied to the clipboard.").arg(image.width()).arg(image.height()), 5000);
}
}
}
@ -1202,6 +1204,7 @@ void PDFExtractImageTool::onImagePicked(const QImage& image)
if (!image.isNull())
{
QApplication::clipboard()->setImage(image, QClipboard::Clipboard);
emit messageDisplayRequest(tr("Image of size %1 x %2 pixels was copied to the clipboard.").arg(image.width()).arg(image.height()), 5000);
}
}

View File

@ -91,8 +91,17 @@ public:
const std::optional<QCursor>& getCursor() const;
signals:
/// Informs about tool activity changed (if tool is enabled or disabled)
/// \param active Is tool active?
void toolActivityChanged(bool active);
/// This is signal is set, when we want to display information message
/// to the user, with timeout in miliseconds, after which message
/// dissappears.
/// \param text Text, which should be displayed to the user
/// \param timeout Timeout in miliseconds
void messageDisplayRequest(const QString& text, int timeout);
protected:
virtual void setActiveImpl(bool active);
virtual void updateActions();
@ -458,6 +467,14 @@ public:
/// in this case, optional will be set to nullopt.
const std::optional<QCursor>& getCursor() const;
signals:
/// This is signal is set, when we want to display information message
/// to the user, with timeout in miliseconds, after which message
/// dissappears.
/// \param text Text, which should be displayed to the user
/// \param timeout Timeout in miliseconds
void messageDisplayRequest(const QString& text, int timeout);
private:
void onToolActionTriggered(bool checked);

View File

@ -260,6 +260,7 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) :
m_toolManager = new pdf::PDFToolManager(m_pdfWidget->getDrawWidgetProxy(), actions, this, this);
m_pdfWidget->setToolManager(m_toolManager);
updateMagnifierToolSettings();
connect(m_toolManager, &pdf::PDFToolManager::messageDisplayRequest, statusBar(), &QStatusBar::showMessage);
connect(m_pdfWidget->getDrawWidgetProxy(), &pdf::PDFDrawWidgetProxy::drawSpaceChanged, this, &PDFViewerMainWindow::onDrawSpaceChanged);
connect(m_pdfWidget->getDrawWidgetProxy(), &pdf::PDFDrawWidgetProxy::pageLayoutChanged, this, &PDFViewerMainWindow::onPageLayoutChanged);