|
|
@@ -10,47 +10,8 @@
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
-struct TimerData {
|
|
|
- int streamTimerHours = 0;
|
|
|
- int streamTimerMinutes = 0;
|
|
|
- int streamTimerSeconds = 0;
|
|
|
- int streamTimerTotal = 0;
|
|
|
-
|
|
|
- int recordTimerHours = 0;
|
|
|
- int recordTimerMinutes = 0;
|
|
|
- int recordTimerSeconds = 0;
|
|
|
- int recordTimerTotal = 0;
|
|
|
-
|
|
|
- int streamTimerDisplay = 0;
|
|
|
- int recordTimerDisplay = 0;
|
|
|
-
|
|
|
- int secondsStream = 0;
|
|
|
- int totalMinutesStream = 0;
|
|
|
- int minutesStream = 0;
|
|
|
- int hoursStream = 0;
|
|
|
-
|
|
|
- int secondsRecord = 0;
|
|
|
- int totalMinutesRecord = 0;
|
|
|
- int minutesRecord = 0;
|
|
|
- int hoursRecord = 0;
|
|
|
-
|
|
|
- bool streamButtonClicked = false;
|
|
|
- bool recordButtonClicked = false;
|
|
|
-
|
|
|
- QTimer *streamingTimer;
|
|
|
- QTimer *recordingTimer;
|
|
|
- QTimer *streamingTimerDisplay;
|
|
|
- QTimer *recordingTimerDisplay;
|
|
|
-
|
|
|
- QString textStream;
|
|
|
- QString textRecord;
|
|
|
-};
|
|
|
-
|
|
|
-QMainWindow *window;
|
|
|
OutputTimer *ot;
|
|
|
|
|
|
-static TimerData *timer = nullptr;
|
|
|
-
|
|
|
OutputTimer::OutputTimer(QWidget *parent)
|
|
|
: QDialog(parent),
|
|
|
ui(new Ui_OutputTimer)
|
|
|
@@ -61,6 +22,12 @@ OutputTimer::OutputTimer(QWidget *parent)
|
|
|
SLOT(StreamingTimerButton()));
|
|
|
QObject::connect(ui->outputTimerRecord, SIGNAL(clicked()), this,
|
|
|
SLOT(RecordingTimerButton()));
|
|
|
+
|
|
|
+ streamingTimer = new QTimer(this);
|
|
|
+ streamingTimerDisplay = new QTimer(this);
|
|
|
+
|
|
|
+ recordingTimer = new QTimer(this);
|
|
|
+ recordingTimerDisplay = new QTimer(this);
|
|
|
}
|
|
|
|
|
|
void OutputTimer::closeEvent(QCloseEvent*)
|
|
|
@@ -86,92 +53,86 @@ void OutputTimer::RecordingTimerButton()
|
|
|
|
|
|
void OutputTimer::StreamTimerStart()
|
|
|
{
|
|
|
- timer->streamingTimer = new QTimer(this);
|
|
|
- timer->streamingTimerDisplay = new QTimer(this);
|
|
|
-
|
|
|
if (!isVisible()) {
|
|
|
ui->outputTimerStream->setEnabled(false);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- timer->streamTimerHours = ui->streamingTimerHours->value();
|
|
|
- timer->streamTimerMinutes = ui->streamingTimerMinutes->value();
|
|
|
- timer->streamTimerSeconds = ui->streamingTimerSeconds->value();
|
|
|
-
|
|
|
- timer->streamTimerTotal = (((timer->streamTimerHours * 3600) +
|
|
|
- (timer->streamTimerMinutes * 60)) +
|
|
|
- timer->streamTimerSeconds) * 1000;
|
|
|
+ int hours = ui->streamingTimerHours->value();
|
|
|
+ int minutes = ui->streamingTimerMinutes->value();
|
|
|
+ int seconds = ui->streamingTimerSeconds->value();
|
|
|
|
|
|
- if (timer->streamTimerTotal == 0)
|
|
|
- timer->streamTimerTotal = 1000;
|
|
|
+ int total = (((hours * 3600) +
|
|
|
+ (minutes * 60)) +
|
|
|
+ seconds) * 1000;
|
|
|
|
|
|
- timer->streamTimerDisplay = timer->streamTimerTotal / 1000;
|
|
|
+ if (total == 0)
|
|
|
+ total = 1000;
|
|
|
|
|
|
- timer->streamingTimer->setInterval(timer->streamTimerTotal);
|
|
|
- timer->streamingTimer->setSingleShot(true);
|
|
|
+ streamingTimer->setInterval(total);
|
|
|
+ streamingTimer->setSingleShot(true);
|
|
|
|
|
|
- QObject::connect(timer->streamingTimer, SIGNAL(timeout()),
|
|
|
+ QObject::connect(streamingTimer, SIGNAL(timeout()),
|
|
|
SLOT(EventStopStreaming()));
|
|
|
|
|
|
- QObject::connect(timer->streamingTimerDisplay, SIGNAL(timeout()), this,
|
|
|
+ QObject::connect(streamingTimerDisplay, SIGNAL(timeout()), this,
|
|
|
SLOT(UpdateStreamTimerDisplay()));
|
|
|
|
|
|
- timer->streamingTimer->start();
|
|
|
- timer->streamingTimerDisplay->start(1000);
|
|
|
+ streamingTimer->start();
|
|
|
+ streamingTimerDisplay->start(1000);
|
|
|
ui->outputTimerStream->setText(tr("Stop"));
|
|
|
+
|
|
|
+ UpdateStreamTimerDisplay();
|
|
|
}
|
|
|
|
|
|
void OutputTimer::RecordTimerStart()
|
|
|
{
|
|
|
- timer->recordingTimer = new QTimer(this);
|
|
|
- timer->recordingTimerDisplay = new QTimer(this);
|
|
|
-
|
|
|
if (!isVisible()) {
|
|
|
ui->outputTimerRecord->setEnabled(false);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- timer->recordTimerHours = ui->recordingTimerHours->value();
|
|
|
- timer->recordTimerMinutes = ui->recordingTimerMinutes->value();
|
|
|
- timer->recordTimerSeconds = ui->recordingTimerSeconds->value();
|
|
|
-
|
|
|
- timer->recordTimerTotal = (((timer->recordTimerHours * 3600) +
|
|
|
- (timer->recordTimerMinutes * 60)) +
|
|
|
- timer->recordTimerSeconds) * 1000;
|
|
|
+ int hours = ui->recordingTimerHours->value();
|
|
|
+ int minutes = ui->recordingTimerMinutes->value();
|
|
|
+ int seconds = ui->recordingTimerSeconds->value();
|
|
|
|
|
|
- if (timer->recordTimerTotal == 0)
|
|
|
- timer->recordTimerTotal = 1000;
|
|
|
+ int total = (((hours * 3600) +
|
|
|
+ (minutes * 60)) +
|
|
|
+ seconds) * 1000;
|
|
|
|
|
|
- timer->recordTimerDisplay = timer->recordTimerTotal / 1000;
|
|
|
+ if (total == 0)
|
|
|
+ total = 1000;
|
|
|
|
|
|
- timer->recordingTimer->setInterval(timer->recordTimerTotal);
|
|
|
- timer->recordingTimer->setSingleShot(true);
|
|
|
+ recordingTimer->setInterval(total);
|
|
|
+ recordingTimer->setSingleShot(true);
|
|
|
|
|
|
- QObject::connect(timer->recordingTimer, SIGNAL(timeout()),
|
|
|
+ QObject::connect(recordingTimer, SIGNAL(timeout()),
|
|
|
SLOT(EventStopRecording()));
|
|
|
|
|
|
- QObject::connect(timer->recordingTimerDisplay, SIGNAL(timeout()), this,
|
|
|
+ QObject::connect(recordingTimerDisplay, SIGNAL(timeout()), this,
|
|
|
SLOT(UpdateRecordTimerDisplay()));
|
|
|
|
|
|
- timer->recordingTimer->start();
|
|
|
- timer->recordingTimerDisplay->start(1000);
|
|
|
+ recordingTimer->start();
|
|
|
+ recordingTimerDisplay->start(1000);
|
|
|
ui->outputTimerRecord->setText(tr("Stop"));
|
|
|
+
|
|
|
+ UpdateRecordTimerDisplay();
|
|
|
}
|
|
|
|
|
|
void OutputTimer::StreamTimerStop()
|
|
|
{
|
|
|
ui->outputTimerStream->setEnabled(true);
|
|
|
|
|
|
- if (!isVisible() && timer->streamingTimer->isActive() == false)
|
|
|
+ if (!isVisible() && streamingTimer->isActive() == false)
|
|
|
return;
|
|
|
|
|
|
- if (timer->streamingTimer->isActive())
|
|
|
- timer->streamingTimer->stop();
|
|
|
+ if (streamingTimer->isActive())
|
|
|
+ streamingTimer->stop();
|
|
|
|
|
|
ui->outputTimerStream->setText(tr("Start"));
|
|
|
|
|
|
- if (timer->streamingTimerDisplay->isActive())
|
|
|
- timer->streamingTimerDisplay->stop();
|
|
|
+ if (streamingTimerDisplay->isActive())
|
|
|
+ streamingTimerDisplay->stop();
|
|
|
|
|
|
ui->streamTime->setText("00:00:00");
|
|
|
}
|
|
|
@@ -180,46 +141,44 @@ void OutputTimer::RecordTimerStop()
|
|
|
{
|
|
|
ui->outputTimerRecord->setEnabled(true);
|
|
|
|
|
|
- if (!isVisible() && timer->recordingTimer->isActive() == false)
|
|
|
+ if (!isVisible() && recordingTimer->isActive() == false)
|
|
|
return;
|
|
|
|
|
|
- if (timer->recordingTimer->isActive())
|
|
|
- timer->recordingTimer->stop();
|
|
|
+ if (recordingTimer->isActive())
|
|
|
+ recordingTimer->stop();
|
|
|
|
|
|
ui->outputTimerRecord->setText(tr("Start"));
|
|
|
|
|
|
- if (timer->recordingTimerDisplay->isActive())
|
|
|
- timer->recordingTimerDisplay->stop();
|
|
|
+ if (recordingTimerDisplay->isActive())
|
|
|
+ recordingTimerDisplay->stop();
|
|
|
|
|
|
ui->recordTime->setText("00:00:00");
|
|
|
}
|
|
|
|
|
|
void OutputTimer::UpdateStreamTimerDisplay()
|
|
|
{
|
|
|
- timer->streamTimerDisplay--;
|
|
|
+ int remainingTime = streamingTimer->remainingTime() / 1000;
|
|
|
|
|
|
- timer->secondsStream = timer->streamTimerDisplay % 60;
|
|
|
- timer->totalMinutesStream = timer->streamTimerDisplay / 60;
|
|
|
- timer->minutesStream = timer->totalMinutesStream % 60;
|
|
|
- timer->hoursStream = timer->totalMinutesStream / 60;
|
|
|
+ int seconds = remainingTime % 60;
|
|
|
+ int minutes = (remainingTime % 3600) / 60;
|
|
|
+ int hours = remainingTime / 3600;
|
|
|
|
|
|
- timer->textStream.sprintf("%02d:%02d:%02d",
|
|
|
- timer->hoursStream, timer->minutesStream, timer->secondsStream);
|
|
|
- ui->streamTime->setText(timer->textStream);
|
|
|
+ QString text;
|
|
|
+ text.sprintf("%02d:%02d:%02d", hours, minutes, seconds);
|
|
|
+ ui->streamTime->setText(text);
|
|
|
}
|
|
|
|
|
|
void OutputTimer::UpdateRecordTimerDisplay()
|
|
|
{
|
|
|
- timer->recordTimerDisplay--;
|
|
|
+ int remainingTime = recordingTimer->remainingTime() / 1000;
|
|
|
|
|
|
- timer->secondsRecord = timer->recordTimerDisplay % 60;
|
|
|
- timer->totalMinutesRecord = timer->recordTimerDisplay / 60;
|
|
|
- timer->minutesRecord = timer->totalMinutesRecord % 60;
|
|
|
- timer->hoursRecord = timer->totalMinutesRecord / 60;
|
|
|
+ int seconds = remainingTime % 60;
|
|
|
+ int minutes = (remainingTime % 3600) / 60;
|
|
|
+ int hours = remainingTime / 3600;
|
|
|
|
|
|
- timer->textRecord.sprintf("%02d:%02d:%02d",
|
|
|
- timer->hoursRecord, timer->minutesRecord, timer->secondsRecord);
|
|
|
- ui->recordTime->setText(timer->textRecord);
|
|
|
+ QString text;
|
|
|
+ text.sprintf("%02d:%02d:%02d", hours, minutes, seconds);
|
|
|
+ ui->recordTime->setText(text);
|
|
|
}
|
|
|
|
|
|
void OutputTimer::ShowHideDialog()
|
|
|
@@ -292,8 +251,6 @@ static void SaveOutputTimer(obs_data_t *save_data, bool saving, void *)
|
|
|
|
|
|
extern "C" void FreeOutputTimer()
|
|
|
{
|
|
|
- delete timer;
|
|
|
- timer = nullptr;
|
|
|
}
|
|
|
|
|
|
static void OBSEvent(enum obs_frontend_event event, void *)
|
|
|
@@ -317,11 +274,9 @@ extern "C" void InitOutputTimer()
|
|
|
QAction *action = (QAction*)obs_frontend_add_tools_menu_qaction(
|
|
|
obs_module_text("OutputTimer"));
|
|
|
|
|
|
- timer = new TimerData;
|
|
|
-
|
|
|
obs_frontend_push_ui_translation(obs_module_get_string);
|
|
|
|
|
|
- window = (QMainWindow*)obs_frontend_get_main_window();
|
|
|
+ QMainWindow *window = (QMainWindow*)obs_frontend_get_main_window();
|
|
|
|
|
|
ot = new OutputTimer(window);
|
|
|
|