Set proper colors in PartResizeWidget

main
Aurélien Gâteau 11 years ago
parent 055904b20a
commit 310fdc56d9

@ -18,8 +18,9 @@
#include <CreatePartitionDialog.h> #include <CreatePartitionDialog.h>
#include <PartitionSizeController.h> #include <ColorUtils.h>
#include <PartitionInfo.h> #include <PartitionInfo.h>
#include <PartitionSizeController.h>
#include <PMUtils.h> #include <PMUtils.h>
#include <ui_CreatePartitionDialog.h> #include <ui_CreatePartitionDialog.h>
#include <utils/Logger.h> #include <utils/Logger.h>
@ -157,7 +158,10 @@ CreatePartitionDialog::initPartResizerWidget( Partition* partition )
qint64 maxLastSector = partition->lastSector() + m_device->partitionTable()->freeSectorsAfter( *partition ); qint64 maxLastSector = partition->lastSector() + m_device->partitionTable()->freeSectorsAfter( *partition );
m_ui->partResizerWidget->init( *m_device, *m_partResizerWidgetPartition, minFirstSector, maxLastSector ); m_ui->partResizerWidget->init( *m_device, *m_partResizerWidgetPartition, minFirstSector, maxLastSector );
controller->init( m_device, m_partResizerWidgetPartition.data() ); QColor color = PMUtils::isPartitionFreeSpace( partition )
? ColorUtils::colorForPartitionInFreeSpace( partition )
: ColorUtils::colorForPartition( partition );
controller->init( m_device, m_partResizerWidgetPartition.data(), color );
controller->setPartResizerWidget( m_ui->partResizerWidget ); controller->setPartResizerWidget( m_ui->partResizerWidget );
controller->setSpinBox( m_ui->sizeSpinBox ); controller->setSpinBox( m_ui->sizeSpinBox );
} }

@ -18,6 +18,7 @@
#include <EditExistingPartitionDialog.h> #include <EditExistingPartitionDialog.h>
#include <ColorUtils.h>
#include <PartitionCoreModule.h> #include <PartitionCoreModule.h>
#include <PartitionInfo.h> #include <PartitionInfo.h>
#include <PartitionSizeController.h> #include <PartitionSizeController.h>
@ -46,7 +47,8 @@ EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partit
// last sectors when used // last sectors when used
m_partResizerWidgetPartition.reset( PMUtils::clonePartition( m_device, m_partition ) ); m_partResizerWidgetPartition.reset( PMUtils::clonePartition( m_device, m_partition ) );
m_partitionSizeController->init( m_device, m_partResizerWidgetPartition.data() ); QColor color = ColorUtils::colorForPartition( m_partition );
m_partitionSizeController->init( m_device, m_partResizerWidgetPartition.data(), color );
m_partitionSizeController->setSpinBox( m_ui->sizeSpinBox ); m_partitionSizeController->setSpinBox( m_ui->sizeSpinBox );
m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) ); m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) );

@ -18,6 +18,8 @@
#include <PartitionSizeController.h> #include <PartitionSizeController.h>
#include <ColorUtils.h>
// Qt // Qt
#include <QSpinBox> #include <QSpinBox>
@ -41,6 +43,11 @@ PartitionSizeController::setPartResizerWidget( PartResizerWidget* widget )
m_partResizerWidget = widget; m_partResizerWidget = widget;
// FIXME: Should be set by PartResizerWidget itself // FIXME: Should be set by PartResizerWidget itself
m_partResizerWidget->setFixedHeight( PartResizerWidget::handleHeight() ); m_partResizerWidget->setFixedHeight( PartResizerWidget::handleHeight() );
QPalette pal = widget->palette();
pal.setColor( QPalette::Base, ColorUtils::freeSpaceColor() );
pal.setColor( QPalette::Button, m_partitionColor );
m_partResizerWidget->setPalette( pal );
updateConnections(); updateConnections();
} }
@ -55,10 +62,11 @@ PartitionSizeController::setSpinBox( QSpinBox* spinBox )
} }
void void
PartitionSizeController::init( Device* device, Partition* partition ) PartitionSizeController::init( Device* device, Partition* partition, const QColor& color )
{ {
m_device = device; m_device = device;
m_partition = partition; m_partition = partition;
m_partitionColor = color;
} }
void void

@ -19,6 +19,7 @@
#ifndef PARTITIONSIZECONTROLLER_H #ifndef PARTITIONSIZECONTROLLER_H
#define PARTITIONSIZECONTROLLER_H #define PARTITIONSIZECONTROLLER_H
#include <QColor>
#include <QObject> #include <QObject>
#include <QPointer> #include <QPointer>
@ -38,13 +39,14 @@ public:
explicit PartitionSizeController( QObject* parent = nullptr ); explicit PartitionSizeController( QObject* parent = nullptr );
void setPartResizerWidget( PartResizerWidget* widget ); void setPartResizerWidget( PartResizerWidget* widget );
void setSpinBox( QSpinBox* spinBox ); void setSpinBox( QSpinBox* spinBox );
void init( Device* device, Partition* partition ); void init( Device* device, Partition* partition, const QColor& color );
private: private:
QPointer< PartResizerWidget > m_partResizerWidget; QPointer< PartResizerWidget > m_partResizerWidget;
QPointer< QSpinBox > m_spinBox; QPointer< QSpinBox > m_spinBox;
Device* m_device = nullptr; Device* m_device = nullptr;
Partition* m_partition = nullptr; Partition* m_partition = nullptr;
QColor m_partitionColor;
bool m_updating = false; bool m_updating = false;
void updateConnections(); void updateConnections();

Loading…
Cancel
Save