diff --git a/sources/elementspanel.cpp b/sources/elementspanel.cpp index 8fd1e075a..3ed1c4ff1 100644 --- a/sources/elementspanel.cpp +++ b/sources/elementspanel.cpp @@ -602,6 +602,8 @@ void ElementsPanel::reload(bool reload_collections) { // the first time, expand the first level of collections if (first_reload_) first_reload_ = false; + + emit(loadingFinished()); } /** diff --git a/sources/elementspanel.h b/sources/elementspanel.h index e24c44e05..8b102ee05 100644 --- a/sources/elementspanel.h +++ b/sources/elementspanel.h @@ -72,6 +72,7 @@ class ElementsPanel : public GenericPanel { void readingAboutToBegin(); void readingFinished(); void loadingProgressed(int, int); + void loadingFinished(); public slots: void slot_doubleClick(QTreeWidgetItem *, int); diff --git a/sources/elementspanelwidget.cpp b/sources/elementspanelwidget.cpp index dfd3c42c6..09b3cd124 100644 --- a/sources/elementspanelwidget.cpp +++ b/sources/elementspanelwidget.cpp @@ -141,6 +141,7 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) { connect(elements_panel, SIGNAL(loadingProgressed(int, int)), this, SLOT(updateProgressBar(int, int))); connect(elements_panel, SIGNAL(readingAboutToBegin()), this, SLOT(collectionsRead())); connect(elements_panel, SIGNAL(readingFinished()), this, SLOT(collectionsReadFinished())); + connect(elements_panel, SIGNAL(loadingFinished()), this, SLOT(loadingFinished())); // initialise la barre d'outils toolbar = new QToolBar(this); @@ -167,6 +168,9 @@ ElementsPanelWidget::ElementsPanelWidget(QWidget *parent) : QWidget(parent) { vlayout -> addWidget(progress_bar_); vlayout -> setStretchFactor(elements_panel, 75000); setLayout(vlayout); + + // by default, the reload button is disabled + reload -> setEnabled(false); } /** @@ -190,12 +194,16 @@ void ElementsPanelWidget::clearFilterTextField() { */ void ElementsPanelWidget::reloadAndFilter() { // recharge tous les elements + reload -> setEnabled(false); elements_panel -> reload(true); + // the reload button was enabled again through loadingFinished() + reload -> setEnabled(false); // reapplique le filtre if (!filter_textfield -> text().isEmpty()) { elements_panel -> filter(filter_textfield -> text()); } + reload -> setEnabled(true); } /** @@ -617,12 +625,20 @@ void ElementsPanelWidget::updateProgressBar(int current, int maximum) { if (!current) { progress_bar_ -> setFormat(tr("Chargement : %p%", "Visual rendering of elements/categories files - %p is the progress percentage")); progress_bar_ -> setVisible(true); - } else if (current == provided_maximum) { - QTimer::singleShot(500, progress_bar_, SLOT(hide())); } progress_bar_ -> setValue(current); } +/** + Reflects the fact the whole panel content was loaded by hiding the progress + bar and enabling again the reload button. +*/ +void ElementsPanelWidget::loadingFinished() { + QTimer::singleShot(500, progress_bar_, SLOT(hide())); + reload -> setEnabled(true); + +} + void ElementsPanelWidget::filterEdited(const QString &next_text) { if (previous_filter_.isEmpty() && next_text.length() == 1) { // the field is not empty anymore: begin filtering diff --git a/sources/elementspanelwidget.h b/sources/elementspanelwidget.h index 3155a3e19..d37fb0772 100644 --- a/sources/elementspanelwidget.h +++ b/sources/elementspanelwidget.h @@ -101,6 +101,7 @@ class ElementsPanelWidget : public QWidget { void collectionsRead(); void collectionsReadFinished(); void updateProgressBar(int, int); + void loadingFinished(); void filterEdited(const QString &); private: diff --git a/sources/genericpanel.cpp b/sources/genericpanel.cpp index 47e5b8737..18dd082b4 100644 --- a/sources/genericpanel.cpp +++ b/sources/genericpanel.cpp @@ -910,6 +910,7 @@ QTreeWidgetItem *GenericPanel::updateItem(QTreeWidgetItem *qtwi, PanelOptions op Q_UNUSED(qtwi); Q_UNUSED(options); Q_UNUSED(freshly_created); + QApplication::processEvents(); return(qtwi); }