mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
* Application: change the signature of getStatus() to reflect the one of GuiView.
* LyXFunc::getStatus(): properly use Application::getStatus() * LFUN_SET_COLOR: transfer to GuiApplication (and get rid of Application::updateColor()). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24900 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5924ca2831
commit
9f5daec59a
@ -433,13 +433,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
bool enable = true;
|
||||
switch (cmd.action) {
|
||||
|
||||
// FIXME: these cases should be hidden in GuiApplication::getStatus().
|
||||
case LFUN_WINDOW_CLOSE:
|
||||
if (theApp())
|
||||
return theApp()->getStatus(cmd);
|
||||
enable = false;
|
||||
break;
|
||||
|
||||
// FIXME optimally this should be in Text::getStatus. In such a case the flags
|
||||
// are not passed when using context menu. This way it works.
|
||||
case LFUN_SET_GRAPHICS_GROUP: {
|
||||
@ -568,8 +561,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_BUFFER_NEW:
|
||||
case LFUN_BUFFER_NEW_TEMPLATE:
|
||||
case LFUN_WORD_FIND_FORWARD:
|
||||
case LFUN_WORD_FIND_BACKWARD:
|
||||
case LFUN_COMMAND_PREFIX:
|
||||
@ -585,7 +576,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
case LFUN_BUFFER_AUTO_SAVE:
|
||||
case LFUN_RECONFIGURE:
|
||||
case LFUN_HELP_OPEN:
|
||||
case LFUN_FILE_OPEN:
|
||||
case LFUN_DROP_LAYOUTS_CHOICE:
|
||||
case LFUN_MENU_OPEN:
|
||||
case LFUN_SERVER_GET_NAME:
|
||||
@ -603,8 +593,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
case LFUN_BUFFER_EXPORT_CUSTOM:
|
||||
case LFUN_BUFFER_PRINT:
|
||||
case LFUN_PREFERENCES_SAVE:
|
||||
case LFUN_SCREEN_FONT_UPDATE:
|
||||
case LFUN_SET_COLOR:
|
||||
case LFUN_MESSAGE:
|
||||
case LFUN_INSET_EDIT:
|
||||
case LFUN_ALL_INSETS_TOGGLE:
|
||||
@ -620,12 +608,17 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
||||
case LFUN_LYXRC_APPLY:
|
||||
case LFUN_BUFFER_NEXT:
|
||||
case LFUN_BUFFER_PREVIOUS:
|
||||
case LFUN_WINDOW_NEW:
|
||||
case LFUN_LYX_QUIT:
|
||||
// these are handled in our dispatch()
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!theApp()) {
|
||||
enable = false;
|
||||
break;
|
||||
}
|
||||
if (theApp()->getStatus(cmd, flag))
|
||||
break;
|
||||
|
||||
// Does the view know something?
|
||||
if (!lyx_view_) {
|
||||
enable = false;
|
||||
@ -1395,40 +1388,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_SET_COLOR: {
|
||||
string lyx_name;
|
||||
string const x11_name = split(argument, lyx_name, ' ');
|
||||
if (lyx_name.empty() || x11_name.empty()) {
|
||||
setErrorMessage(from_ascii(N_(
|
||||
"Syntax: set-color <lyx_name>"
|
||||
" <x11_name>")));
|
||||
break;
|
||||
}
|
||||
|
||||
bool const graphicsbg_changed =
|
||||
(lyx_name == lcolor.getLyXName(Color_graphicsbg) &&
|
||||
x11_name != lcolor.getX11Name(Color_graphicsbg));
|
||||
|
||||
if (!lcolor.setColor(lyx_name, x11_name)) {
|
||||
setErrorMessage(
|
||||
bformat(_("Set-color \"%1$s\" failed "
|
||||
"- color is undefined or "
|
||||
"may not be redefined"),
|
||||
from_utf8(lyx_name)));
|
||||
break;
|
||||
}
|
||||
|
||||
theApp()->updateColor(lcolor.getFromLyXName(lyx_name));
|
||||
|
||||
if (graphicsbg_changed) {
|
||||
// FIXME: The graphics cache no longer has a changeDisplay method.
|
||||
#if 0
|
||||
graphics::GCache::get().changeDisplay(true);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case LFUN_MESSAGE:
|
||||
LASSERT(lyx_view_, /**/);
|
||||
lyx_view_->message(from_utf8(argument));
|
||||
|
@ -169,7 +169,7 @@ public:
|
||||
virtual ~Application() {}
|
||||
|
||||
///
|
||||
virtual FuncStatus getStatus(FuncRequest const & cmd) = 0;
|
||||
virtual bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const = 0;
|
||||
/// dispatch command.
|
||||
/// \return true if the \c FuncRequest has been dispatched.
|
||||
virtual bool dispatch(FuncRequest const & cmd) = 0;
|
||||
@ -209,11 +209,6 @@ public:
|
||||
*/
|
||||
virtual std::string const hexName(ColorCode col) = 0;
|
||||
|
||||
/**
|
||||
* update an altered GUI color
|
||||
*/
|
||||
virtual void updateColor(ColorCode col) = 0;
|
||||
|
||||
/**
|
||||
* read and create the menu structure
|
||||
*/
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "Buffer.h"
|
||||
#include "BufferList.h"
|
||||
#include "BufferView.h"
|
||||
#include "Color.h"
|
||||
#include "Font.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "FuncStatus.h"
|
||||
@ -489,9 +490,8 @@ GuiApplication::GuiApplication(int & argc, char ** argv)
|
||||
}
|
||||
|
||||
|
||||
FuncStatus GuiApplication::getStatus(FuncRequest const & cmd)
|
||||
bool GuiApplication::getStatus(FuncRequest const & cmd, FuncStatus & flag) const
|
||||
{
|
||||
FuncStatus flag;
|
||||
bool enable = true;
|
||||
|
||||
switch(cmd.action) {
|
||||
@ -500,17 +500,24 @@ FuncStatus GuiApplication::getStatus(FuncRequest const & cmd)
|
||||
enable = d->view_ids_.size() > 0;
|
||||
break;
|
||||
|
||||
case LFUN_BUFFER_NEW:
|
||||
case LFUN_BUFFER_NEW_TEMPLATE:
|
||||
case LFUN_FILE_OPEN:
|
||||
case LFUN_SCREEN_FONT_UPDATE:
|
||||
case LFUN_SET_COLOR:
|
||||
case LFUN_WINDOW_NEW:
|
||||
case LFUN_LYX_QUIT:
|
||||
enable = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!current_view_) {
|
||||
enable = false;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!enable)
|
||||
flag.enabled(false);
|
||||
|
||||
return flag;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -588,6 +595,38 @@ bool GuiApplication::dispatch(FuncRequest const & cmd)
|
||||
current_view_->openDocument(to_utf8(cmd.argument()));
|
||||
break;
|
||||
|
||||
case LFUN_SET_COLOR: {
|
||||
string lyx_name;
|
||||
string const x11_name = split(to_utf8(cmd.argument()), lyx_name, ' ');
|
||||
if (lyx_name.empty() || x11_name.empty()) {
|
||||
current_view_->message(
|
||||
_("Syntax: set-color <lyx_name> <x11_name>"));
|
||||
break;
|
||||
}
|
||||
|
||||
string const graphicsbg = lcolor.getLyXName(Color_graphicsbg);
|
||||
bool const graphicsbg_changed = lyx_name == graphicsbg
|
||||
&& x11_name != graphicsbg;
|
||||
if (graphicsbg_changed) {
|
||||
// FIXME: The graphics cache no longer has a changeDisplay method.
|
||||
#if 0
|
||||
graphics::GCache::get().changeDisplay(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!lcolor.setColor(lyx_name, x11_name)) {
|
||||
current_view_->message(
|
||||
bformat(_("Set-color \"%1$s\" failed "
|
||||
"- color is undefined or "
|
||||
"may not be redefined"),
|
||||
from_utf8(lyx_name)));
|
||||
break;
|
||||
}
|
||||
// Make sure we don't keep old colors in cache.
|
||||
d->color_cache_.clear();
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// Notify the caller that the action has not been dispatched.
|
||||
return false;
|
||||
@ -915,13 +954,6 @@ string const GuiApplication::hexName(ColorCode col)
|
||||
}
|
||||
|
||||
|
||||
void GuiApplication::updateColor(ColorCode)
|
||||
{
|
||||
// FIXME: Bleh, can't we just clear them all at once ?
|
||||
d->color_cache_.clear();
|
||||
}
|
||||
|
||||
|
||||
void GuiApplication::registerSocketCallback(int fd, SocketCallback func)
|
||||
{
|
||||
SocketNotifier * sn = new SocketNotifier(this, fd, func);
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
|
||||
/// Method inherited from \c Application class
|
||||
//@{
|
||||
FuncStatus getStatus(FuncRequest const &);
|
||||
bool getStatus(FuncRequest const & cmd, FuncStatus & flag) const;
|
||||
bool dispatch(FuncRequest const &);
|
||||
void resetGui();
|
||||
void restoreGuiSession();
|
||||
@ -65,7 +65,6 @@ public:
|
||||
bool event(QEvent * e);
|
||||
bool getRgbColor(ColorCode col, RGBColor & rgbcol);
|
||||
std::string const hexName(ColorCode col);
|
||||
void updateColor(ColorCode col);
|
||||
void readMenus(Lexer & lex);
|
||||
void registerSocketCallback(int fd, SocketCallback func);
|
||||
void unregisterSocketCallback(int fd);
|
||||
|
Loading…
Reference in New Issue
Block a user