A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

qeditor: add better fallback mecanism for icons

Change-Id: Ib87406c95fc6c579f108b81246350d12de428ba4

authored by

Amaury Pouly and committed by
Solomon Peachy
235cdeca b200cd7e

+57 -17
+54 -15
utils/regtools/qeditor/utils.cpp
··· 1991 1991 m_text->setWordWrap(true); 1992 1992 m_close = new QToolButton(this); 1993 1993 m_close->setText("close"); 1994 - m_close->setIcon(style()->standardIcon(QStyle::SP_DialogCloseButton)); 1994 + m_close->setIcon(style()->standardIcon(QStyle::QStyle::SP_DialogCloseButton)); 1995 1995 m_close->setAutoRaise(true); 1996 1996 1997 1997 QHBoxLayout *layout = new QHBoxLayout(this); ··· 2074 2074 YIconManager::YIconManager() 2075 2075 { 2076 2076 m_icon_name[ListAdd] = "list-add"; 2077 + m_icon_fallback[ListAdd] = QStyle::SP_CustomBase; /* drawn by RenderListAdd */ 2077 2078 m_icon_name[ListRemove] = "list-remove"; 2079 + m_icon_fallback[ListRemove] = QStyle::SP_CustomBase; /* drawn by RenderListAdd */ 2078 2080 m_icon_name[DocumentNew] = "document-new"; 2081 + m_icon_fallback[DocumentNew] = QStyle::SP_FileDialogNewFolder; 2079 2082 m_icon_name[DocumentEdit] = "document-edit"; 2083 + m_icon_fallback[DocumentEdit] = QStyle::SP_FileDialogContentsView; 2080 2084 m_icon_name[DocumentOpen] = "document-open"; 2085 + m_icon_fallback[DocumentOpen] = QStyle::SP_DialogOpenButton; 2081 2086 m_icon_name[DocumentSave] = "document-save"; 2087 + m_icon_fallback[DocumentSave] = QStyle::SP_DialogSaveButton; 2082 2088 m_icon_name[DocumentSaveAs] = "document-save-as"; 2089 + m_icon_fallback[DocumentSaveAs] = QStyle::SP_DialogSaveButton; 2083 2090 m_icon_name[Preferences] = "preferences-system"; 2091 + m_icon_fallback[Preferences] = QStyle::SP_FileDialogInfoView; 2084 2092 m_icon_name[FolderNew] = "folder-new"; 2093 + m_icon_fallback[FolderNew] = QStyle::SP_FileDialogNewFolder; 2085 2094 m_icon_name[Computer] = "computer"; 2095 + m_icon_fallback[Computer] = QStyle::SP_ComputerIcon; 2086 2096 m_icon_name[Cpu] = "cpu"; 2097 + m_icon_fallback[Cpu] = QStyle::SP_DriveHDIcon; 2087 2098 m_icon_name[DialogError] = "dialog-error"; 2099 + m_icon_fallback[DialogError] = QStyle::SP_MessageBoxCritical; 2088 2100 m_icon_name[ViewRefresh] = "view-refresh"; 2101 + m_icon_fallback[ViewRefresh] = QStyle::SP_BrowserReload; 2089 2102 m_icon_name[SytemRun] = "system-run"; 2103 + m_icon_fallback[SytemRun] = QStyle::SP_MediaPlay; 2090 2104 m_icon_name[ApplicationExit] = "application-exit"; 2105 + m_icon_fallback[ApplicationExit] = QStyle::SP_TitleBarCloseButton; 2091 2106 m_icon_name[HelpAbout] = "help-about"; 2107 + m_icon_fallback[HelpAbout] = QStyle::SP_MessageBoxInformation; 2092 2108 m_icon_name[FormatTextBold] = "format-text-bold"; 2109 + m_icon_fallback[FormatTextBold] = QStyle::SP_CustomBase; /* drawn by RenderLetter */ 2093 2110 m_icon_name[FormatTextItalic] = "format-text-italic"; 2111 + m_icon_fallback[FormatTextItalic] = QStyle::SP_CustomBase; /* drawn by RenderLetter */ 2094 2112 m_icon_name[FormatTextUnderline] = "format-text-underline"; 2113 + m_icon_fallback[FormatTextUnderline] = QStyle::SP_CustomBase; /* drawn by RenderLetter */ 2095 2114 m_icon_name[TextGeneric] = "text-x-generic"; 2115 + m_icon_fallback[TextGeneric] = QStyle::SP_FileDialogDetailedView; 2096 2116 m_icon_name[MultimediaPlayer] = "multimedia-player"; 2117 + m_icon_fallback[MultimediaPlayer] = QStyle::SP_ComputerIcon; 2097 2118 } 2098 2119 2099 2120 YIconManager::~YIconManager() ··· 2111 2132 { 2112 2133 if(type < 0 || type >= MaxIcon) 2113 2134 return QIcon(); 2114 - if(QIcon::hasThemeIcon(m_icon_name[type])) 2115 - return QIcon::fromTheme(m_icon_name[type]); 2116 - /* render icon if needed */ 2135 + /* cache icons */ 2117 2136 if(m_icon[type].isNull()) 2118 - Render(type); 2137 + m_icon[type] = QIcon::fromTheme(m_icon_name[type], GetFallbackIcon(type)); 2119 2138 return m_icon[type]; 2120 2139 } 2121 2140 2122 2141 namespace 2123 2142 { 2124 - void RenderListAdd(QIcon& icon) 2143 + QIcon RenderListAdd() 2125 2144 { 2126 2145 QPixmap pix(64, 64); 2127 2146 pix.fill(Qt::transparent); 2128 2147 QPainter paint(&pix); 2129 2148 paint.fillRect(30, 12, 4, 40, QColor(255, 0, 0)); 2130 2149 paint.fillRect(12, 30, 40, 4, QColor(255, 0, 0)); 2131 - icon = QIcon(pix); 2150 + return QIcon(pix); 2132 2151 } 2133 2152 2134 - void RenderListRemove(QIcon& icon) 2153 + QIcon RenderListRemove() 2135 2154 { 2136 2155 QPixmap pix(64, 64); 2137 2156 pix.fill(Qt::transparent); ··· 2139 2158 paint.setPen(QColor(255, 0, 0)); 2140 2159 paint.drawLine(12, 12, 52, 52); 2141 2160 paint.drawLine(12, 52, 52, 16); 2142 - icon = QIcon(pix); 2161 + return QIcon(pix); 2143 2162 } 2144 2163 2145 - void RenderUnknown(QIcon& icon) 2164 + QIcon RenderUnknown() 2146 2165 { 2147 2166 QPixmap pix(64, 64); 2148 2167 pix.fill(); 2149 2168 QPainter paint(&pix); 2150 2169 paint.fillRect(0, 0, 64, 64, QColor(255, 0, 0)); 2151 - icon = QIcon(pix); 2170 + return QIcon(pix); 2171 + } 2172 + 2173 + QIcon RenderText(const QString& str, bool bold, bool italic, bool underline) 2174 + { 2175 + QPixmap pix(64, 64); 2176 + pix.fill(); 2177 + QPainter paint(&pix); 2178 + QFont font = QApplication::font("QButton"); 2179 + font.setBold(bold); 2180 + font.setItalic(italic); 2181 + font.setUnderline(underline); 2182 + font.setPixelSize(64); 2183 + paint.setFont(font); 2184 + paint.drawText(0, 0, 64, 64, Qt::AlignCenter, str); 2185 + return QIcon(pix); 2152 2186 } 2153 2187 } 2154 2188 2155 - void YIconManager::Render(IconType type) 2189 + QIcon YIconManager::GetFallbackIcon(IconType type) 2156 2190 { 2191 + if(m_icon_fallback[type] != QStyle::SP_CustomBase) 2192 + return QApplication::style()->standardIcon(m_icon_fallback[type]); 2157 2193 switch(type) 2158 2194 { 2159 - case ListAdd: RenderListAdd(m_icon[type]); break; 2160 - case ListRemove: RenderListRemove(m_icon[type]); break; 2161 - default: RenderUnknown(m_icon[type]); break; 2195 + case ListAdd: return RenderListAdd(); break; 2196 + case ListRemove: return RenderListRemove(); break; 2197 + case FormatTextBold: return RenderText("B", true, false, false); 2198 + case FormatTextItalic: return RenderText("I", false, true, false); 2199 + case FormatTextUnderline: return RenderText("U", false, false, true); 2200 + default: return RenderUnknown(); break; 2162 2201 } 2163 2202 } 2164 2203
+3 -2
utils/regtools/qeditor/utils.h
··· 732 732 QIcon GetIcon(IconType it); 733 733 734 734 protected: 735 - void Render(IconType type); 735 + QIcon GetFallbackIcon(IconType it); 736 736 737 737 static YIconManager *m_singleton; // single instance 738 - QIcon m_icon[MaxIcon]; /* list add icon */ 738 + QIcon m_icon[MaxIcon]; /* cache icons */ 739 739 QString m_icon_name[MaxIcon]; /* icon name from theme */ 740 + QStyle::StandardPixmap m_icon_fallback[MaxIcon]; /* icon from style */ 740 741 }; 741 742 742 743 class Misc