Commit 040cfd57 authored by Kuntal  Majumder's avatar Kuntal Majumder 😟

this should fix the regression introduced

parent 525e0ad4
......@@ -30,9 +30,10 @@
#include <QPainter>
#include <kis_config.h>
PinnedFontsSeparator::PinnedFontsSeparator(QWidget *parent) :
QStyledItemDelegate(parent), m_separatorIndex(0), m_separatorAdded(false)
{ }
PinnedFontsSeparator::PinnedFontsSeparator(QAbstractItemDelegate *_default, QWidget *parent) :
QStyledItemDelegate(parent), m_separatorIndex(0), m_separatorAdded(false), m_defaultDelegate(_default)
{
}
void PinnedFontsSeparator::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
......@@ -42,10 +43,15 @@ void PinnedFontsSeparator::paint(QPainter *painter, const QStyleOptionViewItem &
painter->drawLine((viewRect.topLeft() + viewRect.bottomLeft()) / 2 + QPoint(5, 0),
(viewRect.topRight() + viewRect.bottomRight()) / 2 - QPoint(5, 0));
} else {
QStyledItemDelegate::paint(painter, option, index);
m_defaultDelegate->paint(painter, option, index);
}
}
QSize PinnedFontsSeparator::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
return QStyledItemDelegate::sizeHint(option, index) * 1.25;
}
void PinnedFontsSeparator::setSeparatorIndex(int index)
{
m_separatorIndex = index;
......@@ -73,7 +79,10 @@ KisFontFamilyComboBox::KisFontFamilyComboBox(QWidget *parent)
<< "msam10" << "msbm10" << "rsfs10"
<< "stmary10" << "wasy10" << "wasyb10";
refillComboBox();
m_fontSeparator = new PinnedFontsSeparator(this);
QFontComboBox *temp = new QFontComboBox();
m_fontSeparator = new PinnedFontsSeparator(temp->itemDelegate(), this);
temp->setEnabled(true);
temp->hide();
m_separatorIndex = 0;
m_pinnedFonts = KisConfig(true).readList("PinnedFonts", QStringList{});
}
......@@ -178,10 +187,8 @@ KisFontComboBoxes::KisFontComboBoxes(QWidget *parent)
{
QHBoxLayout *layout = new QHBoxLayout();
this->setLayout(layout);
QFontComboBox *temp = new QFontComboBox(this);
m_family = new KisFontFamilyComboBox();
m_family->setItemDelegate(temp->itemDelegate());
m_family->setMinimumWidth(100);
m_family->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
layout->addWidget(m_family);
......@@ -194,8 +201,6 @@ KisFontComboBoxes::KisFontComboBoxes(QWidget *parent)
connect(m_family, SIGNAL(currentTextChanged(QString)), this, SLOT(fontFamilyChanged()));
connect(m_family, SIGNAL(currentTextChanged(QString)), this, SLOT(fontChange()));
connect(m_styles, SIGNAL(activated(int)), this, SLOT(fontChange()));
temp->setEnabled(false);
temp->hide();
}
void KisFontComboBoxes::setCurrentFont(QFont font)
......
......@@ -77,14 +77,16 @@ private:
class PinnedFontsSeparator : public QStyledItemDelegate {
public:
PinnedFontsSeparator(QWidget *parent = nullptr);
PinnedFontsSeparator(QAbstractItemDelegate *_default, QWidget *parent = nullptr);
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
void setSeparatorIndex(int index);
void setSeparatorAdded();
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
private:
int m_separatorIndex;
bool m_separatorAdded;
QAbstractItemDelegate *m_defaultDelegate;
};
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment