integrate Hugo's new code a little better, mainly white space.
move implementation of handleWidget() to cpp file to avoid an include add credit to KAboutData svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1135182
This commit is contained in:
parent
16de8b9034
commit
29f73d29fa
|
@ -34,7 +34,6 @@
|
|||
#include <QStyleOptionToolBar>
|
||||
#include <QStyleOptionFrameV3>
|
||||
#include <QStyleOptionButton>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kcolorscheme.h>
|
||||
|
@ -88,15 +87,18 @@ void PartResizerWidget::init(Device& d, Partition& p, qint64 minFirst, qint64 ma
|
|||
setMinimumLength(qMax(partition().sectorsUsed(), partition().minimumSectors()));
|
||||
setMaximumLength(qMin(totalSectors(), partition().maximumSectors()));
|
||||
|
||||
// set margins to accomodate for top/bottom button asymetric layouts
|
||||
// set margins to accomodate for top/bottom button asymmetric layouts
|
||||
QStyleOptionButton bOpt;
|
||||
bOpt.initFrom(this);
|
||||
QRect buttonRect( style()->subElementRect( QStyle::SE_PushButtonContents, &bOpt ) );
|
||||
int asym = (rect().bottom() - buttonRect.bottom()) - (buttonRect.top() - rect().top());
|
||||
if( asym > 0 ) setContentsMargins( 0, asym, 0, 0 );
|
||||
else setContentsMargins( 0, 0, 0, asym );
|
||||
|
||||
/** @todo get real pixmaps for the handles */
|
||||
QRect buttonRect(style()->subElementRect(QStyle::SE_PushButtonContents, &bOpt));
|
||||
|
||||
int asym = (rect().bottom() - buttonRect.bottom()) - (buttonRect.top() - rect().top());
|
||||
if (asym > 0)
|
||||
setContentsMargins(0, asym, 0, 0);
|
||||
else
|
||||
setContentsMargins(0, 0, 0, asym);
|
||||
|
||||
QPixmap pixmap(handleWidth(), handleHeight());
|
||||
pixmap.fill(Qt::transparent);
|
||||
{
|
||||
|
@ -129,6 +131,11 @@ void PartResizerWidget::init(Device& d, Partition& p, qint64 minFirst, qint64 ma
|
|||
updatePositions();
|
||||
}
|
||||
|
||||
qint32 PartResizerWidget::handleWidth() const
|
||||
{
|
||||
return style()->pixelMetric(QStyle::PM_SplitterWidth);
|
||||
}
|
||||
|
||||
qint64 PartResizerWidget::sectorsPerPixel() const
|
||||
{
|
||||
return totalSectors() / (width() - 2 * handleWidth());
|
||||
|
@ -147,9 +154,12 @@ int PartResizerWidget::partWidgetWidth() const
|
|||
void PartResizerWidget::updatePositions()
|
||||
{
|
||||
QMargins margins(contentsMargins());
|
||||
|
||||
partWidget().move(partWidgetStart() + margins.left(), margins.top());
|
||||
partWidget().resize(partWidgetWidth() - margins.left() - margins.right(), height() - margins.top() - margins.bottom());
|
||||
|
||||
leftHandle().move(partWidgetStart() - leftHandle().width(), 0);
|
||||
|
||||
rightHandle().move(partWidgetStart() + partWidgetWidth(), 0);
|
||||
|
||||
partWidget().update();
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QStyle>
|
||||
|
||||
class Partition;
|
||||
class PartWidget;
|
||||
|
@ -80,7 +79,7 @@ class PartResizerWidget : public QWidget
|
|||
bool align() const { return m_Align; } /**< @return true if the Partition is to be aligned */
|
||||
void setAlign(bool b) { m_Align = b; } /**< @param b the new value for aligning the Partition */
|
||||
|
||||
qint32 handleWidth() const { return style()->pixelMetric( QStyle::PM_SplitterWidth ); } /**< @return the handle width in pixels */
|
||||
qint32 handleWidth() const; /**< @return the handle width in pixels */
|
||||
static qint32 handleHeight() { return m_HandleHeight; } /**< @return the handle height in pixels */
|
||||
|
||||
signals:
|
||||
|
|
|
@ -127,8 +127,9 @@ void PartWidget::paintEvent(QPaintEvent*)
|
|||
|
||||
void PartWidget::drawGradient(QPainter* painter, const QColor& color, const QRect& rect) const
|
||||
{
|
||||
if (rect.width() < 8)
|
||||
return;
|
||||
|
||||
if( rect.width() < 8 ) return;
|
||||
QStyleOptionButton option;
|
||||
option.initFrom(this);
|
||||
option.rect = rect;
|
||||
|
@ -138,5 +139,4 @@ void PartWidget::drawGradient( QPainter* painter, const QColor& color, const QRe
|
|||
option.state &= ~QStyle::State_MouseOver;
|
||||
|
||||
style()->drawControl(QStyle::CE_PushButtonBevel, &option, painter, this);
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class PartWidget : public PartWidgetBase
|
|||
|
||||
QColor activeColor(const QColor& col) const;
|
||||
|
||||
void drawGradient( QPainter*, const QColor&, const QRect& ) const;
|
||||
void drawGradient(QPainter* painter, const QColor& col, const QRect& rect) const;
|
||||
|
||||
private:
|
||||
const Partition* m_Partition;
|
||||
|
|
|
@ -130,6 +130,8 @@ KAboutData* createPartitionManagerAboutData()
|
|||
about->addAuthor(ki18nc("@info:credit", "Volker Lanz"), KLocalizedString(), "vl@fidra.de");
|
||||
about->setHomepage("http://www.partitionmanager.org");
|
||||
|
||||
about->addCredit(ki18n("Hugo Pereira Da Costa"), ki18nc("@info:credit", "Partition Widget Design"), "hugo@oxygen-icons.org");
|
||||
|
||||
return about;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue