Commit d8f9800d authored by Albert Astals Cid's avatar Albert Astals Cid

Make the drawing tools be actions instead of tool buttons

3 benefits:
 * We can set the shortcut in the edit shortcuts dialog as before
 * Shortcuts can be activated without showing the topbar as before
 * Drawing in the toppbar is exactly as the other actions
parent 81f80ac3
...@@ -258,7 +258,7 @@ set(okularpart_SRCS ...@@ -258,7 +258,7 @@ set(okularpart_SRCS
ui/annotationwidgets.cpp ui/annotationwidgets.cpp
ui/bookmarklist.cpp ui/bookmarklist.cpp
ui/debug_ui.cpp ui/debug_ui.cpp
ui/drawingtoolselectaction.cpp ui/drawingtoolactions.cpp
ui/fileprinterpreview.cpp ui/fileprinterpreview.cpp
ui/findbar.cpp ui/findbar.cpp
ui/formwidgets.cpp ui/formwidgets.cpp
......
#!/bin/sh #!/bin/sh
$EXTRACTRC *.rc */*.rc >> rc.cpp || exit 11 $EXTRACTRC *.rc */*.rc >> rc.cpp || exit 11
$EXTRACTRC $(find conf/ -name "*.ui") $(find core/ -name "*.ui") $(find ui/ -name "*.ui") $(ls . | grep -E '\.ui') >> rc.cpp || exit 12 $EXTRACTRC $(find conf/ -name "*.ui") $(find core/ -name "*.ui") $(find ui/ -name "*.ui") $(ls . | grep -E '\.ui') >> rc.cpp || exit 12
$EXTRACTATTR --attr=tool,name ui/data/drawingtools.xml >> rc.cpp || exit 13
$XGETTEXT $(find conf/ -name "*.cpp" -o -name "*.h") $(find core/ -name "*.cpp" -o -name "*.h") $(find ui/ -name "*.cpp" -o -name "*.h") $(find shell/ -name "*.cpp" -o -name "*.h") $(ls . | grep -E '\.cpp$') $(ls . | grep -E '\.h$') -o $podir/okular.pot $XGETTEXT $(find conf/ -name "*.cpp" -o -name "*.h") $(find core/ -name "*.cpp" -o -name "*.h") $(find ui/ -name "*.cpp" -o -name "*.h") $(find shell/ -name "*.cpp" -o -name "*.h") $(ls . | grep -E '\.cpp$') $(ls . | grep -E '\.h$') -o $podir/okular.pot
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "editdrawingtooldialog.h" #include "editdrawingtooldialog.h"
#include <KColorButton> #include <KColorButton>
#include <KLineEdit>
#include <KLocalizedString> #include <KLocalizedString>
#include <QDialogButtonBox> #include <QDialogButtonBox>
...@@ -39,32 +40,42 @@ EditDrawingToolDialog::EditDrawingToolDialog( const QDomElement &initialState, Q ...@@ -39,32 +40,42 @@ EditDrawingToolDialog::EditDrawingToolDialog( const QDomElement &initialState, Q
mainLayout->addWidget( widget ); mainLayout->addWidget( widget );
mainLayout->addWidget( buttonBox ); mainLayout->addWidget( buttonBox );
QLabel *tmplabel = new QLabel( i18n( "Color:" ), widget ); m_name = new KLineEdit( widget );
mainLayout->addWidget( m_name );
QLabel *tmplabel = new QLabel( i18n( "&Name:" ), widget );
mainLayout->addWidget( tmplabel );
tmplabel->setBuddy( m_name );
widgetLayout->addWidget( tmplabel, 0, 0, Qt::AlignRight ); widgetLayout->addWidget( tmplabel, 0, 0, Qt::AlignRight );
widgetLayout->addWidget( m_name, 0, 1 );
tmplabel = new QLabel( i18n( "Color:" ), widget );
widgetLayout->addWidget( tmplabel, 1, 0, Qt::AlignRight );
m_colorBn = new KColorButton( this ); m_colorBn = new KColorButton( this );
m_colorBn->setObjectName( QStringLiteral("colorbutton") ); m_colorBn->setObjectName( QStringLiteral("colorbutton") );
widgetLayout->addWidget( m_colorBn, 0, 1, Qt::AlignRight ); widgetLayout->addWidget( m_colorBn, 1, 1, Qt::AlignRight );
tmplabel = new QLabel( i18n( "&Pen Width:" ), widget ); tmplabel = new QLabel( i18n( "&Pen Width:" ), widget );
widgetLayout->addWidget( tmplabel, 1, 0, Qt::AlignRight ); widgetLayout->addWidget( tmplabel, 2, 0, Qt::AlignRight );
m_penWidth = new QSpinBox( widget ); m_penWidth = new QSpinBox( widget );
m_penWidth->setObjectName( QStringLiteral("penWidth") ); m_penWidth->setObjectName( QStringLiteral("penWidth") );
m_penWidth->setRange( 0, 50 ); m_penWidth->setRange( 0, 50 );
m_penWidth->setSuffix( i18nc( "Suffix for the pen width, eg '10 px'", " px" ) ); m_penWidth->setSuffix( i18nc( "Suffix for the pen width, eg '10 px'", " px" ) );
tmplabel->setBuddy( m_penWidth ); tmplabel->setBuddy( m_penWidth );
widgetLayout->addWidget( m_penWidth, 1, 1 ); widgetLayout->addWidget( m_penWidth, 2, 1 );
tmplabel = new QLabel( i18n( "&Opacity:" ), widget ); tmplabel = new QLabel( i18n( "&Opacity:" ), widget );
widgetLayout->addWidget( tmplabel, 2, 0, Qt::AlignRight ); widgetLayout->addWidget( tmplabel, 3, 0, Qt::AlignRight );
m_opacity = new QSpinBox( widget ); m_opacity = new QSpinBox( widget );
m_opacity->setObjectName( QStringLiteral("opacity") ); m_opacity->setObjectName( QStringLiteral("opacity") );
m_opacity->setRange( 0, 100 ); m_opacity->setRange( 0, 100 );
m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) ); m_opacity->setSuffix( i18nc( "Suffix for the opacity level, eg '80 %'", " %" ) );
tmplabel->setBuddy( m_opacity ); tmplabel->setBuddy( m_opacity );
widgetLayout->addWidget( m_opacity, 2, 1 ); widgetLayout->addWidget( m_opacity, 3, 1 );
if ( initialState.isNull() ) if ( initialState.isNull() )
{ {
...@@ -78,12 +89,19 @@ EditDrawingToolDialog::EditDrawingToolDialog( const QDomElement &initialState, Q ...@@ -78,12 +89,19 @@ EditDrawingToolDialog::EditDrawingToolDialog( const QDomElement &initialState, Q
setWindowTitle( i18n("Edit drawing tool") ); setWindowTitle( i18n("Edit drawing tool") );
loadTool( initialState ); loadTool( initialState );
} }
m_name->setFocus();
} }
EditDrawingToolDialog::~EditDrawingToolDialog() EditDrawingToolDialog::~EditDrawingToolDialog()
{ {
} }
QString EditDrawingToolDialog::name() const
{
return m_name->text();
}
QDomDocument EditDrawingToolDialog::toolXml() const QDomDocument EditDrawingToolDialog::toolXml() const
{ {
QDomDocument doc; QDomDocument doc;
...@@ -119,4 +137,9 @@ void EditDrawingToolDialog::loadTool( const QDomElement &toolElement ) ...@@ -119,4 +137,9 @@ void EditDrawingToolDialog::loadTool( const QDomElement &toolElement )
m_penWidth->setValue( annotationElement.attribute( QStringLiteral("width"), QStringLiteral("2") ).toInt() ); m_penWidth->setValue( annotationElement.attribute( QStringLiteral("width"), QStringLiteral("2") ).toInt() );
m_opacity->setValue( annotationElement.attribute( QStringLiteral("opacity"), QStringLiteral("1.0") ).toDouble() * 100 ); m_opacity->setValue( annotationElement.attribute( QStringLiteral("opacity"), QStringLiteral("1.0") ).toDouble() * 100 );
if ( toolElement.attribute( QStringLiteral("default"), QStringLiteral("false") ) == QLatin1String("true") )
m_name->setText( i18n( toolElement.attribute( QStringLiteral("name") ).toLatin1().constData() ) );
else
m_name->setText( toolElement.attribute( QStringLiteral("name") ) );
} }
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <QDomElement> #include <QDomElement>
class KColorButton; class KColorButton;
class KLineEdit;
class QSpinBox; class QSpinBox;
...@@ -26,9 +27,12 @@ public: ...@@ -26,9 +27,12 @@ public:
QDomDocument toolXml() const; QDomDocument toolXml() const;
QString name() const;
private: private:
void loadTool( const QDomElement &toolElement ); void loadTool( const QDomElement &toolElement );
KLineEdit *m_name;
KColorButton *m_colorBn; KColorButton *m_colorBn;
QSpinBox *m_penWidth; QSpinBox *m_penWidth;
QSpinBox *m_opacity; QSpinBox *m_opacity;
......
...@@ -11,9 +11,12 @@ ...@@ -11,9 +11,12 @@
#include "editdrawingtooldialog.h" #include "editdrawingtooldialog.h"
#include <KLocalizedString>
#include <QDebug> #include <QDebug>
#include <QDomElement> #include <QDomElement>
#include <QListWidgetItem> #include <QListWidgetItem>
#include <QMessageBox>
#include <QPainter> #include <QPainter>
// Used to store tools' XML description in m_list's items // Used to store tools' XML description in m_list's items
...@@ -84,7 +87,14 @@ void WidgetDrawingTools::setTools( const QStringList &items ) ...@@ -84,7 +87,14 @@ void WidgetDrawingTools::setTools( const QStringList &items )
const QDomElement toolElement = entryParser.documentElement(); const QDomElement toolElement = entryParser.documentElement();
if ( toolElement.tagName() == QLatin1String("tool") ) if ( toolElement.tagName() == QLatin1String("tool") )
{ {
QListWidgetItem * listEntry = new QListWidgetItem( m_list ); const QString name = toolElement.attribute( QStringLiteral("name") );
QString itemText;
if ( toolElement.attribute( QStringLiteral("default"), QStringLiteral("false") ) == QLatin1String("true") )
itemText = i18n( name.toLatin1().constData() );
else
itemText = name;
QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list );
listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) ); listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) );
listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) ); listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) );
} }
...@@ -93,6 +103,28 @@ void WidgetDrawingTools::setTools( const QStringList &items ) ...@@ -93,6 +103,28 @@ void WidgetDrawingTools::setTools( const QStringList &items )
updateButtons(); updateButtons();
} }
QString WidgetDrawingTools::defaultName() const
{
int nameIndex = 1;
bool freeNameFound = false;
QString candidateName;
while (!freeNameFound)
{
candidateName = i18n("Default Drawing Tool #%1", nameIndex);
int i = 0;
for ( ; i < m_list->count(); ++i )
{
QListWidgetItem * listEntry = m_list->item( i );
if (candidateName == listEntry->text()) {
break;
}
}
freeNameFound = i == m_list->count();
++nameIndex;
}
return candidateName;
}
void WidgetDrawingTools::slotAdd() void WidgetDrawingTools::slotAdd()
{ {
EditDrawingToolDialog dlg( QDomElement(), this ); EditDrawingToolDialog dlg( QDomElement(), this );
...@@ -101,11 +133,30 @@ void WidgetDrawingTools::slotAdd() ...@@ -101,11 +133,30 @@ void WidgetDrawingTools::slotAdd()
return; return;
const QDomDocument rootDoc = dlg.toolXml(); const QDomDocument rootDoc = dlg.toolXml();
const QDomElement toolElement = rootDoc.documentElement(); QDomElement toolElement = rootDoc.documentElement();
QString itemText = dlg.name().trimmed();
if (itemText.isEmpty()) {
itemText = defaultName();
}
for ( int i = 0; i < m_list->count(); ++i )
{
QListWidgetItem * listEntry = m_list->item( i );
if (itemText == listEntry->text()) {
QMessageBox::information( this, i18n("Duplicated Name"), i18n("There's already a tool with that name. Using a default one") );
itemText = defaultName();
break;
}
}
// Store name attribute only if the user specified a customized name
toolElement.setAttribute( QStringLiteral("name"), itemText );
// Create list entry and attach XML string as data // Create list entry and attach XML string as data
const QString toolXml = rootDoc.toString( -1 ); const QString toolXml = rootDoc.toString( -1 );
QListWidgetItem * listEntry = new QListWidgetItem( m_list ); QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list );
listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) ); listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) );
listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) ); listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) );
...@@ -122,7 +173,7 @@ void WidgetDrawingTools::slotEdit() ...@@ -122,7 +173,7 @@ void WidgetDrawingTools::slotEdit()
QDomDocument doc; QDomDocument doc;
doc.setContent( listEntry->data( ToolXmlRole ).value<QString>() ); doc.setContent( listEntry->data( ToolXmlRole ).value<QString>() );
const QDomElement toolElement = doc.documentElement(); QDomElement toolElement = doc.documentElement();
EditDrawingToolDialog dlg( toolElement, this ); EditDrawingToolDialog dlg( toolElement, this );
...@@ -130,9 +181,26 @@ void WidgetDrawingTools::slotEdit() ...@@ -130,9 +181,26 @@ void WidgetDrawingTools::slotEdit()
return; return;
doc = dlg.toolXml(); doc = dlg.toolXml();
toolElement = doc.documentElement();
QString itemText = dlg.name();
for ( int i = 0; i < m_list->count(); ++i )
{
QListWidgetItem * auxListEntry = m_list->item( i );
if (itemText == auxListEntry->text() && auxListEntry != listEntry) {
QMessageBox::information( this, i18n("Duplicated Name"), i18n("There's already a tool with that name. Using a default one") );
itemText = defaultName();
break;
}
}
// Store name attribute only if the user specified a customized name
toolElement.setAttribute( QStringLiteral("name"), itemText );
// Edit list entry and attach XML string as data // Edit list entry and attach XML string as data
const QString toolXml = doc.toString( -1 ); const QString toolXml = doc.toString( -1 );
listEntry->setText( itemText );
listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) ); listEntry->setData( ToolXmlRole, qVariantFromValue( toolXml ) );
listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) ); listEntry->setData( Qt::DecorationRole, colorDecorationFromToolDescription( toolXml ) );
......
...@@ -22,6 +22,8 @@ public: ...@@ -22,6 +22,8 @@ public:
QStringList tools() const Q_DECL_OVERRIDE; QStringList tools() const Q_DECL_OVERRIDE;
void setTools( const QStringList& items ) Q_DECL_OVERRIDE; void setTools( const QStringList& items ) Q_DECL_OVERRIDE;
QString defaultName() const;
protected slots: protected slots:
void slotAdd() Q_DECL_OVERRIDE; void slotAdd() Q_DECL_OVERRIDE;
......
...@@ -73,6 +73,7 @@ ...@@ -73,6 +73,7 @@
#include "aboutdata.h" #include "aboutdata.h"
#include "extensions.h" #include "extensions.h"
#include "ui/debug_ui.h" #include "ui/debug_ui.h"
#include "ui/drawingtoolactions.h"
#include "ui/pageview.h" #include "ui/pageview.h"
#include "ui/toc.h" #include "ui/toc.h"
#include "ui/searchwidget.h" #include "ui/searchwidget.h"
...@@ -691,6 +692,7 @@ void Part::setupViewerActions() ...@@ -691,6 +692,7 @@ void Part::setupViewerActions()
m_exportAsMenu = 0; m_exportAsMenu = 0;
m_exportAsText = 0; m_exportAsText = 0;
m_exportAsDocArchive = 0; m_exportAsDocArchive = 0;
m_presentationDrawingActions = 0;
m_aboutBackend = ac->addAction("help_about_backend"); m_aboutBackend = ac->addAction("help_about_backend");
m_aboutBackend->setText(i18n("About Backend")); m_aboutBackend->setText(i18n("About Backend"));
...@@ -816,6 +818,8 @@ void Part::setupActions() ...@@ -816,6 +818,8 @@ void Part::setupActions()
blackscreenAction->setIcon( QIcon::fromTheme( "view-presentation" ) ); blackscreenAction->setIcon( QIcon::fromTheme( "view-presentation" ) );
blackscreenAction->setEnabled( false ); blackscreenAction->setEnabled( false );
m_presentationDrawingActions = new DrawingToolActions( ac );
QAction *eraseDrawingAction = new QAction( i18n( "Erase Drawings" ), ac ); QAction *eraseDrawingAction = new QAction( i18n( "Erase Drawings" ), ac );
ac->addAction( "presentation_erase_drawings", eraseDrawingAction ); ac->addAction( "presentation_erase_drawings", eraseDrawingAction );
eraseDrawingAction->setIcon( QIcon::fromTheme( "draw-eraser" ) ); eraseDrawingAction->setIcon( QIcon::fromTheme( "draw-eraser" ) );
...@@ -2358,6 +2362,13 @@ void Part::slotNewConfig() ...@@ -2358,6 +2362,13 @@ void Part::slotNewConfig()
m_reviewsWidget->reparseConfig(); m_reviewsWidget->reparseConfig();
setWindowTitleFromDocument (); setWindowTitleFromDocument ();
if ( m_presentationDrawingActions ) {
m_presentationDrawingActions->reparseConfig();
if (factory()) {
factory()->refreshActionProperties();
}
}
} }
...@@ -2511,7 +2522,7 @@ void Part::slotShowPresentation() ...@@ -2511,7 +2522,7 @@ void Part::slotShowPresentation()
{ {
if ( !m_presentationWidget ) if ( !m_presentationWidget )
{ {
m_presentationWidget = new PresentationWidget( widget(), m_document, actionCollection() ); m_presentationWidget = new PresentationWidget( widget(), m_document, m_presentationDrawingActions, actionCollection() );
} }
} }
...@@ -2528,7 +2539,7 @@ void Part::slotTogglePresentation() ...@@ -2528,7 +2539,7 @@ void Part::slotTogglePresentation()
if ( m_document->isOpened() ) if ( m_document->isOpened() )
{ {
if ( !m_presentationWidget ) if ( !m_presentationWidget )
m_presentationWidget = new PresentationWidget( widget(), m_document, actionCollection() ); m_presentationWidget = new PresentationWidget( widget(), m_document, m_presentationDrawingActions, actionCollection() );
else delete (PresentationWidget*) m_presentationWidget; else delete (PresentationWidget*) m_presentationWidget;
} }
} }
......
...@@ -64,6 +64,7 @@ class MiniBarLogic; ...@@ -64,6 +64,7 @@ class MiniBarLogic;
class FileKeeper; class FileKeeper;
class Reviews; class Reviews;
class BookmarkList; class BookmarkList;
class DrawingToolActions;
namespace Okular namespace Okular
{ {
...@@ -328,6 +329,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu ...@@ -328,6 +329,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
QAction *m_reload; QAction *m_reload;
QMenu *m_exportAsMenu; QMenu *m_exportAsMenu;
QAction *m_closeFindBar; QAction *m_closeFindBar;
DrawingToolActions *m_presentationDrawingActions;
bool m_actionsSearched; bool m_actionsSearched;
BrowserExtension *m_bExtension; BrowserExtension *m_bExtension;
......
...@@ -8,32 +8,32 @@ Engine/DrawingTools Types [specific attributes]: ...@@ -8,32 +8,32 @@ Engine/DrawingTools Types [specific attributes]:
Ink [width] Ink [width]
--> -->
<drawingTools> <drawingTools>
<tool id="1"> <tool id="1" name="Red" default="true">
<engine color="#ff0000"> <engine color="#ff0000">
<annotation type="Ink" color="#ff0000" width="2" /> <annotation type="Ink" color="#ff0000" width="2" />
</engine> </engine>
</tool> </tool>
<tool id="2"> <tool id="2" name="Green" default="true">
<engine color="#00ff00"> <engine color="#00ff00">
<annotation type="Ink" color="#00ff00" width="2" /> <annotation type="Ink" color="#00ff00" width="2" />
</engine> </engine>
</tool> </tool>
<tool id="3"> <tool id="3" name="Blue" default="true">
<engine color="#0000ff"> <engine color="#0000ff">
<annotation type="Ink" color="#0000ff" width="2" /> <annotation type="Ink" color="#0000ff" width="2" />
</engine> </engine>
</tool> </tool>
<tool id="4"> <tool id="4" name="Yellow" default="true">
<engine color="#ffff00"> <engine color="#ffff00">
<annotation type="Ink" color="#ffff00" width="2" /> <annotation type="Ink" color="#ffff00" width="2" />
</engine> </engine>
</tool> </tool>
<tool id="5"> <tool id="5" name="Black" default="true">
<engine color="#000000"> <engine color="#000000">
<annotation type="Ink" color="#000000" width="2" /> <annotation type="Ink" color="#000000" width="2" />
</engine> </engine>
</tool> </tool>
<tool id="6"> <tool id="6" name="White" default="true">
<engine color="#ffffff"> <engine color="#ffffff">
<annotation type="Ink" color="#ffffff" width="2" /> <annotation type="Ink" color="#ffffff" width="2" />
</engine> </engine>
......
/*************************************************************************** /***************************************************************************
* Copyright (C) 2015 by Laurent Montel <montel@kde.org> * * Copyright (C) 2015 by Laurent Montel <montel@kde.org> *
* Copyright (C) 2015 by Albert Astals Cid <aacid@kde.org> *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
...@@ -7,22 +8,22 @@ ...@@ -7,22 +8,22 @@
* (at your option) any later version. * * (at your option) any later version. *
***************************************************************************/ ***************************************************************************/
#include "drawingtoolselectaction.h" #include "drawingtoolactions.h"
#include "debug_ui.h" #include "debug_ui.h"
#include "settings.h" #include "settings.h"
#include <KActionCollection>
#include <KLocalizedString> #include <KLocalizedString>
#include <QHBoxLayout> #include <QAction>
#include <QPainter> #include <QPainter>
#include <QToolButton>
class ColorButton : public QToolButton class ColorAction : public QAction
{ {
public: public:
explicit ColorButton( QWidget *parent = Q_NULLPTR ) explicit ColorAction( KActionCollection *parent )
: QToolButton( parent ) : QAction( parent )
{ {
} }
...@@ -52,44 +53,50 @@ public: ...@@ -52,44 +53,50 @@ public:
} }
}; };
DrawingToolSelectAction::DrawingToolSelectAction( QObject *parent ) DrawingToolActions::DrawingToolActions( KActionCollection *parent )
: QWidgetAction( parent ) : QObject( parent )
{ {
QWidget *mainWidget = new QWidget;
m_layout = new QHBoxLayout( mainWidget );
m_layout->setContentsMargins( 0, 0, 0, 0 );
loadTools(); loadTools();
}
setDefaultWidget( mainWidget );
DrawingToolActions::~DrawingToolActions()
{
} }
QList<QAction*> DrawingToolActions::actions() const
{
return m_actions;
}
DrawingToolSelectAction::~DrawingToolSelectAction() void DrawingToolActions::reparseConfig()
{ {
qDeleteAll(m_actions);
m_actions.clear();
loadTools();
} }
void DrawingToolSelectAction::toolButtonClicked() void DrawingToolActions::actionTriggered()
{ {
QAbstractButton *button = qobject_cast<QAbstractButton*>( sender() ); QAction *action = qobject_cast<QAction*>( sender() );
if ( button ) { if ( action ) {
if ( button->isChecked() ) { if ( action->isChecked() ) {
Q_FOREACH ( QAbstractButton *btn, m_buttons ) Q_FOREACH ( QAction *btn, m_actions )
{ {
if ( button != btn ) { if ( action != btn ) {
btn->setChecked( false ); btn->setChecked( false );
} }
} }
emit changeEngine( button->property( "__document" ).value<QDomElement>() ); emit changeEngine( action->property( "__document" ).value<QDomElement>() );
} else { } else {
emit changeEngine( QDomElement() ); emit changeEngine( QDomElement() );
} }
} }
} }
void DrawingToolSelectAction::loadTools() void DrawingToolActions::loadTools()
{ {
const QStringList drawingTools = Okular::Settings::drawingTools(); const QStringList drawingTools = Okular::Settings::drawingTools();
...@@ -104,8 +111,6 @@ void DrawingToolSelectAction::loadTools() ...@@ -104,8 +111,6 @@ void DrawingToolSelectAction::loadTools()
qCWarning(OkularUiDebug) << "Skipping malformed quick selection XML in QuickSelectionTools setting"; qCWarning(OkularUiDebug) << "Skipping malformed quick selection XML in QuickSelectionTools setting";
} }
int shortcutCounter = 0;
// Create the AnnotationToolItems from the XML dom tree // Create the AnnotationToolItems from the XML dom tree
QDomNode drawingDescription = drawingDefinition.firstChild(); QDomNode drawingDescription = drawingDefinition.firstChild();
while ( drawingDescription.isElement() ) while ( drawingDescription.isElement() )
...@@ -113,10 +118,21 @@ void DrawingToolSelectAction::loadTools() ...@@ -113,10 +118,21 @@ void DrawingToolSelectAction::loadTools()
const QDomElement toolElement = drawingDescription.toElement(); const QDomElement toolElement = drawingDescription.toElement();
if ( toolElement.tagName() == "tool" ) if ( toolElement.tagName() == "tool" )
{ {
QString tooltip;
QString width; QString width;
QString colorStr; QString colorStr;
QString opacity;