1 /* syntax_line_edit.cpp
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <epan/prefs.h>
30 #include "syntax_line_edit.h"
32 #include "color_utils.h"
35 SyntaxLineEdit::SyntaxLineEdit(QWidget
*parent
) :
41 void SyntaxLineEdit::setSyntaxState(SyntaxState state
) {
42 syntax_state_
= state
;
43 state_style_sheet_
= QString(
44 "SyntaxLineEdit[syntaxState=\"%1\"] {"
46 " background-color: %5;"
49 "SyntaxLineEdit[syntaxState=\"%2\"] {"
51 " background-color: %6;"
54 "SyntaxLineEdit[syntaxState=\"%3\"] {"
56 " background-color: %7;"
62 .arg("palette(text)") // Foreground
63 .arg(ColorUtils::fromColorT(&prefs
.gui_text_valid
).name()) // Invalid
64 .arg(ColorUtils::fromColorT(&prefs
.gui_text_invalid
).name()) // Deprecated
65 .arg(ColorUtils::fromColorT(&prefs
.gui_text_deprecated
).name()) // Valid
67 setStyleSheet(style_sheet_
);
70 QString
SyntaxLineEdit::styleSheet() const {
74 void SyntaxLineEdit::setStyleSheet(const QString
&style_sheet
) {
75 style_sheet_
= style_sheet
;
76 QLineEdit::setStyleSheet(style_sheet_
+ state_style_sheet_
);