[TD]add preferences for Balloon drag modifiers
This commit is contained in:
@@ -612,3 +612,32 @@ double Preferences::SnapLimitFactor()
|
||||
}
|
||||
|
||||
|
||||
//! returns the key combination that simulates multiple selection. Traditionally Ctrl+pick, as that
|
||||
//! is how QGraphicsScene implements multiple selection. This method is likely to only be used by
|
||||
//! developers.
|
||||
Qt::KeyboardModifiers Preferences::multiselectModifiers()
|
||||
{
|
||||
uint iModifiers = getPreferenceGroup("General")->GetUnsigned("MultiselectModifiers", (uint)Qt::ControlModifier);
|
||||
return (Qt::KeyboardModifiers)iModifiers;
|
||||
// Qt::KeyboardModifiers testMods = Qt::ControlModifier;
|
||||
// return testMods;
|
||||
}
|
||||
|
||||
|
||||
//! returns the key combination that modifies Balloon drag behaviour so that the bubble and leader
|
||||
//! are moved together. Traditionally Ctrl+drag, but that can be in conflict with multi selection.
|
||||
Qt::KeyboardModifiers Preferences::balloonDragModifiers()
|
||||
{
|
||||
uint iModifiers = getPreferenceGroup("General")->GetUnsigned("BalloonDragModifier", (uint)Qt::ControlModifier);
|
||||
return (Qt::KeyboardModifiers)iModifiers;
|
||||
// Qt::KeyboardModifiers testMods = Qt::ShiftModifier | Qt::ControlModifier;
|
||||
// return testMods;
|
||||
}
|
||||
|
||||
|
||||
void Preferences::setBalloonDragModifiers(Qt::KeyboardModifiers newModifiers)
|
||||
{
|
||||
getPreferenceGroup("General")->SetUnsigned("BalloonDragModifier", (uint)newModifiers);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#ifndef Preferences_h_
|
||||
#define Preferences_h_
|
||||
|
||||
#include <Qt>
|
||||
#include <string>
|
||||
|
||||
#include <Base/Parameter.h>
|
||||
@@ -141,6 +142,11 @@ public:
|
||||
|
||||
static bool SnapViews();
|
||||
static double SnapLimitFactor();
|
||||
|
||||
static Qt::KeyboardModifiers multiselectModifiers();
|
||||
|
||||
static Qt::KeyboardModifiers balloonDragModifiers();
|
||||
static void setBalloonDragModifiers(Qt::KeyboardModifiers newModifiers);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>474</width>
|
||||
<height>424</height>
|
||||
<width>700</width>
|
||||
<height>810</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -443,6 +443,149 @@ can be a performance penalty in complex models.</string>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gbBehaviour">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Some combinations of OS and Navigation style key bindings may conflict with the default modifier keys for Ballon dragging and View snapping override. You can make adjustments here to find a non-conflicting key binding.</p></body></html></string>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Behaviour Overrides</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cbBalloonDefault">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to use the default modifier keys. Uncheck this box to set a different key combination.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use Default</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="cbSnapShift">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to include the Shift key in the modifiers.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Shift</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="cbSnapDefault">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to use the default modifier keys. Uncheck this box to set a different key combination.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use Default</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="cbBalloonShift">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to include the Shift key in the modifiers.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Shift</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="cbSnapAlt">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to include the Alt key in the modifiers.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Alt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="cbBalloonMeta">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to include the Meta/Start/Super key in the modifiers.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Meta</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Balloon Drag</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Snap Override</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="cbSnapControl">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to include the Control key in the modifiers.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Control</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="cbBalloonControl">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to include the Control key in the modifiers.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Control</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QCheckBox" name="cbSnapMeta">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to include the Meta/Start/Super key in the modifiers.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Meta</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="cbBalloonAlt">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to include the Alt key in the modifiers.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Alt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="font">
|
||||
@@ -469,8 +612,8 @@ can be a performance penalty in complex models.</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>17</width>
|
||||
<height>1</height>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
||||
@@ -24,17 +24,21 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <Mod/TechDraw/App/Preferences.h>
|
||||
#include "DlgPrefsTechDrawAdvancedImp.h"
|
||||
#include "ui_DlgPrefsTechDrawAdvanced.h"
|
||||
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
|
||||
DlgPrefsTechDrawAdvancedImp::DlgPrefsTechDrawAdvancedImp( QWidget* parent )
|
||||
: PreferencePage( parent )
|
||||
, ui(new Ui_DlgPrefsTechDrawAdvancedImp)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
makeBalloonBoxConnections();
|
||||
}
|
||||
|
||||
DlgPrefsTechDrawAdvancedImp::~DlgPrefsTechDrawAdvancedImp()
|
||||
@@ -58,8 +62,40 @@ void DlgPrefsTechDrawAdvancedImp::saveSettings()
|
||||
ui->cbAutoCorrectRefs->onSave();
|
||||
ui->cbNewFaceFinder->onSave();
|
||||
ui->sbScrubCount->onSave();
|
||||
|
||||
saveBalloonOverride();
|
||||
}
|
||||
|
||||
|
||||
void DlgPrefsTechDrawAdvancedImp::saveBalloonOverride()
|
||||
{
|
||||
if (ui->cbBalloonDefault->isChecked()) {
|
||||
Preferences::setBalloonDragModifiers(Qt::ControlModifier);
|
||||
return;
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers result{Qt::NoModifier};
|
||||
|
||||
if (ui->cbBalloonShift->isChecked()) {
|
||||
result |= Qt::ShiftModifier;
|
||||
}
|
||||
|
||||
if (ui->cbBalloonControl->isChecked()) {
|
||||
result |= Qt::ControlModifier;
|
||||
}
|
||||
|
||||
if (ui->cbBalloonAlt->isChecked()) {
|
||||
result |= Qt::AltModifier;
|
||||
}
|
||||
|
||||
if (ui->cbBalloonMeta->isChecked()) {
|
||||
result |= Qt::MetaModifier;
|
||||
}
|
||||
|
||||
Preferences::setBalloonDragModifiers(result);
|
||||
}
|
||||
|
||||
|
||||
void DlgPrefsTechDrawAdvancedImp::loadSettings()
|
||||
{
|
||||
ui->cbDetectFaces->onRestore();
|
||||
@@ -76,18 +112,116 @@ void DlgPrefsTechDrawAdvancedImp::loadSettings()
|
||||
ui->cbAutoCorrectRefs->onRestore();
|
||||
ui->cbNewFaceFinder->onRestore();
|
||||
ui->sbScrubCount->onRestore();
|
||||
|
||||
loadBalloonOverride();
|
||||
}
|
||||
|
||||
void DlgPrefsTechDrawAdvancedImp::loadBalloonOverride()
|
||||
{
|
||||
uint prefOverride = Preferences::balloonDragModifiers();
|
||||
if (prefOverride == Qt::ControlModifier) {
|
||||
// default case
|
||||
ui->cbBalloonDefault->setChecked(true);
|
||||
clearBalloonOptions();
|
||||
enableBalloonOptions(false);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->cbBalloonDefault->setChecked(false);
|
||||
enableBalloonOptions(true);
|
||||
|
||||
if (flagsContainValue(prefOverride, Qt::ShiftModifier)) {
|
||||
ui->cbBalloonShift->setChecked(true);
|
||||
}
|
||||
if (flagsContainValue(prefOverride, Qt::ControlModifier)) {
|
||||
ui->cbBalloonControl->setChecked(true);
|
||||
}
|
||||
|
||||
if (flagsContainValue(prefOverride, Qt::AltModifier)) {
|
||||
ui->cbBalloonAlt->setChecked(true);
|
||||
}
|
||||
|
||||
if (flagsContainValue(prefOverride, Qt::MetaModifier)) {
|
||||
ui->cbBalloonMeta->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
//! true if bit pattern of value is found in flags.
|
||||
bool DlgPrefsTechDrawAdvancedImp::flagsContainValue(uint flags, uint value)
|
||||
{
|
||||
uint matchResult = flags & value;
|
||||
if (matchResult == value) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void DlgPrefsTechDrawAdvancedImp::clearBalloonOptions()
|
||||
{
|
||||
ui->cbBalloonShift->setChecked(false);
|
||||
ui->cbBalloonControl->setChecked(false);
|
||||
ui->cbBalloonAlt->setChecked(false);
|
||||
ui->cbBalloonMeta->setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
void DlgPrefsTechDrawAdvancedImp::enableBalloonOptions(bool newState)
|
||||
{
|
||||
ui->cbBalloonShift->setEnabled(newState);
|
||||
ui->cbBalloonControl->setEnabled(newState);
|
||||
ui->cbBalloonAlt->setEnabled(newState);
|
||||
ui->cbBalloonMeta->setEnabled(newState);
|
||||
}
|
||||
|
||||
|
||||
void DlgPrefsTechDrawAdvancedImp::slotBalloonBoxChecked()
|
||||
{
|
||||
if (ui->cbBalloonDefault->isChecked()) {
|
||||
clearBalloonOptions();
|
||||
enableBalloonOptions(false);
|
||||
} else {
|
||||
enableBalloonOptions(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DlgPrefsTechDrawAdvancedImp::makeBalloonBoxConnections()
|
||||
{
|
||||
connect(ui->cbBalloonDefault,
|
||||
qOverload<int>(&QCheckBox::stateChanged),
|
||||
this,
|
||||
&DlgPrefsTechDrawAdvancedImp::slotBalloonBoxChecked);
|
||||
connect(ui->cbBalloonShift,
|
||||
qOverload<int>(&QCheckBox::stateChanged),
|
||||
this,
|
||||
&DlgPrefsTechDrawAdvancedImp::slotBalloonBoxChecked);
|
||||
connect(ui->cbBalloonControl,
|
||||
qOverload<int>(&QCheckBox::stateChanged),
|
||||
this,
|
||||
&DlgPrefsTechDrawAdvancedImp::slotBalloonBoxChecked);
|
||||
connect(ui->cbBalloonAlt,
|
||||
qOverload<int>(&QCheckBox::stateChanged),
|
||||
this,
|
||||
&DlgPrefsTechDrawAdvancedImp::slotBalloonBoxChecked);
|
||||
connect(ui->cbBalloonMeta,
|
||||
qOverload<int>(&QCheckBox::stateChanged),
|
||||
this,
|
||||
&DlgPrefsTechDrawAdvancedImp::slotBalloonBoxChecked);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the strings of the subwidgets using the current language.
|
||||
*/
|
||||
void DlgPrefsTechDrawAdvancedImp::changeEvent(QEvent *e)
|
||||
void DlgPrefsTechDrawAdvancedImp::changeEvent(QEvent *event)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
QWidget::changeEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,19 @@ public:
|
||||
protected:
|
||||
void saveSettings() override;
|
||||
void loadSettings() override;
|
||||
void changeEvent(QEvent *e) override;
|
||||
void changeEvent(QEvent *event) override;
|
||||
|
||||
void loadBalloonOverride();
|
||||
void saveBalloonOverride();
|
||||
|
||||
void clearBalloonOptions();
|
||||
|
||||
static bool flagsContainValue(uint flags, uint value);
|
||||
|
||||
void makeBalloonBoxConnections();
|
||||
void slotBalloonBoxChecked();
|
||||
void enableBalloonOptions(bool newState);
|
||||
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_DlgPrefsTechDrawAdvancedImp> ui;
|
||||
|
||||
Reference in New Issue
Block a user