2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2025-01-07 07:21:51 +08:00
|
|
|
// Copyright (C) 2025 Igara Studio S.A.
|
2018-02-08 01:35:12 +08:00
|
|
|
// Copyright (C) 2001-2018 David Capello
|
2015-02-12 23:16:25 +08:00
|
|
|
//
|
2016-08-27 04:02:58 +08:00
|
|
|
// This program is distributed under the terms of
|
|
|
|
// the End-User License Agreement for Aseprite.
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2012-01-06 06:45:03 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/app.h"
|
|
|
|
#include "app/commands/command.h"
|
2018-02-08 01:35:12 +08:00
|
|
|
#include "app/pref/preferences.h"
|
2014-10-29 22:58:03 +08:00
|
|
|
#include "app/ui/keyboard_shortcuts.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/main_window.h"
|
|
|
|
#include "ui/ui.h"
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-09-23 04:27:47 +08:00
|
|
|
#include "advanced_mode.xml.h"
|
|
|
|
|
2012-07-10 04:36:45 +08:00
|
|
|
#include <cstdio>
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
|
|
|
|
2012-06-18 09:02:54 +08:00
|
|
|
using namespace ui;
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
class AdvancedModeCommand : public Command {
|
2012-01-06 06:45:03 +08:00
|
|
|
public:
|
|
|
|
AdvancedModeCommand();
|
|
|
|
|
|
|
|
protected:
|
2015-10-01 03:34:43 +08:00
|
|
|
void onExecute(Context* context) override;
|
2012-01-06 06:45:03 +08:00
|
|
|
};
|
|
|
|
|
2017-12-02 02:10:21 +08:00
|
|
|
AdvancedModeCommand::AdvancedModeCommand() : Command(CommandId::AdvancedMode(), CmdUIOnlyFlag)
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedModeCommand::onExecute(Context* context)
|
|
|
|
{
|
2012-08-25 05:54:47 +08:00
|
|
|
// Switch advanced mode.
|
2016-04-23 00:19:06 +08:00
|
|
|
MainWindow* mainWindow = App::instance()->mainWindow();
|
2014-03-22 10:29:01 +08:00
|
|
|
MainWindow::Mode oldMode = mainWindow->getMode();
|
|
|
|
MainWindow::Mode newMode = oldMode;
|
|
|
|
|
|
|
|
switch (oldMode) {
|
|
|
|
case MainWindow::NormalMode: newMode = MainWindow::ContextBarAndTimelineMode; break;
|
|
|
|
case MainWindow::ContextBarAndTimelineMode: newMode = MainWindow::EditorOnlyMode; break;
|
|
|
|
case MainWindow::EditorOnlyMode: newMode = MainWindow::NormalMode; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
mainWindow->setMode(newMode);
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2018-02-08 01:35:12 +08:00
|
|
|
auto& pref = Preferences::instance();
|
|
|
|
|
2014-03-22 10:29:01 +08:00
|
|
|
if (oldMode == MainWindow::NormalMode && pref.advancedMode.showAlert()) {
|
2018-07-18 10:53:08 +08:00
|
|
|
KeyPtr key = KeyboardShortcuts::instance()->command(this->id().c_str());
|
2025-01-07 07:21:51 +08:00
|
|
|
if (!key->shortcuts().empty()) {
|
2015-09-23 04:27:47 +08:00
|
|
|
app::gen::AdvancedMode window;
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-09-23 04:27:47 +08:00
|
|
|
window.warningLabel()->setTextf("You can go back pressing \"%s\" key.",
|
2025-01-07 07:21:51 +08:00
|
|
|
key->shortcuts().front().toString().c_str());
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-09-23 04:27:47 +08:00
|
|
|
window.openWindowInForeground();
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2018-02-08 01:35:12 +08:00
|
|
|
pref.advancedMode.showAlert(!window.donotShow()->isSelected());
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Command* CommandFactory::createAdvancedModeCommand()
|
|
|
|
{
|
|
|
|
return new AdvancedModeCommand;
|
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
} // namespace app
|