#include "KeyMap.h"
#include "LyX.h"
#include "LyXRC.h"
+#include "Session.h"
#include "support/debug.h"
#include "support/gettext.h"
GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
: QToolBar(toqstr(tbinfo.gui_name), &owner), visibility_(0),
- owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false)
+ owner_(owner), command_buffer_(0), tbinfo_(tbinfo), filled_(false),
+ restored_(false)
{
setIconSize(owner.iconSize());
connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
}
+void GuiToolbar::setVisible(bool visible)
+{
+ // This is a hack to find out which toolbars have been restored by
+ // MainWindow::restoreState and which toolbars should be initialized
+ // by us (i.e., new toolbars)
+ restored_ = true;
+ QToolBar::setVisible(visible);
+}
+
+
+bool GuiToolbar::isRestored() const
+{
+ return restored_;
+}
+
+
void GuiToolbar::fill()
{
if (filled_)
QString const name = toqstr(tbitem_.name_);
QStringList imagedirs;
imagedirs << "images/math/" << "images/";
- for (int i = 0; i < imagedirs.size(); ++i) {
+ for (int i = 0; i < imagedirs.size(); ++i) {
QString imagedir = imagedirs.at(i);
- FileName const fname = imageLibFileSearch(imagedir, name, "png");
+ FileName const fname = imageLibFileSearch(imagedir, name, "svgz,png",
+ theGuiApp()->imageSearchMode());
if (fname.exists()) {
- setIcon(QIcon(getPixmap(imagedir, name, "png")));
+ setIcon(QIcon(getPixmap(imagedir, name, "svgz,png")));
break;
}
}
}
-void GuiToolbar::update(bool in_math, bool in_table, bool in_review,
- bool in_mathmacrotemplate, bool in_ipa)
+void GuiToolbar::update(int context)
{
if (visibility_ & Toolbars::AUTO) {
- bool show_it = (in_math && (visibility_ & Toolbars::MATH))
- || (in_table && (visibility_ & Toolbars::TABLE))
- || (in_review && (visibility_ & Toolbars::REVIEW))
- || (in_mathmacrotemplate && (visibility_ & Toolbars::MATHMACROTEMPLATE))
- || (in_ipa && (visibility_ & Toolbars::IPA));
- setVisible(show_it);
+ bool const was_visible = isVisible();
+ setVisible(visibility_ & context & Toolbars::ALLOWAUTO);
+ if (isVisible() && !was_visible && commandBuffer())
+ commandBuffer()->setFocus();
}
// update visible toolbars only