Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplified UI flow #343

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/GUI/MainWindow.cpp
Expand Up @@ -99,6 +99,7 @@ MainWindow::MainWindow()
if(!g_option_start_hidden)
show();
m_page_record->UpdateShowHide();
m_page_record->OnUpdateHotkey();

}

Expand Down Expand Up @@ -131,14 +132,30 @@ void MainWindow::SaveSettings() {

}

bool MainWindow::Validate() {
if(!m_page_output->Validate()) {
return false;
}

return true;

}

void MainWindow::closeEvent(QCloseEvent* event) {
if (g_option_systray) {
OnShowHide();
event->ignore();
return;
}

if(m_page_record->ShouldBlockClose()) {
event->ignore();
return;
}
SaveSettings();

event->accept();
QApplication::quit();
Quit();

}

void MainWindow::GoPageWelcome() {
Expand Down Expand Up @@ -178,3 +195,8 @@ void MainWindow::OnSysTrayActivated(QSystemTrayIcon::ActivationReason reason) {
OnShowHide();
}
}

void MainWindow::Quit() {
SaveSettings();
QApplication::quit();
}
4 changes: 4 additions & 0 deletions src/GUI/MainWindow.h
Expand Up @@ -59,6 +59,8 @@ class MainWindow : public QMainWindow {
void LoadSettings();
void SaveSettings();

bool Validate();

protected:
virtual void closeEvent(QCloseEvent* event) override;

Expand All @@ -80,4 +82,6 @@ public slots:
void OnShowHide();
void OnSysTrayActivated(QSystemTrayIcon::ActivationReason reason);

void Quit();

};
16 changes: 13 additions & 3 deletions src/GUI/PageOutput.cpp
Expand Up @@ -652,17 +652,27 @@ void PageOutput::OnBrowse() {
}

void PageOutput::OnContinue() {
if(!Validate()) {
return;
}

m_main_window->GoPageRecord();
}

bool PageOutput::Validate() {
QString file = GetFile();
if(file.isEmpty()) {
MessageBox(QMessageBox::Critical, this, MainWindow::WINDOW_CAPTION, tr("You did not select an output file!"), BUTTON_OK, BUTTON_OK);
return;
return false;
}
if(GetFileProtocol().isNull() && !GetSeparateFiles() && QFileInfo(file).exists()) {
if(MessageBox(QMessageBox::Warning, this, MainWindow::WINDOW_CAPTION,
tr("The file '%1' already exists. Are you sure that you want to overwrite it?").arg(QFileInfo(file).fileName()),
BUTTON_YES | BUTTON_NO, BUTTON_YES) != BUTTON_YES) {
return;
return false;
}
}
m_main_window->GoPageRecord();

return true;

}
2 changes: 2 additions & 0 deletions src/GUI/PageOutput.h
Expand Up @@ -149,6 +149,8 @@ class PageOutput : public QWidget {
QString GetVideoCodecAVName();
QString GetAudioCodecAVName();

bool Validate();

private:
unsigned int FindContainerAV(const QString& name);
unsigned int FindVideoCodecAV(const QString& name);
Expand Down
23 changes: 17 additions & 6 deletions src/GUI/PageRecord.cpp
Expand Up @@ -322,7 +322,7 @@ PageRecord::PageRecord(MainWindow* main_window)
menu->addSeparator();
m_systray_action_show_hide = menu->addAction(QString(), m_main_window, SLOT(OnShowHide()));
m_systray_action_show_hide->setIconVisibleInMenu(true);
m_systray_action_quit = menu->addAction(g_icon_quit, tr("Quit"), m_main_window, SLOT(close()));
m_systray_action_quit = menu->addAction(g_icon_quit, tr("Quit"), m_main_window, SLOT(Quit()));
m_systray_action_quit->setIconVisibleInMenu(true);
m_systray_icon->setContextMenu(menu);
} else {
Expand All @@ -332,7 +332,7 @@ PageRecord::PageRecord(MainWindow* main_window)
connect(button_cancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
connect(button_save, SIGNAL(clicked()), this, SLOT(OnSave()));
if(m_systray_icon != NULL)
connect(m_systray_icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), m_main_window, SLOT(OnSysTrayActivated(QSystemTrayIcon::ActivationReason)));
connect(m_systray_icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(OnSysTrayActivated(QSystemTrayIcon::ActivationReason)));

QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(groupbox_recording);
Expand Down Expand Up @@ -894,7 +894,8 @@ void PageRecord::UpdateInput() {
void PageRecord::UpdateSysTray() {
if(m_systray_icon == NULL)
return;
GroupEnabled({m_systray_action_start_pause, m_systray_action_cancel, m_systray_action_save}, m_page_started);
GroupEnabled({m_systray_action_start_pause}, true);
GroupEnabled({m_systray_action_cancel, m_systray_action_save}, m_page_started);
if(m_page_started && m_output_started) {
m_systray_icon->setIcon(g_icon_ssr_recording);
m_systray_action_start_pause->setIcon(g_icon_pause);
Expand Down Expand Up @@ -934,7 +935,7 @@ void PageRecord::OnUpdateHotkeyFields() {
}

void PageRecord::OnUpdateHotkey() {
if(m_page_started && IsHotkeyEnabled()) {
if(IsHotkeyEnabled()) {
unsigned int modifiers = 0;
if(IsHotkeyCtrlEnabled()) modifiers |= ControlMask;
if(IsHotkeyShiftEnabled()) modifiers |= ShiftMask;
Expand All @@ -961,13 +962,17 @@ void PageRecord::OnUpdateSoundNotifications() {
}

void PageRecord::OnRecordStartPause() {
if(!m_page_started)
return;
if(m_wait_saving)
return;
if(m_output_started) {
StopOutput(false);
} else {
if(!m_page_started) {
if(!m_main_window->Validate()) {
return;
}
m_main_window->GoPageRecord();
}
StartOutput();
}
}
Expand Down Expand Up @@ -1130,3 +1135,9 @@ void PageRecord::OnNewLogLine(Logger::enum_type type, QString string) {
m_textedit_log->verticalScrollBar()->setValue(m_textedit_log->verticalScrollBar()->maximum());

}

void PageRecord::OnSysTrayActivated(QSystemTrayIcon::ActivationReason reason) {
if(reason == QSystemTrayIcon::Trigger || reason == QSystemTrayIcon::DoubleClick) {
this->OnRecordStartPause();
}
}
1 change: 1 addition & 0 deletions src/GUI/PageRecord.h
Expand Up @@ -181,5 +181,6 @@ private slots:

void OnUpdateInformation();
void OnNewLogLine(Logger::enum_type type, QString string);
void OnSysTrayActivated(QSystemTrayIcon::ActivationReason);

};