mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-07-26 03:54:30 -04:00
Fix window sizing by calling sizeToContents. Roll back previous commit.
Add rollup settings.
This commit is contained in:
@@ -165,6 +165,17 @@ bool FreqDisplayGUI::deserialize(const QByteArray& data)
|
||||
return false;
|
||||
}
|
||||
|
||||
void FreqDisplayGUI::onWidgetRolled(QWidget* widget, bool rollDown)
|
||||
{
|
||||
(void) widget;
|
||||
(void) rollDown;
|
||||
|
||||
RollupContents *rollupContents = getRollupContents();
|
||||
|
||||
rollupContents->saveState(m_rollupState);
|
||||
applySettings();
|
||||
}
|
||||
|
||||
FreqDisplayGUI::FreqDisplayGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *feature, QWidget* parent) :
|
||||
FeatureGUI(parent),
|
||||
ui(new Ui::FreqDisplayGUI),
|
||||
@@ -178,9 +189,13 @@ FreqDisplayGUI::FreqDisplayGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet,
|
||||
|
||||
m_feature = feature;
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
m_helpURL = "plugins/feature/freqdisplay/readme.md";
|
||||
RollupContents *rollupContents = getRollupContents();
|
||||
ui->setupUi(rollupContents);
|
||||
rollupContents->arrangeRollups();
|
||||
connect(rollupContents, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
|
||||
sizeToContents();
|
||||
|
||||
ui->frequencyValue->setWordWrap(true);
|
||||
|
||||
m_freqDisplay->setMessageQueueToGUI(&m_inputMessageQueue);
|
||||
@@ -211,6 +226,8 @@ FreqDisplayGUI::FreqDisplayGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet,
|
||||
ui->speech->setVisible(false);
|
||||
#endif
|
||||
|
||||
m_settings.setRollupState(&m_rollupState);
|
||||
|
||||
displaySettings();
|
||||
updateFrequencyText();
|
||||
m_resizer.enableChildMouseTracking();
|
||||
@@ -280,6 +297,9 @@ void FreqDisplayGUI::displaySettings()
|
||||
applyTextColor();
|
||||
applySpeech();
|
||||
updateChannelList();
|
||||
|
||||
getRollupContents()->restoreState(m_rollupState);
|
||||
getRollupContents()->arrangeRollups();
|
||||
}
|
||||
|
||||
void FreqDisplayGUI::applySettings(bool force)
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "availablechannelorfeaturehandler.h"
|
||||
#include "feature/featuregui.h"
|
||||
#include "util/messagequeue.h"
|
||||
#include "settings/rollupstate.h"
|
||||
|
||||
#include "freqdisplaysettings.h"
|
||||
|
||||
@@ -96,6 +97,7 @@ private:
|
||||
Ui::FreqDisplayGUI* ui;
|
||||
FreqDisplay* m_freqDisplay;
|
||||
FreqDisplaySettings m_settings;
|
||||
RollupState m_rollupState;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
AvailableChannelOrFeatureHandler m_availableChannelOrFeatureHandler;
|
||||
AvailableChannelOrFeatureList m_availableChannels;
|
||||
@@ -126,6 +128,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void channelsOrFeaturesChanged(const QStringList& renameFrom, const QStringList& renameTo, const QStringList& removed, const QStringList& added);
|
||||
void onWidgetRolled(QWidget* widget, bool rollDown);
|
||||
void on_channels_currentIndexChanged(int index);
|
||||
void on_displayMode_currentIndexChanged(int index);
|
||||
void on_speech_toggled(bool checked);
|
||||
|
||||
@@ -19,10 +19,12 @@
|
||||
#include <QColor>
|
||||
|
||||
#include "util/simpleserializer.h"
|
||||
#include "settings/serializable.h"
|
||||
|
||||
#include "freqdisplaysettings.h"
|
||||
|
||||
FreqDisplaySettings::FreqDisplaySettings()
|
||||
FreqDisplaySettings::FreqDisplaySettings() :
|
||||
m_rollupState(nullptr)
|
||||
{
|
||||
resetToDefaults();
|
||||
}
|
||||
@@ -61,6 +63,9 @@ QByteArray FreqDisplaySettings::serialize() const
|
||||
s.writeS32(11, m_freqDecimalPlaces);
|
||||
s.writeS32(12, m_powerDecimalPlaces);
|
||||
s.writeU32(13, m_textColor.rgba());
|
||||
if (m_rollupState) {
|
||||
s.writeBlob(14, m_rollupState->serialize());
|
||||
}
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@@ -68,6 +73,7 @@ QByteArray FreqDisplaySettings::serialize() const
|
||||
bool FreqDisplaySettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
SimpleDeserializer d(data);
|
||||
QByteArray bytetmp;
|
||||
|
||||
if (!d.isValid())
|
||||
{
|
||||
@@ -100,6 +106,11 @@ bool FreqDisplaySettings::deserialize(const QByteArray& data)
|
||||
quint32 rgba = QColor(Qt::white).rgba();
|
||||
d.readU32(13, &rgba, QColor(Qt::white).rgba());
|
||||
m_textColor = QColor::fromRgba(rgba);
|
||||
if (m_rollupState)
|
||||
{
|
||||
d.readBlob(14, &bytetmp);
|
||||
m_rollupState->deserialize(bytetmp);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
class Serializable;
|
||||
|
||||
struct FreqDisplaySettings
|
||||
{
|
||||
enum DisplayMode {
|
||||
@@ -52,6 +54,7 @@ struct FreqDisplaySettings
|
||||
int m_freqDecimalPlaces; //!< Decimal places for frequency value (max depends on units: kHz→3, MHz→6, GHz→9)
|
||||
int m_powerDecimalPlaces; //!< Decimal places for power value (0–3)
|
||||
QColor m_textColor; //!< Color of the frequency / power text
|
||||
Serializable *m_rollupState;
|
||||
|
||||
FreqDisplaySettings();
|
||||
~FreqDisplaySettings() = default;
|
||||
@@ -59,6 +62,7 @@ struct FreqDisplaySettings
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
|
||||
void applySettings(const QStringList& settingsKeys, const FreqDisplaySettings& settings);
|
||||
};
|
||||
|
||||
|
||||
@@ -377,9 +377,7 @@ void ChannelGUI::sizeToContents()
|
||||
size = size.expandedTo(m_topLayout->minimumSize());
|
||||
size.setHeight(size.height() + getAdditionalHeight());
|
||||
size.setWidth(size.width() + m_resizer.m_gripSize * 2);
|
||||
// m_resizer enforces minimumSizeHint() while m_sizeGripBottomRight enforces minimumSize().
|
||||
// Ensure both are consistent by making minimumSize() at least as large as minimumSizeHint().
|
||||
setMinimumSize(size.expandedTo(minimumSizeHint()));
|
||||
setMinimumSize(size);
|
||||
|
||||
// Restrict size of window to size of desktop
|
||||
DialogPositioner::sizeToDesktop(this);
|
||||
|
||||
@@ -336,9 +336,7 @@ void FeatureGUI::sizeToContents()
|
||||
size = size.expandedTo(m_topLayout->minimumSize());
|
||||
size.setHeight(size.height() + getAdditionalHeight());
|
||||
size.setWidth(size.width() + m_resizer.m_gripSize * 2);
|
||||
// m_resizer enforces minimumSizeHint() while m_sizeGripBottomRight enforces minimumSize().
|
||||
// Ensure both are consistent by making minimumSize() at least as large as minimumSizeHint().
|
||||
setMinimumSize(size.expandedTo(minimumSizeHint()));
|
||||
setMinimumSize(size);
|
||||
}
|
||||
|
||||
void FeatureGUI::maximizeWindow()
|
||||
|
||||
Reference in New Issue
Block a user