From a4523baec2733e1ed871257b883d1673c622bcdd Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sun, 27 Mar 2022 02:57:07 +0200 Subject: [PATCH] changed the window type to QMainWindow, added menubar, and about dialog --- .gitignore | 1 + Makefile.in | 7 +- src/ui.cc | 30 +- src/ui.h | 7 +- ui/about.ui | 135 ++++ ui/spnavcfg.ui | 2003 +++++++++++++++++++++++++----------------------- 6 files changed, 1212 insertions(+), 971 deletions(-) create mode 100644 ui/about.ui diff --git a/.gitignore b/.gitignore index 2105fae..05ef129 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ Makefile spnavcfg ui_mainwin.h ui_bnmaprow.h +ui_about.h res.cc diff --git a/Makefile.in b/Makefile.in index 3cdefe1..d2728eb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -26,7 +26,7 @@ $(bin): $(obj) -include $(dep) src/main.o: src/main.cc -src/ui.o: src/ui.cc ui_mainwin.h ui_bnmaprow.h +src/ui.o: src/ui.cc ui_mainwin.h ui_bnmaprow.h ui_about.h ui_mainwin.h: ui/spnavcfg.ui $(UIC) -o $@ $< @@ -34,6 +34,9 @@ ui_mainwin.h: ui/spnavcfg.ui ui_bnmaprow.h: ui/bnmaprow.ui $(UIC) -o $@ $< +ui_about.h: ui/about.ui + $(UIC) -o $@ $< + %.moc.cc: %.h $(MOC) -o $@ $(incdir) $< @@ -42,7 +45,7 @@ res.cc: ui/spnavcfg.qrc icons/devices.png .PHONY: clean clean: - rm -f $(obj) $(bin) $(mocsrc) win_main_ui.h res.cc + rm -f $(obj) $(bin) $(mocsrc) ui_mainwin.h ui_bnmaprow.h ui_about.h res.cc .PHONY: cleandep cleandep: diff --git a/src/ui.cc b/src/ui.cc index a65f29b..e1cdba7 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -6,6 +6,7 @@ #include "spnavcfg.h" #include "ui_mainwin.h" #include "ui_bnmaprow.h" +#include "ui_about.h" #include #include @@ -63,7 +64,7 @@ static struct device_image devimglist[] = { MainWin::MainWin(QWidget *par) - : QWidget(par) + : QMainWindow(par) { mask_events = true; @@ -114,13 +115,20 @@ MainWin::MainWin(QWidget *par) prog_axis[4] = ui->prog_ry; prog_axis[5] = ui->prog_rz; + connect(ui->act_default, SIGNAL(triggered()), this, SLOT(act_trig())); + connect(ui->act_loadcfg, SIGNAL(triggered()), this, SLOT(act_trig())); + connect(ui->act_savecfg, SIGNAL(triggered()), this, SLOT(act_trig())); + connect(ui->act_about, SIGNAL(triggered()), this, SLOT(act_trig())); + connect(ui->combo_led, SIGNAL(currentIndexChanged(int)), this, SLOT(combo_idx_changed(int))); connect(ui->ed_serpath, SIGNAL(editingFinished()), this, SLOT(serpath_changed())); connect(ui->chk_serial, SIGNAL(stateChanged(int)), this, SLOT(chk_changed(int))); + /* connect(ui->bn_loaddef, SIGNAL(clicked()), this, SLOT(bn_clicked())); connect(ui->bn_loadcfg, SIGNAL(clicked()), this, SLOT(bn_clicked())); connect(ui->bn_savecfg, SIGNAL(clicked()), this, SLOT(bn_clicked())); + */ connect(ui->chk_grab, SIGNAL(stateChanged(int)), this, SLOT(chk_changed(int))); connect(ui->chk_swapyz, SIGNAL(stateChanged(int)), this, SLOT(chk_changed(int))); @@ -336,23 +344,25 @@ static const char *qsave_text = "Saving will overwrite the current spacenavd configuration file.\n" "Are you sure you want to proceed?"; -void MainWin::bn_clicked() +void MainWin::act_trig() { QObject *src = QObject::sender(); - if(src == ui->bn_loaddef) { + if(src == ui->act_default) { if(QMessageBox::question(this, "Reset defaults?", qdefaults_text) == QMessageBox::Yes) { spnav_cfg_reset(); read_cfg(&cfg); } - } else if(src == ui->bn_loadcfg) { + } else if(src == ui->act_loadcfg) { if(QMessageBox::question(this, "Restore configuration?", qload_text) == QMessageBox::Yes) { spnav_cfg_restore(); read_cfg(&cfg); } - } else if(src == ui->bn_savecfg) { + } else if(src == ui->act_savecfg) { if(QMessageBox::question(this, "Save configuration?", qsave_text) == QMessageBox::Yes) { spnav_cfg_save(); } + } else if(src == ui->act_about) { + aboutbox(); } } @@ -615,3 +625,13 @@ extern "C" void errorboxf(const char *fmt, ...) errorbox(buf); } + +extern "C" void aboutbox(void) +{ + QDialog *dlg = new QDialog(mainwin); + Ui::dlg_about about; + about.setupUi(dlg); + dlg->exec(); + + delete dlg; +} diff --git a/src/ui.h b/src/ui.h index 5b181cf..243839f 100644 --- a/src/ui.h +++ b/src/ui.h @@ -3,13 +3,13 @@ #ifdef __cplusplus -#include +#include namespace Ui { class win_main; } -class MainWin : public QWidget { +class MainWin : public QMainWindow { Q_OBJECT private: @@ -24,7 +24,7 @@ public: public slots: void spnav_input(); - void bn_clicked(); + void act_trig(); void slider_moved(int val); void dspin_changed(double val); void spin_changed(int val); @@ -43,6 +43,7 @@ extern "C" { void update_ui(void); void errorbox(const char *msg); void errorboxf(const char *fmt, ...); +void aboutbox(void); #ifdef __cplusplus } diff --git a/ui/about.ui b/ui/about.ui new file mode 100644 index 0000000..45d57b7 --- /dev/null +++ b/ui/about.ui @@ -0,0 +1,135 @@ + + + dlg_about + + + + 0 + 0 + 605 + 366 + + + + About spnavcfg + + + + + + <html><head/><body><p align="center"><span style=" font-size:18pt; font-weight:600;">spnavcfg</span></p></body></html> + + + + + + + <html><head/><body><p align="center"><span style=" font-size:11pt;">spacenavd configuration utility</span></p></body></html> + + + + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 20 + 20 + + + + + + + + <html><head/><body> + +<p><b>spnavcfg</b> is part of the <i>Free Spacenav</i> project. It's a graphical interactive configuration utility for the <i>spacenavd</i> daemon: the free driver for 6-degree-of-freedom input devices.</p> + +<p>All parts of the Free Spacenav project are free software. See their respective licenses for details.</p> + +<p>Author &amp; maintainer: John Tsiombikas &lt;<a href="mailto:nuclear@member.fsf.org">nuclear@member.fsf.org</a>&gt;</p> + +<ul> + <li>Project website: <a href="http://spacenav.sourceforge.net">http://spacenav.sourceforge.net</a></li> + <li>Spacenavd repository: <a href="https://github.com/FreeSpacenav/spacenavd">https://github.com/FreeSpacenav/spacenavd</a></li> + <li>libspnav repository: <a href="https://githib.com/FreeSpacenav/libspnav">https://github.com/FreeSpacenav/libspnav</a></li> + <li>spnavcfg repository: <a href="https://github.com/FreeSpacenav/spnavcfg">https://github.com/FreeSpacenav/spnavcfg</a></li> +</ul> + +</body></html> + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + true + + + + + + + + + buttonBox + accepted() + dlg_about + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + dlg_about + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/ui/spnavcfg.ui b/ui/spnavcfg.ui index 6379dae..2c021d5 100644 --- a/ui/spnavcfg.ui +++ b/ui/spnavcfg.ui @@ -1,997 +1,1014 @@ win_main - + 0 0 800 - 667 + 689 Spacenav configuration - - - - - - - - 0 - 0 - - - - Device - - - - - - - - Name: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Path: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Axes: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Buttons: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - - 150 - 150 - - - - img - - - - - - - - - - - 0 - 0 - - - - General - - - - - - - - LED - - - - - - - - Off - - - - - On - - - - - Auto - - - - - - - - - - grabbing the device, spacenavd will prevent other programs from using it directly - - - Grab device - - - - - - - - - Use a serial device (specify path) - - - Serial device path - - - - - - - false - - - /dev/ttyS0 - - - - - - - - - - - You probably don't need this. Most devices keep sending input when held off-center. - - - Auto-repeat interval (ms) - - - - - - - false - - - 10 - - - 1000 - - - 250 - - - - - - - - - - - Reset to default configuration - - - Restore defaults - - - - - - - Restore configuration from /etc/spnavrc - - - Restore config - - - - - - - Permanently save configuration to /etc/spnavrc - - - Save config - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - 0 - - - - Axes - - - - + + + + + + + + + 0 + 0 + + + + Device + + - - - Sensitivity - - + + + + + Name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + - + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Path: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + - + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Axes: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + - + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + Buttons: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + - + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + - - - Global sensitivity - - - 60 - - - 10 - - - Qt::Horizontal - - - - - - - 10.000000000000000 - - - 0.100000000000000 - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - + + - 40 - 20 + 150 + 150 - - - - - - Swap the Y and Z axes (up/down - in/out) - - Swap Y-Z - - - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 40 - 20 - - - - - - - - Global deadzone - - - true - - - - - - - Deadzone for all axes - - - 255 + img - - - - - Translation - - - - - - -128 - - - 127 - - - 0 - - - false - - - %v - - - - - - - Select which device axis affects Y translation - - - - - - - Select which device axis affects X translation - - - - - - - -128 - - - 127 - - - 0 - - - false - - - %v - - - - - - - invert Y axis translation - + + + + + + + 0 + 0 + + + + General + + + + + + + + LED + + + + + + + + Off + + + + + On + + + + + Auto + + + + + + + + + + grabbing the device, spacenavd will prevent other programs from using it directly + + + Grab device + + + + + + + + + Use a serial device (specify path) + + + Serial device path + + + + + + + false + + + /dev/ttyS0 + + + + + + + + + + + You probably don't need this. Most devices keep sending input when held off-center. + + + Auto-repeat interval (ms) + + + + + + + false + + + 10 + + + 1000 + + + 250 + + + + + + + + + + + Reset to default configuration + + + Restore defaults + + + + + + + Restore configuration from /etc/spnavrc + + + Restore config + + + + + + + Permanently save configuration to /etc/spnavrc + + + Save config + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + 0 + + + + Axes + + + + + + - + Sensitivity - - - - device axis - - - - - - - sensitivity - - - - - - - false - - - 255 - - - - - + + - invert Z axis translation - - - - - - - - - - Select which device axis affects Z translation - - - - - - - Z axis translation sensitivity + Global sensitivity 60 + + 10 + Qt::Horizontal - - - - TX + + + + 10.000000000000000 - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 0.100000000000000 - - - - false + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + Swap the Y and Z axes (up/down - in/out) + + + Swap Y-Z + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + Global deadzone + + + true + + + + + + + Deadzone for all axes 255 - - - - invert X axis translation - - - - - - - - - - Y axis translation sensitivity - - - 60 - - - Qt::Horizontal - - - - - - - -128 - - - 127 - - - 0 - - - false - - - %v - - - - - - - false - - - 255 - - - - - - - X axis translation sensitivity - - - 60 - - - Qt::Horizontal - - - - - - - deadzone - - - - - - - TY - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - TZ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - invert - - - - - - - - - - - - - - - - - - Rotation - - - - - - invert Z axis rotation - - - - - - - - - - X axis rotation sensitivity - - - 60 - - - Qt::Horizontal - - - - - - - Select which device axis affects X rotation - - - - - - - false - - - 255 - - - - - - - Y axis rotation sensitivity - - - 60 - - - Qt::Horizontal - - - - - - - Select which device axis affects Y rotation - - - - - - - -128 - - - 127 - - - 0 - - - false - - - %v - - - - - - - RY - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - -128 - - - 127 - - - 0 - - - false - - - %v - - - - - - - invert - - - - - - - -128 - - - 127 - - - 0 - - - false - - - %v - - - - - - - false - - - 255 - - - - - - - invert Y axis rotation - - - - - - - - - - sensitivity - - - - - - - device axis - - - - - - - Z axis rotation sensitivity - - - 60 - - - Qt::Horizontal - - - - - - - invert X axis rotation - - - - - - - - - - RZ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - false - - - 255 - - - - - - - deadzone - - - - - - - Select which device axis affects Z rotation - - - - - - - RX - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - - - - - - - - - - - - - Buttons - - - - - - Buttons pressed: - - - - - - - true - - - - - 0 - 0 - 758 - 355 - + + + + + Translation + + + + + + -128 + + + 127 + + + 0 + + + false + + + %v + + + + + + + Select which device axis affects Y translation + + + + + + + Select which device axis affects X translation + + + + + + + -128 + + + 127 + + + 0 + + + false + + + %v + + + + + + + invert Y axis translation + + + + + + + + + + device axis + + + + + + + sensitivity + + + + + + + false + + + 255 + + + + + + + invert Z axis translation + + + + + + + + + + Select which device axis affects Z translation + + + + + + + Z axis translation sensitivity + + + 60 + + + Qt::Horizontal + + + + + + + TX + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + 255 + + + + + + + invert X axis translation + + + + + + + + + + Y axis translation sensitivity + + + 60 + + + Qt::Horizontal + + + + + + + -128 + + + 127 + + + 0 + + + false + + + %v + + + + + + + false + + + 255 + + + + + + + X axis translation sensitivity + + + 60 + + + Qt::Horizontal + + + + + + + deadzone + + + + + + + TY + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + TZ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + invert + + + + + + + + + + + + + + + + + + + Rotation + + + + + + invert Z axis rotation + + + + + + + + + + X axis rotation sensitivity + + + 60 + + + Qt::Horizontal + + + + + + + Select which device axis affects X rotation + + + + + + + false + + + 255 + + + + + + + Y axis rotation sensitivity + + + 60 + + + Qt::Horizontal + + + + + + + Select which device axis affects Y rotation + + + + + + + -128 + + + 127 + + + 0 + + + false + + + %v + + + + + + + RY + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + -128 + + + 127 + + + 0 + + + false + + + %v + + + + + + + invert + + + + + + + -128 + + + 127 + + + 0 + + + false + + + %v + + + + + + + false + + + 255 + + + + + + + invert Y axis rotation + + + + + + + + + + sensitivity + + + + + + + device axis + + + + + + + Z axis rotation sensitivity + + + 60 + + + Qt::Horizontal + + + + + + + invert X axis rotation + + + + + + + + + + RZ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + 255 + + + + + + + deadzone + + + + + + + Select which device axis affects Z rotation + + + + + + + RX + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + + + + + + Buttons + + + + + + Buttons pressed: - - - + + + + + true + + + + + 0 + 0 + 758 + 355 + + + + + + + - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + 0 + 800 + 22 + + + + + &File + + + + + + + + + + &Help + + + + + + + - Save config - - - Permanently save configuration to /etc/spnavrc - - - Ctrl+S - - - - - Quit - - - Quit - - - Ctrl+Q + Restore &defaults - Restore configuration - - - Restore configuration from /etc/spnavrc + &Restore config - + - Restore defaults + &Save config - - Reset to default configuration + + + + &Quit + + + + + &About @@ -1008,8 +1025,8 @@ 128 - 632 - 117 + 776 + 151 @@ -1020,12 +1037,12 @@ setEnabled(bool) - 609 - 153 + 654 + 183 - 685 - 149 + 776 + 185 @@ -1036,12 +1053,12 @@ setDisabled(bool) - 649 - 271 + 718 + 307 - 738 - 355 + 767 + 394 @@ -1056,8 +1073,8 @@ 285 - 747 - 393 + 767 + 429 @@ -1068,12 +1085,12 @@ setDisabled(bool) - 639 - 279 + 718 + 307 - 765 - 429 + 767 + 463 @@ -1084,12 +1101,12 @@ setDisabled(bool) - 622 - 280 + 718 + 307 - 727 - 530 + 767 + 559 @@ -1100,8 +1117,8 @@ setDisabled(bool) - 625 - 275 + 718 + 307 739 @@ -1116,8 +1133,8 @@ setDisabled(bool) - 627 - 279 + 718 + 307 753 @@ -1132,12 +1149,76 @@ setEnabled(bool) - 629 - 272 + 718 + 307 - 760 - 277 + 778 + 309 + + + + + act_quit + triggered() + win_main + close() + + + -1 + -1 + + + 399 + 333 + + + + + bn_loaddef + clicked() + act_default + trigger() + + + 521 + 206 + + + -1 + -1 + + + + + bn_loadcfg + clicked() + act_loadcfg + trigger() + + + 635 + 206 + + + -1 + -1 + + + + + bn_savecfg + clicked() + act_savecfg + trigger() + + + 734 + 206 + + + -1 + -1