[TechDraw] Multiselection mode implementation
This commit is contained in:
@@ -867,6 +867,62 @@ for ProjectionGroups</string>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbSelection">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Selection</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="Gui::PrefCheckBox" name="cbMultiSelection">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>If enabled, clicking without Ctrl does not clear existing vertex/edge/face selection</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable Multiselection Mode</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="prefEntry" stdset="0">
|
||||
<cstring>multiSelection</cstring>
|
||||
</property>
|
||||
<property name="prefPath" stdset="0">
|
||||
<cstring>Mod/TechDraw/General</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="font">
|
||||
|
||||
@@ -71,6 +71,8 @@ void DlgPrefsTechDrawGeneralImp::saveSettings()
|
||||
ui->le_NamePattern->onSave();
|
||||
ui->cb_ShowGrid->onSave();
|
||||
ui->psb_GridSpacing->onSave();
|
||||
|
||||
ui->cbMultiSelection->onSave();
|
||||
}
|
||||
|
||||
void DlgPrefsTechDrawGeneralImp::loadSettings()
|
||||
@@ -107,6 +109,10 @@ void DlgPrefsTechDrawGeneralImp::loadSettings()
|
||||
double spacingDefault = PreferencesGui::gridSpacing();
|
||||
ui->psb_GridSpacing->setValue(spacingDefault);
|
||||
ui->psb_GridSpacing->onRestore();
|
||||
|
||||
bool multiSelectionDefault = PreferencesGui::multiSelection();
|
||||
ui->cbMultiSelection->setChecked(multiSelectionDefault);
|
||||
ui->cbMultiSelection->onRestore();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -206,6 +206,11 @@ bool PreferencesGui::showGrid()
|
||||
return Preferences::getPreferenceGroup("General")->GetBool("showGrid", false);
|
||||
}
|
||||
|
||||
bool PreferencesGui::multiSelection()
|
||||
{
|
||||
return Preferences::getPreferenceGroup("General")->GetBool("multiSelection", false);
|
||||
}
|
||||
|
||||
App::Color PreferencesGui::pageColor()
|
||||
{
|
||||
App::Color result;
|
||||
|
||||
@@ -72,6 +72,7 @@ static bool showGrid();
|
||||
static App::Color gridColor();
|
||||
static QColor gridQColor();
|
||||
static double gridSpacing();
|
||||
static bool multiSelection();
|
||||
|
||||
static QColor getAccessibleQColor(QColor orig);
|
||||
static QColor lightTextQColor();
|
||||
|
||||
@@ -63,6 +63,7 @@ Q_SIGNALS:
|
||||
void endEdit();
|
||||
|
||||
protected:
|
||||
bool multiselectEligible() override { return false; }
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -57,6 +57,8 @@ protected:
|
||||
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
bool multiselectEligible() override { return true; }
|
||||
|
||||
int projIndex; //index of edge in Projection. must exist.
|
||||
|
||||
bool isCosmetic;
|
||||
|
||||
@@ -150,6 +150,8 @@ protected:
|
||||
|
||||
bool m_hideSvgTiles;
|
||||
|
||||
bool multiselectEligible() override { return true; }
|
||||
|
||||
private:
|
||||
QPixmap m_texture; //
|
||||
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
|
||||
#include <App/Application.h>
|
||||
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawView.h>
|
||||
|
||||
#include "QGIPrimPath.h"
|
||||
#include "PreferencesGui.h"
|
||||
#include "QGIView.h"
|
||||
@@ -55,6 +59,7 @@ QGIPrimPath::QGIPrimPath():
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
isHighlighted = false;
|
||||
multiselectActivated = false;
|
||||
|
||||
m_colOverride = false;
|
||||
m_colNormal = getNormalColor();
|
||||
@@ -259,6 +264,50 @@ Qt::PenCapStyle QGIPrimPath::prefCapStyle()
|
||||
return result;
|
||||
}
|
||||
|
||||
void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Qt::KeyboardModifiers originalModifiers = event->modifiers();
|
||||
if (event->button()&Qt::LeftButton) {
|
||||
multiselectActivated = false;
|
||||
}
|
||||
|
||||
if (event->button() == Qt::LeftButton
|
||||
&& multiselectEligible()
|
||||
&& PreferencesGui::multiSelection()) {
|
||||
|
||||
auto parent = dynamic_cast<QGIView *>(parentItem());
|
||||
if (parent) {
|
||||
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx();
|
||||
if (selection.size() == 1
|
||||
&& selection.front().getObject() == parent->getViewObject()) {
|
||||
|
||||
multiselectActivated = true;
|
||||
event->setModifiers(originalModifiers | Qt::ControlModifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QGraphicsPathItem::mousePressEvent(event);
|
||||
|
||||
event->setModifiers(originalModifiers);
|
||||
}
|
||||
|
||||
void QGIPrimPath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Qt::KeyboardModifiers originalModifiers = event->modifiers();
|
||||
if ((event->button()&Qt::LeftButton) && multiselectActivated) {
|
||||
if (PreferencesGui::multiSelection()) {
|
||||
event->setModifiers(originalModifiers | Qt::ControlModifier);
|
||||
}
|
||||
|
||||
multiselectActivated = false;
|
||||
}
|
||||
|
||||
QGraphicsPathItem::mouseReleaseEvent(event);
|
||||
|
||||
event->setModifiers(originalModifiers);
|
||||
}
|
||||
|
||||
void QGIPrimPath::setFill(QColor c, Qt::BrushStyle s) {
|
||||
setFillColor(c);
|
||||
m_fillNormal = s;
|
||||
|
||||
@@ -79,6 +79,11 @@ protected:
|
||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
|
||||
virtual bool multiselectEligible() { return false; }
|
||||
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
virtual QColor getNormalColor();
|
||||
virtual QColor getPreColor();
|
||||
virtual QColor getSelectColor();
|
||||
@@ -86,6 +91,7 @@ protected:
|
||||
virtual Qt::PenCapStyle prefCapStyle();
|
||||
|
||||
bool isHighlighted;
|
||||
bool multiselectActivated;
|
||||
|
||||
QPen m_pen;
|
||||
QColor m_colCurrent;
|
||||
|
||||
@@ -46,6 +46,8 @@ public:
|
||||
virtual void setRadius(float r);
|
||||
|
||||
protected:
|
||||
bool multiselectEligible() override { return true; }
|
||||
|
||||
int projIndex;
|
||||
float m_radius;
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ QGIView::QGIView()
|
||||
:QGraphicsItemGroup(),
|
||||
viewObj(nullptr),
|
||||
m_locked(false),
|
||||
m_innerView(false)
|
||||
m_innerView(false),
|
||||
m_multiselectActivated(false)
|
||||
{
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
setHandlesChildEvents(false);
|
||||
@@ -199,7 +200,25 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
void QGIView::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGIV::mousePressEvent() - %s\n", getViewName());
|
||||
Qt::KeyboardModifiers originalModifiers = event->modifiers();
|
||||
if (event->button()&Qt::LeftButton) {
|
||||
m_multiselectActivated = false;
|
||||
}
|
||||
|
||||
if (event->button() == Qt::LeftButton && PreferencesGui::multiSelection()) {
|
||||
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx();
|
||||
if (selection.size() == 1
|
||||
&& selection.front().getObject() == getViewObject()
|
||||
&& selection.front().hasSubNames()) {
|
||||
|
||||
m_multiselectActivated = true;
|
||||
event->setModifiers(originalModifiers | Qt::ControlModifier);
|
||||
}
|
||||
}
|
||||
|
||||
QGraphicsItemGroup::mousePressEvent(event);
|
||||
|
||||
event->setModifiers(originalModifiers);
|
||||
}
|
||||
|
||||
void QGIView::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
|
||||
@@ -210,7 +229,18 @@ void QGIView::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
|
||||
void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGIV::mouseReleaseEvent() - %s\n", getViewName());
|
||||
Qt::KeyboardModifiers originalModifiers = event->modifiers();
|
||||
if ((event->button()&Qt::LeftButton) && m_multiselectActivated) {
|
||||
if (PreferencesGui::multiSelection()) {
|
||||
event->setModifiers(originalModifiers | Qt::ControlModifier);
|
||||
}
|
||||
|
||||
m_multiselectActivated = false;
|
||||
}
|
||||
|
||||
QGraphicsItemGroup::mouseReleaseEvent(event);
|
||||
|
||||
event->setModifiers(originalModifiers);
|
||||
}
|
||||
|
||||
void QGIView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
|
||||
@@ -183,6 +183,7 @@ private:
|
||||
QHash<QString, QGraphicsItem*> alignHash;
|
||||
bool m_locked;
|
||||
bool m_innerView; //View is inside another View
|
||||
bool m_multiselectActivated;
|
||||
|
||||
QPen m_pen;
|
||||
QBrush m_brush;
|
||||
|
||||
Reference in New Issue
Block a user