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>
|
2003
ui/spnavcfg.ui
2003
ui/spnavcfg.ui
Plik diff jest za duży
Load Diff
Ładowanie…
Reference in New Issue