mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 04:11:16 -05:00
Fix font setting
Several issues mainly related to the rather complex interaction of style sheets and widget properties with respect to fonts. Font setting on the astro window should now be consistent and not overridden by application style sheet driven font settings. Decoded text font setting should now be consistent and not revert back to Courier 10 on the next decode after a font change. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5179 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
177aaef501
commit
ed2f4ee226
@ -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
|
||||
|
@ -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;
|
||||
|
22
astro.cpp
22
astro.cpp
@ -12,8 +12,10 @@
|
||||
#include <QFontDialog>
|
||||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
|
||||
#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,
|
||||
|
13
astro.ui
13
astro.ui
@ -17,9 +17,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget {
|
||||
background: cyan;
|
||||
}</string>
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
@ -42,11 +40,10 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier</family>
|
||||
<pointsize>18</pointsize>
|
||||
</font>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel {
|
||||
font: 18pt "Courier";
|
||||
}</string>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "displaytext.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QDateTime>
|
||||
#include <QTextCharFormat>
|
||||
@ -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 = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
||||
bg + "\"><pre>" + text.trimmed () + "</pre></td></tr></table>";
|
||||
moveCursor (QTextCursor::End);
|
||||
append (s);
|
||||
moveCursor (QTextCursor::End);
|
||||
bg + "\">" + text.trimmed ().replace (' ', " ") + "</td></tr></table>";
|
||||
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 ();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 ())
|
||||
|
Loading…
Reference in New Issue
Block a user