diff --git a/Configuration.cpp b/Configuration.cpp index 7a9318cc9..e04f3c652 100644 --- a/Configuration.cpp +++ b/Configuration.cpp @@ -2358,7 +2358,8 @@ void Configuration::impl::update_audio_channels (QComboBox const * source_combo_ void Configuration::impl::set_application_font (QFont const& font) { - qApp->setStyleSheet (qApp->styleSheet () + font_as_stylesheet (font)); + qApp->setStyleSheet (qApp->styleSheet () + "* {" + font_as_stylesheet (font) + '}'); + qDebug () << "app style sheet:" << qApp->styleSheet (); } // load all the supported rig names into the selection combo box diff --git a/StationList.cpp b/StationList.cpp index 87689c2f6..94c09d650 100644 --- a/StationList.cpp +++ b/StationList.cpp @@ -430,7 +430,6 @@ bool StationList::impl::setData (QModelIndex const& model_index, QVariant const& case 2: stations_[row].antenna_description_ = value.toString (); - qDebug () << "stations edited:" << stations_; Q_EMIT dataChanged (model_index, model_index, roles); changed = true; break; diff --git a/astro.cpp b/astro.cpp index 65f47ba43..9fecf51ef 100644 --- a/astro.cpp +++ b/astro.cpp @@ -12,8 +12,10 @@ #include #include #include +#include #include "commons.h" +#include "qt_helpers.hpp" #include "ui_astro.h" @@ -27,8 +29,8 @@ Astro::Astro(QSettings * settings, QWidget * parent) ui_->setupUi(this); setWindowFlags (Qt::Dialog | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint); - setWindowTitle(QApplication::applicationName () + " - " + tr ("Astronomical Data")); + setStyleSheet ("QWidget {background: cyan;}"); read_settings (); @@ -56,7 +58,7 @@ void Astro::read_settings () QFont font; if (font.fromString (settings_->value ("font", ui_->text_label->font ().toString ()).toString ())) { - ui_->text_label->setFont (font); + ui_->text_label->setStyleSheet ("QLabel {" + font_as_stylesheet (font) + '}'); adjustSize (); } settings_->endGroup (); @@ -73,18 +75,22 @@ void Astro::write_settings () void Astro::on_font_push_button_clicked (bool /* checked */) { bool changed; - ui_->text_label->setFont (QFontDialog::getFont (&changed - , ui_->text_label->font () - , this - , tr ("WSJT-X Astro Text Font Chooser") + auto ss = styleSheet (); + setStyleSheet (""); + auto font = QFontDialog::getFont (&changed + , ui_->text_label->font () + , this + , tr ("WSJT-X Astro Text Font Chooser") #if QT_VERSION >= 0x050201 - , QFontDialog::MonospacedFonts + , QFontDialog::MonospacedFonts #endif - )); + ); if (changed) { + ui_->text_label->setStyleSheet ("QLabel {" + font_as_stylesheet (font) + '}'); adjustSize (); } + setStyleSheet (ss); } void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid, diff --git a/astro.ui b/astro.ui index c5c5907a9..7d8f7fa13 100644 --- a/astro.ui +++ b/astro.ui @@ -17,9 +17,7 @@ - QWidget { - background: cyan; -} + @@ -42,11 +40,10 @@ 0 - - - Courier - 18 - + + QLabel { +font: 18pt "Courier"; +} QFrame::Sunken diff --git a/displaytext.cpp b/displaytext.cpp index 003c09d78..695513955 100644 --- a/displaytext.cpp +++ b/displaytext.cpp @@ -1,5 +1,5 @@ #include "displaytext.h" -#include + #include #include #include @@ -15,16 +15,17 @@ DisplayText::DisplayText(QWidget *parent) : { setReadOnly (true); viewport ()->setCursor (Qt::ArrowCursor); + setWordWrapMode (QTextOption::NoWrap); + setStyleSheet (""); } void DisplayText::setContentFont(QFont const& font) { - document ()->setDefaultFont (font); - QTextCharFormat format; - format.setFont (font); + setFont (font); + m_charFormat.setFont (font); selectAll (); auto cursor = textCursor (); - cursor.mergeCharFormat (format); + cursor.mergeCharFormat (m_charFormat); cursor.clearSelection (); cursor.movePosition (QTextCursor::End); setTextCursor (cursor); @@ -49,10 +50,16 @@ void DisplayText::insertLineSpacer() void DisplayText::_insertText(const QString text, const QString bg) { QString s = "
" + text.trimmed () + "
"; - moveCursor (QTextCursor::End); - append (s); - moveCursor (QTextCursor::End); + bg + "\">" + text.trimmed ().replace (' ', " ") + ""; + auto cursor = textCursor (); + cursor.movePosition (QTextCursor::End); + auto pos = cursor.position (); + insertHtml (s); + cursor.setPosition (pos, QTextCursor::MoveAnchor); + cursor.movePosition (QTextCursor::End, QTextCursor::KeepAnchor); + cursor.mergeCharFormat (m_charFormat); + cursor.clearSelection (); + setTextCursor (cursor); ensureCursorVisible (); } diff --git a/displaytext.h b/displaytext.h index 584ec206b..0c481ab3d 100644 --- a/displaytext.h +++ b/displaytext.h @@ -35,6 +35,7 @@ private: void _appendDXCCWorkedB4(/*mod*/DecodedText& t1, QString &bg, LogBook logBook, QColor color_CQ, QColor color_DXCC, QColor color_NewCall); + QTextCharFormat m_charFormat; }; #endif // DISPLAYTEXT_H diff --git a/mainwindow.cpp b/mainwindow.cpp index ef7950148..f9dd1b6fc 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -598,7 +598,7 @@ void MainWindow::setDecodedTextFont (QFont const& font) { ui->decodedTextBrowser->setContentFont (font); ui->decodedTextBrowser2->setContentFont (font); - auto style_sheet = font_as_stylesheet (font); + auto style_sheet = "QLabel {" + font_as_stylesheet (font) + '}'; ui->decodedTextLabel->setStyleSheet (ui->decodedTextLabel->styleSheet () + style_sheet); ui->decodedTextLabel2->setStyleSheet (ui->decodedTextLabel2->styleSheet () + style_sheet); } diff --git a/qt_helpers.cpp b/qt_helpers.cpp index be3af50fd..2d530534b 100644 --- a/qt_helpers.cpp +++ b/qt_helpers.cpp @@ -14,11 +14,11 @@ QString font_as_stylesheet (QFont const& font) case QFont::Bold: font_weight = "bold"; break; case QFont::Black: font_weight = "black"; break; } - return QString {"* {\n" + return QString { " font-family: %1;\n" " font-size: %2pt;\n" " font-style: %3;\n" - " font-weight: %4;}\n"} + " font-weight: %4;\n"} .arg (font.family ()) .arg (font.pointSize ()) .arg (font.styleName ())