Skip to content

Commit

Permalink
* Cosmetic change. Replace Qt keyword emit with Q_EMIT.
Browse files Browse the repository at this point in the history
* Whitespace fixes.
  • Loading branch information
f3nix committed Jan 5, 2017
1 parent 96dc57c commit 9b07616
Show file tree
Hide file tree
Showing 7 changed files with 426 additions and 426 deletions.
4 changes: 2 additions & 2 deletions src/Gui/QSint/actionpanel/taskheader_p.cpp
Expand Up @@ -195,7 +195,7 @@ void TaskHeader::leaveEvent ( QEvent * /*event*/ )
void TaskHeader::fold()
{
if (myExpandable) {
emit activated();
Q_EMIT activated();
// Toggling the 'm_fold' member here may lead to inconsistencies with its ActionGroup.
// Thus, the method setFold() was added and called from ActionGroup when required.
#if 0
Expand Down Expand Up @@ -254,7 +254,7 @@ void TaskHeader::changeIcons()
void TaskHeader::mouseReleaseEvent ( QMouseEvent * event )
{
if (event->button() == Qt::LeftButton) {
emit activated();
Q_EMIT activated();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Gui/Quarter/SignalThread.cpp
Expand Up @@ -70,7 +70,7 @@ SignalThread::run(void)
// just wait, and trigger every time we receive a signal
this->waitcond.wait(&this->mutex);
if (!this->isstopped) {
emit triggerSignal();
Q_EMIT triggerSignal();
}
}
}
242 changes: 121 additions & 121 deletions src/Gui/iisTaskPanel/src/iisiconlabel.cpp
Expand Up @@ -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 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);
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());
}

return QSize(w+2,h+2);
}

void iisIconLabel::paintEvent ( QPaintEvent * event )
void iisIconLabel::paintEvent ( QPaintEvent * event )
{
Q_UNUSED(event);
QPainter p(this);

QRect textRect(rect().adjusted(0,0,-1,0));

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 (!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);

if (isEnabled() && underline && m_over)
fnt.setUnderline(true);
p.setFont(fnt);

textRect.setLeft(x);
QRect boundingRect;

QFontMetrics fm(fnt);
Q_UNUSED(event);
QPainter p(this);

QRect textRect(rect().adjusted(0,0,-1,0));

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 (!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);

if (isEnabled() && underline && m_over)
fnt.setUnderline(true);
p.setFont(fnt);

textRect.setLeft(x);
QRect boundingRect;

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();

update();
if (event->button() == Qt::LeftButton) {
m_pressed = true;
Q_EMIT pressed();
} else
if (event->button() == Qt::RightButton)
Q_EMIT contextMenu();

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);
}

0 comments on commit 9b07616

Please sign in to comment.