GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QTerminal.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2012-2013 Michael Goffioul.
4 Copyright (C) 2012-2013 Jacob Dawid.
5 
6 This file is part of QTerminal.
7 
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program. If not,
20 see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #include "QTerminal.h"
25 
26 #if defined (Q_OS_WIN32)
27 # include "win32/QWinTerminalImpl.h"
28 #else
29 # include "unix/QUnixTerminalImpl.h"
30 #endif
31 
32 QTerminal *
34 {
35 #if defined (Q_OS_WIN32)
36  return new QWinTerminalImpl (xparent);
37 #else
38  return new QUnixTerminalImpl (xparent);
39 #endif
40 }
41 
44 {
45  static QList<QColor> colors;
46 
47  if (colors.isEmpty ())
48  {
49  colors << QColor(0,0,0)
50  << QColor(255,255,255)
51  << QColor(192,192,192)
52  << QColor(128,128,128);
53  }
54 
55  return colors;
56 }
57 
58 QStringList
60 {
61  static QStringList names;
62 
63  if (names.isEmpty ())
64  {
65  names << QObject::tr ("foreground")
66  << QObject::tr ("background")
67  << QObject::tr ("selection")
68  << QObject::tr ("cursor");
69  }
70 
71  return names;
72 }
73 
74 void
75 QTerminal::notice_settings (const QSettings *settings)
76 {
77  // QSettings pointer is checked before emitting.
78 
79  // Set terminal font:
80  QFont term_font = QFont ();
81  term_font.setStyleHint (QFont::TypeWriter);
82  term_font.setFamily
83  (settings->value ("terminal/fontName", "Courier New").toString ());
84  term_font.setPointSize (settings->value ("terminal/fontSize", 10).toInt ());
85  setTerminalFont (term_font);
86 
87  QString cursorType
88  = settings->value ("terminal/cursorType", "ibeam").toString ();
89 
90  bool cursorBlinking
91  = settings->value ("terminal/cursorBlinking", true).toBool ();
92 
93  if (cursorType == "ibeam")
94  setCursorType (QTerminal::IBeamCursor, cursorBlinking);
95  else if (cursorType == "block")
96  setCursorType (QTerminal::BlockCursor, cursorBlinking);
97  else if (cursorType == "underline")
98  setCursorType (QTerminal::UnderlineCursor, cursorBlinking);
99 
100  bool cursorUseForegroundColor
101  = settings->value ("terminal/cursorUseForegroundColor", true).toBool ();
102 
103  QList<QColor> colors = default_colors ();
104 
106  (settings->value ("terminal/color_f",
107  QVariant (colors.at (0))).value<QColor> ());
108 
110  (settings->value ("terminal/color_b",
111  QVariant (colors.at (1))).value<QColor> ());
112 
114  (settings->value ("terminal/color_s",
115  QVariant (colors.at (2))).value<QColor> ());
116 
118  (cursorUseForegroundColor,
119  settings->value ("terminal/color_c",
120  QVariant (colors.at (3))).value<QColor> ());
121 }