Fixed configuration ui for compose textbox

This commit is contained in:
Jordan Sherer 2018-09-12 20:51:46 -04:00
parent e52a62e689
commit 873929b3f6
4 changed files with 274 additions and 114 deletions

View File

@ -473,7 +473,9 @@ private:
Q_SLOT void on_rxBackgroundButton_clicked(); Q_SLOT void on_rxBackgroundButton_clicked();
Q_SLOT void on_rxForegroundButton_clicked(); Q_SLOT void on_rxForegroundButton_clicked();
Q_SLOT void on_rxFontButton_clicked(); Q_SLOT void on_rxFontButton_clicked();
Q_SLOT void on_txBackgroundButton_clicked(); Q_SLOT void on_composeBackgroundButton_clicked();
Q_SLOT void on_composeForegroundButton_clicked();
Q_SLOT void on_composeFontButton_clicked();
Q_SLOT void on_txForegroundButton_clicked(); Q_SLOT void on_txForegroundButton_clicked();
Q_SLOT void on_txFontButton_clicked(); Q_SLOT void on_txFontButton_clicked();
@ -519,6 +521,9 @@ private:
QFont tx_text_font_; QFont tx_text_font_;
QFont next_tx_text_font_; QFont next_tx_text_font_;
QFont compose_text_font_;
QFont next_compose_text_font_;
bool restart_sound_input_device_; bool restart_sound_input_device_;
bool restart_sound_output_device_; bool restart_sound_output_device_;
@ -582,8 +587,10 @@ private:
QColor next_color_rx_background_; QColor next_color_rx_background_;
QColor color_rx_foreground_; QColor color_rx_foreground_;
QColor next_color_rx_foreground_; QColor next_color_rx_foreground_;
QColor color_tx_background_; QColor color_compose_background_;
QColor next_color_tx_background_; QColor next_color_compose_background_;
QColor color_compose_foreground_;
QColor next_color_compose_foreground_;
QColor color_tx_foreground_; QColor color_tx_foreground_;
QColor next_color_tx_foreground_; QColor next_color_tx_foreground_;
QColor color_DXCC_; QColor color_DXCC_;
@ -695,13 +702,15 @@ QColor Configuration::color_CQ () const {return m_->color_cq_;}
QColor Configuration::color_MyCall () const {return m_->color_mycall_;} QColor Configuration::color_MyCall () const {return m_->color_mycall_;}
QColor Configuration::color_rx_background () const {return m_->color_rx_background_;} QColor Configuration::color_rx_background () const {return m_->color_rx_background_;}
QColor Configuration::color_rx_foreground () const {return m_->color_rx_foreground_;} QColor Configuration::color_rx_foreground () const {return m_->color_rx_foreground_;}
QColor Configuration::color_tx_background () const {return m_->color_tx_background_;}
QColor Configuration::color_tx_foreground () const {return m_->color_tx_foreground_;} QColor Configuration::color_tx_foreground () const {return m_->color_tx_foreground_;}
QColor Configuration::color_compose_background () const {return m_->color_compose_background_;}
QColor Configuration::color_compose_foreground () const {return m_->color_compose_foreground_;}
QColor Configuration::color_DXCC () const {return m_->color_DXCC_;} QColor Configuration::color_DXCC () const {return m_->color_DXCC_;}
QColor Configuration::color_NewCall () const {return m_->color_NewCall_;} QColor Configuration::color_NewCall () const {return m_->color_NewCall_;}
QFont Configuration::text_font () const {return m_->font_;} QFont Configuration::text_font () const {return m_->font_;}
QFont Configuration::rx_text_font () const {return m_->rx_text_font_;} QFont Configuration::rx_text_font () const {return m_->rx_text_font_;}
QFont Configuration::tx_text_font () const {return m_->tx_text_font_;} QFont Configuration::tx_text_font () const {return m_->tx_text_font_;}
QFont Configuration::compose_text_font () const {return m_->compose_text_font_;}
qint32 Configuration::id_interval () const {return m_->id_interval_;} qint32 Configuration::id_interval () const {return m_->id_interval_;}
qint32 Configuration::ntrials() const {return m_->ntrials_;} qint32 Configuration::ntrials() const {return m_->ntrials_;}
qint32 Configuration::aggressive() const {return m_->aggressive_;} qint32 Configuration::aggressive() const {return m_->aggressive_;}
@ -1275,9 +1284,9 @@ void Configuration::impl::initialize_models ()
ui_->labMyCall->setStyleSheet(QString("background: %1").arg(color_mycall_.name())); ui_->labMyCall->setStyleSheet(QString("background: %1").arg(color_mycall_.name()));
ui_->rxLabel->setStyleSheet(QString("background: %1").arg(color_rx_background_.name())); ui_->rxLabel->setStyleSheet(QString("background: %1").arg(color_rx_background_.name()));
ui_->txLabel->setStyleSheet(QString("background: %1").arg(color_tx_background_.name()));
ui_->rxForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(color_rx_background_.name()).arg(color_rx_foreground_.name())); ui_->rxForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(color_rx_background_.name()).arg(color_rx_foreground_.name()));
ui_->txForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(color_rx_background_.name()).arg(color_tx_foreground_.name())); ui_->txForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(color_rx_background_.name()).arg(color_tx_foreground_.name()));
ui_->composeLabel->setStyleSheet(QString("background: %1; color: %2").arg(color_compose_background_.name()).arg(color_compose_foreground_.name()));
ui_->CW_id_interval_spin_box->setValue (id_interval_); ui_->CW_id_interval_spin_box->setValue (id_interval_);
ui_->sbNtrials->setValue (ntrials_); ui_->sbNtrials->setValue (ntrials_);
@ -1413,7 +1422,8 @@ void Configuration::impl::read_settings ()
next_color_mycall_ = color_mycall_ = settings_->value("colorMyCall","#ff6666").toString(); next_color_mycall_ = color_mycall_ = settings_->value("colorMyCall","#ff6666").toString();
next_color_rx_background_ = color_rx_background_ = settings_->value("color_rx_background","#ffeaa7").toString(); next_color_rx_background_ = color_rx_background_ = settings_->value("color_rx_background","#ffeaa7").toString();
next_color_rx_foreground_ = color_rx_foreground_ = settings_->value("color_rx_foreground","#000000").toString(); next_color_rx_foreground_ = color_rx_foreground_ = settings_->value("color_rx_foreground","#000000").toString();
next_color_tx_background_ = color_tx_background_ = settings_->value("color_tx_background","#ffffff").toString(); next_color_compose_background_ = color_compose_background_ = settings_->value("color_compose_background","#ffffff").toString();
next_color_compose_foreground_ = color_compose_foreground_ = settings_->value("color_compose_foreground","#000000").toString();
next_color_tx_foreground_ = color_tx_foreground_ = settings_->value("color_tx_foreground","#ff0000").toString(); next_color_tx_foreground_ = color_tx_foreground_ = settings_->value("color_tx_foreground","#ff0000").toString();
next_color_DXCC_ = color_DXCC_ = settings_->value("colorDXCC","#ff00ff").toString(); next_color_DXCC_ = color_DXCC_ = settings_->value("colorDXCC","#ff00ff").toString();
next_color_NewCall_ = color_NewCall_ = settings_->value("colorNewCall","#ffaaff").toString(); next_color_NewCall_ = color_NewCall_ = settings_->value("colorNewCall","#ffaaff").toString();
@ -1456,6 +1466,19 @@ void Configuration::impl::read_settings ()
ui_->rxFontButton->setText(QString("Font (%1 %2)").arg(next_rx_text_font_.family()).arg(next_rx_text_font_.pointSize())); ui_->rxFontButton->setText(QString("Font (%1 %2)").arg(next_rx_text_font_.family()).arg(next_rx_text_font_.pointSize()));
if (next_compose_text_font_.fromString (settings_->value ("composeTextFont", QGuiApplication::font ().toString ()).toString ())
&& next_compose_text_font_ != compose_text_font_)
{
compose_text_font_ = next_compose_text_font_;
Q_EMIT self_->compose_text_font_changed (compose_text_font_);
}
else
{
next_compose_text_font_ = compose_text_font_;
}
ui_->composeFontButton->setText(QString("Font (%1 %2)").arg(next_compose_text_font_.family()).arg(next_compose_text_font_.pointSize()));
id_interval_ = settings_->value ("IDint", 0).toInt (); id_interval_ = settings_->value ("IDint", 0).toInt ();
ntrials_ = settings_->value ("nTrials", 6).toInt (); ntrials_ = settings_->value ("nTrials", 6).toInt ();
txDelay_ = settings_->value ("TxDelay",0.2).toDouble(); txDelay_ = settings_->value ("TxDelay",0.2).toDouble();
@ -1638,7 +1661,8 @@ void Configuration::impl::write_settings ()
settings_->setValue("colorMyCall",color_mycall_); settings_->setValue("colorMyCall",color_mycall_);
settings_->setValue("color_rx_background",color_rx_background_); settings_->setValue("color_rx_background",color_rx_background_);
settings_->setValue("color_rx_foreground",color_rx_foreground_); settings_->setValue("color_rx_foreground",color_rx_foreground_);
settings_->setValue("color_tx_background",color_tx_background_); settings_->setValue("color_compose_background",color_compose_background_);
settings_->setValue("color_compose_foreground",color_compose_foreground_);
settings_->setValue("color_tx_foreground",color_tx_foreground_); settings_->setValue("color_tx_foreground",color_tx_foreground_);
settings_->setValue("colorDXCC",color_DXCC_); settings_->setValue("colorDXCC",color_DXCC_);
settings_->setValue("colorNewCall",color_NewCall_); settings_->setValue("colorNewCall",color_NewCall_);
@ -2018,11 +2042,18 @@ void Configuration::impl::accept ()
Q_EMIT self_->rx_text_font_changed (rx_text_font_); Q_EMIT self_->rx_text_font_changed (rx_text_font_);
} }
if (next_compose_text_font_ != compose_text_font_)
{
compose_text_font_ = next_compose_text_font_;
Q_EMIT self_->compose_text_font_changed (compose_text_font_);
}
color_cq_ = next_color_cq_; color_cq_ = next_color_cq_;
color_mycall_ = next_color_mycall_; color_mycall_ = next_color_mycall_;
color_rx_background_ = next_color_rx_background_; color_rx_background_ = next_color_rx_background_;
color_rx_foreground_ = next_color_rx_foreground_; color_rx_foreground_ = next_color_rx_foreground_;
color_tx_background_ = next_color_tx_background_; color_compose_background_ = next_color_compose_background_;
color_compose_foreground_ = next_color_compose_foreground_;
color_tx_foreground_ = next_color_tx_foreground_; color_tx_foreground_ = next_color_tx_foreground_;
color_DXCC_ = next_color_DXCC_; color_DXCC_ = next_color_DXCC_;
color_NewCall_ = next_color_NewCall_; color_NewCall_ = next_color_NewCall_;
@ -2331,15 +2362,23 @@ void Configuration::impl::on_rxFontButton_clicked ()
ui_->rxFontButton->setText(QString("Font (%1 %2)").arg(next_rx_text_font_.family()).arg(next_rx_text_font_.pointSize())); ui_->rxFontButton->setText(QString("Font (%1 %2)").arg(next_rx_text_font_.family()).arg(next_rx_text_font_.pointSize()));
} }
void Configuration::impl::on_txBackgroundButton_clicked() void Configuration::impl::on_composeBackgroundButton_clicked()
{ {
auto new_color = getColor(next_color_tx_background_, this, "Transmitted Messages Background Color"); auto new_color = getColor(next_color_compose_background_, this, "Compose Messages Background Color");
if (new_color.isValid ()) if (new_color.isValid ())
{ {
next_color_tx_background_ = new_color; next_color_compose_background_ = new_color;
ui_->txLabel->setStyleSheet(QString("background: %1").arg(next_color_tx_background_.name())); ui_->composeLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_compose_background_.name()).arg(next_color_compose_foreground_.name()));
ui_->rxForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_rx_background_.name()).arg(next_color_rx_foreground_.name())); }
ui_->txForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_rx_background_.name()).arg(next_color_tx_foreground_.name())); }
void Configuration::impl::on_composeForegroundButton_clicked()
{
auto new_color = getColor(next_color_compose_foreground_, this, "Compose Messages Foreground Color");
if (new_color.isValid ())
{
next_color_compose_foreground_ = new_color;
ui_->composeLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_compose_background_.name()).arg(next_color_compose_foreground_.name()));
} }
} }
@ -2349,7 +2388,6 @@ void Configuration::impl::on_txForegroundButton_clicked()
if (new_color.isValid ()) if (new_color.isValid ())
{ {
next_color_tx_foreground_ = new_color; next_color_tx_foreground_ = new_color;
ui_->txLabel->setStyleSheet(QString("background: %1").arg(next_color_tx_background_.name()));
ui_->rxForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_rx_background_.name()).arg(next_color_rx_foreground_.name())); ui_->rxForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_rx_background_.name()).arg(next_color_rx_foreground_.name()));
ui_->txForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_rx_background_.name()).arg(next_color_tx_foreground_.name())); ui_->txForegroundLabel->setStyleSheet(QString("background: %1; color: %2").arg(next_color_rx_background_.name()).arg(next_color_tx_foreground_.name()));
} }
@ -2367,6 +2405,17 @@ void Configuration::impl::on_txFontButton_clicked ()
ui_->txFontButton->setText(QString("Font (%1 %2)").arg(next_tx_text_font_.family()).arg(next_tx_text_font_.pointSize())); ui_->txFontButton->setText(QString("Font (%1 %2)").arg(next_tx_text_font_.family()).arg(next_tx_text_font_.pointSize()));
} }
void Configuration::impl::on_composeFontButton_clicked ()
{
next_compose_text_font_ = QFontDialog::getFont (0, next_compose_text_font_ , this
, tr ("Font Chooser")
#if QT_VERSION >= 0x050201
, 0
#endif
);
ui_->composeFontButton->setText(QString("Font (%1 %2)").arg(next_compose_text_font_.family()).arg(next_compose_text_font_.pointSize()));
}
void Configuration::impl::on_PTT_port_combo_box_activated (int /* index */) void Configuration::impl::on_PTT_port_combo_box_activated (int /* index */)
{ {
set_rig_invariants (); set_rig_invariants ();

View File

@ -106,6 +106,7 @@ public:
QFont text_font () const; QFont text_font () const;
QFont rx_text_font () const; QFont rx_text_font () const;
QFont tx_text_font () const; QFont tx_text_font () const;
QFont compose_text_font () const;
qint32 id_interval () const; qint32 id_interval () const;
qint32 ntrials() const; qint32 ntrials() const;
qint32 aggressive() const; qint32 aggressive() const;
@ -184,8 +185,9 @@ public:
QColor color_MyCall () const; QColor color_MyCall () const;
QColor color_rx_background () const; QColor color_rx_background () const;
QColor color_rx_foreground () const; QColor color_rx_foreground () const;
QColor color_tx_background () const;
QColor color_tx_foreground () const; QColor color_tx_foreground () const;
QColor color_compose_background () const;
QColor color_compose_foreground () const;
QColor color_DXCC () const; QColor color_DXCC () const;
QColor color_NewCall () const; QColor color_NewCall () const;
bool pwrBandTxMemory () const; bool pwrBandTxMemory () const;
@ -281,6 +283,7 @@ public:
Q_SIGNAL void gui_text_font_changed (QFont); Q_SIGNAL void gui_text_font_changed (QFont);
Q_SIGNAL void tx_text_font_changed (QFont); Q_SIGNAL void tx_text_font_changed (QFont);
Q_SIGNAL void rx_text_font_changed (QFont); Q_SIGNAL void rx_text_font_changed (QFont);
Q_SIGNAL void compose_text_font_changed (QFont);
Q_SIGNAL void colors_changed (); Q_SIGNAL void colors_changed ();
// //

View File

@ -2747,7 +2747,7 @@ Right click for insert and delete options.</string>
<item> <item>
<widget class="QGroupBox" name="groupBox_9"> <widget class="QGroupBox" name="groupBox_9">
<property name="title"> <property name="title">
<string>Band Activity Background</string> <string>Band Activity Background:</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_15"> <layout class="QGridLayout" name="gridLayout_15">
<item row="0" column="0"> <item row="0" column="0">
@ -2818,12 +2818,55 @@ Right click for insert and delete options.</string>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox_12"> <widget class="QGroupBox" name="groupBox_8">
<property name="title"> <property name="title">
<string>Message Background</string> <string>Messages:</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_13"> <layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0"> <item row="6" column="1">
<widget class="QPushButton" name="rxFontButton">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="rxBackgroundButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Textbox Color</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="rxForegroundButton">
<property name="text">
<string>Foreground Color</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="rxForegroundLabel">
<property name="styleSheet">
<string notr="true">QLabel{background-color: #ffeaa7}</string>
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="rxLabel"> <widget class="QLabel" name="rxLabel">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -2845,24 +2888,98 @@ Right click for insert and delete options.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="9" column="0">
<widget class="QPushButton" name="rxBackgroundButton"> <widget class="QLabel" name="txForegroundLabel">
<property name="enabled"> <property name="styleSheet">
<bool>true</bool> <string notr="true">QLabel{background-color: #ffeaa7}</string>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property> </property>
<property name="text"> <property name="text">
<string>Receive Background Color</string> <string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="8" column="0">
<widget class="QLabel" name="txLabel"> <widget class="QLabel" name="label_22">
<property name="text">
<string>Transmitted:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QPushButton" name="txFontButton">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QPushButton" name="txForegroundButton">
<property name="text">
<string>Foreground Color</string>
</property>
</widget>
</item>
<item row="7" column="1">
<spacer name="verticalSpacer_10">
<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 row="4" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Received:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_9">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_14">
<property name="title">
<string>Message Composition:</string>
</property>
<layout class="QGridLayout" name="gridLayout_18">
<item row="0" column="1">
<widget class="QPushButton" name="composeBackgroundButton">
<property name="text">
<string> Textbox Color</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="composeFontButton">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="composeLabel">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -2883,84 +3000,25 @@ Right click for insert and delete options.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QPushButton" name="txBackgroundButton">
<property name="text">
<string>Transmit Background Color</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Messages Received</string>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="3" column="1">
<widget class="QPushButton" name="rxFontButton">
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QPushButton" name="rxForegroundButton"> <widget class="QPushButton" name="composeForegroundButton">
<property name="text"> <property name="text">
<string>Foreground Color</string> <string>Foreground Color</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="rxForegroundLabel">
<property name="styleSheet">
<string notr="true">QLabel{background-color: #ffeaa7}</string>
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_11">
<property name="title">
<string>Messages Transmitted</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="1"> <item row="1" column="1">
<widget class="QPushButton" name="txForegroundButton"> <spacer name="verticalSpacer_12">
<property name="text"> <property name="orientation">
<string>Foreground Color</string> <enum>Qt::Vertical</enum>
</property> </property>
</widget> <property name="sizeHint" stdset="0">
</item> <size>
<item row="3" column="1"> <width>20</width>
<widget class="QPushButton" name="txFontButton"> <height>40</height>
<property name="text"> </size>
<string>Font</string>
</property> </property>
</widget> </spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="txForegroundLabel">
<property name="styleSheet">
<string notr="true">QLabel{background-color: #ffeaa7}</string>
</property>
<property name="text">
<string>K1ABC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -3418,12 +3476,12 @@ soundcard changes</string>
</connection> </connection>
</connections> </connections>
<buttongroups> <buttongroups>
<buttongroup name="CAT_handshake_button_group"/> <buttongroup name="PTT_method_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="CAT_stop_bits_button_group"/> <buttongroup name="CAT_stop_bits_button_group"/>
<buttongroup name="TX_audio_source_button_group"/> <buttongroup name="TX_audio_source_button_group"/>
<buttongroup name="PTT_method_button_group"/>
<buttongroup name="split_mode_button_group"/> <buttongroup name="split_mode_button_group"/>
<buttongroup name="CAT_data_bits_button_group"/>
<buttongroup name="TX_mode_button_group"/> <buttongroup name="TX_mode_button_group"/>
<buttongroup name="CAT_handshake_button_group"/>
</buttongroups> </buttongroups>
</ui> </ui>

View File

@ -304,10 +304,46 @@ namespace
edit->updateGeometry(); edit->updateGeometry();
} }
void setTextEditBackground(QTextEdit *edit, QColor color){ void setTextEditColors(QTextEdit *edit, QColor fg, QColor bg){
edit->setStyleSheet(QString("QTextEdit{ background: %1 }").arg(color.name())); edit->setStyleSheet(QString("QTextEdit { color:%1; background: %2 }").arg(fg.name()).arg(bg.name()));
QTimer::singleShot(10, nullptr, [edit, fg, bg](){
QPalette p = edit->palette();
p.setColor(QPalette::Base, bg);
p.setColor(QPalette::Active, QPalette::Base, bg);
p.setColor(QPalette::Disabled, QPalette::Base, bg);
p.setColor(QPalette::Inactive, QPalette::Base, bg);
p.setColor(QPalette::Text, fg);
p.setColor(QPalette::Active, QPalette::Text, fg);
p.setColor(QPalette::Disabled, QPalette::Text, fg);
p.setColor(QPalette::Inactive, QPalette::Text, fg);
edit->setBackgroundRole(QPalette::Base);
edit->setForegroundRole(QPalette::Text);
edit->setPalette(p);
edit->updateGeometry();
edit->update();
});
} }
/*
void setTextEditForeground(QTextEdit *edit, QColor color){
QTimer::singleShot(20, nullptr, [edit, color](){
QPalette p = edit->palette();
p.setColor(QPalette::Text, color);
p.setColor(QPalette::Active, QPalette::Text, color);
p.setColor(QPalette::Disabled, QPalette::Text, color);
p.setColor(QPalette::Inactive, QPalette::Text, color);
edit->setPalette(p);
edit->updateGeometry();
edit->update();
});
}
*/
void highlightBlock(QTextBlock block, QFont font, QColor foreground, QColor background){ void highlightBlock(QTextBlock block, QFont font, QColor foreground, QColor background){
QTextCursor cursor(block); QTextCursor cursor(block);
@ -695,12 +731,12 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
connect (&m_config, &Configuration::rx_text_font_changed, [this] (QFont const&) { connect (&m_config, &Configuration::rx_text_font_changed, [this] (QFont const&) {
setTextEditFont(ui->textEditRX, m_config.rx_text_font()); setTextEditFont(ui->textEditRX, m_config.rx_text_font());
}); });
connect (&m_config, &Configuration::tx_text_font_changed, [this] (QFont const&) { connect (&m_config, &Configuration::compose_text_font_changed, [this] (QFont const&) {
setTextEditFont(ui->extFreeTextMsgEdit, m_config.tx_text_font()); setTextEditFont(ui->extFreeTextMsgEdit, m_config.compose_text_font());
}); });
connect (&m_config, &Configuration::colors_changed, [this](){ connect (&m_config, &Configuration::colors_changed, [this](){
setTextEditBackground(ui->textEditRX, m_config.color_rx_background()); setTextEditColors(ui->textEditRX, m_config.color_rx_foreground(), m_config.color_rx_background());
setTextEditBackground(ui->extFreeTextMsgEdit, m_config.color_tx_background()); setTextEditColors(ui->extFreeTextMsgEdit, m_config.color_compose_foreground(), m_config.color_compose_background());
// rehighlight // rehighlight
auto d = ui->textEditRX->document(); auto d = ui->textEditRX->document();
@ -1359,6 +1395,17 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
displayActivity(true); displayActivity(true);
/*
QTimer::singleShot(1000, this, [this](){
QPalette p;
p.setBrush(QPalette::Text, QColor(Qt::red));
p.setColor(QPalette::Text, QColor(Qt::red));
ui->extFreeTextMsgEdit->setPalette(p);
ui->extFreeTextMsgEdit->updateGeometry();
ui->extFreeTextMsgEdit->update();
});
*/
QTimer::singleShot(0, this, &MainWindow::initializeDummyData); QTimer::singleShot(0, this, &MainWindow::initializeDummyData);
// this must be the last statement of constructor // this must be the last statement of constructor
@ -1789,7 +1836,10 @@ void MainWindow::readSettings()
//ui->bandHorizontalWidget->setGeometry( m_settings->value("PanelWaterfallGeometry", ui->bandHorizontalWidget->geometry()).toRect()); //ui->bandHorizontalWidget->setGeometry( m_settings->value("PanelWaterfallGeometry", ui->bandHorizontalWidget->geometry()).toRect());
//qDebug() << m_settings->value("PanelTopGeometry") << ui->extFreeTextMsg; //qDebug() << m_settings->value("PanelTopGeometry") << ui->extFreeTextMsg;
ui->textEditRX->setStyleSheet(QString("QTextEdit { background: %1 }").arg(m_config.color_rx_background().name())); setTextEditColors(ui->textEditRX, m_config.color_rx_foreground(), m_config.color_rx_background());
setTextEditColors(ui->extFreeTextMsgEdit, m_config.color_compose_foreground(), m_config.color_compose_background());
{ {
auto const& coeffs = m_settings->value ("PhaseEqualizationCoefficients" auto const& coeffs = m_settings->value ("PhaseEqualizationCoefficients"
@ -6216,7 +6266,7 @@ void MainWindow::on_extFreeTextMsgEdit_currentTextChanged (QString const& text)
QTextCursor c = ui->extFreeTextMsgEdit->textCursor(); QTextCursor c = ui->extFreeTextMsgEdit->textCursor();
c.setPosition(pos < maxpos ? pos : maxpos, QTextCursor::MoveAnchor); c.setPosition(pos < maxpos ? pos : maxpos, QTextCursor::MoveAnchor);
highlightBlock(c.block(), m_config.tx_text_font(), QColor(Qt::black), QColor(Qt::transparent)); highlightBlock(c.block(), m_config.compose_text_font(), m_config.color_compose_foreground(), QColor(Qt::transparent));
ui->extFreeTextMsgEdit->setTextCursor(c); ui->extFreeTextMsgEdit->setTextCursor(c);
} }