mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Add config icon color based on background
This commit is contained in:
@@ -51,8 +51,11 @@ Button::Button(Type t, QWidget *parent) : QPushButton(parent) {
|
||||
|
||||
}
|
||||
|
||||
QIcon Button::getIcon(const Type t) {
|
||||
QString iconColor = "White"; // or "Black"
|
||||
QIcon Button::getIcon(const Type t, bool isWhite) {
|
||||
QString iconColor = "Black"; // or "Black"
|
||||
if (isWhite) {
|
||||
iconColor = "White";
|
||||
}
|
||||
QString path = ":/img/buttonIcons" + iconColor + "/";
|
||||
|
||||
if (t == Type::mouseVisibility) {
|
||||
@@ -115,6 +118,12 @@ QIcon Button::getIcon(const Type t) {
|
||||
return QIcon(path);
|
||||
}
|
||||
|
||||
QIcon Button::getIcon(const Type t) {
|
||||
// assign th isWhite based on the settings
|
||||
bool isWhite = true;
|
||||
return getIcon(t, isWhite);
|
||||
}
|
||||
|
||||
void Button::enterEvent(QEvent *e) {
|
||||
Q_EMIT hovered();
|
||||
QWidget::enterEvent(e);
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
explicit Button(Type, QWidget *parent = 0);
|
||||
|
||||
static QIcon getIcon(const Type);
|
||||
static QIcon getIcon(const Type, bool isWhite);
|
||||
static size_t getButtonBaseSize();
|
||||
static Button::Type getTypeByName(QString);
|
||||
static QString getTypeName(Button::Type);
|
||||
|
||||
@@ -50,7 +50,7 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QWidget(parent){
|
||||
baseLayout->addWidget(m_buttonListView);
|
||||
show();
|
||||
}
|
||||
|
||||
#include <QDebug>
|
||||
void ConfigWindow::initButtonList() {
|
||||
for (int i = 0; i != static_cast<int>(Button::Type::last); ++i) {
|
||||
auto t = static_cast<Button::Type>(i);
|
||||
@@ -60,7 +60,15 @@ void ConfigWindow::initButtonList() {
|
||||
continue;
|
||||
}
|
||||
QListWidgetItem *buttonItem = new QListWidgetItem(m_buttonListView);
|
||||
buttonItem->setIcon(Button::getIcon(t));
|
||||
|
||||
bool iconsAreWhite = false;
|
||||
QString bgColor = this->palette().color(QWidget::backgroundRole()).name();
|
||||
// when the background is lighter than gray, it uses the white icons
|
||||
if (bgColor < QColor(Qt::gray).name()) {
|
||||
iconsAreWhite = true;
|
||||
}
|
||||
buttonItem->setIcon(Button::getIcon(t, iconsAreWhite));
|
||||
|
||||
buttonItem->setText(Button::getTypeName(t));
|
||||
buttonItem->setToolTip(Button::getTypeTooltip(t));
|
||||
if (m_listButtons.contains(i)) {
|
||||
|
||||
@@ -26,19 +26,18 @@ class QListWidget;
|
||||
class ConfigWindow : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit ConfigWindow(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
void updateActiveButtons(QListWidgetItem *);
|
||||
|
||||
private:
|
||||
void initButtonList();
|
||||
|
||||
QList<int> m_listButtons;
|
||||
QListWidget *m_buttonListView;
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
void updateActiveButtons(QListWidgetItem *);
|
||||
};
|
||||
|
||||
#endif // CONFIGURATION_H
|
||||
|
||||
@@ -36,10 +36,6 @@ InfoWindow::InfoWindow(QWidget *parent) : QWidget(parent) {
|
||||
initInfoTable();
|
||||
layout->addWidget(new QLabel("<b>License</b>", this));
|
||||
layout->addWidget(new QLabel("GPLv3+", this));
|
||||
layout->addWidget(new QLabel("<b>License</b>", this));
|
||||
layout->addWidget(new QLabel("GPLv3+", this));
|
||||
layout->addWidget(new QLabel("<b>License</b>", this));
|
||||
layout->addWidget(new QLabel("GPLv3+", this));
|
||||
|
||||
// inform about full screen capture when no selection
|
||||
|
||||
|
||||
Reference in New Issue
Block a user