Changeset View
Changeset View
Standalone View
Standalone View
libs/widgets/KoRuler.cpp
Show First 20 Lines • Show All 703 Lines • ▼ Show 20 Line(s) | 679 | KoRulerPrivate::KoRulerPrivate(KoRuler *parent, const KoViewConverter *vc, Qt::Orientation o) | |||
---|---|---|---|---|---|
704 | selected(None), | 704 | selected(None), | ||
705 | selectOffset(0), | 705 | selectOffset(0), | ||
706 | tabChooser(0), | 706 | tabChooser(0), | ||
707 | normalPaintingStrategy(o == Qt::Horizontal ? | 707 | normalPaintingStrategy(o == Qt::Horizontal ? | ||
708 | (PaintingStrategy*)new HorizontalPaintingStrategy() : (PaintingStrategy*)new VerticalPaintingStrategy()), | 708 | (PaintingStrategy*)new HorizontalPaintingStrategy() : (PaintingStrategy*)new VerticalPaintingStrategy()), | ||
709 | distancesPaintingStrategy((PaintingStrategy*)new HorizontalDistancesPaintingStrategy()), | 709 | distancesPaintingStrategy((PaintingStrategy*)new HorizontalDistancesPaintingStrategy()), | ||
710 | paintingStrategy(normalPaintingStrategy), | 710 | paintingStrategy(normalPaintingStrategy), | ||
711 | ruler(parent), | 711 | ruler(parent), | ||
712 | guideCreationStarted(false) | 712 | guideCreationStarted(false), | ||
713 | pixelStep(100.0) | ||||
713 | { | 714 | { | ||
714 | } | 715 | } | ||
715 | 716 | | |||
716 | KoRulerPrivate::~KoRulerPrivate() | 717 | KoRulerPrivate::~KoRulerPrivate() | ||
717 | { | 718 | { | ||
718 | delete normalPaintingStrategy; | 719 | delete normalPaintingStrategy; | ||
719 | delete distancesPaintingStrategy; | 720 | delete distancesPaintingStrategy; | ||
720 | } | 721 | } | ||
721 | 722 | | |||
722 | qreal KoRulerPrivate::numberStepForUnit() const | 723 | qreal KoRulerPrivate::numberStepForUnit() const | ||
723 | { | 724 | { | ||
724 | switch(unit.type()) { | 725 | switch(unit.type()) { | ||
725 | case KoUnit::Inch: | 726 | case KoUnit::Inch: | ||
726 | case KoUnit::Centimeter: | 727 | case KoUnit::Centimeter: | ||
727 | case KoUnit::Decimeter: | 728 | case KoUnit::Decimeter: | ||
728 | case KoUnit::Millimeter: | 729 | case KoUnit::Millimeter: | ||
729 | return 1.0; | 730 | return 1.0; | ||
730 | case KoUnit::Pica: | 731 | case KoUnit::Pica: | ||
731 | case KoUnit::Cicero: | 732 | case KoUnit::Cicero: | ||
732 | return 10.0; | 733 | return 10.0; | ||
733 | case KoUnit::Point: | 734 | case KoUnit::Point: | ||
734 | default: | 735 | default: | ||
735 | return 100.0; | 736 | return pixelStep; | ||
736 | } | 737 | } | ||
737 | } | 738 | } | ||
738 | 739 | | |||
739 | qreal KoRulerPrivate::doSnapping(const qreal value) const | 740 | qreal KoRulerPrivate::doSnapping(const qreal value) const | ||
740 | { | 741 | { | ||
741 | qreal numberStep = unit.fromUserValue(numberStepForUnit()/4.0); | 742 | qreal numberStep = unit.fromUserValue(numberStepForUnit()/4.0); | ||
742 | return numberStep * qRound(value / numberStep); | 743 | return numberStep * qRound(value / numberStep); | ||
743 | } | 744 | } | ||
▲ Show 20 Lines • Show All 619 Lines • ▼ Show 20 Line(s) | |||||
1363 | void KoRuler::createGuideToolConnection(KoCanvasBase *canvas) | 1364 | void KoRuler::createGuideToolConnection(KoCanvasBase *canvas) | ||
1364 | { | 1365 | { | ||
1365 | Q_ASSERT(canvas); | 1366 | Q_ASSERT(canvas); | ||
1366 | KoToolBase *tool = KoToolManager::instance()->toolById(canvas, QLatin1String("GuidesTool")); | 1367 | KoToolBase *tool = KoToolManager::instance()->toolById(canvas, QLatin1String("GuidesTool")); | ||
1367 | if (!tool) return; // It's perfectly fine to have no guides tool, we don't have to warn the user about it | 1368 | if (!tool) return; // It's perfectly fine to have no guides tool, we don't have to warn the user about it | ||
1368 | connect(this, SIGNAL(guideLineCreated(Qt::Orientation,qreal)), | 1369 | connect(this, SIGNAL(guideLineCreated(Qt::Orientation,qreal)), | ||
1369 | tool, SLOT(createGuideLine(Qt::Orientation,qreal))); | 1370 | tool, SLOT(createGuideLine(Qt::Orientation,qreal))); | ||
1370 | } | 1371 | } | ||
1372 | | ||||
1373 | void KoRuler::setUnitPixelMultiple2(bool enabled) | ||||
1374 | { | ||||
1375 | if (enabled) { | ||||
1376 | d->pixelStep = 64.0; | ||||
1377 | } | ||||
1378 | else { | ||||
1379 | d->pixelStep = 100.0; | ||||
1380 | } | ||||
1381 | } |