Commit f9553ab1 authored by Agata Cacko's avatar Agata Cacko
Browse files

Show display names in Color Management -> Display

Before this commit, user would have to figure out on their
own which display is which. Because of a bug in the system
assigning color profiles to displays, the automatic way doesn't
always work so the user needs to assign color profiles on their own.
Before this commit the dialog only showed "Screen 1, Screen 2".
This commit adds following information:
- name
- if model is not null, add model; if it is null, add manufacturer info
- resolution
It is also shortened so the maximum length is 25 characters.

CCBUG:412943
parent fd116fc4
......@@ -44,6 +44,8 @@
#include <QFileDialog>
#include <QFormLayout>
#include <QSettings>
#include <QStyleFactory>
#include <QScreen>
#include <KisDocument.h>
#include <KoColorProfile.h>
......@@ -94,6 +96,39 @@
#include "config-high-dpi-scale-factor-rounding-policy.h"
#endif
QString shortNameOfDisplay(QScreen* screen)
{
// Depending on the display, all of those properties might be
// or might not be useful
// Example:
// Screen: 0
// Name: eDP-1
// Manufacturer: BOE
// Model:
// Screen: 1
// Name: DP-2
// Manufacturer: Toshiba America Info Systems Inc
// Model: TOSHIBA-TV-
// In the first case, model is empty, manufacturer is BOE
// The second case model is more useful than manufacturer because it's short
// and it gives basically the same amount of information
QString name = screen->name();
QString model = screen->model();
QString manufacturer = screen->manufacturer();
QString resolution = QString::number(screen->geometry().width()).append("x").append(QString::number(screen->geometry().height()));
QString shortName = name + " ";
if (!model.isEmpty()) {
shortName += model;
} else {
shortName += manufacturer;
}
shortName = shortName.left(15);
shortName = shortName.append(" ").append(resolution);
return shortName;
}
struct BackupSuffixValidator : public QValidator {
BackupSuffixValidator(QObject *parent)
: QValidator(parent)
......@@ -535,7 +570,8 @@ ColorSettingsTab::ColorSettingsTab(QWidget *parent, const char *name)
QFormLayout *monitorProfileGrid = new QFormLayout(m_page->monitorprofileholder);
for(int i = 0; i < QGuiApplication::screens().count(); ++i) {
QLabel *lbl = new QLabel(i18nc("The number of the screen", "Screen %1:", i + 1));
QScreen* screen = QGuiApplication::screens()[i];
QLabel *lbl = new QLabel(i18nc("The number of the screen (ordinal) and shortened 'name' of the screen (model + resolution)", "Screen %1 (%2):", i + 1, shortNameOfDisplay(screen)));
m_monitorProfileLabels << lbl;
KisSqueezedComboBox *cmb = new KisSqueezedComboBox();
cmb->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
......@@ -642,8 +678,9 @@ void ColorSettingsTab::toggleAllowMonitorProfileSelection(bool useSystemProfile)
for(int i = 0; i < QApplication::screens().count(); ++i) {
m_monitorProfileWidgets[i]->clear();
QString monitorForScreen = cfg.monitorForScreen(i, devices[i]);
QScreen* screen = QGuiApplication::screens()[i];
Q_FOREACH (const QString &device, devices) {
m_monitorProfileLabels[i]->setText(i18nc("The display/screen we got from Qt", "Screen %1:", i + 1));
m_monitorProfileLabels[i]->setText(i18nc("The number of the screen (ordinal) and shortened 'name' of the screen (model + resolution)", "Screen %1 (%2):", i + 1, shortNameOfDisplay(screen)));
m_monitorProfileWidgets[i]->addSqueezedItem(KisColorManager::instance()->deviceName(device), device);
if (devices[i] == monitorForScreen) {
m_monitorProfileWidgets[i]->setCurrentIndex(i);
......@@ -719,7 +756,8 @@ void ColorSettingsTab::refillMonitorProfiles(const KoID & colorSpaceId)
}
for (int i = 0; i < QApplication::screens().count(); ++i) {
m_monitorProfileLabels[i]->setText(i18nc("The number of the screen", "Screen %1:", i + 1));
QScreen* screen = QGuiApplication::screens()[i];
m_monitorProfileLabels[i]->setText(i18nc("The number of the screen (ordinal) and shortened 'name' of the screen (model + resolution)", "Screen %1 (%2):", i + 1, shortNameOfDisplay(screen)));
m_monitorProfileWidgets[i]->setCurrent(KoColorSpaceRegistry::instance()->defaultProfileForColorSpace(colorSpaceId.id()));
}
}
......
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