mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2024-12-27 08:42:48 +01:00
Bugfix: Tool not deactivated when text highlight tool was activated
This commit is contained in:
parent
9b9734ffd1
commit
5f13474710
@ -744,6 +744,8 @@ void PDFToolManager::addTool(PDFWidgetTool* tool)
|
||||
m_actionsToTools[action] = tool;
|
||||
connect(action, &QAction::triggered, this, &PDFToolManager::onToolActionTriggered);
|
||||
}
|
||||
|
||||
connect(tool, &PDFWidgetTool::toolActivityChanged, this, &PDFToolManager::onToolActivityChanged);
|
||||
}
|
||||
|
||||
void PDFToolManager::setDocument(const PDFModifiedDocument& document)
|
||||
@ -885,6 +887,22 @@ const std::optional<QCursor>& PDFToolManager::getCursor() const
|
||||
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)
|
||||
{
|
||||
PDFWidgetTool* tool = m_actionsToTools.at(qobject_cast<QAction*>(sender()));
|
||||
|
@ -525,6 +525,7 @@ signals:
|
||||
void documentModified(PDFModifiedDocument document);
|
||||
|
||||
private:
|
||||
void onToolActivityChanged(bool active);
|
||||
void onToolActionTriggered(bool checked);
|
||||
|
||||
std::set<PDFWidgetTool*> m_tools;
|
||||
|
@ -265,6 +265,10 @@ PDFViewerMainWindow::PDFViewerMainWindow(QWidget* parent) :
|
||||
|
||||
// Tools
|
||||
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->actionScreenshot);
|
||||
ui->mainToolBar->addAction(ui->actionExtractImage);
|
||||
|
Loading…
Reference in New Issue
Block a user