mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-21 23:55:13 -05:00
GUI flavor: save and restore the device item index for the initial set up (R0). Fixes #1066
This commit is contained in:
parent
80992c01e0
commit
fcdeffa59c
@ -465,11 +465,14 @@ int DeviceEnumerator::getTestMIMODeviceIndex() const
|
||||
return -1;
|
||||
}
|
||||
|
||||
int DeviceEnumerator::getRxSamplingDeviceIndex(const QString& deviceId, int sequence)
|
||||
int DeviceEnumerator::getRxSamplingDeviceIndex(const QString& deviceId, int sequence, int deviceItemIndex)
|
||||
{
|
||||
for (DevicesEnumeration::iterator it = m_rxEnumeration.begin(); it != m_rxEnumeration.end(); ++it)
|
||||
{
|
||||
if ((it->m_samplingDevice.id == deviceId) && (it->m_samplingDevice.sequence == sequence)) {
|
||||
if ((it->m_samplingDevice.id == deviceId)
|
||||
&& (it->m_samplingDevice.sequence == sequence)
|
||||
&& (it->m_samplingDevice.deviceItemIndex == deviceItemIndex))
|
||||
{
|
||||
return it->m_index;
|
||||
}
|
||||
}
|
||||
@ -477,11 +480,14 @@ int DeviceEnumerator::getRxSamplingDeviceIndex(const QString& deviceId, int sequ
|
||||
return -1;
|
||||
}
|
||||
|
||||
int DeviceEnumerator::getTxSamplingDeviceIndex(const QString& deviceId, int sequence)
|
||||
int DeviceEnumerator::getTxSamplingDeviceIndex(const QString& deviceId, int sequence, int deviceItemIndex)
|
||||
{
|
||||
for (DevicesEnumeration::iterator it = m_txEnumeration.begin(); it != m_txEnumeration.end(); ++it)
|
||||
{
|
||||
if ((it->m_samplingDevice.id == deviceId) && (it->m_samplingDevice.sequence == sequence)) {
|
||||
if ((it->m_samplingDevice.id == deviceId)
|
||||
&& (it->m_samplingDevice.sequence == sequence)
|
||||
&& (it->m_samplingDevice.deviceItemIndex == deviceItemIndex))
|
||||
{
|
||||
return it->m_index;
|
||||
}
|
||||
}
|
||||
|
@ -59,8 +59,8 @@ public:
|
||||
int getFileInputDeviceIndex() const; //!< Get Rx default device
|
||||
int getTestMIMODeviceIndex() const; //!< Get MIMO default device
|
||||
int getFileOutputDeviceIndex() const; //!< Get Tx default device
|
||||
int getRxSamplingDeviceIndex(const QString& deviceId, int sequence);
|
||||
int getTxSamplingDeviceIndex(const QString& deviceId, int sequence);
|
||||
int getRxSamplingDeviceIndex(const QString& deviceId, int sequence, int deviceItemIndex);
|
||||
int getTxSamplingDeviceIndex(const QString& deviceId, int sequence, int deviceItemIndex);
|
||||
int getMIMOSamplingDeviceIndex(const QString& deviceId, int sequence);
|
||||
|
||||
private:
|
||||
|
@ -68,6 +68,8 @@ public:
|
||||
FeatureSetPreset* getWorkingFeatureSetPreset() { return &m_workingFeatureSetPreset; }
|
||||
QList<FeatureSetPreset*> *getFeatureSetPresets() { return &m_featureSetPresets; }
|
||||
|
||||
int getSourceItemIndex() const { return m_preferences.getSourceItemIndex(); }
|
||||
void setSourceItemIndex(int value) { m_preferences.setSourceItemIndex(value); }
|
||||
int getSourceIndex() const { return m_preferences.getSourceIndex(); }
|
||||
void setSourceIndex(int value) { m_preferences.setSourceIndex(value); }
|
||||
const QString& getSourceDeviceId() const { return m_preferences.getSourceDevice(); }
|
||||
|
@ -12,10 +12,11 @@ void Preferences::resetToDefaults()
|
||||
m_audioType.clear();
|
||||
m_audioDevice.clear();
|
||||
m_sourceIndex = 0;
|
||||
m_stationName = "Home";
|
||||
m_sourceItemIndex = 0;
|
||||
m_stationName = "Home";
|
||||
m_latitude = 49.012423; // Set an interesting location so map doesn't open up in the middle of the ocean
|
||||
m_longitude = 8.418125;
|
||||
m_altitude = 0.0f;
|
||||
m_altitude = 0.0f;
|
||||
m_useLogFile = false;
|
||||
m_logFileName = "sdrangel.log";
|
||||
m_consoleMinLogLevel = QtDebugMsg;
|
||||
@ -35,8 +36,9 @@ QByteArray Preferences::serialize() const
|
||||
s.writeBool(9, m_useLogFile);
|
||||
s.writeString(10, m_logFileName);
|
||||
s.writeS32(11, (int) m_fileMinLogLevel);
|
||||
s.writeString(12, m_stationName);
|
||||
s.writeFloat(13, m_altitude);
|
||||
s.writeString(12, m_stationName);
|
||||
s.writeFloat(13, m_altitude);
|
||||
s.writeS32(14, m_sourceItemIndex);
|
||||
return s.final();
|
||||
}
|
||||
|
||||
@ -78,6 +80,7 @@ bool Preferences::deserialize(const QByteArray& data)
|
||||
d.readS32(11, &tmpInt, (int) QtDebugMsg);
|
||||
d.readString(12, &m_stationName, "Home");
|
||||
d.readFloat(13, &m_altitude, 0.0f);
|
||||
d.readS32(14, &m_sourceItemIndex, 0);
|
||||
|
||||
if ((tmpInt == (int) QtDebugMsg) ||
|
||||
(tmpInt == (int) QtInfoMsg) ||
|
||||
|
@ -17,6 +17,8 @@ public:
|
||||
const QString& getSourceDevice() const { return m_sourceDevice; }
|
||||
void setSourceIndex(const int value) { m_sourceIndex = value; }
|
||||
int getSourceIndex() const { return m_sourceIndex; }
|
||||
void setSourceItemIndex(const int value) { m_sourceItemIndex = value; }
|
||||
int getSourceItemIndex() const { return m_sourceItemIndex; }
|
||||
|
||||
void setAudioType(const QString& value) { m_audioType = value; }
|
||||
const QString& getAudioType() const { return m_audioType; }
|
||||
@ -44,14 +46,15 @@ public:
|
||||
protected:
|
||||
QString m_sourceDevice; //!< Identification of the source used in R0 tab (GUI flavor) at startup
|
||||
int m_sourceIndex; //!< Index of the source used in R0 tab (GUI flavor) at startup
|
||||
int m_sourceItemIndex; //!< Index of device item in the source used in R0 tab (GUI flavor) at startup
|
||||
|
||||
QString m_audioType;
|
||||
QString m_audioDevice;
|
||||
|
||||
QString m_stationName; //!< Name of the station (for drawing on the map)
|
||||
float m_latitude; //!< Position of the station
|
||||
float m_latitude; //!< Position of the station
|
||||
float m_longitude;
|
||||
float m_altitude; //!< Altitude in metres
|
||||
float m_altitude; //!< Altitude in metres
|
||||
|
||||
QtMsgType m_consoleMinLogLevel;
|
||||
QtMsgType m_fileMinLogLevel;
|
||||
|
@ -227,10 +227,17 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
|
||||
ui->featureDock->setPresets(m_mainCore->m_settings.getFeatureSetPresets());
|
||||
ui->featureDock->setPluginAPI(m_pluginManager->getPluginAPI());
|
||||
|
||||
splash->showStatusMessage("load file input...", Qt::white);
|
||||
splash->showStatusMessage("load last device or file input...", Qt::white);
|
||||
qDebug() << "MainWindow::MainWindow: select SampleSource from settings or default (file input)...";
|
||||
qDebug() << "MainWindow::MainWindow: look for"
|
||||
<< m_mainCore->m_settings.getSourceDeviceId()
|
||||
<< "at index" << m_mainCore->m_settings.getSourceIndex()
|
||||
<< "and item index" << m_mainCore->m_settings.getSourceItemIndex();
|
||||
|
||||
int deviceIndex = DeviceEnumerator::instance()->getRxSamplingDeviceIndex(m_mainCore->m_settings.getSourceDeviceId(), m_mainCore->m_settings.getSourceIndex());
|
||||
int deviceIndex = DeviceEnumerator::instance()->getRxSamplingDeviceIndex(
|
||||
m_mainCore->m_settings.getSourceDeviceId(),
|
||||
m_mainCore->m_settings.getSourceIndex(),
|
||||
m_mainCore->m_settings.getSourceItemIndex());
|
||||
addSourceDevice(deviceIndex); // add the first device set with file input device as default if device in settings is not enumerated
|
||||
m_deviceUIs.back()->m_deviceAPI->setBuddyLeader(true); // the first device is always the leader
|
||||
tabChannelsIndexChanged(); // force channel selection list update
|
||||
@ -1989,8 +1996,11 @@ void MainWindow::sampleSourceChanged(int tabIndex, int newDeviceIndex)
|
||||
|
||||
if (tabIndex == 0) // save as default starting device
|
||||
{
|
||||
qDebug("MainWindow::sampleSourceChanged: save default starting device %s[%d:%d]",
|
||||
qPrintable(samplingDevice->id), samplingDevice->sequence, samplingDevice->deviceItemIndex);
|
||||
m_mainCore->m_settings.setSourceIndex(samplingDevice->sequence);
|
||||
m_mainCore->m_settings.setSourceDeviceId(samplingDevice->id);
|
||||
m_mainCore->m_settings.setSourceItemIndex(samplingDevice->deviceItemIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user