Transfer command buffer handling to QLToolbar.

* Toolbar::focusCommandBuffer(): new pure virtual method.
* Toolbars::display(): now return the address of the found toolbar.
* GuiView: get rid of command_buffer_, transferred to QLToolbar.
* QCommandBuffer: replace focus_command with setFocusProxy on edit_;



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19767 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2007-08-24 07:13:07 +00:00
parent 91f8cbe204
commit ebff6bd6fb
8 changed files with 31 additions and 41 deletions

View File

@ -144,7 +144,7 @@ void Toolbars::init()
}
void Toolbars::display(string const & name, bool show)
Toolbar * Toolbars::display(string const & name, bool show)
{
ToolbarBackend::Toolbars::iterator cit = toolbarbackend.begin();
ToolbarBackend::Toolbars::iterator end = toolbarbackend.end();
@ -160,13 +160,13 @@ void Toolbars::display(string const & name, bool show)
else
TurnOnFlag(OFF);
cit->flags = static_cast<lyx::ToolbarInfo::Flags>(flags);
displayToolbar(*cit, show);
return;
return displayToolbar(*cit, show);
}
}
LYXERR(Debug::GUI) << "Toolbar::display: no toolbar named "
<< name << endl;
return 0;
}
@ -329,7 +329,7 @@ void Toolbars::add(ToolbarInfo const & tbinfo, bool newline)
}
void Toolbars::displayToolbar(ToolbarInfo const & tbinfo,
Toolbar * Toolbars::displayToolbar(ToolbarInfo const & tbinfo,
bool show_it)
{
ToolbarsMap::iterator it = toolbars_.find(tbinfo.name);
@ -339,6 +339,8 @@ void Toolbars::displayToolbar(ToolbarInfo const & tbinfo,
it->second->show(true);
else
it->second->hide(true);
return it->second.get();
}

View File

@ -79,6 +79,9 @@ public:
virtual void update() = 0;
/// Accessor to the layout combox, if any.
virtual LayoutBox * layout() const = 0;
/// Set the focus on the command buffer, if any.
virtual void focusCommandBuffer() = 0;
};
@ -91,7 +94,7 @@ public:
void init();
/// Show/hide the named toolbar.
void display(std::string const & name, bool show);
Toolbar * display(std::string const & name, bool show);
/// get toolbar info
ToolbarInfo * getToolbarInfo(std::string const & name);
@ -130,7 +133,7 @@ private:
/// Add a new toolbar. if newline==true, start from a new line
void add(ToolbarInfo const & tbinfo, bool newline);
/// Show or hide a toolbar.
void displayToolbar(ToolbarInfo const & tbinfo, bool show);
Toolbar * displayToolbar(ToolbarInfo const & tbinfo, bool show);
/// Update the state of the icons
void update();

View File

@ -20,7 +20,6 @@
#include "QKeySymbol.h"
#include "QLMenubar.h"
#include "QLToolbar.h"
#include "QCommandBuffer.h"
#include "qt_helpers.h"
#include "frontends/Application.h"
@ -216,7 +215,7 @@ unsigned int GuiView::GuiViewPrivate::lastIconSize = 0;
GuiView::GuiView(int id)
: QMainWindow(), LyXView(id), commandbuffer_(0), quitting_by_menu_(false),
: QMainWindow(), LyXView(id), quitting_by_menu_(false),
d(*new GuiViewPrivate)
{
// Qt bug? signal lastWindowClosed does not work
@ -571,13 +570,6 @@ void GuiView::setWindowTitle(docstring const & t, docstring const & it)
}
void GuiView::addCommandBuffer(QToolBar * toolbar)
{
commandbuffer_ = new QCommandBuffer(this);
toolbar->addWidget(commandbuffer_);
}
void GuiView::message(docstring const & str)
{
statusBar()->showMessage(toqstr(str));
@ -934,11 +926,9 @@ void GuiView::removeWorkArea(WorkArea * work_area)
void GuiView::showMiniBuffer(bool visible)
{
if (!commandbuffer_)
return;
toolbars_->display("minibuffer", visible);
commandbuffer_->focus_command();
Toolbar * t = toolbars_->display("minibuffer", visible);
if (t)
t->focusCommandBuffer();
}

View File

@ -32,8 +32,6 @@ class QToolBar;
namespace lyx {
namespace frontend {
class QCommandBuffer;
QWidget* mainWindow();
/**
@ -77,9 +75,6 @@ public:
/// show - display the top-level window
void show();
/// add the command buffer
void addCommandBuffer(QToolBar * toolbar);
/// menu item has been selected
void activated(FuncRequest const &);
@ -142,9 +137,6 @@ private:
QTimer statusbar_timer_;
/// command buffer
QCommandBuffer * commandbuffer_;
/// are we quitting by the menu?
bool quitting_by_menu_;

View File

@ -110,13 +110,7 @@ QCommandBuffer::QCommandBuffer(GuiView * view)
layout->setMargin(0);
top->addLayout(layout);
top->setMargin(0);
}
void QCommandBuffer::focus_command()
{
edit_->setFocus();
setFocusProxy(edit_);
}

View File

@ -29,8 +29,6 @@ class QCommandBuffer : public QWidget {
public:
QCommandBuffer(GuiView * view);
/// focus the edit widget
void focus_command();
public Q_SLOTS:
/// cancel command compose
void cancel();

View File

@ -24,6 +24,7 @@
#include "IconPalette.h"
#include "GuiView.h"
#include "QCommandBuffer.h"
#include "QLToolbar.h"
#include "LyXAction.h"
#include "Action.h"
@ -159,7 +160,7 @@ void QLayoutBox::selected(const QString & str)
QLToolbar::QLToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
: QToolBar(qt_(tbinfo.gui_name), &owner), owner_(owner)
: QToolBar(qt_(tbinfo.gui_name), &owner), command_buffer_(0), owner_(owner)
{
// give visual separation between adjacent toolbars
addSeparator();
@ -174,6 +175,13 @@ QLToolbar::QLToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
}
void QLToolbar::focusCommandBuffer()
{
if (command_buffer_)
command_buffer_->setFocus();
}
void QLToolbar::add(ToolbarItem const & item)
{
switch (item.type_) {
@ -184,7 +192,8 @@ void QLToolbar::add(ToolbarItem const & item)
layout_.reset(new QLayoutBox(this, owner_));
break;
case ToolbarItem::MINIBUFFER:
owner_.addCommandBuffer(this);
command_buffer_ = new QCommandBuffer(&owner_);
addWidget(command_buffer_);
/// \todo find a Qt4 equivalent to setHorizontalStretchable(true);
//setHorizontalStretchable(true);
break;

View File

@ -31,6 +31,7 @@ namespace lyx {
class FuncRequest;
namespace frontend {
class QCommandBuffer;
class QLayoutBox;
class GuiView;
class Action;
@ -75,13 +76,14 @@ public:
void saveInfo(ToolbarSection::ToolbarInfo & info);
void update();
LayoutBox * layout() const { return layout_.get(); }
///
void focusCommandBuffer();
Q_SIGNALS:
void updated();
private:
QCommandBuffer * command_buffer_;
std::vector<Action *> ActionVector;
GuiView & owner_;