Add platform clipboard option to settings
This commit is contained in:
parent
6160a6b7d5
commit
70f6b68fc5
@ -18,6 +18,7 @@ constexpr bool INSTALL_CHECK = @INSTALL_CHECK@;
|
||||
constexpr bool IGNORE_UPDATES = @IGNORE_UPDATES@;
|
||||
constexpr bool ENFORCE_HTTPS = @ENFORCE_HTTPS@;
|
||||
constexpr bool SECURE_CIPHERS_ONLY = @SECURE_CIPHERS_ONLY@;
|
||||
constexpr bool PLATFORM_CLIPBOARD = @PLATFORM_CLIPBOARD@;
|
||||
constexpr bool USE_SYSTEM_CERT_PROVIDER = @USE_SYSTEM_CERT_PROVIDER@;
|
||||
constexpr bool FFTW_PLAN_MEASURE = @FFTW_PLAN_MEASURE@;
|
||||
constexpr bool ALLOW_QUIT = @ALLOW_QUIT@;
|
||||
|
@ -10,5 +10,7 @@ namespace Clipboard
|
||||
void SetClipboardData(std::unique_ptr<GameSave> data);
|
||||
const GameSave *GetClipboardData();
|
||||
void Init();
|
||||
bool GetEnabled();
|
||||
void SetEnabled(bool newEnabled);
|
||||
void RecreateWindow();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "Dynamic.h"
|
||||
#include "Clipboard.h"
|
||||
#include "client/GameSave.h"
|
||||
#include "prefs/GlobalPrefs.h"
|
||||
#include "PowderToySDL.h"
|
||||
@ -90,8 +91,21 @@ namespace Clipboard
|
||||
return clipboardData.get();
|
||||
}
|
||||
|
||||
static bool enabled = false;
|
||||
void Init()
|
||||
{
|
||||
enabled = GlobalPrefs::Ref().Get<bool>("NativeClipboard.Enabled", true);
|
||||
}
|
||||
|
||||
bool GetEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
void SetEnabled(bool newEnabled)
|
||||
{
|
||||
enabled = newEnabled;
|
||||
RecreateWindow();
|
||||
}
|
||||
|
||||
int currentSubsystem;
|
||||
@ -104,7 +118,7 @@ namespace Clipboard
|
||||
SDL_GetWindowWMInfo(sdl_window, &info);
|
||||
clipboard.reset();
|
||||
currentSubsystem = info.subsystem;
|
||||
if (GlobalPrefs::Ref().Get<bool>("NativeClipboard.Enabled", true))
|
||||
if (enabled)
|
||||
{
|
||||
for (auto *impl = clipboardImpls; impl->factory; ++impl)
|
||||
{
|
||||
|
@ -16,6 +16,15 @@ namespace Clipboard
|
||||
{
|
||||
}
|
||||
|
||||
bool GetEnabled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetEnabled(bool)
|
||||
{
|
||||
}
|
||||
|
||||
void RecreateWindow()
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
if get_option('platform_clipboard')
|
||||
if platform_clipboard
|
||||
clipboard_impl_factories = []
|
||||
if host_platform == 'windows'
|
||||
powder_files += files('Windows.cpp')
|
||||
|
@ -107,6 +107,11 @@ void OptionsController::SetGraveExitsConsole(bool graveExitsConsole)
|
||||
model->SetGraveExitsConsole(graveExitsConsole);
|
||||
}
|
||||
|
||||
void OptionsController::SetNativeClipoard(bool nativeClipoard)
|
||||
{
|
||||
model->SetNativeClipoard(nativeClipoard);
|
||||
}
|
||||
|
||||
void OptionsController::SetResizable(bool resizable)
|
||||
{
|
||||
model->SetResizable(resizable);
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
void SetBlurryScaling(bool newBlurryScaling);
|
||||
void SetScale(int scale);
|
||||
void SetGraveExitsConsole(bool graveExitsConsole);
|
||||
void SetNativeClipoard(bool nativeClipoard);
|
||||
void SetResizable(bool resizable);
|
||||
void SetFastQuit(bool fastquit);
|
||||
void SetDecoSpace(int decoSpace);
|
||||
|
@ -1,13 +1,10 @@
|
||||
#include "OptionsModel.h"
|
||||
|
||||
#include "OptionsView.h"
|
||||
|
||||
#include "simulation/Simulation.h"
|
||||
#include "simulation/Air.h"
|
||||
#include "simulation/gravity/Gravity.h"
|
||||
|
||||
#include "prefs/GlobalPrefs.h"
|
||||
|
||||
#include "common/clipboard/Clipboard.h"
|
||||
#include "gui/interface/Engine.h"
|
||||
#include "gui/game/GameModel.h"
|
||||
|
||||
@ -168,6 +165,18 @@ void OptionsModel::SetGraveExitsConsole(bool graveExitsConsole)
|
||||
notifySettingsChanged();
|
||||
}
|
||||
|
||||
bool OptionsModel::GetNativeClipoard()
|
||||
{
|
||||
return Clipboard::GetEnabled();
|
||||
}
|
||||
|
||||
void OptionsModel::SetNativeClipoard(bool nativeClipoard)
|
||||
{
|
||||
Clipboard::SetEnabled(nativeClipoard);
|
||||
GlobalPrefs::Ref().Set("NativeClipboard.Enabled", nativeClipoard);
|
||||
notifySettingsChanged();
|
||||
}
|
||||
|
||||
bool OptionsModel::GetResizable()
|
||||
{
|
||||
return ui::Engine::Ref().GetResizable();
|
||||
|
@ -41,6 +41,8 @@ public:
|
||||
void SetScale(int scale);
|
||||
bool GetGraveExitsConsole();
|
||||
void SetGraveExitsConsole(bool graveExitsConsole);
|
||||
bool GetNativeClipoard();
|
||||
void SetNativeClipoard(bool nativeClipoard);
|
||||
bool GetResizable();
|
||||
void SetResizable(bool resizable);
|
||||
bool GetFullscreen();
|
||||
|
@ -296,6 +296,12 @@ OptionsView::OptionsView() : ui::Window(ui::Point(-1, -1), ui::Point(320, 340))
|
||||
graveExitsConsole = addCheckbox(0, "Key under Esc exits console", "Disable if that key is 0 on your keyboard", [this] {
|
||||
c->SetGraveExitsConsole(graveExitsConsole->GetChecked());
|
||||
});
|
||||
if constexpr (PLATFORM_CLIPBOARD)
|
||||
{
|
||||
nativeClipoard = addCheckbox(0, "Use platform clipboard", "Allows copying and pasting across TPT instances", [this] {
|
||||
c->SetNativeClipoard(nativeClipoard->GetChecked());
|
||||
});
|
||||
}
|
||||
decoSpace = addDropDown("Colour space used by decoration tools", {
|
||||
{ "sRGB", 0 },
|
||||
{ "Linear", 1 },
|
||||
@ -459,6 +465,10 @@ void OptionsView::NotifySettingsChanged(OptionsModel * sender)
|
||||
{
|
||||
fastquit->SetChecked(sender->GetFastQuit());
|
||||
}
|
||||
if (nativeClipoard)
|
||||
{
|
||||
nativeClipoard->SetChecked(sender->GetNativeClipoard());
|
||||
}
|
||||
showAvatars->SetChecked(sender->GetShowAvatars());
|
||||
mouseClickRequired->SetChecked(sender->GetMouseClickRequired());
|
||||
includePressure->SetChecked(sender->GetIncludePressure());
|
||||
|
@ -40,6 +40,7 @@ class OptionsView: public ui::Window
|
||||
ui::Checkbox *includePressure{};
|
||||
ui::Checkbox *perfectCircle{};
|
||||
ui::Checkbox *graveExitsConsole{};
|
||||
ui::Checkbox *nativeClipoard{};
|
||||
ui::ScrollPanel *scrollPanel{};
|
||||
float customGravityX, customGravityY;
|
||||
void UpdateAmbientAirTempPreview(float airTemp, bool isValid);
|
||||
|
@ -28,6 +28,7 @@ update_server = get_option('update_server')
|
||||
conf_data.set('UPDATESERVER', update_server)
|
||||
conf_data.set('USE_UPDATESERVER', (update_server != '').to_string())
|
||||
|
||||
platform_clipboard = get_option('platform_clipboard')
|
||||
enforce_https = get_option('enforce_https')
|
||||
allow_quit = true
|
||||
force_window_frame_ops = 'forceWindowFrameOpsNone'
|
||||
@ -52,6 +53,7 @@ conf_data.set('DEFAULT_TOUCH_UI', default_touch_ui.to_string())
|
||||
conf_data.set('ALLOW_DATA_FOLDER', allow_data_folder.to_string())
|
||||
conf_data.set('ENFORCE_HTTPS', enforce_https.to_string())
|
||||
conf_data.set('SECURE_CIPHERS_ONLY', secure_ciphers_only.to_string())
|
||||
conf_data.set('PLATFORM_CLIPBOARD', platform_clipboard.to_string())
|
||||
|
||||
conf_data.set('IGNORE_UPDATES', get_option('ignore_updates').to_string())
|
||||
conf_data.set('SERVER', get_option('server'))
|
||||
@ -176,17 +178,19 @@ configure_file(
|
||||
configuration: elements_conf_data
|
||||
)
|
||||
|
||||
clipboard_impl_defs = []
|
||||
foreach impl_subsys_factory : clipboard_impl_factories
|
||||
clipboard_impl_defs += 'IMPL_DEFINE(' + impl_subsys_factory[0] + ', ' + impl_subsys_factory[1] + ')'
|
||||
endforeach
|
||||
clipboard_impls_data = configuration_data()
|
||||
clipboard_impls_data.set('impl_defs', '\n'.join(clipboard_impl_defs))
|
||||
configure_file(
|
||||
input: 'common/clipboard/ClipboardImpls.template.h',
|
||||
output: 'ClipboardImpls.h',
|
||||
configuration: clipboard_impls_data
|
||||
)
|
||||
if platform_clipboard
|
||||
clipboard_impl_defs = []
|
||||
foreach impl_subsys_factory : clipboard_impl_factories
|
||||
clipboard_impl_defs += 'IMPL_DEFINE(' + impl_subsys_factory[0] + ', ' + impl_subsys_factory[1] + ')'
|
||||
endforeach
|
||||
clipboard_impls_data = configuration_data()
|
||||
clipboard_impls_data.set('impl_defs', '\n'.join(clipboard_impl_defs))
|
||||
configure_file(
|
||||
input: 'common/clipboard/ClipboardImpls.template.h',
|
||||
output: 'ClipboardImpls.h',
|
||||
configuration: clipboard_impls_data
|
||||
)
|
||||
endif
|
||||
|
||||
simulation_tool_defs = []
|
||||
foreach tool_name_id : simulation_tool_ids
|
||||
|
Loading…
Reference in New Issue
Block a user