changed the window type to QMainWindow, added menubar, and about dialog

pull/24/head
John Tsiombikas 2022-03-27 02:57:07 +02:00
rodzic 4a2de83b29
commit a4523baec2
6 zmienionych plików z 1212 dodań i 971 usunięć

1
.gitignore vendored
Wyświetl plik

@ -5,4 +5,5 @@ Makefile
spnavcfg
ui_mainwin.h
ui_bnmaprow.h
ui_about.h
res.cc

Wyświetl plik

@ -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:

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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
}

135
ui/about.ui 100644
Wyświetl plik

@ -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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:18pt; font-weight:600;&quot;&gt;spnavcfg&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p align=&quot;center&quot;&gt;&lt;span style=&quot; font-size:11pt;&quot;&gt;spacenavd configuration utility&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>&lt;html&gt;&lt;head/&gt;&lt;body&gt;
&lt;p&gt;&lt;b&gt;spnavcfg&lt;/b&gt; is part of the &lt;i&gt;Free Spacenav&lt;/i&gt; project. It's a graphical interactive configuration utility for the &lt;i&gt;spacenavd&lt;/i&gt; daemon: the free driver for 6-degree-of-freedom input devices.&lt;/p&gt;
&lt;p&gt;All parts of the Free Spacenav project are free software. See their respective licenses for details.&lt;/p&gt;
&lt;p&gt;Author &amp;amp; maintainer: John Tsiombikas &amp;lt;&lt;a href=&quot;mailto:nuclear@member.fsf.org&quot;&gt;nuclear@member.fsf.org&lt;/a&gt;&amp;gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Project website: &lt;a href=&quot;http://spacenav.sourceforge.net&quot;&gt;http://spacenav.sourceforge.net&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Spacenavd repository: &lt;a href=&quot;https://github.com/FreeSpacenav/spacenavd&quot;&gt;https://github.com/FreeSpacenav/spacenavd&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;libspnav repository: &lt;a href=&quot;https://githib.com/FreeSpacenav/libspnav&quot;&gt;https://github.com/FreeSpacenav/libspnav&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;spnavcfg repository: &lt;a href=&quot;https://github.com/FreeSpacenav/spnavcfg&quot;&gt;https://github.com/FreeSpacenav/spnavcfg&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/body&gt;&lt;/html&gt;</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>

Plik diff jest za duży Load Diff