mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #4232
DX37 (1): revert: "fix(icons): Removed unnecessary icon preparation."
This commit is contained in:
commit
23b8b84bc9
@ -118,27 +118,28 @@ void Widget::init()
|
|||||||
actionShow = new QAction(this);
|
actionShow = new QAction(this);
|
||||||
connect(actionShow, &QAction::triggered, this, &Widget::forceShow);
|
connect(actionShow, &QAction::triggered, this, &Widget::forceShow);
|
||||||
|
|
||||||
|
//Preparing icons and set their size
|
||||||
statusOnline = new QAction(this);
|
statusOnline = new QAction(this);
|
||||||
statusOnline->setIcon(QIcon(getStatusIconPath(Status::Online)));
|
statusOnline->setIcon(prepareIcon(getStatusIconPath(Status::Online), icon_size, icon_size));
|
||||||
connect(statusOnline, &QAction::triggered, this, &Widget::setStatusOnline);
|
connect(statusOnline, &QAction::triggered, this, &Widget::setStatusOnline);
|
||||||
|
|
||||||
statusAway = new QAction(this);
|
statusAway = new QAction(this);
|
||||||
statusAway->setIcon(QIcon(getStatusIconPath(Status::Away)));
|
statusAway->setIcon(prepareIcon(getStatusIconPath(Status::Away), icon_size, icon_size));
|
||||||
connect(statusAway, &QAction::triggered, this, &Widget::setStatusAway);
|
connect(statusAway, &QAction::triggered, this, &Widget::setStatusAway);
|
||||||
|
|
||||||
statusBusy = new QAction(this);
|
statusBusy = new QAction(this);
|
||||||
statusBusy->setIcon(QIcon(getStatusIconPath(Status::Busy)));
|
statusBusy->setIcon(prepareIcon(getStatusIconPath(Status::Busy), icon_size, icon_size));
|
||||||
connect(statusBusy, &QAction::triggered, this, &Widget::setStatusBusy);
|
connect(statusBusy, &QAction::triggered, this, &Widget::setStatusBusy);
|
||||||
|
|
||||||
actionLogout = new QAction(this);
|
actionLogout = new QAction(this);
|
||||||
actionLogout->setIcon(QIcon(":/img/others/logout-icon.svg"));
|
actionLogout->setIcon(prepareIcon(":/img/others/logout-icon.svg", icon_size, icon_size));
|
||||||
|
|
||||||
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(QIcon(":/ui/rejectCall/rejectCall.svg"));
|
actionQuit->setIcon(prepareIcon(":/ui/rejectCall/rejectCall.svg", icon_size, icon_size));
|
||||||
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);
|
||||||
@ -631,7 +632,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(QIcon(getStatusIconPath(status)));
|
ui->statusButton->setIcon(prepareIcon(getStatusIconPath(status), icon_size, icon_size));
|
||||||
updateIcons();
|
updateIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2064,6 +2065,36 @@ QString Widget::getStatusIconPath(Status status)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Preparing needed to set correct size of icons for GTK tray backend
|
||||||
|
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);
|
||||||
|
@ -122,6 +122,7 @@ 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…
x
Reference in New Issue
Block a user