From d0e72583016639b8abf25994a109b8d27f03482c Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 23 Jul 2021 17:46:42 -0700 Subject: [PATCH] added welcome dialog --- app/config/config.cpp | 1 + app/core.cpp | 2 +- app/dialog/about/about.cpp | 69 ++++++++++++++++++++++++---- app/dialog/about/about.h | 10 +++- app/dialog/about/scrollinglabel.cpp | 2 +- app/window/mainwindow/mainwindow.cpp | 11 +++++ app/window/mainwindow/mainwindow.h | 2 + 7 files changed, 84 insertions(+), 13 deletions(-) diff --git a/app/config/config.cpp b/app/config/config.cpp index d5803a32d..688754693 100644 --- a/app/config/config.cpp +++ b/app/config/config.cpp @@ -95,6 +95,7 @@ void Config::SetDefaults() SetEntryInternal(QStringLiteral("UseGradients"), NodeValue::kBoolean, true); SetEntryInternal(QStringLiteral("AutoMergeTracks"), NodeValue::kBoolean, true); SetEntryInternal(QStringLiteral("UseSliderLadders"), NodeValue::kBoolean, true); + SetEntryInternal(QStringLiteral("ShowWelcomeDialog"), NodeValue::kBoolean, true); SetEntryInternal(QStringLiteral("AutoCacheEnabled"), NodeValue::kBoolean, true); SetEntryInternal(QStringLiteral("AutoCacheDelay"), NodeValue::kInt, 1000); diff --git a/app/core.cpp b/app/core.cpp index 0938330af..dc41884a8 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -316,7 +316,7 @@ void Core::SetSnapping(const bool &b) void Core::DialogAboutShow() { - AboutDialog a(main_window_); + AboutDialog a(false, main_window_); a.exec(); } diff --git a/app/dialog/about/about.cpp b/app/dialog/about/about.cpp index 1f80589b8..3c13440fa 100644 --- a/app/dialog/about/about.cpp +++ b/app/dialog/about/about.cpp @@ -26,23 +26,33 @@ #include #include "common/qtutils.h" +#include "config/config.h" #include "patreon.h" #include "scrollinglabel.h" namespace olive { -AboutDialog::AboutDialog(QWidget *parent) : +AboutDialog::AboutDialog(bool welcome_dialog, QWidget *parent) : QDialog(parent) { - setWindowTitle(tr("About %1").arg(QApplication::applicationName())); + if (welcome_dialog) { + setWindowTitle(tr("Welcome to %1").arg(QApplication::applicationName())); + } else { + setWindowTitle(tr("About %1").arg(QApplication::applicationName())); + } + + QFontMetrics fm = fontMetrics(); QVBoxLayout* layout = new QVBoxLayout(this); + layout->setMargin(fm.height()); - layout->addWidget(new QLabel()); + QHBoxLayout *horiz_layout = new QHBoxLayout(); + horiz_layout->setMargin(fm.height()); + horiz_layout->setSpacing(fm.height()*2); QLabel* icon = new QLabel(QStringLiteral("")); icon->setAlignment(Qt::AlignCenter); - layout->addWidget(icon); + horiz_layout->addWidget(icon); // Construct About text QLabel* label = @@ -58,18 +68,33 @@ AboutDialog::AboutDialog(QWidget *parent) : "This software is licensed under the GNU GPL Version 3."))); // Set text formatting - label->setAlignment(Qt::AlignCenter); + label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); label->setWordWrap(true); label->setOpenExternalLinks(true); label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - layout->addWidget(label); + horiz_layout->addWidget(label); + + layout->addLayout(horiz_layout); // Patrons where necessary if (!patrons.isEmpty()) { layout->addWidget(new QLabel()); + layout->addWidget(QtUtils::CreateHorizontalLine()); + layout->addWidget(new QLabel()); - QLabel* support_lbl = new QLabel(tr("Olive wouldn't be possible without the support of gracious " - "donations from Patreon:")); + QString opening_statement; + + if (welcome_dialog) { + opening_statement = tr("Olive relies on support from the community to continue its development."); + } else { + opening_statement = tr("Olive wouldn't be possible without the support of gracious donations from the following people."); + } + + QLabel* support_lbl = new QLabel(tr("%1 " + "If you like this project, please consider " + "donating or " + "pledging to " + "support its development.").arg(opening_statement)); support_lbl->setWordWrap(true); support_lbl->setAlignment(Qt::AlignCenter); support_lbl->setOpenExternalLinks(true); @@ -82,13 +107,37 @@ AboutDialog::AboutDialog(QWidget *parent) : layout->addWidget(new QLabel()); + QHBoxLayout *btn_layout = new QHBoxLayout(); + btn_layout->setMargin(0); + btn_layout->setSpacing(0); + + if (welcome_dialog) { + dont_show_again_checkbox_ = new QCheckBox(tr("Don't show this message again")); + btn_layout->addWidget(dont_show_again_checkbox_); + } else { + dont_show_again_checkbox_ = nullptr; + } + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok, this); - buttons->setCenterButtons(true); - layout->addWidget(buttons); + if (!welcome_dialog) { + buttons->setCenterButtons(true); + } + btn_layout->addWidget(buttons); + + layout->addLayout(btn_layout); connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); setFixedSize(sizeHint()); } +void AboutDialog::accept() +{ + if (dont_show_again_checkbox_ && dont_show_again_checkbox_->isChecked()) { + Config::Current()[QStringLiteral("ShowWelcomeDialog")] = false; + } + + QDialog::accept(); +} + } diff --git a/app/dialog/about/about.h b/app/dialog/about/about.h index 4fe89a6c2..cc6197f15 100644 --- a/app/dialog/about/about.h +++ b/app/dialog/about/about.h @@ -21,6 +21,7 @@ #ifndef ABOUTDIALOG_H #define ABOUTDIALOG_H +#include #include #include "common/define.h" @@ -46,7 +47,14 @@ public: * * QWidget parent object. Usually this will be MainWindow. */ - explicit AboutDialog(QWidget *parent = nullptr); + explicit AboutDialog(bool welcome_dialog, QWidget *parent = nullptr); + +public slots: + virtual void accept() override; + +private: + QCheckBox *dont_show_again_checkbox_; + }; } diff --git a/app/dialog/about/scrollinglabel.cpp b/app/dialog/about/scrollinglabel.cpp index 2fbc5d027..c7fb59b9d 100644 --- a/app/dialog/about/scrollinglabel.cpp +++ b/app/dialog/about/scrollinglabel.cpp @@ -26,7 +26,7 @@ namespace olive { -const int ScrollingLabel::kMinLineHeight = 5; +const int ScrollingLabel::kMinLineHeight = 10; ScrollingLabel::ScrollingLabel(QWidget *parent) : QWidget(parent), diff --git a/app/window/mainwindow/mainwindow.cpp b/app/window/mainwindow/mainwindow.cpp index 7db76d1ba..7f49a1e89 100644 --- a/app/window/mainwindow/mainwindow.cpp +++ b/app/window/mainwindow/mainwindow.cpp @@ -29,6 +29,7 @@ #include #endif +#include "dialog/about/about.h" #include "mainmenu.h" #include "mainstatusbar.h" @@ -486,6 +487,14 @@ void MainWindow::ProjectPanelSelectionChanged(const QVector &nodes) } } +void MainWindow::ShowWelcomeDialog() +{ + if (Config::Current()[QStringLiteral("ShowWelcomeDialog")].toBool()) { + AboutDialog ad(true, this); + ad.exec(); + } +} + #ifdef Q_OS_LINUX void MainWindow::ShowNouveauWarning() { @@ -844,6 +853,8 @@ void MainWindow::showEvent(QShowEvent *e) } #endif + QMetaObject::invokeMethod(this, "ShowWelcomeDialog", Qt::QueuedConnection); + first_show_ = false; } } diff --git a/app/window/mainwindow/mainwindow.h b/app/window/mainwindow/mainwindow.h index 0e292571c..01f2fc432 100644 --- a/app/window/mainwindow/mainwindow.h +++ b/app/window/mainwindow/mainwindow.h @@ -196,6 +196,8 @@ private slots: void ProjectPanelSelectionChanged(const QVector &nodes); + void ShowWelcomeDialog(); + }; }