forked from qt-creator/qt-creator
Core: Dedicated lock/unlock icons for toolbar and documents view
This change enables us to have a variation of the lock icon for toolbars and for non-toolbars. This gives removes the need for an outlined locked icon which would work on dark and light backgrounds. Change-Id: I5b825b11e892928515112f6f49b1b0639862bc42 Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
This commit is contained in:
@@ -24,8 +24,6 @@
|
||||
<file>images/linkicon@2x.png</file>
|
||||
<file>images/locked.png</file>
|
||||
<file>images/locked@2x.png</file>
|
||||
<file>images/lockedbackground.png</file>
|
||||
<file>images/lockedbackground@2x.png</file>
|
||||
<file>images/magnifier.png</file>
|
||||
<file>images/magnifier@2x.png</file>
|
||||
<file>images/minus.png</file>
|
||||
|
||||
@@ -52,11 +52,12 @@ const Icon RESET(
|
||||
QLatin1String(":/core/images/reset.png"));
|
||||
const Icon DARK_CLOSE(
|
||||
QLatin1String(":/core/images/darkclose.png"));
|
||||
const Icon LOCKED_TOOLBAR({
|
||||
{QLatin1String(":/core/images/locked.png"), Theme::IconsBaseColor}});
|
||||
const Icon LOCKED({
|
||||
{QLatin1String(":/core/images/lockedbackground.png"), Theme::PanelStatusBarBackgroundColor},
|
||||
{QLatin1String(":/core/images/locked.png"), Theme::IconsBaseColor}}, Icon::Tint);
|
||||
const Icon UNLOCKED({
|
||||
{QLatin1String(":/core/images/unlocked.png"), Theme::IconsDisabledColor}}, Icon::Tint);
|
||||
{QLatin1String(":/core/images/locked.png"), Theme::PanelTextColorDark}}, Icon::Tint);
|
||||
const Icon UNLOCKED_TOOLBAR({
|
||||
{QLatin1String(":/core/images/unlocked.png"), Theme::IconsBaseColor}});
|
||||
const Icon FIND_CASE_INSENSITIVELY(
|
||||
QLatin1String(":/find/images/casesensitively.png"));
|
||||
const Icon FIND_WHOLE_WORD(
|
||||
|
||||
@@ -44,8 +44,9 @@ CORE_EXPORT extern const Utils::Icon CUT;
|
||||
CORE_EXPORT extern const Utils::Icon DIR;
|
||||
CORE_EXPORT extern const Utils::Icon RESET;
|
||||
CORE_EXPORT extern const Utils::Icon DARK_CLOSE;
|
||||
CORE_EXPORT extern const Utils::Icon LOCKED_TOOLBAR;
|
||||
CORE_EXPORT extern const Utils::Icon LOCKED;
|
||||
CORE_EXPORT extern const Utils::Icon UNLOCKED;
|
||||
CORE_EXPORT extern const Utils::Icon UNLOCKED_TOOLBAR;
|
||||
CORE_EXPORT extern const Utils::Icon FIND_CASE_INSENSITIVELY;
|
||||
CORE_EXPORT extern const Utils::Icon FIND_WHOLE_WORD;
|
||||
CORE_EXPORT extern const Utils::Icon FIND_REGEXP;
|
||||
|
||||
@@ -48,7 +48,6 @@ class DocumentModelPrivate : public QAbstractItemModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DocumentModelPrivate();
|
||||
~DocumentModelPrivate();
|
||||
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
@@ -70,6 +69,8 @@ public:
|
||||
|
||||
bool disambiguateDisplayNames(DocumentModel::Entry *entry);
|
||||
|
||||
static QIcon lockedIcon();
|
||||
|
||||
private:
|
||||
friend class DocumentModel;
|
||||
void itemChanged();
|
||||
@@ -101,20 +102,11 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
const QIcon m_lockedIcon;
|
||||
const QIcon m_unlockedIcon;
|
||||
|
||||
QList<DocumentModel::Entry *> m_entries;
|
||||
QMap<IDocument *, QList<IEditor *> > m_editors;
|
||||
QHash<QString, DocumentModel::Entry *> m_entryByFixedPath;
|
||||
};
|
||||
|
||||
DocumentModelPrivate::DocumentModelPrivate() :
|
||||
m_lockedIcon(Icons::LOCKED.icon()),
|
||||
m_unlockedIcon(Icons::UNLOCKED.icon())
|
||||
{
|
||||
}
|
||||
|
||||
DocumentModelPrivate::~DocumentModelPrivate()
|
||||
{
|
||||
qDeleteAll(m_entries);
|
||||
@@ -150,12 +142,7 @@ void DocumentModel::destroy()
|
||||
|
||||
QIcon DocumentModel::lockedIcon()
|
||||
{
|
||||
return d->m_lockedIcon;
|
||||
}
|
||||
|
||||
QIcon DocumentModel::unlockedIcon()
|
||||
{
|
||||
return d->m_unlockedIcon;
|
||||
return DocumentModelPrivate::lockedIcon();
|
||||
}
|
||||
|
||||
QAbstractItemModel *DocumentModel::model()
|
||||
@@ -340,6 +327,12 @@ bool DocumentModelPrivate::disambiguateDisplayNames(DocumentModel::Entry *entry)
|
||||
return true;
|
||||
}
|
||||
|
||||
QIcon DocumentModelPrivate::lockedIcon()
|
||||
{
|
||||
const static QIcon icon = Icons::LOCKED.icon();
|
||||
return icon;
|
||||
}
|
||||
|
||||
int DocumentModelPrivate::indexOfFilePath(const Utils::FileName &filePath) const
|
||||
{
|
||||
if (filePath.isEmpty())
|
||||
@@ -535,7 +528,7 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
|
||||
return name;
|
||||
}
|
||||
case Qt::DecorationRole:
|
||||
return e->document->isFileReadOnly() ? m_lockedIcon : QIcon();
|
||||
return e->document->isFileReadOnly() ? lockedIcon() : QIcon();
|
||||
case Qt::ToolTipRole:
|
||||
return e->fileName().isEmpty() ? e->displayName() : e->fileName().toUserOutput();
|
||||
default:
|
||||
|
||||
@@ -48,8 +48,6 @@ public:
|
||||
static void destroy();
|
||||
|
||||
static QIcon lockedIcon();
|
||||
static QIcon unlockedIcon();
|
||||
|
||||
static QAbstractItemModel *model();
|
||||
|
||||
struct CORE_EXPORT Entry {
|
||||
|
||||
@@ -413,11 +413,13 @@ void EditorToolBar::updateDocumentStatus(IDocument *document)
|
||||
d->m_lockButton->setEnabled(false);
|
||||
d->m_lockButton->setToolTip(QString());
|
||||
} else if (document->isFileReadOnly()) {
|
||||
d->m_lockButton->setIcon(DocumentModel::lockedIcon());
|
||||
const static QIcon locked = Icons::LOCKED_TOOLBAR.icon();
|
||||
d->m_lockButton->setIcon(locked);
|
||||
d->m_lockButton->setEnabled(true);
|
||||
d->m_lockButton->setToolTip(tr("Make Writable"));
|
||||
} else {
|
||||
d->m_lockButton->setIcon(DocumentModel::unlockedIcon());
|
||||
const static QIcon unlocked = Icons::UNLOCKED_TOOLBAR.icon();
|
||||
d->m_lockButton->setIcon(unlocked);
|
||||
d->m_lockButton->setEnabled(false);
|
||||
d->m_lockButton->setToolTip(tr("File is writable"));
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 151 B |
Binary file not shown.
|
Before Width: | Height: | Size: 164 B |
Reference in New Issue
Block a user