diff --git a/conf/widgetannottools.cpp b/conf/widgetannottools.cpp index bab9c6a2e..28cccd638 100644 --- a/conf/widgetannottools.cpp +++ b/conf/widgetannottools.cpp @@ -30,6 +30,7 @@ #include "core/annotations.h" #include "ui/annotationwidgets.h" +#include "ui/pageviewannotator.h" // Used to store tools' XML description in m_list's items static const int ToolXmlRole = Qt::UserRole; @@ -134,6 +135,7 @@ void WidgetAnnotTools::setTools(const QStringList& items) const QString itemText = toolElement.attribute( "name" ); QListWidgetItem * listEntry = new QListWidgetItem( itemText, m_list ); listEntry->setData( ToolXmlRole, qVariantFromValue(toolXml) ); + listEntry->setIcon( PageViewAnnotator::makeToolPixmap( toolElement ) ); } } @@ -162,9 +164,14 @@ void WidgetAnnotTools::slotAdd( bool ) if ( t.exec() != QDialog::Accepted ) return; + QDomDocument entryParser; + entryParser.setContent( t.toolXml() ); + QDomElement toolElement = entryParser.documentElement(); + // Create list entry and attach XML string as data QListWidgetItem * listEntry = new QListWidgetItem( t.name(), m_list ); - listEntry->setData( ToolXmlRole, qVariantFromValue( t.toolXml() ) ); + listEntry->setData( ToolXmlRole, qVariantFromValue( entryParser.toString(-1) ) ); + listEntry->setIcon( PageViewAnnotator::makeToolPixmap( toolElement ) ); // Select and scroll m_list->setCurrentItem( listEntry ); diff --git a/ui/pageviewannotator.h b/ui/pageviewannotator.h index 5dc1ede64..568f90ccc 100644 --- a/ui/pageviewannotator.h +++ b/ui/pageviewannotator.h @@ -77,13 +77,14 @@ class PageViewAnnotator : public QObject void reparseConfig(); + static QPixmap makeToolPixmap( const QDomElement &toolElement ); + private slots: void slotToolSelected( int toolID ); void slotSaveToolbarOrientation( int side ); void slotToolDoubleClicked( int toolID ); private: - static QPixmap makeToolPixmap( const QDomElement &toolElement ); void detachAnnotation(); // global class pointers