Add toolbar widget for edit size of handler in diagram editor.

Add a combo box in the tool bar of diagram editor
to quickly change the size of the graphics handler item.

The sarto commit :D

NOTE
only available for diagram editor, element editor will
come later.
This commit is contained in:
joshua
2022-01-03 21:01:25 +01:00
parent e087270b6d
commit ae9faa2192
11 changed files with 223 additions and 6 deletions

View File

@@ -18,6 +18,9 @@
#include "qetutils.h"
#include <QString>
#include <QStringList>
#include <QGraphicsView>
#include "../qetapp.h"
#include "../qetdiagrameditor.h"
/**
@brief QETUtils::marginsToString
@@ -57,3 +60,30 @@ QMargins QETUtils::marginsFromString(const QString &string)
return margins;
}
/**
* @brief QETUtils::graphicsHandlerSize
* @param item
* @return Return the handler size to use in the QGraphicsScene of @a item.
* If size can't be found, return 10 by default.
*/
qreal QETUtils::graphicsHandlerSize(QGraphicsItem *item)
{
if (const auto scene_ = item->scene())
{
if (!scene_->views().isEmpty())
{
if (const auto editor_ = QETApp::instance()->diagramEditorAncestorOf(scene_->views().at(0)))
{
const auto variant_ = editor_->property("graphics_handler_size");
//If variant_ can't be converted to qreal, the returned qreal is 0.0
//it's sufficient for us to check if value is set or not.
if (const auto value_ = variant_.toReal())
return value_;
}
}
}
//Default value
return 10;
}