aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Jenssen <tim.jenssen@qt.io>2020-10-12 09:10:39 +0200
committerTim Jenssen <tim.jenssen@qt.io>2020-10-12 07:27:57 +0000
commitddb078404ade5492a8683af4885b173263d447d8 (patch)
tree12cf86988ab4b362e69a097c83a9b46b2775c522
parentd674548040799515a33518e5dcef51c0796dd7cf (diff)
qmlpreview: add test translation color settings
Change-Id: I9b11fcf1fdae39b089887884a3d96cc8648a0c8a Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
-rw-r--r--src/plugins/qmlpreview/qmldebugtranslationwidget.cpp62
-rw-r--r--src/plugins/qmlpreview/qmldebugtranslationwidget.h7
2 files changed, 67 insertions, 2 deletions
diff --git a/src/plugins/qmlpreview/qmldebugtranslationwidget.cpp b/src/plugins/qmlpreview/qmldebugtranslationwidget.cpp
index 7c0cd3861f..72842eb33d 100644
--- a/src/plugins/qmlpreview/qmldebugtranslationwidget.cpp
+++ b/src/plugins/qmlpreview/qmldebugtranslationwidget.cpp
@@ -38,6 +38,7 @@
#include <utils/outputformatter.h>
#include <utils/utilsicons.h>
#include <utils/fileutils.h>
+#include <utils/qtcolorbutton.h>
#include <extensionsystem/pluginmanager.h>
#include <extensionsystem/pluginspec.h>
@@ -94,6 +95,11 @@ namespace QmlPreview {
QmlDebugTranslationWidget::QmlDebugTranslationWidget(QWidget *parent, TestLanguageGetter languagesGetterMethod)
: QWidget(parent)
, m_testLanguagesGetter(languagesGetterMethod)
+ , m_warningColor(Qt::red)
+ //, m_foundTrColor(Qt::green) // invalid color -> init without the frame
+ , m_lastWarningColor(m_warningColor)
+ , m_lastfoundTrColor(Qt::green)
+
{
auto mainLayout = new QVBoxLayout(this);
@@ -121,12 +127,54 @@ QmlDebugTranslationWidget::QmlDebugTranslationWidget(QWidget *parent, TestLangua
m_selectLanguageLayout = new QHBoxLayout;
mainLayout->addLayout(m_selectLanguageLayout);
+ auto settingsLayout = new QHBoxLayout();
+ mainLayout->addLayout(settingsLayout);
+
auto elideWarningCheckBox = new QCheckBox(tr("Enable elide warning"));
- layout()->addWidget(elideWarningCheckBox);
connect(elideWarningCheckBox, &QCheckBox::stateChanged, [this] (int state) {
m_elideWarning = (state == Qt::Checked);
-
});
+ settingsLayout->addWidget(elideWarningCheckBox);
+
+ auto warningColorCheckbox = new QCheckBox(tr("select Warning color: "));
+ settingsLayout->addWidget(warningColorCheckbox);
+ auto warningColorButton = new Utils::QtColorButton();
+ connect(warningColorCheckbox, &QCheckBox::stateChanged, [warningColorButton, this] (int state) {
+ if (state == Qt::Checked) {
+ warningColorButton->setColor(m_lastWarningColor);
+ warningColorButton->setEnabled(true);
+ } else {
+ m_lastWarningColor = warningColorButton->color();
+ warningColorButton->setColor({});
+ warningColorButton->setEnabled(false);
+ }
+ });
+ connect(warningColorButton, &Utils::QtColorButton::colorChanged, [this](const QColor &color) {
+ m_warningColor = color;
+ });
+ warningColorCheckbox->setCheckState(Qt::Checked);
+ settingsLayout->addWidget(warningColorButton);
+
+ auto foundTrColorCheckbox = new QCheckBox(tr("select found 'tr' color: "));
+ settingsLayout->addWidget(foundTrColorCheckbox);
+ auto foundTrColorButton = new Utils::QtColorButton();
+ foundTrColorButton->setDisabled(true);
+ connect(foundTrColorCheckbox, &QCheckBox::stateChanged, [foundTrColorButton, this] (int state) {
+ if (state == Qt::Checked) {
+ foundTrColorButton->setColor(m_lastfoundTrColor);
+ foundTrColorButton->setEnabled(true);
+ } else {
+ m_lastfoundTrColor = foundTrColorButton->color();
+ foundTrColorButton->setColor({});
+ foundTrColorButton->setEnabled(false);
+ }
+ });
+ connect(foundTrColorButton, &Utils::QtColorButton::colorChanged, [this](const QColor &color) {
+ m_foundTrColor = color;
+ });
+ settingsLayout->addWidget(foundTrColorButton);
+
+ settingsLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding));
auto controlLayout = new QHBoxLayout;
mainLayout->addLayout(controlLayout);
@@ -232,6 +280,16 @@ void QmlDebugTranslationWidget::updateStartupProjectTranslations()
updateCurrentTranslations(ProjectExplorer::SessionManager::startupProject());
}
+QColor QmlDebugTranslationWidget::warningColor()
+{
+ return m_warningColor;
+}
+
+QColor QmlDebugTranslationWidget::foundTrColor()
+{
+ return m_foundTrColor;
+}
+
void QmlDebugTranslationWidget::updateCurrentTranslations(ProjectExplorer::Project *project)
{
m_testLanguages.clear();
diff --git a/src/plugins/qmlpreview/qmldebugtranslationwidget.h b/src/plugins/qmlpreview/qmldebugtranslationwidget.h
index 7ea0760ac0..de0c7ba362 100644
--- a/src/plugins/qmlpreview/qmldebugtranslationwidget.h
+++ b/src/plugins/qmlpreview/qmldebugtranslationwidget.h
@@ -63,6 +63,9 @@ public:
void setCurrentFile(const Utils::FilePath &filepath);
void setFiles(const Utils::FilePaths &filePathes);
void updateStartupProjectTranslations();
+
+ QColor warningColor();
+ QColor foundTrColor();
private:
void updateCurrentEditor(const Core::IEditor *editor);
void updateCurrentTranslations(ProjectExplorer::Project *project);
@@ -98,6 +101,10 @@ private:
QHBoxLayout *m_selectLanguageLayout;
TestLanguageGetter m_testLanguagesGetter;
+ QColor m_warningColor;
+ QColor m_foundTrColor;
+ QColor m_lastWarningColor;
+ QColor m_lastfoundTrColor;
};
} // namespace QmlPreview