* work done for color scheme

This commit is contained in:
royqh1979@gmail.com 2021-06-20 22:54:16 +08:00
parent 39bdd66dbb
commit 6fd4371b43
16 changed files with 880 additions and 428 deletions

View File

@ -2,6 +2,8 @@
#include <QFileInfo>
#include <QObject>
#include "qsynedit/highlighter/cpp.h"
#include "qsynedit/Constants.h"
#include "colorscheme.h"
HighlighterManager highlighterManager;
@ -26,6 +28,14 @@ PSynHighlighter HighlighterManager::getHighlighter(const QString &filename)
return PSynHighlighter();
}
PSynHighlighter HighlighterManager::copyHighlighter(PSynHighlighter highlighter)
{
if (!highlighter)
return PSynHighlighter();
if (highlighter->getName() == SYN_HIGHLIGHTER_CPP)
return getCppHighlighter();
}
PSynHighlighter HighlighterManager::getCppHighlighter()
{
SynEditCppHighlighter* highlighter = new SynEditCppHighlighter();
@ -53,3 +63,32 @@ PSynHighlighter HighlighterManager::getCppHighlighter()
highlighter->variableAttribute()->setForeground(0x400080);
return pHighlighter;
}
void HighlighterManager::applyColorScheme(PSynHighlighter highlighter, const QString &schemeName)
{
if (!highlighter)
return;
if (highlighter->getName() == SYN_HIGHLIGHTER_CPP) {
for (QString name: highlighter->attributes().keys()) {
PColorSchemeItem item = pColorManager->getItem(schemeName,name);
if (item) {
PSynHighlighterAttribute attr = highlighter->attributes()[name];
attr->setBackground(item->background());
attr->setForeground(item->foreground());
SynFontStyles styles = SynFontStyle::fsNone;
if (item->bold()) {
styles.setFlag(SynFontStyle::fsBold);
}
if (item->italic()) {
styles.setFlag(SynFontStyle::fsItalic);
}
if (item->underlined()) {
styles.setFlag(SynFontStyle::fsUnderline);
}
if (item->strikeout()) {
styles.setFlag(SynFontStyle::fsStrikeOut);
}
}
}
}
}

View File

@ -8,7 +8,9 @@ public:
HighlighterManager();
PSynHighlighter getHighlighter(const QString& filename);
PSynHighlighter copyHighlighter(PSynHighlighter highlighter);
PSynHighlighter getCppHighlighter();
void applyColorScheme(PSynHighlighter highlighter, const QString& schemeName);
};
extern HighlighterManager highlighterManager;

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -302,6 +302,48 @@ QString ColorManager::copy(const QString &sourceName)
return newName;
}
bool ColorManager::restoreToDefault(const QString &name)
{
PColorScheme scheme = get(name);
if (!scheme)
return false;
if (!scheme->customed())
return false;
QString fullPath = generateFullPathname(name,scheme->bundled(),false);
PColorScheme oldScheme = ColorScheme::load(fullPath);
if (!oldScheme)
throw FileError(QObject::tr("Can't Find the color scheme file %1!").arg(fullPath));
fullPath = generateFullPathname(name,scheme->bundled(),true);
QFile file(fullPath);
if (file.exists() && !file.remove())
throw FileError(QObject::tr("Can't remove the color scheme file %1!").arg(fullPath));
oldScheme->setBundled(scheme->bundled());
oldScheme->setCustomed(false);
mSchemes[name]=oldScheme;
return true;
}
bool ColorManager::remove(const QString &name)
{
PColorScheme scheme = get(name);
if (!scheme)
return false;
if (scheme->bundled())
return false;
if (scheme->customed()) {
QString fullPath = generateFullPathname(name,false,true);
QFile file(fullPath);
if (!file.remove())
throw FileError(QObject::tr("Can't remove the color scheme file %1!").arg(fullPath));
}
QString fullPath = generateFullPathname(name,false,false);
QFile file(fullPath);
if (!file.remove())
throw FileError(QObject::tr("Can't remove the color scheme file %1!").arg(fullPath));
mSchemes.remove(name);
return true;
}
QString ColorManager::generateFilename(const QString &name, bool isCustomed)
{
QString newName = name;
@ -328,11 +370,13 @@ void ColorManager::loadSchemesInDir(const QString &dirName, bool isBundled, bool
QFileInfo fileInfo = list[i];
QString name = fileInfo.fileName();
if (name.toLower().endsWith(suffix)) {
if (!isCustomed && name.toLower().endsWith(customSuffix))
continue;
PColorScheme scheme = ColorScheme::load(fileInfo.absoluteFilePath());
// if (!isCustomed && name.toLower().endsWith(customSuffix))
// continue;
name.remove(name.length()-suffix.length(),suffix.length());
name.replace('_',' ');
if (!isValidName(name))
continue;
PColorScheme scheme = ColorScheme::load(fileInfo.absoluteFilePath());
if (!isCustomed) {
scheme->setBundled(isBundled);
scheme->setCustomed(false);
@ -504,16 +548,33 @@ bool ColorManager::rename(const QString &oldName, const QString &newName)
PColorScheme scheme = get(oldName);
if (!scheme)
return false;
if (scheme->bundled())
return false;
if (scheme->customed()) {
QString oldfullPath = generateFullPathname(oldName,false,true);
QString fullpath = generateFullPathname(newName,false,true);
QFile oldFile(oldfullPath);
if (oldFile.exists() && !oldFile.rename(fullpath))
throw FileError(QObject::tr("Rename file '%1' to '%2' failed!").arg(oldfullPath).arg(fullpath));
}
QString oldfullPath = generateFullPathname(oldName,false,false);
QString fullpath = generateFullPathname(newName,false,false);
QFile oldFile(oldfullPath);
if (oldFile.exists() && !oldFile.rename(fullpath))
throw FileError(QObject::tr("Rename file '%1' to '%2' failed!").arg(oldfullPath).arg(fullpath));
mSchemes.remove(oldName);
mSchemes[newName] = scheme;
return true;
}
PColorScheme ColorManager::remove(const QString &name)
bool ColorManager::add(const QString &name, PColorScheme scheme)
{
PColorScheme scheme=get(name);
if (scheme)
mSchemes.remove(name);
return scheme;
if (mSchemes.contains(name))
throw FileError(QObject::tr("Scheme '%1' already exists!").arg(name));
scheme->setBundled(false);
scheme->setCustomed(false);
mSchemes[name] = scheme;
saveScheme(name);
}
PColorScheme ColorManager::get(const QString &name)

View File

@ -130,8 +130,10 @@ public:
bool exists(const QString name);
QString copy(const QString& source);
bool restoreToDefault(const QString& name);
bool remove(const QString& name);
bool rename(const QString& oldName, const QString& newName);
PColorScheme remove(const QString& name);
bool add(const QString& name, PColorScheme scheme);
PColorScheme get(const QString& name);
PColorSchemeItem getItem(const QString& schemeName, const QString& itemName);
bool isValidName(const QString& name);

View File

@ -59,12 +59,11 @@ bool FileCompiler::prepareForCompile()
mCompiler = compilerSet()->cppCompiler();
break;
default:
error(tr("Can't the compiler for file %1").arg(mFileName));
error(tr("Can't find the compiler for file %1").arg(mFileName));
return false;
}
mArguments += getLibraryArguments();
log(tr("Processing %1 source file:").arg(strFileType));
log("------------------");
log(tr("%1 Compiler: %2").arg(strFileType).arg(mCompiler));

View File

@ -127,7 +127,7 @@ bool Editor::save(bool force, bool reparse) {
//is this file writable;
if (!force && !info.isWritable()) {
QMessageBox::information(pMainWindow,tr("Fail"),
QString(QObject::tr("File %s is not writable!")));
tr("File %1 is not writable!").arg(mFilename));
return false;
}
if (this->modified()|| force) {
@ -295,22 +295,22 @@ void Editor::copyAsHTML()
SynExporterHTML.setTitle(QFileInfo(mFilename).fileName());
SynExporterHTML.setExportAsText(false);
SynExporterHTML.setUseBackground(true);
SynExporterHTML.setUseBackground(pSettings->editor().copyHTMLUseBackground());
SynExporterHTML.setFont(font());
SynExporterHTML.setHighlighter(highlighter());
PSynHighlighter hl = highlighter();
if (!pSettings->editor().copyHTMLUseEditorColor()) {
hl = highlighterManager.copyHighlighter(highlighter());
highlighterManager.applyColorScheme(hl,pSettings->editor().copyHTMLColorScheme());
}
SynExporterHTML.setHighlighter(hl);
SynExporterHTML.setCreateHTMLFragment(true);
//SynExporterRTF.OnFormatToken := ExporterFormatToken;
SynExporterHTML.ExportRange(lines(),blockBegin(),blockEnd());
//SynExporterHTML.CopyToClipboard();
QMimeData * mimeData = new QMimeData;
//sethtml will convert buffer to QString , which will cause encoding trouble
mimeData->setData(SynExporterHTML.clipboardFormat(),SynExporterHTML.buffer());
//mimeData->setHtml("<span><style> b {color:red;} </style><b>test</b></span>");
mimeData->setText(selText());
QGuiApplication::clipboard()->clear();
@ -464,31 +464,7 @@ void Editor::applySettings()
void Editor::applyColorScheme(const QString& schemeName)
{
if (highlighter()) {
if (highlighter()->getName() == SYN_HIGHLIGHTER_CPP) {
for (QString name: highlighter()->attributes().keys()) {
PColorSchemeItem item = pColorManager->getItem(schemeName,name);
if (item) {
PSynHighlighterAttribute attr = highlighter()->attributes()[name];
attr->setBackground(item->background());
attr->setForeground(item->foreground());
SynFontStyles styles = SynFontStyle::fsNone;
if (item->bold()) {
styles.setFlag(SynFontStyle::fsBold);
}
if (item->italic()) {
styles.setFlag(SynFontStyle::fsItalic);
}
if (item->underlined()) {
styles.setFlag(SynFontStyle::fsUnderline);
}
if (item->strikeout()) {
styles.setFlag(SynFontStyle::fsStrikeOut);
}
}
}
}
}
highlighterManager.applyColorScheme(highlighter(),schemeName);
PColorSchemeItem item = pColorManager->getItem(schemeName,COLOR_SCHEME_ACTIVE_LINE);
if (item) {
setActiveLineColor(item->background());

View File

@ -170,6 +170,7 @@ void MainWindow::applySettings()
font.setStyleStrategy(QFont::PreferAntialias);
QApplication * app = dynamic_cast<QApplication*>(QApplication::instance());
app->setFont(font);
this->setFont(font);
}
void MainWindow::updateStatusbarForLineCol()

View File

@ -2,6 +2,7 @@
#include "ui_editorclipboardwidget.h"
#include "../settings.h"
#include "../mainwindow.h"
#include "../colorscheme.h"
EditorClipboardWidget::EditorClipboardWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
@ -10,6 +11,19 @@ EditorClipboardWidget::EditorClipboardWidget(const QString& name, const QString&
ui->setupUi(this);
ui->cbCopyWithFormatAs->addItem("None");
ui->cbCopyWithFormatAs->addItem("HTML");
for (QString name: pColorManager->getSchemes()) {
ui->cbHTMLColorScheme->addItem(name);
ui->cbRTFColorScheme->addItem(name);
}
connect(ui->chkCopyRTFUseEditorColor,
&QCheckBox::stateChanged,
this,
&EditorClipboardWidget::onUseSchemeChanged);
connect(ui->chkCopyHTMLUseEditorColor,
&QCheckBox::stateChanged,
this,
&EditorClipboardWidget::onUseSchemeChanged);
}
EditorClipboardWidget::~EditorClipboardWidget()
@ -17,6 +31,12 @@ EditorClipboardWidget::~EditorClipboardWidget()
delete ui;
}
void EditorClipboardWidget::onUseSchemeChanged()
{
ui->cbRTFColorScheme->setEnabled(!ui->chkCopyRTFUseEditorColor->isChecked());
ui->cbHTMLColorScheme->setEnabled(!ui->chkCopyHTMLUseEditorColor->isChecked());
}
void EditorClipboardWidget::doLoad()
{
//pSettings->editor().load();
@ -30,13 +50,11 @@ void EditorClipboardWidget::doLoad()
pSettings->editor().copyWithFormatAs())) );
ui->chkCopyRTFUseBackground->setChecked(pSettings->editor().copyRTFUseBackground());
ui->chkCopyRTFUseEditorColor->setChecked(pSettings->editor().copyRTFUseEditorColor());
//todo
//ui->cbCopyRTFColorScheme
ui->cbRTFColorScheme->setCurrentText(pSettings->editor().colorScheme());
ui->chkCopyHTMLUseBackground->setChecked(pSettings->editor().copyHTMLUseBackground());
ui->chkCopyHTMLUseEditorColor->setChecked(pSettings->editor().copyHTMLUseEditorColor());
//todo
//ui->cbCopyHTMLColorScheme
ui->cbHTMLColorScheme->setCurrentText(pSettings->editor().colorScheme());
onUseSchemeChanged();
}
void EditorClipboardWidget::doSave()
@ -49,10 +67,11 @@ void EditorClipboardWidget::doSave()
pSettings->editor().setCopyRTFUseBackground(ui->chkCopyRTFUseBackground->isChecked());
pSettings->editor().setCopyRTFUseEditorColor(ui->chkCopyRTFUseEditorColor->isChecked());
//todo
//ui->cbCopyRTFColorSchema
pSettings->editor().setCopyRTFColorScheme(ui->cbRTFColorScheme->currentText());
pSettings->editor().setCopyHTMLUseBackground(ui->chkCopyHTMLUseBackground->isChecked());
pSettings->editor().setCopyHTMLUseEditorColor(ui->chkCopyHTMLUseEditorColor->isChecked());
pSettings->editor().setCopyHTMLColorScheme(ui->cbHTMLColorScheme->currentText());
pSettings->editor().save();
pMainWindow->updateEditorSettings();

View File

@ -16,6 +16,9 @@ public:
explicit EditorClipboardWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~EditorClipboardWidget();
public slots:
void onUseSchemeChanged();
private:
Ui::EditorClipboardWidget *ui;

View File

@ -7,6 +7,8 @@
#include <QAction>
#include <QMessageBox>
#include <QDebug>
#include <QInputDialog>
#include <QFileDialog>
EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
@ -150,7 +152,7 @@ void EditorColorSchemeWidget::setCurrentSchemeModified()
ui->cbScheme->setItemData(ui->cbScheme->currentIndex(),
mModifiedSchemeComboFont,Qt::FontRole);
ui->cbScheme->setFont(mModifiedSchemeComboFont);
ui->cbScheme->view()->setFont(mDefaultSchemeComboFont);
//ui->cbScheme->view()->setFont(mDefaultSchemeComboFont);
//we must reset the editor here, because this slot is processed after the onSettingChanged
onSettingChanged();
}
@ -227,9 +229,11 @@ void EditorColorSchemeWidget::onForegroundChanged()
PColorSchemeItem item = getCurrentItem();
if (!item)
return;
ui->colorForeground->setVisible(ui->cbForeground->isChecked());
if (ui->cbForeground->isChecked()) {
item->setForeground(ui->colorForeground->color());
} else {
ui->colorForeground->setColor(QColor());
item->setForeground(QColor());
}
setCurrentSchemeModified();
@ -240,9 +244,11 @@ void EditorColorSchemeWidget::onBackgroundChanged()
PColorSchemeItem item = getCurrentItem();
if (!item)
return;
ui->colorBackground->setVisible(ui->cbBackground->isChecked());
if (ui->cbBackground->isChecked()) {
item->setBackground(ui->colorBackground->color());
} else {
ui->colorBackground->setColor(QColor());
item->setBackground(QColor());
}
setCurrentSchemeModified();
@ -269,7 +275,7 @@ void EditorColorSchemeWidget::changeSchemeComboFont()
} else {
ui->cbScheme->setFont(mDefaultSchemeComboFont);
}
ui->cbScheme->view()->setFont(mDefaultSchemeComboFont);
//ui->cbScheme->view()->setFont(mDefaultSchemeComboFont);
}
void EditorColorSchemeWidget::doLoad()
@ -313,6 +319,8 @@ void EditorColorSchemeWidget::on_btnSchemeMenu_pressed()
menu.addAction(ui->actionRename_Scheme);
menu.addAction(ui->actionDelete_Scheme);
}
QString name = ui->cbScheme->currentText();
if (!pColorManager->exists(name+ " Copy"))
menu.addAction(ui->actionCopy_Scheme);
menu.addAction(ui->actionExport_Scheme);
menu.addSeparator();
@ -323,3 +331,111 @@ void EditorColorSchemeWidget::on_btnSchemeMenu_pressed()
p.setY(ui->btnSchemeMenu->height()+2);
menu.exec(ui->btnSchemeMenu->mapToGlobal(p));
}
void EditorColorSchemeWidget::on_actionImport_Scheme_triggered()
{
QString filename = QFileDialog::getOpenFileName(this,
tr("Open"), QString(), tr("Color Scheme Files (*.scheme)"));
if (filename.isEmpty())
return;
QFileInfo fileInfo(filename);
QString name = fileInfo.fileName();
QString suffix = EXT_COLOR_SCHEME;
if (!name.toLower().endsWith(suffix))
return;
name.remove(name.length()-suffix.length(),suffix.length());
name.replace('_',' ');
if (!pColorManager->isValidName(name)) {
QMessageBox::information(this,tr("Error"),tr("'%1' is not a valid name for color scheme file."));
return;
}
try {
PColorScheme scheme = ColorScheme::load(filename);
pColorManager->add(name, scheme);
ui->cbScheme->addItem(name);
ui->cbScheme->setCurrentText(name);
} catch (FileError e) {
QMessageBox::information(this,tr("Error"),e.reason());
return;
}
}
void EditorColorSchemeWidget::on_actionRename_Scheme_triggered()
{
QString name = ui->cbScheme->currentText();
bool isOk;
QString newName = QInputDialog::getText(this,tr("New scheme name"),tr("New scheme name"),
QLineEdit::Normal,name,&isOk);
if (isOk) {
if (!pColorManager->isValidName(newName)) {
QMessageBox::information(this,tr("Error"),tr("'%1' is not a valid scheme name!").arg(newName));
return;
}
try {
pColorManager->rename(name,newName);
ui->cbScheme->setItemText(
ui->cbScheme->currentIndex(),
newName
);
if (mModifiedSchemes.contains(name))
mModifiedSchemes.remove(name);
mModifiedSchemes.insert(newName);
} catch(FileError e) {
QMessageBox::information(this,tr("Error"),e.reason());
}
}
}
void EditorColorSchemeWidget::on_actionReset_Scheme_triggered()
{
try {
if (pColorManager->restoreToDefault(ui->cbScheme->currentText())) {
ui->cbScheme->setItemData(
ui->cbScheme->currentIndex(),
QVariant(),
Qt::FontRole);
ui->cbScheme->setFont(mDefaultSchemeComboFont);
//ui->cbScheme->view()->setFont(mDefaultSchemeComboFont);
}
} catch (FileError e) {
QMessageBox::information(this,tr("Error"),e.reason());
}
}
void EditorColorSchemeWidget::on_actionExport_Scheme_triggered()
{
QString filename = QFileDialog::getSaveFileName(this,
tr("Save"), QString(), tr("Color Scheme Files (*.scheme)"));
if (filename.isEmpty())
return;
try {
PColorScheme scheme = getCurrentScheme();
scheme->save(filename);
} catch (FileError e) {
QMessageBox::information(this,tr("Error"),e.reason());
return;
}
}
void EditorColorSchemeWidget::on_actionDelete_Scheme_triggered()
{
QString name = ui->cbScheme->currentText();
if (QMessageBox::information(this,tr("Confirm Delete Scheme"),
tr("Scheme '%1' will be deleted!<br />Do you really want to continue?")
.arg(name),
QMessageBox::Yes, QMessageBox::No)!=QMessageBox::Yes)
return;
try {
if (pColorManager->remove(name)) {
if (mModifiedSchemes.contains(name))
mModifiedSchemes.remove(name);
ui->cbScheme->removeItem(ui->cbScheme->currentIndex());
if (name == pSettings->editor().colorScheme())
doSave();
}
} catch (FileError e) {
QMessageBox::information(this,tr("Error"),e.reason());
}
}

View File

@ -54,6 +54,11 @@ protected:
private slots:
void on_actionCopy_Scheme_triggered();
void on_btnSchemeMenu_pressed();
void on_actionImport_Scheme_triggered();
void on_actionRename_Scheme_triggered();
void on_actionReset_Scheme_triggered();
void on_actionExport_Scheme_triggered();
void on_actionDelete_Scheme_triggered();
};
#endif // EDITORCOLORSCHEMEWIDGET_H

View File

@ -146,6 +146,24 @@
</attribute>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_5" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>7</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="widgetSchemeItem" native="true">
<property name="enabled">
@ -223,7 +241,25 @@
</property>
</widget>
</item>
<item row="2" column="1">
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="grpFontStyles">
<property name="title">
<string>Font Styles</string>
@ -260,6 +296,22 @@
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -94,7 +94,6 @@ QString TrimLeft(const QString& s);
bool StringIsBlank(const QString& s);
void changeTheme(const QString& themeName);
template <class F>
class final_action
{

View File

@ -3,6 +3,7 @@
#include <QColorDialog>
#include <QPainter>
#include <QDebug>
#include <QApplication>
ColorEdit::ColorEdit(QWidget *parent):QFrame(parent)
{
@ -21,13 +22,18 @@ void ColorEdit::setColor(const QColor &value)
if (mColor!=value) {
mColor=value;
emit colorChanged(value);
update();
resize(sizeHint());
// update();
}
}
QColor ColorEdit::contrast()
{
int crBg = mColor.rgb() & 0xFFFFFF;
int crBg;
if (!mColor.isValid())
crBg = palette().color(QPalette::Base).rgb() & 0xFFFFFF;
else
crBg = mColor.rgb() & 0xFFFFFF;
int TOLERANCE = 30;
int result;
@ -44,18 +50,32 @@ QColor ColorEdit::contrast()
QSize ColorEdit::sizeHint() const
{
QRect rect = fontMetrics().boundingRect(mColor.name());
QRect rect;
if (mColor.isValid() )
rect = fontMetrics().boundingRect(mColor.name());
else
rect = fontMetrics().boundingRect(tr("NONE"));
return QSize{rect.width()+ 10,
rect.height()+ 6 };
}
void ColorEdit::paintEvent(QPaintEvent *event)
void ColorEdit::paintEvent(QPaintEvent *)
{
QPainter painter(this);
QRect rect = QRect(lineWidth(),lineWidth(),width()-2*lineWidth(),height()-2*lineWidth());
painter.fillRect(rect,mColor);
if (mColor.isValid()) {
//painter.fillRect(rect,mColor);
painter.setPen(contrast());
painter.setBrush(mColor);
painter.drawRect(rect);
painter.drawText(rect,Qt::AlignCenter, mColor.name());
} else {
//painter.fillRect(rect,palette().color(QPalette::Base));
painter.setPen(contrast());
painter.setBrush(palette().color(QPalette::Base));
painter.drawRect(rect);
painter.drawText(rect,Qt::AlignCenter, tr("NONE"));
}
}
void ColorEdit::mouseReleaseEvent(QMouseEvent *event)
@ -78,7 +98,5 @@ void ColorEdit::leaveEvent(QEvent *event)
QSize ColorEdit::minimumSizeHint() const
{
QRect rect = fontMetrics().boundingRect(mColor.name());
return QSize{rect.width(),
rect.height()};
return sizeHint();
}