Show tool icons in the configuration widget

This commit is contained in:
Fabio D'Urso 2012-07-27 01:02:00 +02:00
parent 18981a6707
commit 36aca4403a
2 changed files with 10 additions and 2 deletions

View File

@ -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 );

View File

@ -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