* Cosmetic change. Replace Qt keyword emit with Q_EMIT.

* Whitespace fixes.
This commit is contained in:
Mateusz Skowroński 2017-01-05 22:38:23 +01:00
parent 96dc57c068
commit 9b07616fe6
7 changed files with 407 additions and 407 deletions

View File

@ -195,7 +195,7 @@ void TaskHeader::leaveEvent ( QEvent * /*event*/ )
void TaskHeader::fold() void TaskHeader::fold()
{ {
if (myExpandable) { if (myExpandable) {
emit activated(); Q_EMIT activated();
// Toggling the 'm_fold' member here may lead to inconsistencies with its ActionGroup. // 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. // Thus, the method setFold() was added and called from ActionGroup when required.
#if 0 #if 0
@ -254,7 +254,7 @@ void TaskHeader::changeIcons()
void TaskHeader::mouseReleaseEvent ( QMouseEvent * event ) void TaskHeader::mouseReleaseEvent ( QMouseEvent * event )
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
emit activated(); Q_EMIT activated();
} }
} }

View File

@ -70,7 +70,7 @@ SignalThread::run(void)
// just wait, and trigger every time we receive a signal // just wait, and trigger every time we receive a signal
this->waitcond.wait(&this->mutex); this->waitcond.wait(&this->mutex);
if (!this->isstopped) { if (!this->isstopped) {
emit triggerSignal(); Q_EMIT triggerSignal();
} }
} }
} }

View File

@ -9,193 +9,193 @@
#include "iistaskpanelscheme.h" #include "iistaskpanelscheme.h"
iisIconLabel::iisIconLabel(const QIcon &icon, const QString &title, QWidget *parent) iisIconLabel::iisIconLabel(const QIcon &icon, const QString &title, QWidget *parent)
: QWidget(parent), : QWidget(parent),
myPixmap(icon), myPixmap(icon),
myText(title), myText(title),
mySchemePointer(0), mySchemePointer(0),
m_over(false), m_over(false),
m_pressed(false), m_pressed(false),
m_changeCursorOver(true), m_changeCursorOver(true),
m_underlineOver(true) m_underlineOver(true)
{ {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
setCursor(Qt::PointingHandCursor); setCursor(Qt::PointingHandCursor);
myFont.setWeight(0); myFont.setWeight(0);
myPen.setStyle(Qt::NoPen); myPen.setStyle(Qt::NoPen);
myColor = myColorOver = myColorDisabled = QColor(); myColor = myColorOver = myColorDisabled = QColor();
} }
iisIconLabel::~iisIconLabel() iisIconLabel::~iisIconLabel()
{ {
//if (m_changeCursorOver) //if (m_changeCursorOver)
// QApplication::restoreOverrideCursor(); // QApplication::restoreOverrideCursor();
} }
void iisIconLabel::setSchemePointer(iisIconLabelScheme **pointer) void iisIconLabel::setSchemePointer(iisIconLabelScheme **pointer)
{ {
mySchemePointer = pointer; mySchemePointer = pointer;
update(); update();
} }
void iisIconLabel::setColors(const QColor &color, const QColor &colorOver, const QColor &colorOff) void iisIconLabel::setColors(const QColor &color, const QColor &colorOver, const QColor &colorOff)
{ {
myColor = color; myColor = color;
myColorOver = colorOver; myColorOver = colorOver;
myColorDisabled = colorOff; myColorDisabled = colorOff;
update(); update();
} }
void iisIconLabel::setFont(const QFont &font) void iisIconLabel::setFont(const QFont &font)
{ {
myFont = font; myFont = font;
update(); update();
} }
void iisIconLabel::setFocusPen(const QPen &pen) void iisIconLabel::setFocusPen(const QPen &pen)
{ {
myPen = pen; myPen = pen;
update(); update();
} }
QSize iisIconLabel::sizeHint() const QSize iisIconLabel::sizeHint() const
{ {
return minimumSize(); return minimumSize();
} }
QSize iisIconLabel::minimumSizeHint() const QSize iisIconLabel::minimumSizeHint() const
{ {
int s = (mySchemePointer && *mySchemePointer) ? (*mySchemePointer)->iconSize : 16; int s = (mySchemePointer && *mySchemePointer) ? (*mySchemePointer)->iconSize : 16;
QPixmap px = myPixmap.pixmap(s,s, QPixmap px = myPixmap.pixmap(s,s,
isEnabled() ? QIcon::Normal : QIcon::Disabled); isEnabled() ? QIcon::Normal : QIcon::Disabled);
int h = 4+px.height(); int h = 4+px.height();
int w = 8 + px.width(); int w = 8 + px.width();
if (!myText.isEmpty()) { if (!myText.isEmpty()) {
QFontMetrics fm(myFont); QFontMetrics fm(myFont);
w += fm.width(myText); w += fm.width(myText);
h = qMax(h, 4+fm.height()); 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); Q_UNUSED(event);
QPainter p(this); 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()) { if (!myPixmap.isNull()) {
int s = (mySchemePointer && *mySchemePointer) ? (*mySchemePointer)->iconSize : 16; int s = (mySchemePointer && *mySchemePointer) ? (*mySchemePointer)->iconSize : 16;
QPixmap px = myPixmap.pixmap(s,s, QPixmap px = myPixmap.pixmap(s,s,
isEnabled() ? QIcon::Normal : QIcon::Disabled); isEnabled() ? QIcon::Normal : QIcon::Disabled);
p.drawPixmap(x,0,px); p.drawPixmap(x,0,px);
x += px.width() + 4; x += px.width() + 4;
} }
if (!myText.isEmpty()) { if (!myText.isEmpty()) {
QColor text = myColor, textOver = myColorOver, textOff = myColorDisabled; QColor text = myColor, textOver = myColorOver, textOff = myColorDisabled;
QFont fnt = myFont; QFont fnt = myFont;
QPen focusPen = myPen; QPen focusPen = myPen;
bool underline = m_underlineOver/*, cursover = m_changeCursorOver*/; bool underline = m_underlineOver/*, cursover = m_changeCursorOver*/;
if (mySchemePointer && *mySchemePointer) { if (mySchemePointer && *mySchemePointer) {
if (!text.isValid()) text = (*mySchemePointer)->text; if (!text.isValid()) text = (*mySchemePointer)->text;
if (!textOver.isValid()) textOver = (*mySchemePointer)->textOver; if (!textOver.isValid()) textOver = (*mySchemePointer)->textOver;
if (!textOff.isValid()) textOff = (*mySchemePointer)->textOff; if (!textOff.isValid()) textOff = (*mySchemePointer)->textOff;
if (!fnt.weight()) fnt = (*mySchemePointer)->font; if (!fnt.weight()) fnt = (*mySchemePointer)->font;
if (focusPen.style() == Qt::NoPen) focusPen = (*mySchemePointer)->focusPen; if (focusPen.style() == Qt::NoPen) focusPen = (*mySchemePointer)->focusPen;
underline = (*mySchemePointer)->underlineOver; underline = (*mySchemePointer)->underlineOver;
//cursover = (*mySchemePointer)->cursorOver; //cursover = (*mySchemePointer)->cursorOver;
} }
p.setPen(isEnabled() ? m_over ? textOver : text : textOff); p.setPen(isEnabled() ? m_over ? textOver : text : textOff);
if (isEnabled() && underline && m_over) if (isEnabled() && underline && m_over)
fnt.setUnderline(true); fnt.setUnderline(true);
p.setFont(fnt); p.setFont(fnt);
textRect.setLeft(x); textRect.setLeft(x);
QRect boundingRect; QRect boundingRect;
QFontMetrics fm(fnt); QFontMetrics fm(fnt);
#if QT_VERSION >= 0x040203 #if QT_VERSION >= 0x040203
QString txt(fm.elidedText(myText, Qt::ElideRight, textRect.width())); QString txt(fm.elidedText(myText, Qt::ElideRight, textRect.width()));
#else #else
QString txt = myText; QString txt = myText;
#endif #endif
p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, txt, &boundingRect); p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, txt, &boundingRect);
if (hasFocus()) { if (hasFocus()) {
p.setPen(focusPen); p.setPen(focusPen);
p.drawRect(boundingRect.adjusted(-2,-1,0,0)); p.drawRect(boundingRect.adjusted(-2,-1,0,0));
} }
} }
} }
void iisIconLabel::enterEvent ( QEvent * /*event*/ ) void iisIconLabel::enterEvent ( QEvent * /*event*/ )
{ {
m_over = true; m_over = true;
//if (m_changeCursorOver) //if (m_changeCursorOver)
// QApplication::setOverrideCursor(Qt::PointingHandCursor); // QApplication::setOverrideCursor(Qt::PointingHandCursor);
update(); update();
} }
void iisIconLabel::leaveEvent ( QEvent * /*event*/ ) void iisIconLabel::leaveEvent ( QEvent * /*event*/ )
{ {
m_over = false; m_over = false;
update(); update();
//if (m_changeCursorOver) //if (m_changeCursorOver)
// QApplication::restoreOverrideCursor(); // QApplication::restoreOverrideCursor();
} }
void iisIconLabel::mousePressEvent ( QMouseEvent * event ) void iisIconLabel::mousePressEvent ( QMouseEvent * event )
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
m_pressed = true; m_pressed = true;
emit pressed(); Q_EMIT pressed();
} else } else
if (event->button() == Qt::RightButton) if (event->button() == Qt::RightButton)
emit contextMenu(); Q_EMIT contextMenu();
update(); update();
} }
void iisIconLabel::mouseReleaseEvent ( QMouseEvent * event ) void iisIconLabel::mouseReleaseEvent ( QMouseEvent * event )
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
m_pressed = false; m_pressed = false;
emit released(); Q_EMIT released();
if (rect().contains( event->pos() )) { if (rect().contains( event->pos() )) {
emit clicked(); Q_EMIT clicked();
emit activated(); Q_EMIT activated();
} }
} }
update(); update();
} }
void iisIconLabel::keyPressEvent ( QKeyEvent * event ) void iisIconLabel::keyPressEvent ( QKeyEvent * event )
{ {
switch (event->key()) { switch (event->key()) {
case Qt::Key_Space: case Qt::Key_Space:
case Qt::Key_Return: case Qt::Key_Return:
emit activated(); Q_EMIT activated();
break; break;
default:; default:;
} }
QWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
} }

View File

@ -16,38 +16,38 @@
#include "iisiconlabel.h" #include "iisiconlabel.h"
iisTaskHeader::iisTaskHeader(const QIcon &icon, const QString &title, bool expandable, QWidget *parent) iisTaskHeader::iisTaskHeader(const QIcon &icon, const QString &title, bool expandable, QWidget *parent)
: QFrame(parent), : QFrame(parent),
myExpandable(expandable), myExpandable(expandable),
m_over(false), m_over(false),
m_buttonOver(false), m_buttonOver(false),
m_fold(true), m_fold(true),
m_opacity(0.1), m_opacity(0.1),
myButton(0) myButton(0)
{ {
myTitle = new iisIconLabel(icon, title, this); myTitle = new iisIconLabel(icon, title, this);
myTitle->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); myTitle->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
connect(myTitle, SIGNAL(activated()), this, SLOT(fold())); connect(myTitle, SIGNAL(activated()), this, SLOT(fold()));
QHBoxLayout *hbl = new QHBoxLayout(); QHBoxLayout *hbl = new QHBoxLayout();
hbl->setMargin(2); hbl->setMargin(2);
setLayout(hbl); setLayout(hbl);
hbl->addWidget(myTitle); hbl->addWidget(myTitle);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
setScheme(iisTaskPanelScheme::defaultScheme()); setScheme(iisTaskPanelScheme::defaultScheme());
myTitle->setSchemePointer(&myLabelScheme); myTitle->setSchemePointer(&myLabelScheme);
if (myExpandable) { if (myExpandable) {
myButton = new QLabel(this); myButton = new QLabel(this);
hbl->addWidget(myButton); hbl->addWidget(myButton);
myButton->installEventFilter(this); myButton->installEventFilter(this);
myButton->setFixedWidth(myScheme->headerButtonSize.width()); myButton->setFixedWidth(myScheme->headerButtonSize.width());
changeIcons(); changeIcons();
} }
} }
iisTaskHeader::~iisTaskHeader() iisTaskHeader::~iisTaskHeader()
@ -57,145 +57,145 @@ iisTaskHeader::~iisTaskHeader()
bool iisTaskHeader::eventFilter(QObject *obj, QEvent *event) bool iisTaskHeader::eventFilter(QObject *obj, QEvent *event)
{ {
switch (event->type()) { switch (event->type()) {
case QEvent::MouseButtonPress: case QEvent::MouseButtonPress:
fold(); fold();
return true; return true;
case QEvent::Enter: case QEvent::Enter:
m_buttonOver = true; m_buttonOver = true;
changeIcons(); changeIcons();
return true; return true;
case QEvent::Leave: case QEvent::Leave:
m_buttonOver = false; m_buttonOver = false;
changeIcons(); changeIcons();
return true; return true;
default:; default:;
} }
return QFrame::eventFilter(obj, event); return QFrame::eventFilter(obj, event);
} }
void iisTaskHeader::setScheme(iisTaskPanelScheme *scheme) void iisTaskHeader::setScheme(iisTaskPanelScheme *scheme)
{ {
if (scheme) { if (scheme) {
myScheme = scheme; myScheme = scheme;
myLabelScheme = &(scheme->headerLabelScheme); myLabelScheme = &(scheme->headerLabelScheme);
if (myExpandable) { if (myExpandable) {
setCursor(myLabelScheme->cursorOver ? Qt::PointingHandCursor : cursor()); setCursor(myLabelScheme->cursorOver ? Qt::PointingHandCursor : cursor());
changeIcons(); changeIcons();
} }
setFixedHeight(scheme->headerSize); setFixedHeight(scheme->headerSize);
update(); update();
} }
} }
void iisTaskHeader::paintEvent ( QPaintEvent * event ) void iisTaskHeader::paintEvent ( QPaintEvent * event )
{ {
Q_UNUSED(event); Q_UNUSED(event);
QPainter p(this); QPainter p(this);
#if QT_VERSION >= 0x040203 #if QT_VERSION >= 0x040203
if (myScheme->headerAnimation) if (myScheme->headerAnimation)
p.setOpacity(m_opacity+0.7); p.setOpacity(m_opacity+0.7);
#endif #endif
p.setPen(myScheme->headerBorder); p.setPen(myScheme->headerBorder);
p.setBrush(myScheme->headerBackground); p.setBrush(myScheme->headerBackground);
if (myScheme->headerBorder.style() == Qt::NoPen) if (myScheme->headerBorder.style() == Qt::NoPen)
p.drawRect(rect()); p.drawRect(rect());
else else
p.drawRect(rect().adjusted(0,0,-1,-1)); p.drawRect(rect().adjusted(0,0,-1,-1));
} }
void iisTaskHeader::animate() void iisTaskHeader::animate()
{ {
if (!myScheme->headerAnimation) if (!myScheme->headerAnimation)
return; return;
if (!isEnabled()) { if (!isEnabled()) {
m_opacity = 0.1; m_opacity = 0.1;
update(); update();
return; return;
} }
if (m_over) { if (m_over) {
if (m_opacity >= 0.3) { if (m_opacity >= 0.3) {
m_opacity = 0.3; m_opacity = 0.3;
return; return;
} }
m_opacity += 0.05; m_opacity += 0.05;
} else { } else {
if (m_opacity <= 0.1) { if (m_opacity <= 0.1) {
m_opacity = 0.1; m_opacity = 0.1;
return; return;
} }
m_opacity = qMax(0.1, m_opacity-0.05); m_opacity = qMax(0.1, m_opacity-0.05);
} }
QTimer::singleShot(100, this, SLOT(animate())); QTimer::singleShot(100, this, SLOT(animate()));
update(); update();
} }
void iisTaskHeader::enterEvent ( QEvent * /*event*/ ) void iisTaskHeader::enterEvent ( QEvent * /*event*/ )
{ {
m_over = true; m_over = true;
if (isEnabled()) if (isEnabled())
QTimer::singleShot(100, this, SLOT(animate())); QTimer::singleShot(100, this, SLOT(animate()));
update(); update();
} }
void iisTaskHeader::leaveEvent ( QEvent * /*event*/ ) void iisTaskHeader::leaveEvent ( QEvent * /*event*/ )
{ {
m_over = false; m_over = false;
if (isEnabled())
QTimer::singleShot(100, this, SLOT(animate()));
update(); if (isEnabled())
QTimer::singleShot(100, this, SLOT(animate()));
update();
} }
void iisTaskHeader::fold() void iisTaskHeader::fold()
{ {
if (myExpandable) { if (myExpandable) {
emit activated(); Q_EMIT activated();
m_fold = !m_fold; m_fold = !m_fold;
changeIcons(); changeIcons();
} }
} }
void iisTaskHeader::changeIcons() void iisTaskHeader::changeIcons()
{ {
if (!myButton) if (!myButton)
return; return;
if (m_buttonOver) if (m_buttonOver)
{ {
if (m_fold) if (m_fold)
myButton->setPixmap(myScheme->headerButtonFoldOver.pixmap(myScheme->headerButtonSize)); myButton->setPixmap(myScheme->headerButtonFoldOver.pixmap(myScheme->headerButtonSize));
else else
myButton->setPixmap(myScheme->headerButtonUnfoldOver.pixmap(myScheme->headerButtonSize)); myButton->setPixmap(myScheme->headerButtonUnfoldOver.pixmap(myScheme->headerButtonSize));
} else } else
{ {
if (m_fold) if (m_fold)
myButton->setPixmap(myScheme->headerButtonFold.pixmap(myScheme->headerButtonSize)); myButton->setPixmap(myScheme->headerButtonFold.pixmap(myScheme->headerButtonSize));
else else
myButton->setPixmap(myScheme->headerButtonUnfold.pixmap(myScheme->headerButtonSize)); myButton->setPixmap(myScheme->headerButtonUnfold.pixmap(myScheme->headerButtonSize));
} }
} }
void iisTaskHeader::mouseReleaseEvent ( QMouseEvent * event ) void iisTaskHeader::mouseReleaseEvent ( QMouseEvent * event )
{ {
if (event->button() == Qt::LeftButton) { if (event->button() == Qt::LeftButton) {
emit activated(); Q_EMIT activated();
} }
} }

View File

@ -1,17 +1,17 @@
/**************************************************************************** /****************************************************************************
** **
** This file is part of a Qt Solutions component. ** This file is part of a Qt Solutions component.
** **
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
** **
** Contact: Qt Software Information (qt-info@nokia.com) ** Contact: Qt Software Information (qt-info@nokia.com)
** **
** Commercial Usage ** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in ** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Solutions Commercial License Agreement provided ** accordance with the Qt Solutions Commercial License Agreement provided
** with the Software or, alternatively, in accordance with the terms ** with the Software or, alternatively, in accordance with the terms
** contained in a written agreement between you and Nokia. ** contained in a written agreement between you and Nokia.
** **
** GNU Lesser General Public License Usage ** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser ** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software ** General Public License version 2.1 as published by the Free Software
@ -19,29 +19,29 @@
** packaging of this file. Please review the following information to ** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements ** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** **
** In addition, as a special exception, Nokia gives you certain ** In addition, as a special exception, Nokia gives you certain
** additional rights. These rights are described in the Nokia Qt LGPL ** additional rights. These rights are described in the Nokia Qt LGPL
** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
** package. ** package.
** **
** GNU General Public License Usage ** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU ** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software ** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the ** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to ** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be ** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html. ** met: http://www.gnu.org/copyleft/gpl.html.
** **
** Please note Third Party Software included with Qt Solutions may impose ** Please note Third Party Software included with Qt Solutions may impose
** additional restrictions and it is the user's responsibility to ensure ** additional restrictions and it is the user's responsibility to ensure
** that they have met the licensing requirements of the GPL, LGPL, or Qt ** that they have met the licensing requirements of the GPL, LGPL, or Qt
** Solutions Commercial license and the relevant license of the Third ** Solutions Commercial license and the relevant license of the Third
** Party Software they are using. ** Party Software they are using.
** **
** If you are unsure which license is appropriate for your use, please ** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com. ** contact the sales department at qt-sales@nokia.com.
** **
****************************************************************************/ ****************************************************************************/
#include <QApplication> #include <QApplication>
@ -169,7 +169,7 @@ class ColorPickerItem : public QFrame
public: public:
ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString::null, ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString::null,
QWidget *parent = 0); QWidget *parent = 0);
~ColorPickerItem(); ~ColorPickerItem();
QColor color() const; QColor color() const;
@ -205,7 +205,7 @@ class ColorPickerPopup : public QFrame
public: public:
ColorPickerPopup(int width, bool withColorDialog, ColorPickerPopup(int width, bool withColorDialog,
QWidget *parent = 0); QWidget *parent = 0);
~ColorPickerPopup(); ~ColorPickerPopup();
void insertColor(const QColor &col, const QString &text, int index); void insertColor(const QColor &col, const QString &text, int index);
@ -217,7 +217,7 @@ public:
ColorPickerItem *find(const QColor &col) const; ColorPickerItem *find(const QColor &col) const;
QColor color(int index) const; QColor color(int index) const;
void setLastSel(const QColor & col); void setLastSel(const QColor & col);
signals: signals:
@ -268,7 +268,7 @@ private:
\sa QFrame \sa QFrame
*/ */
QtColorPicker::QtColorPicker(QWidget *parent, QtColorPicker::QtColorPicker(QWidget *parent,
int cols, bool enableColorDialog) int cols, bool enableColorDialog)
: QPushButton(parent), popup(0), withColorDialog(enableColorDialog) : QPushButton(parent), popup(0), withColorDialog(enableColorDialog)
{ {
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
@ -288,7 +288,7 @@ QtColorPicker::QtColorPicker(QWidget *parent,
// Create color grid popup and connect to it. // Create color grid popup and connect to it.
popup = new ColorPickerPopup(cols, withColorDialog, this); popup = new ColorPickerPopup(cols, withColorDialog, this);
connect(popup, SIGNAL(selected(const QColor &)), connect(popup, SIGNAL(selected(const QColor &)),
SLOT(setCurrentColor(const QColor &))); SLOT(setCurrentColor(const QColor &)));
connect(popup, SIGNAL(hid()), SLOT(popupClosed())); connect(popup, SIGNAL(hid()), SLOT(popupClosed()));
// Connect this push button's pressed() signal. // Connect this push button's pressed() signal.
@ -434,18 +434,18 @@ void QtColorPicker::setStandardColors()
void QtColorPicker::setCurrentColor(const QColor &color) void QtColorPicker::setCurrentColor(const QColor &color)
{ {
if (color.isValid() && col == color) { if (color.isValid() && col == color) {
emit colorSet(color); Q_EMIT colorSet(color);
return; return;
} }
if (col == color || !color.isValid()) if (col == color || !color.isValid())
return; return;
ColorPickerItem *item = popup->find(color); ColorPickerItem *item = popup->find(color);
if (!item) { if (!item) {
insertColor(color, tr("Custom")); insertColor(color, tr("Custom"));
item = popup->find(color); item = popup->find(color);
} }
popup->setLastSel(color); popup->setLastSel(color);
col = color; col = color;
@ -457,8 +457,8 @@ void QtColorPicker::setCurrentColor(const QColor &color)
repaint(); repaint();
item->setSelected(true); item->setSelected(true);
emit colorChanged(color); Q_EMIT colorChanged(color);
emit colorSet(color); Q_EMIT colorSet(color);
} }
/*! /*!
@ -471,9 +471,9 @@ void QtColorPicker::insertColor(const QColor &color, const QString &text, int in
{ {
popup->insertColor(color, text, index); popup->insertColor(color, text, index);
if (!firstInserted) { if (!firstInserted) {
col = color; col = color;
setText(text); setText(text);
firstInserted = true; firstInserted = true;
} }
} }
@ -504,7 +504,7 @@ bool QtColorPicker::colorDialogEnabled() const
\code \code
void Drawer::mouseReleaseEvent(QMouseEvent *e) void Drawer::mouseReleaseEvent(QMouseEvent *e)
{ {
if (e->button() & RightButton) { if (e->button() & RightButton) {
QColor color = QtColorPicker::getColor(mapToGlobal(e->pos())); QColor color = QtColorPicker::getColor(mapToGlobal(e->pos()));
} }
} }
@ -542,7 +542,7 @@ QColor QtColorPicker::getColor(const QPoint &point, bool allowCustomColors)
Constructs the popup widget. Constructs the popup widget.
*/ */
ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog, ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog,
QWidget *parent) QWidget *parent)
: QFrame(parent, Qt::Popup) : QFrame(parent, Qt::Popup)
{ {
setFrameStyle(QFrame::StyledPanel); setFrameStyle(QFrame::StyledPanel);
@ -553,13 +553,13 @@ ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog,
cols = width; cols = width;
if (withColorDialog) { if (withColorDialog) {
moreButton = new ColorPickerButton(this); moreButton = new ColorPickerButton(this);
moreButton->setFixedWidth(24); moreButton->setFixedWidth(24);
moreButton->setFixedHeight(21); moreButton->setFixedHeight(21);
moreButton->setFrameRect(QRect(2, 2, 20, 17)); moreButton->setFrameRect(QRect(2, 2, 20, 17));
connect(moreButton, SIGNAL(clicked()), SLOT(getColorFromDialog())); connect(moreButton, SIGNAL(clicked()), SLOT(getColorFromDialog()));
} else { } else {
moreButton = 0; moreButton = 0;
} }
eventLoop = 0; eventLoop = 0;
@ -586,8 +586,8 @@ ColorPickerPopup::~ColorPickerPopup()
ColorPickerItem *ColorPickerPopup::find(const QColor &col) const ColorPickerItem *ColorPickerPopup::find(const QColor &col) const
{ {
for (int i = 0; i < items.size(); ++i) { for (int i = 0; i < items.size(); ++i) {
if (items.at(i) && items.at(i)->color() == col) if (items.at(i) && items.at(i)->color() == col)
return items.at(i); return items.at(i);
} }
return 0; return 0;
@ -626,7 +626,7 @@ void ColorPickerPopup::insertColor(const QColor &col, const QString &text, int i
connect(item, SIGNAL(selected()), SLOT(updateSelected())); connect(item, SIGNAL(selected()), SLOT(updateSelected()));
if (index == -1) if (index == -1)
index = items.count(); index = items.count();
items.insert((unsigned int)index, item); items.insert((unsigned int)index, item);
regenerateGrid(); regenerateGrid();
@ -667,19 +667,19 @@ void ColorPickerPopup::updateSelected()
QLayoutItem *layoutItem; QLayoutItem *layoutItem;
int i = 0; int i = 0;
while ((layoutItem = grid->itemAt(i)) != 0) { while ((layoutItem = grid->itemAt(i)) != 0) {
QWidget *w = layoutItem->widget(); QWidget *w = layoutItem->widget();
if (w && w->inherits("ColorPickerItem")) { if (w && w->inherits("ColorPickerItem")) {
ColorPickerItem *litem = reinterpret_cast<ColorPickerItem *>(layoutItem->widget()); ColorPickerItem *litem = reinterpret_cast<ColorPickerItem *>(layoutItem->widget());
if (litem != sender()) if (litem != sender())
litem->setSelected(false); litem->setSelected(false);
} }
++i; ++i;
} }
if (sender() && sender()->inherits("ColorPickerItem")) { if (sender() && sender()->inherits("ColorPickerItem")) {
ColorPickerItem *item = (ColorPickerItem *)sender(); ColorPickerItem *item = (ColorPickerItem *)sender();
lastSel = item->color(); lastSel = item->color();
emit selected(item->color()); Q_EMIT selected(item->color());
} }
hide(); hide();
@ -691,7 +691,7 @@ void ColorPickerPopup::updateSelected()
void ColorPickerPopup::mouseReleaseEvent(QMouseEvent *e) void ColorPickerPopup::mouseReleaseEvent(QMouseEvent *e)
{ {
if (!rect().contains(e->pos())) if (!rect().contains(e->pos()))
hide(); hide();
} }
/*! \internal /*! \internal
@ -705,96 +705,96 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e)
bool foundFocus = false; bool foundFocus = false;
for (int j = 0; !foundFocus && j < grid->rowCount(); ++j) { for (int j = 0; !foundFocus && j < grid->rowCount(); ++j) {
for (int i = 0; !foundFocus && i < grid->columnCount(); ++i) { for (int i = 0; !foundFocus && i < grid->columnCount(); ++i) {
if (widgetAt[j][i] && widgetAt[j][i]->hasFocus()) { if (widgetAt[j][i] && widgetAt[j][i]->hasFocus()) {
curRow = j; curRow = j;
curCol = i; curCol = i;
foundFocus = true; foundFocus = true;
break; break;
} }
} }
} }
switch (e->key()) { switch (e->key()) {
case Qt::Key_Left: case Qt::Key_Left:
if (curCol > 0) --curCol; if (curCol > 0) --curCol;
else if (curRow > 0) { --curRow; curCol = grid->columnCount() - 1; } else if (curRow > 0) { --curRow; curCol = grid->columnCount() - 1; }
break; break;
case Qt::Key_Right: case Qt::Key_Right:
if (curCol < grid->columnCount() - 1 && widgetAt[curRow][curCol + 1]) ++curCol; if (curCol < grid->columnCount() - 1 && widgetAt[curRow][curCol + 1]) ++curCol;
else if (curRow < grid->rowCount() - 1) { ++curRow; curCol = 0; } else if (curRow < grid->rowCount() - 1) { ++curRow; curCol = 0; }
break; break;
case Qt::Key_Up: case Qt::Key_Up:
if (curRow > 0) --curRow; if (curRow > 0) --curRow;
else curCol = 0; else curCol = 0;
break; break;
case Qt::Key_Down: case Qt::Key_Down:
if (curRow < grid->rowCount() - 1) { if (curRow < grid->rowCount() - 1) {
QWidget *w = widgetAt[curRow + 1][curCol]; QWidget *w = widgetAt[curRow + 1][curCol];
if (w) { if (w) {
++curRow; ++curRow;
} else for (int i = 1; i < grid->columnCount(); ++i) { } else for (int i = 1; i < grid->columnCount(); ++i) {
if (!widgetAt[curRow + 1][i]) { if (!widgetAt[curRow + 1][i]) {
curCol = i - 1; curCol = i - 1;
++curRow; ++curRow;
break; break;
} }
} }
} }
break; break;
case Qt::Key_Space: case Qt::Key_Space:
case Qt::Key_Return: case Qt::Key_Return:
case Qt::Key_Enter: { case Qt::Key_Enter: {
QWidget *w = widgetAt[curRow][curCol]; QWidget *w = widgetAt[curRow][curCol];
if (w && w->inherits("ColorPickerItem")) { if (w && w->inherits("ColorPickerItem")) {
ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w); ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w);
wi->setSelected(true); wi->setSelected(true);
QLayoutItem *layoutItem; QLayoutItem *layoutItem;
int i = 0; int i = 0;
while ((layoutItem = grid->itemAt(i)) != 0) { while ((layoutItem = grid->itemAt(i)) != 0) {
QWidget *w = layoutItem->widget(); QWidget *w = layoutItem->widget();
if (w && w->inherits("ColorPickerItem")) { if (w && w->inherits("ColorPickerItem")) {
ColorPickerItem *litem ColorPickerItem *litem
= reinterpret_cast<ColorPickerItem *>(layoutItem->widget()); = reinterpret_cast<ColorPickerItem *>(layoutItem->widget());
if (litem != wi) if (litem != wi)
litem->setSelected(false); litem->setSelected(false);
} }
++i; ++i;
} }
lastSel = wi->color(); lastSel = wi->color();
emit selected(wi->color()); Q_EMIT selected(wi->color());
hide(); hide();
} else if (w && w->inherits("QPushButton")) { } else if (w && w->inherits("QPushButton")) {
ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w); ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w);
wi->setSelected(true); wi->setSelected(true);
QLayoutItem *layoutItem; QLayoutItem *layoutItem;
int i = 0; int i = 0;
while ((layoutItem = grid->itemAt(i)) != 0) { while ((layoutItem = grid->itemAt(i)) != 0) {
QWidget *w = layoutItem->widget(); QWidget *w = layoutItem->widget();
if (w && w->inherits("ColorPickerItem")) { if (w && w->inherits("ColorPickerItem")) {
ColorPickerItem *litem ColorPickerItem *litem
= reinterpret_cast<ColorPickerItem *>(layoutItem->widget()); = reinterpret_cast<ColorPickerItem *>(layoutItem->widget());
if (litem != wi) if (litem != wi)
litem->setSelected(false); litem->setSelected(false);
} }
++i; ++i;
} }
lastSel = wi->color(); lastSel = wi->color();
emit selected(wi->color()); Q_EMIT selected(wi->color());
hide(); hide();
} }
} }
break; break;
case Qt::Key_Escape: case Qt::Key_Escape:
hide(); hide();
break; break;
default: default:
e->ignore(); e->ignore();
break; break;
} }
widgetAt[curRow][curCol]->setFocus(); widgetAt[curRow][curCol]->setFocus();
@ -806,12 +806,12 @@ void ColorPickerPopup::keyPressEvent(QKeyEvent *e)
void ColorPickerPopup::hideEvent(QHideEvent *e) void ColorPickerPopup::hideEvent(QHideEvent *e)
{ {
if (eventLoop) { if (eventLoop) {
eventLoop->exit(); eventLoop->exit();
} }
setFocus(); setFocus();
emit hid(); Q_EMIT hid();
QFrame::hideEvent(e); QFrame::hideEvent(e);
} }
@ -832,23 +832,23 @@ void ColorPickerPopup::showEvent(QShowEvent *)
{ {
bool foundSelected = false; bool foundSelected = false;
for (int i = 0; i < grid->columnCount(); ++i) { for (int i = 0; i < grid->columnCount(); ++i) {
for (int j = 0; j < grid->rowCount(); ++j) { for (int j = 0; j < grid->rowCount(); ++j) {
QWidget *w = widgetAt[j][i]; QWidget *w = widgetAt[j][i];
if (w && w->inherits("ColorPickerItem")) { if (w && w->inherits("ColorPickerItem")) {
if (((ColorPickerItem *)w)->isSelected()) { if (((ColorPickerItem *)w)->isSelected()) {
w->setFocus(); w->setFocus();
foundSelected = true; foundSelected = true;
break; break;
} }
} }
} }
} }
if (!foundSelected) { if (!foundSelected) {
if (items.count() == 0) if (items.count() == 0)
setFocus(); setFocus();
else else
widgetAt[0][0]->setFocus(); widgetAt[0][0]->setFocus();
} }
} }
@ -861,7 +861,7 @@ void ColorPickerPopup::regenerateGrid()
int columns = cols; int columns = cols;
if (columns == -1) if (columns == -1)
columns = (int) ceil(sqrt((float) items.count())); columns = (int) ceil(sqrt((float) items.count()));
// When the number of columns grows, the number of rows will // When the number of columns grows, the number of rows will
// fall. There's no way to shrink a grid, so we create a new // fall. There's no way to shrink a grid, so we create a new
@ -884,8 +884,8 @@ void ColorPickerPopup::regenerateGrid()
} }
if (moreButton) { if (moreButton) {
grid->addWidget(moreButton, crow, ccol); grid->addWidget(moreButton, crow, ccol);
widgetAt[crow][ccol] = moreButton; widgetAt[crow][ccol] = moreButton;
} }
updateGeometry(); updateGeometry();
} }
@ -901,12 +901,12 @@ void ColorPickerPopup::getColorFromDialog()
//QRgb rgb = QColorDialog::getRgba(lastSel.rgba(), &ok, parentWidget()); //QRgb rgb = QColorDialog::getRgba(lastSel.rgba(), &ok, parentWidget());
QColor col = QColorDialog::getColor(lastSel,parentWidget(),0,QColorDialog::ShowAlphaChannel); QColor col = QColorDialog::getColor(lastSel,parentWidget(),0,QColorDialog::ShowAlphaChannel);
if (!col.isValid()) if (!col.isValid())
return; return;
//QColor col = QColor::fromRgba(rgb); //QColor col = QColor::fromRgba(rgb);
insertColor(col, tr("Custom"), -1); insertColor(col, tr("Custom"), -1);
lastSel = col; lastSel = col;
emit selected(col); Q_EMIT selected(col);
} }
void ColorPickerPopup::setLastSel(const QColor & col) { lastSel = col; } void ColorPickerPopup::setLastSel(const QColor & col) { lastSel = col; }
@ -916,7 +916,7 @@ void ColorPickerPopup::setLastSel(const QColor & col) { lastSel = col; }
whose name is set to \a text. whose name is set to \a text.
*/ */
ColorPickerItem::ColorPickerItem(const QColor &color, const QString &text, ColorPickerItem::ColorPickerItem(const QColor &color, const QString &text,
QWidget *parent) QWidget *parent)
: QFrame(parent), c(color), t(text), sel(false) : QFrame(parent), c(color), t(text), sel(false)
{ {
setToolTip(t); setToolTip(t);
@ -994,7 +994,7 @@ void ColorPickerItem::mouseMoveEvent(QMouseEvent *)
void ColorPickerItem::mouseReleaseEvent(QMouseEvent *) void ColorPickerItem::mouseReleaseEvent(QMouseEvent *)
{ {
sel = true; sel = true;
emit selected(); Q_EMIT selected();
} }
/*! /*!
@ -1018,14 +1018,14 @@ void ColorPickerItem::paintEvent(QPaintEvent *)
p.setPen( QPen( Qt::gray, 0, Qt::SolidLine ) ); p.setPen( QPen( Qt::gray, 0, Qt::SolidLine ) );
if (sel) if (sel)
p.drawRect(1, 1, w - 3, h - 3); p.drawRect(1, 1, w - 3, h - 3);
p.setPen( QPen( Qt::black, 0, Qt::SolidLine ) ); p.setPen( QPen( Qt::black, 0, Qt::SolidLine ) );
p.drawRect(3, 3, w - 7, h - 7); p.drawRect(3, 3, w - 7, h - 7);
p.fillRect(QRect(4, 4, w - 8, h - 8), QBrush(c)); p.fillRect(QRect(4, 4, w - 8, h - 8), QBrush(c));
if (hasFocus()) if (hasFocus())
p.drawRect(0, 0, w - 1, h - 1); p.drawRect(0, 0, w - 1, h - 1);
} }
/*! /*!
@ -1062,7 +1062,7 @@ void ColorPickerButton::mouseReleaseEvent(QMouseEvent *)
{ {
setFrameShadow(Raised); setFrameShadow(Raised);
repaint(); repaint();
emit clicked(); Q_EMIT clicked();
} }
/*! /*!
@ -1071,15 +1071,15 @@ void ColorPickerButton::mouseReleaseEvent(QMouseEvent *)
void ColorPickerButton::keyPressEvent(QKeyEvent *e) void ColorPickerButton::keyPressEvent(QKeyEvent *e)
{ {
if (e->key() == Qt::Key_Up if (e->key() == Qt::Key_Up
|| e->key() == Qt::Key_Down || e->key() == Qt::Key_Down
|| e->key() == Qt::Key_Left || e->key() == Qt::Key_Left
|| e->key() == Qt::Key_Right) { || e->key() == Qt::Key_Right) {
qApp->sendEvent(parent(), e); qApp->sendEvent(parent(), e);
} else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space || e->key() == Qt::Key_Return) { } else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space || e->key() == Qt::Key_Return) {
setFrameShadow(Sunken); setFrameShadow(Sunken);
update(); update();
} else { } else {
QFrame::keyPressEvent(e); QFrame::keyPressEvent(e);
} }
} }
@ -1089,16 +1089,16 @@ void ColorPickerButton::keyPressEvent(QKeyEvent *e)
void ColorPickerButton::keyReleaseEvent(QKeyEvent *e) void ColorPickerButton::keyReleaseEvent(QKeyEvent *e)
{ {
if (e->key() == Qt::Key_Up if (e->key() == Qt::Key_Up
|| e->key() == Qt::Key_Down || e->key() == Qt::Key_Down
|| e->key() == Qt::Key_Left || e->key() == Qt::Key_Left
|| e->key() == Qt::Key_Right) { || e->key() == Qt::Key_Right) {
qApp->sendEvent(parent(), e); qApp->sendEvent(parent(), e);
} else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space || e->key() == Qt::Key_Return) { } else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space || e->key() == Qt::Key_Return) {
setFrameShadow(Raised); setFrameShadow(Raised);
repaint(); repaint();
emit clicked(); Q_EMIT clicked();
} else { } else {
QFrame::keyReleaseEvent(e); QFrame::keyReleaseEvent(e);
} }
} }
@ -1144,8 +1144,8 @@ void ColorPickerButton::paintEvent(QPaintEvent *e)
p.drawRect(r.center().x() + offset , r.center().y() + offset, 1, 1); p.drawRect(r.center().x() + offset , r.center().y() + offset, 1, 1);
p.drawRect(r.center().x() + offset + 4, r.center().y() + offset, 1, 1); p.drawRect(r.center().x() + offset + 4, r.center().y() + offset, 1, 1);
if (hasFocus()) { if (hasFocus()) {
p.setPen( QPen( Qt::black, 0, Qt::SolidLine ) ); p.setPen( QPen( Qt::black, 0, Qt::SolidLine ) );
p.drawRect(0, 0, width() - 1, height() - 1); p.drawRect(0, 0, width() - 1, height() - 1);
} }
p.end(); p.end();

View File

@ -182,7 +182,7 @@ void FileChooser::chooseFile()
if (!fn.isEmpty()) { if (!fn.isEmpty()) {
lineEdit->setText(fn); lineEdit->setText(fn);
emit fileNameSelected(fn); Q_EMIT fileNameSelected(fn);
} }
} }
@ -595,9 +595,9 @@ QAbstractSpinBox::StepEnabled QuantitySpinBox::stepEnabled() const
} }
return ret; return ret;
} }
void QuantitySpinBox::stepBy(int steps) void QuantitySpinBox::stepBy(int steps)
{ {
double step = StepSize * steps; double step = StepSize * steps;
double val = Value + step; double val = Value + step;
if (val > Maximum) if (val > Maximum)
@ -607,7 +607,7 @@ void QuantitySpinBox::stepBy(int steps)
lineEdit()->setText(QString::fromUtf8("%L1 %2").arg(val).arg(UnitStr)); lineEdit()->setText(QString::fromUtf8("%L1 %2").arg(val).arg(UnitStr));
update(); update();
} }
void QuantitySpinBox::setUnitText(QString str) void QuantitySpinBox::setUnitText(QString str)
{ {
@ -792,9 +792,9 @@ public:
UIntSpinBox::UIntSpinBox (QWidget* parent) UIntSpinBox::UIntSpinBox (QWidget* parent)
: QSpinBox (parent) : QSpinBox (parent)
{ {
d = new UIntSpinBoxPrivate; d = new UIntSpinBoxPrivate;
d->mValidator = new UnsignedValidator(this->minimum(), this->maximum(), this); d->mValidator = new UnsignedValidator(this->minimum(), this->maximum(), this);
connect(this, SIGNAL(valueChanged(int)), connect(this, SIGNAL(valueChanged(int)),
this, SLOT(valueChange(int))); this, SLOT(valueChange(int)));
setRange(0, 99); setRange(0, 99);
setValue(0); setValue(0);
@ -802,7 +802,7 @@ UIntSpinBox::UIntSpinBox (QWidget* parent)
} }
UIntSpinBox::~UIntSpinBox() UIntSpinBox::~UIntSpinBox()
{ {
delete d->mValidator; delete d->mValidator;
delete d; d = 0; delete d; d = 0;
} }
@ -1032,7 +1032,7 @@ void ColorButton::onChooseColor()
if ( c.isValid() ) if ( c.isValid() )
{ {
setColor( c ); setColor( c );
emit changed(); Q_EMIT changed();
} }
} }

View File

@ -153,7 +153,7 @@ void Wizard::setCurrentIndex(int index)
textLabel->setText(stackWidget->currentWidget()->windowTitle()); textLabel->setText(stackWidget->currentWidget()->windowTitle());
_backButton->setEnabled(index > 0); _backButton->setEnabled(index > 0);
_nextButton->setEnabled(index < count()-1); _nextButton->setEnabled(index < count()-1);
emit currentIndexChanged(index); Q_EMIT currentIndexChanged(index);
} }
} }
@ -171,7 +171,7 @@ void Wizard::setPageTitle(QString const &newTitle)
{ {
stackWidget->currentWidget()->setWindowTitle(newTitle); stackWidget->currentWidget()->setWindowTitle(newTitle);
textLabel->setText(newTitle); textLabel->setText(newTitle);
emit pageTitleChanged(newTitle); Q_EMIT pageTitleChanged(newTitle);
} }
WizardExtension::WizardExtension(Wizard *widget, QObject *parent) WizardExtension::WizardExtension(Wizard *widget, QObject *parent)