PrismLauncher/launcher/ui/widgets/LineSeparator.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
995 B
C++
Raw Normal View History

2014-05-17 15:23:48 +01:00
#include "LineSeparator.h"
#include <QLayout>
#include <QPainter>
#include <QStyle>
#include <QStyleOption>
2014-05-17 15:23:48 +01:00
void LineSeparator::initStyleOption(QStyleOption* option) const
2014-05-17 15:23:48 +01:00
{
option->initFrom(this);
// in a horizontal layout, the line is vertical (and vice versa)
if (m_orientation == Qt::Vertical)
option->state |= QStyle::State_Horizontal;
}
LineSeparator::LineSeparator(QWidget* parent, Qt::Orientation orientation) : QWidget(parent), m_orientation(orientation)
2014-05-17 15:23:48 +01:00
{
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
}
QSize LineSeparator::sizeHint() const
{
QStyleOption opt;
initStyleOption(&opt);
const int extent = style()->pixelMetric(QStyle::PM_ToolBarSeparatorExtent, &opt, parentWidget());
2014-05-17 15:23:48 +01:00
return QSize(extent, extent);
}
void LineSeparator::paintEvent(QPaintEvent*)
2014-05-17 15:23:48 +01:00
{
QPainter p(this);
QStyleOption opt;
initStyleOption(&opt);
style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &opt, &p, parentWidget());
}