Commit e0429552 authored by Elvis Angelaccio's avatar Elvis Angelaccio

Fix non-resizable infopanel when symlinks have a long target

When a symbolic link points to an entry with a long filename, the infopanel
takes almost all available horizontal space and, even worse, cannot be resized.

This is because there is a single QLabel with a multi-line text, one of which
is the symlink's target. This patch replaces this label with a vertical
layout containing different labels. The targetLabel is now a KSqueezedTextLabel so
that a long target name won't mess up anymore the infopanel size.

BUG: 363719
FIXED-IN: 16.08.0

Differential Revision: D1728
parent 27e5167b
......@@ -129,8 +129,7 @@ void InfoPanel::setIndex(const QModelIndex& index)
const QString name = (nameParts.count() > 0) ? nameParts.last() : entry[ FileName ].toString();
fileName->setText(name);
metadataLabel->setText(metadataTextFor(index));
showMetaData();
showMetaDataFor(index);
}
}
......@@ -156,19 +155,20 @@ void InfoPanel::setIndexes(const QModelIndexList &list)
void InfoPanel::showMetaData()
{
m_separator->show();
metadataLabel->show();
m_metaDataWidget->show();
}
void InfoPanel::hideMetaData()
{
m_separator->hide();
metadataLabel->hide();
m_metaDataWidget->hide();
}
QString InfoPanel::metadataTextFor(const QModelIndex &index)
void InfoPanel::showMetaDataFor(const QModelIndex &index)
{
showMetaData();
const ArchiveEntry& entry = m_model->entryForIndex(index);
QString text;
QMimeDatabase db;
QMimeType mimeType;
......@@ -179,23 +179,33 @@ QString InfoPanel::metadataTextFor(const QModelIndex &index)
mimeType = db.mimeTypeForFile(entry[FileName].toString(), QMimeDatabase::MatchExtension);
}
text += i18n("<b>Type:</b> %1<br/>", mimeType.comment());
m_typeLabel->setText(i18n("<b>Type:</b> %1", mimeType.comment()));
if (entry.contains(Owner)) {
text += i18n("<b>Owner:</b> %1<br/>", entry[ Owner ].toString());
m_ownerLabel->show();
m_ownerLabel->setText(i18n("<b>Owner:</b> %1", entry[Owner].toString()));
} else {
m_ownerLabel->hide();
}
if (entry.contains(Group)) {
text += i18n("<b>Group:</b> %1<br/>", entry[ Group ].toString());
m_groupLabel->show();
m_groupLabel->setText(i18n("<b>Group:</b> %1", entry[Group].toString()));
} else {
m_groupLabel->hide();
}
if (entry.contains(Link)) {
text += i18n("<b>Target:</b> %1<br/>", entry[ Link ].toString());
m_targetLabel->show();
m_targetLabel->setText(i18n("<b>Target:</b> %1", entry[Link].toString()));
} else {
m_targetLabel->hide();
}
if (entry.contains(IsPasswordProtected) && entry[ IsPasswordProtected ].toBool()) {
text += i18n("<b>Password protected:</b> Yes<br/>");
m_passwordLabel->show();
m_passwordLabel->setText(i18n("<b>Password protected:</b> Yes"));
} else {
m_passwordLabel->hide();
}
return text;
}
......@@ -64,7 +64,7 @@ private:
void showMetaData();
void hideMetaData();
QString metadataTextFor(const QModelIndex &);
void showMetaDataFor(const QModelIndex &index);
ArchiveModel *m_model;
QString m_prettyFileName;
......
......@@ -79,19 +79,44 @@
</widget>
</item>
<item>
<widget class="QLabel" name="metadataLabel">
<property name="text">
<string>Metadata Label</string>
</property>
<property name="margin">
<number>10</number>
</property>
<property name="indent">
<number>20</number>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
<widget class="QWidget" name="m_metaDataWidget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="m_typeLabel">
<property name="text">
<string notr="true">Type</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_ownerLabel">
<property name="text">
<string notr="true">Owner</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_groupLabel">
<property name="text">
<string notr="true">Group</string>
</property>
</widget>
</item>
<item>
<widget class="KSqueezedTextLabel" name="m_targetLabel">
<property name="text">
<string notr="true">Target</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="m_passwordLabel">
<property name="text">
<string notr="true">Password</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
......
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