mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user