-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rotation map tool now uses it instead of message bar the idea of the user input toolbar can change (fixes crash when closing user input in message bar)
- Loading branch information
Showing
7 changed files
with
156 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*************************************************************************** | ||
qgsuserinputtoolbar.h | ||
-------------------------------------- | ||
Date : 04.2015 | ||
Copyright : (C) 2015 Denis Rouzaud | ||
Email : denis.rouzaud@gmail.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 "qgsuserinputtoolbar.h" | ||
|
||
#include <QAction> | ||
|
||
|
||
QgsUserInputToolBar::QgsUserInputToolBar( QWidget *parent ) | ||
: QToolBar( tr( "User input tool bar" ), parent ) | ||
{ | ||
setAllowedAreas( Qt::BottomToolBarArea | Qt::TopToolBarArea ); | ||
|
||
// add spacer to align right | ||
QWidget* spacer = new QWidget(); | ||
spacer->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | ||
addWidget( spacer ); | ||
} | ||
|
||
QgsUserInputToolBar::~QgsUserInputToolBar() | ||
{ | ||
|
||
} | ||
|
||
void QgsUserInputToolBar::addUserInputWidget( QWidget *widget ) | ||
{ | ||
QAction* sep = 0; | ||
if ( mWidgetList.count() > 0 ) | ||
{ | ||
sep = addSeparator(); | ||
} | ||
addWidget( widget ); | ||
|
||
connect( widget, SIGNAL( destroyed( QObject* ) ), this, SLOT( widgetDestroyed( QObject* ) ) ); | ||
|
||
mWidgetList.insert( widget, sep ); | ||
|
||
show(); | ||
} | ||
|
||
void QgsUserInputToolBar::widgetDestroyed( QObject *obj ) | ||
{ | ||
if ( obj->isWidgetType() ) | ||
{ | ||
QWidget* w = qobject_cast<QWidget*>( obj ); | ||
QMap<QWidget*, QAction*>::iterator i = mWidgetList.find( w ); | ||
while ( i != mWidgetList.end() ) | ||
{ | ||
if ( i.value() ) | ||
{ | ||
i.value()->deleteLater(); | ||
} | ||
mWidgetList.remove( i.key() ); | ||
++i; | ||
} | ||
} | ||
if ( mWidgetList.count() == 0 ) | ||
{ | ||
hide(); | ||
} | ||
} | ||
|
||
void QgsUserInputToolBar::paintEvent(QPaintEvent * event) | ||
{ | ||
QToolBar::paintEvent(event); | ||
if ( mWidgetList.count() == 0 ) | ||
{ | ||
hide(); | ||
} | ||
} |
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 @@ | ||
/*************************************************************************** | ||
qgsuserinputtoolbar.h | ||
-------------------------------------- | ||
Date : 04.2015 | ||
Copyright : (C) 2015 Denis Rouzaud | ||
Email : denis.rouzaud@gmail.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 QGSUSERINPUTTOOLBAR_H | ||
#define QGSUSERINPUTTOOLBAR_H | ||
|
||
#include <QToolBar> | ||
#include <QMap> | ||
|
||
class GUI_EXPORT QgsUserInputToolBar : public QToolBar | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsUserInputToolBar( QWidget* parent = 0 ); | ||
~QgsUserInputToolBar(); | ||
|
||
void addUserInputWidget( QWidget* widget ); | ||
|
||
protected: | ||
void paintEvent(QPaintEvent *event); | ||
|
||
private slots: | ||
void widgetDestroyed( QObject* obj ); | ||
|
||
private: | ||
// list of widget with their corresponding separator | ||
QMap<QWidget*, QAction*> mWidgetList; | ||
}; | ||
|
||
#endif // QGSUSERINPUTTOOLBAR_H |
a1dd7e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nyalldawson @NathanW2 I quickly added this user input tool bar.
it inherits QToolBar: user can move it where he wants.
what do you think?
a1dd7e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@3nids I think it's on the right track, but I don't like how it behaves as a toolbar (eg, how it extends below the browser/layer panel in the default configuration). The widgets just get lost way to the right of were I'd expect them to be. I think instead it should use the same approach as the messagebar, but just always display at the bottom of the canvas. This would also avoid some oddness like how "user input tool bar" shows in the panels list but can't be activated.
What do you think?
a1dd7e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a1dd7e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback.
I will implement it next week then.
By the way, would you allow to have several widgets at once in the bar?
I mean could a plug-in display a widget at a same than a map tool?
a1dd7e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NathanW2 do you speak about the message bar or about the command bat? If it's the latter was it merged already?
a1dd7e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a1dd7e8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, il will have a look at it !