Commit 4e1a0e1d authored by Noah Davis's avatar Noah Davis 🌵 Committed by Nate Graham
Browse files

Don't draw separator in SideBarGroup, use point size instead of bold, adjust...

Don't draw separator in SideBarGroup, use point size instead of bold, adjust margins, don't require title
parent c9236bb2
......@@ -85,30 +85,24 @@ struct SideBarGroupPrivate
{
QFrame* mContainer;
QLabel* mTitleLabel;
bool mDefaultContainerMarginEnabled;
};
SideBarGroup::SideBarGroup(const QString& title, bool defaultContainerMarginEnabled)
SideBarGroup::SideBarGroup(const QString& title)
: QFrame()
, d(new SideBarGroupPrivate)
{
d->mContainer = nullptr;
d->mTitleLabel = new QLabel(this);
d->mDefaultContainerMarginEnabled = defaultContainerMarginEnabled;
d->mTitleLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
d->mTitleLabel->setFixedHeight(d->mTitleLabel->sizeHint().height() * 3 / 2);
QFont font(d->mTitleLabel->font());
font.setBold(true);
font.setPointSizeF(font.pointSizeF() + 1);
d->mTitleLabel->setFont(font);
d->mTitleLabel->setText(title);
d->mTitleLabel->setVisible(!d->mTitleLabel->text().isEmpty());
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(d->mTitleLabel);
d->mTitleLabel->setContentsMargins(DEFAULT_LAYOUT_MARGIN, 0, 0, 0);
layout->setContentsMargins(0, 0, 0, 0);
clear();
}
......@@ -117,17 +111,6 @@ SideBarGroup::~SideBarGroup()
delete d;
}
void SideBarGroup::paintEvent(QPaintEvent* event)
{
QFrame::paintEvent(event);
if (parentWidget()->layout()->indexOf(this) != 0) {
// Draw a separator, but only if we are not the first group
QPainter painter(this);
QPen pen(palette().mid().color());
painter.setPen(pen);
painter.drawLine(rect().topLeft(), rect().topRight());
}
}
void SideBarGroup::addWidget(QWidget* widget)
{
......@@ -147,9 +130,6 @@ void SideBarGroup::clear()
containerLayout->setSpacing(0);
layout()->addWidget(d->mContainer);
if(d->mDefaultContainerMarginEnabled) {
d->mContainer->layout()->setContentsMargins(DEFAULT_LAYOUT_MARGIN, 0, 0, 0);
}
}
void SideBarGroup::addAction(QAction* action)
......@@ -182,7 +162,9 @@ SideBarPage::SideBarPage(const QString& title)
d->mTitle = title;
d->mLayout = new QVBoxLayout(this);
d->mLayout->setContentsMargins(0, 0, 0, 0);
QMargins margins = d->mLayout->contentsMargins();
margins.setRight(qMax(0, margins.right() - style()->pixelMetric(QStyle::PM_SplitterWidth)));
d->mLayout->setContentsMargins(margins);
}
SideBarPage::~SideBarPage()
......
......@@ -27,8 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
namespace Gwenview
{
static const int DEFAULT_LAYOUT_MARGIN = 6;
class SideBar;
struct SideBarGroupPrivate;
......@@ -36,16 +34,13 @@ class SideBarGroup : public QFrame
{
Q_OBJECT
public:
SideBarGroup(const QString& title, bool defaultContainerMarginEnabled = true);
SideBarGroup(const QString& title = "");
~SideBarGroup() override;
void addWidget(QWidget*);
void addAction(QAction*);
void clear();
protected:
void paintEvent(QPaintEvent*) override;
private:
SideBarGroupPrivate* const d;
};
......
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