Add basic configuration GUI for axis and button mapping.
This commit is contained in:
parent
1b1d49ab4c
commit
e941cf9bb1
13 changed files with 532 additions and 38 deletions
|
|
@ -2,6 +2,10 @@ Taken from http://tango.freedesktop.org/Tango_Icon_Library, version 0.8.90 / pub
|
|||
|
||||
- prefsFeatures.png (converted from preferences-system.svg)
|
||||
|
||||
https://openclipart.org/detail/35425/tango-desktop-peripherals / public domain:
|
||||
|
||||
- prefsInput.png
|
||||
|
||||
https://openclipart.org/detail/2281/information-icons-set-by-kuba / public domain:
|
||||
|
||||
- information-icons-error.png
|
||||
|
|
|
|||
BIN
icons/prefsInput.png
Normal file
BIN
icons/prefsInput.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
|
|
@ -1,5 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>icons/prefsInput.png</file>
|
||||
<file>images/zoom-text-in-white.png</file>
|
||||
<file>images/zoom-text-in.png</file>
|
||||
<file>images/zoom-text-out-white.png</file>
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ void Preferences::init() {
|
|||
this->toolBar->removeAction(prefsActionFeatures);
|
||||
#endif
|
||||
addPrefPage(group, prefsActionAdvanced, pageAdvanced);
|
||||
addPrefPage(group, prefsActionInput, pageInput);
|
||||
connect(group, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered(QAction*)));
|
||||
|
||||
prefsAction3DView->setChecked(true);
|
||||
|
|
@ -210,6 +211,22 @@ void Preferences::init() {
|
|||
initSpinBox(this->spinBoxShowWhitespaceSize, Settings::Settings::showWhitespaceSize);
|
||||
initSpinBox(this->spinBoxTabWidth, Settings::Settings::tabWidth);
|
||||
|
||||
initComboBox(this->comboBoxTranslationX, Settings::Settings::inputTranslationX);
|
||||
initComboBox(this->comboBoxTranslationY, Settings::Settings::inputTranslationY);
|
||||
initComboBox(this->comboBoxTranslationZ, Settings::Settings::inputTranslationZ);
|
||||
initComboBox(this->comboBoxRotationX, Settings::Settings::inputRotateX);
|
||||
initComboBox(this->comboBoxRotationY, Settings::Settings::inputRotateY);
|
||||
initComboBox(this->comboBoxRotationZ, Settings::Settings::inputRotateZ);
|
||||
initComboBox(this->comboBoxZoom, Settings::Settings::inputZoom);
|
||||
initComboBox(this->comboBoxButton1, Settings::Settings::inputButton1);
|
||||
initComboBox(this->comboBoxButton2, Settings::Settings::inputButton2);
|
||||
initComboBox(this->comboBoxButton3, Settings::Settings::inputButton3);
|
||||
initComboBox(this->comboBoxButton4, Settings::Settings::inputButton4);
|
||||
initComboBox(this->comboBoxButton5, Settings::Settings::inputButton5);
|
||||
initComboBox(this->comboBoxButton6, Settings::Settings::inputButton6);
|
||||
initComboBox(this->comboBoxButton7, Settings::Settings::inputButton7);
|
||||
initComboBox(this->comboBoxButton8, Settings::Settings::inputButton8);
|
||||
|
||||
SettingsReader settingsReader;
|
||||
Settings::Settings::inst()->visit(settingsReader);
|
||||
emit editorConfigChanged();
|
||||
|
|
@ -574,6 +591,96 @@ void Preferences::on_checkBoxEnableLineNumbers_toggled(bool checked)
|
|||
writeSettings();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxTranslationX_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxTranslationX, val, Settings::Settings::inputTranslationX);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxTranslationY_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxTranslationY, val, Settings::Settings::inputTranslationY);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxTranslationZ_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxTranslationZ, val, Settings::Settings::inputTranslationZ);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxRotationX_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxRotationX, val, Settings::Settings::inputRotateX);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxRotationY_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxRotationY, val, Settings::Settings::inputRotateY);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxRotationZ_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxRotationZ, val, Settings::Settings::inputRotateZ);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxZoom_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxZoom, val, Settings::Settings::inputZoom);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxButton1_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxButton1, val, Settings::Settings::inputButton1);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxButton2_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxButton2, val, Settings::Settings::inputButton2);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxButton3_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxButton3, val, Settings::Settings::inputButton3);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxButton4_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxButton4, val, Settings::Settings::inputButton4);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxButton5_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxButton5, val, Settings::Settings::inputButton5);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxButton6_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxButton6, val, Settings::Settings::inputButton6);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxButton7_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxButton7, val, Settings::Settings::inputButton7);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::on_comboBoxButton8_activated(int val)
|
||||
{
|
||||
applyComboBox(comboBoxButton8, val, Settings::Settings::inputButton8);
|
||||
emit inputMappingChanged();
|
||||
}
|
||||
|
||||
void Preferences::writeSettings()
|
||||
{
|
||||
SettingsWriter settingsWriter;
|
||||
|
|
@ -699,6 +806,22 @@ void Preferences::updateGUI()
|
|||
this->checkBoxShowWarningsIn3dView->setChecked(s->get(Settings::Settings::showWarningsIn3dView).toBool());
|
||||
this->checkBoxEnableLineNumbers->setChecked(s->get(Settings::Settings::enableLineNumbers).toBool());
|
||||
this->spinBoxLineWrapIndentationIndent->setDisabled(this->comboBoxLineWrapIndentationStyle->currentText() == "Same");
|
||||
|
||||
updateComboBox(this->comboBoxTranslationX, Settings::Settings::inputTranslationX);
|
||||
updateComboBox(this->comboBoxTranslationY, Settings::Settings::inputTranslationY);
|
||||
updateComboBox(this->comboBoxTranslationZ, Settings::Settings::inputTranslationZ);
|
||||
updateComboBox(this->comboBoxRotationX, Settings::Settings::inputRotateX);
|
||||
updateComboBox(this->comboBoxRotationY, Settings::Settings::inputRotateY);
|
||||
updateComboBox(this->comboBoxRotationZ, Settings::Settings::inputRotateZ);
|
||||
updateComboBox(this->comboBoxZoom, Settings::Settings::inputZoom);
|
||||
updateComboBox(this->comboBoxButton1, Settings::Settings::inputButton1);
|
||||
updateComboBox(this->comboBoxButton2, Settings::Settings::inputButton2);
|
||||
updateComboBox(this->comboBoxButton3, Settings::Settings::inputButton3);
|
||||
updateComboBox(this->comboBoxButton4, Settings::Settings::inputButton4);
|
||||
updateComboBox(this->comboBoxButton5, Settings::Settings::inputButton5);
|
||||
updateComboBox(this->comboBoxButton6, Settings::Settings::inputButton6);
|
||||
updateComboBox(this->comboBoxButton7, Settings::Settings::inputButton7);
|
||||
updateComboBox(this->comboBoxButton8, Settings::Settings::inputButton8);
|
||||
}
|
||||
|
||||
void Preferences::initComboBox(QComboBox *comboBox, const Settings::SettingsEntry& entry)
|
||||
|
|
|
|||
|
|
@ -73,6 +73,22 @@ public slots:
|
|||
void on_checkBoxEnableBraceMatching_toggled(bool);
|
||||
void on_checkBoxEnableLineNumbers_toggled(bool);
|
||||
|
||||
void on_comboBoxTranslationX_activated(int val);
|
||||
void on_comboBoxTranslationY_activated(int val);
|
||||
void on_comboBoxTranslationZ_activated(int val);
|
||||
void on_comboBoxRotationX_activated(int val);
|
||||
void on_comboBoxRotationY_activated(int val);
|
||||
void on_comboBoxRotationZ_activated(int val);
|
||||
void on_comboBoxZoom_activated(int val);
|
||||
void on_comboBoxButton1_activated(int val);
|
||||
void on_comboBoxButton2_activated(int val);
|
||||
void on_comboBoxButton3_activated(int val);
|
||||
void on_comboBoxButton4_activated(int val);
|
||||
void on_comboBoxButton5_activated(int val);
|
||||
void on_comboBoxButton6_activated(int val);
|
||||
void on_comboBoxButton7_activated(int val);
|
||||
void on_comboBoxButton8_activated(int val);
|
||||
|
||||
signals:
|
||||
void requestRedraw() const;
|
||||
void updateMdiMode(bool mdi) const;
|
||||
|
|
@ -84,6 +100,7 @@ signals:
|
|||
void syntaxHighlightChanged(const QString &s) const;
|
||||
void editorTypeChanged(const QString &type);
|
||||
void editorConfigChanged() const;
|
||||
void inputMappingChanged() const;
|
||||
|
||||
private:
|
||||
Preferences(QWidget *parent = NULL);
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>675</width>
|
||||
<height>476</height>
|
||||
<width>689</width>
|
||||
<height>480</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
|
@ -23,11 +23,11 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page3DView">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
|
|
@ -125,9 +125,9 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-262</y>
|
||||
<width>639</width>
|
||||
<height>653</height>
|
||||
<y>0</y>
|
||||
<width>677</width>
|
||||
<height>784</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
|
|
@ -244,7 +244,7 @@
|
|||
<widget class="QFontComboBox" name="fontChooser">
|
||||
<property name="currentFont">
|
||||
<font>
|
||||
<family>TeX Gyre Heros</family>
|
||||
<family>Nimbus Sans L</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
|
|
@ -1220,8 +1220,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>82</width>
|
||||
<height>26</height>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_10">
|
||||
|
|
@ -1283,8 +1283,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>490</width>
|
||||
<height>383</height>
|
||||
<width>612</width>
|
||||
<height>510</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_12">
|
||||
|
|
@ -1453,6 +1453,174 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageInput">
|
||||
<layout class="QGridLayout" name="gridLayout_13">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="3" column="1">
|
||||
<widget class="QScrollArea" name="scrollArea_3">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>656</width>
|
||||
<height>489</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_7" columnstretch="0,1,1,1">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelInputRotation">
|
||||
<property name="text">
|
||||
<string>Rotation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_16">
|
||||
<property name="text">
|
||||
<string>Button 6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QComboBox" name="comboBoxTranslationZ"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QComboBox" name="comboBoxTranslationY"/>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_17">
|
||||
<property name="text">
|
||||
<string>Button 7</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBoxZoom"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Button 3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelInputZoom">
|
||||
<property name="text">
|
||||
<string>Zoom</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBoxTranslationX"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="comboBoxRotationX"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Button 4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Button 5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Button 8</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelInputButton1">
|
||||
<property name="text">
|
||||
<string>Button 1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="comboBoxRotationY"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="labelInputButton2">
|
||||
<property name="text">
|
||||
<string>Button 2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QComboBox" name="comboBoxRotationZ"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelInputTranslation">
|
||||
<property name="text">
|
||||
<string>Translation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="4">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="comboBoxButton1"/>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="comboBoxButton2"/>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="comboBoxButton3"/>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="comboBoxButton4"/>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="comboBoxButton5"/>
|
||||
</item>
|
||||
<item row="9" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="comboBoxButton6"/>
|
||||
</item>
|
||||
<item row="10" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="comboBoxButton7"/>
|
||||
</item>
|
||||
<item row="11" column="1" colspan="3">
|
||||
<widget class="QComboBox" name="comboBoxButton8"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
@ -1487,6 +1655,7 @@
|
|||
<addaction name="prefsActionUpdate"/>
|
||||
<addaction name="prefsActionFeatures"/>
|
||||
<addaction name="prefsActionAdvanced"/>
|
||||
<addaction name="prefsActionInput"/>
|
||||
</widget>
|
||||
<action name="prefsAction3DView">
|
||||
<property name="checkable">
|
||||
|
|
@ -1551,6 +1720,18 @@
|
|||
<string>Enable/Disable experimental features</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="prefsActionInput">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../openscad.qrc">
|
||||
<normaloff>:/icons/prefsInput.png</normaloff>:/icons/prefsInput.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Input</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../openscad.qrc"/>
|
||||
|
|
|
|||
|
|
@ -148,3 +148,8 @@ void InputDriverManager::onFocusChanged(QWidget *, QWidget *current)
|
|||
currentWindow = dynamic_cast<MainWindow *>(current->window());
|
||||
}
|
||||
}
|
||||
|
||||
void InputDriverManager::onInputMappingUpdated()
|
||||
{
|
||||
mapper.onInputMappingUpdated();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ public:
|
|||
|
||||
static InputDriverManager * instance();
|
||||
|
||||
public slots:
|
||||
void onInputMappingUpdated();
|
||||
|
||||
private slots:
|
||||
void onTimeout();
|
||||
void doOpen(bool firstOpen);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
#include "InputEventMapper.h"
|
||||
#include "InputDriverManager.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <QSettings>
|
||||
|
|
@ -39,29 +40,7 @@ InputEventMapper::InputEventMapper()
|
|||
connect(timer, SIGNAL(timeout()), this, SLOT(onTimer()));
|
||||
timer->start(30);
|
||||
|
||||
QSettings settings;
|
||||
|
||||
if (settings.value("InputDriver/button/1").toString().isEmpty()) {
|
||||
settings.setValue("InputDriver/button/1", "viewActionResetView");
|
||||
settings.setValue("InputDriver/button/2", "viewActionViewAll");
|
||||
settings.setValue("InputDriver/axis/translateX", "+1");
|
||||
settings.setValue("InputDriver/axis/translateY", "-2");
|
||||
settings.setValue("InputDriver/axis/translateZ", "-3");
|
||||
settings.setValue("InputDriver/axis/rotateX", "+4");
|
||||
settings.setValue("InputDriver/axis/rotateY", "-5");
|
||||
settings.setValue("InputDriver/axis/rotateZ", "-6");
|
||||
}
|
||||
|
||||
for (int a = 0;a < 10;a++) {
|
||||
QString key = QString("InputDriver/button/%1").arg(a + 1);
|
||||
actions[a] = settings.value(key).toString();
|
||||
}
|
||||
translate[0] = settings.value("InputDriver/axis/translateX").toInt();
|
||||
translate[1] = settings.value("InputDriver/axis/translateY").toInt();
|
||||
translate[2] = settings.value("InputDriver/axis/translateZ").toInt();
|
||||
rotate[0] = settings.value("InputDriver/axis/rotateX").toInt();
|
||||
rotate[1] = settings.value("InputDriver/axis/rotateY").toInt();
|
||||
rotate[2] = settings.value("InputDriver/axis/rotateZ").toInt();
|
||||
onInputMappingUpdated();
|
||||
}
|
||||
|
||||
InputEventMapper::~InputEventMapper()
|
||||
|
|
@ -103,6 +82,12 @@ void InputEventMapper::onTimer()
|
|||
InputEvent *inputEvent = new InputEventRotate(rx, ry, rz);
|
||||
InputDriverManager::instance()->postEvent(inputEvent);
|
||||
}
|
||||
|
||||
double z = getAxisValue(zoom);
|
||||
if (fabs(z) > threshold) {
|
||||
InputEvent *inputEvent = new InputEventZoom(z);
|
||||
InputDriverManager::instance()->postEvent(inputEvent);
|
||||
}
|
||||
}
|
||||
|
||||
void InputEventMapper::onAxisChanged(InputEventAxisChanged *event)
|
||||
|
|
@ -144,3 +129,33 @@ void InputEventMapper::onZoomEvent(InputEventZoom *event)
|
|||
{
|
||||
InputDriverManager::instance()->postEvent(event);
|
||||
}
|
||||
|
||||
int InputEventMapper::parseSettingValue(const std::string val)
|
||||
{
|
||||
if (val.length() != 2) {
|
||||
return 0;
|
||||
}
|
||||
return atoi(val.c_str());
|
||||
}
|
||||
|
||||
void InputEventMapper::onInputMappingUpdated()
|
||||
{
|
||||
Settings::Settings *s = Settings::Settings::inst();
|
||||
|
||||
actions[0] = QString(s->get(Settings::Settings::inputButton1).toString().c_str());
|
||||
actions[1] = QString(s->get(Settings::Settings::inputButton2).toString().c_str());
|
||||
actions[2] = QString(s->get(Settings::Settings::inputButton3).toString().c_str());
|
||||
actions[3] = QString(s->get(Settings::Settings::inputButton4).toString().c_str());
|
||||
actions[4] = QString(s->get(Settings::Settings::inputButton5).toString().c_str());
|
||||
actions[5] = QString(s->get(Settings::Settings::inputButton6).toString().c_str());
|
||||
actions[6] = QString(s->get(Settings::Settings::inputButton7).toString().c_str());
|
||||
actions[7] = QString(s->get(Settings::Settings::inputButton8).toString().c_str());
|
||||
|
||||
translate[0] = parseSettingValue(s->get(Settings::Settings::inputTranslationX).toString());
|
||||
translate[1] = parseSettingValue(s->get(Settings::Settings::inputTranslationY).toString());
|
||||
translate[2] = parseSettingValue(s->get(Settings::Settings::inputTranslationZ).toString());
|
||||
rotate[0] = parseSettingValue(s->get(Settings::Settings::inputRotateX).toString());
|
||||
rotate[1] = parseSettingValue(s->get(Settings::Settings::inputRotateY).toString());
|
||||
rotate[2] = parseSettingValue(s->get(Settings::Settings::inputRotateZ).toString());
|
||||
zoom = parseSettingValue(s->get(Settings::Settings::inputZoom).toString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,9 +40,11 @@ private:
|
|||
QString actions[10];
|
||||
int translate[3];
|
||||
int rotate[3];
|
||||
int zoom;
|
||||
|
||||
double scale(double val);
|
||||
double getAxisValue(int config);
|
||||
int parseSettingValue(const std::string val);
|
||||
|
||||
public:
|
||||
InputEventMapper();
|
||||
|
|
@ -56,6 +58,8 @@ public:
|
|||
void onActionEvent(class InputEventAction *event);
|
||||
void onZoomEvent(class InputEventZoom *event);
|
||||
|
||||
void onInputMappingUpdated();
|
||||
|
||||
private slots:
|
||||
void onTimer();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ MainWindow::MainWindow(const QString &filename)
|
|||
editor = new LegacyEditor(editorDockContents);
|
||||
|
||||
Preferences::create(editor->colorSchemes());
|
||||
connect(Preferences::inst(), SIGNAL(inputMappingChanged()), InputDriverManager::instance(), SLOT(onInputMappingUpdated()), Qt::UniqueConnection);
|
||||
|
||||
#ifdef USE_SCINTILLA_EDITOR
|
||||
if (useScintilla) {
|
||||
|
|
|
|||
129
src/settings.cc
129
src/settings.cc
|
|
@ -43,10 +43,10 @@ bool SettingsEntry::is_default() const
|
|||
return _value == _default;
|
||||
}
|
||||
|
||||
static Value value(std::string s1, std::string s2) {
|
||||
static ValuePtr value(std::string s1, std::string s2) {
|
||||
Value::VectorType v;
|
||||
v += ValuePtr(s1), ValuePtr(s2);
|
||||
return v;
|
||||
return ValuePtr(v);
|
||||
}
|
||||
|
||||
static Value values(std::string s1, std::string s1disp, std::string s2, std::string s2disp) {
|
||||
|
|
@ -67,6 +67,114 @@ static Value values(std::string s1, std::string s1disp, std::string s2, std::str
|
|||
return v;
|
||||
}
|
||||
|
||||
static Value axisValues() {
|
||||
Value::VectorType v;
|
||||
v += value("None", _("None"));
|
||||
v += value("+1", _("Axis 1"));
|
||||
v += value("-1", _("Axis 1 (inverted)"));
|
||||
v += value("+2", _("Axis 2"));
|
||||
v += value("-2", _("Axis 2 (inverted)"));
|
||||
v += value("+3", _("Axis 3"));
|
||||
v += value("-3", _("Axis 3 (inverted)"));
|
||||
v += value("+4", _("Axis 4"));
|
||||
v += value("-4", _("Axis 4 (inverted)"));
|
||||
v += value("+5", _("Axis 5"));
|
||||
v += value("-5", _("Axis 5 (inverted)"));
|
||||
v += value("+6", _("Axis 6"));
|
||||
v += value("-6", _("Axis 6 (inverted)"));
|
||||
v += value("+7", _("Axis 7"));
|
||||
v += value("-7", _("Axis 7 (inverted)"));
|
||||
v += value("+8", _("Axis 8"));
|
||||
v += value("-8", _("Axis 8 (inverted)"));
|
||||
v += value("+9", _("Axis 9"));
|
||||
v += value("-9", _("Axis 9 (inverted)"));
|
||||
return v;
|
||||
}
|
||||
|
||||
static Value buttonValues() {
|
||||
Value::VectorType v;
|
||||
v += value("None", _("None"));
|
||||
v += value("designActionAutoReload", _("designActionAutoReload"));
|
||||
v += value("designActionDisplayAST", _("designActionDisplayAST"));
|
||||
v += value("designActionDisplayCSGProducts", _("designActionDisplayCSGProducts"));
|
||||
v += value("designActionDisplayCSGTree", _("designActionDisplayCSGTree"));
|
||||
v += value("designActionFlushCaches", _("designActionFlushCaches"));
|
||||
v += value("designActionPreview", _("designActionPreview"));
|
||||
v += value("designActionReloadAndPreview", _("designActionReloadAndPreview"));
|
||||
v += value("designActionRender", _("designActionRender"));
|
||||
v += value("designCheckValidity", _("designCheckValidity"));
|
||||
v += value("editActionComment", _("editActionComment"));
|
||||
v += value("editActionConvertTabsToSpaces", _("editActionConvertTabsToSpaces"));
|
||||
v += value("editActionCopy", _("editActionCopy"));
|
||||
v += value("editActionCopyViewport", _("editActionCopyViewport"));
|
||||
v += value("editActionCut", _("editActionCut"));
|
||||
v += value("editActionFind", _("editActionFind"));
|
||||
v += value("editActionFindAndReplace", _("editActionFindAndReplace"));
|
||||
v += value("editActionFindNext", _("editActionFindNext"));
|
||||
v += value("editActionFindPrevious", _("editActionFindPrevious"));
|
||||
v += value("editActionIndent", _("editActionIndent"));
|
||||
v += value("editActionPaste", _("editActionPaste"));
|
||||
v += value("editActionPasteVPR", _("editActionPasteVPR"));
|
||||
v += value("editActionPasteVPT", _("editActionPasteVPT"));
|
||||
v += value("editActionPreferences", _("editActionPreferences"));
|
||||
v += value("editActionRedo", _("editActionRedo"));
|
||||
v += value("editActionUncomment", _("editActionUncomment"));
|
||||
v += value("editActionUndo", _("editActionUndo"));
|
||||
v += value("editActionUnindent", _("editActionUnindent"));
|
||||
v += value("editActionUseSelectionForFind", _("editActionUseSelectionForFind"));
|
||||
v += value("editActionZoomTextIn", _("editActionZoomTextIn"));
|
||||
v += value("editActionZoomTextOut", _("editActionZoomTextOut"));
|
||||
v += value("fileActionClearRecent", _("fileActionClearRecent"));
|
||||
v += value("fileActionClose", _("fileActionClose"));
|
||||
v += value("fileActionExportAMF", _("fileActionExportAMF"));
|
||||
v += value("fileActionExportCSG", _("fileActionExportCSG"));
|
||||
v += value("fileActionExportDXF", _("fileActionExportDXF"));
|
||||
v += value("fileActionExportImage", _("fileActionExportImage"));
|
||||
v += value("fileActionExportOFF", _("fileActionExportOFF"));
|
||||
v += value("fileActionExportSTL", _("fileActionExportSTL"));
|
||||
v += value("fileActionExportSVG", _("fileActionExportSVG"));
|
||||
v += value("fileActionNew", _("fileActionNew"));
|
||||
v += value("fileActionOpen", _("fileActionOpen"));
|
||||
v += value("fileActionQuit", _("fileActionQuit"));
|
||||
v += value("fileActionReload", _("fileActionReload"));
|
||||
v += value("fileActionSave", _("fileActionSave"));
|
||||
v += value("fileActionSaveAs", _("fileActionSaveAs"));
|
||||
v += value("fileShowLibraryFolder", _("fileShowLibraryFolder"));
|
||||
v += value("helpActionAbout", _("helpActionAbout"));
|
||||
v += value("helpActionCheatSheet", _("helpActionCheatSheet"));
|
||||
v += value("helpActionFontInfo", _("helpActionFontInfo"));
|
||||
v += value("helpActionHomepage", _("helpActionHomepage"));
|
||||
v += value("helpActionLibraryInfo", _("helpActionLibraryInfo"));
|
||||
v += value("helpActionManual", _("helpActionManual"));
|
||||
v += value("viewActionAnimate", _("viewActionAnimate"));
|
||||
v += value("viewActionBack", _("viewActionBack"));
|
||||
v += value("viewActionBottom", _("viewActionBottom"));
|
||||
v += value("viewActionCenter", _("viewActionCenter"));
|
||||
v += value("viewActionDiagonal", _("viewActionDiagonal"));
|
||||
v += value("viewActionFront", _("viewActionFront"));
|
||||
v += value("viewActionHideConsole", _("viewActionHideConsole"));
|
||||
v += value("viewActionHideEditor", _("viewActionHideEditor"));
|
||||
v += value("viewActionHideToolBars", _("viewActionHideToolBars"));
|
||||
v += value("viewActionLeft", _("viewActionLeft"));
|
||||
v += value("viewActionOrthogonal", _("viewActionOrthogonal"));
|
||||
v += value("viewActionPerspective", _("viewActionPerspective"));
|
||||
v += value("viewActionPreview", _("viewActionPreview"));
|
||||
v += value("viewActionResetView", _("viewActionResetView"));
|
||||
v += value("viewActionRight", _("viewActionRight"));
|
||||
v += value("viewActionShowAxes", _("viewActionShowAxes"));
|
||||
v += value("viewActionShowCrosshairs", _("viewActionShowCrosshairs"));
|
||||
v += value("viewActionShowEdges", _("viewActionShowEdges"));
|
||||
v += value("viewActionShowScaleProportional", _("viewActionShowScaleProportional"));
|
||||
v += value("viewActionSurfaces", _("viewActionSurfaces"));
|
||||
v += value("viewActionThrownTogether", _("viewActionThrownTogether"));
|
||||
v += value("viewActionTop", _("viewActionTop"));
|
||||
v += value("viewActionViewAll", _("viewActionViewAll"));
|
||||
v += value("viewActionWireframe", _("viewActionWireframe"));
|
||||
v += value("viewActionZoomIn", _("viewActionZoomIn"));
|
||||
v += value("viewActionZoomOut", _("viewActionZoomOut"));
|
||||
return v;
|
||||
}
|
||||
|
||||
Settings *Settings::inst(bool erase)
|
||||
{
|
||||
static Settings *instance = new Settings;
|
||||
|
|
@ -143,4 +251,21 @@ SettingsEntry Settings::tabKeyFunction("editor", "tabKeyFunction", values("Inden
|
|||
SettingsEntry Settings::highlightCurrentLine("editor", "highlightCurrentLine", Value(true), Value(true));
|
||||
SettingsEntry Settings::enableBraceMatching("editor", "enableBraceMatching", Value(true), Value(true));
|
||||
SettingsEntry Settings::enableLineNumbers("editor", "enableLineNumbers", Value(true), Value(true));
|
||||
|
||||
SettingsEntry Settings::inputTranslationX("input", "translationX", axisValues(), Value("+1"));
|
||||
SettingsEntry Settings::inputTranslationY("input", "translationY", axisValues(), Value("-2"));
|
||||
SettingsEntry Settings::inputTranslationZ("input", "translationZ", axisValues(), Value("-3"));
|
||||
SettingsEntry Settings::inputRotateX("input", "rotateX", axisValues(), Value("+4"));
|
||||
SettingsEntry Settings::inputRotateY("input", "rotateY", axisValues(), Value("-5"));
|
||||
SettingsEntry Settings::inputRotateZ("input", "rotateZ", axisValues(), Value("-6"));
|
||||
SettingsEntry Settings::inputZoom("input", "zoom", axisValues(), Value("None"));
|
||||
SettingsEntry Settings::inputButton1("input", "button1", buttonValues(), Value("viewActionResetView"));
|
||||
SettingsEntry Settings::inputButton2("input", "button2", buttonValues(), Value("None"));
|
||||
SettingsEntry Settings::inputButton3("input", "button3", buttonValues(), Value("None"));
|
||||
SettingsEntry Settings::inputButton4("input", "button4", buttonValues(), Value("None"));
|
||||
SettingsEntry Settings::inputButton5("input", "button5", buttonValues(), Value("None"));
|
||||
SettingsEntry Settings::inputButton6("input", "button6", buttonValues(), Value("None"));
|
||||
SettingsEntry Settings::inputButton7("input", "button7", buttonValues(), Value("None"));
|
||||
SettingsEntry Settings::inputButton8("input", "button8", buttonValues(), Value("None"));
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,21 @@ public:
|
|||
static SettingsEntry highlightCurrentLine;
|
||||
static SettingsEntry enableBraceMatching;
|
||||
static SettingsEntry enableLineNumbers;
|
||||
static SettingsEntry inputTranslationX;
|
||||
static SettingsEntry inputTranslationY;
|
||||
static SettingsEntry inputTranslationZ;
|
||||
static SettingsEntry inputRotateX;
|
||||
static SettingsEntry inputRotateY;
|
||||
static SettingsEntry inputRotateZ;
|
||||
static SettingsEntry inputZoom;
|
||||
static SettingsEntry inputButton1;
|
||||
static SettingsEntry inputButton2;
|
||||
static SettingsEntry inputButton3;
|
||||
static SettingsEntry inputButton4;
|
||||
static SettingsEntry inputButton5;
|
||||
static SettingsEntry inputButton6;
|
||||
static SettingsEntry inputButton7;
|
||||
static SettingsEntry inputButton8;
|
||||
|
||||
static Settings *inst(bool erase = false);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue