Changeset View
Changeset View
Standalone View
Standalone View
dialogs/kpColorSimilarityDialog.cpp
Show All 39 Lines | |||||
40 | #include <QLayout> | 40 | #include <QLayout> | ||
41 | #include <QPushButton> | 41 | #include <QPushButton> | ||
42 | #include <QWhatsThis> | 42 | #include <QWhatsThis> | ||
43 | 43 | | |||
44 | kpColorSimilarityDialog::kpColorSimilarityDialog (QWidget *parent) | 44 | kpColorSimilarityDialog::kpColorSimilarityDialog (QWidget *parent) | ||
45 | : QDialog (parent) | 45 | : QDialog (parent) | ||
46 | { | 46 | { | ||
47 | setWindowTitle (i18nc ("@title:window", "Color Similarity")); | 47 | setWindowTitle (i18nc ("@title:window", "Color Similarity")); | ||
48 | QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | | 48 | auto *buttons = new QDialogButtonBox (QDialogButtonBox::Ok | | ||
49 | QDialogButtonBox::Cancel, this); | 49 | QDialogButtonBox::Cancel, this); | ||
50 | connect (buttons, &QDialogButtonBox::accepted, this, &kpColorSimilarityDialog::accept); | 50 | connect (buttons, &QDialogButtonBox::accepted, this, &kpColorSimilarityDialog::accept); | ||
51 | connect (buttons, &QDialogButtonBox::rejected, this, &kpColorSimilarityDialog::reject); | 51 | connect (buttons, &QDialogButtonBox::rejected, this, &kpColorSimilarityDialog::reject); | ||
52 | 52 | | |||
53 | QWidget *baseWidget = new QWidget (this); | 53 | auto *baseWidget = new QWidget (this); | ||
54 | 54 | | |||
55 | QVBoxLayout *dialogLayout = new QVBoxLayout (this); | 55 | auto *dialogLayout = new QVBoxLayout (this); | ||
56 | dialogLayout->addWidget (baseWidget); | 56 | dialogLayout->addWidget (baseWidget); | ||
57 | dialogLayout->addWidget (buttons); | 57 | dialogLayout->addWidget (buttons); | ||
58 | 58 | | |||
59 | QGroupBox *cubeGroupBox = new QGroupBox (i18n ("Preview"), baseWidget); | 59 | auto *cubeGroupBox = new QGroupBox (i18n ("Preview"), baseWidget); | ||
60 | 60 | | |||
61 | m_colorSimilarityFrame = new kpColorSimilarityFrame(cubeGroupBox); | 61 | m_colorSimilarityFrame = new kpColorSimilarityFrame(cubeGroupBox); | ||
62 | m_colorSimilarityFrame->setMinimumSize (240, 180); | 62 | m_colorSimilarityFrame->setMinimumSize (240, 180); | ||
63 | 63 | | |||
64 | QPushButton *updatePushButton = new QPushButton (i18n ("&Update"), cubeGroupBox); | 64 | auto *updatePushButton = new QPushButton (i18n ("&Update"), cubeGroupBox); | ||
65 | 65 | | |||
66 | 66 | | |||
67 | QVBoxLayout *cubeLayout = new QVBoxLayout (cubeGroupBox); | 67 | auto *cubeLayout = new QVBoxLayout (cubeGroupBox); | ||
68 | cubeLayout->addWidget (m_colorSimilarityFrame, 1/*stretch*/); | 68 | cubeLayout->addWidget (m_colorSimilarityFrame, 1/*stretch*/); | ||
69 | cubeLayout->addWidget (updatePushButton, 0/*stretch*/, Qt::AlignHCenter); | 69 | cubeLayout->addWidget (updatePushButton, 0/*stretch*/, Qt::AlignHCenter); | ||
70 | 70 | | |||
71 | 71 | | |||
72 | connect (updatePushButton, &QPushButton::clicked, | 72 | connect (updatePushButton, &QPushButton::clicked, | ||
73 | this, &kpColorSimilarityDialog::slotColorSimilarityValueChanged); | 73 | this, &kpColorSimilarityDialog::slotColorSimilarityValueChanged); | ||
74 | 74 | | |||
75 | 75 | | |||
76 | QGroupBox *inputGroupBox = new QGroupBox (i18n ("&RGB Color Cube Distance"), | 76 | auto *inputGroupBox = new QGroupBox (i18n ("&RGB Color Cube Distance"), | ||
77 | baseWidget); | 77 | baseWidget); | ||
78 | 78 | | |||
79 | m_colorSimilarityInput = new kpIntNumInput (inputGroupBox); | 79 | m_colorSimilarityInput = new kpIntNumInput (inputGroupBox); | ||
80 | m_colorSimilarityInput->setRange (0, int (kpColorSimilarityHolder::MaxColorSimilarity * 100 + 0.1/*don't floor below target int*/), | 80 | m_colorSimilarityInput->setRange (0, int (kpColorSimilarityHolder::MaxColorSimilarity * 100 + 0.1/*don't floor below target int*/), | ||
81 | 5/*step*/); | 81 | 5/*step*/); | ||
82 | m_colorSimilarityInput->setSuffix (i18n ("%")); | 82 | m_colorSimilarityInput->setSuffix (i18n ("%")); | ||
83 | m_colorSimilarityInput->setSpecialValueText (i18n ("Exact Match")); | 83 | m_colorSimilarityInput->setSpecialValueText (i18n ("Exact Match")); | ||
84 | 84 | | |||
85 | // TODO: We have a good handbook section on this, which we should | 85 | // TODO: We have a good handbook section on this, which we should | ||
86 | // somehow link to. | 86 | // somehow link to. | ||
87 | m_whatIsLabel = new QLabel ( | 87 | m_whatIsLabel = new QLabel ( | ||
88 | i18n ("<a href=\"dummy_to_make_link_clickable\">" | 88 | i18n ("<a href=\"dummy_to_make_link_clickable\">" | ||
89 | "What is Color Similarity?</a>"), | 89 | "What is Color Similarity?</a>"), | ||
90 | inputGroupBox); | 90 | inputGroupBox); | ||
91 | m_whatIsLabel->setAlignment (Qt::AlignHCenter); | 91 | m_whatIsLabel->setAlignment (Qt::AlignHCenter); | ||
92 | connect (m_whatIsLabel, &QLabel::linkActivated, | 92 | connect (m_whatIsLabel, &QLabel::linkActivated, | ||
93 | this, &kpColorSimilarityDialog::slotWhatIsLabelClicked); | 93 | this, &kpColorSimilarityDialog::slotWhatIsLabelClicked); | ||
94 | 94 | | |||
95 | 95 | | |||
96 | QVBoxLayout *inputLayout = new QVBoxLayout (inputGroupBox); | 96 | auto *inputLayout = new QVBoxLayout (inputGroupBox); | ||
97 | 97 | | |||
98 | inputLayout->addWidget (m_colorSimilarityInput); | 98 | inputLayout->addWidget (m_colorSimilarityInput); | ||
99 | inputLayout->addWidget (m_whatIsLabel); | 99 | inputLayout->addWidget (m_whatIsLabel); | ||
100 | 100 | | |||
101 | 101 | | |||
102 | // COMPAT: This is not firing properly when the user is typing in a | 102 | // COMPAT: This is not firing properly when the user is typing in a | ||
103 | // new value. | 103 | // new value. | ||
104 | connect (m_colorSimilarityInput, &kpIntNumInput::valueChanged, | 104 | connect (m_colorSimilarityInput, &kpIntNumInput::valueChanged, | ||
105 | this, &kpColorSimilarityDialog::slotColorSimilarityValueChanged); | 105 | this, &kpColorSimilarityDialog::slotColorSimilarityValueChanged); | ||
106 | 106 | | |||
107 | 107 | | |||
108 | QVBoxLayout *baseLayout = new QVBoxLayout (baseWidget); | 108 | auto *baseLayout = new QVBoxLayout (baseWidget); | ||
109 | baseLayout->setMargin (0); | 109 | baseLayout->setMargin (0); | ||
110 | baseLayout->addWidget (cubeGroupBox, 1/*stretch*/); | 110 | baseLayout->addWidget (cubeGroupBox, 1/*stretch*/); | ||
111 | baseLayout->addWidget (inputGroupBox); | 111 | baseLayout->addWidget (inputGroupBox); | ||
112 | } | 112 | } | ||
113 | 113 | | |||
114 | kpColorSimilarityDialog::~kpColorSimilarityDialog () | 114 | kpColorSimilarityDialog::~kpColorSimilarityDialog () = default; | ||
115 | { | | |||
116 | } | | |||
117 | 115 | | |||
118 | 116 | | |||
119 | // public | 117 | // public | ||
120 | double kpColorSimilarityDialog::colorSimilarity () const | 118 | double kpColorSimilarityDialog::colorSimilarity () const | ||
121 | { | 119 | { | ||
122 | return m_colorSimilarityFrame->colorSimilarity (); | 120 | return m_colorSimilarityFrame->colorSimilarity (); | ||
123 | } | 121 | } | ||
124 | 122 | | |||
Show All 19 Lines |