Skip to content

Commit

Permalink
Menu changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Jul 29, 2024
1 parent cac5e32 commit 5bc3545
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 49 deletions.
78 changes: 31 additions & 47 deletions src/app/GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ void MainWindow::setupMenuBar()
cmdAddAction(openAct);
mRecentMenu = mFileMenu->addMenu(QIcon::fromTheme("file_folder"),
tr("Open Recent", "MenuBar_File"));
mFileMenu->addSeparator();

const auto linkedAct = mFileMenu->addAction(QIcon::fromTheme("linked"),
tr("Link"),
this, &MainWindow::linkFile,
Expand Down Expand Up @@ -501,14 +501,14 @@ void MainWindow::setupMenuBar()
mToolbar->addWidget(loadToolBtn);
}

mFileMenu->addSeparator();
const auto revertAct = mFileMenu->addAction(QIcon::fromTheme("loop_back"),
tr("Revert", "MenuBar_File"),
this, &MainWindow::revert);
revertAct->setData(tr("Revert Project"));
cmdAddAction(revertAct);

mFileMenu->addSeparator();

mSaveAct = mFileMenu->addAction(QIcon::fromTheme("disk_drive"),
tr("Save", "MenuBar_File"),
this, qOverload<>(&MainWindow::saveFile),
Expand Down Expand Up @@ -573,8 +573,6 @@ void MainWindow::setupMenuBar()
closeProjectAct->setData(tr("Close Project"));
cmdAddAction(closeProjectAct);

mFileMenu->addSeparator();

const auto prefsAct = mFileMenu->addAction(QIcon::fromTheme("preferences"),
tr("Preferences", "MenuBar_Edit"), [this]() {
const auto settDial = new SettingsDialog(this);
Expand All @@ -583,8 +581,6 @@ void MainWindow::setupMenuBar()
}, QKeySequence(tr("Ctrl+P")));
cmdAddAction(prefsAct);

mFileMenu->addSeparator();

const auto quitAppAct = mFileMenu->addAction(QIcon::fromTheme("quit"),
tr("Exit", "MenuBar_File"),
this, &MainWindow::close,
Expand Down Expand Up @@ -646,8 +642,6 @@ void MainWindow::setupMenuBar()
cmdAddAction(qAct);
}

mEditMenu->addSeparator();

{
const auto qAct = new NoShortcutAction(tr("Duplicate", "MenuBar_Edit"));
mEditMenu->addAction(qAct);
Expand All @@ -656,8 +650,6 @@ void MainWindow::setupMenuBar()
cmdAddAction(qAct);
}

mEditMenu->addSeparator();

{
const auto qAct = new NoShortcutAction(tr("Delete", "MenuBar_Edit"));
mEditMenu->addAction(qAct);
Expand Down Expand Up @@ -695,8 +687,6 @@ void MainWindow::setupMenuBar()
}, QKeySequence(tr("Ctrl+R")));
cmdAddAction(clearCacheAct);

mEditMenu->addSeparator();

const auto clearRecentAct = mEditMenu->addAction(tr("Clear Recent Files"), [this]() {
mRecentFiles.clear();
writeRecentFiles();
Expand Down Expand Up @@ -908,11 +898,10 @@ void MainWindow::setupMenuBar()
cmdAddAction(qAct);
}

// mEffectsMenu = mMenuBar->addMenu("Effects");

// mEffectsMenu->addAction("Blur");

mSceneMenu = mMenuBar->addMenu(tr("Scene", "MenuBar"));
mEffectsMenu = mMenuBar->addMenu(tr("Effects"));
setupMenuEffects();

const auto newSceneAct = mSceneMenu->addAction(QIcon::fromTheme("file_new"),
tr("New Scene", "MenuBar_Scene"),
Expand All @@ -928,7 +917,10 @@ void MainWindow::setupMenuBar()
mActions.deleteSceneAction->connect(deleteSceneAct);
cmdAddAction(deleteSceneAct);


const auto scenePropAct = mSceneMenu->addAction(QIcon::fromTheme("sequence"),
tr("Scene Properties", "MenuBar_Scene"));
mActions.sceneSettingsAction->connect(scenePropAct);
cmdAddAction(scenePropAct);

mSceneMenu->addSeparator();

Expand All @@ -940,15 +932,6 @@ void MainWindow::setupMenuBar()
"F12").toString()));
cmdAddAction(mAddToQueAct);


mSceneMenu->addSeparator();


const auto scenePropAct = mSceneMenu->addAction(QIcon::fromTheme("sequence"),
tr("Scene Properties", "MenuBar_Scene"));
mActions.sceneSettingsAction->connect(scenePropAct);
cmdAddAction(scenePropAct);

if (eSettings::instance().fToolBarActionScene) {
const auto sceneToolBtn = new QToolButton(this);
sceneToolBtn->setText(tr("Scene"));
Expand Down Expand Up @@ -1242,7 +1225,6 @@ void MainWindow::setupMenuBar()
mCentralWidget, &CentralWidget::setSidesVisibilitySetting);*/


setupMenuEffects();
setupExtraMenus();

const auto help = mMenuBar->addMenu(tr("Help", "MenuBar"));
Expand Down Expand Up @@ -1301,33 +1283,15 @@ void MainWindow::setupMenuBar()

void MainWindow::setupMenuEffects()
{
const auto menu = new QMenu(this);
{ // raster
const auto adder = [this, menu](const QString& name, const QString& path,
const RasterEffectMenuCreator::EffectCreator& creator) {
if (name.isEmpty()) { return; }
QString title = name;
if (!path.isEmpty()) {
title.append(QString(" (%1 - %2)").arg(tr("Raster Effect"), path));
} else {
title.append(QString(" (%1)").arg(tr("Raster Effect")));
}
const auto act = menu->addAction(title);
cmdAddAction(act);
connect(act, &QAction::triggered, this, [this, creator]() {
addRasterEffect(creator());
});
};
RasterEffectMenuCreator::forEveryEffect(adder);
}
{ // path TODO
// adapt PathEffectsMenu::addPathEffectsToBoxActionMenu(menu);
}
{ // transform
const auto menu = mEffectsMenu->addMenu(QIcon::fromTheme("preferences"), tr("Transform Effects"));
const auto adder = [this, menu](const QString& name,
const TransformEffectMenuCreator::EffectCreator& creator) {
if (name.isEmpty()) { return; }
const auto act = menu->addAction(name);
const auto act = menu->addAction(QIcon::fromTheme("preferences"), name);
cmdAddAction(act);
connect(act, &QAction::triggered, this, [this, creator]() {
addTransformEffect(creator());
Expand All @@ -1336,17 +1300,37 @@ void MainWindow::setupMenuEffects()
TransformEffectMenuCreator::forEveryEffect(adder);
}
{ // blend
const auto menu = mEffectsMenu->addMenu(QIcon::fromTheme("preferences"), tr("Blend Effects"));
const auto adder = [this, menu](const QString& name,
const BlendEffectMenuCreator::EffectCreator& creator) {
if (name.isEmpty()) { return; }
const auto act = menu->addAction(name);
const auto act = menu->addAction(QIcon::fromTheme("preferences"), name);
cmdAddAction(act);
connect(act, &QAction::triggered, this, [this, creator]() {
addBlendEffect(creator());
});
};
BlendEffectMenuCreator::forEveryEffect(adder);
}
{ // raster
const auto menu = mEffectsMenu->addMenu(QIcon::fromTheme("preferences"), tr("Raster Effects"));
const auto adder = [this, menu](const QString& name, const QString& path,
const RasterEffectMenuCreator::EffectCreator& creator) {
if (name.isEmpty()) { return; }
QString title = name;
if (!path.isEmpty()) { title.append(QString(" (%1)").arg(path));}
const auto act = menu->addAction(QIcon::fromTheme("preferences"), title);
cmdAddAction(act);
connect(act, &QAction::triggered, this, [this, creator]() {
addRasterEffect(creator());
});
};
RasterEffectMenuCreator::forEveryEffectCore(adder);
menu->addSeparator();
RasterEffectMenuCreator::forEveryEffectCustom(adder);
RasterEffectMenuCreator::forEveryEffectShader(adder);
//RasterEffectMenuCreator::forEveryEffect(adder);
}
}

void MainWindow::addRasterEffect(const qsptr<RasterEffect> &effect)
Expand Down
7 changes: 7 additions & 0 deletions src/app/friction.qss
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,10 @@ QLabel#CommandPaletteLabel {
QLabel#CommandPaletteLabel {
padding: .5em;
}

QMenu::separator {
width: 1px;
height: 1px;
margin: 4px;
background-color: %4;
}
4 changes: 2 additions & 2 deletions src/core/BlendEffects/blendeffectmenucreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ struct CORE_EXPORT BlendEffectMenuCreator
const EffectCreator&)>;
static void forEveryEffect(const EffectAdder& add)
{
add(QObject::tr("New Move Blend Effect"),
add(QObject::tr("Add Move Blend Effect"),
[]() { return enve::make_shared<MoveBlendEffect>(); });
add(QObject::tr("New Targeted Blend Effect"),
add(QObject::tr("Add Targeted Blend Effect"),
[]() { return enve::make_shared<TargetedBlendEffect>(); });
}
};
Expand Down
15 changes: 15 additions & 0 deletions src/core/RasterEffects/rastereffectmenucreator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,29 @@
#include "ShaderEffects/shadereffect.h"

void RasterEffectMenuCreator::forEveryEffect(const EffectAdder& add) {

forEveryEffectCore(add);
forEveryEffectCustom(add);
forEveryEffectShader(add);
}

void RasterEffectMenuCreator::forEveryEffectCore(const EffectAdder &add)
{
add("Blur", "", []() { return enve::make_shared<BlurEffect>(); });
add("Shadow", "", []() { return enve::make_shared<ShadowEffect>(); });
add("Motion Blur", "", []() { return enve::make_shared<MotionBlurEffect>(); });
add("Brightness-Contrast", "Color", []() { return enve::make_shared<BrightnessContrastEffect>(); });
add("Colorize", "Color", []() { return enve::make_shared<ColorizeEffect>(); });
add("Wipe", "Transitions", []() { return enve::make_shared<WipeEffect>(); });
add("Noise Fade", "Transitions", []() { return enve::make_shared<NoiseFadeEffect>(); });
}

void RasterEffectMenuCreator::forEveryEffectCustom(const EffectAdder &add)
{
CustomRasterEffectCreator::sForEveryEffect(add);
}

void RasterEffectMenuCreator::forEveryEffectShader(const EffectAdder &add)
{
ShaderEffectCreator::sForEveryEffect(add);
}
3 changes: 3 additions & 0 deletions src/core/RasterEffects/rastereffectmenucreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ struct CORE_EXPORT RasterEffectMenuCreator {
forEveryEffect(adder);
}
static void forEveryEffect(const EffectAdder& add);
static void forEveryEffectCore(const EffectAdder& add);
static void forEveryEffectCustom(const EffectAdder& add);
static void forEveryEffectShader(const EffectAdder& add);
};

#endif // RASTEREFFECTMENUCREATOR_H

0 comments on commit 5bc3545

Please sign in to comment.