mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-08 10:51:03 +00:00
- Cleanup and simplify the layout list GUI handling.
- Transfer toolbar, statusbar and layoutlist handling to the frontend. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21684 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
228bd9b277
commit
ba3fa9bd03
@ -487,17 +487,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
|
|||||||
//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
|
//lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl;
|
||||||
FuncStatus flag;
|
FuncStatus flag;
|
||||||
|
|
||||||
/* In LyX/Mac, when a dialog is open, the menus of the
|
|
||||||
application can still be accessed without giving focus to
|
|
||||||
the main window. In this case, we want to disable the menu
|
|
||||||
entries that are buffer-related.
|
|
||||||
|
|
||||||
Note that this code is not perfect, as bug 1941 attests:
|
|
||||||
http://bugzilla.lyx.org/show_bug.cgi?id=1941#c4
|
|
||||||
*/
|
|
||||||
Buffer * buf = lyx_view_? lyx_view_->buffer() : 0;
|
Buffer * buf = lyx_view_? lyx_view_->buffer() : 0;
|
||||||
if (lyx_view_ && cmd.origin == FuncRequest::MENU && !lyx_view_->hasFocus())
|
|
||||||
buf = 0;
|
|
||||||
|
|
||||||
if (cmd.action == LFUN_NOACTION) {
|
if (cmd.action == LFUN_NOACTION) {
|
||||||
flag.message(from_utf8(N_("Nothing to do")));
|
flag.message(from_utf8(N_("Nothing to do")));
|
||||||
@ -1888,9 +1878,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
|
|
||||||
actOnUpdatedPrefs(lyxrc_orig, lyxrc);
|
actOnUpdatedPrefs(lyxrc_orig, lyxrc);
|
||||||
|
|
||||||
if (lyx_view_ && lyx_view_->buffer())
|
|
||||||
lyx_view_->updateLayoutChoice(true);
|
|
||||||
|
|
||||||
/// We force the redraw in any case because there might be
|
/// We force the redraw in any case because there might be
|
||||||
/// some screen font changes.
|
/// some screen font changes.
|
||||||
/// FIXME: only the current view will be updated. the Gui
|
/// FIXME: only the current view will be updated. the Gui
|
||||||
@ -1940,7 +1927,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
// (at least partially) visible top-level paragraphs.
|
// (at least partially) visible top-level paragraphs.
|
||||||
// We will redraw the screen only if needed.
|
// We will redraw the screen only if needed.
|
||||||
view()->processUpdateFlags(updateFlags);
|
view()->processUpdateFlags(updateFlags);
|
||||||
lyx_view_->updateStatusBar();
|
|
||||||
|
|
||||||
// if we executed a mutating lfun, mark the buffer as dirty
|
// if we executed a mutating lfun, mark the buffer as dirty
|
||||||
if (flag.enabled()
|
if (flag.enabled()
|
||||||
@ -1952,12 +1938,10 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
|||||||
theSelection().haveSelection(view()->cursor().selection());
|
theSelection().haveSelection(view()->cursor().selection());
|
||||||
|
|
||||||
if (view()->cursor().inTexted()) {
|
if (view()->cursor().inTexted()) {
|
||||||
lyx_view_->updateLayoutChoice(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!quitting && lyx_view_) {
|
if (!quitting && lyx_view_) {
|
||||||
lyx_view_->updateToolbars();
|
|
||||||
// Some messages may already be translated, so we cannot use _()
|
// Some messages may already be translated, so we cannot use _()
|
||||||
sendDispatchMessage(translateIfPossible(getMessage()), cmd);
|
sendDispatchMessage(translateIfPossible(getMessage()), cmd);
|
||||||
}
|
}
|
||||||
@ -2070,7 +2054,6 @@ Buffer * LyXFunc::loadAndViewFile(FileName const & filename, bool tolastfiles)
|
|||||||
|
|
||||||
if (!newBuffer) {
|
if (!newBuffer) {
|
||||||
lyx_view_->message(_("Document not loaded."));
|
lyx_view_->message(_("Document not loaded."));
|
||||||
lyx_view_->updateStatusBar();
|
|
||||||
lyx_view_->setBusy(false);
|
lyx_view_->setBusy(false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -70,12 +70,6 @@ public:
|
|||||||
|
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
/// updates the possible layouts selectable
|
|
||||||
virtual void updateLayoutChoice(bool force) = 0;
|
|
||||||
/// update the toolbar
|
|
||||||
virtual void updateToolbars() = 0;
|
|
||||||
/// update the status bar
|
|
||||||
virtual void updateStatusBar() = 0;
|
|
||||||
/// display a message in the view
|
/// display a message in the view
|
||||||
virtual void message(docstring const &) = 0;
|
virtual void message(docstring const &) = 0;
|
||||||
|
|
||||||
@ -84,14 +78,6 @@ public:
|
|||||||
/// dispatch to current BufferView
|
/// dispatch to current BufferView
|
||||||
virtual void dispatch(FuncRequest const & cmd) = 0;
|
virtual void dispatch(FuncRequest const & cmd) = 0;
|
||||||
|
|
||||||
/** redraw \c inset in all the BufferViews in which it is currently
|
|
||||||
* visible. If successful return a pointer to the owning Buffer.
|
|
||||||
*/
|
|
||||||
virtual Buffer const * updateInset(Inset const *) = 0;
|
|
||||||
|
|
||||||
/// returns true if this view has the focus.
|
|
||||||
virtual bool hasFocus() const = 0;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
virtual void restartCursor() = 0;
|
virtual void restartCursor() = 0;
|
||||||
|
|
||||||
@ -100,14 +86,10 @@ public:
|
|||||||
//
|
//
|
||||||
virtual void errors(std::string const &) = 0;
|
virtual void errors(std::string const &) = 0;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// This View's Dialogs
|
// This View's Dialogs
|
||||||
//
|
//
|
||||||
|
|
||||||
/// Hide all visible dialogs
|
|
||||||
virtual void hideAll() const = 0;
|
|
||||||
|
|
||||||
/** \param name == "bibtex", "citation" etc; an identifier used to
|
/** \param name == "bibtex", "citation" etc; an identifier used to
|
||||||
launch a particular dialog.
|
launch a particular dialog.
|
||||||
\param data is a string representation of the Inset contents.
|
\param data is a string representation of the Inset contents.
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "Buffer.h"
|
#include "Buffer.h"
|
||||||
#include "BufferParams.h"
|
#include "BufferParams.h"
|
||||||
|
#include "BufferView.h"
|
||||||
|
#include "Cursor.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "FuncRequest.h"
|
#include "FuncRequest.h"
|
||||||
#include "FuncStatus.h"
|
#include "FuncStatus.h"
|
||||||
@ -23,6 +25,7 @@
|
|||||||
#include "IconPalette.h"
|
#include "IconPalette.h"
|
||||||
#include "Layout.h"
|
#include "Layout.h"
|
||||||
#include "LyXFunc.h"
|
#include "LyXFunc.h"
|
||||||
|
#include "Paragraph.h"
|
||||||
#include "TextClass.h"
|
#include "TextClass.h"
|
||||||
#include "ToolbarBackend.h"
|
#include "ToolbarBackend.h"
|
||||||
|
|
||||||
@ -227,12 +230,6 @@ static QIcon getIcon(FuncRequest const & f, bool unknown)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TextClass const & textClass(LyXView const & lv)
|
|
||||||
{
|
|
||||||
return lv.buffer()->params().getTextClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// GuiLayoutBox
|
// GuiLayoutBox
|
||||||
@ -249,22 +246,23 @@ GuiLayoutBox::GuiLayoutBox(GuiView & owner)
|
|||||||
|
|
||||||
QObject::connect(this, SIGNAL(activated(QString)),
|
QObject::connect(this, SIGNAL(activated(QString)),
|
||||||
this, SLOT(selected(QString)));
|
this, SLOT(selected(QString)));
|
||||||
|
owner_.setLayoutDialog(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiLayoutBox::set(docstring const & layout)
|
void GuiLayoutBox::set(docstring const & layout)
|
||||||
{
|
{
|
||||||
TextClass const & tc = textClass(owner_);
|
if (!text_class_)
|
||||||
|
return;
|
||||||
|
|
||||||
QString const & name = toqstr(translateIfPossible(tc[layout]->name()));
|
QString const & name = toqstr(translateIfPossible(
|
||||||
|
(*text_class_)[layout]->name()));
|
||||||
|
|
||||||
int i = 0;
|
if (name == currentText())
|
||||||
for (; i < count(); ++i) {
|
return;
|
||||||
if (name == itemText(i))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == count()) {
|
int i = findText(name);
|
||||||
|
if (i == -1) {
|
||||||
lyxerr << "Trying to select non existent layout type "
|
lyxerr << "Trying to select non existent layout type "
|
||||||
<< fromqstr(name) << endl;
|
<< fromqstr(name) << endl;
|
||||||
return;
|
return;
|
||||||
@ -297,15 +295,30 @@ void GuiLayoutBox::addItemSort(QString const & item, bool sorted)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiLayoutBox::updateContents()
|
void GuiLayoutBox::updateContents(bool reset)
|
||||||
{
|
{
|
||||||
TextClass const & tc = textClass(owner_);
|
Buffer const * buffer = owner_.buffer();
|
||||||
|
if (!buffer) {
|
||||||
|
clear();
|
||||||
|
setEnabled(false);
|
||||||
|
text_class_ = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setEnabled(true);
|
||||||
|
TextClass const * text_class = &buffer->params().getTextClass();
|
||||||
|
if (!reset && text_class_ == text_class) {
|
||||||
|
set(owner_.view()->cursor().innerParagraph().layout()->name());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
text_class_ = text_class;
|
||||||
|
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
TextClass::const_iterator it = tc.begin();
|
TextClass::const_iterator it = text_class_->begin();
|
||||||
TextClass::const_iterator const end = tc.end();
|
TextClass::const_iterator const end = text_class_->end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
// ignore obsolete entries
|
// ignore obsolete entries
|
||||||
addItemSort(toqstr(translateIfPossible((*it)->name())), lyxrc.sort_layouts);
|
addItemSort(toqstr(translateIfPossible((*it)->name())), lyxrc.sort_layouts);
|
||||||
@ -316,6 +329,7 @@ void GuiLayoutBox::updateContents()
|
|||||||
// needed to recalculate size hint
|
// needed to recalculate size hint
|
||||||
hide();
|
hide();
|
||||||
setMinimumWidth(sizeHint().width());
|
setMinimumWidth(sizeHint().width());
|
||||||
|
set(owner_.view()->cursor().innerParagraph().layout()->name());
|
||||||
show();
|
show();
|
||||||
|
|
||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
@ -325,10 +339,13 @@ void GuiLayoutBox::updateContents()
|
|||||||
void GuiLayoutBox::selected(const QString & str)
|
void GuiLayoutBox::selected(const QString & str)
|
||||||
{
|
{
|
||||||
owner_.setFocus();
|
owner_.setFocus();
|
||||||
TextClass const & tc = owner_.buffer()->params().getTextClass();
|
updateContents(false);
|
||||||
|
if (!text_class_)
|
||||||
|
return;
|
||||||
|
|
||||||
docstring const name = qstring_to_ucs4(str);
|
docstring const name = qstring_to_ucs4(str);
|
||||||
TextClass::const_iterator it = tc.begin();
|
TextClass::const_iterator it = text_class_->begin();
|
||||||
TextClass::const_iterator const end = tc.end();
|
TextClass::const_iterator const end = text_class_->end();
|
||||||
for (; it != end; ++it) {
|
for (; it != end; ++it) {
|
||||||
docstring const & itname = (*it)->name();
|
docstring const & itname = (*it)->name();
|
||||||
if (translateIfPossible(itname) == name) {
|
if (translateIfPossible(itname) == name) {
|
||||||
@ -517,6 +534,9 @@ void GuiToolbar::updateContents()
|
|||||||
for (int i = 0; i < actions_.size(); ++i)
|
for (int i = 0; i < actions_.size(); ++i)
|
||||||
actions_[i]->update();
|
actions_[i]->update();
|
||||||
|
|
||||||
|
if (layout_)
|
||||||
|
layout_->setEnabled(lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled());
|
||||||
|
|
||||||
// emit signal
|
// emit signal
|
||||||
updated();
|
updated();
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
|
class TextClass;
|
||||||
class ToolbarItem;
|
class ToolbarItem;
|
||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
@ -42,7 +43,7 @@ public:
|
|||||||
/// select the right layout in the combobox.
|
/// select the right layout in the combobox.
|
||||||
void set(docstring const & layout);
|
void set(docstring const & layout);
|
||||||
/// Populate the layout combobox.
|
/// Populate the layout combobox.
|
||||||
void updateContents();
|
void updateContents(bool reset);
|
||||||
/// Add Item to Layout box according to sorting settings from preferences
|
/// Add Item to Layout box according to sorting settings from preferences
|
||||||
void addItemSort(QString const & item, bool sorted);
|
void addItemSort(QString const & item, bool sorted);
|
||||||
|
|
||||||
@ -51,6 +52,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
GuiView & owner_;
|
GuiView & owner_;
|
||||||
|
TextClass const * text_class_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +70,6 @@ public:
|
|||||||
void saveInfo(ToolbarSection::ToolbarInfo & info);
|
void saveInfo(ToolbarSection::ToolbarInfo & info);
|
||||||
/// Refresh the contents of the bar.
|
/// Refresh the contents of the bar.
|
||||||
void updateContents();
|
void updateContents();
|
||||||
GuiLayoutBox * layout() const { return layout_; }
|
|
||||||
///
|
///
|
||||||
GuiCommandBuffer * commandBuffer() { return command_buffer_; }
|
GuiCommandBuffer * commandBuffer() { return command_buffer_; }
|
||||||
|
|
||||||
|
@ -41,9 +41,7 @@ namespace frontend {
|
|||||||
#define TurnOffFlag(x) flags &= ~ToolbarInfo::x
|
#define TurnOffFlag(x) flags &= ~ToolbarInfo::x
|
||||||
|
|
||||||
GuiToolbars::GuiToolbars(GuiView & owner)
|
GuiToolbars::GuiToolbars(GuiView & owner)
|
||||||
: owner_(owner),
|
: owner_(owner)
|
||||||
layout_(0),
|
|
||||||
last_textclass_(TextClassPtr())
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@ -288,41 +286,6 @@ void GuiToolbars::saveToolbarInfo()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiToolbars::setLayout(docstring const & layout)
|
|
||||||
{
|
|
||||||
if (layout_)
|
|
||||||
layout_->set(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GuiToolbars::updateLayoutList(TextClassPtr textclass, bool force)
|
|
||||||
{
|
|
||||||
// update the layout display
|
|
||||||
if (last_textclass_ != textclass || force) {
|
|
||||||
if (layout_)
|
|
||||||
layout_->updateContents();
|
|
||||||
last_textclass_ = textclass;
|
|
||||||
return true;
|
|
||||||
} else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiToolbars::openLayoutList()
|
|
||||||
{
|
|
||||||
if (layout_)
|
|
||||||
layout_->showPopup();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiToolbars::clearLayoutList()
|
|
||||||
{
|
|
||||||
last_textclass_ = TextClassPtr();
|
|
||||||
if (layout_)
|
|
||||||
layout_->clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GuiToolbars::add(ToolbarInfo const & tbinfo, bool newline)
|
void GuiToolbars::add(ToolbarInfo const & tbinfo, bool newline)
|
||||||
{
|
{
|
||||||
GuiToolbar * tb_ptr = owner_.makeToolbar(tbinfo, newline);
|
GuiToolbar * tb_ptr = owner_.makeToolbar(tbinfo, newline);
|
||||||
@ -332,9 +295,6 @@ void GuiToolbars::add(ToolbarInfo const & tbinfo, bool newline)
|
|||||||
tb_ptr->show();
|
tb_ptr->show();
|
||||||
else
|
else
|
||||||
tb_ptr->hide();
|
tb_ptr->hide();
|
||||||
|
|
||||||
if (tb_ptr->layout())
|
|
||||||
layout_ = tb_ptr->layout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -360,12 +320,6 @@ void GuiToolbars::updateIcons()
|
|||||||
ToolbarsMap::const_iterator const end = toolbars_.end();
|
ToolbarsMap::const_iterator const end = toolbars_.end();
|
||||||
for (; it != end; ++it)
|
for (; it != end; ++it)
|
||||||
it->second->updateContents();
|
it->second->updateContents();
|
||||||
|
|
||||||
bool const enable =
|
|
||||||
lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled();
|
|
||||||
|
|
||||||
if (layout_)
|
|
||||||
layout_->setEnabled(enable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ class ToolbarInfo;
|
|||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class GuiLayoutBox;
|
|
||||||
class GuiToolbar;
|
class GuiToolbar;
|
||||||
class GuiView;
|
class GuiView;
|
||||||
|
|
||||||
@ -59,19 +58,6 @@ public:
|
|||||||
/// save toolbar information
|
/// save toolbar information
|
||||||
void saveToolbarInfo();
|
void saveToolbarInfo();
|
||||||
|
|
||||||
/// Select the right layout in the combox.
|
|
||||||
void setLayout(docstring const & layout);
|
|
||||||
|
|
||||||
/** Populate the layout combox - returns whether we did a full
|
|
||||||
* update or not
|
|
||||||
*/
|
|
||||||
bool updateLayoutList(TextClassPtr textclass, bool force);
|
|
||||||
|
|
||||||
/// Drop down the layout list.
|
|
||||||
void openLayoutList();
|
|
||||||
/// Erase the layout list.
|
|
||||||
void clearLayoutList();
|
|
||||||
|
|
||||||
/// Show or hide the command buffer.
|
/// Show or hide the command buffer.
|
||||||
void showCommandBuffer(bool show_it);
|
void showCommandBuffer(bool show_it);
|
||||||
|
|
||||||
@ -92,15 +78,6 @@ private:
|
|||||||
/// The parent window.
|
/// The parent window.
|
||||||
GuiView & owner_;
|
GuiView & owner_;
|
||||||
|
|
||||||
/** The layout box is actually owned by whichever toolbar
|
|
||||||
* contains it. All the Toolbars class needs is a means of
|
|
||||||
* accessing it.
|
|
||||||
*
|
|
||||||
* We don't need to use boost::weak_ptr here because the toolbars
|
|
||||||
* are also stored here. There are, therefore, no lifetime issues.
|
|
||||||
*/
|
|
||||||
GuiLayoutBox * layout_;
|
|
||||||
|
|
||||||
/// Toolbar store providing access to individual toolbars by name.
|
/// Toolbar store providing access to individual toolbars by name.
|
||||||
typedef std::map<std::string, GuiToolbar *> ToolbarsMap;
|
typedef std::map<std::string, GuiToolbar *> ToolbarsMap;
|
||||||
ToolbarsMap toolbars_;
|
ToolbarsMap toolbars_;
|
||||||
|
@ -155,7 +155,7 @@ typedef boost::shared_ptr<Dialog> DialogPtr;
|
|||||||
struct GuiView::GuiViewPrivate
|
struct GuiView::GuiViewPrivate
|
||||||
{
|
{
|
||||||
GuiViewPrivate()
|
GuiViewPrivate()
|
||||||
: current_work_area_(0), posx_offset(0), posy_offset(0),
|
: current_work_area_(0), layout_(0),
|
||||||
autosave_timeout_(new Timeout(5000)), quitting_by_menu_(false),
|
autosave_timeout_(new Timeout(5000)), quitting_by_menu_(false),
|
||||||
in_show_(false)
|
in_show_(false)
|
||||||
{
|
{
|
||||||
@ -263,9 +263,6 @@ public:
|
|||||||
string cur_title;
|
string cur_title;
|
||||||
|
|
||||||
GuiWorkArea * current_work_area_;
|
GuiWorkArea * current_work_area_;
|
||||||
int posx_offset;
|
|
||||||
int posy_offset;
|
|
||||||
|
|
||||||
QSplitter * splitter_;
|
QSplitter * splitter_;
|
||||||
QStackedWidget * stack_widget_;
|
QStackedWidget * stack_widget_;
|
||||||
BackgroundWidget * bg_widget_;
|
BackgroundWidget * bg_widget_;
|
||||||
@ -273,8 +270,16 @@ public:
|
|||||||
GuiMenubar * menubar_;
|
GuiMenubar * menubar_;
|
||||||
/// view's toolbars
|
/// view's toolbars
|
||||||
GuiToolbars * toolbars_;
|
GuiToolbars * toolbars_;
|
||||||
///
|
/// The main layout box.
|
||||||
docstring current_layout;
|
/**
|
||||||
|
* \warning Don't Delete! The layout box is actually owned by
|
||||||
|
* whichever toolbar contains it. All the GuiView class needs is a
|
||||||
|
* means of accessing it.
|
||||||
|
*
|
||||||
|
* FIXME: replace that with a proper model so that we are not limited
|
||||||
|
* to only one dialog.
|
||||||
|
*/
|
||||||
|
GuiLayoutBox * layout_;
|
||||||
|
|
||||||
///
|
///
|
||||||
std::map<std::string, Inset *> open_insets_;
|
std::map<std::string, Inset *> open_insets_;
|
||||||
@ -538,7 +543,7 @@ void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
|
|||||||
// require bv_->text.
|
// require bv_->text.
|
||||||
updateBufferDependent(true);
|
updateBufferDependent(true);
|
||||||
updateToolbars();
|
updateToolbars();
|
||||||
updateLayoutChoice(false);
|
updateLayoutList();
|
||||||
updateStatusBar();
|
updateStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -787,26 +792,16 @@ void GuiView::removeWorkArea(GuiWorkArea * work_area)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiView::updateLayoutChoice(bool force)
|
void GuiView::setLayoutDialog(GuiLayoutBox * layout)
|
||||||
{
|
{
|
||||||
// Don't show any layouts without a buffer
|
d.layout_ = layout;
|
||||||
if (!buffer()) {
|
}
|
||||||
d.toolbars_->clearLayoutList();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the layout display
|
|
||||||
if (d.toolbars_->updateLayoutList(buffer()->params().getTextClassPtr(), force)) {
|
|
||||||
d.current_layout = buffer()->params().getTextClass().defaultLayoutName();
|
|
||||||
}
|
|
||||||
|
|
||||||
docstring const & layout = d.current_work_area_->bufferView().cursor().
|
void GuiView::updateLayoutList()
|
||||||
innerParagraph().layout()->name();
|
{
|
||||||
|
if (d.layout_)
|
||||||
if (layout != d.current_layout) {
|
d.layout_->updateContents(false);
|
||||||
d.toolbars_->setLayout(layout);
|
|
||||||
d.current_layout = layout;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -956,6 +951,17 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd)
|
|||||||
bool enable = true;
|
bool enable = true;
|
||||||
Buffer * buf = buffer();
|
Buffer * buf = buffer();
|
||||||
|
|
||||||
|
/* In LyX/Mac, when a dialog is open, the menus of the
|
||||||
|
application can still be accessed without giving focus to
|
||||||
|
the main window. In this case, we want to disable the menu
|
||||||
|
entries that are buffer-related.
|
||||||
|
|
||||||
|
Note that this code is not perfect, as bug 1941 attests:
|
||||||
|
http://bugzilla.lyx.org/show_bug.cgi?id=1941#c4
|
||||||
|
*/
|
||||||
|
if (cmd.origin == FuncRequest::MENU && !hasFocus())
|
||||||
|
buf = 0;
|
||||||
|
|
||||||
switch(cmd.action) {
|
switch(cmd.action) {
|
||||||
case LFUN_TOOLBAR_TOGGLE:
|
case LFUN_TOOLBAR_TOGGLE:
|
||||||
flag.setOnOff(d.toolbars_->visible(cmd.getArg(0)));
|
flag.setOnOff(d.toolbars_->visible(cmd.getArg(0)));
|
||||||
@ -1030,7 +1036,8 @@ void GuiView::dispatch(FuncRequest const & cmd)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LFUN_DROP_LAYOUTS_CHOICE:
|
case LFUN_DROP_LAYOUTS_CHOICE:
|
||||||
d.toolbars_->openLayoutList();
|
if (d.layout_)
|
||||||
|
d.layout_->showPopup();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LFUN_MENU_OPEN:
|
case LFUN_MENU_OPEN:
|
||||||
|
@ -36,6 +36,7 @@ class ToolbarInfo;
|
|||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class Dialog;
|
class Dialog;
|
||||||
|
class GuiLayoutBox;
|
||||||
class GuiToolbar;
|
class GuiToolbar;
|
||||||
class GuiWorkArea;
|
class GuiWorkArea;
|
||||||
|
|
||||||
@ -63,18 +64,24 @@ public:
|
|||||||
void close();
|
void close();
|
||||||
void setFocus();
|
void setFocus();
|
||||||
void setBusy(bool);
|
void setBusy(bool);
|
||||||
|
/// returns true if this view has the focus.
|
||||||
|
bool hasFocus() const;
|
||||||
|
|
||||||
/// add toolbar, if newline==true, add a toolbar break before the toolbar
|
/// add toolbar, if newline==true, add a toolbar break before the toolbar
|
||||||
GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
|
GuiToolbar * makeToolbar(ToolbarInfo const & tbinfo, bool newline);
|
||||||
virtual void updateStatusBar();
|
virtual void updateStatusBar();
|
||||||
virtual void message(docstring const & str);
|
virtual void message(docstring const & str);
|
||||||
virtual bool hasFocus() const;
|
|
||||||
void updateLayoutChoice(bool force);
|
/// updates the possible layouts selectable
|
||||||
|
void updateLayoutList();
|
||||||
void updateToolbars();
|
void updateToolbars();
|
||||||
QMenu * createPopupMenu();
|
QMenu * createPopupMenu();
|
||||||
FuncStatus getStatus(FuncRequest const & cmd);
|
FuncStatus getStatus(FuncRequest const & cmd);
|
||||||
void dispatch(FuncRequest const & cmd);
|
void dispatch(FuncRequest const & cmd);
|
||||||
|
|
||||||
|
///
|
||||||
|
void setLayoutDialog(GuiLayoutBox *);
|
||||||
|
|
||||||
/// \return the buffer currently shown in this window
|
/// \return the buffer currently shown in this window
|
||||||
Buffer * buffer();
|
Buffer * buffer();
|
||||||
Buffer const * buffer() const;
|
Buffer const * buffer() const;
|
||||||
|
@ -323,6 +323,8 @@ void GuiWorkArea::redraw()
|
|||||||
updateScreen();
|
updateScreen();
|
||||||
update(0, 0, viewport()->width(), viewport()->height());
|
update(0, 0, viewport()->width(), viewport()->height());
|
||||||
|
|
||||||
|
lyx_view_->updateStatusBar();
|
||||||
|
|
||||||
if (lyxerr.debugging(Debug::WORKAREA))
|
if (lyxerr.debugging(Debug::WORKAREA))
|
||||||
buffer_view_->coordCache().dump();
|
buffer_view_->coordCache().dump();
|
||||||
}
|
}
|
||||||
@ -336,6 +338,8 @@ void GuiWorkArea::processKeySym(KeySymbol const & key, KeyModifier mod)
|
|||||||
|
|
||||||
theLyXFunc().setLyXView(lyx_view_);
|
theLyXFunc().setLyXView(lyx_view_);
|
||||||
theLyXFunc().processKeySym(key, mod);
|
theLyXFunc().processKeySym(key, mod);
|
||||||
|
lyx_view_->updateLayoutList();
|
||||||
|
lyx_view_->updateToolbars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -372,7 +376,7 @@ void GuiWorkArea::dispatch(FuncRequest const & cmd0, KeyModifier mod)
|
|||||||
|
|
||||||
// Skip these when selecting
|
// Skip these when selecting
|
||||||
if (cmd.action != LFUN_MOUSE_MOTION) {
|
if (cmd.action != LFUN_MOUSE_MOTION) {
|
||||||
lyx_view_->updateLayoutChoice(false);
|
lyx_view_->updateLayoutList();
|
||||||
lyx_view_->updateToolbars();
|
lyx_view_->updateToolbars();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,7 +400,7 @@ void GuiWorkArea::resizeBufferView()
|
|||||||
// We are already inside a paint event.
|
// We are already inside a paint event.
|
||||||
lyx_view_->setBusy(true);
|
lyx_view_->setBusy(true);
|
||||||
buffer_view_->resize(viewport()->width(), viewport()->height());
|
buffer_view_->resize(viewport()->width(), viewport()->height());
|
||||||
lyx_view_->updateLayoutChoice(false);
|
lyx_view_->updateLayoutList();
|
||||||
lyx_view_->setBusy(false);
|
lyx_view_->setBusy(false);
|
||||||
need_resize_ = false;
|
need_resize_ = false;
|
||||||
}
|
}
|
||||||
@ -502,7 +506,7 @@ void GuiWorkArea::adjustViewWithScrollBar(int action)
|
|||||||
|
|
||||||
if (lyxrc.cursor_follows_scrollbar) {
|
if (lyxrc.cursor_follows_scrollbar) {
|
||||||
buffer_view_->setCursorFromScrollbar();
|
buffer_view_->setCursorFromScrollbar();
|
||||||
lyx_view_->updateLayoutChoice(false);
|
lyx_view_->updateLayoutList();
|
||||||
}
|
}
|
||||||
// Show the cursor immediately after any operation.
|
// Show the cursor immediately after any operation.
|
||||||
startBlinkingCursor();
|
startBlinkingCursor();
|
||||||
|
Loading…
Reference in New Issue
Block a user