kopia lustrzana https://github.com/FreeSpacenav/spnavcfg
changed the window type to QMainWindow, added menubar, and about dialog
rodzic
4a2de83b29
commit
a4523baec2
|
@ -5,4 +5,5 @@ Makefile
|
|||
spnavcfg
|
||||
ui_mainwin.h
|
||||
ui_bnmaprow.h
|
||||
ui_about.h
|
||||
res.cc
|
||||
|
|
|
@ -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:
|
||||
|
|
30
src/ui.cc
30
src/ui.cc
|
@ -6,6 +6,7 @@
|
|||
#include "spnavcfg.h"
|
||||
#include "ui_mainwin.h"
|
||||
#include "ui_bnmaprow.h"
|
||||
#include "ui_about.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
7
src/ui.h
7
src/ui.h
|
@ -3,13 +3,13 @@
|
|||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMainWindow>
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>dlg_about</class>
|
||||
<widget class="QDialog" name="dlg_about">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>605</width>
|
||||
<height>366</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>About spnavcfg</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-size:18pt; font-weight:600;">spnavcfg</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p align="center"><span style=" font-size:11pt;">spacenavd configuration utility</span></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Maximum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string><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></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<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>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>dlg_about</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>dlg_about</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
197
ui/spnavcfg.ui
197
ui/spnavcfg.ui
|
@ -1,18 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>win_main</class>
|
||||
<widget class="QWidget" name="win_main">
|
||||
<widget class="QMainWindow" name="win_main">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>667</height>
|
||||
<height>689</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Spacenav configuration</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
|
@ -297,7 +298,7 @@
|
|||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_axes" native="true">
|
||||
<widget class="QWidget" name="tab_axes">
|
||||
<attribute name="title">
|
||||
<string>Axes</string>
|
||||
</attribute>
|
||||
|
@ -956,42 +957,58 @@
|
|||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="act_savecfg">
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
<property name="title">
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="act_default"/>
|
||||
<addaction name="act_loadcfg"/>
|
||||
<addaction name="act_savecfg"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="act_quit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Help">
|
||||
<property name="title">
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="act_about"/>
|
||||
</widget>
|
||||
<addaction name="menu_File"/>
|
||||
<addaction name="menu_Help"/>
|
||||
</widget>
|
||||
<action name="act_default">
|
||||
<property name="text">
|
||||
<string>Save config</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Permanently save configuration to /etc/spnavrc</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="act_quit">
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
<string>Restore &defaults</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="act_loadcfg">
|
||||
<property name="text">
|
||||
<string>Restore configuration</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Restore configuration from /etc/spnavrc</string>
|
||||
<string>&Restore config</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="act_loaddef">
|
||||
<action name="act_savecfg">
|
||||
<property name="text">
|
||||
<string>Restore defaults</string>
|
||||
<string>&Save config</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset to default configuration</string>
|
||||
</action>
|
||||
<action name="act_quit">
|
||||
<property name="text">
|
||||
<string>&Quit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="act_about">
|
||||
<property name="text">
|
||||
<string>&About</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
@ -1008,8 +1025,8 @@
|
|||
<y>128</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>632</x>
|
||||
<y>117</y>
|
||||
<x>776</x>
|
||||
<y>151</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -1020,12 +1037,12 @@
|
|||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>609</x>
|
||||
<y>153</y>
|
||||
<x>654</x>
|
||||
<y>183</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>685</x>
|
||||
<y>149</y>
|
||||
<x>776</x>
|
||||
<y>185</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -1036,12 +1053,12 @@
|
|||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>649</x>
|
||||
<y>271</y>
|
||||
<x>718</x>
|
||||
<y>307</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>738</x>
|
||||
<y>355</y>
|
||||
<x>767</x>
|
||||
<y>394</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -1056,8 +1073,8 @@
|
|||
<y>285</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>747</x>
|
||||
<y>393</y>
|
||||
<x>767</x>
|
||||
<y>429</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -1068,12 +1085,12 @@
|
|||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>639</x>
|
||||
<y>279</y>
|
||||
<x>718</x>
|
||||
<y>307</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>765</x>
|
||||
<y>429</y>
|
||||
<x>767</x>
|
||||
<y>463</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -1084,12 +1101,12 @@
|
|||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>622</x>
|
||||
<y>280</y>
|
||||
<x>718</x>
|
||||
<y>307</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>727</x>
|
||||
<y>530</y>
|
||||
<x>767</x>
|
||||
<y>559</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -1100,8 +1117,8 @@
|
|||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>625</x>
|
||||
<y>275</y>
|
||||
<x>718</x>
|
||||
<y>307</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>739</x>
|
||||
|
@ -1116,8 +1133,8 @@
|
|||
<slot>setDisabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>627</x>
|
||||
<y>279</y>
|
||||
<x>718</x>
|
||||
<y>307</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>753</x>
|
||||
|
@ -1132,12 +1149,76 @@
|
|||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>629</x>
|
||||
<y>272</y>
|
||||
<x>718</x>
|
||||
<y>307</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>760</x>
|
||||
<y>277</y>
|
||||
<x>778</x>
|
||||
<y>309</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>act_quit</sender>
|
||||
<signal>triggered()</signal>
|
||||
<receiver>win_main</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>333</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bn_loaddef</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>act_default</receiver>
|
||||
<slot>trigger()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>521</x>
|
||||
<y>206</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bn_loadcfg</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>act_loadcfg</receiver>
|
||||
<slot>trigger()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>635</x>
|
||||
<y>206</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>bn_savecfg</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>act_savecfg</receiver>
|
||||
<slot>trigger()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>734</x>
|
||||
<y>206</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
|
Ładowanie…
Reference in New Issue