aboutdialog: support patreon list
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
+37
-13
@@ -25,6 +25,10 @@
|
||||
#include <QLabel>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#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("<html><img src=':/graphics/olive-splash.png'></html>"));
|
||||
icon->setAlignment(Qt::AlignCenter);
|
||||
layout->addWidget(icon);
|
||||
|
||||
// Construct About text
|
||||
QLabel* label =
|
||||
new QLabel(QStringLiteral("<html><head/><body>"
|
||||
"<p><img src=\":/graphics/olive-splash.png\"/></p>"
|
||||
"<p><a href=\"https://www.olivevideoeditor.org/\">"
|
||||
"<span style=\" text-decoration: underline; color:#007af4;\">"
|
||||
"https://www.olivevideoeditor.org/"
|
||||
"</span></a></p>"
|
||||
"<p><b>%1</b> %2</p>" // AppName (version identifier)
|
||||
"<p><a href=\"https://www.olivevideoeditor.org/\">"
|
||||
"https://www.olivevideoeditor.org/"
|
||||
"</a></p>"
|
||||
"<p>%3</p>" // First statement
|
||||
"<p>%4</p>" // Second statement
|
||||
"</body></html>").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("<html>Olive wouldn't be possible without the support of gracious "
|
||||
"donations from <a href='https://www.patreon.com/olivevideoeditor'>Patreon</a></html>:"));
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef PATREON_H
|
||||
#define PATREON_H
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
QStringList patrons;
|
||||
|
||||
#endif // PATREON_H
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "scrollinglabel.h"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#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<text_.size(); i++) {
|
||||
int text_y = fm.ascent() + height() - animate_ + (fm.height()*i);
|
||||
int text_bottom = text_y + fm.descent();
|
||||
int text_top = text_y - fm.ascent();
|
||||
|
||||
if (text_bottom < 0 || text_top >= 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<text_height_; y++) {
|
||||
double mul = double(y)/double(text_height_);
|
||||
|
||||
SetOpacityOfScanLine(map.scanLine(y), map.width(), 4, mul);
|
||||
SetOpacityOfScanLine(map.scanLine(map.height()-1-y), map.width(), 4, mul);
|
||||
}
|
||||
}
|
||||
|
||||
QPainter wp(this);
|
||||
wp.drawImage(0, 0, map);
|
||||
}
|
||||
|
||||
void ScrollingLabel::SetOpacityOfScanLine(uchar *scan_line, int width, int channels, double mul)
|
||||
{
|
||||
for (int x=0; x<width; x++) {
|
||||
uchar* pixel = &scan_line[x*4];
|
||||
|
||||
for (int c=0; c<channels; c++) {
|
||||
pixel[c] *= mul;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScrollingLabel::AnimationUpdate()
|
||||
{
|
||||
animate_++;
|
||||
|
||||
if (animate_ >= height() + text_.size() * text_height_) {
|
||||
animate_ = 0;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SCROLLINGLABEL_H
|
||||
#define SCROLLINGLABEL_H
|
||||
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user