]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt/PanelStack.cpp
Amend 4cd568d31266
[lyx.git] / src / frontends / qt / PanelStack.cpp
index c61c8e02442f531fb3eae7ac2c0abde51a46f900..9b6cb639c8678db63a6993288c1389189f56707e 100644 (file)
 #include "PanelStack.h"
 
 #include "GuiApplication.h"
+#include "GuiFontMetrics.h"
 #include "qt_helpers.h"
 
+#include "FancyLineEdit.h"
+
 #include "support/debug.h"
 #include "support/lassert.h"
 
 #include <QAbstractButton>
 #include <QApplication>
 #include <QComboBox>
-#include <QFontMetrics>
 #include <QGroupBox>
 #include <QHideEvent>
 #include <QHash>
@@ -59,7 +61,7 @@ PanelStack::PanelStack(QWidget * parent)
        list_->setRootIsDecorated(false);
        list_->setColumnCount(1);
        list_->header()->hide();
-       setSectionResizeMode(list_->header(), QHeaderView::ResizeToContents);
+       list_->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
        list_->header()->setStretchLastSection(false);
        list_->setMinimumSize(list_->viewport()->size());
 
@@ -71,11 +73,7 @@ PanelStack::PanelStack(QWidget * parent)
 
        // Configure the search box
        search_->setPlaceholderText(qt_("Search"));
-       search_->setButtonPixmap(FancyLineEdit::Right,
-                                getPixmap("images/", "editclear", "svgz,png"));
-       search_->setButtonVisible(FancyLineEdit::Right, true);
-       search_->setButtonToolTip(FancyLineEdit::Right, qt_("Clear text"));
-       search_->setAutoHideButton(FancyLineEdit::Right, true);
+       search_->setClearButton(true);
        connect(search_, SIGNAL(rightButtonClicked()),
                this, SLOT(resetSearch()));
        connect(search_, SIGNAL(textEdited(QString)),
@@ -97,7 +95,7 @@ PanelStack::PanelStack(QWidget * parent)
 
 void PanelStack::addCategory(QString const & name, QString const & parent)
 {
-       QTreeWidgetItem * item = 0;
+       QTreeWidgetItem * item = nullptr;
 
        LYXERR(Debug::GUI, "addCategory n= " << name << "   parent= ");
 
@@ -118,7 +116,7 @@ void PanelStack::addCategory(QString const & name, QString const & parent)
 
        panel_map_[name] = item;
 
-       QFontMetrics fm(list_->font());
+       GuiFontMetrics fm(list_->font());
 
        // calculate the real size the current item needs in the listview
        int itemsize = fm.width(qt_(name)) + 10 + list_->indentation() * depth;
@@ -148,6 +146,22 @@ void PanelStack::showPanel(QString const & name, bool show)
 }
 
 
+void PanelStack::markPanelValid(QString const & name, bool valid)
+{
+       QTreeWidgetItem * item = panel_map_.value(name, 0);
+       LASSERT(item, return);
+
+       if (valid) {
+               item->setIcon(0, QIcon());
+               item->setToolTip(0, QString());
+       } else {
+               QIcon warn(getPixmap("images/", "emblem-shellescape", "svgz,png"));
+               item->setIcon(0, warn);
+               item->setToolTip(0, qt_("This section contains invalid input. Please fix!"));
+       }
+}
+
+
 void PanelStack::setCurrentPanel(QString const & name)
 {
        QTreeWidgetItem * item = panel_map_.value(name, 0);
@@ -212,7 +226,7 @@ static void setTreeItemStatus(QTreeWidgetItem * tree_item, bool enabled)
        // Change the color from black to gray or viceversa
        QPalette::ColorGroup new_color =
                enabled ? QPalette::Active : QPalette::Disabled;
-       tree_item->setTextColor(0, QApplication::palette().color(new_color,
+       tree_item->setForeground(0, QApplication::palette().color(new_color,
                                                                 QPalette::Text));
 }
 
@@ -220,7 +234,7 @@ void PanelStack::hideEvent(QHideEvent * event)
 {
        QWidget::hideEvent(event);
 
-       // Programatically hidden (not simply minimized by the user)
+       // Programmatically hidden (not simply minimized by the user)
        if (!event->spontaneous()) {
                resetSearch();
        }