[Okular-devel] Bug 330518 - Add configure icon to the annotation toolbar
Abhijeet Nikam
connect08nikam at gmail.com
Mon Mar 31 18:51:10 UTC 2014
Hi,
I have tried working and created a patch for the bug. I tried
uploading the patch many times but it said the selected file is not a
diff.
I used diff -rupN original/ new/ > patch.diff with original and new
files in respective directory.
I tried many times but could not succeed. Maybe I have missed
something. Should I create the patches for individual files (total 4
of them changed) and submit them on the review board? I have attached
my diff with this mail. Can some one please guide me?
Regards,
Abhijeet
-------------- next part --------------
diff -rupN original/pageviewannotator.cpp new/pageviewannotator.cpp
--- original/pageviewannotator.cpp 2014-03-30 12:05:21.000000000 +0530
+++ new/pageviewannotator.cpp 2014-03-31 22:56:41.000000000 +0530
@@ -659,6 +659,15 @@ void PageViewAnnotator::reparseConfig()
{
m_items.clear();
+
+ AnnotationToolItem configure;
+ configure.pixmap= makeToolPixmap();
+ configure.text= "Configure Annotations";
+ configure.isText=true;
+ configure.shortcut = "";
+ configure.id=0;
+ m_items.push_back(configure);
+
// Read tool list from configuration. It's a list of XML <tool></tool> elements
const QStringList userTools = Okular::Settings::annotationTools();
@@ -711,6 +720,8 @@ PageViewAnnotator::~PageViewAnnotator()
void PageViewAnnotator::setEnabled( bool on )
{
+
+
if ( !on )
{
// remove toolBar
@@ -729,8 +740,11 @@ void PageViewAnnotator::setEnabled( bool
// create toolBar
if ( !m_toolBar )
{
+
+
m_toolBar = new PageViewToolBar( m_pageView, m_pageView->viewport() );
m_toolBar->setSide( (PageViewToolBar::Side)Okular::Settings::editToolBarPlacement() );
+ //m_toolBar->setItems(configure);
m_toolBar->setItems( m_items );
m_toolBar->setToolsEnabled( m_toolsEnabled );
m_toolBar->setTextToolsEnabled( m_textToolsEnabled );
@@ -950,6 +964,8 @@ void PageViewAnnotator::routePaint( QPai
painter->restore();
}
+
+
void PageViewAnnotator::slotToolSelected( int toolID )
{
// terminate any previous operation
@@ -1104,6 +1120,15 @@ QString PageViewAnnotator::defaultToolNa
return QString();
}
+QPixmap PageViewAnnotator::makeToolPixmap()
+{
+ QPixmap pixmap( 32, 32 );
+ // Load base pixmap. We'll draw on top of it
+ pixmap.load( KStandardDirs::locate( "data", "okular/pics/help.png" ) );
+
+ return pixmap;
+}
+
QPixmap PageViewAnnotator::makeToolPixmap( const QDomElement &toolElement )
{
QPixmap pixmap( 32, 32 );
diff -rupN original/pageviewannotator.h new/pageviewannotator.h
--- original/pageviewannotator.h 2014-03-30 12:05:21.000000000 +0530
+++ new/pageviewannotator.h 2014-03-31 23:21:50.000000000 +0530
@@ -87,6 +87,7 @@ class PageViewAnnotator : public QObject
static QString defaultToolName( const QDomElement &toolElement );
static QPixmap makeToolPixmap( const QDomElement &toolElement );
+ static QPixmap makeToolPixmap();
private slots:
void slotToolSelected( int toolID );
diff -rupN original/pageviewutils.cpp new/pageviewutils.cpp
--- original/pageviewutils.cpp 2014-03-30 12:05:21.000000000 +0530
+++ new/pageviewutils.cpp 2014-03-31 23:16:29.000000000 +0530
@@ -8,6 +8,8 @@
***************************************************************************/
#include "pageviewutils.h"
+#include "conf/preferencesdialog.h"
+#include "../part.h"
// qt/kde includes
#include <qapplication.h>
@@ -578,6 +580,7 @@ PageViewToolBar::~PageViewToolBar()
void PageViewToolBar::setItems( const QLinkedList<AnnotationToolItem> &items )
{
+
// delete buttons if already present
if ( !d->buttons.isEmpty() )
{
@@ -586,19 +589,30 @@ void PageViewToolBar::setItems( const QL
delete *it;
d->buttons.clear();
}
-
+
// create new buttons for given items
QLinkedList<AnnotationToolItem>::const_iterator it = items.begin(), end = items.end();
for ( ; it != end; ++it )
{
+
ToolBarButton * button = new ToolBarButton( this, *it );
- connect( button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()) );
- connect( button, SIGNAL(buttonDoubleClicked(int)), this, SIGNAL(buttonDoubleClicked(int)) );
+ if (it == items.begin())
+ {
+ connect( button, SIGNAL(clicked()), this, SLOT(slotAnnotationPreferences()) );
+ }
+ else
+ {
+ connect( button, SIGNAL(clicked()), this, SLOT(slotButtonClicked()) );
+ connect( button, SIGNAL(buttonDoubleClicked(int)), this, SIGNAL(buttonDoubleClicked(int)) );
+ }
+
d->buttons.append( button );
}
// rebuild toolbar shape and contents
d->reposition();
+
+
}
void PageViewToolBar::setSide( Side side )
@@ -782,13 +796,13 @@ void ToolBarPrivate::buildToolBar()
// 4. create and set transparency mask // 4. draw background
QPainter maskPainter( &mask);
- mask.fill( Qt::white );
- maskPainter.setBrush( Qt::black );
- if ( vertical )
- maskPainter.drawRoundRect( topLeft ? -10 : 0, 0, myWidth + 11, myHeight, 2000 / (myWidth + 10), 2000 / myHeight );
- else
- maskPainter.drawRoundRect( 0, topLeft ? -10 : 0, myWidth, myHeight + 11, 2000 / myWidth, 2000 / (myHeight + 10) );
- maskPainter.end();
+ mask.fill( Qt::white );
+ maskPainter.setBrush( Qt::black );
+ if ( vertical )
+ maskPainter.drawRoundRect( topLeft ? -10 : 0, 0, myWidth + 11, myHeight, 2000 / (myWidth + 10), 2000 / myHeight );
+ else
+ maskPainter.drawRoundRect( 0, topLeft ? -10 : 0, myWidth, myHeight + 11, 2000 / myWidth, 2000 / (myHeight + 10) );
+ maskPainter.end();
q->setMask( mask );
// 5. draw background
@@ -996,4 +1010,25 @@ void PageViewToolBar::setTextToolsEnable
(*it)->setEnabled( on );
}
+
+
+void PageViewToolBar::slotAnnotationPreferences()
+{
+ // Create dialog
+ Okular::EmbedMode m_embedmode;
+ m_embedmode= Okular::UnknownEmbedMode;
+ PreferencesDialog * dialog = new PreferencesDialog( m_pageView, Okular::Settings::self(),m_embedmode );
+ dialog->setAttribute( Qt::WA_DeleteOnClose );
+
+ // Show it
+ dialog->switchToAnnotationsPage();
+ dialog->show();
+ return;
+
+ slotButtonClicked();
+
+}
+
+
+
#include "pageviewutils.moc"
diff -rupN original/pageviewutils.h new/pageviewutils.h
--- original/pageviewutils.h 2014-03-30 12:05:21.000000000 +0530
+++ new/pageviewutils.h 2014-03-31 22:54:35.000000000 +0530
@@ -10,12 +10,13 @@
#ifndef _PAGEVIEW_UTILS_H_
#define _PAGEVIEW_UTILS_H_
+#include "../part.h"
#include <qwidget.h>
#include <qpixmap.h>
#include <qrect.h>
#include <qhash.h>
#include <qtoolbutton.h>
-
+#include <qpointer.h>
#include <KIcon>
#include "core/area.h"
@@ -212,6 +213,8 @@ class PageViewToolBar : public QWidget
void setToolsEnabled( bool on );
void setTextToolsEnabled( bool on );
+ //Okular::EmbedMode detectEmbedmode();
+
// query properties
@@ -235,10 +238,14 @@ class PageViewToolBar : public QWidget
// private variables
friend class ToolBarPrivate;
class ToolBarPrivate * d;
+ QPointer<PageView> m_pageView;
+
private slots:
void slotAnimate();
void slotButtonClicked();
+ void slotAnnotationPreferences();
+
};
#endif
More information about the Okular-devel
mailing list