diff --git a/app/dialog/about/CMakeLists.txt b/app/dialog/about/CMakeLists.txt index c2c1f018c..707a0bbdc 100644 --- a/app/dialog/about/CMakeLists.txt +++ b/app/dialog/about/CMakeLists.txt @@ -16,7 +16,10 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} - dialog/about/about.h dialog/about/about.cpp + dialog/about/about.h + dialog/about/patreon.h + dialog/about/scrollinglabel.cpp + dialog/about/scrollinglabel.h PARENT_SCOPE ) diff --git a/app/dialog/about/about.cpp b/app/dialog/about/about.cpp index 46261e747..1f80589b8 100644 --- a/app/dialog/about/about.cpp +++ b/app/dialog/about/about.cpp @@ -25,6 +25,10 @@ #include #include +#include "common/qtutils.h" +#include "patreon.h" +#include "scrollinglabel.h" + namespace olive { AboutDialog::AboutDialog(QWidget *parent) : @@ -33,38 +37,58 @@ AboutDialog::AboutDialog(QWidget *parent) : setWindowTitle(tr("About %1").arg(QApplication::applicationName())); QVBoxLayout* layout = new QVBoxLayout(this); - //layout->setSpacing(20); + + layout->addWidget(new QLabel()); + + QLabel* icon = new QLabel(QStringLiteral("")); + icon->setAlignment(Qt::AlignCenter); + layout->addWidget(icon); // Construct About text QLabel* label = new QLabel(QStringLiteral("" - "

" - "

" - "" - "https://www.olivevideoeditor.org/" - "

" "

%1 %2

" // AppName (version identifier) + "

" + "https://www.olivevideoeditor.org/" + "

" "

%3

" // First statement - "

%4

" // Second statement "").arg(QApplication::applicationName(), QApplication::applicationVersion(), - tr("Olive is a non-linear video editor. This software is free and " - "protected by the GNU GPL."), - tr("Olive Team is obliged to inform users that Olive source code is " - "available for download from its website.")),this); + tr("Olive is a free open source non-linear video editor. " + "This software is licensed under the GNU GPL Version 3."))); // Set text formatting label->setAlignment(Qt::AlignCenter); - label->setTextInteractionFlags(Qt::TextSelectableByMouse); - label->setCursor(Qt::IBeamCursor); label->setWordWrap(true); + label->setOpenExternalLinks(true); + label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); layout->addWidget(label); + // Patrons where necessary + if (!patrons.isEmpty()) { + layout->addWidget(new QLabel()); + + QLabel* support_lbl = new QLabel(tr("Olive wouldn't be possible without the support of gracious " + "donations from Patreon:")); + support_lbl->setWordWrap(true); + support_lbl->setAlignment(Qt::AlignCenter); + support_lbl->setOpenExternalLinks(true); + layout->addWidget(support_lbl); + + ScrollingLabel* scroll = new ScrollingLabel(patrons); + scroll->StartAnimating(); + layout->addWidget(scroll); + } + + layout->addWidget(new QLabel()); + QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok, this); buttons->setCenterButtons(true); layout->addWidget(buttons); connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept); + + setFixedSize(sizeHint()); } } diff --git a/app/dialog/about/patreon.h b/app/dialog/about/patreon.h new file mode 100644 index 000000000..3cbc1495d --- /dev/null +++ b/app/dialog/about/patreon.h @@ -0,0 +1,8 @@ +#ifndef PATREON_H +#define PATREON_H + +#include + +QStringList patrons; + +#endif // PATREON_H diff --git a/app/dialog/about/scrollinglabel.cpp b/app/dialog/about/scrollinglabel.cpp new file mode 100644 index 000000000..2fbc5d027 --- /dev/null +++ b/app/dialog/about/scrollinglabel.cpp @@ -0,0 +1,121 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2021 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#include "scrollinglabel.h" + +#include + +#include "common/qtutils.h" + +namespace olive { + +const int ScrollingLabel::kMinLineHeight = 5; + +ScrollingLabel::ScrollingLabel(QWidget *parent) : + QWidget(parent), + animate_(0) +{ + timer_.setInterval(50); + connect(&timer_, &QTimer::timeout, this, &ScrollingLabel::AnimationUpdate); +} + +ScrollingLabel::ScrollingLabel(const QStringList &text, QWidget *parent) : + ScrollingLabel(parent) +{ + SetText(text); +} + +void ScrollingLabel::SetText(const QStringList &text) +{ + text_ = text; + + QFontMetrics fm = fontMetrics(); + text_height_ = fm.height(); + + int width = 0; + foreach (const QString& s, text_) { + width = qMax(width, QtUtils::QFontMetricsWidth(fm, s)); + } + + setMinimumSize(width, text_height_ * kMinLineHeight); +} + +void ScrollingLabel::paintEvent(QPaintEvent *e) +{ + QImage map(width(), height(), QImage::Format_RGBA8888_Premultiplied); + map.fill(Qt::transparent); + + { + QPainter p(&map); + p.setPen(palette().text().color()); + + QFontMetrics fm = p.fontMetrics(); + int half_width = width(); + + for (int i=0; i= height()) { + continue; + } + + const QString& s = text_.at(i); + + int width = QtUtils::QFontMetricsWidth(fm, s); + p.drawText(half_width/2 - width/2, text_y, s); + } + + for (int y=0; y= height() + text_.size() * text_height_) { + animate_ = 0; + } + + update(); +} + +} diff --git a/app/dialog/about/scrollinglabel.h b/app/dialog/about/scrollinglabel.h new file mode 100644 index 000000000..03394b805 --- /dev/null +++ b/app/dialog/about/scrollinglabel.h @@ -0,0 +1,71 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2021 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + +#ifndef SCROLLINGLABEL_H +#define SCROLLINGLABEL_H + +#include +#include + +namespace olive { + +class ScrollingLabel : public QWidget +{ + Q_OBJECT +public: + ScrollingLabel(QWidget* parent = nullptr); + ScrollingLabel(const QStringList& text, QWidget* parent = nullptr); + + void SetText(const QStringList& text); + + void StartAnimating() + { + timer_.start(); + } + + void StopAnimating() + { + timer_.stop(); + } + +protected: + virtual void paintEvent(QPaintEvent* e) override; + +private: + static void SetOpacityOfScanLine(uchar* scan_line, int width, int channels, double mul); + + static const int kMinLineHeight; + + QStringList text_; + + int text_height_; + + QTimer timer_; + + int animate_; + +private slots: + void AnimationUpdate(); + +}; + +} + +#endif // SCROLLINGLABEL_H