void SizeDialogBase::setupConstraints() { setMinimumLength(!canShrink() ? partition().length() : qMax(partition().sectorsUsed(), partition().minimumSectors())); setMaximumLength(!canGrow() ? partition().length() : qMin(maximumLastSector() - minimumFirstSector() + 1, partition().maximumSectors())); dialogWidget().partResizerWidget().setMinimumLength(minimumLength()); dialogWidget().partResizerWidget().setMaximumLength(maximumLength()); dialogWidget().labelMinSize().setText(Capacity::formatByteSize(minimumLength() * device().logicalSectorSize())); dialogWidget().labelMaxSize().setText(Capacity::formatByteSize(maximumLength() * device().logicalSectorSize())); dialogWidget().spinCapacity().setEnabled(canShrink() || canGrow()); dialogWidget().partResizerWidget().setMaximumFirstSector(maximumFirstSector()); dialogWidget().partResizerWidget().setMinimumLastSector(minimumLastSector()); const qint64 totalCapacity = sectorsToDialogUnit(device(), maximumLastSector() - minimumFirstSector() + 1); const qint64 minCapacity = sectorsToDialogUnit(device(), minimumLength()); const qint64 maxCapacity = sectorsToDialogUnit(device(), maximumLength()); dialogWidget().spinCapacity().setRange(minCapacity, maxCapacity); const qint64 maxFree = totalCapacity - minCapacity; dialogWidget().spinFreeBefore().setRange(0, maxFree); dialogWidget().spinFreeAfter().setRange(0, maxFree); detailsWidget().spinFirstSector().setRange(minimumFirstSector(), maximumLastSector()); detailsWidget().spinLastSector().setRange(minimumFirstSector(), maximumLastSector()); onAlignToggled(align()); }
std::shared_ptr<Wt::WValidator> createNameValidator(const std::string& field) { auto v = std::make_shared<Wt::WLengthValidator>(); v->setMandatory(true); v->setMinimumLength(1); v->setMaximumLength(MAX_LENGTH); return v; }
/** Intializes the PartResizerWidget @param d the Device the Partition is on @param p the Partition to show and/or resize @param minFirst the minimum value for the first sector @param maxLast the maximum value for the last sector */ void PartResizerWidget::init(Device& d, Partition& p, qint64 minFirst, qint64 maxLast, bool read_only, bool move_allowed) { setDevice(d); setPartition(p); setMinimumFirstSector(minFirst); setMaximumLastSector(maxLast); setReadOnly(read_only); setMoveAllowed(move_allowed); setMinimumLength(qMax(partition().sectorsUsed(), partition().minimumSectors())); setMaximumLength(qMin(totalSectors(), partition().maximumSectors())); // set margins to accommodate to 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); if (!readOnly()) { QPixmap pixmap(handleWidth(), handleHeight()); pixmap.fill(Qt::transparent); QPainter p(&pixmap); QStyleOption opt; opt.state |= QStyle::State_Horizontal; opt.rect = pixmap.rect().adjusted(0, 2, 0, -2); style()->drawControl(QStyle::CE_Splitter, &opt, &p, this); leftHandle().setPixmap(pixmap); rightHandle().setPixmap(pixmap); leftHandle().setFixedSize(handleWidth(), handleHeight()); rightHandle().setFixedSize(handleWidth(), handleHeight()); } delete m_PartWidget; m_PartWidget = new PartWidget(this, &partition()); if (!readOnly()) { leftHandle().setCursor(Qt::SizeHorCursor); rightHandle().setCursor(Qt::SizeHorCursor); } if (moveAllowed()) partWidget().setCursor(Qt::SizeAllCursor); partWidget().setToolTip(QString()); updatePositions(); }