Skip to content

Commit

Permalink
UI: adapt to new easing icons
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Nov 12, 2024
1 parent 9a57e3f commit cb2778d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 49 deletions.
8 changes: 4 additions & 4 deletions src/app/GUI/Expressions/expressiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,14 @@ bool ExpressionDialog::populateEasingPresets()
mEasingPresetsBox->clear();
mEasingPresetsBox->addItem(tr("Select preset ..."));
}
for (int i = 0; i < presets.size(); ++i) {
QFileInfo file(presets.at(i).second);
for (const auto &preset : presets) {
QFileInfo file(preset.path);
if (mEasingPresetsBox->findText(file.baseName(), Qt::MatchExactly) > -1) {
qWarning() << "expression preset already exists, skip:" << file.absoluteFilePath();
continue;
}
mEasingPresetsBox->addItem(QIcon::fromTheme("easing"),
presets.at(i).first,
mEasingPresetsBox->addItem(QIcon::fromTheme(preset.icon.isEmpty() ? "easing" : preset.icon),
preset.title,
file.absoluteFilePath());
}
return true;
Expand Down
16 changes: 10 additions & 6 deletions src/app/GUI/animationdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,23 @@ void AnimationDockWidget::generateEasingActions(QPushButton *button,
const QString easeInOutText = tr("Ease In/Out ");

const auto menu = new QMenu(this);
const auto menuIn = new QMenu(easeInText, menu);
const auto menuOut = new QMenu(easeOutText, menu);
const auto menuInOut = new QMenu(easeInOutText, menu);
const auto menuIn = new QMenu(easeInText.simplified(), menu);
const auto menuOut = new QMenu(easeOutText.simplified(), menu);
const auto menuInOut = new QMenu(easeInOutText.simplified(), menu);

menuIn->setIcon(easeIcon);
menuOut->setIcon(easeIcon);
menuInOut->setIcon(easeIcon);

const auto presets = AppSupport::getEasingPresets();
for (const auto &preset : presets) {
const auto presetAct = new QAction(easeIcon, QString(), this);
presetAct->setData(preset.second);
QString title = preset.first;
const auto presetAct = new QAction(QIcon::fromTheme(preset.icon.isEmpty() ?
"easing" :
preset.icon),
QString(),
this);
presetAct->setData(preset.path);
QString title = preset.title;
if (title.startsWith(easeInText)) {
title.replace(easeInText, "");
menuIn->addAction(presetAct);
Expand Down
8 changes: 6 additions & 2 deletions src/app/GUI/extraactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,12 @@ void MainWindow::setupMenuExtras()
const QIcon easeIcon(QIcon::fromTheme("easing"));
const auto presets = AppSupport::getEasingPresets();
for (const auto &preset : presets) {
const auto presetAct = new QAction(easeIcon, preset.second, this);
presetAct->setData(preset.first);
const auto presetAct = new QAction(QIcon::fromTheme(preset.icon.isEmpty() ?
"easing" :
preset.icon),
preset.path,
this);
presetAct->setData(preset.title);
cmdAddAction(presetAct);
connect(presetAct, &QAction::triggered,
this, [this, presetAct]() {
Expand Down
72 changes: 36 additions & 36 deletions src/core/appsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1084,42 +1084,42 @@ const AppSupport::ExpressionPreset AppSupport::readEasingPreset(const QString &f
return preset;
}

const QList<QPair<QString, QString> > AppSupport::getEasingPresets()
{
QList<QPair<QString, QString> > presets;

presets.push_back({tr("Ease In Back"), ":/easing/presets/easeInBack.js"});
presets.push_back({tr("Ease In Bounce"), ":/easing/presets/easeInBounce.js"});
presets.push_back({tr("Ease In Circ"), ":/easing/presets/easeInCirc.js"});
presets.push_back({tr("Ease In Cubic"), ":/easing/presets/easeInCubic.js"});
presets.push_back({tr("Ease In Elastic"), ":/easing/presets/easeInElastic.js"});
presets.push_back({tr("Ease In Expo"), ":/easing/presets/easeInExpo.js"});
presets.push_back({tr("Ease In Quad"), ":/easing/presets/easeInQuad.js"});
presets.push_back({tr("Ease In Quart"), ":/easing/presets/easeInQuart.js"});
presets.push_back({tr("Ease In Quint"), ":/easing/presets/easeInQuint.js"});
presets.push_back({tr("Ease In Sine"), ":/easing/presets/easeInSine.js"});

presets.push_back({tr("Ease Out Back"), ":/easing/presets/easeOutBack.js"});
presets.push_back({tr("Ease Out Bounce"), ":/easing/presets/easeOutBounce.js"});
presets.push_back({tr("Ease Out Circ"), ":/easing/presets/easeOutCirc.js"});
presets.push_back({tr("Ease Out Cubic"), ":/easing/presets/easeOutCubic.js"});
presets.push_back({tr("Ease Out Elastic"), ":/easing/presets/easeOutElastic.js"});
presets.push_back({tr("Ease Out Expo"), ":/easing/presets/easeOutExpo.js"});
presets.push_back({tr("Ease Out Quad"), ":/easing/presets/easeOutQuad.js"});
presets.push_back({tr("Ease Out Quart"), ":/easing/presets/easeOutQuart.js"});
presets.push_back({tr("Ease Out Quint"), ":/easing/presets/easeOutQuint.js"});
presets.push_back({tr("Ease Out Sine"), ":/easing/presets/easeOutSine.js"});

presets.push_back({tr("Ease In/Out Back"), ":/easing/presets/easeInOutBack.js"});
presets.push_back({tr("Ease In/Out Bounce"), ":/easing/presets/easeInOutBounce.js"});
presets.push_back({tr("Ease In/Out Circ"), ":/easing/presets/easeInOutCirc.js"});
presets.push_back({tr("Ease In/Out Cubis"), ":/easing/presets/easeInOutCubic.js"});
presets.push_back({tr("Ease In/Out Elastic"), ":/easing/presets/easeInOutElastic.js"});
presets.push_back({tr("Ease In/Out Expo"), ":/easing/presets/easeInOutExpo.js"});
presets.push_back({tr("Ease In/Out Quad"), ":/easing/presets/easeInOutQuad.js"});
presets.push_back({tr("Ease In/Out Quart"), ":/easing/presets/easeInOutQuart.js"});
presets.push_back({tr("Ease In/Out Quint"), ":/easing/presets/easeInOutQuint.js"});
presets.push_back({tr("Ease In/Out Sine"), ":/easing/presets/easeInOutSine.js"});
const QList<AppSupport::EasingPreset> AppSupport::getEasingPresets()
{
QList<EasingPreset> presets;

presets.push_back({"easing-back-in", tr("Ease In Back"), ":/easing/presets/easeInBack.js"});
presets.push_back({"easing-bounce-in", tr("Ease In Bounce"), ":/easing/presets/easeInBounce.js"});
presets.push_back({"easing-circ-in", tr("Ease In Circ"), ":/easing/presets/easeInCirc.js"});
presets.push_back({"easing-cubic-in", tr("Ease In Cubic"), ":/easing/presets/easeInCubic.js"});
presets.push_back({"easing-elastic-in", tr("Ease In Elastic"), ":/easing/presets/easeInElastic.js"});
presets.push_back({"easing-expo-in", tr("Ease In Expo"), ":/easing/presets/easeInExpo.js"});
presets.push_back({"easing-quad-in", tr("Ease In Quad"), ":/easing/presets/easeInQuad.js"});
presets.push_back({"easing-quart-in", tr("Ease In Quart"), ":/easing/presets/easeInQuart.js"});
presets.push_back({"easing-quint-in", tr("Ease In Quint"), ":/easing/presets/easeInQuint.js"});
presets.push_back({"easing-sine-in", tr("Ease In Sine"), ":/easing/presets/easeInSine.js"});

presets.push_back({"easing-back-out", tr("Ease Out Back"), ":/easing/presets/easeOutBack.js"});
presets.push_back({"easing-bounce-out", tr("Ease Out Bounce"), ":/easing/presets/easeOutBounce.js"});
presets.push_back({"easing-circ-out", tr("Ease Out Circ"), ":/easing/presets/easeOutCirc.js"});
presets.push_back({"easing-cubic-out", tr("Ease Out Cubic"), ":/easing/presets/easeOutCubic.js"});
presets.push_back({"easing-elastic-out", tr("Ease Out Elastic"), ":/easing/presets/easeOutElastic.js"});
presets.push_back({"easing-expo-out", tr("Ease Out Expo"), ":/easing/presets/easeOutExpo.js"});
presets.push_back({"easing-quad-out", tr("Ease Out Quad"), ":/easing/presets/easeOutQuad.js"});
presets.push_back({"easing-quart-out", tr("Ease Out Quart"), ":/easing/presets/easeOutQuart.js"});
presets.push_back({"easing-quint-out", tr("Ease Out Quint"), ":/easing/presets/easeOutQuint.js"});
presets.push_back({"easing-sine-out", tr("Ease Out Sine"), ":/easing/presets/easeOutSine.js"});

presets.push_back({"easing-back-in-out", tr("Ease In/Out Back"), ":/easing/presets/easeInOutBack.js"});
presets.push_back({"easing-bounce-in-out", tr("Ease In/Out Bounce"), ":/easing/presets/easeInOutBounce.js"});
presets.push_back({"easing-circ-in-out", tr("Ease In/Out Circ"), ":/easing/presets/easeInOutCirc.js"});
presets.push_back({"easing-cubic-in-out", tr("Ease In/Out Cubis"), ":/easing/presets/easeInOutCubic.js"});
presets.push_back({"easing-elastic-in-out", tr("Ease In/Out Elastic"), ":/easing/presets/easeInOutElastic.js"});
presets.push_back({"easing-expo-in-out", tr("Ease In/Out Expo"), ":/easing/presets/easeInOutExpo.js"});
presets.push_back({"easing-quad-in-out", tr("Ease In/Out Quad"), ":/easing/presets/easeInOutQuad.js"});
presets.push_back({"easing-quart-in-out", tr("Ease In/Out Quart"), ":/easing/presets/easeInOutQuart.js"});
presets.push_back({"easing-quint-in-out", tr("Ease In/Out Quint"), ":/easing/presets/easeInOutQuint.js"});
presets.push_back({"easing-sine-in-out", tr("Ease In/Out Sine"), ":/easing/presets/easeInOutSine.js"});

return presets;
}
Expand Down
8 changes: 7 additions & 1 deletion src/core/appsupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ class CORE_EXPORT AppSupport : public QObject
QString bindings;
QString script;
};
struct EasingPreset
{
QString icon;
QString title;
QString path;
};
explicit AppSupport(QObject *parent = nullptr);
static QVariant getSettings(const QString &group,
const QString &key,
Expand Down Expand Up @@ -135,7 +141,7 @@ class CORE_EXPORT AppSupport : public QObject
static void printVersion();
static void printHelp(const bool &isRenderer);
static const ExpressionPreset readEasingPreset(const QString &filename);
static const QList<QPair<QString,QString>> getEasingPresets();
static const QList<EasingPreset> getEasingPresets();
static void handlePortableFirstRun();
};

Expand Down

0 comments on commit cb2778d

Please sign in to comment.