Changeset View
Changeset View
Standalone View
Standalone View
src/kiconloader.cpp
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Line(s) | 125 | { | |||
---|---|---|---|---|---|
129 | 129 | | |||
130 | for (int i = 0; i < 4; i++) { | 130 | for (int i = 0; i < 4; i++) { | ||
131 | *buffer-- = hexLookup[*colorFields & 0xf]; | 131 | *buffer-- = hexLookup[*colorFields & 0xf]; | ||
132 | *buffer-- = hexLookup[*colorFields >> 4]; | 132 | *buffer-- = hexLookup[*colorFields >> 4]; | ||
133 | colorFields++; | 133 | colorFields++; | ||
134 | } | 134 | } | ||
135 | } | 135 | } | ||
136 | 136 | | |||
137 | static QString paletteId(const QPalette &pal) | 137 | static QString paletteId(const QPalette &pal, KColorScheme::ColorSet colorSet) | ||
138 | { | 138 | { | ||
139 | // 8 per color. We want 3 colors thus 8*3=24. | 139 | // 8 per color. We want 3 colors thus 8*3=24. | ||
140 | QString buffer(24, Qt::Uninitialized); | 140 | QString buffer(24, Qt::Uninitialized); | ||
141 | 141 | | |||
142 | uintToHex(pal.text().color().rgba(), buffer.data()); | 142 | uintToHex(pal.text().color().rgba(), buffer.data()); | ||
143 | uintToHex(pal.highlight().color().rgba(), buffer.data() + 8); | 143 | uintToHex(pal.highlight().color().rgba(), buffer.data() + 8); | ||
144 | uintToHex(pal.highlightedText().color().rgba(), buffer.data() + 16); | 144 | uintToHex(pal.highlightedText().color().rgba(), buffer.data() + 16); | ||
145 | buffer += QString::number(colorSet); | ||||
145 | 146 | | |||
146 | return buffer; | 147 | return buffer; | ||
147 | } | 148 | } | ||
148 | 149 | | |||
149 | /*** KIconThemeNode: A node in the icon theme dependancy tree. ***/ | 150 | /*** KIconThemeNode: A node in the icon theme dependancy tree. ***/ | ||
150 | 151 | | |||
151 | class KIconThemeNode | 152 | class KIconThemeNode | ||
152 | { | 153 | { | ||
▲ Show 20 Lines • Show All 238 Lines • ▼ Show 20 Line(s) | 208 | public: | |||
391 | // mIconThemeInited is used inside initIconThemes() to init only once | 392 | // mIconThemeInited is used inside initIconThemes() to init only once | ||
392 | bool mIconThemeInited : 1; | 393 | bool mIconThemeInited : 1; | ||
393 | QString appname; | 394 | QString appname; | ||
394 | 395 | | |||
395 | void drawOverlays(const KIconLoader *loader, KIconLoader::Group group, int state, QPixmap &pix, const QStringList &overlays); | 396 | void drawOverlays(const KIconLoader *loader, KIconLoader::Group group, int state, QPixmap &pix, const QStringList &overlays); | ||
396 | 397 | | |||
397 | QHash<QString, bool> mIconAvailability; // icon name -> true (known to be available) or false (known to be unavailable) | 398 | QHash<QString, bool> mIconAvailability; // icon name -> true (known to be available) or false (known to be unavailable) | ||
398 | QElapsedTimer mLastUnknownIconCheck; // recheck for unknown icons after kiconloader_ms_between_checks | 399 | QElapsedTimer mLastUnknownIconCheck; // recheck for unknown icons after kiconloader_ms_between_checks | ||
400 | //the kcolorscheme's colorset used to recolor svg icons stylesheets | ||||
401 | KColorScheme::ColorSet mColorSet = KColorScheme::Window; | ||||
399 | }; | 402 | }; | ||
400 | 403 | | |||
401 | class KIconLoaderGlobalData : public QObject | 404 | class KIconLoaderGlobalData : public QObject | ||
402 | { | 405 | { | ||
403 | Q_OBJECT | 406 | Q_OBJECT | ||
404 | 407 | | |||
405 | public: | 408 | public: | ||
406 | KIconLoaderGlobalData() | 409 | KIconLoaderGlobalData() | ||
▲ Show 20 Lines • Show All 390 Lines • ▼ Show 20 Line(s) | |||||
797 | 800 | | |||
798 | } | 801 | } | ||
799 | 802 | | |||
800 | void KIconLoader::drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state) const | 803 | void KIconLoader::drawOverlays(const QStringList &overlays, QPixmap &pixmap, KIconLoader::Group group, int state) const | ||
801 | { | 804 | { | ||
802 | d->drawOverlays(this, group, state, pixmap, overlays); | 805 | d->drawOverlays(this, group, state, pixmap, overlays); | ||
803 | } | 806 | } | ||
804 | 807 | | |||
808 | KColorScheme::ColorSet KIconLoader::colorSet() const | ||||
809 | { | ||||
810 | return d->mColorSet; | ||||
811 | } | ||||
812 | | ||||
813 | void KIconLoader::setColorSet(KColorScheme::ColorSet colorSet) | ||||
814 | { | ||||
815 | d->mColorSet = colorSet; | ||||
816 | } | ||||
817 | | ||||
805 | QString KIconLoaderPrivate::removeIconExtension(const QString &name) const | 818 | QString KIconLoaderPrivate::removeIconExtension(const QString &name) const | ||
806 | { | 819 | { | ||
807 | if (name.endsWith(QLatin1String(".png")) | 820 | if (name.endsWith(QLatin1String(".png")) | ||
808 | || name.endsWith(QLatin1String(".xpm")) | 821 | || name.endsWith(QLatin1String(".xpm")) | ||
809 | || name.endsWith(QLatin1String(".svg"))) { | 822 | || name.endsWith(QLatin1String(".svg"))) { | ||
810 | return name.left(name.length() - 4); | 823 | return name.left(name.length() - 4); | ||
811 | } else if (name.endsWith(QLatin1String(".svgz"))) { | 824 | } else if (name.endsWith(QLatin1String(".svgz"))) { | ||
812 | return name.left(name.length() - 5); | 825 | return name.left(name.length() - 5); | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 869 | return (group == KIconLoader::User | |||
859 | % name | 872 | % name | ||
860 | % QLatin1Char('_') | 873 | % QLatin1Char('_') | ||
861 | % QString::number(size) | 874 | % QString::number(size) | ||
862 | % QLatin1Char('_') | 875 | % QLatin1Char('_') | ||
863 | % overlays.join(QStringLiteral("_")) | 876 | % overlays.join(QStringLiteral("_")) | ||
864 | % (group >= 0 ? mpEffect.fingerprint(group, state) | 877 | % (group >= 0 ? mpEffect.fingerprint(group, state) | ||
865 | : NULL_EFFECT_FINGERPRINT()) | 878 | : NULL_EFFECT_FINGERPRINT()) | ||
866 | % QLatin1Char('_') | 879 | % QLatin1Char('_') | ||
867 | % paletteId(qApp->palette()) | 880 | % paletteId(qApp->palette(), mColorSet) | ||
868 | % (q->theme() && q->theme()->followsColorScheme() && state == KIconLoader::SelectedState ? QStringLiteral("_selected") : QString()); | 881 | % (q->theme() && q->theme()->followsColorScheme() && state == KIconLoader::SelectedState ? QStringLiteral("_selected") : QString()); | ||
869 | } | 882 | } | ||
870 | 883 | | |||
871 | QByteArray KIconLoaderPrivate::processSvg(const QString &path, KIconLoader::States state) const | 884 | QByteArray KIconLoaderPrivate::processSvg(const QString &path, KIconLoader::States state) const | ||
872 | { | 885 | { | ||
873 | QScopedPointer<QIODevice> device; | 886 | QScopedPointer<QIODevice> device; | ||
874 | 887 | | |||
875 | if (path.endsWith(QLatin1String("svgz"))) { | 888 | if (path.endsWith(QLatin1String("svgz"))) { | ||
876 | device.reset(new KCompressionDevice(path, KCompressionDevice::GZip)); | 889 | device.reset(new KCompressionDevice(path, KCompressionDevice::GZip)); | ||
877 | } else { | 890 | } else { | ||
878 | device.reset(new QFile(path)); | 891 | device.reset(new QFile(path)); | ||
879 | } | 892 | } | ||
880 | 893 | | |||
881 | if (!device->open(QIODevice::ReadOnly)) { | 894 | if (!device->open(QIODevice::ReadOnly)) { | ||
882 | return QByteArray(); | 895 | return QByteArray(); | ||
883 | } | 896 | } | ||
884 | 897 | | |||
885 | const QPalette pal = qApp->palette(); | 898 | KColorScheme scheme(QPalette::Active, state == KIconLoader::SelectedState ? KColorScheme::Selection : mColorSet); | ||
886 | KColorScheme scheme(QPalette::Active, KColorScheme::Window); | | |||
887 | QString styleSheet = STYLESHEET_TEMPLATE().arg( | 899 | QString styleSheet = STYLESHEET_TEMPLATE().arg( | ||
888 | state == KIconLoader::SelectedState ? pal.highlightedText().color().name() : pal.windowText().color().name(), | 900 | scheme.foreground(KColorScheme::NormalText).color().name(), | ||
889 | state == KIconLoader::SelectedState ? pal.highlight().color().name() : pal.window().color().name(), | 901 | scheme.background(KColorScheme::NormalBackground).color().name(), | ||
890 | state == KIconLoader::SelectedState ? pal.highlightedText().color().name() : pal.highlight().color().name(), | 902 | scheme.decoration(KColorScheme::FocusColor).color().name(), | ||
891 | scheme.foreground(KColorScheme::PositiveText).color().name(), | 903 | scheme.foreground(KColorScheme::PositiveText).color().name(), | ||
892 | scheme.foreground(KColorScheme::NeutralText).color().name(), | 904 | scheme.foreground(KColorScheme::NeutralText).color().name(), | ||
893 | scheme.foreground(KColorScheme::NegativeText).color().name()); | 905 | scheme.foreground(KColorScheme::NegativeText).color().name()); | ||
894 | 906 | | |||
895 | QByteArray processedContents; | 907 | QByteArray processedContents; | ||
896 | QXmlStreamReader reader(device.data()); | 908 | QXmlStreamReader reader(device.data()); | ||
897 | 909 | | |||
898 | QBuffer buffer(&processedContents); | 910 | QBuffer buffer(&processedContents); | ||
▲ Show 20 Lines • Show All 923 Lines • Show Last 20 Lines |