New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map Icons with IDs #10948
Map Icons with IDs #10948
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...
a459d39
to
ce7aa45
Compare
@jagannatharjun: Thanks for all your work on this feature. :} After this PR is finalized and merged, would you be willing to post a template theme (including icons) for qBittorrent? |
@LordNyriox yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, congratulations, good job 👍
Now it's time to fine tune it.
We should have such names that they are as obvious as possible, but without excesses in them.
I will review them as soon as I have time and make my suggestions and corrections.
src/gui/aboutdialog.cpp
Outdated
@@ -45,7 +45,7 @@ AboutDialog::AboutDialog(QWidget *parent) | |||
// Title | |||
m_ui->labelName->setText(QString("<b><h2>qBittorrent " QBT_VERSION " (%1-bit)</h2></b>").arg(QT_POINTER_SIZE * 8)); | |||
|
|||
m_ui->logo->setPixmap(Utils::Gui::scaledPixmapSvg(":/icons/skin/qbittorrent-tray.svg", this, 32)); | |||
m_ui->logo->setPixmap(Utils::Gui::scaledPixmapSvg("QBittorrent.Logo", this, 32)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use "AboutDialog.Logo".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glassez: It is my understanding that the same icon is used in multiple places (including the system tray).
Do you really want to name the icon based on only one of those components?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LordNyriox, if you had followed #10903, you might have understood my intentions...
#10903 (comment)
Should I fall back to the default icon mapping if the icon path can't be resolved with custom I am thinking to replace the current selection method with something like this. |
My main suggestions for naming are the following: |
What do you mean exactly? If there is no such ID (or appropriate generic ID that matches it) in theme then you should use built-in icon (and cache it for this ID). This situation can occur when some new qBittorrent version introduces new ID so there is no matches in existing themes. You also should indicate this event in some way (maybe show message box about missing icons or some less annoying way). Or maybe don't fallback and just show some predefined icon placeholder? If the theme contains some ID but mapped path is invalid then it's real bug in theme and you shouldn't fallback to correct icon. |
src/gui/uithememanager.cpp
Outdated
@@ -140,5 +156,41 @@ QString UIThemeManager::getIconPath(const QString &iconId) const | |||
return path; | |||
} | |||
#endif | |||
return IconProvider::instance()->getIconPath(iconId); | |||
|
|||
const auto iter = m_iconMap.find(iconId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this method has logical errors. I need to get a fresh look at it.
Here is a theme if anyone wants to try out. |
I'm sorry, I just can't get around to it for lack of free time. It's on my to-do list, so I'll be back here as soon as I can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getIconPath()
is still unchecked...
src/gui/uithememanager.cpp
Outdated
|
||
m_iconsDir = useCustomUITheme ? ":uitheme/icons/" : ":icons/"; | ||
|
||
QFile iconJsonMap(m_iconsDir + iconConfigFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that's right... Does it make sense to override mapping for "system theme" icons in a custom theme? Shouldn't there just be a three-state option (default-system-custom)? @Chocobo1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to override mapping for "system theme" icons in a custom theme?
I think not.
Shouldn't there just be a three-state option (default-system-custom)?
I agree although I haven't checked how the GUI should look like.
src/gui/uithememanager.cpp
Outdated
if (icon.name() != iconId) | ||
icon = QIcon::fromTheme(fallback, QIcon(IconProvider::instance()->getIconPath(iconId))); | ||
icon = QIcon::fromTheme(fallback, QIcon(getIconPath(iconId))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also how do you suppose to provide fallback icon now? It seems that it should come from (system theme) icon mapping now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I now have changed the fallback to fallbackSysThemeIcon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I add separate icon id for fallback as well? I think there are only like 4 instances where fallback is actually used.
Well, It does make sense to add IconIds for fallbacks as well. Will replace direct references with Icon ids.
ubuntu icon theme - link |
d660d83
to
03f0208
Compare
03f0208
to
1ad64ed
Compare
src/gui/aboutdialog.cpp
Outdated
@@ -32,6 +32,7 @@ | |||
|
|||
#include "base/unicodestrings.h" | |||
#include "base/utils/misc.h" | |||
#include "gui/uithememanager.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use "gui/" when include in sibling files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are actually only two such reference one is this one you mention and other is src\gui\rss\articlelistwidget.cpp
. should I don't use this prefix even in gui\rss
folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just follow other include names style in the same file.
src/gui/uithememanager.cpp
Outdated
{ | ||
static const QHash<QString, QString> iconConfig = { | ||
{"AboutDialog.Logo", ":icons/skin/qbittorrent-tray.svg"}, | ||
{"AddNewTorrentDialog.TorrentContentView.RenameAction", ":icons/qbt-theme/edit-rename.svg"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we shouldn't add "Action" suffix? Now it seems superfluous. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yes It does seem superfluous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should recheck all IDs at last step.
src/gui/uithememanager.cpp
Outdated
@@ -95,50 +601,74 @@ QIcon UIThemeManager::getIcon(const QString &iconId) const | |||
return getIcon(iconId, iconId); | |||
} | |||
|
|||
QIcon UIThemeManager::getIcon(const QString &iconId, const QString &fallback) const | |||
QIcon UIThemeManager::getIcon(const QString &iconId, const QString &fallbackSysThemeIcon) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method interface is still contradicts the implemented model. As I said before fallback should be a part of mapping. Client just want to call getIcon("SomeIconId")
. Which icon is really used is determined by the current configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What shall be the name?
MainMenu.Fallback.ConfigureAction
,
Fallback.MainMenu.ConfigureAction
,
MainMenu.ConfigureAction.Fallback
,
MainMenu.ConfigureAction2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What shall be the name?
Sorry, don't understand you.
There is only one name for each IconID. But there should be the way to assign several mappings to it. You can use either "multi map" for system icon config or map each id to list of values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking to use "multi map".
it should only be limited to the system icon config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course. In case of custom icon theme author should provide truly existed files so no fallback is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since system icon config is internal mapping does it make sense to not do pattern based searching here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not doing pattern-based searching for system icon map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, at a first glance.
But I need to look at the whole algorithm to answer exactly.
src/gui/rss/articlelistwidget.cpp
Outdated
@@ -98,7 +99,7 @@ void ArticleListWidget::handleArticleRead(RSS::Article *rssArticle) | |||
if (!item) return; | |||
|
|||
item->setData(Qt::ForegroundRole, QPalette().color(QPalette::Inactive, QPalette::WindowText)); | |||
item->setData(Qt::DecorationRole, QIcon(":/icons/sphere.png")); | |||
item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon("RSS.ReadArticle")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use something like "RSSView" instead of "RSS".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be RSSTab
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tabs is just a way to organise Views/Widgets in container (Main window in this case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're actually used in RSS Feed List so may be RSSFeedList
, but RSSView
seems good to
} | ||
else { | ||
icon = UIThemeManager::instance()->getIcon("inode-directory"); | ||
icon = UIThemeManager::instance()->getIcon("RSS"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where it is actually used? I mean I can't able to understand in which context this icon is actually used thats why such a weird name.
Superseded by #12861. |
qbt-theme
folderskins
folder