Verified Commit 050c1a7e authored by ivan tkachenko's avatar ivan tkachenko
Browse files

kcm: Show connector name for monitors with identical everything

See also: kwin!2922

BUG: 450344
parent fd290ca3
Pipeline #230050 passed with stage
in 1 minute and 3 seconds
......@@ -10,12 +10,12 @@
#include <KLocalizedString>
QString Utils::outputName(const KScreen::OutputPtr &output, bool shouldShowSerialNumber)
QString Utils::outputName(const KScreen::OutputPtr &output, bool shouldShowSerialNumber, bool shouldShowConnector)
{
return outputName(output.data(), shouldShowSerialNumber);
return outputName(output.data(), shouldShowSerialNumber, shouldShowConnector);
}
QString Utils::outputName(const KScreen::Output *output, bool shouldShowSerialNumber)
QString Utils::outputName(const KScreen::Output *output, bool shouldShowSerialNumber, bool shouldShowConnector)
{
if (output->type() == KScreen::Output::Panel) {
return i18n("Built-in Screen");
......@@ -32,7 +32,10 @@ QString Utils::outputName(const KScreen::Output *output, bool shouldShowSerialNu
name += output->edid()->name() + QLatin1Char(' ');
}
if (!output->edid()->serial().isEmpty() && shouldShowSerialNumber) {
name += output->edid()->serial();
name += output->edid()->serial() + QLatin1Char(' ');
}
if (shouldShowConnector) {
name += output->typeName();
}
if (!name.trimmed().isEmpty()) {
return name;
......
......@@ -15,8 +15,8 @@
namespace Utils
{
QString outputName(const KScreen::Output *output, bool shouldShowSerialNumber = false);
QString outputName(const KScreen::OutputPtr &output, bool shouldShowSerialNumber = false);
QString outputName(const KScreen::Output *output, bool shouldShowSerialNumber = false, bool shouldShowConnector = false);
QString outputName(const KScreen::OutputPtr &output, bool shouldShowSerialNumber = false, bool shouldShowConnector = false);
QString sizeToString(const QSize &size);
}
......
......@@ -36,15 +36,18 @@ QVariant OutputModel::data(const QModelIndex &index, int role) const
const KScreen::OutputPtr &output = m_outputs[index.row()].ptr;
switch (role) {
case Qt::DisplayRole: {
bool shouldShowSerialNumber = false;
if (output->edid()) {
shouldShowSerialNumber = std::any_of(m_outputs.cbegin(), m_outputs.cend(), [output](const OutputModel::Output &other) {
const bool shouldShowSerialNumber = std::any_of(m_outputs.cbegin(), m_outputs.cend(), [output](const OutputModel::Output &other) {
return other.ptr->id() != output->id() // avoid same output
&& other.ptr->edid() && output->edid() //
&& other.ptr->edid()->vendor() == output->edid()->vendor() //
&& other.ptr->edid()->name() == output->edid()->name(); // model
});
const bool shouldShowConnector =
shouldShowSerialNumber && std::any_of(m_outputs.cbegin(), m_outputs.cend(), [output](const OutputModel::Output &other) {
return other.ptr->id() != output->id() // avoid same output
&& other.ptr->edid() && other.ptr->edid()->name() == output->edid()->name() // model
&& other.ptr->edid()->vendor() == output->edid()->vendor();
&& other.ptr->edid()->serial() == output->edid()->serial();
});
}
return Utils::outputName(output, shouldShowSerialNumber);
return Utils::outputName(output, shouldShowSerialNumber, shouldShowConnector);
}
case EnabledRole:
return output->isEnabled();
......
Supports Markdown
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