Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
picker: Adds elided buttons for better readability (#176)
It also fixes the region button size and alignment fixes #175
- Loading branch information
Showing
5 changed files
with
65 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "elidedbutton.h" | ||
|
||
ElidedButton::ElidedButton(QWidget *parent) | ||
: QPushButton(parent) | ||
{ | ||
} | ||
|
||
ElidedButton::ElidedButton( const QString& text, QWidget* parent ) | ||
: ElidedButton( parent ) | ||
{ | ||
setText(text); | ||
} | ||
|
||
void ElidedButton::setText(QString text) | ||
{ | ||
og_text = text; | ||
updateText(); | ||
} | ||
|
||
void ElidedButton::resizeEvent(QResizeEvent *event) | ||
{ | ||
QPushButton::resizeEvent(event); | ||
updateText(); | ||
} | ||
|
||
void ElidedButton::updateText() | ||
{ | ||
QFontMetrics metrics(font()); | ||
QString elided = metrics.elidedText(og_text, Qt::ElideRight, width() - 15); | ||
QPushButton::setText(elided); | ||
} |
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,21 @@ | ||
#ifndef ELIDEDBUTTON_H | ||
#define ELIDEDBUTTON_H | ||
|
||
#include <QPushButton> | ||
|
||
class ElidedButton : public QPushButton | ||
{ | ||
public: | ||
explicit ElidedButton(QWidget *parent = nullptr); | ||
explicit ElidedButton(const QString &text, QWidget *parent = nullptr); | ||
void setText(QString); | ||
|
||
protected: | ||
void resizeEvent(QResizeEvent *); | ||
|
||
private: | ||
void updateText(); | ||
QString og_text; | ||
}; | ||
|
||
#endif // ELIDEDBUTTON_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