Refactored help windows into a helpful class

Also  used it  to implement  the  prefixes, shortcuts  and mouse  help
windows.

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5554 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2015-06-08 16:05:01 +00:00
parent bfe8ba4d08
commit b63510ee2e
4 changed files with 85 additions and 114 deletions

View File

@ -63,6 +63,33 @@ namespace
}
}
class HelpTextWindow
: public QLabel
{
public:
HelpTextWindow (QString const& title, QString const& file_name, QFont const& = QFont {}, QWidget * parent = nullptr);
};
HelpTextWindow::HelpTextWindow (QString const& title, QString const& file_name, QFont const& font, QWidget * parent)
: QLabel {parent, Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint}
{
QFile source {file_name};
if (!source.open (QIODevice::ReadOnly | QIODevice::Text))
{
QMessageBox::warning (this, QApplication::applicationName ()
, "Cannot open \"" + source.fileName ()
+ "\" for reading:" + source.errorString ());
return;
}
setText (QTextStream {&source}.readAll ());
setWindowTitle(QApplication::applicationName () + " - " + title);
setTextFormat (Qt::PlainText);
setMargin (10);
setBackgroundRole (QPalette::Base);
setAutoFillBackground (true);
setStyleSheet (font_as_stylesheet (font));
}
//--------------------------------------------------- MainWindow constructor
MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdmem,
unsigned downSampleFactor, QWidget *parent) :
@ -1445,56 +1472,24 @@ void MainWindow::on_actionKeyboard_shortcuts_triggered()
{
if (!m_shortcuts)
{
QFile f(":/shortcuts.txt");
if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
msgBox("Cannot open \"" + f.fileName () + "\" for reading:"+f.errorString ());
return;
}
m_shortcuts.reset (new QTextEdit);
m_shortcuts->setReadOnly(true);
m_shortcuts->setFontPointSize(10);
m_shortcuts->setWindowTitle(QApplication::applicationName () + " - " + tr ("Keyboard Shortcuts"));
m_shortcuts->setGeometry(QRect(45,50,430,460));
Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
Qt::WindowMinimizeButtonHint;
m_shortcuts->setWindowFlags(flags);
QTextStream s(&f);
QString t;
for(int i=0; i<100; i++) {
t=s.readLine();
m_shortcuts->append(t);
if(s.atEnd()) break;
}
QFont font;
font.setPointSize (10);
m_shortcuts.reset (new HelpTextWindow {tr ("Keyboard Shortcuts")
, ":/shortcuts.txt", font});
}
m_shortcuts->showNormal();
m_shortcuts->showNormal ();
}
void MainWindow::on_actionSpecial_mouse_commands_triggered()
{
if (!m_mouseCmnds)
{
QFile f(":/mouse_commands.txt");
if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
msgBox("Cannot open \"" + f.fileName () + "\" for reading:" + f.errorString ());
return;
}
m_mouseCmnds.reset (new QTextEdit);
m_mouseCmnds->setReadOnly(true);
m_mouseCmnds->setFontPointSize(10);
m_mouseCmnds->setWindowTitle(QApplication::applicationName () + " - " + tr ("Special Mouse Commands"));
m_mouseCmnds->setGeometry(QRect(45,50,440,300));
Qt::WindowFlags flags = Qt::WindowCloseButtonHint |
Qt::WindowMinimizeButtonHint;
m_mouseCmnds->setWindowFlags(flags);
QTextStream s(&f);
QString t;
for(int i=0; i<100; i++) {
t=s.readLine();
m_mouseCmnds->append(t);
if(s.atEnd()) break;
}
QFont font;
font.setPointSize (10);
m_mouseCmnds.reset (new HelpTextWindow {tr ("Special Mouse Commands")
, ":/mouse_commands.txt", font});
}
m_mouseCmnds->showNormal();
m_mouseCmnds->showNormal ();
}
void MainWindow::on_DecodeButton_clicked (bool /* checked */) //Decode request
@ -3770,30 +3765,7 @@ void MainWindow::on_actionShort_list_of_add_on_prefixes_and_suffixes_triggered()
{
if (!m_prefixes)
{
QFile f(":/prefixes.txt");
if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) {
msgBox("Cannot open \"" + f.fileName () + "\" for reading:" + f.errorString ());
return;
}
m_prefixes.reset (new QLabel {
QTextStream {&f}.readAll ()
, nullptr
, Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint
});
m_prefixes->setWindowTitle(QApplication::applicationName () +
" - " + tr ("Prefixes"));
m_prefixes->setTextFormat (Qt::PlainText);
m_prefixes->setMargin (10);
m_prefixes->setBackgroundRole (QPalette::Base);
m_prefixes->setAutoFillBackground (true);
// Formatting in columns thanks to Sandro, IW3RAB:
QFont font;
font.setFamily("Courier");
font.setStyleHint(QFont::Monospace);
font.setFixedPitch(true);
font.setPointSize(10); //as for decoded text
m_prefixes->setStyleSheet (font_as_stylesheet (font));
m_prefixes.reset (new HelpTextWindow {tr ("Prefixes"), ":/prefixes.txt", {"Courier", 10}});
}
m_prefixes->showNormal();
}

View File

@ -63,6 +63,7 @@ class MessageAveraging;
class MessageClient;
class QTime;
class WSPRBandHopping;
class HelpTextWindow;
class MainWindow : public QMainWindow
{
@ -274,9 +275,9 @@ private:
QScopedPointer<EchoGraph> m_echoGraph;
QScopedPointer<LogQSO> m_logDlg;
QScopedPointer<Astro> m_astroWidget;
QScopedPointer<QTextEdit> m_shortcuts;
QScopedPointer<QLabel> m_prefixes;
QScopedPointer<QTextEdit> m_mouseCmnds;
QScopedPointer<HelpTextWindow> m_shortcuts;
QScopedPointer<HelpTextWindow> m_prefixes;
QScopedPointer<HelpTextWindow> m_mouseCmnds;
QScopedPointer<MessageAveraging> m_msgAvgWidget;
Frequency m_dialFreq;

View File

@ -1,17 +1,15 @@
Click on Action
__________________________________________________________
Waterfall: Set Rx frequency
Double-click to set Rx frequency and decode there
Ctrl-click to set Rx and Tx frequencies and decode
Decoded text: Double-click to copy second callsign to Dx Call,
locator to Dx Grid; change Rx and Tx frequencies to
decoded signal's frequency; generate standard messages.
If first callsign is your own, Tx frequency is not
changed unless Ctrl is held down when double-clicking.
Erase button: Click to erase QSO window
Double-click to erase QSO and Band Activity windows
Click on Action
_______________________________________________________________
Waterfall: Set Rx frequency.
Double-click to set Rx frequency and decode there.
Ctrl-click to set Rx and Tx frequencies and decode.
Decoded text: Double-click to copy second callsign to Dx Call,
locator to Dx Grid; change Rx and Tx frequencies to
decoded signal's frequency; generate standard messages.
If first callsign is your own, Tx frequency is not
changed unless Ctrl is held down when double-clicking.
Erase button: Click to erase QSO window.
Double-click to erase QSO and Band Activity windows.

View File

@ -1,28 +1,28 @@
F1 Online User's Guide
Ctrl+F1 About WSJT-X
F2 Open configuration window
F3 Display keyboard shortcuts
F4 Clear DX Call, DX Grid, Tx messages 1-5
Alt+F4 Exit program
F5 Display special mouse commands
F6 Open next file in directory
Shift+F6 Decode all remaining files in directrory
F11 Move Rx frequency down 1 Hz
Ctrl+F11 Move Rx and Tx frequencies down 1 Hz
F12 Move Rx frequency up 1 Hz
Ctrl+F12 Move Rx and Tx frequencies up 1 Hz
Alt+1-6 Set now transmission to this number on Tab 1
Ctl+1-6 Set next transmission to this number on Tab 1
Alt+D Decode again at QSO frequency
Shift+D Full decode (both windows)
Alt+E Erase
Ctrl+F Edit the free text message box
Alt+G Generate standard messages
Alt+H Halt Tx
Ctrl+L Lookup callsign in database, generate standard messages
Alt+M Monitor
Alt+N Enable Tx
Alt+Q Log QSO
Alt+S Stop monitoring
Alt+T Tune
Alt+V Save the most recently completed *.wav file
F1 Online User's Guide
Ctrl+F1 About WSJT-X
F2 Open configuration window
F3 Display keyboard shortcuts
F4 Clear DX Call, DX Grid, Tx messages 1-5
Alt+F4 Exit program
F5 Display special mouse commands
F6 Open next file in directory
Shift+F6 Decode all remaining files in directrory
F11 Move Rx frequency down 1 Hz
Ctrl+F11 Move Rx and Tx frequencies down 1 Hz
F12 Move Rx frequency up 1 Hz
Ctrl+F12 Move Rx and Tx frequencies up 1 Hz
Alt+1-6 Set now transmission to this number on Tab 1
Ctl+1-6 Set next transmission to this number on Tab 1
Alt+D Decode again at QSO frequency
Shift+D Full decode (both windows)
Alt+E Erase
Ctrl+F Edit the free text message box
Alt+G Generate standard messages
Alt+H Halt Tx
Ctrl+L Lookup callsign in database, generate standard messages
Alt+M Monitor
Alt+N Enable Tx
Alt+Q Log QSO
Alt+S Stop monitoring
Alt+T Tune
Alt+V Save the most recently completed *.wav file