mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
81 lines
1.6 KiB
C++
81 lines
1.6 KiB
C++
/* vi: set sw=4 ts=4:
|
|
*
|
|
* Copyright (C) 2001 - 2007 Christian Hohnstaedt.
|
|
*
|
|
* All rights reserved.
|
|
*/
|
|
|
|
#include "clicklabel.h"
|
|
|
|
#include <QToolTip>
|
|
#include <QPalette>
|
|
#include <QColor>
|
|
|
|
void DoubleClickLabel::mouseDoubleClickEvent(QMouseEvent * e)
|
|
{
|
|
QWidget::mouseDoubleClickEvent(e);
|
|
if (clicktext.isEmpty())
|
|
emit doubleClicked(text());
|
|
else
|
|
emit doubleClicked(clicktext);
|
|
}
|
|
|
|
void DoubleClickLabel::setClickText(QString s)
|
|
{
|
|
clicktext = s;
|
|
}
|
|
|
|
ClickLabel::ClickLabel(QWidget *parent)
|
|
:DoubleClickLabel(parent)
|
|
{
|
|
QFont fnt( font() );
|
|
fnt.setBold(true);
|
|
setFont( fnt );
|
|
setFrameShape( QLabel::Panel );
|
|
setFrameShadow( QLabel::Sunken );
|
|
setAlignment( Qt::AlignCenter );
|
|
setToolTip( tr("Double click for details") );
|
|
|
|
setAutoFillBackground(true);
|
|
QPalette pal = palette();
|
|
QColor col = QColor(0xff, 0xff, 0xff);
|
|
pal.setColor(QPalette::Normal, QPalette::Window, col );
|
|
pal.setColor(QPalette::Inactive, QPalette::Window, col );
|
|
setPalette( pal );
|
|
setTextFormat(Qt::PlainText);
|
|
}
|
|
|
|
void ClickLabel::setColor(const QColor &col)
|
|
{
|
|
QPalette pal = palette();
|
|
pal.setColor(QPalette::Normal, QPalette::WindowText, col );
|
|
pal.setColor(QPalette::Inactive, QPalette::WindowText, col );
|
|
setPalette( pal );
|
|
}
|
|
|
|
void ClickLabel::setRed()
|
|
{
|
|
setColor( QColor( 192, 32, 32) );
|
|
}
|
|
|
|
void ClickLabel::setGreen()
|
|
{
|
|
setColor( QColor( 32, 192, 32) );
|
|
}
|
|
|
|
void ClickLabel::disableToolTip()
|
|
{
|
|
setToolTip(QString());
|
|
}
|
|
|
|
CopyLabel::CopyLabel(QWidget *parent)
|
|
:DoubleClickLabel(parent)
|
|
{
|
|
setFrameStyle(QFrame::StyledPanel);
|
|
setTextFormat(Qt::PlainText);
|
|
setTextInteractionFlags(
|
|
Qt::TextSelectableByMouse |
|
|
Qt::TextSelectableByKeyboard
|
|
);
|
|
}
|