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:
commit
de78e0dddb
|
@ -119,26 +119,26 @@ void Widget::init()
|
||||||
connect(actionShow, &QAction::triggered, this, &Widget::forceShow);
|
connect(actionShow, &QAction::triggered, this, &Widget::forceShow);
|
||||||
|
|
||||||
statusOnline = new QAction(this);
|
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);
|
connect(statusOnline, &QAction::triggered, this, &Widget::setStatusOnline);
|
||||||
|
|
||||||
statusAway = new QAction(this);
|
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);
|
connect(statusAway, &QAction::triggered, this, &Widget::setStatusAway);
|
||||||
|
|
||||||
statusBusy = new QAction(this);
|
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);
|
connect(statusBusy, &QAction::triggered, this, &Widget::setStatusBusy);
|
||||||
|
|
||||||
actionLogout = new QAction(this);
|
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);
|
actionQuit = new QAction(this);
|
||||||
#ifndef Q_OS_OSX
|
#ifndef Q_OS_OSX
|
||||||
actionQuit->setMenuRole(QAction::QuitRole);
|
actionQuit->setMenuRole(QAction::QuitRole);
|
||||||
#endif
|
#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);
|
connect(actionQuit, &QAction::triggered, qApp, &QApplication::quit);
|
||||||
|
|
||||||
layout()->setContentsMargins(0, 0, 0, 0);
|
layout()->setContentsMargins(0, 0, 0, 0);
|
||||||
|
@ -669,7 +669,7 @@ void Widget::onBadProxyCore()
|
||||||
void Widget::onStatusSet(Status status)
|
void Widget::onStatusSet(Status status)
|
||||||
{
|
{
|
||||||
ui->statusButton->setProperty("status", getStatusTitle(status));
|
ui->statusButton->setProperty("status", getStatusTitle(status));
|
||||||
ui->statusButton->setIcon(prepareIcon(getStatusIconPath(status), icon_size, icon_size));
|
ui->statusButton->setIcon(QIcon(getStatusIconPath(status)));
|
||||||
updateIcons();
|
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 Widget::getStatusIconPixmap(QString path, uint32_t w, uint32_t h)
|
||||||
{
|
{
|
||||||
QPixmap pix(w, h);
|
QPixmap pix(w, h);
|
||||||
|
|
|
@ -102,7 +102,6 @@ public:
|
||||||
|
|
||||||
void reloadTheme();
|
void reloadTheme();
|
||||||
static QString getStatusIconPath(Status status);
|
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 QPixmap getStatusIconPixmap(QString path, uint32_t w, uint32_t h);
|
||||||
static QString getStatusTitle(Status status);
|
static QString getStatusTitle(Status status);
|
||||||
static Status getStatusFromString(QString status);
|
static Status getStatusFromString(QString status);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user