1 //============================================================================= 2 // MuseScore 3 // Music Composition & Notation 4 // 5 // Copyright (C) 2017 Werner Schweer and others 6 // 7 // This program is free software; you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License version 2 9 // as published by the Free Software Foundation and appearing in 10 // the file LICENSE.GPL 11 //============================================================================= 12 13 #include "offsetSelect.h" 14 #include "libmscore/types.h" 15 #include "icons.h" 16 #include "musescore.h" 17 #include "inspectorBase.h" 18 19 namespace Ms { 20 21 //--------------------------------------------------------- 22 // OffsetSelect 23 //--------------------------------------------------------- 24 OffsetSelect(QWidget * parent)25OffsetSelect::OffsetSelect(QWidget* parent) 26 : QWidget(parent) 27 { 28 setupUi(this); 29 30 showRaster(false); 31 32 QAction* a = getAction("hraster"); 33 a->setCheckable(true); 34 hRaster->setDefaultAction(a); 35 hRaster->setContextMenuPolicy(Qt::ActionsContextMenu); 36 hRaster->addAction(getAction("config-raster")); 37 38 a = getAction("vraster"); 39 a->setCheckable(true); 40 vRaster->setDefaultAction(a); 41 vRaster->setContextMenuPolicy(Qt::ActionsContextMenu); 42 vRaster->addAction(getAction("config-raster")); 43 44 connect(xVal, SIGNAL(valueChanged(double)), SLOT(_offsetChanged())); 45 connect(yVal, SIGNAL(valueChanged(double)), SLOT(_offsetChanged())); 46 } 47 48 //--------------------------------------------------------- 49 // setSuffix 50 //--------------------------------------------------------- 51 setSuffix(const QString & s)52void OffsetSelect::setSuffix(const QString& s) 53 { 54 xVal->setSuffix(s); 55 yVal->setSuffix(s); 56 } 57 58 //--------------------------------------------------------- 59 // showRaster 60 //--------------------------------------------------------- 61 showRaster(bool v)62void OffsetSelect::showRaster(bool v) 63 { 64 hRaster->setVisible(v); 65 vRaster->setVisible(v); 66 } 67 68 //--------------------------------------------------------- 69 // _offsetChanged 70 //--------------------------------------------------------- 71 _offsetChanged()72void OffsetSelect::_offsetChanged() 73 { 74 emit offsetChanged(QPointF(xVal->value(), yVal->value())); 75 } 76 77 //--------------------------------------------------------- 78 // offset 79 //--------------------------------------------------------- 80 offset() const81QPointF OffsetSelect::offset() const 82 { 83 return QPointF(xVal->value(), yVal->value()); 84 } 85 86 //--------------------------------------------------------- 87 // blockOffset 88 //--------------------------------------------------------- 89 blockOffset(bool val)90void OffsetSelect::blockOffset(bool val) 91 { 92 xVal->blockSignals(val); 93 yVal->blockSignals(val); 94 } 95 96 //--------------------------------------------------------- 97 // setOffset 98 //--------------------------------------------------------- 99 setOffset(const QPointF & o)100void OffsetSelect::setOffset(const QPointF& o) 101 { 102 blockOffset(true); 103 xVal->setValue(o.x()); 104 yVal->setValue(o.y()); 105 blockOffset(false); 106 } 107 installScrollPreventer(InspectorScrollPreventer * sp)108void OffsetSelect::installScrollPreventer(InspectorScrollPreventer* sp) 109 { 110 xVal->installEventFilter(sp); 111 yVal->installEventFilter(sp); 112 } 113 114 } 115 116 117