Restyling of log viewer

Now the entries have icons telling the type of message.
This is more convenient when multi-line messages are
encountered.
This commit is contained in:
Matthias Koefferlein 2017-03-21 12:18:09 +01:00
parent 334fca3f76
commit 10345eea73
8 changed files with 35 additions and 12 deletions

View File

@ -88,12 +88,24 @@
</item>
<item row="1" column="0" colspan="6">
<widget class="QListView" name="log_view">
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="isWrapping" stdset="0">
<bool>false</bool>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="uniformItemSizes">
<bool>true</bool>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="2">
@ -157,7 +169,7 @@
<string/>
</property>
<property name="pixmap">
<pixmap resource="layResources.qrc">:/warn.png</pixmap>
<pixmap resource="layResources.qrc">:/warn_16.png</pixmap>
</property>
</widget>
</item>

BIN
src/lay/images/empty_16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

BIN
src/lay/images/error_16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

BIN
src/lay/images/info_16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

BIN
src/lay/images/warn_16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 637 B

View File

@ -233,18 +233,25 @@ LogFile::data(const QModelIndex &index, int role) const
{
QMutexLocker locker (&m_lock);
if (role == Qt::DisplayRole) {
if (role == Qt::DecorationRole) {
if (index.row () < int (m_messages.size ()) && index.row () >= 0) {
LogFileEntry::mode_type mode = m_messages [index.row ()].mode ();
std::string message = m_messages [index.row ()].text ();
if (mode == LogFileEntry::Error) {
return QVariant (tl::to_qstring (tl::to_string (QObject::tr ("ERROR: ")) + message));
return QIcon (QString::fromUtf8 (":/error_16.png"));
} else if (mode == LogFileEntry::Warning) {
return QVariant (tl::to_qstring (tl::to_string (QObject::tr ("Warning: ")) + message));
return QIcon (QString::fromUtf8 (":/warn_16.png"));
} else if (mode == LogFileEntry::Info) {
return QIcon (QString::fromUtf8 (":/info_16.png"));
} else {
return QVariant (tl::to_qstring (message));
return QIcon (QString::fromUtf8 (":/empty_16.png"));
}
}
} else if (role == Qt::DisplayRole) {
if (index.row () < int (m_messages.size ()) && index.row () >= 0) {
return QVariant (tl::to_qstring (m_messages [index.row ()].text ()));
}
} else if (role == Qt::FontRole) {

View File

@ -116,6 +116,10 @@
<file alias="salt.png">images/salt.png</file>
<file alias="salt_icon.png">images/salt_icon.png</file>
<file alias="warn.png">images/warn.png</file>
<file alias="warn_16.png">images/warn_16.png</file>
<file alias="empty_16.png">images/empty_16.png</file>
<file alias="error_16.png">images/error_16.png</file>
<file alias="info_16.png">images/info_16.png</file>
</qresource>
<qresource prefix="/syntax">
<file alias="ruby.xml">syntax/ruby.xml</file>

View File

@ -519,8 +519,8 @@ SaltGrainPropertiesDialog::accept ()
if (! SaltGrain::valid_name (d->name)) {
dependencies_alert->error () << tr ("'%1' is not a valid package name").arg (tl::to_qstring (d->name)) << tl::endl
<< tr ("Valid package names are words (letters, digits, underscores)") << tl::endl
<< tr ("Package groups can be specified in the form 'group/package'");
<< tr ("Valid package names are words (letters, digits, underscores).") << tl::endl
<< tr ("Package groups can be specified in the form 'group/package'.");
continue;
}
@ -539,20 +539,20 @@ SaltGrainPropertiesDialog::accept ()
dep.check_circular (dep.grain_for_name (m_grain.name ()), dep.grain_for_name (d->name));
} catch (tl::Exception &ex) {
dependencies_alert->error () << ex.msg () << tl::endl
<< tr ("Circular dependency means a package is eventually depending on itself.");
<< tr ("Circular dependency means, a package is eventually depending on itself.");
}
}
if (d->version.empty ()) {
dependencies_alert->warn () << tr ("No version specified for dependency '%1'").arg (tl::to_qstring (d->name)) << tl::endl
<< tr ("Versions help checking dependencies.") << tl::endl
<< tr ("If the dependency package has a version itself, the version is automatically set to it's current version");
<< tr ("Please consider giving a version here. Versions help deciding whether a package needs to be updated.") << tl::endl
<< tr ("If the dependency package has a version itself, the version is automatically set to it's current version.");
}
if (d->url.empty ()) {
dependencies_alert->warn () << tr ("No download URL specified for dependency '%1'").arg (tl::to_qstring (d->name)) << tl::endl
<< tr ("A download URL should be specified to ensure the package dependencies can be resolved.") << tl::endl
<< tr ("If the dependency package was downloaded itself, the URL is automatically set to the download source");
<< tr ("If the dependency package was downloaded itself, the URL is automatically set to the download source.");
} else {
std::string spec_url = SaltGrain::spec_url (d->url);
tl::InputHttpStream stream (spec_url);