forked from qt-creator/qt-creator
ExtensionManager: Display extension status
Fixes: QTCREATORBUG-31180 Change-Id: I28c56f2e312670183b21e919ef578135c0384d92 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/extensionmanager">
|
<qresource prefix="/extensionmanager">
|
||||||
|
<file>images/checkmark.png</file>
|
||||||
|
<file>images/checkmark@2x.png</file>
|
||||||
<file>images/download.png</file>
|
<file>images/download.png</file>
|
||||||
<file>images/download@2x.png</file>
|
<file>images/download@2x.png</file>
|
||||||
<file>images/extensionbig.png</file>
|
<file>images/extensionbig.png</file>
|
||||||
|
|||||||
@@ -59,6 +59,19 @@ constexpr int gapSize = HGapL;
|
|||||||
constexpr int itemWidth = 330;
|
constexpr int itemWidth = 330;
|
||||||
constexpr int cellWidth = itemWidth + gapSize;
|
constexpr int cellWidth = itemWidth + gapSize;
|
||||||
|
|
||||||
|
static QString extensionStateDisplayString(ExtensionState state)
|
||||||
|
{
|
||||||
|
switch (state) {
|
||||||
|
case InstalledEnabled:
|
||||||
|
return Tr::tr("Loaded");
|
||||||
|
case InstalledDisabled:
|
||||||
|
return Tr::tr("Installed");
|
||||||
|
default:
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
class ExtensionItemDelegate : public QItemDelegate
|
class ExtensionItemDelegate : public QItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -71,6 +84,8 @@ public:
|
|||||||
constexpr static TextFormat vendorTF
|
constexpr static TextFormat vendorTF
|
||||||
{Theme::Token_Text_Muted, UiElement::UiElementLabelSmall,
|
{Theme::Token_Text_Muted, UiElement::UiElementLabelSmall,
|
||||||
Qt::AlignVCenter | Qt::TextDontClip};
|
Qt::AlignVCenter | Qt::TextDontClip};
|
||||||
|
constexpr static TextFormat stateTF
|
||||||
|
{vendorTF.themeColor, UiElement::UiElementCaption, vendorTF.drawTextFlags};
|
||||||
constexpr static TextFormat tagsTF
|
constexpr static TextFormat tagsTF
|
||||||
{Theme::Token_Text_Default, UiElement::UiElementCaption};
|
{Theme::Token_Text_Default, UiElement::UiElementCaption};
|
||||||
|
|
||||||
@@ -84,9 +99,9 @@ public:
|
|||||||
{
|
{
|
||||||
// +---------------+-------+---------------+----------------------------------------------------------------------+---------------+---------+
|
// +---------------+-------+---------------+----------------------------------------------------------------------+---------------+---------+
|
||||||
// | | | | (ExPaddingGapL) | | |
|
// | | | | (ExPaddingGapL) | | |
|
||||||
// | | | +-------------------------------------------------------------+--------+ | |
|
// | | | +-----------------------------+---------+--------+---------+-----------+ | |
|
||||||
// | | | | <itemName> |<status>| | |
|
// | | | | <itemName> |(HGapXxs)|<status>|(HGapXxs)|<checkmark>| | |
|
||||||
// | | | +-------------------------------------------------------------+--------+ | |
|
// | | | +-----------------------------+---------+--------+---------+-----------+ | |
|
||||||
// | | | | (VGapXxs) | | |
|
// | | | | (VGapXxs) | | |
|
||||||
// | | | +--------+--------+--------------+--------+--------+---------+---------+ | |
|
// | | | +--------+--------+--------------+--------+--------+---------+---------+ | |
|
||||||
// |(ExPaddingGapL)|<icon> |(ExPaddingGapL)|<vendor>|(HGapXs)|<divider>(h16)|(HGapXs)|<dlIcon>|(HGapXxs)|<dlCount>|(ExPaddingGapL)|(gapSize)|
|
// |(ExPaddingGapL)|<icon> |(ExPaddingGapL)|<vendor>|(HGapXs)|<divider>(h16)|(HGapXs)|<dlIcon>|(HGapXxs)|<dlCount>|(ExPaddingGapL)|(gapSize)|
|
||||||
@@ -116,6 +131,19 @@ public:
|
|||||||
const QRect itemNameR(x, y, middleColumnW, itemNameTF.lineHeight());
|
const QRect itemNameR(x, y, middleColumnW, itemNameTF.lineHeight());
|
||||||
const QString itemName = index.data().toString();
|
const QString itemName = index.data().toString();
|
||||||
|
|
||||||
|
const QSize checkmarkS(12, 12);
|
||||||
|
const QRect checkmarkR(x + middleColumnW - checkmarkS.width(), y,
|
||||||
|
checkmarkS.width(), checkmarkS.height());
|
||||||
|
const ExtensionState state = index.data(RoleExtensionState).value<ExtensionState>();
|
||||||
|
const QString stateString = extensionStateDisplayString(state);
|
||||||
|
const bool showState = (state == InstalledEnabled || state == InstalledDisabled)
|
||||||
|
&& !stateString.isEmpty();
|
||||||
|
const QFont stateFont = stateTF.font();
|
||||||
|
const QFontMetrics stateFM(stateFont);
|
||||||
|
const int stateStringWidth = stateFM.horizontalAdvance(stateString);
|
||||||
|
const QRect stateR(checkmarkR.x() - HGapXxs - stateStringWidth, y,
|
||||||
|
stateStringWidth, stateTF.lineHeight());
|
||||||
|
|
||||||
y += itemNameR.height() + VGapXxs;
|
y += itemNameR.height() + VGapXxs;
|
||||||
const QRect vendorRowR(x, y, middleColumnW, vendorRowHeight());
|
const QRect vendorRowR(x, y, middleColumnW, vendorRowHeight());
|
||||||
QRect vendorR = vendorRowR;
|
QRect vendorR = vendorRowR;
|
||||||
@@ -162,11 +190,22 @@ public:
|
|||||||
painter->drawText(smallCircle, countTF.drawTextFlags, QString::number(plugins.count()));
|
painter->drawText(smallCircle, countTF.drawTextFlags, QString::number(plugins.count()));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
QRect effectiveR = itemNameR;
|
||||||
|
if (showState)
|
||||||
|
effectiveR.setRight(stateR.left() - HGapXxs - 1);
|
||||||
painter->setPen(itemNameTF.color());
|
painter->setPen(itemNameTF.color());
|
||||||
painter->setFont(itemNameTF.font());
|
painter->setFont(itemNameTF.font());
|
||||||
const QString titleElided
|
const QString titleElided
|
||||||
= painter->fontMetrics().elidedText(itemName, Qt::ElideRight, itemNameR.width());
|
= painter->fontMetrics().elidedText(itemName, Qt::ElideRight, effectiveR.width());
|
||||||
painter->drawText(itemNameR, itemNameTF.drawTextFlags, titleElided);
|
painter->drawText(effectiveR, itemNameTF.drawTextFlags, titleElided);
|
||||||
|
}
|
||||||
|
if (showState) {
|
||||||
|
static const QIcon checkmark = Icon({{":/extensionmanager/images/checkmark.png",
|
||||||
|
stateTF.themeColor}}, Icon::Tint).icon();
|
||||||
|
checkmark.paint(painter, checkmarkR);
|
||||||
|
painter->setPen(stateTF.color());
|
||||||
|
painter->setFont(stateTF.font());
|
||||||
|
painter->drawText(stateR, stateTF.drawTextFlags, stateString);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
const QString vendor = index.data(RoleVendor).toString();
|
const QString vendor = index.data(RoleVendor).toString();
|
||||||
|
|||||||
@@ -358,6 +358,18 @@ static QVariant dataFromExtension(const Extension &extension, int role)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExtensionState extensionState(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
if (index.data(RoleItemType) != ItemTypeExtension)
|
||||||
|
return None;
|
||||||
|
|
||||||
|
const PluginSpec *ps = pluginSpecForName(index.data(RoleName).toString());
|
||||||
|
if (!ps)
|
||||||
|
return NotInstalled;
|
||||||
|
|
||||||
|
return ps->isEffectivelyEnabled() ? InstalledEnabled : InstalledDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
static QString searchText(const QModelIndex &index)
|
static QString searchText(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QStringList searchTexts;
|
QStringList searchTexts;
|
||||||
@@ -370,6 +382,8 @@ static QString searchText(const QModelIndex &index)
|
|||||||
|
|
||||||
QVariant ExtensionsModel::data(const QModelIndex &index, int role) const
|
QVariant ExtensionsModel::data(const QModelIndex &index, int role) const
|
||||||
{
|
{
|
||||||
|
if (role == RoleExtensionState)
|
||||||
|
return extensionState(index);
|
||||||
if (role == RoleSearchText)
|
if (role == RoleSearchText)
|
||||||
return searchText(index);
|
return searchText(index);
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,13 @@ enum ItemType {
|
|||||||
ItemTypeExtension,
|
ItemTypeExtension,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ExtensionState {
|
||||||
|
None, // Not a plugin
|
||||||
|
InstalledEnabled,
|
||||||
|
InstalledDisabled,
|
||||||
|
NotInstalled,
|
||||||
|
};
|
||||||
|
|
||||||
enum Role {
|
enum Role {
|
||||||
RoleName = Qt::UserRole,
|
RoleName = Qt::UserRole,
|
||||||
RoleCompatVersion,
|
RoleCompatVersion,
|
||||||
@@ -32,6 +39,7 @@ enum Role {
|
|||||||
RoleDescriptionLinks,
|
RoleDescriptionLinks,
|
||||||
RoleDescriptionText,
|
RoleDescriptionText,
|
||||||
RoleDownloadCount,
|
RoleDownloadCount,
|
||||||
|
RoleExtensionState,
|
||||||
RoleId,
|
RoleId,
|
||||||
RoleItemType,
|
RoleItemType,
|
||||||
RoleLicense,
|
RoleLicense,
|
||||||
|
|||||||
BIN
src/plugins/extensionmanager/images/checkmark.png
Normal file
BIN
src/plugins/extensionmanager/images/checkmark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 165 B |
BIN
src/plugins/extensionmanager/images/checkmark@2x.png
Normal file
BIN
src/plugins/extensionmanager/images/checkmark@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 286 B |
@@ -3886,6 +3886,26 @@
|
|||||||
d="m 67,422 h 12 m -6,-3.5 V 410 m -3,5.5 3,3 3.03461,-3"
|
d="m 67,422 h 12 m -6,-3.5 V 410 m -3,5.5 3,3 3.03461,-3"
|
||||||
sodipodi:nodetypes="ccccccc" />
|
sodipodi:nodetypes="ccccccc" />
|
||||||
</g>
|
</g>
|
||||||
|
<g
|
||||||
|
id="src/plugins/extensionmanager/images/checkmark">
|
||||||
|
<use
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
xlink:href="#backgroundRect_12"
|
||||||
|
id="use6279"
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
transform="translate(101,1)" />
|
||||||
|
<circle
|
||||||
|
id="path9935"
|
||||||
|
cx="71"
|
||||||
|
cy="431"
|
||||||
|
r="5" />
|
||||||
|
<path
|
||||||
|
style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round"
|
||||||
|
d="m 69,431 1.5,1.5 2.5,-3"
|
||||||
|
id="path10003" />
|
||||||
|
</g>
|
||||||
<g
|
<g
|
||||||
id="src/libs/utils/images/eyeoverlay">
|
id="src/libs/utils/images/eyeoverlay">
|
||||||
<use
|
<use
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 374 KiB After Width: | Height: | Size: 375 KiB |
Reference in New Issue
Block a user