Add icons in the sourse file and use them as fallback icons.

This commit is contained in:
baijunjie 2021-12-16 15:59:13 +08:00 committed by iaom
parent 651782ff2d
commit 9c86647520
7 changed files with 52 additions and 8 deletions

View File

@ -30,13 +30,13 @@ ShowMoreLabel::ShowMoreLabel(QWidget *parent) : QWidget(parent) {
void ShowMoreLabel::resetLabel() { void ShowMoreLabel::resetLabel() {
m_isOpen = false; m_isOpen = false;
m_iconLabel->setPixmap(QIcon::fromTheme("pan-down-symbolic").pixmap(QSize(16, 16))); m_iconLabel->setPixmap(QIcon::fromTheme("pan-down-symbolic", QIcon(":/res/icons/pan-down-symbolic.svg")).pixmap(QSize(16, 16)));
} }
void ShowMoreLabel::setLabel() void ShowMoreLabel::setLabel()
{ {
m_isOpen = true; m_isOpen = true;
m_iconLabel->setPixmap(QIcon::fromTheme("pan-up-symbolic").pixmap(QSize(16, 16))); m_iconLabel->setPixmap(QIcon::fromTheme("pan-up-symbolic", QIcon(":/res/icons/pan-up-symbolic.svg")).pixmap(QSize(16, 16)));
} }
/** /**
@ -53,7 +53,7 @@ void ShowMoreLabel::initUi() {
m_layout = new QHBoxLayout(this); m_layout = new QHBoxLayout(this);
m_layout->setContentsMargins(0, 0, 0, 6); m_layout->setContentsMargins(0, 0, 0, 6);
m_iconLabel = new QLabel(this); m_iconLabel = new QLabel(this);
m_iconLabel->setPixmap(QIcon::fromTheme("pan-down-symbolic").pixmap(QSize(16, 16))); m_iconLabel->setPixmap(QIcon::fromTheme("pan-down-symbolic", QIcon(":/res/icons/pan-down-symbolic.svg")).pixmap(QSize(16, 16)));
m_iconLabel->setCursor(QCursor(Qt::PointingHandCursor)); m_iconLabel->setCursor(QCursor(Qt::PointingHandCursor));
m_iconLabel->installEventFilter(this); m_iconLabel->installEventFilter(this);
// m_loadingIconLabel = new QLabel(this); //使用图片显示加载状态时取消此label的注释 // m_loadingIconLabel = new QLabel(this); //使用图片显示加载状态时取消此label的注释
@ -71,11 +71,11 @@ bool ShowMoreLabel::eventFilter(QObject *watched, QEvent *event) {
if(event->type() == QEvent::MouseButtonPress) { if(event->type() == QEvent::MouseButtonPress) {
if(! m_timer->isActive()) { if(! m_timer->isActive()) {
if(!m_isOpen) { if(!m_isOpen) {
m_iconLabel->setPixmap(QIcon::fromTheme("pan-up-symbolic").pixmap(QSize(16, 16))); m_iconLabel->setPixmap(QIcon::fromTheme("pan-up-symbolic", QIcon(":/res/icons/pan-up-symbolic.svg")).pixmap(QSize(16, 16)));
m_isOpen = true; m_isOpen = true;
Q_EMIT this->showMoreClicked(); Q_EMIT this->showMoreClicked();
} else { } else {
m_iconLabel->setPixmap(QIcon::fromTheme("pan-down-symbolic").pixmap(QSize(16, 16))); m_iconLabel->setPixmap(QIcon::fromTheme("pan-down-symbolic", QIcon(":/res/icons/pan-down-symbolic.svg")).pixmap(QSize(16, 16)));
m_isOpen = false; m_isOpen = false;
Q_EMIT this->retractClicked(); Q_EMIT this->retractClicked();
} }

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg">
<path d="m13 6-5 5-5-5z" fill="#2e3436"/>
</svg>

After

Width:  |  Height:  |  Size: 153 B

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg">
<path d="m13 10-5-5-5 5z" fill="#2e3436"/>
</svg>

After

Width:  |  Height:  |  Size: 154 B

View File

@ -6,5 +6,7 @@
<file>res/qt-translations/qt_zh_CN.qm</file> <file>res/qt-translations/qt_zh_CN.qm</file>
<file>res/icons/net-disconnected.svg</file> <file>res/icons/net-disconnected.svg</file>
<file>res/icons/system-search.symbolic.png</file> <file>res/icons/system-search.symbolic.png</file>
<file>res/icons/pan-up-symbolic.svg</file>
<file>res/icons/pan-down-symbolic.svg</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -58,7 +58,7 @@ QIcon FileUtils::getFileIcon(const QString &uri, bool checkValid) {
nullptr, nullptr,
nullptr)); nullptr));
if(!G_IS_FILE_INFO(info.get()->get())) if(!G_IS_FILE_INFO(info.get()->get()))
return QIcon::fromTheme("unknown",QIcon(":res/icons/unknown.png")); return QIcon::fromTheme("unknown",QIcon(":/res/icons/unknown.svg"));
GIcon *g_icon = g_file_info_get_icon(info.get()->get()); GIcon *g_icon = g_file_info_get_icon(info.get()->get());
//do not unref the GIcon from info. //do not unref the GIcon from info.
@ -76,7 +76,7 @@ QIcon FileUtils::getFileIcon(const QString &uri, bool checkValid) {
} }
} }
} }
return QIcon::fromTheme("unknown",QIcon(":res/icons/unknown.png")); return QIcon::fromTheme("unknown",QIcon(":/res/icons/unknown.svg"));
} }
/** /**
@ -91,7 +91,7 @@ QIcon FileUtils::getAppIcon(const QString &path) {
keyfile = g_key_file_new(); keyfile = g_key_file_new();
if(!g_key_file_load_from_file(keyfile, ba.data(), G_KEY_FILE_NONE, NULL)) { if(!g_key_file_load_from_file(keyfile, ba.data(), G_KEY_FILE_NONE, NULL)) {
g_key_file_free(keyfile); g_key_file_free(keyfile);
return QIcon::fromTheme("unknown",QIcon(":res/icons/unknown.png")); return QIcon::fromTheme("unknown",QIcon(":/res/icons/unknown.svg"));
} }
QString icon = QString(g_key_file_get_locale_string(keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL, NULL)); QString icon = QString(g_key_file_get_locale_string(keyfile, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_ICON, NULL, NULL));
g_key_file_free(keyfile); g_key_file_free(keyfile);

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 24.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 96 96" enable-background="new 0 0 96 96" xml:space="preserve">
<title>96</title>
<g id="白色">
<g id="_96">
<g id="_48">
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="48" y1="6.5" x2="48" y2="89.5" gradientTransform="matrix(1 0 0 -1 0 96)">
<stop offset="0" style="stop-color:#D6D9E6"/>
<stop offset="1" style="stop-color:#F5F5F5"/>
</linearGradient>
<path fill="url(#SVGID_1_)" d="M23,89.5c-4.7,0-8.5-3.8-8.5-8.5V15c0-4.7,3.8-8.5,8.5-8.5h50c4.7,0,8.5,3.8,8.5,8.5v53.8
L60.8,89.5H23z"/>
<path fill="#C4C6CC" d="M73,7c4.4,0,8,3.6,8,8v53.6L60.6,89H23c-4.4,0-8-3.6-8-8V15c0-4.4,3.6-8,8-8H73 M73,6H23c-5,0-9,4-9,9v66
c0,5,4,9,9,9h38l21-21V15C82,10,78,6,73,6z"/>
</g>
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="63.6598" y1="46.9703" x2="70.4798" y2="52.6503" gradientTransform="matrix(1 0 0 1 0 26)">
<stop offset="0" style="stop-color:#000000;stop-opacity:0.1"/>
<stop offset="1" style="stop-color:#000000;stop-opacity:5.000000e-02"/>
</linearGradient>
<path fill="url(#SVGID_2_)" d="M67,69h15L61,90V75C61,71.7,63.7,69,67,69z"/>
<path fill="#898989" d="M47.9,52.6h-4.1v-2c0-1.5,0.3-2.9,1-4.2c0.9-1.5,2.1-2.7,3.5-3.7c1.4-1,2.6-2.2,3.5-3.6
c0.7-1.1,1.1-2.5,1.1-3.8c0-1.5-0.6-2.9-1.7-3.8c-1.3-1.1-2.9-1.6-4.5-1.5c-3,0-5.8,1.2-7.9,3.4v-4.8c2.5-1.6,5.5-2.5,8.5-2.5
c2.6-0.1,5.2,0.7,7.3,2.4c1.8,1.6,2.8,3.9,2.7,6.3c0,1.7-0.4,3.4-1.3,4.9c-1.1,1.8-2.5,3.4-4.2,4.7c-1.2,0.9-2.3,2-3.2,3.2
c-0.6,1-0.9,2.1-0.8,3.3L47.9,52.6z M45.8,57.5c0.8,0,1.6,0.3,2.1,0.9c1.2,1.1,1.2,3,0.1,4.2c0,0,0,0-0.1,0.1
c-0.6,0.6-1.3,0.9-2.1,0.8c-0.8,0-1.5-0.3-2.1-0.8c-0.6-0.5-0.9-1.3-0.9-2.1c0-0.8,0.3-1.6,0.9-2.1C44.3,57.8,45.1,57.5,45.8,57.5
z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -10,5 +10,6 @@
<file>res/icons/search-web-icon.svg</file> <file>res/icons/search-web-icon.svg</file>
<file>res/icons/search-web-dark.svg</file> <file>res/icons/search-web-dark.svg</file>
<file>res/icons/search-web-default.svg</file> <file>res/icons/search-web-default.svg</file>
<file>res/icons/unknown.svg</file>
</qresource> </qresource>
</RCC> </RCC>