Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEATURE][API] Add interface hooks to allow plugins to register
"development/debugging" tools These tools appear in a new Development/Debugging Tools dock, and provide a unified handling and place for these tools in the UI. The intention here is that specialised development/debugging tools will be moved to this common interface, e.g. - network logger - first aid style Python local variables inspector - startup time debugging tools - layer load and rendering time debugging tools ... ?
- Loading branch information
1 parent
bab86e9
commit b1d50c2
Showing
10 changed files
with
317 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/*************************************************************************** | ||
qgsdevtoolspanelwidget.cpp | ||
--------------------- | ||
Date : March 2020 | ||
Copyright : (C) 2020 Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#include "qgsdevtoolspanelwidget.h" | ||
#include "qgisapp.h" | ||
#include "qgsdevtoolwidgetfactory.h" | ||
#include "qgsdevtoolwidget.h" | ||
#include "qgspanelwidgetstack.h" | ||
|
||
|
||
QgsDevToolsPanelWidget::QgsDevToolsPanelWidget( const QList<QgsDevToolWidgetFactory *> &factories, QWidget *parent ) | ||
: QWidget( parent ) | ||
{ | ||
setupUi( this ); | ||
|
||
mOptionsListWidget->setIconSize( QgisApp::instance()->iconSize( false ) ); | ||
mOptionsListWidget->setMaximumWidth( static_cast< int >( mOptionsListWidget->iconSize().width() * 1.18 ) ); | ||
|
||
for ( QgsDevToolWidgetFactory *factory : factories ) | ||
addToolFactory( factory ); | ||
|
||
connect( mOptionsListWidget, &QListWidget::currentRowChanged, this, &QgsDevToolsPanelWidget::setCurrentTool ); | ||
} | ||
|
||
QgsDevToolsPanelWidget::~QgsDevToolsPanelWidget() = default; | ||
|
||
void QgsDevToolsPanelWidget::addToolFactory( QgsDevToolWidgetFactory *factory ) | ||
{ | ||
if ( QgsDevToolWidget *toolWidget = factory->createWidget( this ) ) | ||
{ | ||
QgsPanelWidgetStack *toolStack = new QgsPanelWidgetStack(); | ||
toolStack->setMainPanel( toolWidget ); | ||
mStackedWidget->addWidget( toolStack ); | ||
|
||
QListWidgetItem *item = new QListWidgetItem( factory->icon(), QString() ); | ||
item->setToolTip( factory->title() ); | ||
mOptionsListWidget->addItem( item ); | ||
int row = mOptionsListWidget->row( item ); | ||
mFactoryPages[factory] = row; | ||
|
||
if ( mOptionsListWidget->count() == 1 ) | ||
{ | ||
setCurrentTool( 0 ); | ||
} | ||
} | ||
} | ||
|
||
void QgsDevToolsPanelWidget::removeToolFactory( QgsDevToolWidgetFactory *factory ) | ||
{ | ||
if ( mFactoryPages.contains( factory ) ) | ||
{ | ||
int currentRow = mStackedWidget->currentIndex(); | ||
int row = mFactoryPages.value( factory ); | ||
mStackedWidget->removeWidget( mStackedWidget->widget( row ) ); | ||
mOptionsListWidget->removeItemWidget( mOptionsListWidget->item( row ) ); | ||
mFactoryPages.remove( factory ); | ||
if ( currentRow == row ) | ||
setCurrentTool( 0 ); | ||
} | ||
} | ||
|
||
void QgsDevToolsPanelWidget::setCurrentTool( int row ) | ||
{ | ||
whileBlocking( mOptionsListWidget )->setCurrentRow( row ); | ||
mStackedWidget->setCurrentIndex( row ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/*************************************************************************** | ||
qgsdevtoolspanelwidget.h | ||
--------------------- | ||
Date : March 2020 | ||
Copyright : (C) 2020 Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QGSDEVTOOLSPANELWIDGET_H | ||
#define QGSDEVTOOLSPANELWIDGET_H | ||
|
||
#include "ui_qgsdevtoolswidgetbase.h" | ||
#include "qgis_app.h" | ||
|
||
class QgsDevToolWidgetFactory; | ||
|
||
class APP_EXPORT QgsDevToolsPanelWidget : public QWidget, private Ui::QgsDevToolsWidgetBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
|
||
QgsDevToolsPanelWidget( const QList<QgsDevToolWidgetFactory *> &factories, QWidget *parent = nullptr ); | ||
~QgsDevToolsPanelWidget() override; | ||
|
||
void addToolFactory( QgsDevToolWidgetFactory *factory ); | ||
|
||
void removeToolFactory( QgsDevToolWidgetFactory *factory ); | ||
|
||
private slots: | ||
|
||
void setCurrentTool( int row ); | ||
|
||
private: | ||
|
||
QMap< QgsDevToolWidgetFactory *, int> mFactoryPages; | ||
}; | ||
|
||
#endif // QGSDEVTOOLSPANELWIDGET_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.