mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Bugfix: Tool not deactivated when text highlight tool was activated
This commit is contained in:
@@ -744,6 +744,8 @@ void PDFToolManager::addTool(PDFWidgetTool* tool)
|
|||||||
m_actionsToTools[action] = tool;
|
m_actionsToTools[action] = tool;
|
||||||
connect(action, &QAction::triggered, this, &PDFToolManager::onToolActionTriggered);
|
connect(action, &QAction::triggered, this, &PDFToolManager::onToolActionTriggered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(tool, &PDFWidgetTool::toolActivityChanged, this, &PDFToolManager::onToolActivityChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PDFToolManager::setDocument(const PDFModifiedDocument& document)
|
void PDFToolManager::setDocument(const PDFModifiedDocument& document)
|
||||||
@@ -885,6 +887,22 @@ const std::optional<QCursor>& PDFToolManager::getCursor() const
|
|||||||
return dummy;
|
return dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PDFToolManager::onToolActivityChanged(bool active)
|
||||||
|
{
|
||||||
|
if (active)
|
||||||
|
{
|
||||||
|
// When tool is activated outside, we must deactivate old active tool
|
||||||
|
PDFWidgetTool* tool = qobject_cast<PDFWidgetTool*>(sender());
|
||||||
|
for (PDFWidgetTool* currentTool : m_tools)
|
||||||
|
{
|
||||||
|
if (currentTool->isActive() && currentTool != tool)
|
||||||
|
{
|
||||||
|
currentTool->setActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PDFToolManager::onToolActionTriggered(bool checked)
|
void PDFToolManager::onToolActionTriggered(bool checked)
|
||||||
{
|
{
|
||||||
PDFWidgetTool* tool = m_actionsToTools.at(qobject_cast<QAction*>(sender()));
|
PDFWidgetTool* tool = m_actionsToTools.at(qobject_cast<QAction*>(sender()));
|
||||||
|
@@ -525,6 +525,7 @@ signals:
|
|||||||
void documentModified(PDFModifiedDocument document);
|
void documentModified(PDFModifiedDocument document);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void onToolActivityChanged(bool active);
|
||||||
void onToolActionTriggered(bool checked);
|
void onToolActionTriggered(bool checked);
|
||||||
|
|
||||||
std::set<PDFWidgetTool*> m_tools;
|
std::set<PDFWidgetTool*> m_tools;
|
||||||
|
@@ -265,6 +265,10 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) :
|
|||||||
|
|
||||||
// Tools
|
// Tools
|
||||||
ui->mainToolBar->addAction(ui->actionSelectText);
|
ui->mainToolBar->addAction(ui->actionSelectText);
|
||||||
|
ui->mainToolBar->addAction(ui->actionCreateTextHighlight);
|
||||||
|
ui->mainToolBar->addAction(ui->actionCreateTextUnderline);
|
||||||
|
ui->mainToolBar->addAction(ui->actionCreateTextStrikeout);
|
||||||
|
ui->mainToolBar->addAction(ui->actionCreateTextSquiggly);
|
||||||
ui->mainToolBar->addAction(ui->actionMagnifier);
|
ui->mainToolBar->addAction(ui->actionMagnifier);
|
||||||
ui->mainToolBar->addAction(ui->actionScreenshot);
|
ui->mainToolBar->addAction(ui->actionScreenshot);
|
||||||
ui->mainToolBar->addAction(ui->actionExtractImage);
|
ui->mainToolBar->addAction(ui->actionExtractImage);
|
||||||
|
Reference in New Issue
Block a user