From: Abdelrazak Younes Date: Sun, 10 Sep 2006 11:03:21 +0000 (+0000) Subject: * LyXView.h: X-Git-Tag: 1.6.10~12605 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c9c47c646451917b6a3e3dc77792dd02f0bf4082;p=features.git * LyXView.h: - makeToolbar(): new pure virtual method * qt4/GuiView.h: - makeToolbar(): new method transferred from QLToolbar * qt4/QLToolbar: derive from QToolBar instead of owning a QToolBar member. * Toolbars.h: remove make_toolbar() prototype (use LyXView::makeToolbar instead). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14964 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index 104e0ed771..726175f249 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -13,6 +13,8 @@ #ifndef LYXVIEW_H #define LYXVIEW_H +#include "frontends/Toolbars.h" + #include #include #include @@ -20,7 +22,6 @@ #include class Buffer; -class Toolbars; class InsetBase; class Intl; class Menubar; @@ -73,6 +74,8 @@ public: /// show busy cursor virtual void busy(bool) const = 0; + virtual Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb) = 0; + //@{ generic accessor functions /** return the current buffer view diff --git a/src/frontends/Toolbars.C b/src/frontends/Toolbars.C index 7ca15c0afc..3d1bf5e1f0 100644 --- a/src/frontends/Toolbars.C +++ b/src/frontends/Toolbars.C @@ -116,7 +116,7 @@ void Toolbars::clearLayoutList() void Toolbars::add(ToolbarBackend::Toolbar const & tbb) { - ToolbarPtr tb_ptr = make_toolbar(tbb, owner_); + ToolbarPtr tb_ptr = owner_.makeToolbar(tbb); toolbars_[tbb.name] = tb_ptr; if (tbb.flags & ToolbarBackend::ON) diff --git a/src/frontends/Toolbars.h b/src/frontends/Toolbars.h index 83cd71807f..8dc8bc7794 100644 --- a/src/frontends/Toolbars.h +++ b/src/frontends/Toolbars.h @@ -131,8 +131,4 @@ private: /// Set the layout in the kernel when an entry has been selected void layoutSelected(LyXView & lv, std::string const & name); -/** Each GUI frontend should provide its own version of this. - */ -Toolbars::ToolbarPtr make_toolbar(ToolbarBackend::Toolbar const &, LyXView &); - #endif // NOT TOOLBARS_H diff --git a/src/frontends/gtk/GView.C b/src/frontends/gtk/GView.C index d00842b3b5..83fe0fc557 100644 --- a/src/frontends/gtk/GView.C +++ b/src/frontends/gtk/GView.C @@ -20,6 +20,7 @@ #include "GView.h" #include "GMenubar.h" +#include "GToolbar.h" #include "GMiniBuffer.h" #include "BufferView.h" @@ -219,5 +220,10 @@ bool GView::hasFocus() const } +Toolbars::ToolbarPtr GView::makeToolbar(ToolbarBackend::Toolbar const & tbb) +{ + return make_toolbar(tbb, *this); +} + } // namespace frontend } // namespace lyx diff --git a/src/frontends/gtk/GView.h b/src/frontends/gtk/GView.h index ea05f84a1c..e222049036 100644 --- a/src/frontends/gtk/GView.h +++ b/src/frontends/gtk/GView.h @@ -50,6 +50,10 @@ public: /// show busy cursor virtual void busy(bool) const; + + /// + Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb); + /// clear any temporary message and replace with current status virtual void clearMessage(); diff --git a/src/frontends/qt3/QtView.C b/src/frontends/qt3/QtView.C index e9b57f8d68..f8bc508b1c 100644 --- a/src/frontends/qt3/QtView.C +++ b/src/frontends/qt3/QtView.C @@ -29,6 +29,7 @@ #include "QtView.h" #include "QLMenubar.h" +#include "QLToolbar.h" #include "qfont_loader.h" #include "QCommandBuffer.h" #include "qt_helpers.h" @@ -222,6 +223,12 @@ void QtView::busy(bool yes) const QApplication::restoreOverrideCursor(); } + +Toolbars::ToolbarPtr QtView::makeToolbar(ToolbarBackend::Toolbar const & tbb) +{ + return make_toolbar(tbb, *this); +} + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt3/QtView.h b/src/frontends/qt3/QtView.h index f79ee1ae4a..ca0dc1e97d 100644 --- a/src/frontends/qt3/QtView.h +++ b/src/frontends/qt3/QtView.h @@ -49,6 +49,9 @@ public: /// show busy cursor virtual void busy(bool) const; + /// + Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb); + /// display a status message virtual void message(std::string const & str); diff --git a/src/frontends/qt4/GuiView.C b/src/frontends/qt4/GuiView.C index 749a6b58bc..8eba2f2545 100644 --- a/src/frontends/qt4/GuiView.C +++ b/src/frontends/qt4/GuiView.C @@ -24,7 +24,6 @@ #include "debug.h" -#include "frontends/Toolbars.h" #include "frontends/WorkArea.h" #include "support/filetools.h" #include "support/convert.h" @@ -36,6 +35,7 @@ #include "GuiView.h" #include "QLMenubar.h" +#include "QLToolbar.h" #include "FontLoader.h" #include "QCommandBuffer.h" #include "qt_helpers.h" @@ -245,6 +245,32 @@ void GuiView::busy(bool yes) const QApplication::restoreOverrideCursor(); } + +Toolbars::ToolbarPtr GuiView::makeToolbar(ToolbarBackend::Toolbar const & tbb) +{ + QLToolbar * Tb = new QLToolbar(tbb, *this); + static QLToolbar * lastTb = 0; + + if (tbb.flags & ToolbarBackend::TOP) { + addToolBar(Qt::TopToolBarArea, Tb); + addToolBarBreak(Qt::TopToolBarArea); + } + if (tbb.flags & ToolbarBackend::BOTTOM) { + addToolBar(Qt::BottomToolBarArea, Tb); + if (lastTb) + insertToolBarBreak(lastTb); + lastTb = Tb; + } + if (tbb.flags & ToolbarBackend::LEFT) { + addToolBar(Qt::LeftToolBarArea, Tb); + } + if (tbb.flags & ToolbarBackend::RIGHT) { + addToolBar(Qt::RightToolBarArea, Tb); + } + + return Toolbars::ToolbarPtr(Tb); +} + } // namespace frontend } // namespace lyx diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 3c53ed0c5d..e72ad8bde7 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -60,6 +60,8 @@ public: /// show busy cursor virtual void busy(bool) const; + Toolbars::ToolbarPtr makeToolbar(ToolbarBackend::Toolbar const & tbb); + /// display a status message virtual void message(std::string const & str); diff --git a/src/frontends/qt4/QLToolbar.C b/src/frontends/qt4/QLToolbar.C index 2d82643a22..8941be22fa 100644 --- a/src/frontends/qt4/QLToolbar.C +++ b/src/frontends/qt4/QLToolbar.C @@ -47,34 +47,6 @@ LyXTextClass const & getTextClass(LyXView const & lv) return lv.buffer()->params().getLyXTextClass(); } -/* -/// \todo Remove Qt::Dock getPosition(ToolbarBackend::Flags const & flags) if not needed anymore -Qt::Dock getPosition(ToolbarBackend::Flags const & flags) -{ - if (flags & ToolbarBackend::TOP) - return Qt::DockTop; - if (flags & ToolbarBackend::BOTTOM) - return Qt::DockBottom; - if (flags & ToolbarBackend::LEFT) - return Qt::DockLeft; - if (flags & ToolbarBackend::RIGHT) - return Qt::DockRight; - return Qt::DockTop; -} -*/ - -Qt::ToolBarArea getToolBarPosition(ToolbarBackend::Flags const & flags) -{ - if (flags & ToolbarBackend::TOP) - return Qt::TopToolBarArea; - if (flags & ToolbarBackend::BOTTOM) - return Qt::BottomToolBarArea; - if (flags & ToolbarBackend::LEFT) - return Qt::LeftToolBarArea; - if (flags & ToolbarBackend::RIGHT) - return Qt::RightToolBarArea; - return Qt::TopToolBarArea; -} } // namespace anon @@ -173,48 +145,17 @@ void QLayoutBox::selected(const QString & str) layoutSelected(owner_, sel); } -} // namespace frontend -} // namespace lyx - -Toolbars::ToolbarPtr make_toolbar(ToolbarBackend::Toolbar const & tbb, - LyXView & owner) -{ - using lyx::frontend::QLToolbar; - return Toolbars::ToolbarPtr(new QLToolbar(tbb, owner)); -} - -namespace lyx { -namespace frontend { -QLToolbar::QLToolbar(ToolbarBackend::Toolbar const & tbb, LyXView & owner) - : owner_(dynamic_cast(owner)), - toolbar_(new QToolBar(qt_(tbb.gui_name), (QWidget*) &owner_)) //, getPosition(tbb.flags))) +QLToolbar::QLToolbar(ToolbarBackend::Toolbar const & tbb, GuiView & owner) + : owner_(owner), + QToolBar(qt_(tbb.gui_name), &owner) { - /// \toto Move \a addToolBar call into QView because, in Qt4, - /// the ToolBars placement is the duty of QMainWindow (aka QView) - Qt::ToolBarArea tba = getToolBarPosition(tbb.flags); - switch(tba) { - case Qt::TopToolBarArea: - owner_.addToolBar(tba, toolbar_); - owner_.addToolBarBreak(tba); - break; -// case Qt::BottomToolBarArea: - //bottomToolbarVector.push_back(toolbar_); -// owner_.addToolBar(tba, toolbar_); -// //if owner_.insertToolBarBreak(toolbar_); - break; - default: - owner_.addToolBar(Qt::TopToolBarArea, toolbar_); - owner_.addToolBarBreak(Qt::TopToolBarArea); - break; - } - // give visual separation between adjacent toolbars - toolbar_->addSeparator(); + addSeparator(); // allowing the toolbars to tear off is too easily done, // and we don't save their orientation anyway. Disable the handle. - toolbar_->setMovable(false); + setMovable(false); ToolbarBackend::item_iterator it = tbb.items.begin(); ToolbarBackend::item_iterator end = tbb.items.end(); @@ -227,15 +168,15 @@ void QLToolbar::add(FuncRequest const & func, string const & tooltip) { switch (func.action) { case ToolbarBackend::SEPARATOR: - toolbar_->addSeparator(); + addSeparator(); break; case ToolbarBackend::LAYOUTS: - layout_.reset(new QLayoutBox(toolbar_, owner_)); + layout_.reset(new QLayoutBox(this, owner_)); break; case ToolbarBackend::MINIBUFFER: - owner_.addCommandBuffer(toolbar_); + owner_.addCommandBuffer(this); /// \todo find a Qt4 equivalent to setHorizontalStretchable(true); - //toolbar_->setHorizontalStretchable(true); + //setHorizontalStretchable(true); break; case LFUN_TABULAR_INSERT: { QToolButton * tb = new QToolButton; @@ -247,7 +188,7 @@ void QLToolbar::add(FuncRequest const & func, string const & tooltip) connect(tb, SIGNAL(toggled(bool)), iv, SLOT(show(bool))); connect(iv, SIGNAL(visible(bool)), tb, SLOT(setChecked(bool))); connect(this, SIGNAL(updated()), iv, SLOT(updateParent())); - toolbar_->addWidget(tb); + addWidget(tb); break; } default: { @@ -255,7 +196,7 @@ void QLToolbar::add(FuncRequest const & func, string const & tooltip) break; Action * action = new Action(owner_, toolbarbackend.getIcon(func), "", func, tooltip); - toolbar_->addAction(action); + addAction(action); ActionVector.push_back(action); break; } @@ -265,13 +206,13 @@ void QLToolbar::add(FuncRequest const & func, string const & tooltip) void QLToolbar::hide(bool) { - toolbar_->hide(); + QToolBar::hide(); } void QLToolbar::show(bool) { - toolbar_->show(); + QToolBar::show(); } diff --git a/src/frontends/qt4/QLToolbar.h b/src/frontends/qt4/QLToolbar.h index 3557ff07d5..da09a9b5a4 100644 --- a/src/frontends/qt4/QLToolbar.h +++ b/src/frontends/qt4/QLToolbar.h @@ -19,11 +19,10 @@ #include "frontends/Toolbars.h" #include -#include +#include #include class QComboBox; -class QToolBar; namespace lyx { namespace frontend { @@ -58,10 +57,10 @@ private: }; -class QLToolbar : public QObject, public Toolbar { +class QLToolbar : public QToolBar, public Toolbar { Q_OBJECT public: - QLToolbar(ToolbarBackend::Toolbar const &, LyXView &); + QLToolbar(ToolbarBackend::Toolbar const &, GuiView &); //~QLToolbar(); @@ -71,6 +70,8 @@ public: void update(); LayoutBox * layout() const { return layout_.get(); } + + Q_SIGNALS: void updated(); @@ -78,11 +79,8 @@ private: std::vector ActionVector; GuiView & owner_; - QToolBar * toolbar_; boost::scoped_ptr layout_; - - Qt::ToolBarArea tba; }; } // namespace frontend