change: change code style to Linux style except indent.

This commit is contained in:
Mike Solar
2025-08-03 03:09:40 +08:00
parent 65ab76edc8
commit 74f73ab3be
789 changed files with 77113 additions and 68888 deletions
+96 -83
View File
@@ -30,114 +30,127 @@
#include "patreon.h"
#include "scrollinglabel.h"
namespace olive {
AboutDialog::AboutDialog(bool welcome_dialog, QWidget *parent) :
QDialog(parent)
namespace olive
{
if (welcome_dialog) {
setWindowTitle(tr("Welcome to %1").arg(QApplication::applicationName()));
} else {
setWindowTitle(tr("About %1").arg(QApplication::applicationName()));
}
QFontMetrics fm = fontMetrics();
AboutDialog::AboutDialog(bool welcome_dialog, QWidget *parent)
: QDialog(parent)
{
if (welcome_dialog) {
setWindowTitle(
tr("Welcome to %1").arg(QApplication::applicationName()));
} else {
setWindowTitle(tr("About %1").arg(QApplication::applicationName()));
}
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(fm.height(), fm.height(), fm.height(), fm.height());
QFontMetrics fm = fontMetrics();
QHBoxLayout *horiz_layout = new QHBoxLayout();
horiz_layout->setContentsMargins(fm.height(), fm.height(), fm.height(), fm.height());
horiz_layout->setSpacing(fm.height()*2);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(fm.height(), fm.height(), fm.height(),
fm.height());
QLabel* icon = new QLabel(QStringLiteral("<html><img src=':/graphics/olive-splash.png'></html>"));
icon->setAlignment(Qt::AlignCenter);
horiz_layout->addWidget(icon);
QHBoxLayout *horiz_layout = new QHBoxLayout();
horiz_layout->setContentsMargins(fm.height(), fm.height(), fm.height(),
fm.height());
horiz_layout->setSpacing(fm.height() * 2);
// Construct About text
QLabel* label =
new QLabel(QStringLiteral("<html><head/><body>"
"<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
"</body></html>").arg(QApplication::applicationName(),
QApplication::applicationVersion(),
tr("Olive is a free open source non-linear video editor. "
"This software is licensed under the GNU GPL Version 3.")));
QLabel *icon = new QLabel(
QStringLiteral("<html><img src=':/graphics/olive-splash.png'></html>"));
icon->setAlignment(Qt::AlignCenter);
horiz_layout->addWidget(icon);
// Set text formatting
label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
label->setWordWrap(true);
label->setOpenExternalLinks(true);
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
label->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse);
label->setCursor(Qt::IBeamCursor);
horiz_layout->addWidget(label);
// Construct About text
QLabel *label = new QLabel(
QStringLiteral("<html><head/><body>"
"<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
"</body></html>")
.arg(QApplication::applicationName(),
QApplication::applicationVersion(),
tr("Olive is a free open source non-linear video editor. "
"This software is licensed under the GNU GPL Version 3.")));
layout->addLayout(horiz_layout);
// Set text formatting
label->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
label->setWordWrap(true);
label->setOpenExternalLinks(true);
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
label->setTextInteractionFlags(Qt::TextSelectableByMouse |
Qt::LinksAccessibleByMouse);
label->setCursor(Qt::IBeamCursor);
horiz_layout->addWidget(label);
// Patrons where possible
layout->addWidget(new QLabel());
layout->addLayout(horiz_layout);
QString opening_statement;
// Patrons where possible
layout->addWidget(new QLabel());
if (welcome_dialog || patrons.isEmpty()) {
opening_statement = tr("<b>Olive relies on support from the community to continue its development.</b>");
} else {
opening_statement = tr("Olive wouldn't be possible without the support of gracious donations from the following people.");
}
QString opening_statement;
QLabel* support_lbl = new QLabel(tr("<html>%1 "
"If you like this project, please consider making a "
"<a href='https://olivevideoeditor.org/donate.php'>one-time donation</a> or "
"<a href='https://www.patreon.com/olivevideoeditor'>pledging monthly</a> to "
"support its development.</html>").arg(opening_statement));
support_lbl->setWordWrap(true);
support_lbl->setAlignment(Qt::AlignCenter);
support_lbl->setOpenExternalLinks(true);
layout->addWidget(support_lbl);
if (welcome_dialog || patrons.isEmpty()) {
opening_statement = tr(
"<b>Olive relies on support from the community to continue its development.</b>");
} else {
opening_statement = tr(
"Olive wouldn't be possible without the support of gracious donations from the following people.");
}
if (!patrons.isEmpty()) {
ScrollingLabel* scroll = new ScrollingLabel(patrons);
scroll->StartAnimating();
layout->addWidget(scroll);
}
QLabel *support_lbl = new QLabel(
tr("<html>%1 "
"If you like this project, please consider making a "
"<a href='https://olivevideoeditor.org/donate.php'>one-time donation</a> or "
"<a href='https://www.patreon.com/olivevideoeditor'>pledging monthly</a> to "
"support its development.</html>")
.arg(opening_statement));
support_lbl->setWordWrap(true);
support_lbl->setAlignment(Qt::AlignCenter);
support_lbl->setOpenExternalLinks(true);
layout->addWidget(support_lbl);
layout->addWidget(new QLabel());
if (!patrons.isEmpty()) {
ScrollingLabel *scroll = new ScrollingLabel(patrons);
scroll->StartAnimating();
layout->addWidget(scroll);
}
QHBoxLayout *btn_layout = new QHBoxLayout();
btn_layout->setContentsMargins(0, 0, 0, 0);
btn_layout->setSpacing(0);
layout->addWidget(new QLabel());
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;
}
QHBoxLayout *btn_layout = new QHBoxLayout();
btn_layout->setContentsMargins(0, 0, 0, 0);
btn_layout->setSpacing(0);
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok, this);
if (!welcome_dialog) {
buttons->setCenterButtons(true);
}
btn_layout->addWidget(buttons);
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;
}
layout->addLayout(btn_layout);
QDialogButtonBox *buttons =
new QDialogButtonBox(QDialogButtonBox::Ok, this);
if (!welcome_dialog) {
buttons->setCenterButtons(true);
}
btn_layout->addWidget(buttons);
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
layout->addLayout(btn_layout);
setFixedSize(sizeHint());
connect(buttons, &QDialogButtonBox::accepted, this, &QDialog::accept);
setFixedSize(sizeHint());
}
void AboutDialog::accept()
{
if (dont_show_again_checkbox_ && dont_show_again_checkbox_->isChecked()) {
OLIVE_CONFIG("ShowWelcomeDialog") = false;
}
if (dont_show_again_checkbox_ && dont_show_again_checkbox_->isChecked()) {
OLIVE_CONFIG("ShowWelcomeDialog") = false;
}
QDialog::accept();
QDialog::accept();
}
}
+8 -9
View File
@@ -26,7 +26,8 @@
#include "common/define.h"
namespace olive {
namespace olive
{
/**
* @brief The AboutDialog class
@@ -34,11 +35,10 @@ namespace olive {
* The About dialog (accessible through Help > About). Contains license and version information. This can be run from
* anywhere
*/
class AboutDialog : public QDialog
{
Q_OBJECT
class AboutDialog : public QDialog {
Q_OBJECT
public:
/**
/**
* @brief AboutDialog Constructor
*
* Creates About dialog.
@@ -47,14 +47,13 @@ public:
*
* QWidget parent object. Usually this will be MainWindow.
*/
explicit AboutDialog(bool welcome_dialog, QWidget *parent = nullptr);
explicit AboutDialog(bool welcome_dialog, QWidget *parent = nullptr);
public slots:
virtual void accept() override;
virtual void accept() override;
private:
QCheckBox *dont_show_again_checkbox_;
QCheckBox *dont_show_again_checkbox_;
};
}
+58 -55
View File
@@ -24,98 +24,101 @@
#include "common/qtutils.h"
namespace olive {
namespace olive
{
const int ScrollingLabel::kMinLineHeight = 10;
ScrollingLabel::ScrollingLabel(QWidget *parent) :
QWidget(parent),
animate_(0)
ScrollingLabel::ScrollingLabel(QWidget *parent)
: QWidget(parent)
, animate_(0)
{
timer_.setInterval(50);
connect(&timer_, &QTimer::timeout, this, &ScrollingLabel::AnimationUpdate);
timer_.setInterval(50);
connect(&timer_, &QTimer::timeout, this, &ScrollingLabel::AnimationUpdate);
}
ScrollingLabel::ScrollingLabel(const QStringList &text, QWidget *parent) :
ScrollingLabel(parent)
ScrollingLabel::ScrollingLabel(const QStringList &text, QWidget *parent)
: ScrollingLabel(parent)
{
SetText(text);
SetText(text);
}
void ScrollingLabel::SetText(const QStringList &text)
{
text_ = text;
text_ = text;
QFontMetrics fm = fontMetrics();
text_height_ = fm.height();
QFontMetrics fm = fontMetrics();
text_height_ = fm.height();
int width = 0;
foreach (const QString& s, text_) {
width = qMax(width, QtUtils::QFontMetricsWidth(fm, s));
}
int width = 0;
foreach (const QString &s, text_) {
width = qMax(width, QtUtils::QFontMetricsWidth(fm, s));
}
setMinimumSize(width, text_height_ * kMinLineHeight);
setMinimumSize(width, text_height_ * kMinLineHeight);
}
void ScrollingLabel::paintEvent(QPaintEvent *e)
{
QImage map(width(), height(), QImage::Format_RGBA8888_Premultiplied);
map.fill(Qt::transparent);
QImage map(width(), height(), QImage::Format_RGBA8888_Premultiplied);
map.fill(Qt::transparent);
{
QPainter p(&map);
p.setPen(palette().text().color());
{
QPainter p(&map);
p.setPen(palette().text().color());
QFontMetrics fm = p.fontMetrics();
int half_width = width();
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();
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;
}
if (text_bottom < 0 || text_top >= height()) {
continue;
}
const QString& s = text_.at(i);
const QString &s = text_.at(i);
int width = QtUtils::QFontMetricsWidth(fm, s);
p.drawText(half_width/2 - width/2, text_y, s);
}
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_);
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);
}
}
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);
QPainter wp(this);
wp.drawImage(0, 0, map);
}
void ScrollingLabel::SetOpacityOfScanLine(uchar *scan_line, int width, int channels, double mul)
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 x = 0; x < width; x++) {
uchar *pixel = &scan_line[x * 4];
for (int c=0; c<channels; c++) {
pixel[c] *= mul;
}
}
for (int c = 0; c < channels; c++) {
pixel[c] *= mul;
}
}
}
void ScrollingLabel::AnimationUpdate()
{
animate_++;
animate_++;
if (animate_ >= height() + text_.size() * text_height_) {
animate_ = 0;
}
if (animate_ >= height() + text_.size() * text_height_) {
animate_ = 0;
}
update();
update();
}
}
+24 -24
View File
@@ -24,46 +24,46 @@
#include <QTimer>
#include <QWidget>
namespace olive {
class ScrollingLabel : public QWidget
namespace olive
{
Q_OBJECT
class ScrollingLabel : public QWidget {
Q_OBJECT
public:
ScrollingLabel(QWidget* parent = nullptr);
ScrollingLabel(const QStringList& text, QWidget* parent = nullptr);
ScrollingLabel(QWidget *parent = nullptr);
ScrollingLabel(const QStringList &text, QWidget *parent = nullptr);
void SetText(const QStringList& text);
void SetText(const QStringList &text);
void StartAnimating()
{
timer_.start();
}
void StartAnimating()
{
timer_.start();
}
void StopAnimating()
{
timer_.stop();
}
void StopAnimating()
{
timer_.stop();
}
protected:
virtual void paintEvent(QPaintEvent* e) override;
virtual void paintEvent(QPaintEvent *e) override;
private:
static void SetOpacityOfScanLine(uchar* scan_line, int width, int channels, double mul);
static void SetOpacityOfScanLine(uchar *scan_line, int width, int channels,
double mul);
static const int kMinLineHeight;
static const int kMinLineHeight;
QStringList text_;
QStringList text_;
int text_height_;
int text_height_;
QTimer timer_;
QTimer timer_;
int animate_;
int animate_;
private slots:
void AnimationUpdate();
void AnimationUpdate();
};
}