summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-10-16 20:57:56 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-10-16 20:57:56 +0200
commit015547df5de7dcfaa60bfa6f8ac30b1f9c91385a (patch)
treec845392790b2eca5556432dfd75db6ddb4390078
parentdf7969c687a0e6a5e6cbed8cabaf11c51058d35a (diff)
fix the damn mess
Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
-rw-r--r--facetracknoir/facetracknoir.cpp119
-rw-r--r--facetracknoir/facetracknoir.h10
-rw-r--r--facetracknoir/facetracknoir.ui270
-rw-r--r--facetracknoir/shortcuts.cpp19
4 files changed, 86 insertions, 332 deletions
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp
index dddcd4e4..af630bea 100644
--- a/facetracknoir/facetracknoir.cpp
+++ b/facetracknoir/facetracknoir.cpp
@@ -91,12 +91,12 @@ static void fill_combobox(const QString& filter, QList<DynamicLibrary*>& list, Q
//
FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) :
QMainWindow(parent, flags),
- #if defined(_WIN32)
- keybindingWorker(NULL),
- #else
- keyCenter(0),
- keyToggle(0),
- #endif
+#if defined(_WIN32)
+ keybindingWorker(NULL),
+#else
+ keyCenter(this),
+ keyToggle(this),
+#endif
timUpdateHeadPose(this),
pTrackerDialog(NULL),
pSecondTrackerDialog(NULL),
@@ -182,6 +182,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) :
ui.lcdNumOutputRotX->setVisible(false);
ui.lcdNumOutputRotY->setVisible(false);
ui.lcdNumOutputRotZ->setVisible(false);
+
+ connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered()));
+ connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled()));
}
/** destructor stops the engine and quits the faceapi **/
@@ -545,7 +548,7 @@ void FaceTrackNoIR::startTracker( ) {
}
#if defined(_WIN32)
- keybindingWorker = new KeybindingWorker(*this, keyCenter);
+ keybindingWorker = new KeybindingWorker(*this, &keyCenter, &keyToggle);
keybindingWorker->start();
#endif
@@ -913,79 +916,97 @@ void FaceTrackNoIR::profileSelected(int index)
loadSettings();
}
-void FaceTrackNoIR::bindKeyboardShortcuts()
-{
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
- iniFile.beginGroup ( "KB_Shortcuts" );
- int idxCenter = iniFile.value("Key_index_Center", 0).toInt();
-
#if !defined(_WIN32)
- if (keyCenter) {
- delete keyCenter;
- keyCenter = NULL;
- }
-
- if (idxCenter > 0)
+void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile)
+{
+ const int idx = iniFile.value("Key_index_" + label, 0).toInt();
+ key.setShortcut(QKeySequence::fromString(""));
+ key.setDisabled();
+ QString seq(global_key_sequences.value(idx, ""));
+ if (idx > 0)
{
- QString seq(global_key_sequences.value(idxCenter, ""));
if (!seq.isEmpty())
{
- if (iniFile.value("Shift_Center", false).toBool())
+ if (iniFile.value(QString("Shift_%1").arg(label), false).toBool())
seq = "Shift+" + seq;
- if (iniFile.value("Alt_Center", false).toBool())
+ if (iniFile.value(QString("Alt_%1").arg(label), false).toBool())
seq = "Alt+" + seq;
- if (iniFile.value("Ctrl_Center", false).toBool())
+ if (iniFile.value(QString("Ctrl_%1").arg(label), false).toBool())
seq = "Ctrl+" + seq;
- keyCenter = new QxtGlobalShortcut(QKeySequence(seq), this);
- connect(keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered()));
+ key.setShortcut(QKeySequence::fromString(seq, QKeySequence::NativeText));
+ key.setEnabled();
}
}
+}
#else
- keyCenter.keycode = 0;
- keyCenter.shift = keyCenter.alt = keyCenter.ctrl = 0;
- if (idxCenter > 0 && idxCenter < global_windows_key_sequences.size())
- keyCenter.keycode = global_windows_key_sequences[idxCenter];
- keyCenter.shift = iniFile.value("Shift_Center", false).toBool();
- keyCenter.alt = iniFile.value("Alt_Center", false).toBool();
- keyCenter.ctrl = iniFile.value("Ctrl_Center", false).toBool();
+static void bind_keyboard_shotcut(Key& key, const QString label, QSettings& iniFile)
+{
+ const int idx = iniFile.value("Key_index_" + label, 0).toInt();
+ if (idx > 0)
+ {
+ key.keycode = 0;
+ key.shift = key.alt = key.ctrl = 0;
+ if (idx < global_windows_key_sequences.size())
+ key.keycode = global_windows_key_sequences[idx];
+ key.shift = iniFile.value(QString("Shift_").arg(label), false).toBool();
+ key.alt = iniFile.value(QString("Alt_").arg(label), false).toBool();
+ key.ctrl = iniFile.value(QString("Ctrl_").arg(label), false).toBool();
+ }
+}
#endif
- iniFile.endGroup ();
+
+void FaceTrackNoIR::bindKeyboardShortcuts()
+{
+ QSettings settings("opentrack"); // Registry settings (in HK_USER)
+
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+ iniFile.beginGroup ( "KB_Shortcuts" );
+#if !defined(_WIN32)
+ bind_keyboard_shortcut(keyCenter, "Center", iniFile);
+ bind_keyboard_shortcut(keyToggle, "Toggle", iniFile);
+#else
+ bind_keyboard_shortcut(&keyCenter, "Center", iniFile));
+ bind_keyboard_shortcut(&keyToggle, "Toggle", iniFile));
+#endif
+ iniFile.endGroup ();
+
if (tracker) /* running already */
{
#if defined(_WIN32)
- if (keybindingWorker)
- {
- keybindingWorker->should_quit = true;
- keybindingWorker->wait();
- delete keybindingWorker;
- keybindingWorker = NULL;
- }
- keybindingWorker = new KeybindingWorker(*this, keyCenter);
- keybindingWorker->start();
+ if (keybindingWorker)
+ {
+ keybindingWorker->should_quit = true;
+ keybindingWorker->wait();
+ delete keybindingWorker;
+ keybindingWorker = NULL;
+ }
+ const int idx_center = iniFile.value("Key_index_Center", 0).toInt();
+ const int idx_toggle = iniFile.value("Key_index_Toggle", 0).toInt();
+ keybindingWorker = new KeybindingWorker(*this, keyCenter, keyToggle);
+ keybindingWorker->start();
#endif
}
}
void FaceTrackNoIR::shortcutRecentered()
{
+ QApplication::beep();
+
+ qDebug() << "Center";
if (tracker)
{
- QApplication::beep();
- qDebug() << "Center";
tracker->do_center = true;
}
}
void FaceTrackNoIR::shortcutToggled()
{
+ QApplication::beep();
+ qDebug() << "Toggle";
if (tracker)
{
- QApplication::beep();
- qDebug() << "Toggle";
tracker->enabled = !tracker->enabled;
}
}
diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h
index 8f510d78..bfeb2d38 100644
--- a/facetracknoir/facetracknoir.h
+++ b/facetracknoir/facetracknoir.h
@@ -94,8 +94,8 @@ public:
Key keyToggle;
KeybindingWorker* keybindingWorker;
#else
- QxtGlobalShortcut* keyCenter;
- QxtGlobalShortcut* keyToggle;
+ QxtGlobalShortcut keyCenter;
+ QxtGlobalShortcut keyToggle;
#endif
public slots:
void shortcutRecentered();
@@ -112,7 +112,6 @@ private:
IProtocolDialog* pProtocolDialog; // Pointer to Protocol dialog instance (in DLL)
IFilterDialog* pFilterDialog; // Pointer to Filter dialog instance (in DLL)
- /** Widget variables **/
QWidget *_keyboard_shortcuts;
QWidget *_curve_config;
@@ -120,12 +119,15 @@ private:
void GetCameraNameDX();
void loadSettings();
- void setupFaceTrackNoIR();
QList<DynamicLibrary*> dlopen_filters;
QList<DynamicLibrary*> dlopen_trackers;
QList<DynamicLibrary*> dlopen_protocols;
+#ifndef _WIN32
+ void bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile);
+#endif
+
bool looping;
private slots:
diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui
index 0578e2f6..2f35e29b 100644
--- a/facetracknoir/facetracknoir.ui
+++ b/facetracknoir/facetracknoir.ui
@@ -181,259 +181,6 @@ QGroupBox {
<height>419</height>
</size>
</property>
- <property name="palette">
- <palette>
- <active>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>192</red>
- <green>192</green>
- <blue>192</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>72</red>
- <green>72</green>
- <blue>72</blue>
- </color>
- </brush>
- </colorrole>
- </active>
- <inactive>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>192</red>
- <green>192</green>
- <blue>192</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>72</red>
- <green>72</green>
- <blue>72</blue>
- </color>
- </brush>
- </colorrole>
- </inactive>
- <disabled>
- <colorrole role="WindowText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Button">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Text">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="ButtonText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Base">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Window">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>89</red>
- <green>89</green>
- <blue>89</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="Highlight">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>192</red>
- <green>192</green>
- <blue>192</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="HighlightedText">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </color>
- </brush>
- </colorrole>
- <colorrole role="AlternateBase">
- <brush brushstyle="SolidPattern">
- <color alpha="255">
- <red>72</red>
- <green>72</green>
- <blue>72</blue>
- </color>
- </brush>
- </colorrole>
- </disabled>
- </palette>
- </property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
@@ -1464,7 +1211,6 @@ background:none;</string>
</property>
<property name="styleSheet">
<string notr="true">* {
- text-color: white;
color: white;
}
</string>
@@ -1727,8 +1473,7 @@ color:white;</string>
</rect>
</property>
<property name="styleSheet">
- <string notr="true">color: white;
-text-color: white;</string>
+ <string notr="true">color: white; </string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@@ -1750,19 +1495,6 @@ text-color: white;</string>
</property>
</widget>
</widget>
- <zorder>groupBox</zorder>
- <zorder>lcdNumZ</zorder>
- <zorder>lcdNumY</zorder>
- <zorder>label_8</zorder>
- <zorder>label_9</zorder>
- <zorder>lcdNumRotY</zorder>
- <zorder>label_4</zorder>
- <zorder>lcdNumRotX</zorder>
- <zorder>label_7</zorder>
- <zorder>lcdNumRotZ</zorder>
- <zorder>lcdNumX</zorder>
- <zorder>label_5</zorder>
- <zorder>label_6</zorder>
</widget>
<widget class="QWidget" name="widget4logo" native="true">
<property name="geometry">
diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp
index 4256e932..1cd967e0 100644
--- a/facetracknoir/shortcuts.cpp
+++ b/facetracknoir/shortcuts.cpp
@@ -39,7 +39,7 @@ void KeyboardShortcutDialog::doOK() {
mainApp->bindKeyboardShortcuts();
}
-void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) {
+void KeyboardShortcutDialog::showEvent ( QShowEvent * ) {
loadSettings();
}
@@ -90,7 +90,7 @@ void KeyboardShortcutDialog::loadSettings() {
"Center", "Toggle"
};
- QComboBox* checkboxen[] = {
+ QComboBox* comboboxen[] = {
ui.cbxCenterKey,
ui.cbxToggleKey
};
@@ -121,11 +121,11 @@ void KeyboardShortcutDialog::loadSettings() {
for (int i = 0; i < KEY_COUNT; i++)
{
- for (int m = 0; i < MODIFIERS; i++)
+ for (int m = 0; m < MODIFIERS; m++)
{
- boxen[i][m]->setChecked (iniFile.value ( modnames[m] + QString("_") + QString(keynames[i]), 0 ).toBool());
+ boxen[i][m]->setChecked (iniFile.value ( QString("%1_%2").arg(modnames[m], keynames[i]), 0).toBool());
}
- checkboxen[i]->setCurrentIndex(iniFile.value("Key_index_" + QString(names[i]), 0).toInt());
+ comboboxen[i]->setCurrentIndex(iniFile.value(QString("Key_index_%1").arg(names[i]), 0).toInt());
}
iniFile.endGroup ();
@@ -138,7 +138,7 @@ void KeyboardShortcutDialog::save() {
"Center", "Toggle"
};
- QComboBox* checkboxen[] = {
+ QComboBox* comboboxen[] = {
ui.cbxCenterKey,
ui.cbxToggleKey
};
@@ -172,12 +172,11 @@ void KeyboardShortcutDialog::save() {
for (int i = 0; i < KEY_COUNT; i++)
{
- iniFile.setValue ( "Key_index_" + QString(keynames[i]),
- checkboxen[i]->currentIndex() );
- for (int m = 0; i < MODIFIERS; i++)
+ for (int m = 0; m < MODIFIERS; m++)
{
- iniFile.setValue(modnames[m] + QString("_") + keynames[i], !!boxen[i][m]->isChecked());
+ iniFile.setValue(QString("%1_%2").arg(modnames[m], keynames[i]), boxen[i][m]->isChecked());
}
+ iniFile.setValue(QString("Key_index_%1").arg(keynames[i]), comboboxen[i]->currentIndex());
}
iniFile.endGroup();