Permalink
Browse files

Issue #10: Move IF gain controls to dock widget.

  • Loading branch information...
1 parent 4703423 commit 6f09ff01d72fa89d581255267c8964180284c8e5 @csete committed Aug 28, 2011
Showing with 240 additions and 87 deletions.
  1. +33 −0 dockifgain.cpp
  2. +44 −0 dockifgain.h
  3. +86 −0 dockifgain.ui
  4. +45 −14 mainwindow.cpp
  5. +16 −6 mainwindow.h
  6. +10 −64 mainwindow.ui
  7. +6 −3 qthid.pro
View
33 dockifgain.cpp
@@ -0,0 +1,33 @@
+/***************************************************************************
+ * This file is part of Qthid.
+ *
+ * CopyRight (C) 2011 Alexandru Csete, OZ9AEC
+ *
+ * Qthid is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Qthid is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qthid. If not, see <http://www.gnu.org/licenses/>.
+ *
+ ***************************************************************************/
+#include "dockifgain.h"
+#include "ui_dockifgain.h"
+
+DockIfGain::DockIfGain(QWidget *parent) :
+ QDockWidget(parent),
+ ui(new Ui::DockIfGain)
+{
+ ui->setupUi(this);
+}
+
+DockIfGain::~DockIfGain()
+{
+ delete ui;
+}
View
44 dockifgain.h
@@ -0,0 +1,44 @@
+/***************************************************************************
+ * This file is part of Qthid.
+ *
+ * CopyRight (C) 2011 Alexandru Csete, OZ9AEC
+ *
+ * Qthid is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Qthid is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qthid. If not, see <http://www.gnu.org/licenses/>.
+ *
+ ***************************************************************************/
+#ifndef DOCKIFGAIN_H
+#define DOCKIFGAIN_H
+
+#include <QDockWidget>
+#include "ui_dockifgain.h" // necessary if we want ui to be public
+
+namespace Ui {
+ class DockIfGain;
+}
+
+class DockIfGain : public QDockWidget
+{
+ Q_OBJECT
+
+public:
+ explicit DockIfGain(QWidget *parent = 0);
+ ~DockIfGain();
+
+ Ui::DockIfGain *ui; /*! UI generated by Qt Designer. We keep it pulic so mainwindow can access controls. */
+
+private:
+
+};
+
+#endif // DOCKIFGAIN_H
View
86 dockifgain.ui
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DockIfGain</class>
+ <widget class="QDockWidget" name="DockIfGain">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>164</width>
+ <height>235</height>
+ </rect>
+ </property>
+ <property name="allowedAreas">
+ <set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
+ </property>
+ <property name="windowTitle">
+ <string>IF Gain</string>
+ </property>
+ <widget class="QWidget" name="dockWidgetContents">
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="labelIFGain1">
+ <property name="text">
+ <string>IF gain 1</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="comboBoxIFGain1"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="labelIFGain2">
+ <property name="text">
+ <string>IF gain 2</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="comboBoxIFGain2"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="labelIFGain3">
+ <property name="text">
+ <string>IF gain 3</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="comboBoxIFGain3"/>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="labelIFGain4">
+ <property name="text">
+ <string>IF gain 4</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="comboBoxIFGain4"/>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="labelIFGain5">
+ <property name="text">
+ <string>IF gain 5</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QComboBox" name="comboBoxIFGain5"/>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="labelIFGain6">
+ <property name="text">
+ <string>IF gain 6</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QComboBox" name="comboBoxIFGain6"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
View
59 mainwindow.cpp
@@ -294,7 +294,7 @@ static const COMBO_ITEM_STRUCT _cisIFGain6[]=
};
-/** \brief List of all combo boxes. */ /** FIXME: Review defaults */
+/** \brief List of all combo boxes. */
static COMBO_STRUCT _acs[] =
{
{FCD_CMD_APP_SET_LNA_GAIN, FCD_CMD_APP_GET_LNA_GAIN, 10, NULL, _cisLNAGain},
@@ -328,6 +328,25 @@ MainWindow::MainWindow(QWidget *parent) :
ui->setupUi(this);
+ /* create dock widgets */
+ uiDockIfGain = new DockIfGain();
+
+ /* Add dock widgets to main window. This should be done even for
+ dock widgets that are going to be hidden, otherwise they will
+ end up floating in their own top-level window and can not be
+ docked to the mainwindow.
+ */
+ addDockWidget(Qt::RightDockWidgetArea, uiDockIfGain);
+
+ /* hide dock widgets we don't want to show by default */
+ uiDockIfGain->hide();
+
+ /* Add dock widget actions to View menu. This way all signal/slot
+ connections will be established automagially.
+ */
+ ui->menu_View->addAction(uiDockIfGain->toggleViewAction());
+
+
/* Populate Combo Box list structure */
_acs[0].pComboBox=ui->comboBoxLNAGain;
_acs[1].pComboBox=ui->comboBoxLNAEnhance;
@@ -336,15 +355,15 @@ MainWindow::MainWindow(QWidget *parent) :
_acs[4].pComboBox=ui->comboBoxMixerGain;
_acs[5].pComboBox=ui->comboBoxBiasCurrent;
_acs[6].pComboBox=ui->comboBoxMixerFilter;
- _acs[7].pComboBox=ui->comboBoxIFGain1;
+ _acs[7].pComboBox=uiDockIfGain->ui->comboBoxIFGain1;
_acs[8].pComboBox=ui->comboBoxIFGainMode;
_acs[9].pComboBox=ui->comboBoxIFRCFilter;
- _acs[10].pComboBox=ui->comboBoxIFGain2;
- _acs[11].pComboBox=ui->comboBoxIFGain3;
- _acs[12].pComboBox=ui->comboBoxIFGain4;
+ _acs[10].pComboBox=uiDockIfGain->ui->comboBoxIFGain2;
+ _acs[11].pComboBox=uiDockIfGain->ui->comboBoxIFGain3;
+ _acs[12].pComboBox=uiDockIfGain->ui->comboBoxIFGain4;
_acs[13].pComboBox=ui->comboBoxIFFilter;
- _acs[14].pComboBox=ui->comboBoxIFGain5;
- _acs[15].pComboBox=ui->comboBoxIFGain6;
+ _acs[14].pComboBox=uiDockIfGain->ui->comboBoxIFGain5;
+ _acs[15].pComboBox=uiDockIfGain->ui->comboBoxIFGain6;
populateCombos();
@@ -370,6 +389,14 @@ MainWindow::MainWindow(QWidget *parent) :
/* connect signals & slots */
connect(ui->freqCtrl, SIGNAL(NewFrequency(qint64)), this, SLOT(setNewFrequency(qint64)));
+ /* if gains */
+ connect(uiDockIfGain->ui->comboBoxIFGain1, SIGNAL(activated(int)), this, SLOT(setIfGain1(int)));
+ connect(uiDockIfGain->ui->comboBoxIFGain2, SIGNAL(activated(int)), this, SLOT(setIfGain2(int)));
+ connect(uiDockIfGain->ui->comboBoxIFGain3, SIGNAL(activated(int)), this, SLOT(setIfGain3(int)));
+ connect(uiDockIfGain->ui->comboBoxIFGain4, SIGNAL(activated(int)), this, SLOT(setIfGain4(int)));
+ connect(uiDockIfGain->ui->comboBoxIFGain5, SIGNAL(activated(int)), this, SLOT(setIfGain5(int)));
+ connect(uiDockIfGain->ui->comboBoxIFGain6, SIGNAL(activated(int)), this, SLOT(setIfGain6(int)));
+
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(enableControls()));
timer->start(1000);
@@ -382,6 +409,8 @@ MainWindow::~MainWindow()
timer->stop();
delete timer;
+ delete uiDockIfGain;
+
settings.setValue("Frequency",ui->freqCtrl->GetFrequency());
settings.setValue("Correction",ui->spinBoxCorr->value());
@@ -603,9 +632,11 @@ void MainWindow::enableControls()
ui->spinBoxCorr->setEnabled(fme==FCD_MODE_APP);
ui->actionBalance->setEnabled(fme==FCD_MODE_APP);
+ ui->actionFirmware->setEnabled(fme==FCD_MODE_APP);
ui->actionDefault->setEnabled(fme==FCD_MODE_APP);
- enableCombos(fme==FCD_MODE_APP);
+ //enableCombos(fme==FCD_MODE_APP);
+ uiDockIfGain->setEnabled(fme==FCD_MODE_APP);
/* manage FCD mode transitions */
if (fme != prevMode) {
@@ -785,7 +816,7 @@ void MainWindow::on_comboBoxMixerFilter_activated(int index)
fcdAppSetParam(_acs[6].u8CommandSet, &u8Write, 1);
}
-void MainWindow::on_comboBoxIFGain1_activated(int index)
+void MainWindow::setIfGain1(int index)
{
quint8 u8Write = _acs[7].pacis[index].u8Val;
fcdAppSetParam(_acs[7].u8CommandSet, &u8Write, 1);
@@ -803,19 +834,19 @@ void MainWindow::on_comboBoxIFRCFilter_activated(int index)
fcdAppSetParam(_acs[9].u8CommandSet, &u8Write, 1);
}
-void MainWindow::on_comboBoxIFGain2_activated(int index)
+void MainWindow::setIfGain2(int index)
{
quint8 u8Write = _acs[10].pacis[index].u8Val;
fcdAppSetParam(_acs[10].u8CommandSet, &u8Write, 1);
}
-void MainWindow::on_comboBoxIFGain3_activated(int index)
+void MainWindow::setIfGain3(int index)
{
quint8 u8Write = _acs[11].pacis[index].u8Val;
fcdAppSetParam(_acs[11].u8CommandSet, &u8Write, 1);
}
-void MainWindow::on_comboBoxIFGain4_activated(int index)
+void MainWindow::setIfGain4(int index)
{
quint8 u8Write = _acs[12].pacis[index].u8Val;
fcdAppSetParam(_acs[12].u8CommandSet, &u8Write, 1);
@@ -827,13 +858,13 @@ void MainWindow::on_comboBoxIFFilter_activated(int index)
fcdAppSetParam(_acs[13].u8CommandSet, &u8Write, 1);
}
-void MainWindow::on_comboBoxIFGain5_activated(int index)
+void MainWindow::setIfGain5(int index)
{
quint8 u8Write = _acs[14].pacis[index].u8Val;
fcdAppSetParam(_acs[14].u8CommandSet, &u8Write, 1);
}
-void MainWindow::on_comboBoxIFGain6_activated(int index)
+void MainWindow::setIfGain6(int index)
{
quint8 u8Write = _acs[15].pacis[index].u8Val;
fcdAppSetParam(_acs[15].u8CommandSet,&u8Write,1);
View
22 mainwindow.h
@@ -28,6 +28,7 @@
#include <QLabel>
#include "fcd.h"
#include "fcddiagram.h"
+#include "dockifgain.h"
namespace Ui {
class MainWindow;
@@ -75,6 +76,7 @@ class MainWindow : public QMainWindow
FCD_MODE_ENUM prevMode; /*! Previous mode to detect FCd mode changes (bootloader/app). */
FcdDiagram *diagramDialog;
+ DockIfGain *uiDockIfGain;
double StrToDouble(QString s);
@@ -97,18 +99,26 @@ private slots:
void on_comboBoxRfFilter_activated(int index);
void on_comboBoxMixerGain_activated(int index);
void on_comboBoxMixerFilter_activated(int index);
- void on_comboBoxIFGain1_activated(int index);
+ //void on_comboBoxIFGain1_activated(int index);
void on_comboBoxIFRCFilter_activated(int index);
- void on_comboBoxIFGain2_activated(int index);
- void on_comboBoxIFGain3_activated(int index);
+ //void on_comboBoxIFGain2_activated(int index);
+ //void on_comboBoxIFGain3_activated(int index);
void on_comboBoxIFFilter_activated(int index);
- void on_comboBoxIFGain4_activated(int index);
- void on_comboBoxIFGain5_activated(int index);
- void on_comboBoxIFGain6_activated(int index);
+ //void on_comboBoxIFGain4_activated(int index);
+ //void on_comboBoxIFGain5_activated(int index);
+ //void on_comboBoxIFGain6_activated(int index);
void on_comboBoxLNAEnhance_activated(int index);
void on_comboBoxBiasCurrent_activated(int index);
void on_comboBoxIFGainMode_activated(int index);
+ /* if gain */
+ void setIfGain1(int index);
+ void setIfGain2(int index);
+ void setIfGain3(int index);
+ void setIfGain4(int index);
+ void setIfGain5(int index);
+ void setIfGain6(int index);
+
void enableControls();
/* actions */
View
74 mainwindow.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>1106</width>
+ <width>560</width>
<height>350</height>
</rect>
</property>
@@ -261,61 +261,19 @@ Requires FCD with S/N TBD or above.</string>
</widget>
</item>
<item row="0" column="4">
- <widget class="QLabel" name="labelIFGain1">
- <property name="text">
- <string>IF gain 1</string>
- </property>
- </widget>
- </item>
- <item row="0" column="5">
<widget class="QLabel" name="labelIFRCfilter">
<property name="text">
<string>IF RC filter</string>
</property>
</widget>
</item>
- <item row="0" column="6">
- <widget class="QLabel" name="labelIFGain2">
- <property name="text">
- <string>IF gain 2</string>
- </property>
- </widget>
- </item>
- <item row="0" column="7">
- <widget class="QLabel" name="labelIFGain3">
- <property name="text">
- <string>IF gain 3</string>
- </property>
- </widget>
- </item>
- <item row="0" column="8">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>IF gain 4</string>
- </property>
- </widget>
- </item>
- <item row="0" column="9">
+ <item row="0" column="5">
<widget class="QLabel" name="labelFilter">
<property name="text">
<string>IF filter</string>
</property>
</widget>
</item>
- <item row="0" column="10">
- <widget class="QLabel" name="labelIFGain5">
- <property name="text">
- <string>IF gain 5</string>
- </property>
- </widget>
- </item>
- <item row="0" column="11">
- <widget class="QLabel" name="labelIFGain6">
- <property name="text">
- <string>IF gain 6</string>
- </property>
- </widget>
- </item>
<item row="1" column="0">
<widget class="QComboBox" name="comboBoxLNAGain"/>
</item>
@@ -338,29 +296,11 @@ the frequency changes but you can force it to use a specific filter.</string>
<widget class="QComboBox" name="comboBoxMixerFilter"/>
</item>
<item row="1" column="4">
- <widget class="QComboBox" name="comboBoxIFGain1"/>
- </item>
- <item row="1" column="5">
<widget class="QComboBox" name="comboBoxIFRCFilter"/>
</item>
- <item row="1" column="6">
- <widget class="QComboBox" name="comboBoxIFGain2"/>
- </item>
- <item row="1" column="7">
- <widget class="QComboBox" name="comboBoxIFGain3"/>
- </item>
- <item row="1" column="8">
- <widget class="QComboBox" name="comboBoxIFGain4"/>
- </item>
- <item row="1" column="9">
+ <item row="1" column="5">
<widget class="QComboBox" name="comboBoxIFFilter"/>
</item>
- <item row="1" column="10">
- <widget class="QComboBox" name="comboBoxIFGain5"/>
- </item>
- <item row="1" column="11">
- <widget class="QComboBox" name="comboBoxIFGain6"/>
- </item>
<item row="0" column="1">
<widget class="QLabel" name="labelRFFilter">
<property name="text">
@@ -451,7 +391,7 @@ a specific band.</string>
<rect>
<x>0</x>
<y>0</y>
- <width>1106</width>
+ <width>560</width>
<height>25</height>
</rect>
</property>
@@ -481,8 +421,14 @@ a specific band.</string>
<addaction name="actionBalance"/>
<addaction name="actionDefault"/>
</widget>
+ <widget class="QMenu" name="menu_View">
+ <property name="title">
+ <string>&amp;View</string>
+ </property>
+ </widget>
<addaction name="menuFile"/>
<addaction name="menu_Tools"/>
+ <addaction name="menu_View"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="mainToolBar">
View
9 qthid.pro
@@ -37,7 +37,8 @@ SOURCES +=\
freqctrl.cpp \
iqbalance.cc \
fcddiagram.cpp \
- firmware.cpp
+ firmware.cpp \
+ dockifgain.cpp
mac: SOURCES += hidmac.c
win32: SOURCES += hidwin.cpp
@@ -49,13 +50,15 @@ HEADERS += mainwindow.h \
freqctrl.h \
iqbalance.h \
fcddiagram.h \
- firmware.h
+ firmware.h \
+ dockifgain.h
FORMS += \
iqbalance.ui \
mainwindow.ui \
fcddiagram.ui \
- firmware.ui
+ firmware.ui \
+ dockifgain.ui
mac:LIBS += /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation \
/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit

0 comments on commit 6f09ff0

Please sign in to comment.