Fixes when adding new conditional format

Font point size preference is taken into account when creating a new
default conditional format.

New conditional formats in dialog are resized to contents.

See issues #1976 and #1815.
This commit is contained in:
mgrojo
2019-09-21 23:30:28 +02:00
parent c27002c301
commit 5b73cd1481
2 changed files with 14 additions and 2 deletions
+8 -1
View File
@@ -45,12 +45,19 @@ CondFormatManager::~CondFormatManager()
void CondFormatManager::addNewItem()
{
QFont font = QFont(Settings::getValue("databrowser", "font").toString());
font.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
CondFormat newCondFormat("", QColor(Settings::getValue("databrowser", "reg_fg_colour").toString()),
m_condFormatPalette.nextSerialColor(Palette::appHasDarkTheme()),
QFont(Settings::getValue("databrowser", "font").toString()),
font,
CondFormat::AlignLeft,
m_encoding);
addItem(newCondFormat);
// Resize columns to contents, except for the condition
for(int col = ColumnForeground; col < ColumnFilter; ++col)
ui->tableCondFormats->resizeColumnToContents(col);
}
void CondFormatManager::addItem(const CondFormat& aCondFormat)
+6 -1
View File
@@ -437,11 +437,14 @@ void TableBrowser::updateFilter(int column, const QString& value)
void TableBrowser::addCondFormat(int column, const QString& value)
{
QFont font = QFont(Settings::getValue("databrowser", "font").toString());
font.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
// Create automatically a new conditional format with the next serial background color according to the theme and the regular foreground
// color and font in the settings.
CondFormat newCondFormat(value, QColor(Settings::getValue("databrowser", "reg_fg_colour").toString()),
m_condFormatPalette.nextSerialColor(Palette::appHasDarkTheme()),
QFont(Settings::getValue("databrowser", "font").toString()),
font,
CondFormat::AlignLeft,
m_browseTableModel->encoding());
m_browseTableModel->addCondFormat(column, newCondFormat);
@@ -460,6 +463,8 @@ void TableBrowser::editCondFormats(int column)
{
CondFormatManager condFormatDialog(browseTableSettings[currentlyBrowsedTableName()].condFormats[column],
m_browseTableModel->encoding(), this);
condFormatDialog.setWindowTitle(tr("Conditional formats for \"%1\"").
arg(m_browseTableModel->headerData(column, Qt::Horizontal).toString()));
if (condFormatDialog.exec()) {
std::vector<CondFormat> condFormatVector = condFormatDialog.getCondFormats();
m_browseTableModel->setCondFormats(column, condFormatVector);