GUI: Format code of BackgroundFlickerThread
This commit is contained in:
parent
3e81b2449f
commit
156b604c46
|
@ -1,29 +1,29 @@
|
|||
#include "BackgroundFlickerThread.h"
|
||||
#include <Windows.h>
|
||||
|
||||
BackgroundFlickerThread::BackgroundFlickerThread(QWidget* widget, QColor& background, QObject* parent) : QThread(parent), background(background)
|
||||
{
|
||||
mWidget = widget;
|
||||
setProperties();
|
||||
}
|
||||
|
||||
void BackgroundFlickerThread::setProperties(int count, int delay)
|
||||
{
|
||||
this->count = count;
|
||||
this->delay = delay;
|
||||
}
|
||||
|
||||
void BackgroundFlickerThread::run()
|
||||
{
|
||||
QColor oldColor = background;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
background = QColor(Qt::red);
|
||||
mWidget->update();
|
||||
Sleep(delay);
|
||||
|
||||
background = oldColor;
|
||||
mWidget->update();
|
||||
Sleep(delay);
|
||||
}
|
||||
}
|
||||
#include "BackgroundFlickerThread.h"
|
||||
#include <Windows.h>
|
||||
|
||||
BackgroundFlickerThread::BackgroundFlickerThread(QWidget* widget, QColor & background, QObject* parent) : QThread(parent), background(background)
|
||||
{
|
||||
mWidget = widget;
|
||||
setProperties();
|
||||
}
|
||||
|
||||
void BackgroundFlickerThread::setProperties(int count, int delay)
|
||||
{
|
||||
this->count = count;
|
||||
this->delay = delay;
|
||||
}
|
||||
|
||||
void BackgroundFlickerThread::run()
|
||||
{
|
||||
QColor oldColor = background;
|
||||
for(int i = 0; i < count; i++)
|
||||
{
|
||||
background = QColor(Qt::red);
|
||||
mWidget->update();
|
||||
Sleep(delay);
|
||||
|
||||
background = oldColor;
|
||||
mWidget->update();
|
||||
Sleep(delay);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
#ifndef BACKGROUNDFLICKERTHREAD_H
|
||||
#define BACKGROUNDFLICKERTHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QWidget>
|
||||
#include <QColor>
|
||||
|
||||
class BackgroundFlickerThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BackgroundFlickerThread(QWidget* widget, QColor& background, QObject* parent = 0);
|
||||
void setProperties(int count = 3, int delay = 300);
|
||||
|
||||
private:
|
||||
void run();
|
||||
QWidget* mWidget;
|
||||
QColor& background;
|
||||
int count;
|
||||
int delay;
|
||||
};
|
||||
|
||||
#endif // BACKGROUNDFLICKERTHREAD_H
|
||||
#ifndef BACKGROUNDFLICKERTHREAD_H
|
||||
#define BACKGROUNDFLICKERTHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QWidget>
|
||||
#include <QColor>
|
||||
|
||||
class BackgroundFlickerThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BackgroundFlickerThread(QWidget* widget, QColor & background, QObject* parent = 0);
|
||||
void setProperties(int count = 3, int delay = 300);
|
||||
|
||||
private:
|
||||
void run();
|
||||
QWidget* mWidget;
|
||||
QColor & background;
|
||||
int count;
|
||||
int delay;
|
||||
};
|
||||
|
||||
#endif // BACKGROUNDFLICKERTHREAD_H
|
||||
|
|
Loading…
Reference in New Issue