]> git.lyx.org Git - features.git/blobdiff - src/frontends/qt4/GuiToolbar.cpp
Improve the local layout feature by better handling of unknown textclass, unknown...
[features.git] / src / frontends / qt4 / GuiToolbar.cpp
index 8cec1043521ed102412e672b7bbb0a5d372c2235..119ebba01ee14536cac5a82395773f7b9b2ab009 100644 (file)
@@ -493,6 +493,8 @@ void GuiLayoutBox::setIconSize(QSize size)
        bool small = size.height() < 20;
        setAttribute(Qt::WA_MacSmallSize, small);
        setAttribute(Qt::WA_MacNormalSize, !small);
+#else
+       (void)size; // suppress warning
 #endif
 }
 
@@ -504,7 +506,8 @@ void GuiLayoutBox::set(docstring const & layout)
        if (!text_class_)
                return;
 
-       QString const & name = toqstr((*text_class_)[layout].name());
+       Layout const & lay = (*text_class_)[layout];
+       QString const & name = toqstr(lay.name() + (lay.isUnknown() ? " (unknown)" : ""));
        if (name == currentText())
                return;
 
@@ -605,7 +608,7 @@ void GuiLayoutBox::updateContents(bool reset)
 
        for (; lit != len; ++lit) {
                docstring const & name = lit->name();
-               bool const useEmpty = inset_->forceEmptyLayout() || inset_->useEmptyLayout();
+               bool const useEmpty = inset_->forcePlainLayout() || inset_->usePlainLayout();
                // if this inset requires the empty layout, we skip the default
                // layout
                if (name == text_class_->defaultLayoutName() && inset_ && useEmpty)
@@ -613,7 +616,8 @@ void GuiLayoutBox::updateContents(bool reset)
                // if it doesn't require the empty layout, we skip it
                if (name == text_class_->emptyLayoutName() && inset_ && !useEmpty)
                        continue;
-               addItemSort(name, lit->category(), lyxrc.sort_layouts, lyxrc.group_layouts);
+               addItemSort(name + (lit->isUnknown() ? " (unknown)" : ""),
+                       lit->category(), lyxrc.sort_layouts, lyxrc.group_layouts);
        }
 
        set(owner_.view()->cursor().innerParagraph().layout().name());
@@ -631,8 +635,8 @@ void GuiLayoutBox::selected(int index)
 {
        // get selection
        QModelIndex mindex = filterModel_->mapToSource(filterModel_->index(index, 1));
-       docstring const layoutName = 
-               qstring_to_ucs4(model_->itemFromIndex(mindex)->text());
+       docstring const layoutName = rtrim(
+               qstring_to_ucs4(model_->itemFromIndex(mindex)->text()), " (unknown)");
 
        owner_.setFocus();
 
@@ -651,7 +655,7 @@ void GuiLayoutBox::selected(int index)
                resetFilter();
                return;
        }
-       lyxerr << "ERROR (layoutSelected): layout not found!" << endl;
+       LYXERR0("ERROR (layoutSelected): layout not found!");
 }
 
 
@@ -668,12 +672,15 @@ GuiToolbar::GuiToolbar(ToolbarInfo const & tbinfo, GuiView & owner)
          allowauto_(false), owner_(owner), layout_(0), command_buffer_(0),
          tbinfo_(tbinfo), filled_(false)
 {
+       setIconSize(owner.iconSize());
+       connect(&owner, SIGNAL(iconSizeChanged(QSize)), this,
+               SLOT(setIconSize(QSize)));
+
        // Toolbar dragging is allowed.
        setMovable(true);
        // This is used by QMainWindow::restoreState for proper main window state
        // restauration.
        setObjectName(toqstr(tbinfo.name));
-
        restoreSession();
 }
 
@@ -748,7 +755,7 @@ public:
 
                ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
                if (!tbinfo) {
-                       lyxerr << "Unknown toolbar " << tbitem_.name_ << endl;
+                       LYXERR0("Unknown toolbar " << tbitem_.name_);
                        return;
                }
                IconPalette * panel = new IconPalette(this);
@@ -802,7 +809,7 @@ public:
                connect(bar_, SIGNAL(updated()), m, SLOT(updateParent()));
                ToolbarInfo const * tbinfo = guiApp->toolbars().info(tbitem_.name_);
                if (!tbinfo) {
-                       lyxerr << "Unknown toolbar " << tbitem_.name_ << endl;
+                       LYXERR0("Unknown toolbar " << tbitem_.name_);
                        return;
                }
                ToolbarInfo::item_iterator it = tbinfo->items.begin();