2010-05-21 03:13:36 +02:00
// Copyright (c) 2010, Amar Takhar <verm@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/// @file preferences.cpp
/// @brief Preferences dialogue
/// @ingroup configuration_ui
2011-10-11 02:06:44 +02:00
# include "preferences.h"
2014-05-04 13:03:04 +02:00
# include "ass_style_storage.h"
2014-07-09 16:22:49 +02:00
# include "audio_provider_factory.h"
2011-12-22 22:19:21 +01:00
# include "audio_renderer_waveform.h"
2011-10-28 22:40:43 +02:00
# include "command/command.h"
2010-06-03 22:32:25 +02:00
# include "compat.h"
2012-04-01 04:43:01 +02:00
# include "help_button.h"
2011-10-28 22:40:43 +02:00
# include "hotkey_data_view_model.h"
2010-08-02 08:31:38 +02:00
# include "include/aegisub/audio_player.h"
2011-10-28 22:40:43 +02:00
# include "include/aegisub/hotkey.h"
2010-08-02 08:31:38 +02:00
# include "include/aegisub/subtitles_provider.h"
2011-10-11 02:06:44 +02:00
# include "libresrc/libresrc.h"
2013-01-07 02:50:09 +01:00
# include "options.h"
2010-07-19 19:53:29 +02:00
# include "preferences_base.h"
2011-10-11 02:06:44 +02:00
# include "video_provider_manager.h"
2010-05-21 03:13:36 +02:00
2011-11-28 21:01:58 +01:00
# ifdef WITH_PORTAUDIO
# include "audio_player_portaudio.h"
# endif
2012-03-07 05:25:46 +01:00
# ifdef WITH_FFMS2
# include <ffms.h>
# endif
2013-09-20 16:43:33 +02:00
# include <libaegisub/hotkey.h>
2014-05-03 22:23:01 +02:00
# include <unordered_set>
2013-09-20 16:43:33 +02:00
# include <wx/checkbox.h>
# include <wx/combobox.h>
# include <wx/event.h>
# include <wx/listctrl.h>
# include <wx/msgdlg.h>
# include <wx/srchctrl.h>
# include <wx/sizer.h>
# include <wx/spinctrl.h>
# include <wx/stattext.h>
# include <wx/treebook.h>
2014-07-09 00:16:49 +02:00
namespace {
2014-05-31 05:32:07 +02:00
/// General preferences page
void General ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " General " ) ) ;
2011-10-28 22:40:43 +02:00
2014-05-31 05:32:07 +02:00
auto general = p - > PageSizer ( _ ( " General " ) ) ;
p - > OptionAdd ( general , _ ( " Check for updates on startup " ) , " App/Auto/Check For Updates " ) ;
p - > OptionAdd ( general , _ ( " Show main toolbar " ) , " App/Show Toolbar " ) ;
p - > OptionAdd ( general , _ ( " Save UI state in subtitles files " ) , " App/Save UI State " ) ;
p - > CellSkip ( general ) ;
2011-10-28 22:40:43 +02:00
2014-05-31 05:32:07 +02:00
p - > OptionAdd ( general , _ ( " Toolbar Icon Size " ) , " App/Toolbar Icon Size " ) ;
2011-12-06 20:59:04 +01:00
wxString autoload_modes [ ] = { _ ( " Never " ) , _ ( " Always " ) , _ ( " Ask " ) } ;
wxArrayString autoload_modes_arr ( 3 , autoload_modes ) ;
2014-05-31 05:32:07 +02:00
p - > OptionChoice ( general , _ ( " Automatically load linked files " ) , autoload_modes_arr , " App/Auto/Load Linked Files " ) ;
p - > OptionAdd ( general , _ ( " Undo Levels " ) , " Limits/Undo Levels " , 2 , 10000 ) ;
2010-05-21 03:13:36 +02:00
2014-05-31 05:32:07 +02:00
auto recent = p - > PageSizer ( _ ( " Recently Used Lists " ) ) ;
p - > OptionAdd ( recent , _ ( " Files " ) , " Limits/MRU " , 0 , 16 ) ;
p - > OptionAdd ( recent , _ ( " Find/Replace " ) , " Limits/Find Replace " ) ;
2011-07-15 06:06:23 +02:00
2014-05-31 05:32:07 +02:00
p - > SetSizerAndFit ( p - > sizer ) ;
2010-07-19 19:53:29 +02:00
}
2010-05-21 03:13:36 +02:00
2014-05-31 05:32:07 +02:00
void General_DefaultStyles ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Default styles " ) , OptionPage : : PAGE_SUB ) ;
auto staticbox = new wxStaticBoxSizer ( wxVERTICAL , p , _ ( " Default style catalogs " ) ) ;
p - > sizer - > Add ( staticbox , 0 , wxEXPAND , 5 ) ;
p - > sizer - > AddSpacer ( 8 ) ;
2014-05-03 22:23:01 +02:00
2014-05-31 05:32:07 +02:00
auto instructions = new wxStaticText ( p , wxID_ANY , _ ( " The chosen style catalogs will be loaded when you start a new file or import files in the various formats. \n \n You can set up style catalogs in the Style Manager. " ) ) ;
p - > sizer - > Fit ( p ) ;
2014-05-03 22:23:01 +02:00
instructions - > Wrap ( 400 ) ;
staticbox - > Add ( instructions , 0 , wxALL , 5 ) ;
staticbox - > AddSpacer ( 16 ) ;
auto general = new wxFlexGridSizer ( 2 , 5 , 5 ) ;
general - > AddGrowableCol ( 0 , 1 ) ;
staticbox - > Add ( general , 1 , wxEXPAND , 5 ) ;
// Build a list of available style catalogs, and wished-available ones
2014-05-31 05:32:07 +02:00
auto const & avail_catalogs = AssStyleStorage : : GetCatalogs ( ) ;
std : : unordered_set < std : : string > catalogs_set ( begin ( avail_catalogs ) , end ( avail_catalogs ) ) ;
2014-05-03 22:23:01 +02:00
// Always include one named "Default" even if it doesn't exist (ensure there is at least one on the list)
catalogs_set . insert ( " Default " ) ;
// Include all catalogs named in the existing configuration
2014-05-04 13:14:28 +02:00
static const char * formats [ ] = { " ASS " , " MicroDVD " , " SRT " , " TTXT " , " TXT " } ;
2014-05-03 22:23:01 +02:00
for ( auto formatname : formats )
catalogs_set . insert ( OPT_GET ( " Subtitle Format/ " + std : : string ( formatname ) + " /Default Style Catalog " ) - > GetString ( ) ) ;
// Sorted version
wxArrayString catalogs ;
for ( auto const & cn : catalogs_set )
catalogs . Add ( to_wx ( cn ) ) ;
catalogs . Sort ( ) ;
2014-05-31 05:32:07 +02:00
p - > OptionChoice ( general , _ ( " New files " ) , catalogs , " Subtitle Format/ASS/Default Style Catalog " ) ;
p - > OptionChoice ( general , _ ( " MicroDVD import " ) , catalogs , " Subtitle Format/MicroDVD/Default Style Catalog " ) ;
p - > OptionChoice ( general , _ ( " SRT import " ) , catalogs , " Subtitle Format/SRT/Default Style Catalog " ) ;
p - > OptionChoice ( general , _ ( " TTXT import " ) , catalogs , " Subtitle Format/TTXT/Default Style Catalog " ) ;
p - > OptionChoice ( general , _ ( " Plain text import " ) , catalogs , " Subtitle Format/TXT/Default Style Catalog " ) ;
2014-05-03 22:23:01 +02:00
2014-05-31 05:32:07 +02:00
p - > SetSizerAndFit ( p - > sizer ) ;
2014-05-03 22:23:01 +02:00
}
2010-07-19 14:25:53 +02:00
/// Audio preferences page
2014-05-31 05:32:07 +02:00
void Audio ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Audio " ) ) ;
auto general = p - > PageSizer ( _ ( " Options " ) ) ;
p - > OptionAdd ( general , _ ( " Default mouse wheel to zoom " ) , " Audio/Wheel Default to Zoom " ) ;
p - > OptionAdd ( general , _ ( " Lock scroll on cursor " ) , " Audio/Lock Scroll on Cursor " ) ;
p - > OptionAdd ( general , _ ( " Snap markers by default " ) , " Audio/Snap/Enable " ) ;
p - > OptionAdd ( general , _ ( " Auto-focus on mouse over " ) , " Audio/Auto/Focus " ) ;
p - > OptionAdd ( general , _ ( " Play audio when stepping in video " ) , " Audio/Plays When Stepping Video " ) ;
p - > OptionAdd ( general , _ ( " Left-click-drag moves end marker " ) , " Audio/Drag Timing " ) ;
p - > OptionAdd ( general , _ ( " Default timing length (ms) " ) , " Timing/Default Duration " , 0 , 36000 ) ;
p - > OptionAdd ( general , _ ( " Default lead-in length (ms) " ) , " Audio/Lead/IN " , 0 , 36000 ) ;
p - > OptionAdd ( general , _ ( " Default lead-out length (ms) " ) , " Audio/Lead/OUT " , 0 , 36000 ) ;
p - > OptionAdd ( general , _ ( " Marker drag-start sensitivity (px) " ) , " Audio/Start Drag Sensitivity " , 1 , 15 ) ;
p - > OptionAdd ( general , _ ( " Line boundary thickness (px) " ) , " Audio/Line Boundaries Thickness " , 1 , 5 ) ;
p - > OptionAdd ( general , _ ( " Maximum snap distance (px) " ) , " Audio/Snap/Distance " , 0 , 25 ) ;
2010-07-19 19:53:29 +02:00
2012-01-10 21:03:31 +01:00
const wxString dtl_arr [ ] = { _ ( " Don't show " ) , _ ( " Show previous " ) , _ ( " Show previous and next " ) , _ ( " Show all " ) } ;
wxArrayString choice_dtl ( 4 , dtl_arr ) ;
2014-05-31 05:32:07 +02:00
p - > OptionChoice ( general , _ ( " Show inactive lines " ) , choice_dtl , " Audio/Inactive Lines Display Mode " ) ;
p - > CellSkip ( general ) ;
p - > OptionAdd ( general , _ ( " Include commented inactive lines " ) , " Audio/Display/Draw/Inactive Comments " ) ;
auto display = p - > PageSizer ( _ ( " Display Visual Options " ) ) ;
p - > OptionAdd ( display , _ ( " Keyframes in dialogue mode " ) , " Audio/Display/Draw/Keyframes in Dialogue Mode " ) ;
p - > OptionAdd ( display , _ ( " Keyframes in karaoke mode " ) , " Audio/Display/Draw/Keyframes in Karaoke Mode " ) ;
p - > OptionAdd ( display , _ ( " Cursor time " ) , " Audio/Display/Draw/Cursor Time " ) ;
p - > OptionAdd ( display , _ ( " Video position " ) , " Audio/Display/Draw/Video Position " ) ;
p - > OptionAdd ( display , _ ( " Seconds boundaries " ) , " Audio/Display/Draw/Seconds " ) ;
p - > CellSkip ( display ) ;
p - > OptionChoice ( display , _ ( " Waveform Style " ) , AudioWaveformRenderer : : GetWaveformStyles ( ) , " Audio/Display/Waveform Style " ) ;
auto label = p - > PageSizer ( _ ( " Audio labels " ) ) ;
p - > OptionFont ( label , " Audio/Karaoke/ " ) ;
p - > SetSizerAndFit ( p - > sizer ) ;
2010-07-19 19:53:29 +02:00
}
2010-05-21 03:13:36 +02:00
2010-07-19 14:25:53 +02:00
/// Video preferences page
2014-05-31 05:32:07 +02:00
void Video ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Video " ) ) ;
auto general = p - > PageSizer ( _ ( " Options " ) ) ;
p - > OptionAdd ( general , _ ( " Show keyframes in slider " ) , " Video/Slider/Show Keyframes " ) ;
p - > CellSkip ( general ) ;
p - > OptionAdd ( general , _ ( " Only show visual tools when mouse is over video " ) , " Tool/Visual/Autohide " ) ;
p - > CellSkip ( general ) ;
p - > OptionAdd ( general , _ ( " Seek video to line start on selection change " ) , " Video/Subtitle Sync " ) ;
p - > CellSkip ( general ) ;
p - > OptionAdd ( general , _ ( " Automatically open audio when opening video " ) , " Video/Open Audio " ) ;
p - > CellSkip ( general ) ;
2010-05-21 03:13:36 +02:00
2011-09-28 21:43:11 +02:00
const wxString czoom_arr [ 24 ] = { " 12.5% " , " 25% " , " 37.5% " , " 50% " , " 62.5% " , " 75% " , " 87.5% " , " 100% " , " 112.5% " , " 125% " , " 137.5% " , " 150% " , " 162.5% " , " 175% " , " 187.5% " , " 200% " , " 212.5% " , " 225% " , " 237.5% " , " 250% " , " 262.5% " , " 275% " , " 287.5% " , " 300% " } ;
2010-07-19 19:53:29 +02:00
wxArrayString choice_zoom ( 24 , czoom_arr ) ;
2014-05-31 05:32:07 +02:00
p - > OptionChoice ( general , _ ( " Default Zoom " ) , choice_zoom , " Video/Default Zoom " ) ;
2010-05-21 03:13:36 +02:00
2014-05-31 05:32:07 +02:00
p - > OptionAdd ( general , _ ( " Fast jump step in frames " ) , " Video/Slider/Fast Jump Step " ) ;
2010-05-21 03:13:36 +02:00
2012-02-07 02:22:42 +01:00
const wxString cscr_arr [ 3 ] = { " ?video " , " ?script " , " . " } ;
2010-07-19 19:53:29 +02:00
wxArrayString scr_res ( 3 , cscr_arr ) ;
2014-05-31 05:32:07 +02:00
p - > OptionChoice ( general , _ ( " Screenshot save path " ) , scr_res , " Path/Screenshot " ) ;
2010-05-21 03:13:36 +02:00
2014-05-31 05:32:07 +02:00
auto resolution = p - > PageSizer ( _ ( " Script Resolution " ) ) ;
wxControl * autocb = p - > OptionAdd ( resolution , _ ( " Use resolution of first video opened " ) , " Subtitle/Default Resolution/Auto " ) ;
p - > CellSkip ( resolution ) ;
p - > DisableIfChecked ( autocb ,
p - > OptionAdd ( resolution , _ ( " Default width " ) , " Subtitle/Default Resolution/Width " ) ) ;
p - > DisableIfChecked ( autocb ,
p - > OptionAdd ( resolution , _ ( " Default height " ) , " Subtitle/Default Resolution/Height " ) ) ;
2012-01-08 02:04:37 +01:00
2014-05-17 16:53:01 +02:00
const wxString cres_arr [ ] = { _ ( " Never " ) , _ ( " Ask " ) , _ ( " Always set " ) , _ ( " Always resample " ) } ;
wxArrayString choice_res ( 4 , cres_arr ) ;
2014-05-31 05:32:07 +02:00
p - > OptionChoice ( resolution , _ ( " Match video resolution on open " ) , choice_res , " Video/Script Resolution Mismatch " ) ;
2012-01-08 02:04:37 +01:00
2014-05-31 05:32:07 +02:00
p - > SetSizerAndFit ( p - > sizer ) ;
2010-07-19 19:53:29 +02:00
}
2010-05-21 03:13:36 +02:00
2010-07-19 14:25:53 +02:00
/// Interface preferences page
2014-05-31 05:32:07 +02:00
void Interface ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Interface " ) ) ;
auto edit_box = p - > PageSizer ( _ ( " Edit Box " ) ) ;
p - > OptionAdd ( edit_box , _ ( " Enable call tips " ) , " App/Call Tips " ) ;
p - > OptionAdd ( edit_box , _ ( " Overwrite in time boxes " ) , " Subtitle/Time Edit/Insert Mode " ) ;
p - > CellSkip ( edit_box ) ;
p - > OptionAdd ( edit_box , _ ( " Enable syntax highlighting " ) , " Subtitle/Highlight/Syntax " ) ;
p - > OptionBrowse ( edit_box , _ ( " Dictionaries path " ) , " Path/Dictionary " ) ;
p - > OptionFont ( edit_box , " Subtitle/Edit Box/ " ) ;
auto character_count = p - > PageSizer ( _ ( " Character Counter " ) ) ;
p - > OptionAdd ( character_count , _ ( " Maximum characters per line " ) , " Subtitle/Character Limit " , 0 , 1000 ) ;
p - > OptionAdd ( character_count , _ ( " Characters Per Second Warning Threshold " ) , " Subtitle/Character Counter/CPS Warning Threshold " , 0 , 1000 ) ;
p - > OptionAdd ( character_count , _ ( " Characters Per Second Error Threshold " ) , " Subtitle/Character Counter/CPS Error Threshold " , 0 , 1000 ) ;
p - > OptionAdd ( character_count , _ ( " Ignore whitespace " ) , " Subtitle/Character Counter/Ignore Whitespace " ) ;
p - > OptionAdd ( character_count , _ ( " Ignore punctuation " ) , " Subtitle/Character Counter/Ignore Punctuation " ) ;
auto grid = p - > PageSizer ( _ ( " Grid " ) ) ;
p - > OptionAdd ( grid , _ ( " Focus grid on click " ) , " Subtitle/Grid/Focus Allow " ) ;
p - > OptionAdd ( grid , _ ( " Highlight visible subtitles " ) , " Subtitle/Grid/Highlight Subtitles in Frame " ) ;
p - > OptionAdd ( grid , _ ( " Hide overrides symbol " ) , " Subtitle/Grid/Hide Overrides Char " ) ;
p - > OptionFont ( grid , " Subtitle/Grid/ " ) ;
2018-03-27 21:07:37 +02:00
auto tl_assistant = p - > PageSizer ( _ ( " Translation Assistant " ) ) ;
p - > OptionAdd ( tl_assistant , _ ( " Skip over whitespace " ) , " Tool/Translation Assistant/Skip Whitespace " ) ;
2014-05-31 05:32:07 +02:00
p - > SetSizerAndFit ( p - > sizer ) ;
2010-07-19 19:53:29 +02:00
}
2010-05-21 03:13:36 +02:00
2010-07-19 14:25:53 +02:00
/// Interface Colours preferences subpage
2014-05-31 05:32:07 +02:00
void Interface_Colours ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Colors " ) , OptionPage : : PAGE_SCROLL | OptionPage : : PAGE_SUB ) ;
delete p - > sizer ;
2012-03-31 19:38:33 +02:00
wxSizer * main_sizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2014-05-31 05:32:07 +02:00
p - > sizer = new wxBoxSizer ( wxVERTICAL ) ;
main_sizer - > Add ( p - > sizer , wxEXPAND ) ;
auto audio = p - > PageSizer ( _ ( " Audio Display " ) ) ;
p - > OptionAdd ( audio , _ ( " Play cursor " ) , " Colour/Audio Display/Play Cursor " ) ;
p - > OptionAdd ( audio , _ ( " Line boundary start " ) , " Colour/Audio Display/Line boundary Start " ) ;
p - > OptionAdd ( audio , _ ( " Line boundary end " ) , " Colour/Audio Display/Line boundary End " ) ;
p - > OptionAdd ( audio , _ ( " Line boundary inactive line " ) , " Colour/Audio Display/Line Boundary Inactive Line " ) ;
p - > OptionAdd ( audio , _ ( " Syllable boundaries " ) , " Colour/Audio Display/Syllable Boundaries " ) ;
p - > OptionAdd ( audio , _ ( " Seconds boundaries " ) , " Colour/Audio Display/Seconds Line " ) ;
auto syntax = p - > PageSizer ( _ ( " Syntax Highlighting " ) ) ;
2014-06-27 20:03:07 +02:00
p - > OptionAdd ( syntax , _ ( " Background " ) , " Colour/Subtitle/Background " ) ;
2014-05-31 05:32:07 +02:00
p - > OptionAdd ( syntax , _ ( " Normal " ) , " Colour/Subtitle/Syntax/Normal " ) ;
2014-07-01 19:48:55 +02:00
p - > OptionAdd ( syntax , _ ( " Comments " ) , " Colour/Subtitle/Syntax/Comment " ) ;
p - > OptionAdd ( syntax , _ ( " Drawings " ) , " Colour/Subtitle/Syntax/Drawing " ) ;
2014-05-31 05:32:07 +02:00
p - > OptionAdd ( syntax , _ ( " Brackets " ) , " Colour/Subtitle/Syntax/Brackets " ) ;
p - > OptionAdd ( syntax , _ ( " Slashes and Parentheses " ) , " Colour/Subtitle/Syntax/Slashes " ) ;
p - > OptionAdd ( syntax , _ ( " Tags " ) , " Colour/Subtitle/Syntax/Tags " ) ;
p - > OptionAdd ( syntax , _ ( " Parameters " ) , " Colour/Subtitle/Syntax/Parameters " ) ;
p - > OptionAdd ( syntax , _ ( " Error " ) , " Colour/Subtitle/Syntax/Error " ) ;
p - > OptionAdd ( syntax , _ ( " Error Background " ) , " Colour/Subtitle/Syntax/Background/Error " ) ;
p - > OptionAdd ( syntax , _ ( " Line Break " ) , " Colour/Subtitle/Syntax/Line Break " ) ;
p - > OptionAdd ( syntax , _ ( " Karaoke templates " ) , " Colour/Subtitle/Syntax/Karaoke Template " ) ;
2014-07-01 19:48:55 +02:00
p - > OptionAdd ( syntax , _ ( " Karaoke variables " ) , " Colour/Subtitle/Syntax/Karaoke Variable " ) ;
2014-05-31 05:32:07 +02:00
p - > sizer = new wxBoxSizer ( wxVERTICAL ) ;
2012-05-15 16:06:24 +02:00
main_sizer - > AddSpacer ( 5 ) ;
2014-05-31 05:32:07 +02:00
main_sizer - > Add ( p - > sizer , wxEXPAND ) ;
2012-05-15 16:06:24 +02:00
2014-05-31 05:32:07 +02:00
auto color_schemes = p - > PageSizer ( _ ( " Audio Color Schemes " ) ) ;
2012-12-23 00:18:38 +01:00
wxArrayString schemes = to_wx ( OPT_GET ( " Audio/Colour Schemes " ) - > GetListString ( ) ) ;
2014-05-31 05:32:07 +02:00
p - > OptionChoice ( color_schemes , _ ( " Spectrum " ) , schemes , " Colour/Audio Display/Spectrum " ) ;
p - > OptionChoice ( color_schemes , _ ( " Waveform " ) , schemes , " Colour/Audio Display/Waveform " ) ;
auto grid = p - > PageSizer ( _ ( " Subtitle Grid " ) ) ;
p - > OptionAdd ( grid , _ ( " Standard foreground " ) , " Colour/Subtitle Grid/Standard " ) ;
p - > OptionAdd ( grid , _ ( " Standard background " ) , " Colour/Subtitle Grid/Background/Background " ) ;
p - > OptionAdd ( grid , _ ( " Selection foreground " ) , " Colour/Subtitle Grid/Selection " ) ;
p - > OptionAdd ( grid , _ ( " Selection background " ) , " Colour/Subtitle Grid/Background/Selection " ) ;
p - > OptionAdd ( grid , _ ( " Collision foreground " ) , " Colour/Subtitle Grid/Collision " ) ;
p - > OptionAdd ( grid , _ ( " In frame background " ) , " Colour/Subtitle Grid/Background/Inframe " ) ;
p - > OptionAdd ( grid , _ ( " Comment background " ) , " Colour/Subtitle Grid/Background/Comment " ) ;
p - > OptionAdd ( grid , _ ( " Selected comment background " ) , " Colour/Subtitle Grid/Background/Selected Comment " ) ;
p - > OptionAdd ( grid , _ ( " Header background " ) , " Colour/Subtitle Grid/Header " ) ;
p - > OptionAdd ( grid , _ ( " Left Column " ) , " Colour/Subtitle Grid/Left Column " ) ;
p - > OptionAdd ( grid , _ ( " Active Line Border " ) , " Colour/Subtitle Grid/Active Border " ) ;
p - > OptionAdd ( grid , _ ( " Lines " ) , " Colour/Subtitle Grid/Lines " ) ;
p - > OptionAdd ( grid , _ ( " CPS Error " ) , " Colour/Subtitle Grid/CPS Error " ) ;
2018-04-15 23:59:32 +02:00
auto visual_tools = p - > PageSizer ( _ ( " Visual Typesetting Tools " ) ) ;
p - > OptionAdd ( visual_tools , _ ( " Primary Lines " ) , " Colour/Visual Tools/Lines Primary " ) ;
p - > OptionAdd ( visual_tools , _ ( " Secondary Lines " ) , " Colour/Visual Tools/Lines Secondary " ) ;
p - > OptionAdd ( visual_tools , _ ( " Primary Highlight " ) , " Colour/Visual Tools/Highlight Primary " ) ;
p - > OptionAdd ( visual_tools , _ ( " Secondary Highlight " ) , " Colour/Visual Tools/Highlight Secondary " ) ;
// Separate sizer to prevent the colors in the visual tools section from getting resized
auto visual_tools_alpha = p - > PageSizer ( _ ( " Visual Typesetting Tools Alpha " ) ) ;
p - > OptionAdd ( visual_tools_alpha , _ ( " Shaded Area " ) , " Colour/Visual Tools/Shaded Area Alpha " , 0 , 1 , 0.1 ) ;
2014-05-31 05:32:07 +02:00
p - > sizer = main_sizer ;
p - > SetSizerAndFit ( p - > sizer ) ;
}
2010-08-26 20:38:14 +02:00
2014-05-31 05:32:07 +02:00
/// Backup preferences page
void Backup ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Backup " ) ) ;
auto save = p - > PageSizer ( _ ( " Automatic Save " ) ) ;
wxControl * cb = p - > OptionAdd ( save , _ ( " Enable " ) , " App/Auto/Save " ) ;
p - > CellSkip ( save ) ;
p - > EnableIfChecked ( cb ,
p - > OptionAdd ( save , _ ( " Interval in seconds " ) , " App/Auto/Save Every Seconds " , 1 ) ) ;
p - > OptionBrowse ( save , _ ( " Path " ) , " Path/Auto/Save " , cb , true ) ;
p - > OptionAdd ( save , _ ( " Autosave after every change " ) , " App/Auto/Save on Every Change " ) ;
auto backup = p - > PageSizer ( _ ( " Automatic Backup " ) ) ;
cb = p - > OptionAdd ( backup , _ ( " Enable " ) , " App/Auto/Backup " ) ;
p - > CellSkip ( backup ) ;
p - > OptionBrowse ( backup , _ ( " Path " ) , " Path/Auto/Backup " , cb , true ) ;
p - > SetSizerAndFit ( p - > sizer ) ;
}
/// Automation preferences page
void Automation ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Automation " ) ) ;
auto general = p - > PageSizer ( _ ( " General " ) ) ;
p - > OptionAdd ( general , _ ( " Base path " ) , " Path/Automation/Base " ) ;
p - > OptionAdd ( general , _ ( " Include path " ) , " Path/Automation/Include " ) ;
p - > OptionAdd ( general , _ ( " Auto-load path " ) , " Path/Automation/Autoload " ) ;
const wxString tl_arr [ 6 ] = { _ ( " 0: Fatal " ) , _ ( " 1: Error " ) , _ ( " 2: Warning " ) , _ ( " 3: Hint " ) , _ ( " 4: Debug " ) , _ ( " 5: Trace " ) } ;
wxArrayString tl_choice ( 6 , tl_arr ) ;
p - > OptionChoice ( general , _ ( " Trace level " ) , tl_choice , " Automation/Trace Level " ) ;
const wxString ar_arr [ 4 ] = { _ ( " No scripts " ) , _ ( " Subtitle-local scripts " ) , _ ( " Global autoload scripts " ) , _ ( " All scripts " ) } ;
wxArrayString ar_choice ( 4 , ar_arr ) ;
p - > OptionChoice ( general , _ ( " Autoreload on Export " ) , ar_choice , " Automation/Autoreload Mode " ) ;
p - > SetSizerAndFit ( p - > sizer ) ;
}
/// Advanced preferences page
void Advanced ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Advanced " ) ) ;
auto general = p - > PageSizer ( _ ( " General " ) ) ;
auto warning = new wxStaticText ( p , wxID_ANY , _ ( " Changing these settings might result in bugs and/or crashes. Do not touch these unless you know what you're doing. " ) ) ;
warning - > SetFont ( wxFont ( 12 , wxFONTFAMILY_SWISS , wxFONTSTYLE_NORMAL , wxFONTWEIGHT_BOLD ) ) ;
p - > sizer - > Fit ( p ) ;
warning - > Wrap ( 400 ) ;
general - > Add ( warning , 0 , wxALL , 5 ) ;
p - > SetSizerAndFit ( p - > sizer ) ;
}
/// Advanced Audio preferences subpage
void Advanced_Audio ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Audio " ) , OptionPage : : PAGE_SUB ) ;
auto expert = p - > PageSizer ( _ ( " Expert " ) ) ;
2014-07-09 16:22:49 +02:00
wxArrayString ap_choice = to_wx ( GetAudioProviderNames ( ) ) ;
2014-05-31 05:32:07 +02:00
p - > OptionChoice ( expert , _ ( " Audio provider " ) , ap_choice , " Audio/Provider " ) ;
wxArrayString apl_choice = to_wx ( AudioPlayerFactory : : GetClasses ( ) ) ;
p - > OptionChoice ( expert , _ ( " Audio player " ) , apl_choice , " Audio/Player " ) ;
auto cache = p - > PageSizer ( _ ( " Cache " ) ) ;
const wxString ct_arr [ 3 ] = { _ ( " None (NOT RECOMMENDED) " ) , _ ( " RAM " ) , _ ( " Hard Disk " ) } ;
wxArrayString ct_choice ( 3 , ct_arr ) ;
p - > OptionChoice ( cache , _ ( " Cache type " ) , ct_choice , " Audio/Cache/Type " ) ;
p - > OptionBrowse ( cache , _ ( " Path " ) , " Audio/Cache/HD/Location " ) ;
auto spectrum = p - > PageSizer ( _ ( " Spectrum " ) ) ;
const wxString sq_arr [ 4 ] = { _ ( " Regular quality " ) , _ ( " Better quality " ) , _ ( " High quality " ) , _ ( " Insane quality " ) } ;
wxArrayString sq_choice ( 4 , sq_arr ) ;
p - > OptionChoice ( spectrum , _ ( " Quality " ) , sq_choice , " Audio/Renderer/Spectrum/Quality " ) ;
p - > OptionAdd ( spectrum , _ ( " Cache memory max (MB) " ) , " Audio/Renderer/Spectrum/Memory Max " , 2 , 1024 ) ;
# ifdef WITH_AVISYNTH
auto avisynth = p - > PageSizer ( " Avisynth " ) ;
const wxString adm_arr [ 3 ] = { " ConvertToMono " , " GetLeftChannel " , " GetRightChannel " } ;
wxArrayString adm_choice ( 3 , adm_arr ) ;
p - > OptionChoice ( avisynth , _ ( " Avisynth down-mixer " ) , adm_choice , " Audio/Downmixer " ) ;
p - > OptionAdd ( avisynth , _ ( " Force sample rate " ) , " Provider/Audio/AVS/Sample Rate " ) ;
# endif
# ifdef WITH_FFMS2
auto ffms = p - > PageSizer ( " FFmpegSource " ) ;
const wxString error_modes [ ] = { _ ( " Ignore " ) , _ ( " Clear " ) , _ ( " Stop " ) , _ ( " Abort " ) } ;
wxArrayString error_modes_choice ( 4 , error_modes ) ;
p - > OptionChoice ( ffms , _ ( " Audio indexing error handling mode " ) , error_modes_choice , " Provider/Audio/FFmpegSource/Decode Error Handling " ) ;
p - > OptionAdd ( ffms , _ ( " Always index all audio tracks " ) , " Provider/FFmpegSource/Index All Tracks " ) ;
# endif
# ifdef WITH_PORTAUDIO
auto portaudio = p - > PageSizer ( " Portaudio " ) ;
p - > OptionChoice ( portaudio , _ ( " Portaudio device " ) , PortAudioPlayer : : GetOutputDevices ( ) , " Player/Audio/PortAudio/Device Name " ) ;
# endif
# ifdef WITH_OSS
auto oss = p - > PageSizer ( " OSS " ) ;
p - > OptionBrowse ( oss , _ ( " OSS Device " ) , " Player/Audio/OSS/Device " ) ;
# endif
# ifdef WITH_DIRECTSOUND
auto dsound = p - > PageSizer ( " DirectSound " ) ;
p - > OptionAdd ( dsound , _ ( " Buffer latency " ) , " Player/Audio/DirectSound/Buffer Latency " , 1 , 1000 ) ;
p - > OptionAdd ( dsound , _ ( " Buffer length " ) , " Player/Audio/DirectSound/Buffer Length " , 1 , 100 ) ;
# endif
p - > SetSizerAndFit ( p - > sizer ) ;
}
/// Advanced Video preferences subpage
void Advanced_Video ( wxTreebook * book , Preferences * parent ) {
auto p = new OptionPage ( book , parent , _ ( " Video " ) , OptionPage : : PAGE_SUB ) ;
auto expert = p - > PageSizer ( _ ( " Expert " ) ) ;
wxArrayString vp_choice = to_wx ( VideoProviderFactory : : GetClasses ( ) ) ;
p - > OptionChoice ( expert , _ ( " Video provider " ) , vp_choice , " Video/Provider " ) ;
wxArrayString sp_choice = to_wx ( SubtitlesProviderFactory : : GetClasses ( ) ) ;
p - > OptionChoice ( expert , _ ( " Subtitles provider " ) , sp_choice , " Subtitle/Provider " ) ;
# ifdef WITH_AVISYNTH
auto avisynth = p - > PageSizer ( " Avisynth " ) ;
p - > OptionAdd ( avisynth , _ ( " Avisynth memory limit " ) , " Provider/Avisynth/Memory Max " ) ;
# endif
# ifdef WITH_FFMS2
auto ffms = p - > PageSizer ( " FFmpegSource " ) ;
const wxString log_levels [ ] = { " Quiet " , " Panic " , " Fatal " , " Error " , " Warning " , " Info " , " Verbose " , " Debug " } ;
wxArrayString log_levels_choice ( 8 , log_levels ) ;
p - > OptionChoice ( ffms , _ ( " Debug log verbosity " ) , log_levels_choice , " Provider/FFmpegSource/Log Level " ) ;
p - > OptionAdd ( ffms , _ ( " Decoding threads " ) , " Provider/Video/FFmpegSource/Decoding Threads " , - 1 ) ;
p - > OptionAdd ( ffms , _ ( " Enable unsafe seeking " ) , " Provider/Video/FFmpegSource/Unsafe Seeking " ) ;
# endif
p - > SetSizerAndFit ( p - > sizer ) ;
2010-07-19 19:53:29 +02:00
}
2010-05-21 03:13:36 +02:00
2011-10-28 22:40:43 +02:00
/// wxDataViewIconTextRenderer with command name autocompletion
2014-03-13 02:39:07 +01:00
class CommandRenderer final : public wxDataViewCustomRenderer {
2011-10-28 22:40:43 +02:00
wxArrayString autocomplete ;
2012-01-17 03:47:25 +01:00
wxDataViewIconText value ;
2012-02-20 06:41:54 +01:00
static const int icon_width = 20 ;
2012-01-17 03:47:25 +01:00
2011-10-28 22:40:43 +02:00
public :
CommandRenderer ( )
2012-01-17 03:47:25 +01:00
: wxDataViewCustomRenderer ( " wxDataViewIconText " , wxDATAVIEW_CELL_EDITABLE )
2012-12-30 01:53:30 +01:00
, autocomplete ( to_wx ( cmd : : get_registered_commands ( ) ) )
2011-10-28 22:40:43 +02:00
{
}
2013-11-21 18:13:36 +01:00
wxWindow * CreateEditorCtrl ( wxWindow * parent , wxRect label_rect , wxVariant const & value ) override {
2012-01-17 03:47:25 +01:00
wxDataViewIconText iconText ;
iconText < < value ;
wxString text = iconText . GetText ( ) ;
// adjust the label rect to take the width of the icon into account
2012-02-20 06:41:54 +01:00
label_rect . x + = icon_width ;
label_rect . width - = icon_width ;
2012-01-17 03:47:25 +01:00
wxTextCtrl * ctrl = new wxTextCtrl ( parent , - 1 , text , label_rect . GetPosition ( ) , label_rect . GetSize ( ) , wxTE_PROCESS_ENTER ) ;
ctrl - > SetInsertionPointEnd ( ) ;
ctrl - > SelectAll ( ) ;
2011-10-28 22:40:43 +02:00
ctrl - > AutoComplete ( autocomplete ) ;
return ctrl ;
}
2012-01-17 03:47:25 +01:00
2013-11-21 18:13:36 +01:00
bool SetValue ( wxVariant const & var ) override {
2012-01-17 03:47:25 +01:00
value < < var ;
return true ;
}
2013-11-21 18:13:36 +01:00
bool Render ( wxRect rect , wxDC * dc , int state ) override {
2012-01-17 03:47:25 +01:00
wxIcon const & icon = value . GetIcon ( ) ;
2012-02-20 06:41:54 +01:00
if ( icon . IsOk ( ) )
2012-01-17 03:47:25 +01:00
dc - > DrawIcon ( icon , rect . x , rect . y + ( rect . height - icon . GetHeight ( ) ) / 2 ) ;
2012-02-20 06:41:54 +01:00
RenderText ( value . GetText ( ) , icon_width , rect , dc , state ) ;
2012-01-17 03:47:25 +01:00
return true ;
}
2013-11-21 18:13:36 +01:00
wxSize GetSize ( ) const override {
2012-01-17 03:47:25 +01:00
if ( ! value . GetText ( ) . empty ( ) ) {
wxSize size = GetTextExtent ( value . GetText ( ) ) ;
2012-02-20 06:41:54 +01:00
size . x + = icon_width ;
2012-01-17 03:47:25 +01:00
return size ;
}
return wxSize ( 80 , 20 ) ;
}
2013-11-21 18:13:36 +01:00
bool GetValueFromEditorCtrl ( wxWindow * editor , wxVariant & var ) override {
2012-01-17 03:47:25 +01:00
wxTextCtrl * text = static_cast < wxTextCtrl * > ( editor ) ;
wxDataViewIconText iconText ( text - > GetValue ( ) , value . GetIcon ( ) ) ;
var < < iconText ;
return true ;
}
2013-11-21 18:13:36 +01:00
bool GetValue ( wxVariant & ) const override { return false ; }
bool HasEditorCtrl ( ) const override { return true ; }
2011-10-28 22:40:43 +02:00
} ;
2014-03-13 02:39:07 +01:00
class HotkeyRenderer final : public wxDataViewCustomRenderer {
2012-01-17 03:47:25 +01:00
wxString value ;
2014-04-25 19:01:07 +02:00
wxTextCtrl * ctrl = nullptr ;
2012-01-17 03:47:25 +01:00
2011-10-28 22:40:43 +02:00
public :
2012-10-15 06:37:14 +02:00
HotkeyRenderer ( )
: wxDataViewCustomRenderer ( " string " , wxDATAVIEW_CELL_EDITABLE )
{ }
2011-10-28 22:40:43 +02:00
2013-11-21 18:13:36 +01:00
wxWindow * CreateEditorCtrl ( wxWindow * parent , wxRect label_rect , wxVariant const & var ) override {
2012-01-17 03:47:25 +01:00
ctrl = new wxTextCtrl ( parent , - 1 , var . GetString ( ) , label_rect . GetPosition ( ) , label_rect . GetSize ( ) , wxTE_PROCESS_ENTER ) ;
ctrl - > SetInsertionPointEnd ( ) ;
ctrl - > SelectAll ( ) ;
2012-04-14 00:27:56 +02:00
ctrl - > Bind ( wxEVT_CHAR_HOOK , & HotkeyRenderer : : OnKeyDown , this ) ;
2011-10-28 22:40:43 +02:00
return ctrl ;
}
void OnKeyDown ( wxKeyEvent & evt ) {
2013-06-09 03:24:50 +02:00
ctrl - > ChangeValue ( to_wx ( hotkey : : keypress_to_str ( evt . GetKeyCode ( ) , evt . GetModifiers ( ) ) ) ) ;
2011-10-28 22:40:43 +02:00
}
2012-01-17 03:47:25 +01:00
2013-11-21 18:13:36 +01:00
bool SetValue ( wxVariant const & var ) override {
2012-01-17 03:47:25 +01:00
value = var . GetString ( ) ;
return true ;
}
2013-11-21 18:13:36 +01:00
bool Render ( wxRect rect , wxDC * dc , int state ) override {
2012-01-17 03:47:25 +01:00
RenderText ( value , 0 , rect , dc , state ) ;
return true ;
}
2013-11-21 18:13:36 +01:00
bool GetValueFromEditorCtrl ( wxWindow * , wxVariant & var ) override {
2012-01-17 03:47:25 +01:00
var = ctrl - > GetValue ( ) ;
return true ;
}
2013-11-21 18:13:36 +01:00
bool GetValue ( wxVariant & ) const override { return false ; }
wxSize GetSize ( ) const override { return ! value ? wxSize ( 80 , 20 ) : GetTextExtent ( value ) ; }
bool HasEditorCtrl ( ) const override { return true ; }
2011-10-28 22:40:43 +02:00
} ;
2010-05-21 03:13:36 +02:00
2012-12-02 22:29:46 +01:00
static void edit_item ( wxDataViewCtrl * dvc , wxDataViewItem item ) {
dvc - > EditItem ( item , dvc - > GetColumn ( 0 ) ) ;
}
2014-05-31 05:32:07 +02:00
class Interface_Hotkeys final : public OptionPage {
wxDataViewCtrl * dvc ;
wxObjectDataPtr < HotkeyDataViewModel > model ;
wxSearchCtrl * quick_search ;
void OnNewButton ( wxCommandEvent & ) ;
void OnUpdateFilter ( wxCommandEvent & ) ;
public :
Interface_Hotkeys ( wxTreebook * book , Preferences * parent ) ;
} ;
2010-07-19 14:25:53 +02:00
/// Interface Hotkeys preferences subpage
2011-10-28 22:40:43 +02:00
Interface_Hotkeys : : Interface_Hotkeys ( wxTreebook * book , Preferences * parent )
2014-05-31 05:32:07 +02:00
: OptionPage ( book , parent , _ ( " Hotkeys " ) , OptionPage : : PAGE_SUB )
2011-10-28 22:40:43 +02:00
, model ( new HotkeyDataViewModel ( parent ) )
{
quick_search = new wxSearchCtrl ( this , - 1 ) ;
2014-05-31 05:32:07 +02:00
auto new_button = new wxButton ( this , - 1 , _ ( " &New " ) ) ;
auto edit_button = new wxButton ( this , - 1 , _ ( " &Edit " ) ) ;
auto delete_button = new wxButton ( this , - 1 , _ ( " &Delete " ) ) ;
2011-10-28 22:40:43 +02:00
2013-12-12 03:25:13 +01:00
new_button - > Bind ( wxEVT_BUTTON , & Interface_Hotkeys : : OnNewButton , this ) ;
edit_button - > Bind ( wxEVT_BUTTON , [ = ] ( wxCommandEvent & ) { edit_item ( dvc , dvc - > GetSelection ( ) ) ; } ) ;
delete_button - > Bind ( wxEVT_BUTTON , [ = ] ( wxCommandEvent & ) { model - > Delete ( dvc - > GetSelection ( ) ) ; } ) ;
2011-10-28 22:40:43 +02:00
2013-12-12 03:25:13 +01:00
quick_search - > Bind ( wxEVT_TEXT , & Interface_Hotkeys : : OnUpdateFilter , this ) ;
quick_search - > Bind ( wxEVT_SEARCHCTRL_CANCEL_BTN , [ = ] ( wxCommandEvent & ) { quick_search - > SetValue ( " " ) ; } ) ;
2011-10-28 22:40:43 +02:00
dvc = new wxDataViewCtrl ( this , - 1 ) ;
dvc - > AssociateModel ( model . get ( ) ) ;
2013-05-06 05:55:10 +02:00
# ifndef __APPLE__
2011-10-28 22:40:43 +02:00
dvc - > AppendColumn ( new wxDataViewColumn ( " Hotkey " , new HotkeyRenderer , 0 , 125 , wxALIGN_LEFT , wxCOL_SORTABLE | wxCOL_RESIZABLE ) ) ;
dvc - > AppendColumn ( new wxDataViewColumn ( " Command " , new CommandRenderer , 1 , 250 , wxALIGN_LEFT , wxCOL_SORTABLE | wxCOL_RESIZABLE ) ) ;
2013-05-06 05:55:10 +02:00
# else
2014-06-05 04:56:13 +02:00
auto col = new wxDataViewColumn ( " Hotkey " , new wxDataViewTextRenderer ( " string " , wxDATAVIEW_CELL_EDITABLE ) , 0 , 150 , wxALIGN_LEFT , wxCOL_SORTABLE | wxCOL_RESIZABLE ) ;
col - > SetMinWidth ( 150 ) ;
dvc - > AppendColumn ( col ) ;
2013-05-06 05:55:10 +02:00
dvc - > AppendColumn ( new wxDataViewColumn ( " Command " , new wxDataViewIconTextRenderer ( " wxDataViewIconText " , wxDATAVIEW_CELL_EDITABLE ) , 1 , 250 , wxALIGN_LEFT , wxCOL_SORTABLE | wxCOL_RESIZABLE ) ) ;
# endif
2011-10-28 22:40:43 +02:00
dvc - > AppendTextColumn ( " Description " , 2 , wxDATAVIEW_CELL_INERT , 300 , wxALIGN_LEFT , wxCOL_SORTABLE | wxCOL_RESIZABLE ) ;
wxSizer * buttons = new wxBoxSizer ( wxHORIZONTAL ) ;
2021-02-01 00:28:12 +01:00
buttons - > Add ( quick_search , wxSizerFlags ( 1 ) . Expand ( ) . Border ( ) ) ;
2015-07-29 02:05:50 +02:00
buttons - > Add ( new_button , wxSizerFlags ( ) . Border ( ) ) ;
buttons - > Add ( edit_button , wxSizerFlags ( ) . Border ( ) ) ;
buttons - > Add ( delete_button , wxSizerFlags ( ) . Border ( ) ) ;
2011-10-28 22:40:43 +02:00
sizer - > Add ( buttons , wxSizerFlags ( ) . Expand ( ) ) ;
sizer - > Add ( dvc , wxSizerFlags ( 1 ) . Expand ( ) . Border ( wxLEFT | wxRIGHT ) ) ;
2010-07-19 19:53:29 +02:00
SetSizerAndFit ( sizer ) ;
}
2010-05-21 03:13:36 +02:00
2011-10-28 22:40:43 +02:00
void Interface_Hotkeys : : OnNewButton ( wxCommandEvent & ) {
2012-02-01 19:47:00 +01:00
wxDataViewItem sel = dvc - > GetSelection ( ) ;
dvc - > ExpandAncestors ( sel ) ;
dvc - > Expand ( sel ) ;
wxDataViewItem new_item = model - > New ( sel ) ;
if ( new_item . IsOk ( ) ) {
dvc - > Select ( new_item ) ;
dvc - > EnsureVisible ( new_item ) ;
edit_item ( dvc , new_item ) ;
}
2011-10-28 22:40:43 +02:00
}
2010-05-21 03:13:36 +02:00
2011-10-28 22:40:43 +02:00
void Interface_Hotkeys : : OnUpdateFilter ( wxCommandEvent & ) {
model - > SetFilter ( quick_search - > GetValue ( ) ) ;
2010-05-21 03:13:36 +02:00
2011-10-28 22:40:43 +02:00
if ( ! quick_search - > GetValue ( ) . empty ( ) ) {
wxDataViewItemArray contexts ;
2013-11-21 18:13:36 +01:00
model - > GetChildren ( wxDataViewItem ( nullptr ) , contexts ) ;
2012-11-04 04:53:03 +01:00
for ( auto const & context : contexts )
dvc - > Expand ( context ) ;
2011-10-28 22:40:43 +02:00
}
}
2014-07-09 00:16:49 +02:00
}
2011-10-28 22:40:43 +02:00
2013-09-16 15:43:17 +02:00
void Preferences : : SetOption ( std : : unique_ptr < agi : : OptionValue > new_value ) {
2013-06-08 06:19:40 +02:00
pending_changes [ new_value - > GetName ( ) ] = std : : move ( new_value ) ;
2014-06-27 20:10:28 +02:00
applyButton - > Enable ( true ) ;
2011-10-28 22:40:43 +02:00
}
void Preferences : : AddPendingChange ( Thunk const & callback ) {
pending_callbacks . push_back ( callback ) ;
2014-06-27 20:10:28 +02:00
applyButton - > Enable ( true ) ;
2011-10-28 22:40:43 +02:00
}
2012-04-11 05:43:08 +02:00
void Preferences : : AddChangeableOption ( std : : string const & name ) {
option_names . push_back ( name ) ;
}
2011-10-28 22:40:43 +02:00
void Preferences : : OnOK ( wxCommandEvent & event ) {
OnApply ( event ) ;
EndModal ( 0 ) ;
}
2011-12-22 22:09:31 +01:00
void Preferences : : OnApply ( wxCommandEvent & ) {
2013-06-08 06:19:40 +02:00
for ( auto const & change : pending_changes )
OPT_SET ( change . first ) - > Set ( change . second . get ( ) ) ;
2011-10-28 22:40:43 +02:00
pending_changes . clear ( ) ;
2012-11-04 04:53:03 +01:00
for ( auto const & thunk : pending_callbacks )
thunk ( ) ;
2011-10-28 22:40:43 +02:00
pending_callbacks . clear ( ) ;
applyButton - > Enable ( false ) ;
config : : opt - > Flush ( ) ;
}
2012-04-11 05:43:08 +02:00
void Preferences : : OnResetDefault ( wxCommandEvent & ) {
if ( wxYES ! = wxMessageBox ( _ ( " Are you sure that you want to restore the defaults? All your settings will be overridden. " ) , _ ( " Restore defaults? " ) , wxYES_NO ) )
return ;
2012-11-04 04:53:03 +01:00
for ( auto const & opt_name : option_names ) {
agi : : OptionValue * opt = OPT_SET ( opt_name ) ;
2012-04-11 05:43:08 +02:00
if ( ! opt - > IsDefault ( ) )
opt - > Reset ( ) ;
}
config : : opt - > Flush ( ) ;
agi : : hotkey : : Hotkey def_hotkeys ( " " , GET_DEFAULT_CONFIG ( default_hotkey ) ) ;
hotkey : : inst - > SetHotkeyMap ( def_hotkeys . GetHotkeyMap ( ) ) ;
// Close and reopen the dialog to update all the controls with the new values
OPT_SET ( " Tool/Preferences/Page " ) - > SetInt ( book - > GetSelection ( ) ) ;
EndModal ( - 1 ) ;
}
2012-05-13 02:58:16 +02:00
Preferences : : Preferences ( wxWindow * parent ) : wxDialog ( parent , - 1 , _ ( " Preferences " ) , wxDefaultPosition , wxSize ( - 1 , - 1 ) , wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ) {
2012-04-03 22:40:33 +02:00
SetIcon ( GETICON ( options_button_16 ) ) ;
2011-10-28 22:40:43 +02:00
book = new wxTreebook ( this , - 1 , wxDefaultPosition , wxDefaultSize ) ;
2014-05-31 05:32:07 +02:00
General ( book , this ) ;
General_DefaultStyles ( book , this ) ;
Audio ( book , this ) ;
Video ( book , this ) ;
Interface ( book , this ) ;
Interface_Colours ( book , this ) ;
2011-10-28 22:40:43 +02:00
new Interface_Hotkeys ( book , this ) ;
2014-05-31 05:32:07 +02:00
Backup ( book , this ) ;
Automation ( book , this ) ;
Advanced ( book , this ) ;
Advanced_Audio ( book , this ) ;
Advanced_Video ( book , this ) ;
2011-10-28 22:40:43 +02:00
book - > Fit ( ) ;
book - > ChangeSelection ( OPT_GET ( " Tool/Preferences/Page " ) - > GetInt ( ) ) ;
2014-05-31 05:32:07 +02:00
book - > Bind ( wxEVT_TREEBOOK_PAGE_CHANGED , [ ] ( wxBookCtrlEvent & evt ) {
OPT_SET ( " Tool/Preferences/Page " ) - > SetInt ( evt . GetSelection ( ) ) ;
} ) ;
2011-10-28 22:40:43 +02:00
// Bottom Buttons
2014-05-31 05:32:07 +02:00
auto stdButtonSizer = CreateStdDialogButtonSizer ( wxOK | wxCANCEL | wxAPPLY | wxHELP ) ;
2011-10-28 22:40:43 +02:00
applyButton = stdButtonSizer - > GetApplyButton ( ) ;
2012-04-11 05:43:08 +02:00
wxSizer * buttonSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2014-05-31 05:32:07 +02:00
auto defaultButton = new wxButton ( this , - 1 , _ ( " &Restore Defaults " ) ) ;
2012-04-11 05:43:08 +02:00
buttonSizer - > Add ( defaultButton , wxSizerFlags ( 0 ) . Expand ( ) ) ;
buttonSizer - > AddStretchSpacer ( 1 ) ;
buttonSizer - > Add ( stdButtonSizer , wxSizerFlags ( 0 ) . Expand ( ) ) ;
2011-10-28 22:40:43 +02:00
// Main Sizer
wxSizer * mainSizer = new wxBoxSizer ( wxVERTICAL ) ;
mainSizer - > Add ( book , wxSizerFlags ( 1 ) . Expand ( ) . Border ( ) ) ;
2012-04-11 05:43:08 +02:00
mainSizer - > Add ( buttonSizer , wxSizerFlags ( 0 ) . Expand ( ) . Border ( wxALL & ~ wxTOP ) ) ;
2011-10-28 22:40:43 +02:00
SetSizerAndFit ( mainSizer ) ;
CenterOnParent ( ) ;
applyButton - > Enable ( false ) ;
2013-12-12 03:25:13 +01:00
Bind ( wxEVT_BUTTON , & Preferences : : OnOK , this , wxID_OK ) ;
Bind ( wxEVT_BUTTON , & Preferences : : OnApply , this , wxID_APPLY ) ;
Bind ( wxEVT_BUTTON , std : : bind ( & HelpButton : : OpenPage , " Options " ) , wxID_HELP ) ;
defaultButton - > Bind ( wxEVT_BUTTON , & Preferences : : OnResetDefault , this ) ;
2011-10-28 22:40:43 +02:00
}
2014-12-29 05:28:33 +01:00
void ShowPreferences ( wxWindow * parent ) {
while ( Preferences ( parent ) . ShowModal ( ) < 0 ) ;
}