2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
|
|
|
// Copyright (C) 2001-2015 David Capello
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License version 2 as
|
|
|
|
// published by the Free Software Foundation.
|
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"
|
2012-06-16 10:37:59 +08:00
|
|
|
#include "app/find_widget.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ini_file.h"
|
2012-06-16 10:37:59 +08:00
|
|
|
#include "app/load_widget.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
|
|
|
|
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();
|
2014-08-15 10:07:47 +08:00
|
|
|
Command* clone() const override { return new AdvancedModeCommand(*this); }
|
2012-01-06 06:45:03 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void onExecute(Context* context);
|
|
|
|
};
|
|
|
|
|
|
|
|
AdvancedModeCommand::AdvancedModeCommand()
|
|
|
|
: Command("AdvancedMode",
|
|
|
|
"Advanced Mode",
|
|
|
|
CmdUIOnlyFlag)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdvancedModeCommand::onExecute(Context* context)
|
|
|
|
{
|
2012-08-25 05:54:47 +08:00
|
|
|
// Switch advanced mode.
|
2012-07-10 00:20:58 +08:00
|
|
|
MainWindow* mainWindow = App::instance()->getMainWindow();
|
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
|
|
|
|
2014-03-22 10:29:01 +08:00
|
|
|
if (oldMode == MainWindow::NormalMode &&
|
2012-01-06 06:45:03 +08:00
|
|
|
get_config_bool("AdvancedMode", "Warning", true)) {
|
2014-10-29 22:58:03 +08:00
|
|
|
Key* key = KeyboardShortcuts::instance()->command(short_name());
|
|
|
|
if (!key->accels().empty()) {
|
2013-08-06 08:20:19 +08:00
|
|
|
base::UniquePtr<Window> window(app::load_widget<Window>("advanced_mode.xml", "advanced_mode_warning"));
|
2012-06-16 10:37:59 +08:00
|
|
|
Widget* warning_label = app::find_widget<Widget>(window, "warning_label");
|
|
|
|
Widget* donot_show = app::find_widget<Widget>(window, "donot_show");
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-10-29 22:58:03 +08:00
|
|
|
warning_label->setTextf("You can go back pressing \"%s\" key.",
|
|
|
|
key->accels().front().toString().c_str());
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2012-07-09 10:24:42 +08:00
|
|
|
window->openWindowInForeground();
|
2012-01-06 06:45:03 +08:00
|
|
|
|
|
|
|
set_config_bool("AdvancedMode", "Warning", !donot_show->isSelected());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Command* CommandFactory::createAdvancedModeCommand()
|
|
|
|
{
|
|
|
|
return new AdvancedModeCommand;
|
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
} // namespace app
|