Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
// Copyright (c) 2005-2010, Niels Martin Hansen
// Copyright (c) 2005-2010, Rodrigo Braz Monteiro
// Copyright (c) 2010, Amar Takhar
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// Aegisub Project http://www.aegisub.org/
//
// $Id$
/// @file app.cpp
/// @brief app/ commands.
/// @ingroup command
///
2011-01-05 19:40:37 +01:00
# include "../config.h"
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
# ifndef AGI_PRE
2011-01-08 13:10:40 +01:00
# include <wx/msgdlg.h>
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
# endif
# include "command.h"
2011-01-05 19:40:37 +01:00
# include "../include/aegisub/context.h"
# include "../main.h"
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
2011-01-05 19:40:37 +01:00
# include "../audio_controller.h"
2011-07-15 06:05:01 +02:00
# include "../dialog_about.h"
2011-01-05 19:40:37 +01:00
# include "../dialog_log.h"
# include "../dialog_version_check.h"
2011-07-15 06:05:01 +02:00
# include "../frame_main.h"
# include "../preferences.h"
# include "../utils.h"
# include "../video_context.h"
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
2011-07-15 06:05:01 +02:00
namespace {
using cmd : : Command ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
/// @defgroup cmd-app Application related
/// @{
/// Launch about dialogue.
2011-01-16 08:15:32 +01:00
struct app_about : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/about " )
2011-10-01 20:35:12 +02:00
STR_MENU ( " &About... " )
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
STR_DISP ( " About " )
STR_HELP ( " About Aegisub. " )
void operator ( ) ( agi : : Context * c ) {
2011-01-16 08:15:24 +01:00
AboutScreen ( c - > parent ) . ShowModal ( ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
}
} ;
/// Display audio and subtitles.
2011-01-16 08:15:32 +01:00
struct app_display_audio_subs : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/display/audio_subs " )
STR_MENU ( " Audio+Subs View " )
STR_DISP ( " Audio+Subs View " )
STR_HELP ( " Display audio and subtitles only. " )
2011-07-15 06:05:56 +02:00
CMD_TYPE ( COMMAND_VALIDATE | COMMAND_RADIO )
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
void operator ( ) ( agi : : Context * c ) {
wxGetApp ( ) . frame - > SetDisplayMode ( 0 , 1 ) ;
}
2011-07-15 06:05:22 +02:00
bool Validate ( const agi : : Context * c ) {
return c - > audioController - > IsAudioOpen ( ) ;
}
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
} ;
/// Display audio, video and subtitles.
2011-01-16 08:15:32 +01:00
struct app_display_full : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/display/full " )
STR_MENU ( " Full view " )
STR_DISP ( " Full view " )
STR_HELP ( " Display audio, video and subtitles. " )
2011-07-15 06:05:56 +02:00
CMD_TYPE ( COMMAND_VALIDATE | COMMAND_RADIO )
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
void operator ( ) ( agi : : Context * c ) {
wxGetApp ( ) . frame - > SetDisplayMode ( 1 , 1 ) ;
}
2011-07-15 06:05:22 +02:00
bool Validate ( const agi : : Context * c ) {
return c - > audioController - > IsAudioOpen ( ) & & c - > videoController - > IsLoaded ( ) & & ! c - > detachedVideo ;
}
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
} ;
/// Display subtitles only.
2011-01-16 08:15:32 +01:00
struct app_display_subs : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/display/subs " )
STR_MENU ( " Subs Only View " )
STR_DISP ( " Subs Only View " )
STR_HELP ( " Display subtitles only. " )
2011-07-15 06:05:56 +02:00
CMD_TYPE ( COMMAND_VALIDATE | COMMAND_RADIO )
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
void operator ( ) ( agi : : Context * c ) {
wxGetApp ( ) . frame - > SetDisplayMode ( 0 , 0 ) ;
}
} ;
/// Display video and subtitles only.
2011-01-16 08:15:32 +01:00
struct app_display_video_subs : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/display/video_subs " )
STR_MENU ( " Video+Subs View " )
STR_DISP ( " Video+Subs View " )
STR_HELP ( " Display video and subtitles only. " )
2011-07-15 06:05:56 +02:00
CMD_TYPE ( COMMAND_VALIDATE | COMMAND_RADIO )
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
void operator ( ) ( agi : : Context * c ) {
wxGetApp ( ) . frame - > SetDisplayMode ( 1 , 0 ) ;
}
2011-07-15 06:05:22 +02:00
bool Validate ( const agi : : Context * c ) {
return c - > videoController - > IsLoaded ( ) & & ! c - > detachedVideo ;
}
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
} ;
/// Exit the application.
2011-01-16 08:15:32 +01:00
struct app_exit : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/exit " )
STR_MENU ( " E&xit " )
STR_DISP ( " Exit " )
STR_HELP ( " Exit the application. " )
void operator ( ) ( agi : : Context * c ) {
2011-01-16 08:15:24 +01:00
wxGetApp ( ) . frame - > Close ( ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
}
} ;
/// Select Aegisub interface language
2011-01-16 08:15:32 +01:00
struct app_language : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/language " )
STR_MENU ( " &Language... " )
STR_DISP ( " Language " )
STR_HELP ( " Select Aegisub interface language " )
void operator ( ) ( agi : : Context * c ) {
// Get language
AegisubApp * app = ( AegisubApp * ) wxTheApp ;
int old = app - > locale . curCode ;
int newCode = app - > locale . PickLanguage ( ) ;
// Is OK?
2011-01-16 08:15:24 +01:00
if ( newCode ! = - 1 & & newCode ! = old ) {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
// Set code
OPT_SET ( " App/Locale " ) - > SetInt ( newCode ) ;
2011-01-16 08:15:24 +01:00
// Ask to restart program
2011-09-28 21:43:11 +02:00
int result = wxMessageBox ( " Aegisub needs to be restarted so that the new language can be applied. Restart now? " , " Restart Aegisub? " , wxICON_QUESTION | wxYES_NO ) ;
2011-01-16 08:15:24 +01:00
if ( result = = wxYES ) {
// Restart Aegisub
if ( wxGetApp ( ) . frame - > Close ( ) ) {
RestartAegisub ( ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
}
}
}
}
} ;
/// Event log.
2011-01-16 08:15:32 +01:00
struct app_log : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/log " )
STR_MENU ( " &Log window... " )
STR_DISP ( " Log window " )
STR_HELP ( " Event log. " )
void operator ( ) ( agi : : Context * c ) {
2011-01-16 08:15:24 +01:00
( new LogWindow ( c - > parent ) ) - > Show ( 1 ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
}
} ;
/// Open a new application window.
2011-01-16 08:15:32 +01:00
struct app_new_window : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/new_window " )
STR_MENU ( " New Window " )
STR_DISP ( " New Window " )
STR_HELP ( " Open a new application window. " )
void operator ( ) ( agi : : Context * c ) {
RestartAegisub ( ) ;
}
} ;
/// Configure Aegisub.
2011-01-16 08:15:32 +01:00
struct app_options : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/options " )
2011-10-01 20:35:12 +02:00
STR_MENU ( " &Options... " )
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
STR_DISP ( " Options " )
STR_HELP ( " Configure Aegisub. " )
void operator ( ) ( agi : : Context * c ) {
try {
2011-01-16 08:15:24 +01:00
Preferences ( c - > parent ) . ShowModal ( ) ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
} catch ( agi : : Exception & e ) {
LOG_E ( " config/init " ) < < " Caught exception: " < < e . GetName ( ) < < " -> " < < e . GetMessage ( ) ;
}
}
} ;
2011-07-28 00:59:11 +02:00
/// Toggle global override hotkeys (aka medusa mode).
struct app_toggle_global_hotkeys : public Command {
CMD_NAME ( " app/toggle/global_hotkeys " )
STR_MENU ( " Toggle global hotkey overrides " )
STR_DISP ( " Toggle global hotkey overrides " )
STR_HELP ( " Toggle global hotkey overrides. " )
CMD_TYPE ( COMMAND_TOGGLE )
bool IsActive ( const agi : : Context * c ) {
return OPT_GET ( " Audio/Medusa Timing Hotkeys " ) - > GetBool ( ) ;
}
void operator ( ) ( agi : : Context * c ) {
agi : : OptionValue * opt = OPT_SET ( " Audio/Medusa Timing Hotkeys " ) ;
opt - > SetBool ( ! opt - > GetBool ( ) ) ;
}
} ;
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
/// Check to see if there is a new version of Aegisub available.
2011-01-16 08:15:32 +01:00
struct app_updates : public Command {
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
CMD_NAME ( " app/updates " )
2011-07-28 00:59:11 +02:00
STR_MENU ( " &Check for Updates... " )
Merge the dynamic menu, hotkey and toolbar branch to trunk. This doesn't include Windows support as vs2008 was being a major pain. This involves revisions r4921:4950, r4961:5002, r5005:5006, r5008:5056, r5062:5065, r5072, r5081:5082, r5087, r5096:5110, r5124:5125. Updates #1258.
Originally committed to SVN as r5126.
2011-01-05 14:00:46 +01:00
STR_DISP ( " Check for Updates " )
STR_HELP ( " Check to see if there is a new version of Aegisub available. " )
void operator ( ) ( agi : : Context * c ) {
PerformVersionCheck ( true ) ;
}
} ;
/// @}
}
2011-07-15 06:05:01 +02:00
namespace cmd {
void init_app ( ) {
reg ( new app_about ) ;
reg ( new app_display_audio_subs ) ;
reg ( new app_display_full ) ;
reg ( new app_display_subs ) ;
reg ( new app_display_video_subs ) ;
reg ( new app_exit ) ;
reg ( new app_language ) ;
reg ( new app_log ) ;
reg ( new app_new_window ) ;
reg ( new app_options ) ;
2011-07-28 00:59:11 +02:00
reg ( new app_toggle_global_hotkeys ) ;
2011-07-15 06:05:01 +02:00
reg ( new app_updates ) ;
}
}