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:
Alessandro Portale
2016-04-02 01:44:19 +02:00
parent 051ac9dd0e
commit 14af79932a
9 changed files with 22 additions and 51 deletions

View File

@@ -24,8 +24,6 @@
<file>images/linkicon@2x.png</file> <file>images/linkicon@2x.png</file>
<file>images/locked.png</file> <file>images/locked.png</file>
<file>images/locked@2x.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.png</file>
<file>images/magnifier@2x.png</file> <file>images/magnifier@2x.png</file>
<file>images/minus.png</file> <file>images/minus.png</file>

View File

@@ -52,11 +52,12 @@ const Icon RESET(
QLatin1String(":/core/images/reset.png")); QLatin1String(":/core/images/reset.png"));
const Icon DARK_CLOSE( const Icon DARK_CLOSE(
QLatin1String(":/core/images/darkclose.png")); QLatin1String(":/core/images/darkclose.png"));
const Icon LOCKED_TOOLBAR({
{QLatin1String(":/core/images/locked.png"), Theme::IconsBaseColor}});
const Icon LOCKED({ const Icon LOCKED({
{QLatin1String(":/core/images/lockedbackground.png"), Theme::PanelStatusBarBackgroundColor}, {QLatin1String(":/core/images/locked.png"), Theme::PanelTextColorDark}}, Icon::Tint);
{QLatin1String(":/core/images/locked.png"), Theme::IconsBaseColor}}, Icon::Tint); const Icon UNLOCKED_TOOLBAR({
const Icon UNLOCKED({ {QLatin1String(":/core/images/unlocked.png"), Theme::IconsBaseColor}});
{QLatin1String(":/core/images/unlocked.png"), Theme::IconsDisabledColor}}, Icon::Tint);
const Icon FIND_CASE_INSENSITIVELY( const Icon FIND_CASE_INSENSITIVELY(
QLatin1String(":/find/images/casesensitively.png")); QLatin1String(":/find/images/casesensitively.png"));
const Icon FIND_WHOLE_WORD( const Icon FIND_WHOLE_WORD(

View File

@@ -44,8 +44,9 @@ CORE_EXPORT extern const Utils::Icon CUT;
CORE_EXPORT extern const Utils::Icon DIR; CORE_EXPORT extern const Utils::Icon DIR;
CORE_EXPORT extern const Utils::Icon RESET; CORE_EXPORT extern const Utils::Icon RESET;
CORE_EXPORT extern const Utils::Icon DARK_CLOSE; 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 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_CASE_INSENSITIVELY;
CORE_EXPORT extern const Utils::Icon FIND_WHOLE_WORD; CORE_EXPORT extern const Utils::Icon FIND_WHOLE_WORD;
CORE_EXPORT extern const Utils::Icon FIND_REGEXP; CORE_EXPORT extern const Utils::Icon FIND_REGEXP;

View File

@@ -48,7 +48,6 @@ class DocumentModelPrivate : public QAbstractItemModel
Q_OBJECT Q_OBJECT
public: public:
DocumentModelPrivate();
~DocumentModelPrivate(); ~DocumentModelPrivate();
int columnCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const;
@@ -70,6 +69,8 @@ public:
bool disambiguateDisplayNames(DocumentModel::Entry *entry); bool disambiguateDisplayNames(DocumentModel::Entry *entry);
static QIcon lockedIcon();
private: private:
friend class DocumentModel; friend class DocumentModel;
void itemChanged(); void itemChanged();
@@ -101,20 +102,11 @@ private:
} }
}; };
const QIcon m_lockedIcon;
const QIcon m_unlockedIcon;
QList<DocumentModel::Entry *> m_entries; QList<DocumentModel::Entry *> m_entries;
QMap<IDocument *, QList<IEditor *> > m_editors; QMap<IDocument *, QList<IEditor *> > m_editors;
QHash<QString, DocumentModel::Entry *> m_entryByFixedPath; QHash<QString, DocumentModel::Entry *> m_entryByFixedPath;
}; };
DocumentModelPrivate::DocumentModelPrivate() :
m_lockedIcon(Icons::LOCKED.icon()),
m_unlockedIcon(Icons::UNLOCKED.icon())
{
}
DocumentModelPrivate::~DocumentModelPrivate() DocumentModelPrivate::~DocumentModelPrivate()
{ {
qDeleteAll(m_entries); qDeleteAll(m_entries);
@@ -150,12 +142,7 @@ void DocumentModel::destroy()
QIcon DocumentModel::lockedIcon() QIcon DocumentModel::lockedIcon()
{ {
return d->m_lockedIcon; return DocumentModelPrivate::lockedIcon();
}
QIcon DocumentModel::unlockedIcon()
{
return d->m_unlockedIcon;
} }
QAbstractItemModel *DocumentModel::model() QAbstractItemModel *DocumentModel::model()
@@ -340,6 +327,12 @@ bool DocumentModelPrivate::disambiguateDisplayNames(DocumentModel::Entry *entry)
return true; return true;
} }
QIcon DocumentModelPrivate::lockedIcon()
{
const static QIcon icon = Icons::LOCKED.icon();
return icon;
}
int DocumentModelPrivate::indexOfFilePath(const Utils::FileName &filePath) const int DocumentModelPrivate::indexOfFilePath(const Utils::FileName &filePath) const
{ {
if (filePath.isEmpty()) if (filePath.isEmpty())
@@ -535,7 +528,7 @@ QVariant DocumentModelPrivate::data(const QModelIndex &index, int role) const
return name; return name;
} }
case Qt::DecorationRole: case Qt::DecorationRole:
return e->document->isFileReadOnly() ? m_lockedIcon : QIcon(); return e->document->isFileReadOnly() ? lockedIcon() : QIcon();
case Qt::ToolTipRole: case Qt::ToolTipRole:
return e->fileName().isEmpty() ? e->displayName() : e->fileName().toUserOutput(); return e->fileName().isEmpty() ? e->displayName() : e->fileName().toUserOutput();
default: default:

View File

@@ -48,8 +48,6 @@ public:
static void destroy(); static void destroy();
static QIcon lockedIcon(); static QIcon lockedIcon();
static QIcon unlockedIcon();
static QAbstractItemModel *model(); static QAbstractItemModel *model();
struct CORE_EXPORT Entry { struct CORE_EXPORT Entry {

View File

@@ -413,11 +413,13 @@ void EditorToolBar::updateDocumentStatus(IDocument *document)
d->m_lockButton->setEnabled(false); d->m_lockButton->setEnabled(false);
d->m_lockButton->setToolTip(QString()); d->m_lockButton->setToolTip(QString());
} else if (document->isFileReadOnly()) { } 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->setEnabled(true);
d->m_lockButton->setToolTip(tr("Make Writable")); d->m_lockButton->setToolTip(tr("Make Writable"));
} else { } 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->setEnabled(false);
d->m_lockButton->setToolTip(tr("File is writable")); 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

View File

@@ -1984,31 +1984,9 @@
d="m 301,559 0,7 8,0 0,-7 -8,0 z m 4.5,3.847 0,1.153 -1,0 0,-1.153 c -0.293,-0.175 -0.5,-0.48 -0.5,-0.847 0,-0.553 0.448,-1 1,-1 0.552,0 1,0.447 1,1 0,0.366 -0.207,0.672 -0.5,0.847 z" d="m 301,559 0,7 8,0 0,-7 -8,0 z m 4.5,3.847 0,1.153 -1,0 0,-1.153 c -0.293,-0.175 -0.5,-0.48 -0.5,-0.847 0,-0.553 0.448,-1 1,-1 0.552,0 1,0.447 1,1 0,0.366 -0.207,0.672 -0.5,0.847 z"
id="lockbody" /> id="lockbody" />
</g> </g>
<g
id="src/plugins/coreplugin/images/lockedbackground"
transform="translate(0,16)">
<rect
id="rect5031-6-2"
height="16"
width="16"
y="552"
x="313"
style="fill:#ffffff;fill-opacity:1" />
<path
d="m 316,558 1,0 0,-1.5 c 0,0 0,-3.5 4,-3.5 4,0 4,3.5 4,3.5 l 0,1.5 1,0 0,9 -10,0 0,-9"
id="path6096"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccczcccccc" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd"
d="m 320,558 2,0 0,-1 c 0,0 0,-1 -1,-1 -1,0 -1,1 -1,1 l 0,1"
id="path6098"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccczcc" />
</g>
<g <g
id="src/plugins/coreplugin/images/unlocked" id="src/plugins/coreplugin/images/unlocked"
transform="translate(0,16)"> transform="translate(-16,16)">
<rect <rect
id="rect5041-1" id="rect5041-1"
height="16" height="16"

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 142 KiB