feat(tray):change svg,read from theme

This commit is contained in:
shaojun 2019-09-26 16:20:15 +08:00
parent 218ce506e2
commit 96d4bc9b75
11 changed files with 8 additions and 73 deletions

View File

@ -26,7 +26,7 @@ pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
add_definitions("${QT_DEFINITIONS} -DQT_PLUGIN")
add_library(${PLUGIN_NAME} SHARED ${SRCS} tray.qrc)
add_library(${PLUGIN_NAME} SHARED ${SRCS})
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ../)
target_include_directories(${PLUGIN_NAME} PUBLIC ${DtkWidget_INCLUDE_DIRS}
${Qt5DBus_INCLUDE_DIRS}

View File

@ -48,10 +48,6 @@ FashionTrayControlWidget::FashionTrayControlWidget(Dock::Position position, QWid
setMinimumSize(PLUGIN_BACKGROUND_MIN_SIZE, PLUGIN_BACKGROUND_MIN_SIZE);
setMaximumSize(PLUGIN_BACKGROUND_MAX_SIZE, PLUGIN_BACKGROUND_MAX_SIZE);
connect(DGuiApplicationHelper::instance(),&DGuiApplicationHelper::themeTypeChanged,[=]{
this->refreshArrowPixmap();
});
}
void FashionTrayControlWidget::setDockPostion(Dock::Position pos)
@ -120,6 +116,7 @@ void FashionTrayControlWidget::paintEvent(QPaintEvent *event)
painter.setOpacity(1);
// draw arrow pixmap
refreshArrowPixmap();
QRectF rf = QRectF(rect());
QRectF rfp = QRectF(m_arrowPix.rect());
QPointF p = rf.center() - rfp.center() / m_arrowPix.devicePixelRatioF();
@ -204,21 +201,21 @@ void FashionTrayControlWidget::refreshArrowPixmap()
switch (m_dockPosition) {
case Dock::Top:
case Dock::Bottom:
iconPath = m_expanded ? ":/icons/resources/arrow-left" : ":/icons/resources/arrow-right";
iconPath = m_expanded ? "arrow-right" : "arrow-left";
break;
case Dock::Left:
case Dock::Right:
iconPath = m_expanded ? ":/icons/resources/arrow-up" : ":/icons/resources/arrow-down";
iconPath = m_expanded ? "arrow-down" : "arrow-up";
break;
default:
break;
}
if(DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) {
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) {
iconPath.append("-dark");
}
m_arrowPix = DHiDPIHelper::loadNxPixmap(iconPath);
update();
const auto ratio = devicePixelRatioF();
m_arrowPix = QIcon::fromTheme(iconPath).pixmap(QSize(PLUGIN_ICON_MAX_SIZE, PLUGIN_ICON_MAX_SIZE) * ratio);
m_arrowPix.setDevicePixelRatio(ratio);
}

View File

@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<polygon fill-rule="evenodd" points="6.659 10.73 5.952 11.437 .563 6.048 5.952 .659 6.659 1.366 1.977 6.048" transform="rotate(-90 9 5)"/>
</svg>

Before

Width:  |  Height:  |  Size: 232 B

View File

@ -1,9 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<defs>
<linearGradient id="arrow-down-a" x1="100%" x2="0%" y1="50%" y2="50%">
<stop offset="0%" stop-color="#DBFDFF"/>
<stop offset="100%" stop-color="#70FBFB"/>
</linearGradient>
</defs>
<polygon fill="url(#arrow-down-a)" fill-rule="evenodd" points="6.659 10.73 5.952 11.437 .563 6.048 5.952 .659 6.659 1.366 1.977 6.048" transform="rotate(-90 9 5)"/>
</svg>

Before

Width:  |  Height:  |  Size: 470 B

View File

@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<polygon fill-rule="evenodd" points="6.596 10.671 5.889 11.378 .5 5.989 5.889 .6 6.596 1.307 1.914 5.989" transform="translate(6 4)"/>
</svg>

Before

Width:  |  Height:  |  Size: 228 B

View File

@ -1,9 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<defs>
<linearGradient id="arrow-left-a" x1="50%" x2="50%" y1="2.055%" y2="97.559%">
<stop offset="0%" stop-color="#DBFDFF"/>
<stop offset="100%" stop-color="#70FBFB"/>
</linearGradient>
</defs>
<polygon fill="url(#arrow-left-a)" fill-rule="evenodd" points="6.596 10.671 5.889 11.378 .5 5.989 5.889 .6 6.596 1.307 1.914 5.989" transform="translate(6 4)"/>
</svg>

Before

Width:  |  Height:  |  Size: 473 B

View File

@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<polygon fill-rule="evenodd" points="6.5 10.693 5.793 11.4 .404 6.011 5.793 .622 6.5 1.329 1.818 6.011" transform="matrix(-1 0 0 1 14 3.978)"/>
</svg>

Before

Width:  |  Height:  |  Size: 237 B

View File

@ -1,9 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<defs>
<linearGradient id="arrow-right-a" x1="50%" x2="50%" y1="2.055%" y2="97.559%">
<stop offset="0%" stop-color="#DBFDFF"/>
<stop offset="100%" stop-color="#70FBFB"/>
</linearGradient>
</defs>
<polygon fill="url(#arrow-right-a)" fill-rule="evenodd" points="6.5 10.693 5.793 11.4 .404 6.011 5.793 .622 6.5 1.329 1.818 6.011" transform="matrix(-1 0 0 1 14 3.978)"/>
</svg>

Before

Width:  |  Height:  |  Size: 484 B

View File

@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<polygon fill-rule="evenodd" points="6.437 10.73 5.73 11.437 .341 6.048 5.73 .659 6.437 1.366 1.755 6.048" transform="matrix(0 1 1 0 4 6)"/>
</svg>

Before

Width:  |  Height:  |  Size: 234 B

View File

@ -1,9 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<defs>
<linearGradient id="arrow-up-a" x1="0%" x2="100%" y1="50%" y2="50%">
<stop offset="0%" stop-color="#DBFDFF"/>
<stop offset="100%" stop-color="#70FBFB"/>
</linearGradient>
</defs>
<polygon fill="url(#arrow-up-a)" fill-rule="evenodd" points="6.437 10.73 5.73 11.437 .341 6.048 5.73 .659 6.437 1.366 1.755 6.048" transform="matrix(0 1 1 0 4 6)"/>
</svg>

Before

Width:  |  Height:  |  Size: 468 B

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.2 KiB