2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2020-02-06 04:50:17 +08:00
|
|
|
// Copyright (C) 2018-2020 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"
|
2019-10-11 02:08:59 +08:00
|
|
|
#include "app/cmd/set_grid_bounds.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/commands/command.h"
|
2017-06-12 23:38:53 +08:00
|
|
|
#include "app/console.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/context.h"
|
2019-10-11 02:08:59 +08:00
|
|
|
#include "app/context_access.h"
|
2017-06-11 02:02:39 +08:00
|
|
|
#include "app/extensions.h"
|
2018-02-23 21:32:02 +08:00
|
|
|
#include "app/file/file.h"
|
2017-06-12 23:38:53 +08:00
|
|
|
#include "app/file_selector.h"
|
2017-10-18 05:00:45 +08:00
|
|
|
#include "app/i18n/strings.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ini_file.h"
|
2014-06-14 10:00:49 +08:00
|
|
|
#include "app/launcher.h"
|
2019-05-08 21:55:56 +08:00
|
|
|
#include "app/modules/gui.h"
|
2014-12-15 07:19:31 +08:00
|
|
|
#include "app/pref/preferences.h"
|
2018-03-15 01:14:47 +08:00
|
|
|
#include "app/recent_files.h"
|
2014-08-20 11:11:19 +08:00
|
|
|
#include "app/resource_finder.h"
|
2019-10-11 02:08:59 +08:00
|
|
|
#include "app/tx.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/color_button.h"
|
2018-06-07 02:44:52 +08:00
|
|
|
#include "app/ui/pref_widget.h"
|
2017-07-25 02:13:32 +08:00
|
|
|
#include "app/ui/separator_in_view.h"
|
2017-02-10 00:18:44 +08:00
|
|
|
#include "app/ui/skin/skin_theme.h"
|
2012-06-16 10:37:59 +08:00
|
|
|
#include "base/bind.h"
|
2020-04-08 06:47:16 +08:00
|
|
|
#include "base/clamp.h"
|
2015-04-09 18:46:55 +08:00
|
|
|
#include "base/convert_to.h"
|
2015-09-18 23:23:02 +08:00
|
|
|
#include "base/fs.h"
|
2017-06-23 18:53:31 +08:00
|
|
|
#include "base/string.h"
|
|
|
|
#include "base/version.h"
|
2014-10-21 09:21:31 +08:00
|
|
|
#include "doc/image.h"
|
2017-10-18 05:00:45 +08:00
|
|
|
#include "fmt/format.h"
|
2018-08-09 23:58:43 +08:00
|
|
|
#include "os/display.h"
|
|
|
|
#include "os/system.h"
|
2019-05-08 21:55:56 +08:00
|
|
|
#include "render/render.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "ui/ui.h"
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-09-23 03:33:49 +08:00
|
|
|
#include "options.xml.h"
|
2014-08-10 12:12:31 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
2012-06-18 09:02:54 +08:00
|
|
|
|
2019-05-08 21:55:56 +08:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
const char* kSectionGeneralId = "section_general";
|
|
|
|
const char* kSectionBgId = "section_bg";
|
|
|
|
const char* kSectionGridId = "section_grid";
|
|
|
|
const char* kSectionThemeId = "section_theme";
|
|
|
|
const char* kSectionExtensionsId = "section_extensions";
|
2015-09-18 23:23:02 +08:00
|
|
|
|
2019-05-08 21:55:56 +08:00
|
|
|
const char* kInfiniteSymbol = "\xE2\x88\x9E"; // Infinite symbol (UTF-8)
|
2017-10-26 04:58:55 +08:00
|
|
|
|
2019-05-08 21:55:56 +08:00
|
|
|
app::gen::ColorProfileBehavior filesWithCsMap[] = {
|
2018-10-19 02:29:16 +08:00
|
|
|
app::gen::ColorProfileBehavior::DISABLE,
|
|
|
|
app::gen::ColorProfileBehavior::EMBEDDED,
|
|
|
|
app::gen::ColorProfileBehavior::CONVERT,
|
|
|
|
app::gen::ColorProfileBehavior::ASSIGN,
|
|
|
|
app::gen::ColorProfileBehavior::ASK,
|
|
|
|
};
|
|
|
|
|
2019-05-08 21:55:56 +08:00
|
|
|
app::gen::ColorProfileBehavior missingCsMap[] = {
|
2018-10-19 02:29:16 +08:00
|
|
|
app::gen::ColorProfileBehavior::DISABLE,
|
|
|
|
app::gen::ColorProfileBehavior::ASSIGN,
|
|
|
|
app::gen::ColorProfileBehavior::ASK,
|
|
|
|
};
|
|
|
|
|
2019-05-08 21:55:56 +08:00
|
|
|
} // anonymous namespace
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
using namespace ui;
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-08-10 12:12:31 +08:00
|
|
|
class OptionsWindow : public app::gen::Options {
|
2016-07-21 05:30:03 +08:00
|
|
|
|
2018-10-19 02:29:16 +08:00
|
|
|
class ColorSpaceItem : public ListItem {
|
|
|
|
public:
|
|
|
|
ColorSpaceItem(const os::ColorSpacePtr& cs)
|
|
|
|
: ListItem(cs->gfxColorSpace()->name()),
|
|
|
|
m_cs(cs) {
|
|
|
|
}
|
|
|
|
os::ColorSpacePtr cs() const { return m_cs; }
|
|
|
|
private:
|
|
|
|
os::ColorSpacePtr m_cs;
|
|
|
|
};
|
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
class ThemeItem : public ListItem {
|
|
|
|
public:
|
|
|
|
ThemeItem(const std::string& path,
|
|
|
|
const std::string& name)
|
|
|
|
: ListItem(name.empty() ? "-- " + path + " --": name),
|
|
|
|
m_path(path),
|
|
|
|
m_name(name) {
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& themePath() const { return m_path; }
|
|
|
|
const std::string& themeName() const { return m_name; }
|
|
|
|
|
|
|
|
void openFolder() const {
|
2017-06-13 22:51:49 +08:00
|
|
|
app::launcher::open_folder(m_path);
|
2016-07-21 05:30:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool canSelect() const {
|
|
|
|
return !m_name.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_path;
|
|
|
|
std::string m_name;
|
|
|
|
};
|
2017-06-11 02:02:39 +08:00
|
|
|
|
|
|
|
class ExtensionItem : public ListItem {
|
|
|
|
public:
|
|
|
|
ExtensionItem(Extension* extension)
|
|
|
|
: ListItem(extension->displayName())
|
|
|
|
, m_extension(extension) {
|
2017-06-12 23:38:53 +08:00
|
|
|
setEnabled(extension->isEnabled());
|
2017-06-11 02:02:39 +08:00
|
|
|
}
|
|
|
|
|
2017-06-23 18:53:31 +08:00
|
|
|
Extension* extension() { return m_extension; }
|
|
|
|
|
2017-06-12 23:38:53 +08:00
|
|
|
bool isEnabled() const {
|
|
|
|
ASSERT(m_extension);
|
|
|
|
return m_extension->isEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isInstalled() const {
|
|
|
|
ASSERT(m_extension);
|
|
|
|
return m_extension->isInstalled();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool canBeDisabled() const {
|
|
|
|
ASSERT(m_extension);
|
|
|
|
return m_extension->canBeDisabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool canBeUninstalled() const {
|
|
|
|
ASSERT(m_extension);
|
|
|
|
return m_extension->canBeUninstalled();
|
|
|
|
}
|
2017-06-11 02:02:39 +08:00
|
|
|
|
|
|
|
void enable(bool state) {
|
2017-06-12 23:38:53 +08:00
|
|
|
ASSERT(m_extension);
|
2017-06-13 05:08:02 +08:00
|
|
|
App::instance()->extensions().enableExtension(m_extension, state);
|
2017-06-12 23:38:53 +08:00
|
|
|
setEnabled(m_extension->isEnabled());
|
2017-06-11 02:02:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void uninstall() {
|
2017-06-12 23:38:53 +08:00
|
|
|
ASSERT(m_extension);
|
2017-06-11 02:02:39 +08:00
|
|
|
ASSERT(canBeUninstalled());
|
2017-06-13 05:08:02 +08:00
|
|
|
App::instance()->extensions().uninstallExtension(m_extension);
|
2017-06-12 23:38:53 +08:00
|
|
|
m_extension = nullptr;
|
2017-06-11 02:02:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void openFolder() const {
|
2017-06-12 23:38:53 +08:00
|
|
|
ASSERT(m_extension);
|
2017-06-11 02:02:39 +08:00
|
|
|
app::launcher::open_folder(m_extension->path());
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
Extension* m_extension;
|
|
|
|
};
|
|
|
|
|
2012-01-06 06:45:03 +08:00
|
|
|
public:
|
2015-02-15 09:43:21 +08:00
|
|
|
OptionsWindow(Context* context, int& curSection)
|
2019-10-11 02:08:59 +08:00
|
|
|
: m_context(context)
|
|
|
|
, m_pref(Preferences::instance())
|
2016-03-25 01:29:15 +08:00
|
|
|
, m_globPref(m_pref.document(nullptr))
|
|
|
|
, m_docPref(m_pref.document(context->activeDocument()))
|
2015-02-15 10:31:11 +08:00
|
|
|
, m_curPref(&m_docPref)
|
2015-02-15 09:43:21 +08:00
|
|
|
, m_curSection(curSection)
|
2017-08-23 02:44:44 +08:00
|
|
|
, m_restoreThisTheme(m_pref.theme.selected())
|
|
|
|
, m_restoreScreenScaling(m_pref.general.screenScale())
|
|
|
|
, m_restoreUIScaling(m_pref.general.uiScale())
|
2014-06-23 08:56:04 +08:00
|
|
|
{
|
2015-12-05 02:17:42 +08:00
|
|
|
sectionListbox()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeSection, this));
|
2016-03-25 01:29:15 +08:00
|
|
|
|
2018-02-23 21:32:02 +08:00
|
|
|
// Default extension to save files
|
2018-03-20 02:53:02 +08:00
|
|
|
fillExtensionsCombobox(defaultExtension(), m_pref.saveFile.defaultExtension());
|
|
|
|
fillExtensionsCombobox(exportImageDefaultExtension(), m_pref.exportFile.imageDefaultExtension());
|
|
|
|
fillExtensionsCombobox(exportAnimationDefaultExtension(), m_pref.exportFile.animationDefaultExtension());
|
|
|
|
fillExtensionsCombobox(exportSpriteSheetDefaultExtension(), m_pref.spriteSheet.defaultExtension());
|
2018-02-23 21:32:02 +08:00
|
|
|
|
2018-03-15 01:14:47 +08:00
|
|
|
// Number of recent items
|
|
|
|
recentFiles()->setValue(m_pref.general.recentItems());
|
|
|
|
clearRecentFiles()->Click.connect(base::Bind<void>(&OptionsWindow::onClearRecentFiles, this));
|
|
|
|
|
2019-05-08 21:55:56 +08:00
|
|
|
// Template item for active display color profiles
|
|
|
|
m_templateTextForDisplayCS = windowCs()->getItem(2)->text();
|
|
|
|
windowCs()->deleteItem(2);
|
|
|
|
|
2018-10-19 02:29:16 +08:00
|
|
|
// Color profiles
|
|
|
|
resetColorManagement()->Click.connect(base::Bind<void>(&OptionsWindow::onResetColorManagement, this));
|
|
|
|
colorManagement()->Click.connect(base::Bind<void>(&OptionsWindow::onColorManagement, this));
|
|
|
|
{
|
|
|
|
os::instance()->listColorSpaces(m_colorSpaces);
|
|
|
|
for (auto& cs : m_colorSpaces) {
|
|
|
|
if (cs->gfxColorSpace()->type() != gfx::ColorSpace::None)
|
|
|
|
workingRgbCs()->addItem(new ColorSpaceItem(cs));
|
|
|
|
}
|
|
|
|
updateColorProfileControls(m_pref.color.manage(),
|
2019-05-08 21:55:56 +08:00
|
|
|
m_pref.color.windowProfile(),
|
|
|
|
m_pref.color.windowProfileName(),
|
2018-10-19 02:29:16 +08:00
|
|
|
m_pref.color.workingRgbSpace(),
|
|
|
|
m_pref.color.filesWithProfile(),
|
|
|
|
m_pref.color.missingProfile());
|
|
|
|
}
|
|
|
|
|
2018-02-08 01:35:12 +08:00
|
|
|
// Alerts
|
|
|
|
resetAlerts()->Click.connect(base::Bind<void>(&OptionsWindow::onResetAlerts, this));
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
// Cursor
|
2016-08-31 22:22:08 +08:00
|
|
|
paintingCursorType()->setSelectedItemIndex(int(m_pref.cursor.paintingCursorType()));
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setColor(m_pref.cursor.cursorColor());
|
2016-03-25 01:29:15 +08:00
|
|
|
|
2017-03-25 12:15:40 +08:00
|
|
|
if (cursorColor()->getColor().getType() == app::Color::MaskType) {
|
2016-03-25 01:29:15 +08:00
|
|
|
cursorColorType()->setSelectedItemIndex(0);
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setVisible(false);
|
2016-03-25 01:29:15 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
cursorColorType()->setSelectedItemIndex(1);
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setVisible(true);
|
2016-03-25 01:29:15 +08:00
|
|
|
}
|
|
|
|
cursorColorType()->Change.connect(base::Bind<void>(&OptionsWindow::onCursorColorType, this));
|
|
|
|
|
|
|
|
// Brush preview
|
|
|
|
brushPreview()->setSelectedItemIndex(
|
2016-08-31 03:52:03 +08:00
|
|
|
(int)m_pref.cursor.brushPreview());
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2017-03-25 12:01:59 +08:00
|
|
|
// Guide colors
|
|
|
|
layerEdgesColor()->setColor(m_pref.guides.layerEdgesColor());
|
|
|
|
autoGuidesColor()->setColor(m_pref.guides.autoGuidesColor());
|
|
|
|
|
|
|
|
// Slices default color
|
|
|
|
defaultSliceColor()->setColor(m_pref.slices.defaultColor());
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
// Others
|
2016-11-23 05:05:56 +08:00
|
|
|
firstFrame()->setTextf("%d", m_globPref.timeline.firstFrame());
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.general.expandMenubarOnMouseover())
|
2014-10-25 22:24:29 +08:00
|
|
|
expandMenubarOnMouseover()->setSelected(true);
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.general.dataRecovery())
|
2015-04-09 07:28:30 +08:00
|
|
|
enableDataRecovery()->setSelected(true);
|
2019-06-08 02:12:39 +08:00
|
|
|
enableDataRecovery()->Click.connect(
|
|
|
|
[this](Event&){
|
|
|
|
const bool state = enableDataRecovery()->isSelected();
|
|
|
|
keepEditedSpriteData()->setEnabled(state);
|
|
|
|
keepEditedSpriteData()->setSelected(state);
|
|
|
|
keepEditedSpriteDataFor()->setEnabled(state);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (m_pref.general.dataRecovery() &&
|
|
|
|
m_pref.general.keepEditedSpriteData())
|
2019-05-27 22:10:52 +08:00
|
|
|
keepEditedSpriteData()->setSelected(true);
|
2019-06-08 02:12:39 +08:00
|
|
|
else if (!m_pref.general.dataRecovery()) {
|
|
|
|
keepEditedSpriteData()->setEnabled(false);
|
|
|
|
keepEditedSpriteDataFor()->setEnabled(false);
|
|
|
|
}
|
2019-05-27 22:10:52 +08:00
|
|
|
|
2019-06-08 00:17:21 +08:00
|
|
|
if (m_pref.general.keepClosedSpriteOnMemory())
|
|
|
|
keepClosedSpriteOnMemory()->setSelected(true);
|
|
|
|
|
2016-07-25 22:04:16 +08:00
|
|
|
if (m_pref.general.showFullPath())
|
|
|
|
showFullPath()->setSelected(true);
|
|
|
|
|
2015-04-09 18:46:55 +08:00
|
|
|
dataRecoveryPeriod()->setSelectedItemIndex(
|
|
|
|
dataRecoveryPeriod()->findItemIndexByValue(
|
2016-03-25 01:29:15 +08:00
|
|
|
base::convert_to<std::string>(m_pref.general.dataRecoveryPeriod())));
|
2015-04-09 18:46:55 +08:00
|
|
|
|
2019-06-08 00:17:21 +08:00
|
|
|
keepEditedSpriteDataFor()->setSelectedItemIndex(
|
|
|
|
keepEditedSpriteDataFor()->findItemIndexByValue(
|
|
|
|
base::convert_to<std::string>(m_pref.general.keepEditedSpriteDataFor())));
|
|
|
|
|
|
|
|
keepClosedSpriteOnMemoryFor()->setSelectedItemIndex(
|
|
|
|
keepClosedSpriteOnMemoryFor()->findItemIndexByValue(
|
|
|
|
base::convert_to<std::string>(m_pref.general.keepClosedSpriteOnMemoryFor())));
|
2019-05-27 22:10:52 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.editor.zoomFromCenterWithWheel())
|
2015-05-08 02:52:26 +08:00
|
|
|
zoomFromCenterWithWheel()->setSelected(true);
|
2014-11-08 06:11:23 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.editor.zoomFromCenterWithKeys())
|
2015-05-08 02:56:38 +08:00
|
|
|
zoomFromCenterWithKeys()->setSelected(true);
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.selection.autoOpaque())
|
2015-07-27 22:43:48 +08:00
|
|
|
autoOpaque()->setSelected(true);
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.selection.keepSelectionAfterClear())
|
2015-12-23 04:49:21 +08:00
|
|
|
keepSelectionAfterClear()->setSelected(true);
|
|
|
|
|
2018-04-20 21:56:27 +08:00
|
|
|
if (m_pref.selection.autoShowSelectionEdges())
|
|
|
|
autoShowSelectionEdges()->setSelected(true);
|
|
|
|
|
2017-04-07 06:12:36 +08:00
|
|
|
if (m_pref.selection.moveEdges())
|
|
|
|
moveEdges()->setSelected(true);
|
|
|
|
|
2017-09-08 23:07:21 +08:00
|
|
|
if (m_pref.selection.modifiersDisableHandles())
|
|
|
|
modifiersDisableHandles()->setSelected(true);
|
|
|
|
|
2017-10-04 02:03:51 +08:00
|
|
|
if (m_pref.selection.moveOnAddMode())
|
|
|
|
moveOnAddMode()->setSelected(true);
|
|
|
|
|
2017-04-22 02:31:22 +08:00
|
|
|
// If the platform supports native cursors...
|
2018-08-09 23:58:43 +08:00
|
|
|
if ((int(os::instance()->capabilities()) &
|
|
|
|
int(os::Capabilities::CustomNativeMouseCursor)) != 0) {
|
2017-04-22 02:31:22 +08:00
|
|
|
if (m_pref.cursor.useNativeCursor())
|
|
|
|
nativeCursor()->setSelected(true);
|
|
|
|
nativeCursor()->Click.connect(base::Bind<void>(&OptionsWindow::onNativeCursorChange, this));
|
|
|
|
|
|
|
|
cursorScale()->setSelectedItemIndex(
|
|
|
|
cursorScale()->findItemIndexByValue(
|
|
|
|
base::convert_to<std::string>(m_pref.cursor.cursorScale())));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nativeCursor()->setEnabled(false);
|
|
|
|
}
|
|
|
|
|
2016-08-31 04:27:19 +08:00
|
|
|
onNativeCursorChange();
|
2014-08-11 06:51:14 +08:00
|
|
|
|
2018-05-24 23:56:07 +08:00
|
|
|
if (m_pref.experimental.useNativeClipboard())
|
|
|
|
nativeClipboard()->setSelected(true);
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.experimental.useNativeFileDialog())
|
2015-03-03 03:07:35 +08:00
|
|
|
nativeFileDialog()->setSelected(true);
|
|
|
|
|
2018-06-19 21:59:12 +08:00
|
|
|
#ifndef _WIN32
|
|
|
|
oneFingerAsMouseMovement()->setVisible(false);
|
2018-06-20 01:10:19 +08:00
|
|
|
loadWintabDriverBox()->setVisible(false);
|
2018-06-19 21:59:12 +08:00
|
|
|
#endif
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.experimental.flashLayer())
|
2014-10-26 03:04:39 +08:00
|
|
|
flashLayer()->setSelected(true);
|
|
|
|
|
2016-12-02 02:20:35 +08:00
|
|
|
nonactiveLayersOpacity()->setValue(m_pref.experimental.nonactiveLayersOpacity());
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
if (m_pref.editor.showScrollbars())
|
2014-08-10 12:12:31 +08:00
|
|
|
showScrollbars()->setSelected(true);
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2016-12-03 07:37:54 +08:00
|
|
|
if (m_pref.editor.autoScroll())
|
|
|
|
autoScroll()->setSelected(true);
|
|
|
|
|
2017-09-09 03:04:18 +08:00
|
|
|
if (m_pref.editor.straightLinePreview())
|
|
|
|
straightLinePreview()->setSelected(true);
|
|
|
|
|
2017-11-23 21:06:13 +08:00
|
|
|
if (m_pref.eyedropper.discardBrush())
|
|
|
|
discardBrush()->setSelected(true);
|
|
|
|
|
2015-02-15 10:31:11 +08:00
|
|
|
// Scope
|
2016-12-05 22:58:26 +08:00
|
|
|
bgScope()->addItem("Background for New Documents");
|
|
|
|
gridScope()->addItem("Grid for New Documents");
|
2015-02-15 10:31:11 +08:00
|
|
|
if (context->activeDocument()) {
|
2016-12-05 22:58:26 +08:00
|
|
|
bgScope()->addItem("Background for the Active Document");
|
2016-12-05 22:06:32 +08:00
|
|
|
bgScope()->setSelectedItemIndex(1);
|
|
|
|
bgScope()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeBgScope, this));
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
gridScope()->addItem("Grid for the Active Document");
|
2015-02-15 10:31:11 +08:00
|
|
|
gridScope()->setSelectedItemIndex(1);
|
2015-12-05 02:17:42 +08:00
|
|
|
gridScope()->Change.connect(base::Bind<void>(&OptionsWindow::onChangeGridScope, this));
|
2015-02-15 10:31:11 +08:00
|
|
|
}
|
|
|
|
|
2017-08-19 06:23:23 +08:00
|
|
|
selectScalingItems();
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2018-08-09 23:58:43 +08:00
|
|
|
if ((int(os::instance()->capabilities()) &
|
|
|
|
int(os::Capabilities::GpuAccelerationSwitch)) == int(os::Capabilities::GpuAccelerationSwitch)) {
|
2016-03-25 01:29:15 +08:00
|
|
|
gpuAcceleration()->setSelected(m_pref.general.gpuAcceleration());
|
2015-10-06 08:18:42 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
gpuAcceleration()->setVisible(false);
|
|
|
|
}
|
|
|
|
|
2017-09-02 04:18:53 +08:00
|
|
|
// If the platform does support native menus, we show the option,
|
|
|
|
// in other case, the option doesn't make sense for this platform.
|
2018-08-09 23:58:43 +08:00
|
|
|
if (os::instance()->menus())
|
2017-09-02 04:18:53 +08:00
|
|
|
showMenuBar()->setSelected(m_pref.general.showMenuBar());
|
|
|
|
else
|
|
|
|
showMenuBar()->setVisible(false);
|
|
|
|
|
2016-12-19 01:44:39 +08:00
|
|
|
showHome()->setSelected(m_pref.general.showHome());
|
|
|
|
|
2014-08-19 19:17:57 +08:00
|
|
|
// Right-click
|
2016-12-01 08:07:30 +08:00
|
|
|
|
|
|
|
static_assert(int(app::gen::RightClickMode::PAINT_BGCOLOR) == 0, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::PICK_FGCOLOR) == 1, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::ERASE) == 2, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::SCROLL) == 3, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::RECTANGULAR_MARQUEE) == 4, "");
|
|
|
|
static_assert(int(app::gen::RightClickMode::LASSO) == 5, "");
|
2018-10-26 21:01:25 +08:00
|
|
|
static_assert(int(app::gen::RightClickMode::SELECT_LAYER_AND_MOVE) == 6, "");
|
2016-12-01 08:07:30 +08:00
|
|
|
|
2014-08-19 19:17:57 +08:00
|
|
|
rightClickBehavior()->addItem("Paint with background color");
|
|
|
|
rightClickBehavior()->addItem("Pick foreground color");
|
|
|
|
rightClickBehavior()->addItem("Erase");
|
2015-08-20 05:00:51 +08:00
|
|
|
rightClickBehavior()->addItem("Scroll");
|
2016-12-01 08:07:30 +08:00
|
|
|
rightClickBehavior()->addItem("Rectangular Marquee");
|
|
|
|
rightClickBehavior()->addItem("Lasso");
|
2018-10-26 21:01:25 +08:00
|
|
|
rightClickBehavior()->addItem("Select Layer & Move");
|
2016-03-25 01:29:15 +08:00
|
|
|
rightClickBehavior()->setSelectedItemIndex((int)m_pref.editor.rightClickMode());
|
2014-08-19 19:17:57 +08:00
|
|
|
|
2018-07-20 10:05:14 +08:00
|
|
|
#ifndef __APPLE__ // Zoom sliding two fingers option only on macOS
|
2016-05-28 00:15:13 +08:00
|
|
|
slideZoom()->setVisible(false);
|
|
|
|
#endif
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
// Checked background size
|
2017-09-06 01:38:42 +08:00
|
|
|
static_assert(int(app::gen::BgType::CHECKED_16x16) == 0, "");
|
|
|
|
static_assert(int(app::gen::BgType::CHECKED_1x1) == 4, "");
|
2018-11-15 21:07:40 +08:00
|
|
|
static_assert(int(app::gen::BgType::CHECKED_CUSTOM) == 5, "");
|
2014-08-10 12:12:31 +08:00
|
|
|
checkedBgSize()->addItem("16x16");
|
|
|
|
checkedBgSize()->addItem("8x8");
|
|
|
|
checkedBgSize()->addItem("4x4");
|
|
|
|
checkedBgSize()->addItem("2x2");
|
2017-09-06 01:38:42 +08:00
|
|
|
checkedBgSize()->addItem("1x1");
|
2018-11-15 21:07:40 +08:00
|
|
|
checkedBgSize()->addItem("Custom");
|
|
|
|
checkedBgSize()->Change.connect(base::Bind<void>(&OptionsWindow::onCheckedBgSizeChange, this));
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
// Reset buttons
|
|
|
|
resetBg()->Click.connect(base::Bind<void>(&OptionsWindow::onResetBg, this));
|
|
|
|
resetGrid()->Click.connect(base::Bind<void>(&OptionsWindow::onResetGrid, this));
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2014-08-20 11:11:19 +08:00
|
|
|
// Links
|
2015-12-05 02:17:42 +08:00
|
|
|
locateFile()->Click.connect(base::Bind<void>(&OptionsWindow::onLocateConfigFile, this));
|
2020-03-07 01:45:13 +08:00
|
|
|
if (!App::instance()->memoryDumpFilename().empty())
|
|
|
|
locateCrashFolder()->Click.connect(base::Bind<void>(&OptionsWindow::onLocateCrashFolder, this));
|
|
|
|
else
|
|
|
|
locateCrashFolder()->setVisible(false);
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2015-01-19 09:05:33 +08:00
|
|
|
// Undo preferences
|
2017-10-26 04:58:55 +08:00
|
|
|
limitUndo()->Click.connect(base::Bind<void>(&OptionsWindow::onLimitUndoCheck, this));
|
|
|
|
limitUndo()->setSelected(m_pref.undo.sizeLimit() != 0);
|
|
|
|
onLimitUndoCheck();
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
undoGotoModified()->setSelected(m_pref.undo.gotoModified());
|
|
|
|
undoAllowNonlinearHistory()->setSelected(m_pref.undo.allowNonlinearHistory());
|
2014-06-23 08:56:04 +08:00
|
|
|
|
2015-09-18 23:23:02 +08:00
|
|
|
// Theme buttons
|
2016-07-21 05:30:03 +08:00
|
|
|
themeList()->Change.connect(base::Bind<void>(&OptionsWindow::onThemeChange, this));
|
2017-08-23 02:44:44 +08:00
|
|
|
themeList()->DoubleClickItem.connect(base::Bind<void>(&OptionsWindow::onSelectTheme, this));
|
2015-12-05 02:17:42 +08:00
|
|
|
selectTheme()->Click.connect(base::Bind<void>(&OptionsWindow::onSelectTheme, this));
|
|
|
|
openThemeFolder()->Click.connect(base::Bind<void>(&OptionsWindow::onOpenThemeFolder, this));
|
2015-09-18 23:23:02 +08:00
|
|
|
|
2017-06-11 02:02:39 +08:00
|
|
|
// Extensions buttons
|
|
|
|
extensionsList()->Change.connect(base::Bind<void>(&OptionsWindow::onExtensionChange, this));
|
2017-06-12 23:38:53 +08:00
|
|
|
addExtension()->Click.connect(base::Bind<void>(&OptionsWindow::onAddExtension, this));
|
2017-06-11 02:02:39 +08:00
|
|
|
disableExtension()->Click.connect(base::Bind<void>(&OptionsWindow::onDisableExtension, this));
|
|
|
|
uninstallExtension()->Click.connect(base::Bind<void>(&OptionsWindow::onUninstallExtension, this));
|
|
|
|
openExtensionFolder()->Click.connect(base::Bind<void>(&OptionsWindow::onOpenExtensionFolder, this));
|
|
|
|
|
2015-12-20 23:58:25 +08:00
|
|
|
// Apply button
|
2017-08-23 02:44:44 +08:00
|
|
|
buttonApply()->Click.connect(base::Bind<void>(&OptionsWindow::onApply, this));
|
2015-12-20 23:58:25 +08:00
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
onChangeBgScope();
|
2015-02-15 10:31:11 +08:00
|
|
|
onChangeGridScope();
|
2015-02-15 09:43:21 +08:00
|
|
|
sectionListbox()->selectIndex(m_curSection);
|
2017-06-13 22:51:49 +08:00
|
|
|
|
2018-03-20 06:37:39 +08:00
|
|
|
// Refill languages combobox when extensions are enabled/disabled
|
|
|
|
m_extLanguagesChanges =
|
|
|
|
App::instance()->extensions().LanguagesChange.connect(
|
|
|
|
base::Bind<void>(&OptionsWindow::refillLanguages, this));
|
|
|
|
|
2017-06-13 22:51:49 +08:00
|
|
|
// Reload themes when extensions are enabled/disabled
|
|
|
|
m_extThemesChanges =
|
|
|
|
App::instance()->extensions().ThemesChange.connect(
|
|
|
|
base::Bind<void>(&OptionsWindow::reloadThemes, this));
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
bool ok() {
|
2015-12-05 01:54:15 +08:00
|
|
|
return (closer() == buttonOk());
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
void saveConfig() {
|
2018-06-07 02:44:52 +08:00
|
|
|
// Save preferences in widgets that are bound to options automatically
|
|
|
|
{
|
|
|
|
Message* msg = new Message(kSavePreferencesMessage);
|
|
|
|
msg->setPropagateToChildren(msg);
|
|
|
|
sendMessage(msg);
|
|
|
|
}
|
|
|
|
|
2018-03-20 06:37:39 +08:00
|
|
|
// Update language
|
|
|
|
Strings::instance()->setCurrentLanguage(
|
|
|
|
language()->getItemText(language()->getSelectedItemIndex()));
|
|
|
|
|
2016-11-23 05:05:56 +08:00
|
|
|
m_globPref.timeline.firstFrame(firstFrame()->textInt());
|
2016-07-25 22:04:16 +08:00
|
|
|
m_pref.general.showFullPath(showFullPath()->isSelected());
|
2018-03-20 02:53:02 +08:00
|
|
|
m_pref.saveFile.defaultExtension(getExtension(defaultExtension()));
|
|
|
|
m_pref.exportFile.imageDefaultExtension(getExtension(exportImageDefaultExtension()));
|
|
|
|
m_pref.exportFile.animationDefaultExtension(getExtension(exportAnimationDefaultExtension()));
|
|
|
|
m_pref.spriteSheet.defaultExtension(getExtension(exportSpriteSheetDefaultExtension()));
|
2018-03-15 01:14:47 +08:00
|
|
|
{
|
|
|
|
const int limit = recentFiles()->getValue();
|
|
|
|
m_pref.general.recentItems(limit);
|
|
|
|
App::instance()->recentFiles()->setLimit(limit);
|
|
|
|
}
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-10-25 22:24:29 +08:00
|
|
|
bool expandOnMouseover = expandMenubarOnMouseover()->isSelected();
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.general.expandMenubarOnMouseover(expandOnMouseover);
|
2014-10-25 22:24:29 +08:00
|
|
|
ui::MenuBar::setExpandOnMouseover(expandOnMouseover);
|
|
|
|
|
2015-04-09 07:28:30 +08:00
|
|
|
std::string warnings;
|
|
|
|
|
2016-11-13 05:02:47 +08:00
|
|
|
double newPeriod = base::convert_to<double>(dataRecoveryPeriod()->getValue());
|
2016-03-25 01:29:15 +08:00
|
|
|
if (enableDataRecovery()->isSelected() != m_pref.general.dataRecovery() ||
|
|
|
|
newPeriod != m_pref.general.dataRecoveryPeriod()) {
|
|
|
|
m_pref.general.dataRecovery(enableDataRecovery()->isSelected());
|
|
|
|
m_pref.general.dataRecoveryPeriod(newPeriod);
|
2015-04-09 18:46:55 +08:00
|
|
|
|
2017-10-18 05:00:45 +08:00
|
|
|
warnings += "<<- " + Strings::alerts_restart_by_preferences_save_recovery_data_period();
|
2015-04-09 07:28:30 +08:00
|
|
|
}
|
|
|
|
|
2019-06-08 00:17:21 +08:00
|
|
|
int newLifespan = base::convert_to<int>(keepEditedSpriteDataFor()->getValue());
|
2019-05-27 22:10:52 +08:00
|
|
|
if (keepEditedSpriteData()->isSelected() != m_pref.general.keepEditedSpriteData() ||
|
2019-06-08 00:17:21 +08:00
|
|
|
newLifespan != m_pref.general.keepEditedSpriteDataFor()) {
|
2019-05-27 22:10:52 +08:00
|
|
|
m_pref.general.keepEditedSpriteData(keepEditedSpriteData()->isSelected());
|
2019-06-08 00:17:21 +08:00
|
|
|
m_pref.general.keepEditedSpriteDataFor(newLifespan);
|
2019-05-27 22:10:52 +08:00
|
|
|
|
|
|
|
warnings += "<<- " + Strings::alerts_restart_by_preferences_keep_edited_sprite_data_lifespan();
|
|
|
|
}
|
|
|
|
|
2019-06-08 00:26:12 +08:00
|
|
|
double newKeepClosed = base::convert_to<double>(keepClosedSpriteOnMemoryFor()->getValue());
|
2019-06-08 00:17:21 +08:00
|
|
|
if (keepClosedSpriteOnMemory()->isSelected() != m_pref.general.keepClosedSpriteOnMemory() ||
|
2019-06-08 00:26:12 +08:00
|
|
|
newKeepClosed != m_pref.general.keepClosedSpriteOnMemoryFor()) {
|
2019-06-08 00:17:21 +08:00
|
|
|
m_pref.general.keepClosedSpriteOnMemory(keepClosedSpriteOnMemory()->isSelected());
|
2019-06-08 00:26:12 +08:00
|
|
|
m_pref.general.keepClosedSpriteOnMemoryFor(newKeepClosed);
|
2019-06-08 00:17:21 +08:00
|
|
|
|
|
|
|
warnings += "<<- " + Strings::alerts_restart_by_preferences_keep_closed_sprite_on_memory_for();
|
|
|
|
}
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.editor.zoomFromCenterWithWheel(zoomFromCenterWithWheel()->isSelected());
|
|
|
|
m_pref.editor.zoomFromCenterWithKeys(zoomFromCenterWithKeys()->isSelected());
|
|
|
|
m_pref.editor.showScrollbars(showScrollbars()->isSelected());
|
2016-12-03 07:37:54 +08:00
|
|
|
m_pref.editor.autoScroll(autoScroll()->isSelected());
|
2017-09-09 03:04:18 +08:00
|
|
|
m_pref.editor.straightLinePreview(straightLinePreview()->isSelected());
|
2017-11-23 21:06:13 +08:00
|
|
|
m_pref.eyedropper.discardBrush(discardBrush()->isSelected());
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.editor.rightClickMode(static_cast<app::gen::RightClickMode>(rightClickBehavior()->getSelectedItemIndex()));
|
2016-08-31 22:22:08 +08:00
|
|
|
m_pref.cursor.paintingCursorType(static_cast<app::gen::PaintingCursorType>(paintingCursorType()->getSelectedItemIndex()));
|
2017-03-25 12:15:40 +08:00
|
|
|
m_pref.cursor.cursorColor(cursorColor()->getColor());
|
2016-08-31 03:52:03 +08:00
|
|
|
m_pref.cursor.brushPreview(static_cast<app::gen::BrushPreview>(brushPreview()->getSelectedItemIndex()));
|
|
|
|
m_pref.cursor.useNativeCursor(nativeCursor()->isSelected());
|
2016-08-31 04:27:19 +08:00
|
|
|
m_pref.cursor.cursorScale(base::convert_to<int>(cursorScale()->getValue()));
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.selection.autoOpaque(autoOpaque()->isSelected());
|
|
|
|
m_pref.selection.keepSelectionAfterClear(keepSelectionAfterClear()->isSelected());
|
2018-04-20 21:56:27 +08:00
|
|
|
m_pref.selection.autoShowSelectionEdges(autoShowSelectionEdges()->isSelected());
|
2017-04-07 06:12:36 +08:00
|
|
|
m_pref.selection.moveEdges(moveEdges()->isSelected());
|
2017-09-08 23:07:21 +08:00
|
|
|
m_pref.selection.modifiersDisableHandles(modifiersDisableHandles()->isSelected());
|
2017-10-04 02:03:51 +08:00
|
|
|
m_pref.selection.moveOnAddMode(moveOnAddMode()->isSelected());
|
2017-03-25 12:01:59 +08:00
|
|
|
m_pref.guides.layerEdgesColor(layerEdgesColor()->getColor());
|
|
|
|
m_pref.guides.autoGuidesColor(autoGuidesColor()->getColor());
|
|
|
|
m_pref.slices.defaultColor(defaultSliceColor()->getColor());
|
2014-01-27 00:28:11 +08:00
|
|
|
|
2018-10-19 02:29:16 +08:00
|
|
|
m_pref.color.workingRgbSpace(
|
|
|
|
workingRgbCs()->getItemText(
|
|
|
|
workingRgbCs()->getSelectedItemIndex()));
|
|
|
|
m_pref.color.filesWithProfile(
|
|
|
|
filesWithCsMap[filesWithCs()->getSelectedItemIndex()]);
|
|
|
|
m_pref.color.missingProfile(
|
|
|
|
missingCsMap[missingCs()->getSelectedItemIndex()]);
|
|
|
|
|
2019-05-08 21:55:56 +08:00
|
|
|
int winCs = windowCs()->getSelectedItemIndex();
|
|
|
|
switch (winCs) {
|
|
|
|
case 0:
|
|
|
|
m_pref.color.windowProfile(gen::WindowColorProfile::MONITOR);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
m_pref.color.windowProfile(gen::WindowColorProfile::SRGB);
|
|
|
|
break;
|
|
|
|
default: {
|
|
|
|
m_pref.color.windowProfile(gen::WindowColorProfile::SPECIFIC);
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
int j = 2;
|
|
|
|
for (auto& cs : m_colorSpaces) {
|
|
|
|
// We add ICC profiles only
|
|
|
|
auto gfxCs = cs->gfxColorSpace();
|
|
|
|
if (gfxCs->type() != gfx::ColorSpace::ICC)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (j == winCs) {
|
|
|
|
name = gfxCs->name();
|
|
|
|
os::instance()->setDisplaysColorSpace(cs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pref.color.windowProfileName(name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
update_displays_color_profile_from_preferences();
|
|
|
|
|
2019-10-11 02:08:59 +08:00
|
|
|
// Change sprite grid bounds
|
|
|
|
if (m_context && m_context->activeDocument()) {
|
2020-02-06 04:50:17 +08:00
|
|
|
ContextWriter writer(m_context);
|
2019-10-11 02:08:59 +08:00
|
|
|
Tx tx(m_context, Strings::commands_GridSettings(), ModifyDocument);
|
|
|
|
tx(new cmd::SetGridBounds(writer.sprite(), gridBounds()));
|
|
|
|
tx.commit();
|
|
|
|
}
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
m_curPref->show.grid(gridVisible()->isSelected());
|
|
|
|
m_curPref->grid.bounds(gridBounds());
|
2017-03-25 12:15:40 +08:00
|
|
|
m_curPref->grid.color(gridColor()->getColor());
|
2015-02-15 20:48:38 +08:00
|
|
|
m_curPref->grid.opacity(gridOpacity()->getValue());
|
|
|
|
m_curPref->grid.autoOpacity(gridAutoOpacity()->isSelected());
|
2016-12-05 22:58:26 +08:00
|
|
|
|
|
|
|
m_curPref->show.pixelGrid(pixelGridVisible()->isSelected());
|
2017-03-25 12:15:40 +08:00
|
|
|
m_curPref->pixelGrid.color(pixelGridColor()->getColor());
|
2015-02-15 20:48:38 +08:00
|
|
|
m_curPref->pixelGrid.opacity(pixelGridOpacity()->getValue());
|
|
|
|
m_curPref->pixelGrid.autoOpacity(pixelGridAutoOpacity()->isSelected());
|
2016-12-05 22:58:26 +08:00
|
|
|
|
2015-02-15 10:31:11 +08:00
|
|
|
m_curPref->bg.type(app::gen::BgType(checkedBgSize()->getSelectedItemIndex()));
|
2018-11-15 21:07:40 +08:00
|
|
|
if (m_curPref->bg.type() == app::gen::BgType::CHECKED_CUSTOM) {
|
|
|
|
m_curPref->bg.size(gfx::Size(
|
|
|
|
checkedBgCustomW()->textInt(),
|
|
|
|
checkedBgCustomH()->textInt()));
|
|
|
|
}
|
2015-02-15 10:31:11 +08:00
|
|
|
m_curPref->bg.zoom(checkedBgZoom()->isSelected());
|
2017-03-25 12:15:40 +08:00
|
|
|
m_curPref->bg.color1(checkedBgColor1()->getColor());
|
|
|
|
m_curPref->bg.color2(checkedBgColor2()->getColor());
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
int undo_size_limit_value;
|
Refactor several "getNoun()" getters to "noun()"
This is a work-in-progress to create a consistent API and finally
separate the whole Aseprite base/gfx/ui libs into a reusable C++ library.
Classes:
app::IFileItem, app::AppMenuItem, app::skin::SkinPart,
gfx::Rect, gfx::Border, she::FileDialog,
ui::IButtonIcon, ui::Graphics, ui::Overlay, ui::Widget,
ui::ScrollableViewDelegate, and UI events
2015-12-05 01:39:04 +08:00
|
|
|
undo_size_limit_value = undoSizeLimit()->textInt();
|
2020-04-08 06:47:16 +08:00
|
|
|
undo_size_limit_value = base::clamp(undo_size_limit_value, 0, 999999);
|
2014-07-31 11:19:58 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.undo.sizeLimit(undo_size_limit_value);
|
|
|
|
m_pref.undo.gotoModified(undoGotoModified()->isSelected());
|
|
|
|
m_pref.undo.allowNonlinearHistory(undoAllowNonlinearHistory()->isSelected());
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2014-10-26 03:04:39 +08:00
|
|
|
// Experimental features
|
2018-05-24 23:56:07 +08:00
|
|
|
m_pref.experimental.useNativeClipboard(nativeClipboard()->isSelected());
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.experimental.useNativeFileDialog(nativeFileDialog()->isSelected());
|
|
|
|
m_pref.experimental.flashLayer(flashLayer()->isSelected());
|
2016-12-02 02:20:35 +08:00
|
|
|
m_pref.experimental.nonactiveLayersOpacity(nonactiveLayersOpacity()->getValue());
|
2016-08-31 04:27:19 +08:00
|
|
|
|
2018-06-19 21:59:12 +08:00
|
|
|
#ifdef _WIN32
|
|
|
|
manager()->getDisplay()
|
|
|
|
->setInterpretOneFingerGestureAsMouseMovement(
|
|
|
|
oneFingerAsMouseMovement()->isSelected());
|
|
|
|
#endif
|
|
|
|
|
2016-08-31 03:52:03 +08:00
|
|
|
ui::set_use_native_cursors(m_pref.cursor.useNativeCursor());
|
2016-08-31 04:27:19 +08:00
|
|
|
ui::set_mouse_cursor_scale(m_pref.cursor.cursorScale());
|
2014-08-11 06:51:14 +08:00
|
|
|
|
2015-04-17 22:11:36 +08:00
|
|
|
bool reset_screen = false;
|
|
|
|
int newScreenScale = base::convert_to<int>(screenScale()->getValue());
|
2016-03-25 01:29:15 +08:00
|
|
|
if (newScreenScale != m_pref.general.screenScale()) {
|
|
|
|
m_pref.general.screenScale(newScreenScale);
|
2015-04-17 22:11:36 +08:00
|
|
|
reset_screen = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int newUIScale = base::convert_to<int>(uiScale()->getValue());
|
2016-09-09 20:46:10 +08:00
|
|
|
if (newUIScale != m_pref.general.uiScale()) {
|
|
|
|
m_pref.general.uiScale(newUIScale);
|
2017-08-15 21:39:06 +08:00
|
|
|
ui::set_theme(ui::get_theme(),
|
|
|
|
newUIScale);
|
|
|
|
reset_screen = true;
|
2014-02-08 11:19:20 +08:00
|
|
|
}
|
|
|
|
|
2015-10-06 08:18:42 +08:00
|
|
|
bool newGpuAccel = gpuAcceleration()->isSelected();
|
2016-03-25 01:29:15 +08:00
|
|
|
if (newGpuAccel != m_pref.general.gpuAcceleration()) {
|
|
|
|
m_pref.general.gpuAcceleration(newGpuAccel);
|
2015-10-06 08:18:42 +08:00
|
|
|
reset_screen = true;
|
|
|
|
}
|
2016-12-19 01:44:39 +08:00
|
|
|
|
2018-08-09 23:58:43 +08:00
|
|
|
if (os::instance()->menus() &&
|
2017-09-02 04:18:53 +08:00
|
|
|
m_pref.general.showMenuBar() != showMenuBar()->isSelected()) {
|
|
|
|
m_pref.general.showMenuBar(showMenuBar()->isSelected());
|
|
|
|
}
|
|
|
|
|
2016-12-19 01:44:39 +08:00
|
|
|
bool newShowHome = showHome()->isSelected();
|
|
|
|
if (newShowHome != m_pref.general.showHome())
|
|
|
|
m_pref.general.showHome(newShowHome);
|
2015-10-06 08:18:42 +08:00
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
m_pref.save();
|
2015-04-09 07:28:30 +08:00
|
|
|
|
|
|
|
if (!warnings.empty()) {
|
2017-10-18 05:00:45 +08:00
|
|
|
ui::Alert::show(
|
|
|
|
fmt::format(Strings::alerts_restart_by_preferences(),
|
|
|
|
warnings));
|
2015-04-09 07:28:30 +08:00
|
|
|
}
|
2015-04-17 22:11:36 +08:00
|
|
|
|
2017-08-19 06:23:23 +08:00
|
|
|
if (reset_screen)
|
|
|
|
updateScreenScaling();
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
2017-08-23 02:44:44 +08:00
|
|
|
void restoreTheme() {
|
|
|
|
if (m_pref.theme.selected() != m_restoreThisTheme) {
|
|
|
|
setUITheme(m_restoreThisTheme, false);
|
|
|
|
|
|
|
|
// Restore UI & Screen Scaling
|
|
|
|
if (m_restoreUIScaling != m_pref.general.uiScale()) {
|
|
|
|
m_pref.general.uiScale(m_restoreUIScaling);
|
|
|
|
ui::set_theme(ui::get_theme(), m_restoreUIScaling);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_restoreScreenScaling != m_pref.general.screenScale()) {
|
|
|
|
m_pref.general.screenScale(m_restoreScreenScaling);
|
|
|
|
updateScreenScaling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-28 21:30:33 +08:00
|
|
|
bool showDialogToInstallExtension(const std::string& filename) {
|
|
|
|
for (Widget* item : sectionListbox()->children()) {
|
|
|
|
if (auto listItem = dynamic_cast<const ListItem*>(item)) {
|
|
|
|
if (listItem->getValue() == kSectionExtensionsId) {
|
|
|
|
sectionListbox()->selectChild(item);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Install?
|
|
|
|
if (ui::Alert::show(
|
|
|
|
fmt::format(Strings::alerts_install_extension(), filename)) != 1)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
installExtension(filename);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
private:
|
2017-08-23 02:44:44 +08:00
|
|
|
|
2018-03-20 02:53:02 +08:00
|
|
|
void fillExtensionsCombobox(ui::ComboBox* combobox,
|
|
|
|
const std::string& defExt) {
|
|
|
|
base::paths exts = get_writable_extensions();
|
|
|
|
for (const auto& e : exts) {
|
|
|
|
int index = combobox->addItem(e);
|
|
|
|
if (base::utf8_icmp(e, defExt) == 0)
|
|
|
|
combobox->setSelectedItemIndex(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getExtension(ui::ComboBox* combobox) {
|
|
|
|
Widget* defExt = combobox->getSelectedItem();
|
|
|
|
ASSERT(defExt);
|
|
|
|
return (defExt ? defExt->text(): std::string());
|
|
|
|
}
|
|
|
|
|
2017-08-19 06:23:23 +08:00
|
|
|
void selectScalingItems() {
|
|
|
|
// Screen/UI Scale
|
|
|
|
screenScale()->setSelectedItemIndex(
|
|
|
|
screenScale()->findItemIndexByValue(
|
|
|
|
base::convert_to<std::string>(m_pref.general.screenScale())));
|
|
|
|
|
|
|
|
uiScale()->setSelectedItemIndex(
|
|
|
|
uiScale()->findItemIndexByValue(
|
|
|
|
base::convert_to<std::string>(m_pref.general.uiScale())));
|
|
|
|
}
|
|
|
|
|
|
|
|
void updateScreenScaling() {
|
|
|
|
ui::Manager* manager = ui::Manager::getDefault();
|
2018-08-09 23:58:43 +08:00
|
|
|
os::Display* display = manager->getDisplay();
|
|
|
|
os::instance()->setGpuAcceleration(m_pref.general.gpuAcceleration());
|
2017-08-19 06:23:23 +08:00
|
|
|
display->setScale(m_pref.general.screenScale());
|
|
|
|
manager->setDisplay(display);
|
|
|
|
}
|
|
|
|
|
2017-08-23 02:44:44 +08:00
|
|
|
void onApply() {
|
|
|
|
saveConfig();
|
|
|
|
m_restoreThisTheme = m_pref.theme.selected();
|
|
|
|
m_restoreScreenScaling = m_pref.general.screenScale();
|
|
|
|
m_restoreUIScaling = m_pref.general.uiScale();
|
|
|
|
}
|
|
|
|
|
2016-08-31 04:27:19 +08:00
|
|
|
void onNativeCursorChange() {
|
2017-04-22 02:31:22 +08:00
|
|
|
bool state =
|
|
|
|
// If the platform supports native cursors...
|
2018-08-09 23:58:43 +08:00
|
|
|
(((int(os::instance()->capabilities()) &
|
|
|
|
int(os::Capabilities::CustomNativeMouseCursor)) != 0) &&
|
2017-04-22 02:31:22 +08:00
|
|
|
// If the native cursor option is not selec
|
|
|
|
!nativeCursor()->isSelected());
|
|
|
|
|
2016-08-31 04:27:19 +08:00
|
|
|
cursorScaleLabel()->setEnabled(state);
|
|
|
|
cursorScale()->setEnabled(state);
|
|
|
|
}
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
void onChangeSection() {
|
2015-03-02 22:18:33 +08:00
|
|
|
ListItem* item = static_cast<ListItem*>(sectionListbox()->getSelectedChild());
|
2014-06-23 08:56:04 +08:00
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
|
2014-08-10 12:12:31 +08:00
|
|
|
panel()->showChild(findChild(item->getValue().c_str()));
|
2015-02-15 09:43:21 +08:00
|
|
|
m_curSection = sectionListbox()->getSelectedIndex();
|
2015-09-18 23:23:02 +08:00
|
|
|
|
2018-03-20 06:37:39 +08:00
|
|
|
// General section
|
|
|
|
if (item->getValue() == kSectionGeneralId)
|
|
|
|
loadLanguages();
|
|
|
|
// Background section
|
|
|
|
else if (item->getValue() == kSectionBgId)
|
2016-12-05 22:58:26 +08:00
|
|
|
onChangeBgScope();
|
2018-03-20 06:37:39 +08:00
|
|
|
// Grid section
|
2016-12-05 22:58:26 +08:00
|
|
|
else if (item->getValue() == kSectionGridId)
|
|
|
|
onChangeGridScope();
|
2015-09-18 23:23:02 +08:00
|
|
|
// Load themes
|
2016-12-05 22:58:26 +08:00
|
|
|
else if (item->getValue() == kSectionThemeId)
|
2015-09-18 23:23:02 +08:00
|
|
|
loadThemes();
|
2017-06-11 02:02:39 +08:00
|
|
|
// Load extension
|
|
|
|
else if (item->getValue() == kSectionExtensionsId)
|
|
|
|
loadExtensions();
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
|
|
|
|
2018-03-15 01:14:47 +08:00
|
|
|
void onClearRecentFiles() {
|
|
|
|
App::instance()->recentFiles()->clear();
|
|
|
|
}
|
|
|
|
|
2018-10-19 02:29:16 +08:00
|
|
|
void onColorManagement() {
|
|
|
|
const bool state = colorManagement()->isSelected();
|
2019-05-08 21:55:56 +08:00
|
|
|
windowCsLabel()->setEnabled(state);
|
|
|
|
windowCs()->setEnabled(state);
|
2018-10-19 02:29:16 +08:00
|
|
|
workingRgbCsLabel()->setEnabled(state);
|
|
|
|
workingRgbCs()->setEnabled(state);
|
|
|
|
filesWithCsLabel()->setEnabled(state);
|
|
|
|
filesWithCs()->setEnabled(state);
|
|
|
|
missingCsLabel()->setEnabled(state);
|
|
|
|
missingCs()->setEnabled(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void onResetColorManagement() {
|
|
|
|
updateColorProfileControls(m_pref.color.manage.defaultValue(),
|
2019-05-08 21:55:56 +08:00
|
|
|
m_pref.color.windowProfile.defaultValue(),
|
|
|
|
m_pref.color.windowProfileName.defaultValue(),
|
2018-10-19 02:29:16 +08:00
|
|
|
m_pref.color.workingRgbSpace.defaultValue(),
|
|
|
|
m_pref.color.filesWithProfile.defaultValue(),
|
|
|
|
m_pref.color.missingProfile.defaultValue());
|
|
|
|
}
|
|
|
|
|
|
|
|
void updateColorProfileControls(const bool manage,
|
2019-05-08 21:55:56 +08:00
|
|
|
const app::gen::WindowColorProfile& windowProfile,
|
|
|
|
const std::string& windowProfileName,
|
2018-10-19 02:29:16 +08:00
|
|
|
const std::string& workingRgbSpace,
|
|
|
|
const app::gen::ColorProfileBehavior& filesWithProfile,
|
|
|
|
const app::gen::ColorProfileBehavior& missingProfile) {
|
|
|
|
colorManagement()->setSelected(manage);
|
|
|
|
|
2019-05-08 21:55:56 +08:00
|
|
|
// Window color profile
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
if (windowProfile == gen::WindowColorProfile::MONITOR)
|
|
|
|
i = 0;
|
|
|
|
else if (windowProfile == gen::WindowColorProfile::SRGB)
|
|
|
|
i = 1;
|
|
|
|
|
|
|
|
// Delete previous added items in the combobox for each display
|
|
|
|
// (we'll re-add them below).
|
|
|
|
while (windowCs()->getItem(2))
|
|
|
|
windowCs()->deleteItem(2);
|
|
|
|
|
|
|
|
int j = 2;
|
|
|
|
for (auto& cs : m_colorSpaces) {
|
|
|
|
// We add ICC profiles only
|
|
|
|
auto gfxCs = cs->gfxColorSpace();
|
|
|
|
if (gfxCs->type() != gfx::ColorSpace::ICC)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
auto name = gfxCs->name();
|
|
|
|
windowCs()->addItem(fmt::format(m_templateTextForDisplayCS, name));
|
|
|
|
if (windowProfile == gen::WindowColorProfile::SPECIFIC &&
|
|
|
|
windowProfileName == name) {
|
|
|
|
i = j;
|
|
|
|
}
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
windowCs()->setSelectedItemIndex(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Working color profile
|
2018-10-19 02:29:16 +08:00
|
|
|
for (auto child : *workingRgbCs()) {
|
|
|
|
if (child->text() == workingRgbSpace) {
|
|
|
|
workingRgbCs()->setSelectedItem(child);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i=0; i<sizeof(filesWithCsMap)/sizeof(filesWithCsMap[0]); ++i) {
|
|
|
|
if (filesWithCsMap[i] == filesWithProfile) {
|
|
|
|
filesWithCs()->setSelectedItemIndex(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i=0; i<sizeof(missingCsMap)/sizeof(missingCsMap[0]); ++i) {
|
|
|
|
if (missingCsMap[i] == missingProfile) {
|
|
|
|
missingCs()->setSelectedItemIndex(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onColorManagement();
|
|
|
|
}
|
|
|
|
|
2018-02-08 01:35:12 +08:00
|
|
|
void onResetAlerts() {
|
2018-06-09 02:25:08 +08:00
|
|
|
fileFormatDoesntSupportAlert()->resetWithDefaultValue();
|
|
|
|
exportAnimationInSequenceAlert()->resetWithDefaultValue();
|
|
|
|
overwriteFilesOnExportAlert()->resetWithDefaultValue();
|
|
|
|
overwriteFilesOnExportSpriteSheetAlert()->resetWithDefaultValue();
|
|
|
|
advancedModeAlert()->resetWithDefaultValue();
|
2018-12-14 02:36:35 +08:00
|
|
|
invalidFgBgColorAlert()->resetWithDefaultValue();
|
|
|
|
runScriptAlert()->resetWithDefaultValue();
|
2020-03-21 06:18:03 +08:00
|
|
|
gifOptionsAlert()->resetWithDefaultValue();
|
|
|
|
jpegOptionsAlert()->resetWithDefaultValue();
|
|
|
|
svgOptionsAlert()->resetWithDefaultValue();
|
|
|
|
tgaOptionsAlert()->resetWithDefaultValue();
|
2018-02-08 01:35:12 +08:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
void onChangeBgScope() {
|
2018-11-15 21:07:40 +08:00
|
|
|
const int item = bgScope()->getSelectedItemIndex();
|
2016-12-05 22:06:32 +08:00
|
|
|
switch (item) {
|
|
|
|
case 0: m_curPref = &m_globPref; break;
|
|
|
|
case 1: m_curPref = &m_docPref; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
checkedBgSize()->setSelectedItemIndex(int(m_curPref->bg.type()));
|
|
|
|
checkedBgZoom()->setSelected(m_curPref->bg.zoom());
|
2017-03-25 12:15:40 +08:00
|
|
|
checkedBgColor1()->setColor(m_curPref->bg.color1());
|
|
|
|
checkedBgColor2()->setColor(m_curPref->bg.color2());
|
2018-11-15 21:07:40 +08:00
|
|
|
|
|
|
|
onCheckedBgSizeChange();
|
|
|
|
}
|
|
|
|
|
|
|
|
void onCheckedBgSizeChange() {
|
|
|
|
if (checkedBgSize()->getSelectedItemIndex() == int(app::gen::BgType::CHECKED_CUSTOM)) {
|
|
|
|
checkedBgCustomW()->setTextf("%d", m_curPref->bg.size().w);
|
|
|
|
checkedBgCustomH()->setTextf("%d", m_curPref->bg.size().h);
|
|
|
|
checkedBgCustomW()->setVisible(true);
|
|
|
|
checkedBgCustomH()->setVisible(true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
checkedBgCustomW()->setVisible(false);
|
|
|
|
checkedBgCustomH()->setVisible(false);
|
|
|
|
}
|
|
|
|
sectionBg()->layout();
|
2016-12-05 22:06:32 +08:00
|
|
|
}
|
|
|
|
|
2015-02-15 10:31:11 +08:00
|
|
|
void onChangeGridScope() {
|
|
|
|
int item = gridScope()->getSelectedItemIndex();
|
|
|
|
|
|
|
|
switch (item) {
|
2015-02-15 20:48:38 +08:00
|
|
|
case 0: m_curPref = &m_globPref; break;
|
|
|
|
case 1: m_curPref = &m_docPref; break;
|
2015-02-15 10:31:11 +08:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
gridVisible()->setSelected(m_curPref->show.grid());
|
|
|
|
gridX()->setTextf("%d", m_curPref->grid.bounds().x);
|
|
|
|
gridY()->setTextf("%d", m_curPref->grid.bounds().y);
|
|
|
|
gridW()->setTextf("%d", m_curPref->grid.bounds().w);
|
|
|
|
gridH()->setTextf("%d", m_curPref->grid.bounds().h);
|
|
|
|
|
2017-03-25 12:15:40 +08:00
|
|
|
gridColor()->setColor(m_curPref->grid.color());
|
2015-02-15 20:48:38 +08:00
|
|
|
gridOpacity()->setValue(m_curPref->grid.opacity());
|
|
|
|
gridAutoOpacity()->setSelected(m_curPref->grid.autoOpacity());
|
2015-02-15 10:31:11 +08:00
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
pixelGridVisible()->setSelected(m_curPref->show.pixelGrid());
|
2017-03-25 12:15:40 +08:00
|
|
|
pixelGridColor()->setColor(m_curPref->pixelGrid.color());
|
2015-02-15 20:48:38 +08:00
|
|
|
pixelGridOpacity()->setValue(m_curPref->pixelGrid.opacity());
|
|
|
|
pixelGridAutoOpacity()->setSelected(m_curPref->pixelGrid.autoOpacity());
|
2016-12-05 22:06:32 +08:00
|
|
|
}
|
2015-02-15 10:31:11 +08:00
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
void onResetBg() {
|
2016-12-05 22:58:26 +08:00
|
|
|
DocumentPreferences& pref = m_globPref;
|
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
// Reset global preferences (use default values specified in pref.xml)
|
|
|
|
if (m_curPref == &m_globPref) {
|
|
|
|
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type.defaultValue()));
|
2018-11-15 21:07:40 +08:00
|
|
|
checkedBgCustomW()->setVisible(false);
|
|
|
|
checkedBgCustomH()->setVisible(false);
|
2016-12-05 22:06:32 +08:00
|
|
|
checkedBgZoom()->setSelected(pref.bg.zoom.defaultValue());
|
2017-03-25 12:15:40 +08:00
|
|
|
checkedBgColor1()->setColor(pref.bg.color1.defaultValue());
|
|
|
|
checkedBgColor2()->setColor(pref.bg.color2.defaultValue());
|
2016-12-05 22:06:32 +08:00
|
|
|
}
|
|
|
|
// Reset document preferences with global settings
|
|
|
|
else {
|
|
|
|
checkedBgSize()->setSelectedItemIndex(int(pref.bg.type()));
|
|
|
|
checkedBgZoom()->setSelected(pref.bg.zoom());
|
2017-03-25 12:15:40 +08:00
|
|
|
checkedBgColor1()->setColor(pref.bg.color1());
|
|
|
|
checkedBgColor2()->setColor(pref.bg.color2());
|
2016-12-05 22:06:32 +08:00
|
|
|
}
|
2015-02-15 10:31:11 +08:00
|
|
|
}
|
|
|
|
|
2016-12-05 22:06:32 +08:00
|
|
|
void onResetGrid() {
|
2016-12-05 22:58:26 +08:00
|
|
|
DocumentPreferences& pref = m_globPref;
|
|
|
|
|
2015-05-19 03:53:25 +08:00
|
|
|
// Reset global preferences (use default values specified in pref.xml)
|
2015-02-15 20:59:11 +08:00
|
|
|
if (m_curPref == &m_globPref) {
|
2016-12-05 22:58:26 +08:00
|
|
|
gridVisible()->setSelected(pref.show.grid.defaultValue());
|
|
|
|
gridX()->setTextf("%d", pref.grid.bounds.defaultValue().x);
|
|
|
|
gridY()->setTextf("%d", pref.grid.bounds.defaultValue().y);
|
|
|
|
gridW()->setTextf("%d", pref.grid.bounds.defaultValue().w);
|
|
|
|
gridH()->setTextf("%d", pref.grid.bounds.defaultValue().h);
|
2015-02-15 20:59:11 +08:00
|
|
|
|
2017-03-25 12:15:40 +08:00
|
|
|
gridColor()->setColor(pref.grid.color.defaultValue());
|
2015-02-15 20:59:11 +08:00
|
|
|
gridOpacity()->setValue(pref.grid.opacity.defaultValue());
|
|
|
|
gridAutoOpacity()->setSelected(pref.grid.autoOpacity.defaultValue());
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
pixelGridVisible()->setSelected(pref.show.pixelGrid.defaultValue());
|
2017-03-25 12:15:40 +08:00
|
|
|
pixelGridColor()->setColor(pref.pixelGrid.color.defaultValue());
|
2015-02-15 20:59:11 +08:00
|
|
|
pixelGridOpacity()->setValue(pref.pixelGrid.opacity.defaultValue());
|
|
|
|
pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity.defaultValue());
|
|
|
|
}
|
2015-05-19 03:53:25 +08:00
|
|
|
// Reset document preferences with global settings
|
2015-02-15 20:59:11 +08:00
|
|
|
else {
|
2016-12-05 22:58:26 +08:00
|
|
|
gridVisible()->setSelected(pref.show.grid());
|
|
|
|
gridX()->setTextf("%d", pref.grid.bounds().x);
|
|
|
|
gridY()->setTextf("%d", pref.grid.bounds().y);
|
|
|
|
gridW()->setTextf("%d", pref.grid.bounds().w);
|
|
|
|
gridH()->setTextf("%d", pref.grid.bounds().h);
|
2015-02-15 20:59:11 +08:00
|
|
|
|
2017-03-25 12:15:40 +08:00
|
|
|
gridColor()->setColor(pref.grid.color());
|
2015-02-15 20:59:11 +08:00
|
|
|
gridOpacity()->setValue(pref.grid.opacity());
|
|
|
|
gridAutoOpacity()->setSelected(pref.grid.autoOpacity());
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
pixelGridVisible()->setSelected(pref.show.pixelGrid());
|
2017-03-25 12:15:40 +08:00
|
|
|
pixelGridColor()->setColor(pref.pixelGrid.color());
|
2015-02-15 20:59:11 +08:00
|
|
|
pixelGridOpacity()->setValue(pref.pixelGrid.opacity());
|
|
|
|
pixelGridAutoOpacity()->setSelected(pref.pixelGrid.autoOpacity());
|
|
|
|
}
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
|
|
|
|
2014-08-20 11:11:19 +08:00
|
|
|
void onLocateCrashFolder() {
|
2020-03-07 01:45:13 +08:00
|
|
|
app::launcher::open_folder(
|
|
|
|
base::get_file_path(App::instance()->memoryDumpFilename()));
|
2014-08-20 11:11:19 +08:00
|
|
|
}
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
void onLocateConfigFile() {
|
2014-10-17 08:27:25 +08:00
|
|
|
app::launcher::open_folder(app::main_config_filename());
|
2014-06-23 08:56:04 +08:00
|
|
|
}
|
|
|
|
|
2017-10-26 04:58:55 +08:00
|
|
|
void onLimitUndoCheck() {
|
|
|
|
if (limitUndo()->isSelected()) {
|
|
|
|
undoSizeLimit()->setEnabled(true);
|
|
|
|
undoSizeLimit()->setTextf("%d", m_pref.undo.sizeLimit());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
undoSizeLimit()->setEnabled(false);
|
|
|
|
undoSizeLimit()->setText(kInfiniteSymbol);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-20 06:37:39 +08:00
|
|
|
void refillLanguages() {
|
2019-05-07 21:28:37 +08:00
|
|
|
language()->deleteAllItems();
|
2018-03-20 06:37:39 +08:00
|
|
|
loadLanguages();
|
|
|
|
}
|
|
|
|
|
|
|
|
void loadLanguages() {
|
|
|
|
// Languages already loaded
|
|
|
|
if (language()->getItemCount() > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Strings* strings = Strings::instance();
|
|
|
|
std::string curLang = strings->currentLanguage();
|
|
|
|
for (const std::string& lang : strings->availableLanguages()) {
|
|
|
|
int i = language()->addItem(lang);
|
|
|
|
if (lang == curLang)
|
|
|
|
language()->setSelectedItemIndex(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-13 22:51:49 +08:00
|
|
|
void reloadThemes() {
|
|
|
|
while (themeList()->firstChild())
|
|
|
|
delete themeList()->lastChild();
|
|
|
|
|
|
|
|
loadThemes();
|
|
|
|
}
|
|
|
|
|
2015-09-18 23:23:02 +08:00
|
|
|
void loadThemes() {
|
|
|
|
// Themes already loaded
|
|
|
|
if (themeList()->getItemsCount() > 0)
|
|
|
|
return;
|
|
|
|
|
2017-06-13 22:51:49 +08:00
|
|
|
auto theme = skin::SkinTheme::instance();
|
2016-07-21 05:30:03 +08:00
|
|
|
auto userFolder = userThemeFolder();
|
|
|
|
auto folders = themeFolders();
|
|
|
|
std::sort(folders.begin(), folders.end());
|
2017-06-13 22:51:49 +08:00
|
|
|
const auto& selectedPath = theme->path();
|
2016-07-21 05:30:03 +08:00
|
|
|
|
2017-06-13 22:51:49 +08:00
|
|
|
bool first = true;
|
2016-07-21 05:30:03 +08:00
|
|
|
for (const auto& path : folders) {
|
|
|
|
auto files = base::list_files(path);
|
|
|
|
|
|
|
|
// Only one empty theme folder: the user folder
|
|
|
|
if (files.empty() && path != userFolder)
|
2015-09-18 23:23:02 +08:00
|
|
|
continue;
|
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
std::sort(files.begin(), files.end());
|
|
|
|
for (auto& fn : files) {
|
2017-06-13 22:51:49 +08:00
|
|
|
std::string fullPath =
|
|
|
|
base::normalize_path(
|
|
|
|
base::join_path(path, fn));
|
|
|
|
if (!base::is_directory(fullPath))
|
2016-07-21 05:30:03 +08:00
|
|
|
continue;
|
|
|
|
|
2017-06-13 22:51:49 +08:00
|
|
|
if (first) {
|
|
|
|
first = false;
|
2017-07-25 02:13:32 +08:00
|
|
|
themeList()->addChild(
|
|
|
|
new SeparatorInView(base::normalize_path(path), HORIZONTAL));
|
2017-06-13 22:51:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ThemeItem* item = new ThemeItem(fullPath, fn);
|
|
|
|
themeList()->addChild(item);
|
|
|
|
|
|
|
|
// Selected theme
|
|
|
|
if (fullPath == selectedPath)
|
|
|
|
themeList()->selectChild(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Themes from extensions
|
|
|
|
first = true;
|
|
|
|
for (auto ext : App::instance()->extensions()) {
|
|
|
|
if (!ext->isEnabled())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (ext->themes().empty())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (first) {
|
|
|
|
first = false;
|
2017-07-25 02:13:32 +08:00
|
|
|
themeList()->addChild(
|
2017-07-25 21:47:33 +08:00
|
|
|
new SeparatorInView("Extension Themes", HORIZONTAL));
|
2017-06-13 22:51:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (auto it : ext->themes()) {
|
|
|
|
ThemeItem* item = new ThemeItem(it.second, it.first);
|
2016-07-21 05:30:03 +08:00
|
|
|
themeList()->addChild(item);
|
2015-09-18 23:23:02 +08:00
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
// Selected theme
|
2017-06-13 22:51:49 +08:00
|
|
|
if (it.second == selectedPath)
|
2016-07-21 05:30:03 +08:00
|
|
|
themeList()->selectChild(item);
|
|
|
|
}
|
2015-09-18 23:23:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
themeList()->layout();
|
|
|
|
}
|
|
|
|
|
2017-06-11 02:02:39 +08:00
|
|
|
void loadExtensions() {
|
|
|
|
// Extensions already loaded
|
|
|
|
if (extensionsList()->getItemsCount() > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (auto extension : App::instance()->extensions()) {
|
|
|
|
ExtensionItem* item = new ExtensionItem(extension);
|
|
|
|
extensionsList()->addChild(item);
|
|
|
|
}
|
2018-04-03 20:36:32 +08:00
|
|
|
extensionsList()->sortItems();
|
2017-06-11 02:02:39 +08:00
|
|
|
|
|
|
|
onExtensionChange();
|
|
|
|
extensionsList()->layout();
|
|
|
|
}
|
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
void onThemeChange() {
|
|
|
|
ThemeItem* item = dynamic_cast<ThemeItem*>(themeList()->getSelectedChild());
|
|
|
|
selectTheme()->setEnabled(item && item->canSelect());
|
2017-06-13 22:51:49 +08:00
|
|
|
openThemeFolder()->setEnabled(item != nullptr);
|
2016-07-21 05:30:03 +08:00
|
|
|
}
|
|
|
|
|
2015-09-18 23:23:02 +08:00
|
|
|
void onSelectTheme() {
|
2017-08-23 02:44:44 +08:00
|
|
|
ThemeItem* item = dynamic_cast<ThemeItem*>(themeList()->getSelectedChild());
|
|
|
|
if (item)
|
|
|
|
setUITheme(item->themeName(), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setUITheme(const std::string& themeName,
|
|
|
|
const bool updateScaling) {
|
2017-08-19 06:23:23 +08:00
|
|
|
try {
|
2017-08-23 02:44:44 +08:00
|
|
|
if (themeName != m_pref.theme.selected()) {
|
2017-08-19 06:23:23 +08:00
|
|
|
auto theme = static_cast<skin::SkinTheme*>(ui::get_theme());
|
|
|
|
|
|
|
|
// Change theme name from preferences
|
2017-08-23 02:44:44 +08:00
|
|
|
m_pref.theme.selected(themeName);
|
2017-08-19 06:23:23 +08:00
|
|
|
|
2017-09-29 00:22:59 +08:00
|
|
|
// Change the UI theme
|
2017-08-19 06:23:23 +08:00
|
|
|
ui::set_theme(theme, m_pref.general.uiScale());
|
|
|
|
|
2017-09-29 00:22:59 +08:00
|
|
|
// Ask for new scaling
|
|
|
|
const int newUIScale = theme->preferredUIScaling();
|
|
|
|
const int newScreenScale = theme->preferredScreenScaling();
|
|
|
|
|
|
|
|
if (updateScaling &&
|
|
|
|
((newUIScale > 0 && m_pref.general.uiScale() != newUIScale) ||
|
|
|
|
(newScreenScale > 0 && m_pref.general.screenScale() != newScreenScale))) {
|
|
|
|
// Ask if the user want to adjust the Screen/UI Scaling
|
|
|
|
const int result =
|
|
|
|
ui::Alert::show(
|
2017-10-18 05:00:45 +08:00
|
|
|
fmt::format(
|
|
|
|
Strings::alerts_update_screen_ui_scaling_with_theme_values(),
|
|
|
|
themeName,
|
|
|
|
100 * m_pref.general.screenScale(),
|
|
|
|
100 * (newScreenScale > 0 ? newScreenScale: m_pref.general.screenScale()),
|
|
|
|
100 * m_pref.general.uiScale(),
|
|
|
|
100 * (newUIScale > 0 ? newUIScale: m_pref.general.uiScale())));
|
2017-09-29 00:22:59 +08:00
|
|
|
|
|
|
|
if (result == 1) {
|
|
|
|
// Preferred UI Scaling factor
|
|
|
|
if (newUIScale > 0 &&
|
|
|
|
newUIScale != m_pref.general.uiScale()) {
|
|
|
|
m_pref.general.uiScale(newUIScale);
|
|
|
|
ui::set_theme(theme, m_pref.general.uiScale());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Preferred Screen Scaling
|
|
|
|
if (newScreenScale > 0 &&
|
|
|
|
newScreenScale != m_pref.general.screenScale()) {
|
|
|
|
m_pref.general.screenScale(newScreenScale);
|
|
|
|
updateScreenScaling();
|
|
|
|
}
|
|
|
|
|
|
|
|
selectScalingItems();
|
2017-08-23 02:44:44 +08:00
|
|
|
}
|
2017-08-19 06:23:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (const std::exception& ex) {
|
|
|
|
Console::showException(ex);
|
2015-09-18 23:23:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-18 23:39:46 +08:00
|
|
|
void onOpenThemeFolder() {
|
2016-07-21 05:30:03 +08:00
|
|
|
ThemeItem* item = dynamic_cast<ThemeItem*>(themeList()->getSelectedChild());
|
|
|
|
if (item)
|
|
|
|
item->openFolder();
|
2015-09-18 23:39:46 +08:00
|
|
|
}
|
|
|
|
|
2017-06-11 02:02:39 +08:00
|
|
|
void onExtensionChange() {
|
|
|
|
ExtensionItem* item = dynamic_cast<ExtensionItem*>(extensionsList()->getSelectedChild());
|
|
|
|
if (item && item->isInstalled()) {
|
2019-09-23 19:54:04 +08:00
|
|
|
disableExtension()->setText(item->isEnabled() ?
|
|
|
|
Strings::options_disable_extension():
|
|
|
|
Strings::options_enable_extension());
|
2017-06-13 23:04:40 +08:00
|
|
|
disableExtension()->processMnemonicFromText();
|
2017-06-11 02:02:39 +08:00
|
|
|
disableExtension()->setEnabled(item->isEnabled() ? item->canBeDisabled(): true);
|
|
|
|
uninstallExtension()->setEnabled(item->canBeUninstalled());
|
|
|
|
openExtensionFolder()->setEnabled(true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
disableExtension()->setEnabled(false);
|
|
|
|
uninstallExtension()->setEnabled(false);
|
|
|
|
openExtensionFolder()->setEnabled(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-12 23:38:53 +08:00
|
|
|
void onAddExtension() {
|
2018-11-28 21:30:33 +08:00
|
|
|
base::paths exts = { "aseprite-extension", "zip" };
|
2018-02-21 21:39:30 +08:00
|
|
|
base::paths filename;
|
2017-06-12 23:38:53 +08:00
|
|
|
if (!app::show_file_selector(
|
2019-09-23 19:54:04 +08:00
|
|
|
Strings::options_add_extension_title(), "", exts,
|
2017-06-12 23:38:53 +08:00
|
|
|
FileSelectorType::Open, filename))
|
|
|
|
return;
|
|
|
|
|
|
|
|
ASSERT(!filename.empty());
|
2018-11-28 21:30:33 +08:00
|
|
|
installExtension(filename.front());
|
|
|
|
}
|
2017-06-12 23:38:53 +08:00
|
|
|
|
2018-11-28 21:30:33 +08:00
|
|
|
void installExtension(const std::string& filename) {
|
2017-06-23 19:29:21 +08:00
|
|
|
try {
|
|
|
|
Extensions& exts = App::instance()->extensions();
|
2017-06-23 18:53:31 +08:00
|
|
|
|
2017-06-23 19:29:21 +08:00
|
|
|
// Get the extension information from the compressed
|
|
|
|
// package.json file.
|
2018-11-28 21:30:33 +08:00
|
|
|
ExtensionInfo info = exts.getCompressedExtensionInfo(filename);
|
2017-06-23 19:29:21 +08:00
|
|
|
|
|
|
|
// Check if the extension already exist
|
|
|
|
for (auto ext : exts) {
|
|
|
|
if (base::string_to_lower(ext->name()) !=
|
|
|
|
base::string_to_lower(info.name))
|
|
|
|
continue;
|
2017-06-23 18:53:31 +08:00
|
|
|
|
2017-06-23 19:29:21 +08:00
|
|
|
bool isDowngrade =
|
|
|
|
base::Version(info.version.c_str()) <
|
|
|
|
base::Version(ext->version().c_str());
|
|
|
|
|
|
|
|
// Uninstall?
|
|
|
|
if (ui::Alert::show(
|
2017-10-18 05:00:45 +08:00
|
|
|
fmt::format(
|
|
|
|
Strings::alerts_update_extension(),
|
|
|
|
ext->name(),
|
|
|
|
(isDowngrade ? Strings::alerts_update_extension_downgrade():
|
|
|
|
Strings::alerts_update_extension_upgrade()),
|
|
|
|
ext->version(),
|
|
|
|
info.version)) != 1)
|
2017-06-23 19:29:21 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
// Uninstall old version
|
|
|
|
if (ext->canBeUninstalled()) {
|
|
|
|
exts.uninstallExtension(ext);
|
|
|
|
|
|
|
|
ExtensionItem* item = getItemByExtension(ext);
|
|
|
|
if (item)
|
|
|
|
deleteExtensionItem(item);
|
|
|
|
}
|
|
|
|
break;
|
2017-06-23 18:53:31 +08:00
|
|
|
}
|
|
|
|
|
2018-11-28 21:30:33 +08:00
|
|
|
Extension* ext = exts.installCompressedExtension(filename, info);
|
2017-06-23 18:53:31 +08:00
|
|
|
|
|
|
|
// Enable extension
|
|
|
|
exts.enableExtension(ext, true);
|
2017-06-12 23:38:53 +08:00
|
|
|
|
|
|
|
// Add the new extension in the listbox
|
2017-06-23 18:53:31 +08:00
|
|
|
ExtensionItem* item = new ExtensionItem(ext);
|
2017-06-12 23:38:53 +08:00
|
|
|
extensionsList()->addChild(item);
|
2018-11-28 21:30:33 +08:00
|
|
|
extensionsList()->sortItems();
|
2017-06-12 23:38:53 +08:00
|
|
|
extensionsList()->layout();
|
2018-11-28 21:30:33 +08:00
|
|
|
extensionsList()->selectChild(item);
|
2017-06-12 23:38:53 +08:00
|
|
|
}
|
2017-08-19 06:23:23 +08:00
|
|
|
catch (const std::exception& ex) {
|
2017-06-12 23:38:53 +08:00
|
|
|
Console::showException(ex);
|
|
|
|
}
|
2017-06-11 02:02:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void onDisableExtension() {
|
|
|
|
ExtensionItem* item = dynamic_cast<ExtensionItem*>(extensionsList()->getSelectedChild());
|
|
|
|
if (item) {
|
|
|
|
item->enable(!item->isEnabled());
|
|
|
|
onExtensionChange();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void onUninstallExtension() {
|
|
|
|
ExtensionItem* item = dynamic_cast<ExtensionItem*>(extensionsList()->getSelectedChild());
|
2017-06-12 23:38:53 +08:00
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ui::Alert::show(
|
2017-10-18 05:00:45 +08:00
|
|
|
fmt::format(
|
|
|
|
Strings::alerts_uninstall_extension_warning(),
|
|
|
|
item->text())) != 1)
|
2017-06-12 23:38:53 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
try {
|
2017-06-11 02:02:39 +08:00
|
|
|
item->uninstall();
|
2017-06-23 18:53:31 +08:00
|
|
|
deleteExtensionItem(item);
|
2017-06-12 23:38:53 +08:00
|
|
|
}
|
2017-08-19 06:23:23 +08:00
|
|
|
catch (const std::exception& ex) {
|
2017-06-12 23:38:53 +08:00
|
|
|
Console::showException(ex);
|
2017-06-11 02:02:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-23 18:53:31 +08:00
|
|
|
void deleteExtensionItem(ExtensionItem* item) {
|
|
|
|
// Remove the item from the list
|
|
|
|
extensionsList()->removeChild(item);
|
|
|
|
extensionsList()->layout();
|
|
|
|
item->deferDelete();
|
|
|
|
}
|
|
|
|
|
|
|
|
ExtensionItem* getItemByExtension(Extension* ext) {
|
|
|
|
for (auto child : extensionsList()->children()) {
|
|
|
|
ExtensionItem* item = dynamic_cast<ExtensionItem*>(child);
|
|
|
|
if (item && item->extension() == ext)
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2017-06-11 02:02:39 +08:00
|
|
|
void onOpenExtensionFolder() {
|
|
|
|
ExtensionItem* item = dynamic_cast<ExtensionItem*>(extensionsList()->getSelectedChild());
|
|
|
|
if (item)
|
|
|
|
item->openFolder();
|
|
|
|
}
|
|
|
|
|
2016-03-25 01:29:15 +08:00
|
|
|
void onCursorColorType() {
|
|
|
|
switch (cursorColorType()->getSelectedItemIndex()) {
|
|
|
|
case 0:
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setColor(app::Color::fromMask());
|
|
|
|
cursorColor()->setVisible(false);
|
2016-03-25 01:29:15 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2017-03-25 12:15:40 +08:00
|
|
|
cursorColor()->setColor(app::Color::fromRgb(0, 0, 0, 255));
|
|
|
|
cursorColor()->setVisible(true);
|
2016-03-25 01:29:15 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
layout();
|
|
|
|
}
|
|
|
|
|
2016-12-05 22:58:26 +08:00
|
|
|
gfx::Rect gridBounds() const {
|
|
|
|
return gfx::Rect(gridX()->textInt(), gridY()->textInt(),
|
|
|
|
gridW()->textInt(), gridH()->textInt());
|
|
|
|
}
|
|
|
|
|
2016-07-21 05:30:03 +08:00
|
|
|
static std::string userThemeFolder() {
|
2015-09-18 23:39:46 +08:00
|
|
|
ResourceFinder rf;
|
2017-02-10 00:18:44 +08:00
|
|
|
rf.includeDataDir(skin::SkinTheme::kThemesFolderName);
|
2016-07-21 05:30:03 +08:00
|
|
|
|
2017-06-14 23:06:55 +08:00
|
|
|
#if 0 // Don't create the user folder to store themes because now we prefer extensions
|
2016-07-21 05:30:03 +08:00
|
|
|
try {
|
|
|
|
if (!base::is_directory(rf.defaultFilename()))
|
|
|
|
base::make_all_directories(rf.defaultFilename());
|
|
|
|
}
|
|
|
|
catch (...) {
|
|
|
|
// Ignore errors
|
|
|
|
}
|
2017-06-14 23:06:55 +08:00
|
|
|
#endif
|
2016-07-21 05:30:03 +08:00
|
|
|
|
|
|
|
return base::normalize_path(rf.defaultFilename());
|
|
|
|
}
|
|
|
|
|
2018-02-21 21:39:30 +08:00
|
|
|
static base::paths themeFolders() {
|
2016-07-21 05:30:03 +08:00
|
|
|
ResourceFinder rf;
|
2017-02-10 00:18:44 +08:00
|
|
|
rf.includeDataDir(skin::SkinTheme::kThemesFolderName);
|
2016-07-21 05:30:03 +08:00
|
|
|
|
2018-02-21 21:39:30 +08:00
|
|
|
base::paths paths;
|
2016-07-21 05:30:03 +08:00
|
|
|
while (rf.next())
|
|
|
|
paths.push_back(base::normalize_path(rf.filename()));
|
|
|
|
return paths;
|
2015-09-18 23:39:46 +08:00
|
|
|
}
|
|
|
|
|
2019-10-11 02:08:59 +08:00
|
|
|
Context* m_context;
|
2016-03-25 01:29:15 +08:00
|
|
|
Preferences& m_pref;
|
2015-02-15 10:31:11 +08:00
|
|
|
DocumentPreferences& m_globPref;
|
2014-12-28 22:06:11 +08:00
|
|
|
DocumentPreferences& m_docPref;
|
2015-02-15 10:31:11 +08:00
|
|
|
DocumentPreferences* m_curPref;
|
2015-02-15 09:43:21 +08:00
|
|
|
int& m_curSection;
|
2018-03-20 06:37:39 +08:00
|
|
|
obs::scoped_connection m_extLanguagesChanges;
|
2017-06-13 22:51:49 +08:00
|
|
|
obs::scoped_connection m_extThemesChanges;
|
2017-08-23 02:44:44 +08:00
|
|
|
std::string m_restoreThisTheme;
|
|
|
|
int m_restoreScreenScaling;
|
|
|
|
int m_restoreUIScaling;
|
2018-10-19 02:29:16 +08:00
|
|
|
std::vector<os::ColorSpacePtr> m_colorSpaces;
|
2019-05-08 21:55:56 +08:00
|
|
|
std::string m_templateTextForDisplayCS;
|
2014-06-23 08:56:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class OptionsCommand : public Command {
|
|
|
|
public:
|
|
|
|
OptionsCommand();
|
|
|
|
|
|
|
|
protected:
|
2018-11-28 21:30:33 +08:00
|
|
|
void onLoadParams(const Params& params) override;
|
2015-10-01 03:34:43 +08:00
|
|
|
void onExecute(Context* context) override;
|
2018-11-28 21:30:33 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::string m_installExtensionFilename;
|
2014-06-23 08:56:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
OptionsCommand::OptionsCommand()
|
2017-12-02 02:10:21 +08:00
|
|
|
: Command(CommandId::Options(), CmdUIOnlyFlag)
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
2015-05-19 03:53:25 +08:00
|
|
|
Preferences& preferences = Preferences::instance();
|
2014-12-15 07:19:31 +08:00
|
|
|
|
2014-10-25 22:24:29 +08:00
|
|
|
ui::MenuBar::setExpandOnMouseover(
|
2014-12-15 07:19:31 +08:00
|
|
|
preferences.general.expandMenubarOnMouseover());
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
2018-11-28 21:30:33 +08:00
|
|
|
void OptionsCommand::onLoadParams(const Params& params)
|
|
|
|
{
|
|
|
|
m_installExtensionFilename = params.get("installExtension");
|
|
|
|
}
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
void OptionsCommand::onExecute(Context* context)
|
2014-06-14 10:00:49 +08:00
|
|
|
{
|
2015-02-15 09:43:21 +08:00
|
|
|
static int curSection = 0;
|
|
|
|
|
|
|
|
OptionsWindow window(context, curSection);
|
2018-11-28 21:30:33 +08:00
|
|
|
window.openWindow();
|
|
|
|
|
|
|
|
if (!m_installExtensionFilename.empty()) {
|
|
|
|
if (!window.showDialogToInstallExtension(m_installExtensionFilename))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-23 08:56:04 +08:00
|
|
|
window.openWindowInForeground();
|
2015-02-12 23:16:25 +08:00
|
|
|
if (window.ok())
|
2014-06-23 08:56:04 +08:00
|
|
|
window.saveConfig();
|
2017-08-23 02:44:44 +08:00
|
|
|
else
|
|
|
|
window.restoreTheme();
|
2014-06-14 10:00:49 +08:00
|
|
|
}
|
|
|
|
|
2012-01-06 06:45:03 +08:00
|
|
|
Command* CommandFactory::createOptionsCommand()
|
|
|
|
{
|
|
|
|
return new OptionsCommand;
|
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
} // namespace app
|