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

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();
......
......@@ -113,9 +113,9 @@ void CodePasterProtocol::list()
}
void CodePasterProtocol::paste(const QString &text,
const QString &username,
const QString &comment,
const QString &description)
const QString &username,
const QString &comment,
const QString &description)
{
QString hostName = m_page->hostName();
if (!isValidHostName(hostName))
......@@ -139,7 +139,7 @@ bool CodePasterProtocol::hasSettings() const
return true;
}
Core::IOptionsPage* CodePasterProtocol::settingsPage()
Core::IOptionsPage *CodePasterProtocol::settingsPage()
{
return m_page;
}
......
......@@ -75,6 +75,11 @@ QString CodePasterSettingsPage::displayCategory() const
return QCoreApplication::translate("CodePaster", Constants::CPASTER_SETTINGS_TR_CATEGORY);
}
QIcon CodePasterSettingsPage::categoryIcon() const
{
return QIcon(); // TODO: Add icon for code paster category
}
QWidget *CodePasterSettingsPage::createPage(QWidget *parent)
{
QGroupBox *groupBox = new QGroupBox();
......
......@@ -49,6 +49,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -149,7 +149,7 @@ void PasteBinDotComProtocol::fetchFinished()
emit fetchDone(title, content, error);
}
Core::IOptionsPage* PasteBinDotComProtocol::settingsPage()
Core::IOptionsPage *PasteBinDotComProtocol::settingsPage()
{
return settings;
}
......
......@@ -48,7 +48,7 @@ public:
virtual unsigned capabilities() const { return 0; }
bool hasSettings() const { return true; }
Core::IOptionsPage* settingsPage();
Core::IOptionsPage *settingsPage();
bool canList() const { return false; }
......
......@@ -66,6 +66,11 @@ QString PasteBinDotComSettings::displayCategory() const
return QCoreApplication::translate("CodePaster", CodePaster::Constants::CPASTER_SETTINGS_TR_CATEGORY);
}
QIcon PasteBinDotComSettings::categoryIcon() const
{
return QIcon(); // TODO: Icon for CodePaster
}
QWidget *PasteBinDotComSettings::createPage(QWidget *parent)
{
Ui_PasteBinComSettingsWidget ui;
......
......@@ -52,6 +52,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -54,7 +54,7 @@ bool Protocol::hasSettings() const
return false;
}
Core::IOptionsPage* Protocol::settingsPage()
Core::IOptionsPage *Protocol::settingsPage()
{
return 0;
}
......
......@@ -57,7 +57,7 @@ public:
virtual unsigned capabilities() const = 0;
virtual bool hasSettings() const;
virtual Core::IOptionsPage* settingsPage();
virtual Core::IOptionsPage *settingsPage();
virtual void fetch(const QString &id) = 0;
virtual void list();
......
......@@ -104,6 +104,11 @@ QString SettingsPage::displayCategory() const
return QCoreApplication::translate("CodePaster", Constants::CPASTER_SETTINGS_TR_CATEGORY);
}
QIcon SettingsPage::categoryIcon() const
{
return QIcon(); // TODO: Icon for CodePaster
}
QWidget *SettingsPage::createPage(QWidget *parent)
{
m_widget = new SettingsWidget(m_protocols, parent);
......
......@@ -68,6 +68,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -70,6 +70,11 @@ QString CompletionSettingsPage::displayCategory() const
return QCoreApplication::translate("Text Editor", TextEditor::Constants::TEXT_EDITOR_SETTINGS_TR_CATEGORY);
}
QIcon CompletionSettingsPage::categoryIcon() const
{
return QIcon(QLatin1String(TextEditor::Constants::TEXT_EDITOR_SETTINGS_CATEGORY_ICON));
}
QWidget *CompletionSettingsPage::createPage(QWidget *parent)
{
QWidget *w = new QWidget(parent);
......
......@@ -53,6 +53,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -319,6 +319,11 @@ QString CppFileSettingsPage::displayCategory() const
return QCoreApplication::translate("CppTools", Constants::CPP_SETTINGS_TR_CATEGORY);
}
QIcon CppFileSettingsPage::categoryIcon() const
{
return QIcon(); // TODO: Icon for C++ or move into category
}
QWidget *CppFileSettingsPage::createPage(QWidget *parent)
{
......
......@@ -101,6 +101,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();
......
......@@ -108,6 +108,11 @@ QString SettingsPage::displayCategory() const
return QCoreApplication::translate("VCSBase", VCSBase::Constants::VCS_SETTINGS_TR_CATEGORY);
}
QIcon SettingsPage::categoryIcon() const
{
return QIcon(); // TODO: Icon for Version Control
}
QWidget *SettingsPage::createPage(QWidget *parent)
{
m_widget = new SettingsPageWidget(parent);
......
......@@ -73,6 +73,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -60,6 +60,8 @@ const char * const DEBUGGER_COMMON_SETTINGS_NAME =
const char * const DEBUGGER_SETTINGS_CATEGORY = "O.Debugger";
const char * const DEBUGGER_SETTINGS_TR_CATEGORY =
QT_TRANSLATE_NOOP("Debugger", "Debugger");
const char * const DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON =
":/core/images/category_debug.png";
namespace Internal {
enum { debug = 0 };
......
......@@ -341,6 +341,8 @@ public:
{ return _(DEBUGGER_SETTINGS_CATEGORY); }
QString displayCategory() const
{ return QCoreApplication::translate("Debugger", DEBUGGER_SETTINGS_TR_CATEGORY); }
QIcon categoryIcon() const
{ return QIcon(QLatin1String(DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON)); }
QWidget *createPage(QWidget *parent);
void apply() { m_group.apply(settings()); }
......@@ -455,6 +457,7 @@ public:
QString displayName() const { return tr("Debugging Helper"); }
QString category() const { return _(DEBUGGER_SETTINGS_CATEGORY); }
QString displayCategory() const { return QCoreApplication::translate("Debugger", DEBUGGER_SETTINGS_TR_CATEGORY); }
QIcon categoryIcon() const { return QIcon(QLatin1String(DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON)); }
QWidget *createPage(QWidget *parent);
void apply() { m_group.apply(settings()); }
......
......@@ -62,6 +62,11 @@ QString GdbOptionsPage::displayCategory() const
return QCoreApplication::translate("Debugger", Debugger::Constants::DEBUGGER_SETTINGS_TR_CATEGORY);
}
QIcon GdbOptionsPage::categoryIcon() const
{
return QIcon(QLatin1String(Debugger::Constants::DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON));
}
QWidget *GdbOptionsPage::createPage(QWidget *parent)
{
QWidget *w = new QWidget(parent);
......
......@@ -48,6 +48,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();
......
......@@ -69,6 +69,11 @@ QString TrkOptionsPage::displayCategory() const
return QCoreApplication::translate("Debugger", Debugger::Constants::DEBUGGER_SETTINGS_TR_CATEGORY);
}
QIcon TrkOptionsPage::categoryIcon() const
{
return QIcon(QLatin1String(Debugger::Constants::DEBUGGER_COMMON_SETTINGS_CATEGORY_ICON));
}
QWidget *TrkOptionsPage::createPage(QWidget *parent)
{
if (!m_widget)
......
......@@ -56,6 +56,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();
......
......@@ -123,6 +123,11 @@ QString CppSettingsPage::displayCategory() const
return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_TR_CATEGORY);
}
QIcon CppSettingsPage::categoryIcon() const
{
return QIcon(QLatin1String(Designer::Constants::SETTINGS_CATEGORY_ICON));
}
QWidget *CppSettingsPage::createPage(QWidget *parent)
{
m_widget = new CppSettingsPageWidget(parent);
......
......@@ -67,6 +67,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();
......
......@@ -42,6 +42,7 @@ const char * const DESIGNER_XML_EDITOR_ID ="DesignerXmlEditor";
const char * const C_DESIGNER_XML_DISPLAY_NAME = QT_TRANSLATE_NOOP("Designer", "Xml Editor");
const char * const SETTINGS_CATEGORY = "P.Designer";
const char * const SETTINGS_CATEGORY_ICON = ":/core/images/category_design.png";
const char * const SETTINGS_TR_CATEGORY = QT_TRANSLATE_NOOP("Designer", "Designer");
const char * const SETTINGS_CPP_SETTINGS_ID = "Class Generation";
const char * const SETTINGS_CPP_SETTINGS_NAME = QT_TRANSLATE_NOOP("Designer", "Class Generation");
......
......@@ -65,6 +65,11 @@ QString SettingsPage::displayCategory() const
return QCoreApplication::translate("Designer", Designer::Constants::SETTINGS_TR_CATEGORY);
}
QIcon SettingsPage::categoryIcon() const
{
return QIcon(QLatin1String(Designer::Constants::SETTINGS_CATEGORY_ICON));
}
QWidget *SettingsPage::createPage(QWidget *parent)
{
return m_designerPage->createPage(parent);
......
......@@ -53,6 +53,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
virtual QWidget *createPage(QWidget *parent);
virtual void apply();
......
......@@ -131,6 +131,7 @@ public:
QString displayName() const { return tr("General"); }
QString category() const { return QLatin1String(Constants::SETTINGS_CATEGORY); }
QString displayCategory() const { return tr("FakeVim"); }
QIcon categoryIcon() const { return QIcon(); } // TODO: Add an icon or move into another category
QWidget *createPage(QWidget *parent);
void apply() { m_group.apply(ICore::instance()->settings()); }
......@@ -289,6 +290,7 @@ public:
QString displayName() const { return tr("Ex Command Mapping"); }
QString category() const { return QLatin1String(Constants::SETTINGS_CATEGORY); }
QString displayCategory() const { return tr("FakeVim"); }
QIcon categoryIcon() const { return QIcon(); } // TODO: Icon for FakeVim
QWidget *createPage(QWidget *parent);
void initialize();
......
......@@ -122,6 +122,11 @@ QString SettingsPage::displayCategory() const
return QCoreApplication::translate("VCSBase", VCSBase::Constants::VCS_SETTINGS_TR_CATEGORY);
}
QIcon SettingsPage::categoryIcon() const
{
return QIcon(); // TODO: Icon for Version Control
}
QWidget *SettingsPage::createPage(QWidget *parent)
{
m_widget = new SettingsPageWidget(parent);
......
......@@ -74,6 +74,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -65,6 +65,11 @@ QString DocSettingsPage::displayCategory() const
return QCoreApplication::translate("Help", Help::Constants::HELP_TR_CATEGORY);
}
QIcon DocSettingsPage::categoryIcon() const
{
return QIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
}
QWidget *DocSettingsPage::createPage(QWidget *parent)
{
QWidget *widget = new QWidget(parent);
......
......@@ -48,6 +48,7 @@ public:
QString displayName() const;
QString category() const;
QString displayCategory() const;
QIcon categoryIcon() const;
QWidget *createPage(QWidget *parent);
void apply();
......
......@@ -66,6 +66,11 @@ QString FilterSettingsPage::displayCategory() const
return QCoreApplication::translate("Help", Help::Constants::HELP_TR_CATEGORY);
}
QIcon FilterSettingsPage::categoryIcon() const
{
return QIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
}
QWidget *FilterSettingsPage::createPage(QWidget *parent)
{