Skip to content

Commit 4b789b8

Browse files
committed
make html print option more visible in identify tool
1 parent 9336af0 commit 4b789b8

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

src/app/qgsidentifyresults.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q
9494
mExpandToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionExpandTree.png" ) );
9595
mCollapseToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionCollapseTree.png" ) );
9696
mExpandNewToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionExpandNewTree.png" ) );
97+
mPrintToolButton->setIcon( QgsApplication::getThemeIcon( "/mActionFilePrint.png" ) );
9798

9899
QSettings mySettings;
99100
restoreGeometry( mySettings.value( "/Windows/Identify/geometry" ).toByteArray() );
@@ -120,6 +121,9 @@ QgsIdentifyResults::QgsIdentifyResults( QgsMapCanvas *canvas, QWidget *parent, Q
120121

121122
connect( lstResults, SIGNAL( itemClicked( QTreeWidgetItem*, int ) ),
122123
this, SLOT( itemClicked( QTreeWidgetItem*, int ) ) );
124+
125+
connect( mPrintToolButton, SIGNAL( clicked() ),
126+
this, SLOT( printCurrentItem() ) );
123127
}
124128

125129
QgsIdentifyResults::~QgsIdentifyResults()
@@ -294,6 +298,7 @@ void QgsIdentifyResults::addFeature( QgsRasterLayer *layer,
294298
wv->insertAction( 0, action );
295299

296300
wv->setContextMenuPolicy( Qt::ActionsContextMenu );
301+
mPrintToolButton->setVisible( true );
297302

298303
connect( wv, SIGNAL( linkClicked( const QUrl & ) ), this, SLOT( openUrl( const QUrl & ) ) );
299304
attrItem->treeWidget()->setItemWidget( attrItem, 1, wv );
@@ -546,6 +551,9 @@ void QgsIdentifyResults::clear()
546551

547552
lstResults->clear();
548553
clearHighlights();
554+
555+
mPrintToolButton->setDisabled( true );
556+
mPrintToolButton->setHidden( true );
549557
}
550558

551559
void QgsIdentifyResults::activate()
@@ -699,6 +707,9 @@ void QgsIdentifyResults::handleCurrentItemChanged( QTreeWidgetItem *current, QTr
699707
return;
700708
}
701709

710+
QWebView *wv = qobject_cast<QWebView*>( current->treeWidget()->itemWidget( current, 1 ) );
711+
mPrintToolButton->setEnabled( wv != 0 );
712+
702713
QTreeWidgetItem *layItem = layerItem( current );
703714

704715
if ( current == layItem )
@@ -1045,6 +1056,22 @@ void QgsIdentifyResults::print()
10451056
wv->print( &printer );
10461057
}
10471058

1059+
void QgsIdentifyResults::printCurrentItem()
1060+
{
1061+
QTreeWidgetItem *item = lstResults->currentItem();
1062+
if ( !item )
1063+
return;
1064+
1065+
QWebView *wv = qobject_cast<QWebView*>( item->treeWidget()->itemWidget( item, 1 ) );
1066+
if ( !wv )
1067+
return;
1068+
1069+
QPrinter printer;
1070+
QPrintDialog *dialog = new QPrintDialog( &printer );
1071+
if ( dialog->exec() == QDialog::Accepted )
1072+
wv->print( &printer );
1073+
}
1074+
10481075
void QgsIdentifyResults:: on_mExpandNewToolButton_toggled( bool checked )
10491076
{
10501077
QSettings settings;

src/app/qgsidentifyresults.h

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class QgsIdentifyResults: public QDialog, private Ui::QgsIdentifyResultsBase
120120

121121
void openUrl( const QUrl &url );
122122
void print();
123+
void printCurrentItem();
123124

124125
private:
125126
QMenu *mActionPopup;

src/ui/qgsidentifyresultsbase.ui

+21-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>279</width>
9+
<width>288</width>
1010
<height>306</height>
1111
</rect>
1212
</property>
@@ -82,6 +82,26 @@
8282
</property>
8383
</widget>
8484
</item>
85+
<item>
86+
<widget class="QToolButton" name="mPrintToolButton">
87+
<property name="enabled">
88+
<bool>true</bool>
89+
</property>
90+
<property name="toolTip">
91+
<string>Print selected HTML response.</string>
92+
</property>
93+
<property name="text">
94+
<string>...</string>
95+
</property>
96+
<property name="icon">
97+
<iconset>
98+
<normaloff>../../images/themes/default/mActionFilePrint.png</normaloff>../../images/themes/default/mActionFilePrint.png</iconset>
99+
</property>
100+
<property name="checkable">
101+
<bool>false</bool>
102+
</property>
103+
</widget>
104+
</item>
85105
<item>
86106
<spacer name="horizontalSpacer">
87107
<property name="orientation">

0 commit comments

Comments
 (0)