Delay IconPalette construction.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22610 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-01-17 08:42:28 +00:00
parent 139802b193
commit ff588411af

View File

@ -396,7 +396,6 @@ class PaletteButton : public QToolButton
private: private:
GuiToolbar * bar_; GuiToolbar * bar_;
ToolbarItem const & tbitem_; ToolbarItem const & tbitem_;
IconPalette * panel_;
bool initialized_; bool initialized_;
public: public:
PaletteButton(GuiToolbar * bar, ToolbarItem const & item) PaletteButton(GuiToolbar * bar, ToolbarItem const & item)
@ -408,11 +407,7 @@ public:
setText(label); setText(label);
connect(bar_, SIGNAL(iconSizeChanged(QSize)), connect(bar_, SIGNAL(iconSizeChanged(QSize)),
this, SLOT(setIconSize(QSize))); this, SLOT(setIconSize(QSize)));
panel_ = new IconPalette(this);
panel_->setWindowTitle(label);
setCheckable(true); setCheckable(true);
connect(this, SIGNAL(clicked(bool)), panel_, SLOT(setVisible(bool)));
connect(panel_, SIGNAL(visible(bool)), this, SLOT(setChecked(bool)));
ToolbarInfo const * tbinfo = ToolbarInfo const * tbinfo =
toolbarbackend.getDefinedToolbarInfo(tbitem_.name_); toolbarbackend.getDefinedToolbarInfo(tbitem_.name_);
if (tbinfo) if (tbinfo)
@ -435,11 +430,16 @@ public:
lyxerr << "Unknown toolbar " << tbitem_.name_ << endl; lyxerr << "Unknown toolbar " << tbitem_.name_ << endl;
return; return;
} }
IconPalette * panel = new IconPalette(this);
QString label = qt_(to_ascii(tbitem_.label_));
panel->setWindowTitle(label);
connect(this, SIGNAL(clicked(bool)), panel, SLOT(setVisible(bool)));
connect(panel, SIGNAL(visible(bool)), this, SLOT(setChecked(bool)));
ToolbarInfo::item_iterator it = tbinfo->items.begin(); ToolbarInfo::item_iterator it = tbinfo->items.begin();
ToolbarInfo::item_iterator const end = tbinfo->items.end(); ToolbarInfo::item_iterator const end = tbinfo->items.end();
for (; it != end; ++it) for (; it != end; ++it)
if (!getStatus(it->func_).unknown()) if (!getStatus(it->func_).unknown())
panel_->addButton(bar_->addItem(*it)); panel->addButton(bar_->addItem(*it));
QToolButton::mousePressEvent(e); QToolButton::mousePressEvent(e);
} }
@ -450,7 +450,6 @@ class MenuButton : public QToolButton
private: private:
GuiToolbar * bar_; GuiToolbar * bar_;
ToolbarItem const & tbitem_; ToolbarItem const & tbitem_;
IconPalette * panel_;
bool initialized_; bool initialized_;
public: public:
MenuButton(GuiToolbar * bar, ToolbarItem const & item) MenuButton(GuiToolbar * bar, ToolbarItem const & item)