Add ObjectsCenter action to center objects in label both h and v. (#184)
This commit is contained in:
@@ -188,6 +188,16 @@ namespace glabels
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Center : public QIcon
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Center()
|
||||||
|
{
|
||||||
|
addPixmap( QPixmap( ":icons/flat/16x16/glabels-center.svg" ) );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class CenterHoriz : public QIcon
|
class CenterHoriz : public QIcon
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -574,6 +574,11 @@ namespace glabels
|
|||||||
objectsCenterVertAction->setStatusTip( tr("Vertically center objects in label") );
|
objectsCenterVertAction->setStatusTip( tr("Vertically center objects in label") );
|
||||||
connect( objectsCenterVertAction, SIGNAL(triggered()), this, SLOT(objectsCenterVert()) );
|
connect( objectsCenterVertAction, SIGNAL(triggered()), this, SLOT(objectsCenterVert()) );
|
||||||
|
|
||||||
|
objectsCenterAction = new QAction( tr("Center Both"), this );
|
||||||
|
objectsCenterAction->setIcon( Icons::Center() );
|
||||||
|
objectsCenterAction->setStatusTip( tr("Center objects in label") );
|
||||||
|
connect( objectsCenterAction, SIGNAL(triggered()), this, SLOT(objectsCenter()) );
|
||||||
|
|
||||||
|
|
||||||
/* Help actions */
|
/* Help actions */
|
||||||
helpContentsAction = new QAction( tr("&User Manual..."), this );
|
helpContentsAction = new QAction( tr("&User Manual..."), this );
|
||||||
@@ -698,6 +703,7 @@ namespace glabels
|
|||||||
objectsCenterMenu = objectsMenu->addMenu( tr("Center") );
|
objectsCenterMenu = objectsMenu->addMenu( tr("Center") );
|
||||||
objectsCenterMenu->addAction( objectsCenterHorizAction );
|
objectsCenterMenu->addAction( objectsCenterHorizAction );
|
||||||
objectsCenterMenu->addAction( objectsCenterVertAction );
|
objectsCenterMenu->addAction( objectsCenterVertAction );
|
||||||
|
objectsCenterMenu->addAction( objectsCenterAction );
|
||||||
|
|
||||||
helpMenu = menuBar()->addMenu( tr("&Help") );
|
helpMenu = menuBar()->addMenu( tr("&Help") );
|
||||||
helpMenu->addAction( helpContentsAction );
|
helpMenu->addAction( helpContentsAction );
|
||||||
@@ -724,6 +730,7 @@ namespace glabels
|
|||||||
contextCenterMenu = contextMenu->addMenu( tr("Center") );
|
contextCenterMenu = contextMenu->addMenu( tr("Center") );
|
||||||
contextCenterMenu->addAction( objectsCenterHorizAction );
|
contextCenterMenu->addAction( objectsCenterHorizAction );
|
||||||
contextCenterMenu->addAction( objectsCenterVertAction );
|
contextCenterMenu->addAction( objectsCenterVertAction );
|
||||||
|
contextCenterMenu->addAction( objectsCenterAction );
|
||||||
contextMenu->addSeparator();
|
contextMenu->addSeparator();
|
||||||
contextMenu->addAction( contextCutAction );
|
contextMenu->addAction( contextCutAction );
|
||||||
contextMenu->addAction( contextCopyAction );
|
contextMenu->addAction( contextCopyAction );
|
||||||
@@ -1005,6 +1012,7 @@ namespace glabels
|
|||||||
objectsCenterMenu->setEnabled( isEditorPage && hasSelection );
|
objectsCenterMenu->setEnabled( isEditorPage && hasSelection );
|
||||||
objectsCenterHorizAction->setEnabled( isEditorPage && hasSelection );
|
objectsCenterHorizAction->setEnabled( isEditorPage && hasSelection );
|
||||||
objectsCenterVertAction->setEnabled( isEditorPage && hasSelection );
|
objectsCenterVertAction->setEnabled( isEditorPage && hasSelection );
|
||||||
|
objectsCenterAction->setEnabled( isEditorPage && hasSelection );
|
||||||
|
|
||||||
// Help actions
|
// Help actions
|
||||||
helpContentsAction->setEnabled( true );
|
helpContentsAction->setEnabled( true );
|
||||||
@@ -1650,6 +1658,16 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Objects->Center Action
|
||||||
|
///
|
||||||
|
void MainWindow::objectsCenter()
|
||||||
|
{
|
||||||
|
mUndoRedoModel->checkpoint( tr("Center") );
|
||||||
|
mModel->centerSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Objects->Center->Vertically Action
|
/// Objects->Center->Vertically Action
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ namespace glabels
|
|||||||
void objectsAlignTop();
|
void objectsAlignTop();
|
||||||
void objectsAlignVCenter();
|
void objectsAlignVCenter();
|
||||||
void objectsAlignBottom();
|
void objectsAlignBottom();
|
||||||
|
void objectsCenter();
|
||||||
void objectsCenterHoriz();
|
void objectsCenterHoriz();
|
||||||
void objectsCenterVert();
|
void objectsCenterVert();
|
||||||
|
|
||||||
@@ -301,6 +302,7 @@ namespace glabels
|
|||||||
QAction* objectsAlignTopAction;
|
QAction* objectsAlignTopAction;
|
||||||
QAction* objectsAlignVCenterAction;
|
QAction* objectsAlignVCenterAction;
|
||||||
QAction* objectsAlignBottomAction;
|
QAction* objectsAlignBottomAction;
|
||||||
|
QAction* objectsCenterAction;
|
||||||
QAction* objectsCenterHorizAction;
|
QAction* objectsCenterHorizAction;
|
||||||
QAction* objectsCenterVertAction;
|
QAction* objectsCenterVertAction;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<file>icons/flat/16x16/glabels-arrow.svg</file>
|
<file>icons/flat/16x16/glabels-arrow.svg</file>
|
||||||
<file>icons/flat/16x16/glabels-barcode.svg</file>
|
<file>icons/flat/16x16/glabels-barcode.svg</file>
|
||||||
<file>icons/flat/16x16/glabels-box.svg</file>
|
<file>icons/flat/16x16/glabels-box.svg</file>
|
||||||
|
<file>icons/flat/16x16/glabels-center.svg</file>
|
||||||
<file>icons/flat/16x16/glabels-center-horiz.svg</file>
|
<file>icons/flat/16x16/glabels-center-horiz.svg</file>
|
||||||
<file>icons/flat/16x16/glabels-center-vert.svg</file>
|
<file>icons/flat/16x16/glabels-center-vert.svg</file>
|
||||||
<file>icons/flat/16x16/glabels-edit-clear.svg</file>
|
<file>icons/flat/16x16/glabels-edit-clear.svg</file>
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="16" height="16" >
|
||||||
|
|
||||||
|
<path
|
||||||
|
style="fill:#333333;fill-opacity:1;stroke:none"
|
||||||
|
d="M 7.5,6 5,3 10,3 Z" />
|
||||||
|
|
||||||
|
<path
|
||||||
|
style="fill:#333333;fill-opacity:1;stroke:none"
|
||||||
|
d="M 7.5,9 5,12 10,12 Z" />
|
||||||
|
|
||||||
|
<line
|
||||||
|
style="fill:none;stroke:#333333;stroke-opacity:1;stroke-width:1"
|
||||||
|
x1="7.5" y1="1" x2="7.5" y2="5" />
|
||||||
|
|
||||||
|
<line
|
||||||
|
style="fill:none;stroke:#333333;stroke-opacity:1;stroke-width:1"
|
||||||
|
x1="7.5" y1="10" x2="7.5" y2="14" />
|
||||||
|
|
||||||
|
|
||||||
|
<path
|
||||||
|
style="fill:#333333;fill-opacity:1;stroke:none"
|
||||||
|
d="M 6,7.5 3,5 3,10 Z" />
|
||||||
|
|
||||||
|
<path
|
||||||
|
style="fill:#333333;fill-opacity:1;stroke:none"
|
||||||
|
d="M 9,7.5 12,5 12,10 Z" />
|
||||||
|
|
||||||
|
<line
|
||||||
|
style="fill:none;stroke:#333333;stroke-opacity:1;stroke-width:1"
|
||||||
|
x1="1" y1="7.5" x2="5" y2="7.5" />
|
||||||
|
|
||||||
|
<line
|
||||||
|
style="fill:none;stroke:#333333;stroke-opacity:1;stroke-width:1"
|
||||||
|
x1="10" y1="7.5" x2="14" y2="7.5" />
|
||||||
|
|
||||||
|
|
||||||
|
<line
|
||||||
|
style="fill:none;stroke:#333333;stroke-opacity:1;stroke-width:1"
|
||||||
|
x1="7" y1="7.5" x2="8" y2="7.5" />
|
||||||
|
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -1163,6 +1163,33 @@ namespace glabels
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Align Selected Objects To Center Of Label Both Horizontally and Vertically
|
||||||
|
///
|
||||||
|
void Model::centerSelection()
|
||||||
|
{
|
||||||
|
Distance xLabelCenter = w() / 2.0;
|
||||||
|
Distance yLabelCenter = h() / 2.0;
|
||||||
|
|
||||||
|
foreach ( ModelObject* object, mObjectList )
|
||||||
|
{
|
||||||
|
if ( object->isSelected() )
|
||||||
|
{
|
||||||
|
Region r = object->getExtent();
|
||||||
|
Distance xObjectCenter = (r.x1() + r.x2()) / 2.0;
|
||||||
|
Distance yObjectCenter = (r.y1() + r.y2()) / 2.0;
|
||||||
|
Distance dx = xLabelCenter - xObjectCenter;
|
||||||
|
Distance dy = yLabelCenter - yObjectCenter;
|
||||||
|
object->setPositionRelative( dx, dy );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setModified();
|
||||||
|
|
||||||
|
emit changed();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Align Selected Objects To Center Of Label Vertically
|
/// Align Selected Objects To Center Of Label Vertically
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -184,6 +184,7 @@ namespace glabels
|
|||||||
void alignSelectionTop();
|
void alignSelectionTop();
|
||||||
void alignSelectionBottom();
|
void alignSelectionBottom();
|
||||||
void alignSelectionVCenter();
|
void alignSelectionVCenter();
|
||||||
|
void centerSelection();
|
||||||
void centerSelectionHoriz();
|
void centerSelectionHoriz();
|
||||||
void centerSelectionVert();
|
void centerSelectionVert();
|
||||||
void moveSelection( const Distance& dx, const Distance& dy );
|
void moveSelection( const Distance& dx, const Distance& dy );
|
||||||
|
|||||||
@@ -1879,6 +1879,14 @@
|
|||||||
<source>Redo %1</source>
|
<source>Redo %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Center Both</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Center objects in label</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>glabels::MergeView</name>
|
<name>glabels::MergeView</name>
|
||||||
|
|||||||
Reference in New Issue
Block a user