Mercurial > hg > octave-nkf
annotate libgui/qterminal/libqterminal/QTerminal.cc @ 16641:64f9a3e301d3
don't store default values in resource manager class
* QTerminal.h, QTerminal.cc (QTerminal::default_colors,
QTerminal::color_names): New functions.
(QTerminal::notice_settings): Call default_colors.
* workspace-model.h, workspace-model.cc
(workspace_model::storage_class_default_colors,
workspace_model::storage_class_names): New functions.
* resource-manager.cc (resource_manager::storage_class_names,
resource_manager::storage_class_default_colors): Get values from
workspace_model.
(resource_manager::terminal_color_names,
resource_manager::terminal_default_colors): Get values from QTerminal.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 12 May 2013 16:17:48 -0400 |
parents | 0ee7b4d1b940 |
children | a28c3fb15ad8 |
rev | line source |
---|---|
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
1 /* |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
2 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
3 Copyright (C) 2012 Michael Goffioul. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
4 Copyright (C) 2012 Jacob Dawid. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
5 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
6 This file is part of QTerminal. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
7 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
8 Foobar is free software: you can redistribute it and/or modify |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
9 it under the terms of the GNU General Public License as published by |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
10 the Free Software Foundation, either version 3 of the License, or |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
11 (at your option) any later version. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
12 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
13 QTerminal is distributed in the hope that it will be useful, |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
16 GNU General Public License for more details. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
17 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
18 You should have received a copy of the GNU General Public License |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
19 along with Foobar. If not, see <http://www.gnu.org/licenses/>. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
20 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
21 */ |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
22 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
23 #include "QTerminal.h" |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
24 |
16639
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
25 #if defined (Q_OS_WIN32) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
26 # include "win32/QWinTerminalImpl.h" |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
27 #else |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
28 # include "unix/QUnixTerminalImpl.h" |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
29 #endif |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
30 |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
31 QTerminal * |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
32 QTerminal::create (QWidget *xparent) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
33 { |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
34 #if defined (Q_OS_WIN32) |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
35 return new QWinTerminalImpl (xparent); |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
36 #else |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
37 return new QUnixTerminalImpl (xparent); |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
38 #endif |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
39 } |
ba808cd9d86c
simplify QTerminal inheritance scheme
John W. Eaton <jwe@octave.org>
parents:
16620
diff
changeset
|
40 |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
41 QList<QColor> |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
42 QTerminal::default_colors (void) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
43 { |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
44 static QList<QColor> colors; |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
45 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
46 if (colors.isEmpty ()) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
47 { |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
48 colors << QColor(0,0,0) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
49 << QColor(255,255,255) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
50 << QColor(192,192,192) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
51 << QColor(128,128,128); |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
52 } |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
53 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
54 return colors; |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
55 } |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
56 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
57 QStringList |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
58 QTerminal::color_names (void) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
59 { |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
60 static QStringList names; |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
61 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
62 if (names.isEmpty ()) |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
63 { |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
64 names << QObject::tr ("foreground") |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
65 << QObject::tr ("background") |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
66 << QObject::tr ("selection") |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
67 << QObject::tr ("cursor"); |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
68 } |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
69 |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
70 return names; |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
71 } |
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
72 |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
73 void |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
74 QTerminal::notice_settings (const QSettings *settings) |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
75 { |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
76 // QSettings pointer is checked before emitting. |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
77 |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
78 // Set terminal font: |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
79 QFont term_font = QFont (); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
80 term_font.setFamily |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
81 (settings->value ("terminal/fontName", "Courier New").toString ()); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
82 |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
83 term_font.setPointSize (settings->value ("terminal/fontSize", 10).toInt ()); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
84 |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
85 setTerminalFont (term_font); |
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
86 |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
87 QString cursorType |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
88 = settings->value ("terminal/cursorType", "ibeam").toString (); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
89 |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
90 bool cursorBlinking |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
91 = settings->value ("terminal/cursorBlinking", true).toBool (); |
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
92 |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
93 if (cursorType == "ibeam") |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
94 setCursorType (QTerminal::IBeamCursor, cursorBlinking); |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
95 else if (cursorType == "block") |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
96 setCursorType (QTerminal::BlockCursor, cursorBlinking); |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
97 else if (cursorType == "underline") |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
98 setCursorType (QTerminal::UnderlineCursor, cursorBlinking); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
99 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
100 bool cursorUseForegroundColor |
16640
0ee7b4d1b940
* QTerminal.cc: Style fixes.
John W. Eaton <jwe@octave.org>
parents:
16639
diff
changeset
|
101 = settings->value ("terminal/cursorUseForegroundColor", true).toBool (); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
102 |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
103 QList<QColor> colors = default_colors (); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
104 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
105 setForegroundColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
106 (settings->value ("terminal/color_f", |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
107 QVariant (colors.at (0))).value<QColor> ()); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
108 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
109 setBackgroundColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
110 (settings->value ("terminal/color_b", |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
111 QVariant (colors.at (1))).value<QColor> ()); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
112 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
113 setSelectionColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
114 (settings->value ("terminal/color_s", |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
115 QVariant (colors.at (2))).value<QColor> ()); |
16620
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
116 |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
117 setCursorColor |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
118 (cursorUseForegroundColor, |
818eef7b2618
allow terminal colors to be set from preferences dialog
John W. Eaton <jwe@octave.org>
parents:
16570
diff
changeset
|
119 settings->value ("terminal/color_c", |
16641
64f9a3e301d3
don't store default values in resource manager class
John W. Eaton <jwe@octave.org>
parents:
16640
diff
changeset
|
120 QVariant (colors.at (3))).value<QColor> ()); |
16413
28136851099a
remove _terminal pointer from main_window, it is contained by other Qt object
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff
changeset
|
121 } |