forked from qt-creator/qt-creator
qmlpreview: add test translation color settings
Change-Id: I9b11fcf1fdae39b089887884a3d96cc8648a0c8a Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -38,6 +38,7 @@
|
|||||||
#include <utils/outputformatter.h>
|
#include <utils/outputformatter.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
#include <utils/qtcolorbutton.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <extensionsystem/pluginspec.h>
|
#include <extensionsystem/pluginspec.h>
|
||||||
@@ -94,6 +95,11 @@ namespace QmlPreview {
|
|||||||
QmlDebugTranslationWidget::QmlDebugTranslationWidget(QWidget *parent, TestLanguageGetter languagesGetterMethod)
|
QmlDebugTranslationWidget::QmlDebugTranslationWidget(QWidget *parent, TestLanguageGetter languagesGetterMethod)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, m_testLanguagesGetter(languagesGetterMethod)
|
, 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);
|
auto mainLayout = new QVBoxLayout(this);
|
||||||
|
|
||||||
@@ -121,12 +127,54 @@ QmlDebugTranslationWidget::QmlDebugTranslationWidget(QWidget *parent, TestLangua
|
|||||||
m_selectLanguageLayout = new QHBoxLayout;
|
m_selectLanguageLayout = new QHBoxLayout;
|
||||||
mainLayout->addLayout(m_selectLanguageLayout);
|
mainLayout->addLayout(m_selectLanguageLayout);
|
||||||
|
|
||||||
|
auto settingsLayout = new QHBoxLayout();
|
||||||
|
mainLayout->addLayout(settingsLayout);
|
||||||
|
|
||||||
auto elideWarningCheckBox = new QCheckBox(tr("Enable elide warning"));
|
auto elideWarningCheckBox = new QCheckBox(tr("Enable elide warning"));
|
||||||
layout()->addWidget(elideWarningCheckBox);
|
|
||||||
connect(elideWarningCheckBox, &QCheckBox::stateChanged, [this] (int state) {
|
connect(elideWarningCheckBox, &QCheckBox::stateChanged, [this] (int state) {
|
||||||
m_elideWarning = (state == Qt::Checked);
|
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;
|
auto controlLayout = new QHBoxLayout;
|
||||||
mainLayout->addLayout(controlLayout);
|
mainLayout->addLayout(controlLayout);
|
||||||
@@ -232,6 +280,16 @@ void QmlDebugTranslationWidget::updateStartupProjectTranslations()
|
|||||||
updateCurrentTranslations(ProjectExplorer::SessionManager::startupProject());
|
updateCurrentTranslations(ProjectExplorer::SessionManager::startupProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor QmlDebugTranslationWidget::warningColor()
|
||||||
|
{
|
||||||
|
return m_warningColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
QColor QmlDebugTranslationWidget::foundTrColor()
|
||||||
|
{
|
||||||
|
return m_foundTrColor;
|
||||||
|
}
|
||||||
|
|
||||||
void QmlDebugTranslationWidget::updateCurrentTranslations(ProjectExplorer::Project *project)
|
void QmlDebugTranslationWidget::updateCurrentTranslations(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
m_testLanguages.clear();
|
m_testLanguages.clear();
|
||||||
|
@@ -63,6 +63,9 @@ public:
|
|||||||
void setCurrentFile(const Utils::FilePath &filepath);
|
void setCurrentFile(const Utils::FilePath &filepath);
|
||||||
void setFiles(const Utils::FilePaths &filePathes);
|
void setFiles(const Utils::FilePaths &filePathes);
|
||||||
void updateStartupProjectTranslations();
|
void updateStartupProjectTranslations();
|
||||||
|
|
||||||
|
QColor warningColor();
|
||||||
|
QColor foundTrColor();
|
||||||
private:
|
private:
|
||||||
void updateCurrentEditor(const Core::IEditor *editor);
|
void updateCurrentEditor(const Core::IEditor *editor);
|
||||||
void updateCurrentTranslations(ProjectExplorer::Project *project);
|
void updateCurrentTranslations(ProjectExplorer::Project *project);
|
||||||
@@ -98,6 +101,10 @@ private:
|
|||||||
|
|
||||||
QHBoxLayout *m_selectLanguageLayout;
|
QHBoxLayout *m_selectLanguageLayout;
|
||||||
TestLanguageGetter m_testLanguagesGetter;
|
TestLanguageGetter m_testLanguagesGetter;
|
||||||
|
QColor m_warningColor;
|
||||||
|
QColor m_foundTrColor;
|
||||||
|
QColor m_lastWarningColor;
|
||||||
|
QColor m_lastfoundTrColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace QmlPreview
|
} // namespace QmlPreview
|
||||||
|
Reference in New Issue
Block a user