Qt: Make welcome dialog accessible through F1 or Help menu

Enable window close button after "I have read the Quickstart" is checked.
This commit is contained in:
Eladash 2023-06-23 19:46:00 +03:00 committed by Ivan
parent a230340578
commit 83e22fa9f0
6 changed files with 50 additions and 6 deletions

View File

@ -135,7 +135,7 @@ bool gui_application::Init()
if (m_gui_settings->GetValue(gui::ib_show_welcome).toBool())
{
welcome_dialog* welcome = new welcome_dialog(m_gui_settings);
welcome_dialog* welcome = new welcome_dialog(m_gui_settings, false);
welcome->exec();
}

View File

@ -35,6 +35,7 @@
#include "shortcut_dialog.h"
#include "system_cmd_dialog.h"
#include "emulated_pad_settings_dialog.h"
#include "welcome_dialog.h"
#include <thread>
#include <charconv>
@ -2737,6 +2738,12 @@ void main_window::CreateConnects()
m_updater.check_for_updates(false, false, false, this);
});
connect(ui->welcomeAct, &QAction::triggered, this, [this]()
{
welcome_dialog* welcome = new welcome_dialog(m_gui_settings, true, this);
welcome->open();
});
connect(ui->aboutAct, &QAction::triggered, this, [this]
{
about_dialog dlg(this);
@ -3389,3 +3396,24 @@ void main_window::dragLeaveEvent(QDragLeaveEvent* event)
{
event->accept();
}
void main_window::keyPressEvent(QKeyEvent* event)
{
QMainWindow::keyPressEvent(event);
if (event->isAutoRepeat() || event->modifiers())
{
return;
}
switch (event->key())
{
case Qt::Key_F1:
{
welcome_dialog* welcome = new welcome_dialog(m_gui_settings, true, this);
welcome->open();
break;
}
default: break;
}
}

View File

@ -135,6 +135,7 @@ protected:
void dragEnterEvent(QDragEnterEvent* event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
void dragLeaveEvent(QDragLeaveEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
private:
void ConfigureGuiFromSettings();

View File

@ -366,6 +366,7 @@
<addaction name="languageAct0"/>
</widget>
<addaction name="updateAct"/>
<addaction name="welcomeAct"/>
<addaction name="separator"/>
<addaction name="languageMenu"/>
<addaction name="separator"/>
@ -748,6 +749,11 @@
<string>Check for Updates</string>
</property>
</action>
<action name="welcomeAct">
<property name="text">
<string>View The Welcome Dialog</string>
</property>
</action>
<action name="confVFSDialogAct">
<property name="text">
<string>Virtual File System</string>

View File

@ -8,17 +8,20 @@
#include <QCheckBox>
#include <QSvgWidget>
welcome_dialog::welcome_dialog(std::shared_ptr<gui_settings> gui_settings, QWidget* parent)
welcome_dialog::welcome_dialog(std::shared_ptr<gui_settings> gui_settings, bool is_manual_show, QWidget* parent)
: QDialog(parent)
, ui(new Ui::welcome_dialog)
, m_gui_settings(std::move(gui_settings))
{
ui->setupUi(this);
setWindowFlags(windowFlags() & Qt::WindowTitleHint);
setAttribute(Qt::WA_DeleteOnClose);
ui->okay->setEnabled(false);
setWindowFlag(Qt::WindowCloseButtonHint, is_manual_show);
ui->okay->setEnabled(is_manual_show);
ui->i_have_read->setChecked(is_manual_show);
ui->i_have_read->setEnabled(!is_manual_show);
ui->do_not_show->setChecked(!m_gui_settings->GetValue(gui::ib_show_welcome).toBool());
ui->icon_label->load(QStringLiteral(":/rpcs3.svg"));
ui->label_3->setText(tr(
R"(
@ -42,9 +45,15 @@ welcome_dialog::welcome_dialog(std::shared_ptr<gui_settings> gui_settings, QWidg
)"
).arg(gui::utils::get_link_style()));
connect(ui->i_have_read, &QCheckBox::clicked, [this](bool checked)
connect(ui->i_have_read, &QCheckBox::clicked, [this, is_manual_show](bool checked)
{
if (is_manual_show)
{
return;
}
ui->okay->setEnabled(checked);
setWindowFlag(Qt::WindowCloseButtonHint, checked);
});
connect(ui->do_not_show, &QCheckBox::clicked, [this](bool checked)

View File

@ -14,7 +14,7 @@ class welcome_dialog : public QDialog
Q_OBJECT
public:
explicit welcome_dialog(std::shared_ptr<gui_settings> gui_settings, QWidget* parent = nullptr);
explicit welcome_dialog(std::shared_ptr<gui_settings> gui_settings, bool is_manual_show, QWidget* parent = nullptr);
~welcome_dialog();
private: