**
****************************************************************************/
-#include "chat.h"
-#include <QtWidgets/QApplication>
-#include <QtWidgets/QMessageBox>
+#include <QApplication>
+#include <QMessageBox>
+#include "chat.h"
#include "chat_adaptor.h"
#include "chat_interface.h"
#ifndef CHAT_H
#define CHAT_H
-#include <QtCore/QStringList>
-#include <QtDBus/QtDBus>
+#include <QStringList>
+
#include "ui_chatmainwindow.h"
#include "ui_chatsetnickname.h"
NicknameDialog(QWidget *parent = 0);
};
-#endif
+#endif // CHAT_H
**
****************************************************************************/
-#include <QApplication>
-
#include "mandelbrotwidget.h"
+#include <QApplication>
+
//! [0]
int main(int argc, char *argv[])
{
**
****************************************************************************/
-#include <QtWidgets>
+#include <QPainter>
+#include <QKeyEvent>
#include <math.h>
curScale = DefaultScale;
qRegisterMetaType<QImage>("QImage");
- connect(&thread, SIGNAL(renderedImage(QImage,double)),
- this, SLOT(updatePixmap(QImage,double)));
+ connect(&thread, SIGNAL(renderedImage(QImage,double)), this, SLOT(updatePixmap(QImage,double)));
setWindowTitle(tr("Mandelbrot"));
#ifndef QT_NO_CURSOR
if (pixmap.isNull()) {
painter.setPen(Qt::white);
- painter.drawText(rect(), Qt::AlignCenter,
- tr("Rendering initial image, please wait..."));
+ painter.drawText(rect(), Qt::AlignCenter, tr("Rendering initial image, please wait..."));
//! [2] //! [3]
return;
//! [3] //! [4]
painter.setPen(Qt::NoPen);
painter.setBrush(QColor(0, 0, 0, 127));
- painter.drawRect((width() - textWidth) / 2 - 5, 0, textWidth + 10,
- metrics.lineSpacing() + 5);
+ painter.drawRect((width() - textWidth) / 2 - 5, 0, textWidth + 10, metrics.lineSpacing() + 5);
painter.setPen(Qt::white);
- painter.drawText((width() - textWidth) / 2,
- metrics.leading() + metrics.ascent(), text);
+ painter.drawText((width() - textWidth) / 2, metrics.leading() + metrics.ascent(), text);
}
//! [9]
};
//! [0]
-#endif
+#endif // MANDELBROTWIDGET_H
**
****************************************************************************/
+#include "renderthread.h"
+
#include <QtWidgets>
#include <math.h>
-#include "renderthread.h"
-
//! [0]
RenderThread::RenderThread(QObject *parent)
: QThread(parent)
RenderThread(QObject *parent = 0);
~RenderThread();
- void render(double centerX, double centerY, double scaleFactor,
- QSize resultSize);
+ void render(double centerX, double centerY, double scaleFactor, QSize resultSize);
signals:
void renderedImage(const QImage &image, double scaleFactor);
};
//! [0]
-#endif
+#endif // RENDERTHREAD_H
Screenshot::Screenshot()
{
screenshotLabel = new QLabel;
- screenshotLabel->setSizePolicy(QSizePolicy::Expanding,
- QSizePolicy::Expanding);
+ screenshotLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
screenshotLabel->setAlignment(Qt::AlignCenter);
screenshotLabel->setMinimumSize(240, 160);
{
QSize scaledSize = originalPixmap.size();
scaledSize.scale(screenshotLabel->size(), Qt::KeepAspectRatio);
- if (!screenshotLabel->pixmap()
- || scaledSize != screenshotLabel->pixmap()->size())
+ if (!screenshotLabel->pixmap() || scaledSize != screenshotLabel->pixmap()->size())
updateScreenshotLabel();
}
//! [1]
QString format = "png";
QString initialPath = QDir::currentPath() + tr("/untitled.") + format;
- QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
- initialPath,
- tr("%1 Files (*.%2);;All Files (*)")
- .arg(format.toUpper())
- .arg(format));
+ QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), initialPath,
+ tr("%1 Files (*.%2);;All Files (*)")
+ .arg(format.toUpper())
+ .arg(format));
if (!fileName.isEmpty())
originalPixmap.save(fileName, format.toLatin1().constData());
}
if (delaySpinBox->value() == 0) {
hideThisWindowCheckBox->setDisabled(true);
hideThisWindowCheckBox->setChecked(false);
- }
- else
+ } else {
hideThisWindowCheckBox->setDisabled(false);
+ }
}
//! [6]
//! [8]
void Screenshot::createButtonsLayout()
{
- newScreenshotButton = createButton(tr("New Screenshot"),
- this, SLOT(newScreenshot()));
-
- saveScreenshotButton = createButton(tr("Save Screenshot"),
- this, SLOT(saveScreenshot()));
-
+ newScreenshotButton = createButton(tr("New Screenshot"), this, SLOT(newScreenshot()));
+ saveScreenshotButton = createButton(tr("Save Screenshot"), this, SLOT(saveScreenshot()));
quitScreenshotButton = createButton(tr("Quit"), this, SLOT(close()));
buttonsLayout = new QHBoxLayout;
private:
void createOptionsGroupBox();
void createButtonsLayout();
- QPushButton *createButton(const QString &text, QWidget *receiver,
- const char *member);
+ QPushButton *createButton(const QString &text, QWidget *receiver, const char *member);
void updateScreenshotLabel();
QPixmap originalPixmap;
};
//! [0]
-#endif
+#endif // SCREENSHOT_H
createTrayIcon();
connect(showMessageButton, SIGNAL(clicked()), this, SLOT(showMessage()));
- connect(showIconCheckBox, SIGNAL(toggled(bool)),
- trayIcon, SLOT(setVisible(bool)));
- connect(iconComboBox, SIGNAL(currentIndexChanged(int)),
- this, SLOT(setIcon(int)));
+ connect(showIconCheckBox, SIGNAL(toggled(bool)), trayIcon, SLOT(setVisible(bool)));
+ connect(iconComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setIcon(int)));
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
switch (reason) {
case QSystemTrayIcon::Trigger:
case QSystemTrayIcon::DoubleClick:
- iconComboBox->setCurrentIndex((iconComboBox->currentIndex() + 1)
- % iconComboBox->count());
+ iconComboBox->setCurrentIndex((iconComboBox->currentIndex() + 1) % iconComboBox->count());
break;
case QSystemTrayIcon::MiddleClick:
showMessage();
child->setPixmap(tempPixmap);
- if (drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction)
+ if (drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction) {
child->close();
- else {
+ } else {
child->show();
child->setPixmap(pixmap);
}
class DragWidget : public QFrame
{
public:
- DragWidget(QWidget *parent=0);
+ DragWidget(QWidget *parent = 0);
protected:
void dragEnterEvent(QDragEnterEvent *event);
};
//! [0]
-#endif
+#endif // DRAGWIDGET_H
#include <QApplication>
#include <QHBoxLayout>
+
#include "dragwidget.h"
int main(int argc, char *argv[])
**
****************************************************************************/
-#include <QtWidgets>
-
#include "draglabel.h"
DragLabel::DragLabel(const QString &text, QWidget *parent)
DragLabel(const QString &text, QWidget *parent);
};
-#endif
+#endif // DRAGLABEL_H
QMimeData *mimeData = new QMimeData;
mimeData->setText(child->text());
mimeData->setData("application/x-hotspot",
- QByteArray::number(hotSpot.x())
- + " " + QByteArray::number(hotSpot.y()));
+ QByteArray::number(hotSpot.x()) + " " + QByteArray::number(hotSpot.y()));
QPixmap pixmap(child->size());
child->render(&pixmap);
void mousePressEvent(QMouseEvent *event);
};
-#endif
+#endif // DRAGWIDGET_H
****************************************************************************/
#include <QApplication>
+
#include "dragwidget.h"
int main(int argc, char *argv[])
**
****************************************************************************/
-#include <QtWidgets>
-
#include "droparea.h"
+#include <QDragEnterEvent>
+#include <QMimeData>
+
//! [DropArea constructor]
DropArea::DropArea(QWidget *parent)
: QLabel(parent)
};
//! [DropArea header part2]
-#endif
+#endif // DROPAREA_H
};
//! [DropSiteWindow header]
-#endif
+#endif // DROPSITEWINDOW_H
**
****************************************************************************/
-#include <QtWidgets>
-
#include "draglabel.h"
+#include <QtWidgets>
+
//! [0]
DragLabel::DragLabel(const QString &text, QWidget *parent)
: QLabel(parent)
QFontMetrics metric(font());
QSize size = metric.size(Qt::TextSingleLine, text);
- QImage image(size.width() + 12, size.height() + 12,
- QImage::Format_ARGB32_Premultiplied);
+ QImage image(size.width() + 12, size.height() + 12, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(0, 0, 0, 0));
QFont font;
};
//! [0]
-#endif
+#endif // DRAGLABEL_H
**
****************************************************************************/
-#include <QtWidgets>
-
#include "draglabel.h"
#include "dragwidget.h"
+#include <QtWidgets>
+
//! [0]
DragWidget::DragWidget(QWidget *parent)
: QWidget(parent)
};
//! [0]
-#endif
+#endif // DRAGWIDGET_H
****************************************************************************/
#include <QApplication>
+
#include "dragwidget.h"
int main(int argc, char *argv[])
**
****************************************************************************/
-#include <QtWidgets>
-#include <stdlib.h>
-
#include "mainwindow.h"
#include "pieceslist.h"
#include "puzzlewidget.h"
+#include <QtWidgets>
+#include <stdlib.h>
+
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
{
QString fileName = path;
- if (fileName.isNull())
+ if (fileName.isNull()) {
fileName = QFileDialog::getOpenFileName(this,
tr("Open Image"), "", "Image Files (*.png *.jpg *.bmp)");
+ }
if (!fileName.isEmpty()) {
QPixmap newImage;
void MainWindow::setCompleted()
{
QMessageBox::information(this, tr("Puzzle Completed"),
- tr("Congratulations! You have completed the puzzle!\n"
- "Click OK to start again."),
- QMessageBox::Ok);
+ tr("Congratulations! You have completed the puzzle!\n"
+ "Click OK to start again."),
+ QMessageBox::Ok);
setupPuzzle();
}
PuzzleWidget *puzzleWidget;
};
-#endif
+#endif // MAINWINDOW_H
**
****************************************************************************/
-#include <QtWidgets>
-
#include "pieceslist.h"
+#include <QDrag>
+#include <QDragEnterEvent>
+#include <QMimeData>
+
PiecesList::PiecesList(int pieceSize, QWidget *parent)
: QListWidget(parent), m_PieceSize(pieceSize)
{
if (event->mimeData()->hasFormat("image/x-puzzle-piece")) {
event->setDropAction(Qt::MoveAction);
event->accept();
- } else
+ } else {
event->ignore();
+ }
}
void PiecesList::dropEvent(QDropEvent *event)
event->setDropAction(Qt::MoveAction);
event->accept();
- } else
+ } else {
event->ignore();
+ }
}
void PiecesList::addPiece(QPixmap pixmap, QPoint location)
pieceItem->setIcon(QIcon(pixmap));
pieceItem->setData(Qt::UserRole, QVariant(pixmap));
pieceItem->setData(Qt::UserRole+1, location);
- pieceItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable
- | Qt::ItemIsDragEnabled);
+ pieceItem->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled);
}
void PiecesList::startDrag(Qt::DropActions /*supportedActions*/)
int m_PieceSize;
};
-#endif
+#endif // PIECESLIST_H
**
****************************************************************************/
-#include <QtWidgets>
-
#include "puzzlewidget.h"
+#include <QDrag>
+#include <QDragEnterEvent>
+#include <QMimeData>
+#include <QPainter>
+
PuzzleWidget::PuzzleWidget(int imageSize, QWidget *parent)
: QWidget(parent), m_ImageSize(imageSize)
{
int PuzzleWidget::findPiece(const QRect &pieceRect) const
{
for (int i = 0; i < pieceRects.size(); ++i) {
- if (pieceRect == pieceRects[i]) {
+ if (pieceRect == pieceRects[i])
return i;
- }
}
return -1;
}
painter.drawRect(highlightedRect.adjusted(0, 0, -1, -1));
}
- for (int i = 0; i < pieceRects.size(); ++i) {
+ for (int i = 0; i < pieceRects.size(); ++i)
painter.drawPixmap(pieceRects[i], piecePixmaps[i]);
- }
painter.end();
}
int m_ImageSize;
};
-#endif
+#endif // PUZZLEWIDGET_H