* Cosmetic change. Replace Qt keyword emit with Q_EMIT.
* Whitespace fixes.
This commit is contained in:
@@ -9,193 +9,193 @@
|
||||
#include "iistaskpanelscheme.h"
|
||||
|
||||
iisIconLabel::iisIconLabel(const QIcon &icon, const QString &title, QWidget *parent)
|
||||
: QWidget(parent),
|
||||
myPixmap(icon),
|
||||
myText(title),
|
||||
mySchemePointer(0),
|
||||
m_over(false),
|
||||
m_pressed(false),
|
||||
m_changeCursorOver(true),
|
||||
m_underlineOver(true)
|
||||
: QWidget(parent),
|
||||
myPixmap(icon),
|
||||
myText(title),
|
||||
mySchemePointer(0),
|
||||
m_over(false),
|
||||
m_pressed(false),
|
||||
m_changeCursorOver(true),
|
||||
m_underlineOver(true)
|
||||
{
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setCursor(Qt::PointingHandCursor);
|
||||
|
||||
myFont.setWeight(0);
|
||||
myPen.setStyle(Qt::NoPen);
|
||||
myFont.setWeight(0);
|
||||
myPen.setStyle(Qt::NoPen);
|
||||
|
||||
myColor = myColorOver = myColorDisabled = QColor();
|
||||
myColor = myColorOver = myColorDisabled = QColor();
|
||||
}
|
||||
|
||||
iisIconLabel::~iisIconLabel()
|
||||
{
|
||||
//if (m_changeCursorOver)
|
||||
// QApplication::restoreOverrideCursor();
|
||||
//if (m_changeCursorOver)
|
||||
// QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void iisIconLabel::setSchemePointer(iisIconLabelScheme **pointer)
|
||||
{
|
||||
mySchemePointer = pointer;
|
||||
update();
|
||||
mySchemePointer = pointer;
|
||||
update();
|
||||
}
|
||||
|
||||
void iisIconLabel::setColors(const QColor &color, const QColor &colorOver, const QColor &colorOff)
|
||||
{
|
||||
myColor = color;
|
||||
myColorOver = colorOver;
|
||||
myColorDisabled = colorOff;
|
||||
update();
|
||||
myColor = color;
|
||||
myColorOver = colorOver;
|
||||
myColorDisabled = colorOff;
|
||||
update();
|
||||
}
|
||||
|
||||
void iisIconLabel::setFont(const QFont &font)
|
||||
{
|
||||
myFont = font;
|
||||
update();
|
||||
myFont = font;
|
||||
update();
|
||||
}
|
||||
|
||||
void iisIconLabel::setFocusPen(const QPen &pen)
|
||||
{
|
||||
myPen = pen;
|
||||
update();
|
||||
myPen = pen;
|
||||
update();
|
||||
}
|
||||
|
||||
QSize iisIconLabel::sizeHint() const
|
||||
{
|
||||
return minimumSize();
|
||||
return minimumSize();
|
||||
}
|
||||
|
||||
QSize iisIconLabel::minimumSizeHint() const
|
||||
{
|
||||
int s = (mySchemePointer && *mySchemePointer) ? (*mySchemePointer)->iconSize : 16;
|
||||
QPixmap px = myPixmap.pixmap(s,s,
|
||||
isEnabled() ? QIcon::Normal : QIcon::Disabled);
|
||||
int s = (mySchemePointer && *mySchemePointer) ? (*mySchemePointer)->iconSize : 16;
|
||||
QPixmap px = myPixmap.pixmap(s,s,
|
||||
isEnabled() ? QIcon::Normal : QIcon::Disabled);
|
||||
|
||||
int h = 4+px.height();
|
||||
int w = 8 + px.width();
|
||||
if (!myText.isEmpty()) {
|
||||
QFontMetrics fm(myFont);
|
||||
w += fm.width(myText);
|
||||
h = qMax(h, 4+fm.height());
|
||||
}
|
||||
int h = 4+px.height();
|
||||
int w = 8 + px.width();
|
||||
if (!myText.isEmpty()) {
|
||||
QFontMetrics fm(myFont);
|
||||
w += fm.width(myText);
|
||||
h = qMax(h, 4+fm.height());
|
||||
}
|
||||
|
||||
return QSize(w+2,h+2);
|
||||
return QSize(w+2,h+2);
|
||||
}
|
||||
|
||||
void iisIconLabel::paintEvent ( QPaintEvent * event )
|
||||
void iisIconLabel::paintEvent ( QPaintEvent * event )
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
QPainter p(this);
|
||||
Q_UNUSED(event);
|
||||
QPainter p(this);
|
||||
|
||||
QRect textRect(rect().adjusted(0,0,-1,0));
|
||||
QRect textRect(rect().adjusted(0,0,-1,0));
|
||||
|
||||
int x = 2;
|
||||
int x = 2;
|
||||
|
||||
if (!myPixmap.isNull()) {
|
||||
int s = (mySchemePointer && *mySchemePointer) ? (*mySchemePointer)->iconSize : 16;
|
||||
QPixmap px = myPixmap.pixmap(s,s,
|
||||
isEnabled() ? QIcon::Normal : QIcon::Disabled);
|
||||
p.drawPixmap(x,0,px);
|
||||
x += px.width() + 4;
|
||||
}
|
||||
if (!myPixmap.isNull()) {
|
||||
int s = (mySchemePointer && *mySchemePointer) ? (*mySchemePointer)->iconSize : 16;
|
||||
QPixmap px = myPixmap.pixmap(s,s,
|
||||
isEnabled() ? QIcon::Normal : QIcon::Disabled);
|
||||
p.drawPixmap(x,0,px);
|
||||
x += px.width() + 4;
|
||||
}
|
||||
|
||||
if (!myText.isEmpty()) {
|
||||
QColor text = myColor, textOver = myColorOver, textOff = myColorDisabled;
|
||||
QFont fnt = myFont;
|
||||
QPen focusPen = myPen;
|
||||
bool underline = m_underlineOver/*, cursover = m_changeCursorOver*/;
|
||||
if (mySchemePointer && *mySchemePointer) {
|
||||
if (!text.isValid()) text = (*mySchemePointer)->text;
|
||||
if (!textOver.isValid()) textOver = (*mySchemePointer)->textOver;
|
||||
if (!textOff.isValid()) textOff = (*mySchemePointer)->textOff;
|
||||
if (!fnt.weight()) fnt = (*mySchemePointer)->font;
|
||||
if (focusPen.style() == Qt::NoPen) focusPen = (*mySchemePointer)->focusPen;
|
||||
underline = (*mySchemePointer)->underlineOver;
|
||||
//cursover = (*mySchemePointer)->cursorOver;
|
||||
}
|
||||
if (!myText.isEmpty()) {
|
||||
QColor text = myColor, textOver = myColorOver, textOff = myColorDisabled;
|
||||
QFont fnt = myFont;
|
||||
QPen focusPen = myPen;
|
||||
bool underline = m_underlineOver/*, cursover = m_changeCursorOver*/;
|
||||
if (mySchemePointer && *mySchemePointer) {
|
||||
if (!text.isValid()) text = (*mySchemePointer)->text;
|
||||
if (!textOver.isValid()) textOver = (*mySchemePointer)->textOver;
|
||||
if (!textOff.isValid()) textOff = (*mySchemePointer)->textOff;
|
||||
if (!fnt.weight()) fnt = (*mySchemePointer)->font;
|
||||
if (focusPen.style() == Qt::NoPen) focusPen = (*mySchemePointer)->focusPen;
|
||||
underline = (*mySchemePointer)->underlineOver;
|
||||
//cursover = (*mySchemePointer)->cursorOver;
|
||||
}
|
||||
|
||||
p.setPen(isEnabled() ? m_over ? textOver : text : textOff);
|
||||
p.setPen(isEnabled() ? m_over ? textOver : text : textOff);
|
||||
|
||||
if (isEnabled() && underline && m_over)
|
||||
fnt.setUnderline(true);
|
||||
p.setFont(fnt);
|
||||
if (isEnabled() && underline && m_over)
|
||||
fnt.setUnderline(true);
|
||||
p.setFont(fnt);
|
||||
|
||||
textRect.setLeft(x);
|
||||
QRect boundingRect;
|
||||
textRect.setLeft(x);
|
||||
QRect boundingRect;
|
||||
|
||||
QFontMetrics fm(fnt);
|
||||
QFontMetrics fm(fnt);
|
||||
#if QT_VERSION >= 0x040203
|
||||
QString txt(fm.elidedText(myText, Qt::ElideRight, textRect.width()));
|
||||
QString txt(fm.elidedText(myText, Qt::ElideRight, textRect.width()));
|
||||
#else
|
||||
QString txt = myText;
|
||||
QString txt = myText;
|
||||
#endif
|
||||
|
||||
p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, txt, &boundingRect);
|
||||
p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, txt, &boundingRect);
|
||||
|
||||
if (hasFocus()) {
|
||||
p.setPen(focusPen);
|
||||
p.drawRect(boundingRect.adjusted(-2,-1,0,0));
|
||||
}
|
||||
}
|
||||
if (hasFocus()) {
|
||||
p.setPen(focusPen);
|
||||
p.drawRect(boundingRect.adjusted(-2,-1,0,0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void iisIconLabel::enterEvent ( QEvent * /*event*/ )
|
||||
{
|
||||
m_over = true;
|
||||
m_over = true;
|
||||
|
||||
//if (m_changeCursorOver)
|
||||
// QApplication::setOverrideCursor(Qt::PointingHandCursor);
|
||||
//if (m_changeCursorOver)
|
||||
// QApplication::setOverrideCursor(Qt::PointingHandCursor);
|
||||
|
||||
update();
|
||||
update();
|
||||
}
|
||||
|
||||
void iisIconLabel::leaveEvent ( QEvent * /*event*/ )
|
||||
{
|
||||
m_over = false;
|
||||
update();
|
||||
m_over = false;
|
||||
update();
|
||||
|
||||
//if (m_changeCursorOver)
|
||||
// QApplication::restoreOverrideCursor();
|
||||
//if (m_changeCursorOver)
|
||||
// QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
void iisIconLabel::mousePressEvent ( QMouseEvent * event )
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
m_pressed = true;
|
||||
emit pressed();
|
||||
} else
|
||||
if (event->button() == Qt::RightButton)
|
||||
emit contextMenu();
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
m_pressed = true;
|
||||
Q_EMIT pressed();
|
||||
} else
|
||||
if (event->button() == Qt::RightButton)
|
||||
Q_EMIT contextMenu();
|
||||
|
||||
update();
|
||||
update();
|
||||
}
|
||||
|
||||
void iisIconLabel::mouseReleaseEvent ( QMouseEvent * event )
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
m_pressed = false;
|
||||
emit released();
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
m_pressed = false;
|
||||
Q_EMIT released();
|
||||
|
||||
if (rect().contains( event->pos() )) {
|
||||
emit clicked();
|
||||
emit activated();
|
||||
}
|
||||
}
|
||||
if (rect().contains( event->pos() )) {
|
||||
Q_EMIT clicked();
|
||||
Q_EMIT activated();
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
update();
|
||||
}
|
||||
|
||||
void iisIconLabel::keyPressEvent ( QKeyEvent * event )
|
||||
{
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Space:
|
||||
case Qt::Key_Return:
|
||||
emit activated();
|
||||
break;
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Space:
|
||||
case Qt::Key_Return:
|
||||
Q_EMIT activated();
|
||||
break;
|
||||
|
||||
default:;
|
||||
}
|
||||
default:;
|
||||
}
|
||||
|
||||
QWidget::keyPressEvent(event);
|
||||
QWidget::keyPressEvent(event);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,38 +16,38 @@
|
||||
#include "iisiconlabel.h"
|
||||
|
||||
iisTaskHeader::iisTaskHeader(const QIcon &icon, const QString &title, bool expandable, QWidget *parent)
|
||||
: QFrame(parent),
|
||||
myExpandable(expandable),
|
||||
m_over(false),
|
||||
m_buttonOver(false),
|
||||
m_fold(true),
|
||||
m_opacity(0.1),
|
||||
myButton(0)
|
||||
: QFrame(parent),
|
||||
myExpandable(expandable),
|
||||
m_over(false),
|
||||
m_buttonOver(false),
|
||||
m_fold(true),
|
||||
m_opacity(0.1),
|
||||
myButton(0)
|
||||
{
|
||||
myTitle = new iisIconLabel(icon, title, this);
|
||||
myTitle->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
myTitle = new iisIconLabel(icon, title, this);
|
||||
myTitle->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
|
||||
connect(myTitle, SIGNAL(activated()), this, SLOT(fold()));
|
||||
connect(myTitle, SIGNAL(activated()), this, SLOT(fold()));
|
||||
|
||||
QHBoxLayout *hbl = new QHBoxLayout();
|
||||
hbl->setMargin(2);
|
||||
setLayout(hbl);
|
||||
QHBoxLayout *hbl = new QHBoxLayout();
|
||||
hbl->setMargin(2);
|
||||
setLayout(hbl);
|
||||
|
||||
hbl->addWidget(myTitle);
|
||||
hbl->addWidget(myTitle);
|
||||
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||
|
||||
setScheme(iisTaskPanelScheme::defaultScheme());
|
||||
myTitle->setSchemePointer(&myLabelScheme);
|
||||
setScheme(iisTaskPanelScheme::defaultScheme());
|
||||
myTitle->setSchemePointer(&myLabelScheme);
|
||||
|
||||
|
||||
if (myExpandable) {
|
||||
myButton = new QLabel(this);
|
||||
hbl->addWidget(myButton);
|
||||
myButton->installEventFilter(this);
|
||||
myButton->setFixedWidth(myScheme->headerButtonSize.width());
|
||||
changeIcons();
|
||||
}
|
||||
if (myExpandable) {
|
||||
myButton = new QLabel(this);
|
||||
hbl->addWidget(myButton);
|
||||
myButton->installEventFilter(this);
|
||||
myButton->setFixedWidth(myScheme->headerButtonSize.width());
|
||||
changeIcons();
|
||||
}
|
||||
}
|
||||
|
||||
iisTaskHeader::~iisTaskHeader()
|
||||
@@ -57,145 +57,145 @@ iisTaskHeader::~iisTaskHeader()
|
||||
|
||||
bool iisTaskHeader::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
fold();
|
||||
return true;
|
||||
switch (event->type()) {
|
||||
case QEvent::MouseButtonPress:
|
||||
fold();
|
||||
return true;
|
||||
|
||||
case QEvent::Enter:
|
||||
m_buttonOver = true;
|
||||
changeIcons();
|
||||
return true;
|
||||
case QEvent::Enter:
|
||||
m_buttonOver = true;
|
||||
changeIcons();
|
||||
return true;
|
||||
|
||||
case QEvent::Leave:
|
||||
m_buttonOver = false;
|
||||
changeIcons();
|
||||
return true;
|
||||
case QEvent::Leave:
|
||||
m_buttonOver = false;
|
||||
changeIcons();
|
||||
return true;
|
||||
|
||||
default:;
|
||||
}
|
||||
default:;
|
||||
}
|
||||
|
||||
return QFrame::eventFilter(obj, event);
|
||||
return QFrame::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void iisTaskHeader::setScheme(iisTaskPanelScheme *scheme)
|
||||
{
|
||||
if (scheme) {
|
||||
myScheme = scheme;
|
||||
myLabelScheme = &(scheme->headerLabelScheme);
|
||||
if (scheme) {
|
||||
myScheme = scheme;
|
||||
myLabelScheme = &(scheme->headerLabelScheme);
|
||||
|
||||
if (myExpandable) {
|
||||
setCursor(myLabelScheme->cursorOver ? Qt::PointingHandCursor : cursor());
|
||||
changeIcons();
|
||||
}
|
||||
if (myExpandable) {
|
||||
setCursor(myLabelScheme->cursorOver ? Qt::PointingHandCursor : cursor());
|
||||
changeIcons();
|
||||
}
|
||||
|
||||
setFixedHeight(scheme->headerSize);
|
||||
setFixedHeight(scheme->headerSize);
|
||||
|
||||
update();
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void iisTaskHeader::paintEvent ( QPaintEvent * event )
|
||||
void iisTaskHeader::paintEvent ( QPaintEvent * event )
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
QPainter p(this);
|
||||
Q_UNUSED(event);
|
||||
QPainter p(this);
|
||||
|
||||
#if QT_VERSION >= 0x040203
|
||||
if (myScheme->headerAnimation)
|
||||
p.setOpacity(m_opacity+0.7);
|
||||
if (myScheme->headerAnimation)
|
||||
p.setOpacity(m_opacity+0.7);
|
||||
#endif
|
||||
|
||||
p.setPen(myScheme->headerBorder);
|
||||
p.setBrush(myScheme->headerBackground);
|
||||
if (myScheme->headerBorder.style() == Qt::NoPen)
|
||||
p.drawRect(rect());
|
||||
else
|
||||
p.drawRect(rect().adjusted(0,0,-1,-1));
|
||||
p.setPen(myScheme->headerBorder);
|
||||
p.setBrush(myScheme->headerBackground);
|
||||
if (myScheme->headerBorder.style() == Qt::NoPen)
|
||||
p.drawRect(rect());
|
||||
else
|
||||
p.drawRect(rect().adjusted(0,0,-1,-1));
|
||||
}
|
||||
|
||||
void iisTaskHeader::animate()
|
||||
{
|
||||
if (!myScheme->headerAnimation)
|
||||
return;
|
||||
if (!myScheme->headerAnimation)
|
||||
return;
|
||||
|
||||
if (!isEnabled()) {
|
||||
m_opacity = 0.1;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
if (!isEnabled()) {
|
||||
m_opacity = 0.1;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_over) {
|
||||
if (m_opacity >= 0.3) {
|
||||
m_opacity = 0.3;
|
||||
return;
|
||||
}
|
||||
m_opacity += 0.05;
|
||||
} else {
|
||||
if (m_opacity <= 0.1) {
|
||||
m_opacity = 0.1;
|
||||
return;
|
||||
}
|
||||
m_opacity = qMax(0.1, m_opacity-0.05);
|
||||
}
|
||||
if (m_over) {
|
||||
if (m_opacity >= 0.3) {
|
||||
m_opacity = 0.3;
|
||||
return;
|
||||
}
|
||||
m_opacity += 0.05;
|
||||
} else {
|
||||
if (m_opacity <= 0.1) {
|
||||
m_opacity = 0.1;
|
||||
return;
|
||||
}
|
||||
m_opacity = qMax(0.1, m_opacity-0.05);
|
||||
}
|
||||
|
||||
QTimer::singleShot(100, this, SLOT(animate()));
|
||||
update();
|
||||
QTimer::singleShot(100, this, SLOT(animate()));
|
||||
update();
|
||||
}
|
||||
|
||||
void iisTaskHeader::enterEvent ( QEvent * /*event*/ )
|
||||
{
|
||||
m_over = true;
|
||||
m_over = true;
|
||||
|
||||
if (isEnabled())
|
||||
QTimer::singleShot(100, this, SLOT(animate()));
|
||||
if (isEnabled())
|
||||
QTimer::singleShot(100, this, SLOT(animate()));
|
||||
|
||||
update();
|
||||
update();
|
||||
}
|
||||
|
||||
void iisTaskHeader::leaveEvent ( QEvent * /*event*/ )
|
||||
{
|
||||
m_over = false;
|
||||
|
||||
if (isEnabled())
|
||||
QTimer::singleShot(100, this, SLOT(animate()));
|
||||
m_over = false;
|
||||
|
||||
update();
|
||||
if (isEnabled())
|
||||
QTimer::singleShot(100, this, SLOT(animate()));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
void iisTaskHeader::fold()
|
||||
{
|
||||
if (myExpandable) {
|
||||
emit activated();
|
||||
if (myExpandable) {
|
||||
Q_EMIT activated();
|
||||
|
||||
m_fold = !m_fold;
|
||||
changeIcons();
|
||||
}
|
||||
m_fold = !m_fold;
|
||||
changeIcons();
|
||||
}
|
||||
}
|
||||
|
||||
void iisTaskHeader::changeIcons()
|
||||
{
|
||||
if (!myButton)
|
||||
return;
|
||||
if (!myButton)
|
||||
return;
|
||||
|
||||
if (m_buttonOver)
|
||||
{
|
||||
if (m_fold)
|
||||
myButton->setPixmap(myScheme->headerButtonFoldOver.pixmap(myScheme->headerButtonSize));
|
||||
else
|
||||
myButton->setPixmap(myScheme->headerButtonUnfoldOver.pixmap(myScheme->headerButtonSize));
|
||||
} else
|
||||
{
|
||||
if (m_fold)
|
||||
myButton->setPixmap(myScheme->headerButtonFold.pixmap(myScheme->headerButtonSize));
|
||||
else
|
||||
myButton->setPixmap(myScheme->headerButtonUnfold.pixmap(myScheme->headerButtonSize));
|
||||
}
|
||||
if (m_buttonOver)
|
||||
{
|
||||
if (m_fold)
|
||||
myButton->setPixmap(myScheme->headerButtonFoldOver.pixmap(myScheme->headerButtonSize));
|
||||
else
|
||||
myButton->setPixmap(myScheme->headerButtonUnfoldOver.pixmap(myScheme->headerButtonSize));
|
||||
} else
|
||||
{
|
||||
if (m_fold)
|
||||
myButton->setPixmap(myScheme->headerButtonFold.pixmap(myScheme->headerButtonSize));
|
||||
else
|
||||
myButton->setPixmap(myScheme->headerButtonUnfold.pixmap(myScheme->headerButtonSize));
|
||||
}
|
||||
}
|
||||
|
||||
void iisTaskHeader::mouseReleaseEvent ( QMouseEvent * event )
|
||||
{
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
emit activated();
|
||||
}
|
||||
if (event->button() == Qt::LeftButton) {
|
||||
Q_EMIT activated();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user