Bring colour settings into line with general configuration strategy

Colours behave  like other  configuration items  and changes  are only
applied when the Settings UI is dismissed via the "OK" button.

Simplified font settings and use  style sheets consistently to set the
application and decoded  text fonts. This is necessary  because any UI
widget that  has a style  sheet applied does not  honor a font  set by
QWidget::setFont()  even if  there is  no  font setting  in the  style
sheet, this is broken behaviour IMHO  but that is the way Qt currently
works.

Use a  style sheet to style  the frequency display and  clock. This is
necessary to  allow fonts to  be cascaded through parent  style sheets
and still be overridden on these widgets.

Simplify  the decoded  text  widgets,  there is  no  need  to use  the
QTextBrowser  as a  super class  since  the simpler  QTextEdit set  as
read-only is sufficient. Also removed  colour setting via a background
brush  as it  doesn't  work  and the  HTML  'bgcolor' attribute  works
correctly.

Change  to  UI  properties  of  the  decoded  text  widgets  to  allow
horizontal scrolling if required, this  allows larger fonts to be used
without truncating decoded messages.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@4957 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville
2015-02-13 08:53:02 +00:00
parent a7b3951df5
commit 3327625346
9 changed files with 238 additions and 218 deletions
+11 -31
View File
@@ -3,13 +3,15 @@
#include <QMouseEvent>
#include <QDateTime>
#include "qt_helpers.hpp"
#include "moc_displaytext.cpp"
DisplayText::DisplayText(QWidget *parent) :
QTextBrowser(parent)
QTextEdit(parent)
{
_fontWidth = 8; // typical
_maxDisplayedCharacters = 48; // a nominal safe(?) value
setReadOnly (true);
setCursorWidth (0);
}
void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
@@ -17,26 +19,9 @@ void DisplayText::mouseDoubleClickEvent(QMouseEvent *e)
bool ctrl = (e->modifiers() & Qt::ControlModifier);
bool shift = (e->modifiers() & Qt::ShiftModifier);
emit(selectCallsign(shift,ctrl));
QTextBrowser::mouseDoubleClickEvent(e);
QTextEdit::mouseDoubleClickEvent(e);
}
void DisplayText::setFont(QFont const& font)
{
QFontMetrics qfm(font);
_fontWidth = qfm.averageCharWidth()+1; // the plus one is emperical
QTextBrowser::setFont(font);
}
void DisplayText::resizeEvent(QResizeEvent * event)
{
if (_fontWidth > 0 && _fontWidth < 999)
_maxDisplayedCharacters = width()/_fontWidth;
QTextBrowser::resizeEvent(event);
}
void DisplayText::insertLineSpacer()
{
QString tt="----------------------------------------";
@@ -46,16 +31,11 @@ void DisplayText::insertLineSpacer()
void DisplayText::_insertText(const QString text, const QString bg)
{
QString tt = text.mid(0,_maxDisplayedCharacters); //truncate to max display chars
QString s = "<table border=0 cellspacing=0 width=100%><tr><td bgcolor=\"" +
bg + "\"><pre>" + tt + "</pre></td></tr></table>";
QTextCursor cursor = textCursor();
cursor.movePosition(QTextCursor::End);
QTextBlockFormat bf = cursor.blockFormat();
bf.setBackground(QBrush(QColor(bg)));
cursor.insertHtml(s);
this->setTextCursor(cursor);
bg + "\"><pre>" + text.trimmed () + "</pre></td></tr></table>";
moveCursor (QTextCursor::End);
append (s);
moveCursor (QTextCursor::End);
}
@@ -74,7 +54,7 @@ void DisplayText::_appendDXCCWorkedB4(DecodedText& t1, QString& bg,
bool countryWorkedBefore;
logBook.match(/*in*/call,/*out*/countryName,callWorkedBefore,countryWorkedBefore);
int charsAvail = _maxDisplayedCharacters;
int charsAvail = 48;
// the decoder (seems) to always generate 40 chars. For a normal CQ call, the last five are spaces
// TODO this magic 36 characters is also referenced in MainWindow::doubleClickOnCall()