1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #4120

Yuri (1):
      fix(icons): Removed unnecessary icon preparation.
This commit is contained in:
sudden6 2017-02-25 20:03:17 +01:00
commit de78e0dddb
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
2 changed files with 6 additions and 36 deletions

View File

@ -119,26 +119,26 @@ void Widget::init()
connect(actionShow, &QAction::triggered, this, &Widget::forceShow);
statusOnline = new QAction(this);
statusOnline->setIcon(prepareIcon(getStatusIconPath(Status::Online), icon_size, icon_size));
statusOnline->setIcon(QIcon(getStatusIconPath(Status::Online)));
connect(statusOnline, &QAction::triggered, this, &Widget::setStatusOnline);
statusAway = new QAction(this);
statusAway->setIcon(prepareIcon(getStatusIconPath(Status::Away), icon_size, icon_size));
statusAway->setIcon(QIcon(getStatusIconPath(Status::Away)));
connect(statusAway, &QAction::triggered, this, &Widget::setStatusAway);
statusBusy = new QAction(this);
statusBusy->setIcon(prepareIcon(getStatusIconPath(Status::Busy), icon_size, icon_size));
statusBusy->setIcon(QIcon(getStatusIconPath(Status::Busy)));
connect(statusBusy, &QAction::triggered, this, &Widget::setStatusBusy);
actionLogout = new QAction(this);
actionLogout->setIcon(prepareIcon(":/img/others/logout-icon.svg", icon_size, icon_size));
actionLogout->setIcon(QIcon(":/img/others/logout-icon.svg"));
actionQuit = new QAction(this);
#ifndef Q_OS_OSX
actionQuit->setMenuRole(QAction::QuitRole);
#endif
actionQuit->setIcon(prepareIcon(":/ui/rejectCall/rejectCall.svg", icon_size, icon_size));
actionQuit->setIcon(QIcon(":/ui/rejectCall/rejectCall.svg"));
connect(actionQuit, &QAction::triggered, qApp, &QApplication::quit);
layout()->setContentsMargins(0, 0, 0, 0);
@ -669,7 +669,7 @@ void Widget::onBadProxyCore()
void Widget::onStatusSet(Status status)
{
ui->statusButton->setProperty("status", getStatusTitle(status));
ui->statusButton->setIcon(prepareIcon(getStatusIconPath(status), icon_size, icon_size));
ui->statusButton->setIcon(QIcon(getStatusIconPath(status)));
updateIcons();
}
@ -2287,35 +2287,6 @@ QString Widget::getStatusIconPath(Status status)
}
}
inline QIcon Widget::prepareIcon(QString path, int w, int h)
{
#ifdef Q_OS_LINUX
QString desktop = getenv("XDG_CURRENT_DESKTOP");
if (desktop.isEmpty())
{
desktop = getenv("DESKTOP_SESSION");
}
desktop = desktop.toLower();
if (desktop == "xfce" || desktop.contains("gnome") || desktop == "mate" || desktop == "x-cinnamon")
{
if (w > 0 && h > 0)
{
QSvgRenderer renderer(path);
QPixmap pm(w, h);
pm.fill(Qt::transparent);
QPainter painter(&pm);
renderer.render(&painter, pm.rect());
return QIcon(pm);
}
}
#endif
return QIcon(path);
}
QPixmap Widget::getStatusIconPixmap(QString path, uint32_t w, uint32_t h)
{
QPixmap pix(w, h);

View File

@ -102,7 +102,6 @@ public:
void reloadTheme();
static QString getStatusIconPath(Status status);
static inline QIcon prepareIcon(QString path, int w = 0, int h = 0);
static QPixmap getStatusIconPixmap(QString path, uint32_t w, uint32_t h);
static QString getStatusTitle(Status status);
static Status getStatusFromString(QString status);