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) {
|
QIcon Button::getIcon(const Type t, bool isWhite) {
|
||||||
QString iconColor = "White"; // or "Black"
|
QString iconColor = "Black"; // or "Black"
|
||||||
|
if (isWhite) {
|
||||||
|
iconColor = "White";
|
||||||
|
}
|
||||||
QString path = ":/img/buttonIcons" + iconColor + "/";
|
QString path = ":/img/buttonIcons" + iconColor + "/";
|
||||||
|
|
||||||
if (t == Type::mouseVisibility) {
|
if (t == Type::mouseVisibility) {
|
||||||
@@ -115,6 +118,12 @@ QIcon Button::getIcon(const Type t) {
|
|||||||
return QIcon(path);
|
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) {
|
void Button::enterEvent(QEvent *e) {
|
||||||
Q_EMIT hovered();
|
Q_EMIT hovered();
|
||||||
QWidget::enterEvent(e);
|
QWidget::enterEvent(e);
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public:
|
|||||||
explicit Button(Type, QWidget *parent = 0);
|
explicit Button(Type, QWidget *parent = 0);
|
||||||
|
|
||||||
static QIcon getIcon(const Type);
|
static QIcon getIcon(const Type);
|
||||||
|
static QIcon getIcon(const Type, bool isWhite);
|
||||||
static size_t getButtonBaseSize();
|
static size_t getButtonBaseSize();
|
||||||
static Button::Type getTypeByName(QString);
|
static Button::Type getTypeByName(QString);
|
||||||
static QString getTypeName(Button::Type);
|
static QString getTypeName(Button::Type);
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QWidget(parent){
|
|||||||
baseLayout->addWidget(m_buttonListView);
|
baseLayout->addWidget(m_buttonListView);
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
#include <QDebug>
|
||||||
void ConfigWindow::initButtonList() {
|
void ConfigWindow::initButtonList() {
|
||||||
for (int i = 0; i != static_cast<int>(Button::Type::last); ++i) {
|
for (int i = 0; i != static_cast<int>(Button::Type::last); ++i) {
|
||||||
auto t = static_cast<Button::Type>(i);
|
auto t = static_cast<Button::Type>(i);
|
||||||
@@ -60,7 +60,15 @@ void ConfigWindow::initButtonList() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QListWidgetItem *buttonItem = new QListWidgetItem(m_buttonListView);
|
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->setText(Button::getTypeName(t));
|
||||||
buttonItem->setToolTip(Button::getTypeTooltip(t));
|
buttonItem->setToolTip(Button::getTypeTooltip(t));
|
||||||
if (m_listButtons.contains(i)) {
|
if (m_listButtons.contains(i)) {
|
||||||
|
|||||||
@@ -26,19 +26,18 @@ class QListWidget;
|
|||||||
class ConfigWindow : public QWidget {
|
class ConfigWindow : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit ConfigWindow(QWidget *parent = 0);
|
explicit ConfigWindow(QWidget *parent = 0);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateActiveButtons(QListWidgetItem *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initButtonList();
|
void initButtonList();
|
||||||
|
|
||||||
QList<int> m_listButtons;
|
QList<int> m_listButtons;
|
||||||
QListWidget *m_buttonListView;
|
QListWidget *m_buttonListView;
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void updateActiveButtons(QListWidgetItem *);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIGURATION_H
|
#endif // CONFIGURATION_H
|
||||||
|
|||||||
@@ -36,10 +36,6 @@ InfoWindow::InfoWindow(QWidget *parent) : QWidget(parent) {
|
|||||||
initInfoTable();
|
initInfoTable();
|
||||||
layout->addWidget(new QLabel("<b>License</b>", this));
|
layout->addWidget(new QLabel("<b>License</b>", this));
|
||||||
layout->addWidget(new QLabel("GPLv3+", 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
|
// inform about full screen capture when no selection
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user