Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make highlightable line edit its own widget - QgsHighlightableLineEdit
- Loading branch information
1 parent
a2fb472
commit 9e4e32f
Showing
7 changed files
with
165 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgshighlightablelineedit.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsHighlightableLineEdit: QgsFilterLineEdit | ||
{ | ||
%Docstring | ||
|
||
A QgsFilterLineEdit subclass with the ability to "highlight" the edges of the widget. | ||
|
||
.. versionadded:: 3.14 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgshighlightablelineedit.h" | ||
%End | ||
public: | ||
QgsHighlightableLineEdit( QWidget *parent /TransferThis/ = 0 ); | ||
|
||
bool isHighlighted() const; | ||
%Docstring | ||
Returns ``True`` if the line edit is currently highlighted. | ||
|
||
.. seealso:: :py:func:`setHighlighted` | ||
%End | ||
|
||
void setHighlighted( bool highlighted ); | ||
%Docstring | ||
Sets whether the line edit is currently ``highlighted``. | ||
|
||
.. seealso:: :py:func:`isHighlighted` | ||
%End | ||
|
||
protected: | ||
virtual void paintEvent( QPaintEvent *e ); | ||
|
||
|
||
}; | ||
|
||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgshighlightablelineedit.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
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,41 @@ | ||
/*************************************************************************** | ||
qgshighlightablelineedit.h | ||
------------------------- | ||
Date : March 2020 | ||
Copyright : (C) 2020 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 "qgshighlightablelineedit.h" | ||
#include <QPainter> | ||
|
||
QgsHighlightableLineEdit::QgsHighlightableLineEdit( QWidget *parent ) | ||
: QgsFilterLineEdit( parent ) | ||
{} | ||
|
||
void QgsHighlightableLineEdit::paintEvent( QPaintEvent *e ) | ||
{ | ||
QgsFilterLineEdit::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 QgsHighlightableLineEdit::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,61 @@ | ||
/*************************************************************************** | ||
qgshighlightablelineedit.h | ||
------------------------- | ||
Date : March 2020 | ||
Copyright : (C) 2020 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 QGSHIGHLIGHTABLELINEEDIT_H | ||
#define QGSHIGHLIGHTABLELINEEDIT_H | ||
|
||
#include <QWidget> | ||
|
||
#include "qgis_gui.h" | ||
#include "qgis_sip.h" | ||
#include "qgsfilterlineedit.h" | ||
|
||
/** | ||
* \class QgsHighlightableLineEdit | ||
* \ingroup gui | ||
* | ||
* A QgsFilterLineEdit subclass with the ability to "highlight" the edges of the widget. | ||
* | ||
* \since QGIS 3.14 | ||
*/ | ||
class GUI_EXPORT QgsHighlightableLineEdit: public QgsFilterLineEdit | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
QgsHighlightableLineEdit( QWidget *parent SIP_TRANSFERTHIS = nullptr ); | ||
|
||
/** | ||
* Returns TRUE if the line edit is currently highlighted. | ||
* \see setHighlighted() | ||
*/ | ||
bool isHighlighted() const { return mHighlight; } | ||
|
||
/** | ||
* Sets whether the line edit is currently \a highlighted. | ||
* \see isHighlighted() | ||
*/ | ||
void setHighlighted( bool highlighted ); | ||
|
||
protected: | ||
void paintEvent( QPaintEvent *e ) override; | ||
|
||
private: | ||
|
||
bool mHighlight = false; | ||
}; | ||
|
||
|
||
#endif // QGSHIGHLIGHTABLELINEEDIT_H |