diff options
| author | Tem PQD <[email protected]> | 2025-09-21 20:48:22 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2025-09-26 09:12:14 +0000 |
| commit | 7eb1696a32891ce4f1f0e44c590a7fdb7c55fecd (patch) | |
| tree | 3645e3998d10bcd63ebc7174e719804038de9174 | |
| parent | b9a3b749ead4bac7e2294f7bc2124f4fae274319 (diff) | |
placespanel: Fix default width by moving things from showEvent to constructor
Move instantiation, setModel, and some connections to constructor and remove showEvent.
This was being done in an erroneous lazy order which led to the places panel's sizeHint not being called properly.
Also removes the double loading workaround in setUrl, which is no longer needed either.
BUG: 449070
| -rw-r--r-- | src/panels/places/placespanel.cpp | 43 | ||||
| -rw-r--r-- | src/panels/places/placespanel.h | 2 |
2 files changed, 16 insertions, 29 deletions
diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index cb3f3183b..12d7619b8 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -67,15 +67,28 @@ PlacesPanel::PlacesPanel(QWidget *parent) settings->setIconSize(iconSize); settings->save(); }); + + readSettings(); + + // Set the model here so that it's loaded in time for the sizeHint to properly apply (setting it upon showEvent is too late) + auto *placesModel = DolphinPlacesModelSingleton::instance().placesModel(); + setModel(placesModel); + + connect(placesModel, &KFilePlacesModel::errorMessage, this, &PlacesPanel::errorMessage); + connect(placesModel, &KFilePlacesModel::teardownDone, this, &PlacesPanel::slotTearDownDone); + + connect(placesModel, &QAbstractItemModel::rowsInserted, this, &PlacesPanel::slotRowsInserted); + connect(placesModel, &QAbstractItemModel::rowsAboutToBeRemoved, this, &PlacesPanel::slotRowsAboutToBeRemoved); + + for (int i = 0; i < model()->rowCount(); ++i) { + connectDeviceSignals(model()->index(i, 0, QModelIndex())); + } } PlacesPanel::~PlacesPanel() = default; void PlacesPanel::setUrl(const QUrl &url) { - // KFilePlacesView::setUrl no-ops when no model is set but we only set it in showEvent() - // Remember the URL and set it in showEvent - m_url = url; KFilePlacesView::setUrl(url); } @@ -111,30 +124,6 @@ void PlacesPanel::readSettings() setIconSize(QSize(iconSize, iconSize)); } -void PlacesPanel::showEvent(QShowEvent *event) -{ - if (!event->spontaneous() && !model()) { - readSettings(); - - auto *placesModel = DolphinPlacesModelSingleton::instance().placesModel(); - setModel(placesModel); - - connect(placesModel, &KFilePlacesModel::errorMessage, this, &PlacesPanel::errorMessage); - connect(placesModel, &KFilePlacesModel::teardownDone, this, &PlacesPanel::slotTearDownDone); - - connect(placesModel, &QAbstractItemModel::rowsInserted, this, &PlacesPanel::slotRowsInserted); - connect(placesModel, &QAbstractItemModel::rowsAboutToBeRemoved, this, &PlacesPanel::slotRowsAboutToBeRemoved); - - for (int i = 0; i < model()->rowCount(); ++i) { - connectDeviceSignals(model()->index(i, 0, QModelIndex())); - } - - setUrl(m_url); - } - - KFilePlacesView::showEvent(event); -} - static bool isInternalDrag(const QMimeData *mimeData) { const auto formats = mimeData->formats(); diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index cbd5fc224..dd5cb6d9e 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -54,7 +54,6 @@ Q_SIGNALS: void openInSplitViewRequested(const QUrl &url); protected: - void showEvent(QShowEvent *event) override; void dragMoveEvent(QDragMoveEvent *event) override; private Q_SLOTS: @@ -70,7 +69,6 @@ private Q_SLOTS: private: void connectDeviceSignals(const QModelIndex &idx); - QUrl m_url; // only used for initial setUrl QList<QAction *> m_customContextMenuActions; QPersistentModelIndex m_indexToTearDown; |
