Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
446 andreas 1
/*
2
 * Copyright (C) 2023 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#include <QWidget>
20
#include <QKeyEvent>
21
 
22
#include "tqsingleline.h"
23
#include "terror.h"
24
 
25
using std::string;
26
 
27
TQSingleLine::TQSingleLine(QWidget *parent)
28
    : QLineEdit(parent)
29
{
30
    DECL_TRACER("TQSingleLine::TQSingleLine(QWidget *parent)");
31
 
32
    QPalette pal(palette());
33
    pal.setColor(QPalette::Window, Qt::transparent);
34
    pal.setColor(QPalette::Base, Qt::transparent);
35
    pal.setColor(QPalette::WindowText, Qt::black);
36
    pal.setColor(QPalette::Text, Qt::black);
37
    setPalette(pal);
38
    setFrame(false);
39
}
40
 
41
TQSingleLine::TQSingleLine(QWidget *parent, const string& text)
42
    : QLineEdit(QString::fromStdString(text), parent)
43
{
44
    DECL_TRACER("TQSingleLine::TQSingleLine(QWidget *parent, const string& text)");
45
 
46
    QPalette pal(palette());
47
    pal.setColor(QPalette::Window, Qt::transparent);
48
    pal.setColor(QPalette::Base, Qt::transparent);
49
    pal.setColor(QPalette::WindowText, Qt::black);
50
    pal.setColor(QPalette::Text, Qt::black);
51
    setPalette(pal);
52
    setFrame(false);
53
}
54
 
55
/*******************************************************************************
56
 * Signal handling
57
 ******************************************************************************/
58
 
59
void TQSingleLine::keyPressEvent(QKeyEvent *e)
60
{
61
    DECL_TRACER("TQSingleLine::keyPressEvent(QKeyEvent *e)");
62
 
63
    QLineEdit::keyPressEvent(e);
64
    emit keyPressed(e->key());
65
}
66
 
67
void TQSingleLine::focusInEvent(QFocusEvent *e)
68
{
69
    DECL_TRACER("TQSingleLine::focusInEvent(QFocusEvent *e)");
70
 
71
    QLineEdit::focusInEvent(e);
72
    emit focusChanged(true);
73
}
74
 
75
void TQSingleLine::focusOutEvent(QFocusEvent *e)
76
{
77
    DECL_TRACER("TQSingleLine::focusOutEvent(QFocusEvent *e)");
78
 
79
    QLineEdit::focusOutEvent(e);
80
    emit focusChanged(false);
81
}