HACK: 1. try to match RowsetProperties
[wireshark-wip.git] / ui / qt / syntax_line_edit.cpp
blob40a8621fc1e62ce501f049b1dce071f6499ea260
1 /* syntax_line_edit.cpp
3 * $Id$
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.
24 #include "config.h"
26 #include <glib.h>
28 #include <epan/prefs.h>
30 #include "syntax_line_edit.h"
32 #include "color_utils.h"
33 #include <QDebug>
35 SyntaxLineEdit::SyntaxLineEdit(QWidget *parent) :
36 QLineEdit(parent)
38 setSyntaxState();
41 void SyntaxLineEdit::setSyntaxState(SyntaxState state) {
42 syntax_state_ = state;
43 state_style_sheet_ = QString(
44 "SyntaxLineEdit[syntaxState=\"%1\"] {"
45 " color: %4;"
46 " background-color: %5;"
47 "}"
49 "SyntaxLineEdit[syntaxState=\"%2\"] {"
50 " color: %4;"
51 " background-color: %6;"
52 "}"
54 "SyntaxLineEdit[syntaxState=\"%3\"] {"
55 " color: %4;"
56 " background-color: %7;"
57 "}"
59 .arg(Valid)
60 .arg(Invalid)
61 .arg(Deprecated)
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 {
71 return style_sheet_;
74 void SyntaxLineEdit::setStyleSheet(const QString &style_sheet) {
75 style_sheet_ = style_sheet;
76 QLineEdit::setStyleSheet(style_sheet_ + state_style_sheet_);