summaryrefslogtreecommitdiffstats
path: root/examples/widgets/desktop
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@digia.com>2012-11-23 14:27:50 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-25 01:34:07 +0100
commit4ac521354dfa575c31ecb732a0f8c1e18827c21e (patch)
tree20833a59d0c291c582332c4cc0f7e724d1c9b996 /examples/widgets/desktop
parentd5ec06be6397b807b743aa46707ff45aa9dccafa (diff)
QtBase: example code style
Change-Id: I0685f7e2c7c698a4bf288b8b1ae909167932a3fb Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'examples/widgets/desktop')
-rw-r--r--examples/widgets/desktop/screenshot/screenshot.cpp27
-rw-r--r--examples/widgets/desktop/screenshot/screenshot.h5
-rw-r--r--examples/widgets/desktop/systray/window.cpp9
3 files changed, 15 insertions, 26 deletions
diff --git a/examples/widgets/desktop/screenshot/screenshot.cpp b/examples/widgets/desktop/screenshot/screenshot.cpp
index 41f219c489..6fbbb8e32b 100644
--- a/examples/widgets/desktop/screenshot/screenshot.cpp
+++ b/examples/widgets/desktop/screenshot/screenshot.cpp
@@ -46,8 +46,7 @@
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);
@@ -73,8 +72,7 @@ void Screenshot::resizeEvent(QResizeEvent * /* event */)
{
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]
@@ -96,11 +94,10 @@ void Screenshot::saveScreenshot()
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());
}
@@ -132,9 +129,9 @@ void Screenshot::updateCheckBox()
if (delaySpinBox->value() == 0) {
hideThisWindowCheckBox->setDisabled(true);
hideThisWindowCheckBox->setChecked(false);
- }
- else
+ } else {
hideThisWindowCheckBox->setDisabled(false);
+ }
}
//! [6]
@@ -163,12 +160,8 @@ void Screenshot::createOptionsGroupBox()
//! [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;
diff --git a/examples/widgets/desktop/screenshot/screenshot.h b/examples/widgets/desktop/screenshot/screenshot.h
index 22b98415bf..5defdc6d6a 100644
--- a/examples/widgets/desktop/screenshot/screenshot.h
+++ b/examples/widgets/desktop/screenshot/screenshot.h
@@ -75,8 +75,7 @@ private slots:
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;
@@ -96,4 +95,4 @@ private:
};
//! [0]
-#endif
+#endif // SCREENSHOT_H
diff --git a/examples/widgets/desktop/systray/window.cpp b/examples/widgets/desktop/systray/window.cpp
index af56f47595..8de1f5843e 100644
--- a/examples/widgets/desktop/systray/window.cpp
+++ b/examples/widgets/desktop/systray/window.cpp
@@ -66,10 +66,8 @@ Window::Window()
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)));
@@ -129,8 +127,7 @@ void Window::iconActivated(QSystemTrayIcon::ActivationReason reason)
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();