Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Allow dropping a map layer from the layer tree onto
a projection selection widget to set the projection to match that layer Just a little timesaving shortcut!
- Loading branch information
1 parent
1db193e
commit fb5b440
Showing
6 changed files
with
208 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*************************************************************************** | ||
qgshighlightablecombobox.cpp | ||
--------------------------- | ||
Date : 20/12/2019 | ||
Copyright : (C) 2019 by 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 "qgshighlightablecombobox.h" | ||
#include <QPainter> | ||
|
||
QgsHighlightableComboBox::QgsHighlightableComboBox( QWidget *parent ) | ||
: QComboBox( parent ) | ||
{} | ||
|
||
void QgsHighlightableComboBox::paintEvent( QPaintEvent *e ) | ||
{ | ||
QComboBox::paintEvent( e ); | ||
if ( mHighlight ) | ||
{ | ||
QPainter p( this ); | ||
int width = 2; // width of highlight rectangle inside frame | ||
p.setPen( QPen( palette().highlight(), width ) ); | ||
QRect r = rect().adjusted( width, width, -width, -width ); | ||
p.drawRect( r ); | ||
} | ||
} | ||
|
||
void QgsHighlightableComboBox::setHighlighted( bool highlighted ) | ||
{ | ||
mHighlight = highlighted; | ||
update(); | ||
} |
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,65 @@ | ||
/*************************************************************************** | ||
qgshighlightablecombobox.h | ||
------------------------- | ||
Date : 20/12/2019 | ||
Copyright : (C) 2019 by 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 QGSHIGHLIGHTABLECOMBOBOX_H | ||
#define QGSHIGHLIGHTABLECOMBOBOX_H | ||
|
||
#include <QComboBox> | ||
|
||
#include "qgscoordinatereferencesystem.h" | ||
#include "qgis_gui.h" | ||
|
||
#define SIP_NO_FILE | ||
|
||
/** | ||
* \class QgsHighlightableComboBox | ||
* \ingroup gui | ||
* | ||
* A QComboBox subclass with the ability to "highlight" the edges of the widget. | ||
* | ||
* \since QGIS 3.12 | ||
*/ | ||
class GUI_EXPORT QgsHighlightableComboBox : public QComboBox | ||
{ | ||
Q_OBJECT | ||
public: | ||
|
||
/** | ||
* Constructor for QgsHighlightableComboBox with the specified parent widget. | ||
*/ | ||
QgsHighlightableComboBox( QWidget *parent = nullptr ); | ||
|
||
/** | ||
* Returns TRUE if the combo box is currently highlighted. | ||
* \see setHighlighted() | ||
*/ | ||
bool isHighlighted() const { return mHighlight; } | ||
|
||
/** | ||
* Sets whether the combo box is currently \a highlighted. | ||
* \see isHighlighted() | ||
*/ | ||
void setHighlighted( bool highlighted ); | ||
|
||
protected: | ||
void paintEvent( QPaintEvent *e ) override; | ||
|
||
private: | ||
|
||
bool mHighlight = false; | ||
|
||
}; | ||
|
||
#endif // QGSHIGHLIGHTABLECOMBOBOX_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
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