mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
[Gui] Apply createColorAwareIcon on more icons
This commit is contained in:
parent
7b75fe2c93
commit
90cdbe442b
6
changelog/unreleased/7043
Normal file
6
changelog/unreleased/7043
Normal file
@ -0,0 +1,6 @@
|
||||
Bugfix: Fix serveral wrong colored icons in dark mode
|
||||
|
||||
We fixed multiple issues where monocrome icons where not converted to match the
|
||||
current theme.
|
||||
|
||||
https://github.com/owncloud/client/issues/7043
|
||||
@ -25,6 +25,7 @@
|
||||
#include "folderman.h"
|
||||
#include "accessmanager.h"
|
||||
#include "activityitemdelegate.h"
|
||||
#include "guiutility.h"
|
||||
|
||||
#include "activitydata.h"
|
||||
#include "activitylistmodel.h"
|
||||
@ -68,7 +69,7 @@ QVariant ActivityListModel::data(const QModelIndex &index, int role) const
|
||||
return QVariant(); // FIXME once the action can be quantified, display on Icon
|
||||
break;
|
||||
case ActivityItemDelegate::UserIconRole:
|
||||
return QIcon(QLatin1String(":/client/resources/account.png"));
|
||||
return Utility::createColorAwareIcon(QLatin1String(":/client/resources/account.png"));
|
||||
break;
|
||||
case Qt::ToolTipRole:
|
||||
return tr("%1 %2 on %3").arg(a._subject, Utility::timeAgoInWords(a._dateTime), a._accName);
|
||||
|
||||
@ -21,6 +21,8 @@
|
||||
#include <QMessageBox>
|
||||
#include <QUrlQuery>
|
||||
|
||||
#include "theme.h"
|
||||
|
||||
#include "common/asserts.h"
|
||||
|
||||
using namespace OCC;
|
||||
@ -95,3 +97,17 @@ QString Utility::vfsFreeSpaceActionText()
|
||||
{
|
||||
return QCoreApplication::translate("utility", "Free up local space");
|
||||
}
|
||||
|
||||
QPixmap Utility::createColorAwareIcon(const QString &name, const QPalette &palette)
|
||||
{
|
||||
const QColor bg(palette.base().color());
|
||||
QImage img(Theme::hidpiFileName(name));
|
||||
if (img.isGrayscale()) {
|
||||
// account for different sensitivity of the human eye to certain colors
|
||||
double treshold = 1.0 - (0.299 * bg.red() + 0.587 * bg.green() + 0.114 * bg.blue()) / 255.0;
|
||||
if (treshold > 0.5) {
|
||||
img.invertPixels(QImage::InvertRgb);
|
||||
}
|
||||
}
|
||||
return QPixmap::fromImage(img);
|
||||
}
|
||||
|
||||
@ -49,6 +49,9 @@ namespace Utility {
|
||||
/** Translated text for "free up local space" (and unpinning the item) */
|
||||
QString vfsFreeSpaceActionText();
|
||||
|
||||
/** Create bw icon with matching contrast for the current theme */
|
||||
QPixmap createColorAwareIcon(const QString &name, const QPalette &palette = QPalette());
|
||||
|
||||
} // namespace Utility
|
||||
} // namespace OCC
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include "QProgressIndicator.h"
|
||||
#include "common/utility.h"
|
||||
#include "common/asserts.h"
|
||||
#include "guiutility.h"
|
||||
|
||||
#include <QPushButton>
|
||||
|
||||
@ -56,9 +57,9 @@ void NotificationWidget::setActivity(const Activity &activity)
|
||||
|
||||
_ui._messageLabel->setText(activity._message);
|
||||
|
||||
_ui._notifIcon->setPixmap(QPixmap(":/client/resources/bell.png"));
|
||||
_ui._notifIcon->setMinimumWidth(64);
|
||||
_ui._notifIcon->setMinimumHeight(64);
|
||||
const auto icon = Utility::createColorAwareIcon(":/client/resources/bell.png").scaled(64, 64, Qt::KeepAspectRatio);
|
||||
_ui._notifIcon->setPixmap(icon);
|
||||
_ui._notifIcon->setFixedSize(icon.size());
|
||||
_ui._notifIcon->show();
|
||||
|
||||
QString tText = tr("Created at %1").arg(Utility::timeAgoInWords(activity._dateTime));
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "folderman.h"
|
||||
#include "theme.h"
|
||||
#include "generalsettings.h"
|
||||
#include "guiutility.h"
|
||||
#include "networksettings.h"
|
||||
#include "accountsettings.h"
|
||||
#include "configfile.h"
|
||||
@ -349,7 +350,7 @@ void SettingsDialog::customizeStyle()
|
||||
_toolBar->setStyleSheet(TOOLBAR_CSS().arg(background, dark, highlightColor, highlightTextColor));
|
||||
|
||||
Q_FOREACH (QAction *a, _actionGroup->actions()) {
|
||||
QIcon icon = createColorAwareIcon(a->property("iconPath").toString());
|
||||
QIcon icon = Utility::createColorAwareIcon(a->property("iconPath").toString(), palette());
|
||||
a->setIcon(icon);
|
||||
QToolButton *btn = qobject_cast<QToolButton *>(_toolBar->widgetForAction(a));
|
||||
if (btn) {
|
||||
@ -358,19 +359,6 @@ void SettingsDialog::customizeStyle()
|
||||
}
|
||||
}
|
||||
|
||||
QIcon SettingsDialog::createColorAwareIcon(const QString &name)
|
||||
{
|
||||
QColor bg(palette().base().color());
|
||||
QImage img(name);
|
||||
// account for different sensitivity of the human eye to certain colors
|
||||
double treshold = 1.0 - (0.299 * bg.red() + 0.587 * bg.green() + 0.114 * bg.blue()) / 255.0;
|
||||
if (treshold > 0.5) {
|
||||
img.invertPixels(QImage::InvertRgb);
|
||||
}
|
||||
|
||||
return QIcon(QPixmap::fromImage(img));
|
||||
}
|
||||
|
||||
class ToolButtonAction : public QWidgetAction
|
||||
{
|
||||
public:
|
||||
@ -413,7 +401,7 @@ QAction *SettingsDialog::createActionWithIcon(const QIcon &icon, const QString &
|
||||
QAction *SettingsDialog::createColorAwareAction(const QString &iconPath, const QString &text)
|
||||
{
|
||||
// all buttons must have the same size in order to keep a good layout
|
||||
QIcon coloredIcon = createColorAwareIcon(iconPath);
|
||||
QIcon coloredIcon = Utility::createColorAwareIcon(iconPath, palette());
|
||||
return createActionWithIcon(coloredIcon, text, iconPath);
|
||||
}
|
||||
|
||||
|
||||
@ -75,7 +75,6 @@ private slots:
|
||||
private:
|
||||
void customizeStyle();
|
||||
|
||||
QIcon createColorAwareIcon(const QString &name);
|
||||
QAction *createColorAwareAction(const QString &iconName, const QString &fileName);
|
||||
QAction *createActionWithIcon(const QIcon &icon, const QString &text, const QString &iconPath = QString());
|
||||
|
||||
|
||||
@ -228,7 +228,7 @@ void ShareLinkWidget::slotSharesFetched(const QList<QSharedPointer<Share>> &shar
|
||||
connect(table, &QTableWidget::itemSelectionChanged, this, &ShareLinkWidget::slotShareSelectionChanged);
|
||||
|
||||
auto deleteIcon = QIcon::fromTheme(QLatin1String("user-trash"),
|
||||
QIcon(QLatin1String(":/client/resources/delete.png")));
|
||||
Utility::createColorAwareIcon(QLatin1String(":/client/resources/delete.png")));
|
||||
|
||||
foreach (auto share, shares) {
|
||||
if (share->getShareType() != Share::TypeLink) {
|
||||
|
||||
@ -381,7 +381,7 @@ ShareUserLine::ShareUserLine(QSharedPointer<Share> share,
|
||||
_ui->permissionToolButton->setMenu(menu);
|
||||
_ui->permissionToolButton->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
QIcon icon(QLatin1String(":/client/resources/more.svg"));
|
||||
QIcon icon = Utility::createColorAwareIcon(QLatin1String(":/client/resources/more.svg"));
|
||||
_ui->permissionToolButton->setIcon(icon);
|
||||
|
||||
// If there's only a single entry in the detailed permission menu, hide it
|
||||
@ -417,7 +417,7 @@ ShareUserLine::ShareUserLine(QSharedPointer<Share> share,
|
||||
connect(share.data(), &Share::shareDeleted, this, &ShareUserLine::slotShareDeleted);
|
||||
|
||||
_ui->deleteShareButton->setIcon(QIcon::fromTheme(QLatin1String("user-trash"),
|
||||
QIcon(QLatin1String(":/client/resources/delete.png"))));
|
||||
Utility::createColorAwareIcon(QLatin1String(":/client/resources/delete.png"))));
|
||||
|
||||
if (!share->account()->capabilities().shareResharing()) {
|
||||
_ui->permissionShare->hide();
|
||||
|
||||
@ -94,8 +94,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>377</width>
|
||||
<height>169</height>
|
||||
<width>371</width>
|
||||
<height>148</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3"/>
|
||||
@ -105,7 +105,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="privateLinkText">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>You can direct people to this shared file or folder <a href="private link menu"><span style=" text-decoration: underline; color:#0000ff;">by giving them a private link</span></a>.</p></body></html></string>
|
||||
<string><html><head/><body><p>You can direct people to this shared file or folder <a href="private link menu"><span style=" text-decoration: underline">by giving them a private link</span></a>.</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include "account.h"
|
||||
#include "accountstate.h"
|
||||
#include "theme.h"
|
||||
#include "guiutility.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QUrl>
|
||||
@ -169,11 +170,11 @@ void SslButton::updateAccountState(AccountState *accountState)
|
||||
|
||||
AccountPtr account = _accountState->account();
|
||||
if (account->url().scheme() == QLatin1String("https")) {
|
||||
setIcon(QIcon(QLatin1String(":/client/resources/lock-https.png")));
|
||||
setIcon(Utility::createColorAwareIcon(QLatin1String(":/client/resources/lock-https.png")));
|
||||
QSslCipher cipher = account->_sessionCipher;
|
||||
setToolTip(tr("This connection is encrypted using %1 bit %2.\n").arg(cipher.usedBits()).arg(cipher.name()));
|
||||
} else {
|
||||
setIcon(QIcon(QLatin1String(":/client/resources/lock-http.png")));
|
||||
setIcon(Utility::createColorAwareIcon(QLatin1String(":/client/resources/lock-http.png")));
|
||||
setToolTip(tr("This connection is NOT secure as it is not encrypted.\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include <folderman.h>
|
||||
#include "creds/abstractcredentials.h"
|
||||
#include "networkjobs.h"
|
||||
#include "guiutility.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
@ -68,7 +69,7 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage()
|
||||
_ui.lServerIcon->setText(QString());
|
||||
_ui.lServerIcon->setPixmap(appIcon.pixmap(48));
|
||||
_ui.lLocalIcon->setText(QString());
|
||||
_ui.lLocalIcon->setPixmap(QPixmap(Theme::hidpiFileName(":/client/resources/folder-sync.png")));
|
||||
_ui.lLocalIcon->setPixmap(Utility::createColorAwareIcon(":/client/resources/folder-sync.png"));
|
||||
|
||||
if (theme->wizardHideExternalStorageConfirmationCheckbox()) {
|
||||
_ui.confCheckBoxExternal->hide();
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
#include "QProgressIndicator.h"
|
||||
|
||||
#include "guiutility.h"
|
||||
#include "wizard/owncloudwizardcommon.h"
|
||||
#include "wizard/owncloudsetuppage.h"
|
||||
#include "wizard/owncloudconnectionmethoddialog.h"
|
||||
@ -127,11 +128,11 @@ void OwncloudSetupPage::slotUrlChanged(const QString &url)
|
||||
}
|
||||
|
||||
if (!url.startsWith(QLatin1String("https://"))) {
|
||||
_ui.urlLabel->setPixmap(QPixmap(Theme::hidpiFileName(":/client/resources/lock-http.png")));
|
||||
_ui.urlLabel->setPixmap(Utility::createColorAwareIcon(":/client/resources/lock-http.png"));
|
||||
_ui.urlLabel->setToolTip(tr("This url is NOT secure as it is not encrypted.\n"
|
||||
"It is not advisable to use it."));
|
||||
} else {
|
||||
_ui.urlLabel->setPixmap(QPixmap(Theme::hidpiFileName(":/client/resources/lock-https.png")));
|
||||
_ui.urlLabel->setPixmap(Utility::createColorAwareIcon(":/client/resources/lock-https.png"));
|
||||
_ui.urlLabel->setToolTip(tr("This url is secure. You can use it."));
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
|
||||
#include "guiutility.h"
|
||||
#include "wizard/owncloudwizardresultpage.h"
|
||||
#include "wizard/owncloudwizardcommon.h"
|
||||
#include "theme.h"
|
||||
@ -38,7 +39,7 @@ OwncloudWizardResultPage::OwncloudWizardResultPage()
|
||||
setSubTitle(QLatin1String(" "));
|
||||
|
||||
_ui.pbOpenLocal->setText(tr("Open Local Folder"));
|
||||
_ui.pbOpenLocal->setIcon(QIcon(QLatin1String(":/client/resources/folder-sync.png")));
|
||||
_ui.pbOpenLocal->setIcon(Utility::createColorAwareIcon(QLatin1String(":/client/resources/folder-sync.png")));
|
||||
_ui.pbOpenLocal->setIconSize(QSize(48, 48));
|
||||
_ui.pbOpenLocal->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
||||
connect(_ui.pbOpenLocal, &QAbstractButton::clicked, this, &OwncloudWizardResultPage::slotOpenLocal);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user