From 19799d63b6d6751fd2b14ff5bf7e81ad78d2c04d Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sat, 26 Oct 2024 15:11:27 +0800 Subject: [PATCH] chore(CI): msvc build with libavif --- .github/workflows/windows.yml | 10 +++ app/shortcutedit.cpp | 129 ++++++++++++++++++++++++++++++++++ app/shortcutedit.h | 50 +++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 app/shortcutedit.cpp create mode 100644 app/shortcutedit.h diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 7599fd2..045bdeb 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -82,6 +82,16 @@ jobs: cmake ./dependencies_src/zlib -Bbuild_dependencies/zlib -DCMAKE_INSTALL_PREFIX="dependencies_bin" || goto :error cmake --build build_dependencies/zlib --config Release --target=install || goto :error curl -fsSL -o expat_src.zip https://github.com/libexpat/libexpat/archive/R_2_6_2.zip + :: ===== AOM for libavif AVI decoding support ===== + git clone -q -b v3.10.0 --depth 1 https://aomedia.googlesource.com/aom dependencies_src/aom + cmake ./dependencies_src/aom -Bbuild_dependencies/aom -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DENABLE_DOCS=OFF -DBUILD_SHARED_LIBS=ON -DAOM_TARGET_CPU=generic -DENABLE_TESTS=OFF -DENABLE_TESTDATA=OFF -DENABLE_TOOLS=OFF -DENABLE_EXAMPLES=0 || goto :error + cmake --build build_dependencies/aom --config Release --target=install || goto :error + :: ===== libavif ===== + curl -fsSL -o libavif-v1_1_1.zip https://github.com/AOMediaCodec/libavif/archive/v1.1.1.zip + 7z x libavif-v1_1_1.zip -y -o"dependencies_src" + ren .\dependencies_src\libavif-1.1.1 libavif || goto :error + cmake ./dependencies_src/libavif -DCMAKE_INSTALL_PREFIX="dependencies_bin" -DAVIF_CODEC_AOM=ON -DAVIF_LOCAL_LIBYUV=ON + cmake --build build_dependencies/libavif --config Release --target=install || goto :error :: ===== expat ===== 7z x expat_src.zip -y -o"dependencies_src" ren .\dependencies_src\libexpat-R_2_6_2 expat || goto :error diff --git a/app/shortcutedit.cpp b/app/shortcutedit.cpp new file mode 100644 index 0000000..f752b4a --- /dev/null +++ b/app/shortcutedit.cpp @@ -0,0 +1,129 @@ +#include "shortcutedit.h" + +#include +#include +#include +#include +#include +#include + +ShortcutEditor::ShortcutEditor(ShortcutEdit * shortcutEdit, QWidget * parent) + : QWidget(parent) + , m_descriptionLabel(new QLabel) + , m_shortcutEdit(shortcutEdit) + , m_shortcutLayout(new QFormLayout) +{ + Q_CHECK_PTR(m_shortcutEdit); + + QDialogButtonBox * buttons = new QDialogButtonBox(QDialogButtonBox::Apply | QDialogButtonBox::Discard); + + QVBoxLayout * layout = new QVBoxLayout(this); + layout->addWidget(m_descriptionLabel); + layout->addLayout(m_shortcutLayout); + layout->addWidget(buttons); + + connect(buttons, &QDialogButtonBox::clicked, this, [=](QAbstractButton *button){ + if ((QPushButton *)button == buttons->button(QDialogButtonBox::Apply)) { + applyShortcuts(); + } else { + reloadShortcuts(); + } + }); + + setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); + + reloadShortcuts(); +} + +ShortcutEditor::~ShortcutEditor() +{ + +} + +void ShortcutEditor::setDescription(const QString &desc) +{ + m_descriptionLabel->setText(desc); +} + +void ShortcutEditor::reloadShortcuts() +{ + if (!m_keySequenceEdits.isEmpty()) { + for (QKeySequenceEdit * keyseqEdit : m_keySequenceEdits) { + m_shortcutLayout->removeRow(keyseqEdit); + } + m_keySequenceEdits.clear(); + } + + QList shortcuts = m_shortcutEdit->shortcuts(); + shortcuts.append(QKeySequence()); + for (const QKeySequence & shortcut : shortcuts) { + QKeySequenceEdit * keyseqEdit = new QKeySequenceEdit(this); +#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) + keyseqEdit->setClearButtonEnabled(true); +#endif // QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) +#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + keyseqEdit->setMaximumSequenceLength(1); +#endif // QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) + keyseqEdit->setKeySequence(shortcut); + m_keySequenceEdits.append(keyseqEdit); + } + + for (int i = 0; i < m_keySequenceEdits.count(); i++) { + m_shortcutLayout->addRow(tr("Shortcut #%1").arg(i + 1), m_keySequenceEdits.at(i)); + } +} + +void ShortcutEditor::applyShortcuts() +{ + QList shortcuts; + for (const QKeySequenceEdit * keyseqEdit : m_keySequenceEdits) { + if (!keyseqEdit->keySequence().isEmpty()) { + shortcuts.append(keyseqEdit->keySequence()); + } + } + m_shortcutEdit->setShortcuts(shortcuts); + reloadShortcuts(); +} + +// ---------------------------------------- + +ShortcutEdit::ShortcutEdit(QWidget *parent) + : QWidget(parent) + , m_shortcutsLabel(new QLabel(this)) + , m_setShortcutButton(new QToolButton(this)) +{ + m_setShortcutButton->setText("..."); + + QHBoxLayout * layout = new QHBoxLayout(this); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(m_shortcutsLabel, 1); + layout->addWidget(m_setShortcutButton); + + connect(this, &ShortcutEdit::shortcutsChanged, this, [=](){ + QStringList shortcutTexts; + for (const QKeySequence & shortcut : m_shortcuts) { + shortcutTexts.append(shortcut.toString()); + } + m_shortcutsLabel->setText(shortcutTexts.isEmpty() ? tr("No shortcuts") : shortcutTexts.join(", ")); + m_shortcutsLabel->setDisabled(shortcutTexts.isEmpty()); + }); + + connect(m_setShortcutButton, &QToolButton::clicked, this, &ShortcutEdit::editButtonClicked); + + adjustSize(); +} + +ShortcutEdit::~ShortcutEdit() +{ +} + +QList ShortcutEdit::shortcuts() const +{ + return m_shortcuts; +} + +void ShortcutEdit::setShortcuts(const QList &shortcuts) +{ + m_shortcuts = shortcuts; + emit shortcutsChanged(); +} diff --git a/app/shortcutedit.h b/app/shortcutedit.h new file mode 100644 index 0000000..23b9c4f --- /dev/null +++ b/app/shortcutedit.h @@ -0,0 +1,50 @@ +#pragma once + +#include +#include +#include + +class QLabel; +class QFormLayout; +class QToolButton; +class QKeySequenceEdit; +class ShortcutEdit; +class ShortcutEditor : public QWidget +{ + Q_OBJECT +public: + explicit ShortcutEditor(ShortcutEdit * shortcutEdit, QWidget * parent = nullptr); + ~ShortcutEditor(); + + void setDescription(const QString & desc); + + void reloadShortcuts(); + void applyShortcuts(); + +private: + QLabel * m_descriptionLabel; + ShortcutEdit * m_shortcutEdit; + QFormLayout * m_shortcutLayout; + QList m_keySequenceEdits; +}; + +class ShortcutEdit : public QWidget +{ + Q_OBJECT + Q_PROPERTY(QList shortcuts MEMBER m_shortcuts WRITE setShortcuts NOTIFY shortcutsChanged) +public: + explicit ShortcutEdit(QWidget * parent = nullptr); + ~ShortcutEdit(); + + QList shortcuts() const; + void setShortcuts(const QList &shortcuts); + +signals: + void shortcutsChanged(); + void editButtonClicked(); + +private: + QList m_shortcuts; + QLabel * m_shortcutsLabel; + QToolButton * m_setShortcutButton; +};