mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-02 11:10:31 +03:00
Settings Panel fixes.
Fix Haiku default modifier.
This commit is contained in:
@@ -693,7 +693,7 @@ enum KeyModTable {
|
|||||||
#if EE_PLATFORM == EE_PLATFORM_MACOS
|
#if EE_PLATFORM == EE_PLATFORM_MACOS
|
||||||
#define KEYMOD_DEFAULT_MODIFIER KEYMOD_META
|
#define KEYMOD_DEFAULT_MODIFIER KEYMOD_META
|
||||||
#elif EE_PLATFORM == EE_PLATFORM_HAIKU
|
#elif EE_PLATFORM == EE_PLATFORM_HAIKU
|
||||||
#define KEYMOD_DEFAULT_MODIFIER KEYMOD_ALT
|
#define KEYMOD_DEFAULT_MODIFIER KEYMOD_LALT
|
||||||
#else
|
#else
|
||||||
#define KEYMOD_DEFAULT_MODIFIER KEYMOD_CTRL
|
#define KEYMOD_DEFAULT_MODIFIER KEYMOD_CTRL
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ UISpinBox::UISpinBox() :
|
|||||||
mInput->setVisible( true );
|
mInput->setVisible( true );
|
||||||
mInput->setEnabled( true );
|
mInput->setEnabled( true );
|
||||||
mInput->setParent( this );
|
mInput->setParent( this );
|
||||||
|
mInput->setFlags( UI_SCROLLABLE );
|
||||||
|
|
||||||
auto cb = [this]( const Event* ) { adjustChildren(); };
|
auto cb = [this]( const Event* ) { adjustChildren(); };
|
||||||
|
|
||||||
|
|||||||
@@ -160,26 +160,25 @@ void FontPickerController::openFontDialog( std::string& fontPath, bool loadingMo
|
|||||||
if ( fontPath != newPath ) {
|
if ( fontPath != newPath ) {
|
||||||
if ( !loadingMonoFont ) {
|
if ( !loadingMonoFont ) {
|
||||||
fontPath = newPath;
|
fontPath = newPath;
|
||||||
if ( onFinish )
|
} else {
|
||||||
onFinish();
|
FontTrueTypePtr previewFont = preview && newPath != preview->originalPath
|
||||||
return;
|
? loadPreviewFont( selection.font )
|
||||||
}
|
: FontTrueTypePtr{};
|
||||||
|
FontTrueType* fontMono = previewFont ? previewFont.get() : preview->originalFont;
|
||||||
FontTrueTypePtr previewFont = preview && newPath != preview->originalPath
|
if ( fontMono ) {
|
||||||
? loadPreviewFont( selection.font )
|
fontPath = newPath;
|
||||||
: FontTrueTypePtr{};
|
if ( preview )
|
||||||
FontTrueType* fontMono = previewFont ? previewFont.get() : preview->originalFont;
|
preview->confirmed = true;
|
||||||
if ( fontMono ) {
|
publishPreviewFont( newPath, previewFont );
|
||||||
fontPath = newPath;
|
applyMonospaceFont( fontMono, previewFont != nullptr );
|
||||||
if ( preview )
|
}
|
||||||
preview->confirmed = true;
|
|
||||||
publishPreviewFont( newPath, previewFont );
|
|
||||||
applyMonospaceFont( fontMono, previewFont != nullptr );
|
|
||||||
}
|
}
|
||||||
} else if ( preview ) {
|
} else if ( preview ) {
|
||||||
preview->confirmed = true;
|
preview->confirmed = true;
|
||||||
applyMonospaceFont( preview->originalFont, false );
|
applyMonospaceFont( preview->originalFont, false );
|
||||||
}
|
}
|
||||||
|
if ( onFinish )
|
||||||
|
onFinish();
|
||||||
} );
|
} );
|
||||||
if ( pickFontSize ) {
|
if ( pickFontSize ) {
|
||||||
UIFontSelection selection = dialog->getSelection();
|
UIFontSelection selection = dialog->getSelection();
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ bool SettingsPage::addJsonObject( std::string id, std::string jsonPointer, Strin
|
|||||||
document->setValue( jsonPointer, std::move( parsed ) );
|
document->setValue( jsonPointer, std::move( parsed ) );
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
true } } );
|
false } } );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SettingsPage::addStringList( std::string id, std::string jsonPointer, String name,
|
bool SettingsPage::addStringList( std::string id, std::string jsonPointer, String name,
|
||||||
|
|||||||
@@ -629,6 +629,20 @@ void SettingsPanel::addAction( PanelState& panel, SettingDescriptor binding,
|
|||||||
{ std::move( binding ), ActionSetting{ buttonText, std::move( action ) } } );
|
{ std::move( binding ), ActionSetting{ buttonText, std::move( action ) } } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsPanel::refreshTextSetting( PanelState& panel, const std::string& id ) {
|
||||||
|
const auto& settings = panel.model.settings();
|
||||||
|
for ( size_t i = 0; i < settings.size(); ++i ) {
|
||||||
|
if ( settings[i].descriptor.id != id || i >= panel.settingViews.size() ||
|
||||||
|
!panel.settingViews[i].row )
|
||||||
|
continue;
|
||||||
|
auto* value = std::get_if<TextSetting>( &settings[i].value );
|
||||||
|
auto* input = panel.settingViews[i].row->find<UITextInput>( "setting_control_widget" );
|
||||||
|
if ( value && input )
|
||||||
|
input->setText( String::fromUtf8( value->get() ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void setNodeTreeEnabled( Node* node, bool enabled );
|
static void setNodeTreeEnabled( Node* node, bool enabled );
|
||||||
|
|
||||||
void SettingsPanel::materializeCategory( PanelState& panel, const std::string& category ) {
|
void SettingsPanel::materializeCategory( PanelState& panel, const std::string& category ) {
|
||||||
@@ -724,7 +738,7 @@ void SettingsPanel::materializeCategory( PanelState& panel, const std::string& c
|
|||||||
if ( value->password )
|
if ( value->password )
|
||||||
input->setMode( UITextInput::TextInputMode::Password );
|
input->setMode( UITextInput::TextInputMode::Password );
|
||||||
input->setText( String::fromUtf8( value->get() ) );
|
input->setText( String::fromUtf8( value->get() ) );
|
||||||
auto commit = [input, value]( const Event* ) {
|
auto commit = [input, value] {
|
||||||
if ( !value->set( input->getText().toUtf8() ) ) {
|
if ( !value->set( input->getText().toUtf8() ) ) {
|
||||||
input->addClass( "error" );
|
input->addClass( "error" );
|
||||||
return;
|
return;
|
||||||
@@ -732,10 +746,21 @@ void SettingsPanel::materializeCategory( PanelState& panel, const std::string& c
|
|||||||
input->removeClass( "error" );
|
input->removeClass( "error" );
|
||||||
};
|
};
|
||||||
if ( value->commitOnFocusLoss ) {
|
if ( value->commitOnFocusLoss ) {
|
||||||
panel.connections += input->connect( Event::OnPressEnter, commit );
|
const auto debounceTag = reinterpret_cast<Action::UniqueID>( input );
|
||||||
panel.connections += input->connect( Event::OnFocusLoss, std::move( commit ) );
|
panel.connections += input->connect(
|
||||||
|
Event::OnTextChanged, [input, commit, debounceTag]( const Event* ) {
|
||||||
|
input->debounce( commit, Milliseconds( 500 ), debounceTag );
|
||||||
|
} );
|
||||||
|
auto flush = [input, commit, debounceTag]( const Event* ) {
|
||||||
|
input->removeActionsByTag( debounceTag );
|
||||||
|
commit();
|
||||||
|
};
|
||||||
|
panel.connections += input->connect( Event::OnPressEnter, flush );
|
||||||
|
panel.connections += input->connect( Event::OnFocusLoss, std::move( flush ) );
|
||||||
} else {
|
} else {
|
||||||
panel.connections += input->connect( Event::OnTextChanged, std::move( commit ) );
|
panel.connections +=
|
||||||
|
input->connect( Event::OnTextChanged,
|
||||||
|
[commit = std::move( commit )]( const Event* ) { commit(); } );
|
||||||
}
|
}
|
||||||
} else if ( auto* value = std::get_if<FloatSetting>( &setting.value ) ) {
|
} else if ( auto* value = std::get_if<FloatSetting>( &setting.value ) ) {
|
||||||
auto* row = createRow( panel, setting, view, SETTINGS_INTEGER_ROW_LAYOUT.root() );
|
auto* row = createRow( panel, setting, view, SETTINGS_INTEGER_ROW_LAYOUT.root() );
|
||||||
@@ -1429,22 +1454,30 @@ void SettingsPanel::addUserSettings( PanelState& panel ) {
|
|||||||
{ "uiFont", "appearance.fonts",
|
{ "uiFont", "appearance.fonts",
|
||||||
mApp->i18n( "ui_font_and_size_ellipsis", "UI Font & Size..." ),
|
mApp->i18n( "ui_font_and_size_ellipsis", "UI Font & Size..." ),
|
||||||
mApp->i18n( "ui_font_desc", "Choose the proportional font used by the interface." ) },
|
mApp->i18n( "ui_font_desc", "Choose the proportional font used by the interface." ) },
|
||||||
mApp->i18n( "choose_font", "Choose Font..." ),
|
mApp->i18n( "choose_font", "Choose Font..." ), [this, &panel] {
|
||||||
[this] { mApp->runCommand( "sans-serif-font" ); } );
|
mApp->openFontDialog( mApp->getConfig().ui.sansSerifFont, false, false,
|
||||||
|
[this, &panel] { refreshTextSetting( panel, "uiFontSize" ); } );
|
||||||
|
} );
|
||||||
addAction(
|
addAction(
|
||||||
panel,
|
panel,
|
||||||
{ "editorFont", "appearance.fonts",
|
{ "editorFont", "appearance.fonts",
|
||||||
mApp->i18n( "editor_font_and_size_ellipsis", "Editor Font & Size..." ),
|
mApp->i18n( "editor_font_and_size_ellipsis", "Editor Font & Size..." ),
|
||||||
mApp->i18n( "editor_font_desc", "Choose the monospace font used by code editors." ) },
|
mApp->i18n( "editor_font_desc", "Choose the monospace font used by code editors." ) },
|
||||||
mApp->i18n( "choose_font", "Choose Font..." ),
|
mApp->i18n( "choose_font", "Choose Font..." ), [this, &panel] {
|
||||||
[this] { mApp->runCommand( "editor-font" ); } );
|
mApp->openFontDialog( mApp->getConfig().ui.monospaceFont, true, false, [this, &panel] {
|
||||||
|
refreshTextSetting( panel, "editorFontSize" );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
addAction(
|
addAction(
|
||||||
panel,
|
panel,
|
||||||
{ "terminalFont", "appearance.fonts",
|
{ "terminalFont", "appearance.fonts",
|
||||||
mApp->i18n( "terminal_font_and_size_ellipsis", "Terminal Font & Size..." ),
|
mApp->i18n( "terminal_font_and_size_ellipsis", "Terminal Font & Size..." ),
|
||||||
mApp->i18n( "terminal_font_desc", "Choose the monospace font used by terminals." ) },
|
mApp->i18n( "terminal_font_desc", "Choose the monospace font used by terminals." ) },
|
||||||
mApp->i18n( "choose_font", "Choose Font..." ),
|
mApp->i18n( "choose_font", "Choose Font..." ), [this, &panel] {
|
||||||
[this] { mApp->runCommand( "terminal-font" ); } );
|
mApp->openFontDialog( mApp->getConfig().ui.terminalFont, true, true, [this, &panel] {
|
||||||
|
refreshTextSetting( panel, "terminalFontSize" );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
addAction( panel,
|
addAction( panel,
|
||||||
{ "fallbackFont", "appearance.fonts",
|
{ "fallbackFont", "appearance.fonts",
|
||||||
mApp->i18n( "fallback_font_ellipsis", "Fallback Font..." ),
|
mApp->i18n( "fallback_font_ellipsis", "Fallback Font..." ),
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ class SettingsPanel {
|
|||||||
|
|
||||||
void addAction( PanelState& state, SettingDescriptor binding, const String& buttonText,
|
void addAction( PanelState& state, SettingDescriptor binding, const String& buttonText,
|
||||||
std::function<void()> action );
|
std::function<void()> action );
|
||||||
|
void refreshTextSetting( PanelState& state, const std::string& id );
|
||||||
|
|
||||||
UIWidget* createRow( PanelState& state, SettingDefinition& setting, SettingView& view,
|
UIWidget* createRow( PanelState& state, SettingDefinition& setting, SettingView& view,
|
||||||
pugi::xml_node layout );
|
pugi::xml_node layout );
|
||||||
|
|||||||
Reference in New Issue
Block a user