Commit 2d21060b authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer
Browse files

Added icons to options dialog categories

Some categories do not have icons yet, unfortunately.
parent d6b67fb2
......@@ -84,4 +84,4 @@ void ParameterAction::setParameter(const QString &p)
setEnabled(enabled);
}
}
} // namespace Utils
......@@ -58,7 +58,7 @@ public:
explicit ParameterAction(const QString &emptyText,
const QString &parameterText,
EnablingMode em = AlwaysEnabled,
QObject* parent = 0);
QObject *parent = 0);
QString emptyText() const;
void setEmptyText(const QString &);
......@@ -78,6 +78,6 @@ private:
EnablingMode m_enablingMode;
};
}
} // namespace Utils
#endif // PARAMETERACTION_H
......@@ -258,6 +258,11 @@ QString CMakeSettingsPage::displayCategory() const
return tr("CMake");
}
QIcon CMakeSettingsPage::categoryIcon() const
{
return QIcon(); // TODO: Add CMake icon or move this into Projects category
}
QWidget *CMakeSettingsPage::createPage(QWidget *parent)
{
QWidget *outerWidget = new QWidget(parent);
......
......@@ -91,6 +91,7 @@ public:
virtual QString displayName() const;
virtual QString category() const;
virtual QString displayCategory() const;
virtual QIcon categoryIcon() const;
virtual QWidget *createPage(QWidget *parent);
virtual void apply();
......
......@@ -60,12 +60,6 @@ public:
CommandMappings(QObject *parent = 0);
~CommandMappings();
// IOptionsPage
virtual QString id() const = 0;
virtual QString displayName() const = 0;
virtual QString category() const = 0;
virtual QString displayCategory() const = 0;
protected slots:
void commandChanged(QTreeWidgetItem *current);
void filterChanged(const QString &f);
......
......@@ -43,6 +43,14 @@
<file>images/unlocked.png</file>
<file>images/extension.png</file>
<file>images/darkclosebutton.png</file>
<file>images/category_debug.png</file>
<file>images/category_core.png</file>
<file>images/category_texteditor.png</file>
<file>images/category_help.png</file>
<file>images/category_project.png</file>
<file>images/category_design.png</file>
<file>images/category_qt.png</file>
<file>editormanager/BinFiles.mimetypes.xml</file>
<file>images/progressbar.png</file>
</qresource>
......
......@@ -227,6 +227,7 @@ const char * const WIZARD_CATEGORY_QT = "R.Qt";
const char * const WIZARD_TR_CATEGORY_QT = QT_TRANSLATE_NOOP("Core", "Qt");
const char * const SETTINGS_CATEGORY_CORE = "A.Core";
const char * const SETTINGS_CATEGORY_CORE_ICON = ":/core/images/category_core.png";
const char * const SETTINGS_TR_CATEGORY_CORE = QT_TRANSLATE_NOOP("Core", "Environment");
const char * const SETTINGS_ID_ENVIRONMENT = "A.General";
......
......@@ -32,6 +32,7 @@
#include <coreplugin/core_global.h>
#include <QtGui/QIcon>
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
......@@ -51,6 +52,7 @@ public:
virtual QString displayName() const = 0;
virtual QString category() const = 0;
virtual QString displayCategory() const = 0;
virtual QIcon categoryIcon() const = 0;
virtual bool matches(const QString & /* searchKeyWord*/) const { return false; }
virtual QWidget *createPage(QWidget *parent) = 0;
......
......@@ -43,6 +43,7 @@
#include <QtGui/QPushButton>
#include <QtGui/QToolButton>
#include <QtGui/QToolBar>
#include <QtGui/QScrollBar>
#include <QtGui/QSpacerItem>
#include <QtGui/QStyle>
#include <QtGui/QStackedLayout>
......@@ -52,9 +53,11 @@
#include <QtGui/QDialogButtonBox>
#include <QtGui/QListView>
#include <QtGui/QApplication>
#include <QtGui/QGroupBox>
static const char categoryKeyC[] = "General/LastPreferenceCategory";
static const char pageKeyC[] = "General/LastPreferencePage";
const int categoryIconSize = 32;
namespace Core {
namespace Internal {
......@@ -64,6 +67,7 @@ namespace Internal {
struct Category {
QString id;
QString displayName;
QIcon icon;
QList<IOptionsPage*> pages;
int index;
QTabWidget *tabWidget;
......@@ -85,11 +89,15 @@ private:
Category *findCategoryById(const QString &id);
QList<Category*> m_categories;
QIcon m_emptyIcon;
};
CategoryModel::CategoryModel(QObject *parent)
: QAbstractListModel(parent)
{
QPixmap empty(categoryIconSize, categoryIconSize);
empty.fill(Qt::transparent);
m_emptyIcon = QIcon(empty);
}
CategoryModel::~CategoryModel()
......@@ -107,6 +115,12 @@ QVariant CategoryModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DisplayRole:
return m_categories.at(index.row())->displayName;
case Qt::DecorationRole: {
QIcon icon = m_categories.at(index.row())->icon;
if (icon.isNull())
icon = m_emptyIcon;
return icon;
}
}
return QVariant();
......@@ -126,6 +140,7 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages)
category = new Category;
category->id = categoryId;
category->displayName = page->displayCategory();
category->icon = page->categoryIcon();
category->pages.append(page);
m_categories.append(category);
} else {
......@@ -198,7 +213,10 @@ public:
virtual QSize sizeHint() const
{
return QSize(sizeHintForColumn(0) + frameWidth() * 2, 100);
int width = sizeHintForColumn(0) + frameWidth() * 2 + 5;
if (verticalScrollBar()->isVisible())
width += verticalScrollBar()->width();
return QSize(width, 100);
}
};
......@@ -262,9 +280,14 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
QTabWidget *tabWidget = new QTabWidget;
for (int j = 0; j < category->pages.size(); ++j) {
IOptionsPage *page = category->pages.at(j);
tabWidget->addTab(page->createPage(0), page->displayName());
QWidget *widget = page->createPage(0);
tabWidget->addTab(widget, page->displayName());
if (initialCategoryIndex == i && page->id() == initialPage)
initialPageIndex = j;
// A hack to remove the borders from all group boxes
foreach (QGroupBox *groupBox, qFindChildren<QGroupBox*>(widget))
groupBox->setFlat(true);
}
connect(tabWidget, SIGNAL(currentChanged(int)),
......@@ -276,8 +299,10 @@ SettingsDialog::SettingsDialog(QWidget *parent, const QString &categoryId,
m_proxyModel->setSourceModel(m_model);
m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_categoryList->setIconSize(QSize(categoryIconSize, categoryIconSize));
m_categoryList->setModel(m_proxyModel);
m_categoryList->setSelectionMode(QAbstractItemView::SingleSelection);
m_categoryList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
connect(m_categoryList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
this, SLOT(currentChanged(QModelIndex)));
......
......@@ -87,6 +87,11 @@ QString ShortcutSettings::displayCategory() const
return QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE);
}
QIcon ShortcutSettings::categoryIcon() const
{
return QIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
QWidget *ShortcutSettings::createPage(QWidget *parent)
{
m_keyNum = m_key[0] = m_key[1] = m_key[2] = m_key[3] = 0;
......
......@@ -68,6 +68,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -77,6 +77,11 @@ QString GeneralSettings::displayCategory() const
return QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE);
}
QIcon GeneralSettings::categoryIcon() const
{
return QIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
static bool hasQmFilesForLocale(const QString &locale, const QString &creatorTrPath)
{
static const QString qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
......
......@@ -55,6 +55,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget* createPage(QWidget *parent);
void apply();
void finish();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment