mirror of
https://github.com/QuasarApp/SoundBand.git
synced 2025-05-04 02:59:34 +00:00
control key
This commit is contained in:
parent
85f161f617
commit
77c4fa3c14
testLocalTimer
@ -2,6 +2,7 @@
|
|||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
@ -13,6 +14,19 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::keyPressEvent(QKeyEvent * key) {
|
||||||
|
|
||||||
|
if (key->key() == Qt::Key_Space) {
|
||||||
|
if (timer.isActive()) {
|
||||||
|
timer.stop();
|
||||||
|
} else {
|
||||||
|
timer.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
@ -21,15 +35,5 @@ void MainWindow::handleTick() {
|
|||||||
|
|
||||||
auto time = QDateTime::currentMSecsSinceEpoch();
|
auto time = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
|
||||||
ui->msec->setText(QString::number( time% 1000));
|
ui->msec->setText(QString::number(time));
|
||||||
|
|
||||||
if (!(time % 1000)) {
|
|
||||||
if (color == Qt::white) {
|
|
||||||
color = Qt::green;
|
|
||||||
} else {
|
|
||||||
color = Qt::white;
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->color->setStyleSheet(QString("background-color: '%0';").arg(color.name(QColor::HexRgb)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ class MainWindow : public QMainWindow
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
|
void keyPressEvent(QKeyEvent*);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -19,19 +19,21 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="msec">
|
<widget class="QLabel" name="msec">
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="color">
|
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">background-color: rgb(138, 226, 52);</string>
|
<string notr="true">font: 48pt "Ubuntu";</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="textInteractionFlags">
|
||||||
|
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user