Added "Quick Reference" command.

- Added Launcher class to open files and URLs.
This commit is contained in:
David Capello 2010-07-03 13:34:17 -03:00
parent 263c9d4e6e
commit 3d89a21e2f
6 changed files with 137 additions and 0 deletions

View File

@ -307,6 +307,8 @@
<item command="options" text="&amp;Options" />
</menu>
<menu text="&amp;Help">
<item command="quick_reference" text="Quick &amp;Reference" />
<separator />
<item command="about" text="&amp;About" />
</menu>
</menu>

View File

@ -11,6 +11,7 @@ COMMON_SOURCES = \
src/console.cpp \
src/context.cpp \
src/gfxmode.cpp \
src/launcher.cpp \
src/recent_files.cpp \
src/ui_context.cpp \
src/undoable.cpp \
@ -59,6 +60,7 @@ COMMON_SOURCES = \
src/commands/cmd_paste.cpp \
src/commands/cmd_play_animation.cpp \
src/commands/cmd_preview.cpp \
src/commands/cmd_quick_reference.cpp \
src/commands/cmd_record_screen.cpp \
src/commands/cmd_redo.cpp \
src/commands/cmd_refresh.cpp \

View File

@ -0,0 +1,57 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2010 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "commands/command.h"
#include "launcher.h"
//////////////////////////////////////////////////////////////////////
// about
class QuickReferenceCommand : public Command
{
public:
QuickReferenceCommand();
Command* clone() const { return new QuickReferenceCommand(*this); }
protected:
void execute(Context* context);
};
QuickReferenceCommand::QuickReferenceCommand()
: Command("quick_reference",
"Quick Reference",
CmdUIOnlyFlag)
{
}
void QuickReferenceCommand::execute(Context* context)
{
std::string path = "docs/quickref.pdf";
Launcher::openFile(path);
}
//////////////////////////////////////////////////////////////////////
// CommandFactory
Command* CommandFactory::create_quick_reference_command()
{
return new QuickReferenceCommand;
}

View File

@ -75,6 +75,7 @@ FOR_EACH_COMMAND(play_animation)
FOR_EACH_COMMAND(preview_fit_to_screen)
FOR_EACH_COMMAND(preview_normal)
FOR_EACH_COMMAND(preview_tiled)
FOR_EACH_COMMAND(quick_reference)
FOR_EACH_COMMAND(record_screen)
FOR_EACH_COMMAND(redo)
FOR_EACH_COMMAND(refresh)

43
src/launcher.cpp Normal file
View File

@ -0,0 +1,43 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2010 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "launcher.h"
void Launcher::openUrl(const std::string& url)
{
openFile(url);
}
void Launcher::openFile(const std::string& file)
{
#if defined ALLEGRO_WINDOWS
system(("start " + file).c_str());
#elif defined ALLEGRO_MACOSX
system(("open " + file).c_str());
#else // Linux
system(("todo " + file).c_str());
#endif
}

32
src/launcher.h Normal file
View File

@ -0,0 +1,32 @@
/* ASE - Allegro Sprite Editor
* Copyright (C) 2001-2010 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LAUNCHER_H_INCLUDED
#define LAUNCHER_H_INCLUDED
#include <string>
class Launcher
{
public:
static void openUrl(const std::string& url);
static void openFile(const std::string& file);
};
#endif