forked from qt-creator/qt-creator
Core: Move settings category icon creation closer to its first use
No real difference in performance, just stuff closer to its use. Change-Id: Ib41209fc90872743a3baa692c9bc32c87e951ad5 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "clangtoolsunittests.h"
|
||||
#endif
|
||||
|
||||
#include <utils/icon.h>
|
||||
#include <utils/mimeutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stylehelper.h>
|
||||
|
@@ -7,14 +7,12 @@
|
||||
#include "ioptionspage.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/aspects.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QGroupBox>
|
||||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
@@ -74,12 +72,12 @@ namespace Core {
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the category icon of the options page. This icon is displayed in the list on the left
|
||||
side of the \uicontrol Options dialog.
|
||||
Returns the path to the category icon of the options page. This icon will be read from this
|
||||
path and displayed in the list on the left side of the \uicontrol Options dialog.
|
||||
*/
|
||||
QIcon IOptionsPage::categoryIcon() const
|
||||
FilePath IOptionsPage::categoryIconPath() const
|
||||
{
|
||||
return m_categoryIcon.icon();
|
||||
return m_categoryIconPath;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -206,7 +204,7 @@ void IOptionsPage::finish()
|
||||
*/
|
||||
void IOptionsPage::setCategoryIconPath(const FilePath &categoryIconPath)
|
||||
{
|
||||
m_categoryIcon = Icon({{categoryIconPath, Theme::PanelTextColorDark}}, Icon::Tint);
|
||||
m_categoryIconPath = categoryIconPath;
|
||||
}
|
||||
|
||||
void IOptionsPage::setSettings(AspectContainer *settings)
|
||||
@@ -316,11 +314,6 @@ const QList<IOptionsPageProvider *> IOptionsPageProvider::allOptionsPagesProvide
|
||||
return g_optionsPagesProviders;
|
||||
}
|
||||
|
||||
QIcon IOptionsPageProvider::categoryIcon() const
|
||||
{
|
||||
return m_categoryIcon.icon();
|
||||
}
|
||||
|
||||
// PagedSettings
|
||||
|
||||
PagedSettings::PagedSettings()
|
||||
|
@@ -6,20 +6,14 @@
|
||||
#include <coreplugin/core_global.h>
|
||||
|
||||
#include <utils/aspects.h>
|
||||
#include <utils/icon.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace Layouting { class LayoutItem; }
|
||||
|
||||
namespace Utils { class AspectContainer; }
|
||||
|
||||
namespace Core {
|
||||
|
||||
class CORE_EXPORT IOptionsPageWidget : public QWidget
|
||||
@@ -54,7 +48,7 @@ public:
|
||||
QString displayName() const { return m_displayName; }
|
||||
Utils::Id category() const { return m_category; }
|
||||
QString displayCategory() const { return m_displayCategory; }
|
||||
QIcon categoryIcon() const;
|
||||
Utils::FilePath categoryIconPath() const;
|
||||
|
||||
using WidgetCreator = std::function<IOptionsPageWidget *()>;
|
||||
void setWidgetCreator(const WidgetCreator &widgetCreator);
|
||||
@@ -72,7 +66,6 @@ protected:
|
||||
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
|
||||
void setCategory(Utils::Id category) { m_category = category; }
|
||||
void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
|
||||
void setCategoryIcon(const Utils::Icon &categoryIcon) { m_categoryIcon = categoryIcon; }
|
||||
void setCategoryIconPath(const Utils::FilePath &categoryIconPath);
|
||||
void setSettings(Utils::AspectContainer *settings); // FIXME: Remove.
|
||||
void setSettingsProvider(const std::function<Utils::AspectContainer *()> &provider);
|
||||
@@ -82,7 +75,7 @@ private:
|
||||
Utils::Id m_category;
|
||||
QString m_displayName;
|
||||
QString m_displayCategory;
|
||||
Utils::Icon m_categoryIcon;
|
||||
Utils::FilePath m_categoryIconPath;
|
||||
WidgetCreator m_widgetCreator;
|
||||
QPointer<QWidget> m_widget; // Used in conjunction with m_widgetCreator
|
||||
|
||||
@@ -102,7 +95,7 @@ private:
|
||||
|
||||
class CORE_EXPORT IOptionsPageProvider
|
||||
{
|
||||
Q_DISABLE_COPY_MOVE(IOptionsPageProvider);
|
||||
Q_DISABLE_COPY_MOVE(IOptionsPageProvider)
|
||||
|
||||
public:
|
||||
IOptionsPageProvider();
|
||||
@@ -112,7 +105,7 @@ public:
|
||||
|
||||
Utils::Id category() const { return m_category; }
|
||||
QString displayCategory() const { return m_displayCategory; }
|
||||
QIcon categoryIcon() const;
|
||||
Utils::FilePath categoryIconPath() const { return m_categoryIconPath; }
|
||||
|
||||
virtual QList<IOptionsPage *> pages() const = 0;
|
||||
virtual bool matches(const QRegularExpression ®exp) const = 0;
|
||||
@@ -120,11 +113,11 @@ public:
|
||||
protected:
|
||||
void setCategory(Utils::Id category) { m_category = category; }
|
||||
void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
|
||||
void setCategoryIcon(const Utils::Icon &categoryIcon) { m_categoryIcon = categoryIcon; }
|
||||
void setCategoryIconPath(const Utils::FilePath &iconPath) { m_categoryIconPath = iconPath; }
|
||||
|
||||
Utils::Id m_category;
|
||||
QString m_displayCategory;
|
||||
Utils::Icon m_categoryIcon;
|
||||
Utils::FilePath m_categoryIconPath;
|
||||
};
|
||||
|
||||
class CORE_EXPORT PagedSettings : public Utils::AspectContainer, public IOptionsPage
|
||||
|
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/icon.h>
|
||||
#include <utils/fancylineedit.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -166,8 +167,10 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages,
|
||||
}
|
||||
if (category->displayName.isEmpty())
|
||||
category->displayName = page->displayCategory();
|
||||
if (category->icon.isNull())
|
||||
category->icon = page->categoryIcon();
|
||||
if (category->icon.isNull()) {
|
||||
Icon icon({{page->categoryIconPath(), Theme::PanelTextColorDark}}, Icon::Tint);
|
||||
category->icon = icon.icon();
|
||||
}
|
||||
category->pages.append(page);
|
||||
}
|
||||
|
||||
@@ -183,8 +186,10 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages,
|
||||
}
|
||||
if (category->displayName.isEmpty())
|
||||
category->displayName = provider->displayCategory();
|
||||
if (category->icon.isNull())
|
||||
category->icon = provider->categoryIcon();
|
||||
if (category->icon.isNull()) {
|
||||
Icon icon({{provider->categoryIconPath(), Theme::PanelTextColorDark}}, Icon::Tint);
|
||||
category->icon = icon.icon();
|
||||
}
|
||||
category->providers.append(provider);
|
||||
}
|
||||
|
||||
|
@@ -25,8 +25,10 @@
|
||||
#include <coreplugin/minisplitter.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <coreplugin/outputpane.h>
|
||||
|
||||
#include <utils/infobar.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
#include <QDesignerFormEditorPluginInterface>
|
||||
#include <QDesignerFormEditorInterface>
|
||||
|
@@ -47,8 +47,7 @@ SettingsPageProvider::SettingsPageProvider()
|
||||
{
|
||||
setCategory(Designer::Constants::SETTINGS_CATEGORY);
|
||||
setDisplayCategory(Tr::tr(Designer::Constants::SETTINGS_TR_CATEGORY));
|
||||
setCategoryIcon(Utils::Icon({{":/core/images/settingscategory_design.png",
|
||||
Utils::Theme::PanelTextColorDark}}, Utils::Icon::Tint));
|
||||
setCategoryIconPath(":/core/images/settingscategory_design.png");
|
||||
}
|
||||
|
||||
QList<Core::IOptionsPage *> SettingsPageProvider::pages() const
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include <texteditor/snippets/snippetprovider.h>
|
||||
|
||||
#include <utils/fsengine/fileiconprovider.h>
|
||||
#include <utils/icon.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
using namespace Utils;
|
||||
using namespace ProjectExplorer;
|
||||
|
Reference in New Issue
Block a user