mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-30 08:08:39 -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
3781bdb57a
commit
d80576b1cd
@ -2358,7 +2358,8 @@ void Configuration::impl::update_audio_channels (QComboBox const * source_combo_
|
|||||||
|
|
||||||
void Configuration::impl::set_application_font (QFont const& font)
|
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
|
// 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:
|
case 2:
|
||||||
stations_[row].antenna_description_ = value.toString ();
|
stations_[row].antenna_description_ = value.toString ();
|
||||||
qDebug () << "stations edited:" << stations_;
|
|
||||||
Q_EMIT dataChanged (model_index, model_index, roles);
|
Q_EMIT dataChanged (model_index, model_index, roles);
|
||||||
changed = true;
|
changed = true;
|
||||||
break;
|
break;
|
||||||
|
22
astro.cpp
22
astro.cpp
@ -12,8 +12,10 @@
|
|||||||
#include <QFontDialog>
|
#include <QFontDialog>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "commons.h"
|
#include "commons.h"
|
||||||
|
#include "qt_helpers.hpp"
|
||||||
|
|
||||||
#include "ui_astro.h"
|
#include "ui_astro.h"
|
||||||
|
|
||||||
@ -27,8 +29,8 @@ Astro::Astro(QSettings * settings, QWidget * parent)
|
|||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
|
|
||||||
setWindowFlags (Qt::Dialog | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
|
setWindowFlags (Qt::Dialog | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
|
||||||
|
|
||||||
setWindowTitle(QApplication::applicationName () + " - " + tr ("Astronomical Data"));
|
setWindowTitle(QApplication::applicationName () + " - " + tr ("Astronomical Data"));
|
||||||
|
setStyleSheet ("QWidget {background: cyan;}");
|
||||||
|
|
||||||
read_settings ();
|
read_settings ();
|
||||||
|
|
||||||
@ -56,7 +58,7 @@ void Astro::read_settings ()
|
|||||||
QFont font;
|
QFont font;
|
||||||
if (font.fromString (settings_->value ("font", ui_->text_label->font ().toString ()).toString ()))
|
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 ();
|
adjustSize ();
|
||||||
}
|
}
|
||||||
settings_->endGroup ();
|
settings_->endGroup ();
|
||||||
@ -73,18 +75,22 @@ void Astro::write_settings ()
|
|||||||
void Astro::on_font_push_button_clicked (bool /* checked */)
|
void Astro::on_font_push_button_clicked (bool /* checked */)
|
||||||
{
|
{
|
||||||
bool changed;
|
bool changed;
|
||||||
ui_->text_label->setFont (QFontDialog::getFont (&changed
|
auto ss = styleSheet ();
|
||||||
, ui_->text_label->font ()
|
setStyleSheet ("");
|
||||||
, this
|
auto font = QFontDialog::getFont (&changed
|
||||||
, tr ("WSJT-X Astro Text Font Chooser")
|
, ui_->text_label->font ()
|
||||||
|
, this
|
||||||
|
, tr ("WSJT-X Astro Text Font Chooser")
|
||||||
#if QT_VERSION >= 0x050201
|
#if QT_VERSION >= 0x050201
|
||||||
, QFontDialog::MonospacedFonts
|
, QFontDialog::MonospacedFonts
|
||||||
#endif
|
#endif
|
||||||
));
|
);
|
||||||
if (changed)
|
if (changed)
|
||||||
{
|
{
|
||||||
|
ui_->text_label->setStyleSheet ("QLabel {" + font_as_stylesheet (font) + '}');
|
||||||
adjustSize ();
|
adjustSize ();
|
||||||
}
|
}
|
||||||
|
setStyleSheet (ss);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid,
|
void Astro::astroUpdate(QDateTime t, QString mygrid, QString hisgrid,
|
||||||
|
13
astro.ui
13
astro.ui
@ -17,9 +17,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">QWidget {
|
<string notr="true"/>
|
||||||
background: cyan;
|
|
||||||
}</string>
|
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
@ -42,11 +40,10 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="styleSheet">
|
||||||
<font>
|
<string notr="true">QLabel {
|
||||||
<family>Courier</family>
|
font: 18pt "Courier";
|
||||||
<pointsize>18</pointsize>
|
}</string>
|
||||||
</font>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Sunken</enum>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "displaytext.h"
|
#include "displaytext.h"
|
||||||
#include <QDebug>
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QTextCharFormat>
|
#include <QTextCharFormat>
|
||||||
@ -15,16 +15,17 @@ DisplayText::DisplayText(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
setReadOnly (true);
|
setReadOnly (true);
|
||||||
viewport ()->setCursor (Qt::ArrowCursor);
|
viewport ()->setCursor (Qt::ArrowCursor);
|
||||||
|
setWordWrapMode (QTextOption::NoWrap);
|
||||||
|
setStyleSheet ("");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayText::setContentFont(QFont const& font)
|
void DisplayText::setContentFont(QFont const& font)
|
||||||
{
|
{
|
||||||
document ()->setDefaultFont (font);
|
setFont (font);
|
||||||
QTextCharFormat format;
|
m_charFormat.setFont (font);
|
||||||
format.setFont (font);
|
|
||||||
selectAll ();
|
selectAll ();
|
||||||
auto cursor = textCursor ();
|
auto cursor = textCursor ();
|
||||||
cursor.mergeCharFormat (format);
|
cursor.mergeCharFormat (m_charFormat);
|
||||||
cursor.clearSelection ();
|
cursor.clearSelection ();
|
||||||
cursor.movePosition (QTextCursor::End);
|
cursor.movePosition (QTextCursor::End);
|
||||||
setTextCursor (cursor);
|
setTextCursor (cursor);
|
||||||
@ -49,10 +50,16 @@ void DisplayText::insertLineSpacer()
|
|||||||
void DisplayText::_insertText(const QString text, const QString bg)
|
void DisplayText::_insertText(const QString text, const QString bg)
|
||||||
{
|
{
|
||||||
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
|
||||||
bg + "\"><pre>" + text.trimmed () + "</pre></td></tr></table>";
|
bg + "\">" + text.trimmed ().replace (' ', " ") + "</td></tr></table>";
|
||||||
moveCursor (QTextCursor::End);
|
auto cursor = textCursor ();
|
||||||
append (s);
|
cursor.movePosition (QTextCursor::End);
|
||||||
moveCursor (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 ();
|
ensureCursorVisible ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ private:
|
|||||||
void _appendDXCCWorkedB4(/*mod*/DecodedText& t1, QString &bg, LogBook logBook,
|
void _appendDXCCWorkedB4(/*mod*/DecodedText& t1, QString &bg, LogBook logBook,
|
||||||
QColor color_CQ, QColor color_DXCC, QColor color_NewCall);
|
QColor color_CQ, QColor color_DXCC, QColor color_NewCall);
|
||||||
|
|
||||||
|
QTextCharFormat m_charFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DISPLAYTEXT_H
|
#endif // DISPLAYTEXT_H
|
||||||
|
@ -598,7 +598,7 @@ void MainWindow::setDecodedTextFont (QFont const& font)
|
|||||||
{
|
{
|
||||||
ui->decodedTextBrowser->setContentFont (font);
|
ui->decodedTextBrowser->setContentFont (font);
|
||||||
ui->decodedTextBrowser2->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->decodedTextLabel->setStyleSheet (ui->decodedTextLabel->styleSheet () + style_sheet);
|
||||||
ui->decodedTextLabel2->setStyleSheet (ui->decodedTextLabel2->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::Bold: font_weight = "bold"; break;
|
||||||
case QFont::Black: font_weight = "black"; break;
|
case QFont::Black: font_weight = "black"; break;
|
||||||
}
|
}
|
||||||
return QString {"* {\n"
|
return QString {
|
||||||
" font-family: %1;\n"
|
" font-family: %1;\n"
|
||||||
" font-size: %2pt;\n"
|
" font-size: %2pt;\n"
|
||||||
" font-style: %3;\n"
|
" font-style: %3;\n"
|
||||||
" font-weight: %4;}\n"}
|
" font-weight: %4;\n"}
|
||||||
.arg (font.family ())
|
.arg (font.family ())
|
||||||
.arg (font.pointSize ())
|
.arg (font.pointSize ())
|
||||||
.arg (font.styleName ())
|
.arg (font.styleName ())
|
||||||
|
Loading…
Reference in New Issue
Block a user