1 /**************************************************************************
2 *   Copyright (C) 2005-2020 by Oleksandr Shneyder                         *
3 *                              <o.shneyder@phoca-gmbh.de>                 *
4 *   Copyright (C) 2015-2020 by Mihai Moldovan <ionic@ionic.de>            *
5 *                                                                         *
6 *   This program is free software; you can redistribute it and/or modify  *
7 *   it under the terms of the GNU General Public License as published by  *
8 *   the Free Software Foundation; either version 2 of the License, or     *
9 *   (at your option) any later version.                                   *
10 *   This program is distributed in the hope that it will be useful,       *
11 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13 *   GNU General Public License for more details.                          *
14 *                                                                         *
15 *   You should have received a copy of the GNU General Public License     *
16 *   along with this program.  If not, see <https://www.gnu.org/licenses/>. *
17 ***************************************************************************/
18 
19 #include <QtGlobal>
20 #include "helpdialog.h"
21 #include "x2goutils.h"
22 
HelpDialog(QWidget * parent)23 HelpDialog::HelpDialog (QWidget *parent): QDialog (parent) {
24   setupUi (this);
25 }
26 
setText(QString text)27 void HelpDialog::setText (QString text) {
28   /* Try real hard to get a monospaced font. */
29   QFont font ("monospace");
30 
31   if (!font_is_monospaced (font)) {
32 #if QT_VERSION >= 0x040700
33     font.setStyleHint (QFont::Monospace);
34 #else
35     font.setStyleHint (QFont::TypeWriter);
36 #endif
37   }
38 
39   if (!font_is_monospaced (font)) {
40     font.setFamily ("Courier New");
41   }
42 
43   if (!font_is_monospaced (font)) {
44     font.setFamily ("Courier");
45   }
46 
47   /* If the font is not monospaced by now, there's not much else we can do... */
48   font.setPointSize (10);
49 
50   plainTextEdit->setFont (font);
51 
52   plainTextEdit->setTabStopWidth (30);
53   plainTextEdit->setWordWrapMode (QTextOption::NoWrap);
54   plainTextEdit->setPlainText (text);
55 }
56 
57