From 385765ecddbb1e9d7f38cf313c3c6db6dc07be52 Mon Sep 17 00:00:00 2001 From: LostDragonist Date: Mon, 23 Jul 2018 14:13:12 -0500 Subject: Truncate strings longer than 1024 characters in the plugin list tooltip --- src/pluginlist.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 58364e78..76de436d 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -72,6 +72,15 @@ static bool ByDate(const PluginList::ESPInfo& LHS, const PluginList::ESPInfo& RH return QFileInfo(LHS.m_FullPath).lastModified() < QFileInfo(RHS.m_FullPath).lastModified(); } +static QString TruncateString(const QString& text) { + QString new_text = text; + if (new_text.length() > 1024) { + new_text.truncate(1024); + new_text += "..."; + } + return new_text; +} + PluginList::PluginList(QObject *parent) : QAbstractItemModel(parent) , m_FontMetrics(QFont()) @@ -187,7 +196,7 @@ void PluginList::refresh(const QString &profileName bool hasIni = baseDirectory.findFile(ToWString(iniPath)).get() != nullptr; std::set loadedArchives; - QString originPath = QString::fromWCharArray(origin.getPath().c_str()); + QString originPath = QString::fromWCharArray(origin.getPath().c_str()); QDir dir(QDir::toNativeSeparators(originPath)); for (QString filename : dir.entryList(QStringList() << QFileInfo(filename).baseName() + "*.bsa" << QFileInfo(filename).baseName() + "*.ba2")) { loadedArchives.insert(filename); @@ -887,23 +896,23 @@ QVariant PluginList::data(const QModelIndex &modelIndex, int role) const } else { QString text = tr("Origin: %1").arg(m_ESPs[index].m_OriginName); if (m_ESPs[index].m_Author.size() > 0) { - text += "
" + tr("Author") + ": " + m_ESPs[index].m_Author; + text += "
" + tr("Author") + ": " + TruncateString(m_ESPs[index].m_Author); } if (m_ESPs[index].m_Description.size() > 0) { - text += "
" + tr("Description") + ": " + m_ESPs[index].m_Description; + text += "
" + tr("Description") + ": " + TruncateString(m_ESPs[index].m_Description); } if (m_ESPs[index].m_MasterUnset.size() > 0) { - text += "
" + tr("Missing Masters") + ": " + SetJoin(m_ESPs[index].m_MasterUnset, ", ") + ""; + text += "
" + tr("Missing Masters") + ": " + TruncateString(SetJoin(m_ESPs[index].m_MasterUnset, ", ")) + ""; } std::set enabledMasters; std::set_difference(m_ESPs[index].m_Masters.begin(), m_ESPs[index].m_Masters.end(), m_ESPs[index].m_MasterUnset.begin(), m_ESPs[index].m_MasterUnset.end(), std::inserter(enabledMasters, enabledMasters.end())); if (!enabledMasters.empty()) { - text += "
" + tr("Enabled Masters") + ": " + SetJoin(enabledMasters, ", "); + text += "
" + tr("Enabled Masters") + ": " + TruncateString(SetJoin(enabledMasters, ", ")); } if (!m_ESPs[index].m_Archives.empty()) { - text += "
" + tr("Loads Archives") + ": " + SetJoin(m_ESPs[index].m_Archives, ", "); + text += "
" + tr("Loads Archives") + ": " + TruncateString(SetJoin(m_ESPs[index].m_Archives, ", ")); text += "
" + tr("There are Archives connected to this plugin. " "Their assets will be added to your game, overwriting in case of conflicts following the plugin order. " "Loose files will always overwrite assets from Archives. (This flag only checks for Archives from the same mod as the plugin)"); -- cgit v1.3.1