--- a/cadMousePro-gui/src/MouseMainWindow.cpp Fri Aug 30 01:22:12 2019 +0200
+++ b/cadMousePro-gui/src/MouseMainWindow.cpp Mon Sep 02 00:23:37 2019 +0200
@@ -23,54 +23,87 @@
MouseMainWindow::MouseMainWindow() {
proxy = new InfoGlobalcodeMouseCadMouseProInterface("info.globalcode.mouse.cadMousePro", "/info/globalcode/mouse/cadMousePro", connection, this);
- resize(640, 480);
setWindowTitle("cadMousePro");
- centralwidget = new QWidget(this);
- formLayout = new QFormLayout(centralwidget);
+
+ initStatusPanel();
+ initConfigurationPanel();
+ initAboutPanel();
+
+ setCentralWidget(tabs);
+ refresh();
+}
+
+void MouseMainWindow::initStatusPanel() {
+ QWidget* panel = new QWidget(this);
+ QFormLayout* layout = new QFormLayout(panel);
int f = 0;
- formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("How does the mouse feel:", centralwidget));
-
statusProxy->setEnabled(false);
statusUPower->setEnabled(false);
statusDevice->setEnabled(false);
- formLayout->setWidget(f++, QFormLayout::FieldRole, statusProxy);
- formLayout->setWidget(f++, QFormLayout::FieldRole, statusUPower);
- formLayout->setWidget(f++, QFormLayout::FieldRole, statusDevice);
+ layout->setWidget(f++, QFormLayout::FieldRole, statusProxy);
+ layout->setWidget(f++, QFormLayout::FieldRole, statusUPower);
+ layout->setWidget(f++, QFormLayout::FieldRole, statusDevice);
-
-
- QPushButton* refreshButton = new QPushButton("Refresh", this);
- formLayout->setWidget(f++, QFormLayout::FieldRole, refreshButton);
+ QPushButton* refreshButton = new QPushButton("Refresh", panel);
+ layout->setWidget(f++, QFormLayout::FieldRole, refreshButton);
connect(refreshButton, &QPushButton::clicked, this, &MouseMainWindow::refresh);
-
+ tabs->addTab(panel, "Status");
+}
- formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Talk to your mouse:", centralwidget));
+void MouseMainWindow::initConfigurationPanel() {
+ QWidget* panel = new QWidget(this);
+ QFormLayout* layout = new QFormLayout(panel);
+
+ int f = 0;
configureLiftOffDetection->setChecked(true);
- formLayout->setWidget(f++, QFormLayout::FieldRole, configureLiftOffDetection);
- formLayout->setWidget(f++, QFormLayout::FieldRole, configureSmartScrolling);
+ layout->setWidget(f++, QFormLayout::FieldRole, configureLiftOffDetection);
+ layout->setWidget(f++, QFormLayout::FieldRole, configureSmartScrolling);
configureFrequency250->setChecked(true);
- formLayout->setWidget(f++, QFormLayout::FieldRole, configureFrequency125);
- formLayout->setWidget(f++, QFormLayout::FieldRole, configureFrequency250);
- formLayout->setWidget(f++, QFormLayout::FieldRole, configureFrequency500);
- formLayout->setWidget(f++, QFormLayout::FieldRole, configureFrequency1000);
+ layout->setWidget(f++, QFormLayout::FieldRole, configureFrequency125);
+ layout->setWidget(f++, QFormLayout::FieldRole, configureFrequency250);
+ layout->setWidget(f++, QFormLayout::FieldRole, configureFrequency500);
+ layout->setWidget(f++, QFormLayout::FieldRole, configureFrequency1000);
- QPushButton* configureButton = new QPushButton("Configure", this);
+ QPushButton* configureButton = new QPushButton("Configure", panel);
configureButton->setToolTip("n.b. current interface is write-only and the controls above just configures the mouse – does not show current configuration");
- formLayout->setWidget(f++, QFormLayout::FieldRole, configureButton);
+ layout->setWidget(f++, QFormLayout::FieldRole, configureButton);
connect(configureButton, &QPushButton::clicked, this, &MouseMainWindow::configure);
+ message->setReadOnly(true);
+ layout->setWidget(f++, QFormLayout::FieldRole, new QLabel("Result:", panel));
+ layout->setWidget(f++, QFormLayout::FieldRole, message);
- message->setReadOnly(true);
- formLayout->setWidget(f++, QFormLayout::LabelRole, new QLabel("Mouse responds:", this));
- formLayout->setWidget(f++, QFormLayout::FieldRole, message);
+ tabs->addTab(panel, "Configuration");
+}
- setCentralWidget(centralwidget);
- refresh();
+void MouseMainWindow::initAboutPanel() {
+ QWidget* panel = new QWidget(this);
+ QFormLayout* layout = new QFormLayout(panel);
+
+ int f = 0;
+
+ layout->setWidget(f, QFormLayout::LabelRole, new QLabel("Program name:", panel));
+ layout->setWidget(f++, QFormLayout::FieldRole, new QLabel("cadMousePro", panel));
+
+ layout->setWidget(f, QFormLayout::LabelRole, new QLabel("Description:", panel));
+ layout->setWidget(f++, QFormLayout::FieldRole, new QLabel("configuration tool for 3DConnexion CadMouse Pro Wireless", panel));
+
+ layout->setWidget(f, QFormLayout::LabelRole, new QLabel("Author:", panel));
+ layout->setWidget(f++, QFormLayout::FieldRole, new QLabel("Ing. František Kučera, Frantovo.cz, GlobalCode.info", panel));
+
+ layout->setWidget(f, QFormLayout::LabelRole, new QLabel("License:", panel));
+ layout->setWidget(f++, QFormLayout::FieldRole, new QLabel("GNU GPLv3+", panel));
+
+ layout->setWidget(f, QFormLayout::LabelRole, new QLabel("Contact and support:", panel));
+ layout->setWidget(f++, QFormLayout::FieldRole, new QLabel("https://mouse.globalcode.info/", panel));
+
+ tabs->addTab(panel, "About");
+
}
void MouseMainWindow::refresh() {
@@ -80,13 +113,15 @@
}
void MouseMainWindow::configure() {
+ message->setText("…");
+
int frequency; // TODO: get value from the group
if (configureFrequency125->isChecked()) frequency = 125;
else if (configureFrequency250->isChecked()) frequency = 250;
else if (configureFrequency500->isChecked()) frequency = 500;
else if (configureFrequency1000->isChecked()) frequency = 1000;
else frequency = 250;
-
+
auto response = proxy->configure(configureLiftOffDetection->isChecked(), configureSmartScrolling->isChecked(), frequency);
response.waitForFinished();