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,22 +87,25 @@ 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 );
|
||||
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 */
|
||||
QPixmap pixmap(handleWidth(), handleHeight());
|
||||
pixmap.fill( Qt::transparent );
|
||||
pixmap.fill(Qt::transparent);
|
||||
{
|
||||
QPainter p( &pixmap );
|
||||
QPainter p(&pixmap);
|
||||
QStyleOption opt;
|
||||
opt.state |= QStyle::State_Horizontal;
|
||||
opt.rect = pixmap.rect().adjusted( 0, 2, 0, -2 );
|
||||
opt.rect = pixmap.rect().adjusted(0, 2, 0, -2);
|
||||
style()->drawControl(QStyle::CE_Splitter, &opt, &p, this);
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
@ -146,10 +153,13 @@ int PartResizerWidget::partWidgetWidth() const
|
|||
|
||||
void PartResizerWidget::updatePositions()
|
||||
{
|
||||
QMargins margins( contentsMargins() );
|
||||
QMargins margins(contentsMargins());
|
||||
|
||||
partWidget().move(partWidgetStart() + margins.left(), margins.top());
|
||||
partWidget().resize(partWidgetWidth() - margins.left() - margins.right(), height() - margins.top() - margins.bottom() );
|
||||
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();
|
||||
|
@ -166,14 +176,14 @@ void PartResizerWidget::paintEvent(QPaintEvent*)
|
|||
// draw sunken frame
|
||||
QPainter painter(this);
|
||||
QStyleOptionFrameV3 opt;
|
||||
opt.initFrom( this );
|
||||
opt.initFrom(this);
|
||||
opt.frameShape = QFrame::StyledPanel;
|
||||
opt.state |= QStyle::State_Sunken;
|
||||
|
||||
// disable mouse over and focus state
|
||||
opt.state &= ~QStyle::State_MouseOver;
|
||||
opt.state &= ~QStyle::State_HasFocus;
|
||||
opt.rect.adjust( handleWidth(), 0, -handleWidth()-1, -1 );
|
||||
opt.rect.adjust(handleWidth(), 0, -handleWidth() - 1, -1);
|
||||
style()->drawControl(QStyle::CE_ShapedFrame, &opt, &painter, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -102,7 +102,7 @@ void PartWidget::paintEvent(QPaintEvent*)
|
|||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHints(QPainter::Antialiasing);
|
||||
drawGradient( &painter, activeColor(Config::fileSystemColorCode(partition()->fileSystem().type())),QRect(0, 0, width() - 1, height() - 1));
|
||||
drawGradient(&painter, activeColor(Config::fileSystemColorCode(partition()->fileSystem().type())), QRect(0, 0, width() - 1, height() - 1));
|
||||
|
||||
if (partition()->roles().has(PartitionRole::Extended))
|
||||
return;
|
||||
|
@ -110,10 +110,10 @@ void PartWidget::paintEvent(QPaintEvent*)
|
|||
if (!partition()->roles().has(PartitionRole::Unallocated))
|
||||
{
|
||||
// draw free space background
|
||||
drawGradient( &painter, activeColor(Config::availableSpaceColorCode()), QRect(PartWidget::borderWidth(), PartWidget::borderHeight(), width() - 1 - (PartWidget::borderWidth() * 2), height() - (PartWidget::borderHeight() * 2)));
|
||||
drawGradient(&painter, activeColor(Config::availableSpaceColorCode()), QRect(PartWidget::borderWidth(), PartWidget::borderHeight(), width() - 1 - (PartWidget::borderWidth() * 2), height() - (PartWidget::borderHeight() * 2)));
|
||||
|
||||
// draw used space in front of that
|
||||
drawGradient( &painter, activeColor(Config::usedSpaceColorCode()), QRect(PartWidget::borderWidth(), PartWidget::borderHeight(), w, height() - (PartWidget::borderHeight() * 2)));
|
||||
drawGradient(&painter, activeColor(Config::usedSpaceColorCode()), QRect(PartWidget::borderWidth(), PartWidget::borderHeight(), w, height() - (PartWidget::borderHeight() * 2)));
|
||||
}
|
||||
|
||||
// draw name and size
|
||||
|
@ -125,18 +125,18 @@ void PartWidget::paintEvent(QPaintEvent*)
|
|||
painter.drawText(textRect, Qt::AlignVCenter | Qt::AlignHCenter, text);
|
||||
}
|
||||
|
||||
void PartWidget::drawGradient( QPainter* painter, const QColor& color, const QRect& rect ) const
|
||||
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;
|
||||
option.palette.setColor( QPalette::Button, color );
|
||||
option.palette.setColor( QPalette::Window, color );
|
||||
option.palette.setColor(QPalette::Button, color);
|
||||
option.palette.setColor(QPalette::Window, color);
|
||||
option.state |= QStyle::State_Raised;
|
||||
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