Skip to content

Commit

Permalink
add possibility to configure location of the QGIS help
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Jan 10, 2017
1 parent 3145a01 commit 981810b
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 27 deletions.
84 changes: 84 additions & 0 deletions src/app/qgsoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,21 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl )
mListHiddenBrowserPaths->addItem( newItem );
}

//locations of the QGIS help
myPaths = mSettings->value( QStringLiteral( "help/helpSearchPath" ), "" ).toString();
if ( !myPaths.isEmpty() )
{
QStringList myPathList = myPaths.split( '|' );
QStringList::const_iterator pathIt = myPathList.constBegin();
for ( ; pathIt != myPathList.constEnd(); ++pathIt )
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText( 0, *pathIt );
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
mHelpPathTreeWidget->addTopLevelItem( item );
}
}

//Network timeout
mNetworkTimeoutSpinBox->setValue( mSettings->value( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), "60000" ).toInt() );
leUserAgent->setText( mSettings->value( QStringLiteral( "/qgis/networkAndProxy/userAgent" ), "Mozilla/5.0" ).toString() );
Expand Down Expand Up @@ -1096,6 +1111,22 @@ void QgsOptions::saveOptions()
}
mSettings->setValue( QStringLiteral( "/browser/hiddenPaths" ), pathsList );

//QGIS help locations
myPaths.clear();
for ( int i = 0; i < mHelpPathTreeWidget->topLevelItemCount(); ++i )
{
QTreeWidgetItem* item = mHelpPathTreeWidget->topLevelItem( i );
if ( item )
{
if ( i != 0 )
{
myPaths += '|';
}
myPaths += item->text( 0 );
}
}
mSettings->setValue( QStringLiteral( "help/helpSearchPath" ), myPaths );

//Network timeout
mSettings->setValue( QStringLiteral( "/qgis/networkAndProxy/networkTimeout" ), mNetworkTimeoutSpinBox->value() );
mSettings->setValue( QStringLiteral( "/qgis/networkAndProxy/userAgent" ), leUserAgent->text() );
Expand Down Expand Up @@ -1713,6 +1744,59 @@ void QgsOptions::on_mBtnRemovePluginPath_clicked()
delete itemToRemove;
}

void QgsOptions::on_mBtnAddHelpPath_clicked()
{
QTreeWidgetItem* item = new QTreeWidgetItem();
item->setText( 0, QLatin1String( "" ) );
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
mHelpPathTreeWidget->addTopLevelItem( item );
}

void QgsOptions::on_mBtnRemoveHelpPath_clicked()
{
QList<QTreeWidgetItem*> items = mHelpPathTreeWidget->selectedItems();
for ( int i = 0; i < items.size(); ++i )
{
int idx = mHelpPathTreeWidget->indexOfTopLevelItem( items.at( i ) );
if ( idx >= 0 )
{
delete mHelpPathTreeWidget->takeTopLevelItem( idx );
}
}
}

void QgsOptions::on_mBtnMoveHelpUp_clicked()
{
QList<QTreeWidgetItem*> selectedItems = mHelpPathTreeWidget->selectedItems();
QList<QTreeWidgetItem*>::iterator itemIt = selectedItems.begin();
for ( ; itemIt != selectedItems.end(); ++itemIt )
{
int currentIndex = mHelpPathTreeWidget->indexOfTopLevelItem( *itemIt );
if ( currentIndex > 0 )
{
mHelpPathTreeWidget->takeTopLevelItem( currentIndex );
mHelpPathTreeWidget->insertTopLevelItem( currentIndex - 1, *itemIt );
mHelpPathTreeWidget->setCurrentItem( *itemIt );
}
}
}

void QgsOptions::on_mBtnMoveHelpDown_clicked()
{
QList<QTreeWidgetItem*> selectedItems = mHelpPathTreeWidget->selectedItems();
QList<QTreeWidgetItem*>::iterator itemIt = selectedItems.begin();
for ( ; itemIt != selectedItems.end(); ++itemIt )
{
int currentIndex = mHelpPathTreeWidget->indexOfTopLevelItem( *itemIt );
if ( currentIndex < mHelpPathTreeWidget->topLevelItemCount() - 1 )
{
mHelpPathTreeWidget->takeTopLevelItem( currentIndex );
mHelpPathTreeWidget->insertTopLevelItem( currentIndex + 1, *itemIt );
mHelpPathTreeWidget->setCurrentItem( *itemIt );
}
}
}

void QgsOptions::on_mBtnAddTemplatePath_clicked()
{
QString myDir = QFileDialog::getExistingDirectory(
Expand Down
16 changes: 16 additions & 0 deletions src/app/qgsoptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,22 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
* used for finding Plugin libs. */
void on_mBtnRemovePluginPath_clicked();

/* Let the user add a path to the list of search paths
* used for finding QGIS help. */
void on_mBtnAddHelpPath_clicked();

/* Let the user remove a path from the list of search paths
* used for finding QGIS help. */
void on_mBtnRemoveHelpPath_clicked();

/* Let the user move selected path(s) up in the list raising
* their priority. */
void on_mBtnMoveHelpUp_clicked();

/* Let the user move selected path(s) down in the list lowering
* their priority. */
void on_mBtnMoveHelpDown_clicked();

/* Let the user add a path to the list of search paths
* used for finding composer template files. */
void on_mBtnAddTemplatePath_clicked();
Expand Down
151 changes: 124 additions & 27 deletions src/ui/qgsoptionsbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>3</number>
<number>1</number>
</property>
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -337,8 +337,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>723</width>
<height>640</height>
<width>651</width>
<height>590</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
Expand Down Expand Up @@ -1023,8 +1023,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<height>850</height>
<width>843</width>
<height>1065</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
Expand Down Expand Up @@ -1162,6 +1162,103 @@
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="groupBox_29">
<property name="title">
<string>Documentation paths</string>
</property>
<layout class="QGridLayout" name="_4">
<item row="0" column="5">
<widget class="QToolButton" name="mBtnMoveHelpDown">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionArrowDown.svg</normaloff>:/images/themes/default/mActionArrowDown.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mSVGLabel_5">
<property name="text">
<string>Path(s) to search for QGIS help</string>
</property>
</widget>
</item>
<item row="0" column="1">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>31</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="mBtnAddHelpPath">
<property name="toolTip">
<string>Add new path</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyAdd.svg</normaloff>:/images/themes/default/symbologyAdd.svg</iconset>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="mBtnRemoveHelpPath">
<property name="toolTip">
<string>Remove path</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/symbologyRemove.svg</normaloff>:/images/themes/default/symbologyRemove.svg</iconset>
</property>
</widget>
</item>
<item row="1" column="0" colspan="6">
<widget class="QTreeWidget" name="mHelpPathTreeWidget">
<property name="minimumSize">
<size>
<width>0</width>
<height>120</height>
</size>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string notr="true">1</string>
</property>
</column>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="mBtnMoveHelpUp">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionArrowUp.svg</normaloff>:/images/themes/default/mActionArrowUp.svg</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mQSettingsGrpBx">
<property name="title">
Expand Down Expand Up @@ -1456,8 +1553,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>545</width>
<height>694</height>
<width>495</width>
<height>659</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
Expand Down Expand Up @@ -1813,9 +1910,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-299</y>
<width>839</width>
<height>982</height>
<y>0</y>
<width>674</width>
<height>936</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_22">
Expand Down Expand Up @@ -2565,8 +2662,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>147</width>
<height>240</height>
<width>142</width>
<height>239</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_46">
Expand Down Expand Up @@ -2712,8 +2809,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>528</width>
<height>327</height>
<width>501</width>
<height>316</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
Expand Down Expand Up @@ -3055,8 +3152,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>650</width>
<height>612</height>
<width>604</width>
<height>589</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_30">
Expand Down Expand Up @@ -3486,7 +3583,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>514</width>
<width>480</width>
<height>571</height>
</rect>
</property>
Expand Down Expand Up @@ -3755,8 +3852,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>586</width>
<height>701</height>
<width>543</width>
<height>667</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_31">
Expand Down Expand Up @@ -4310,8 +4407,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>474</width>
<height>372</height>
<width>412</width>
<height>368</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
Expand Down Expand Up @@ -4449,8 +4546,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>574</width>
<height>644</height>
<width>512</width>
<height>638</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
Expand Down Expand Up @@ -4695,8 +4792,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>302</width>
<height>226</height>
<width>273</width>
<height>236</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
Expand Down Expand Up @@ -4804,8 +4901,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>542</width>
<height>737</height>
<width>484</width>
<height>689</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_33">
Expand Down

0 comments on commit 981810b

Please sign in to comment.