diff --git a/src/plugin/ollieplugin.cpp b/src/plugin/ollieplugin.cpp index 52db469..7af5bbf 100644 --- a/src/plugin/ollieplugin.cpp +++ b/src/plugin/ollieplugin.cpp @@ -408,21 +408,17 @@ QList OllieView::collectActions() const return entries; } -void OllieView::positionPalette(PaletteWidget *palette, bool fullWidth) +void OllieView::positionPalette(PaletteWidget *palette) { QWidget *w = m_mainWindow->window(); if (!w) { return; } + // Span the window width (minus a small margin), anchored near the top, so + // long paths / symbol labels fit without truncation. const int margin = 12; - const int y = w->height() / 6; - if (fullWidth) { - palette->resize(w->width() - 2 * margin, 320); - palette->move(w->mapToGlobal(QPoint(margin, y))); - } else { - const QSize sz = palette->size(); - palette->move(w->mapToGlobal(QPoint((w->width() - sz.width()) / 2, y))); - } + palette->resize(w->width() - 2 * margin, 320); + palette->move(w->mapToGlobal(QPoint(margin, w->height() / 6))); } void OllieView::showCommandPalette() @@ -482,8 +478,8 @@ void OllieView::showCommandPalette() m_palette->setItems(items); - // The command palette keeps its compact centered width. - positionPalette(m_palette, /*fullWidth=*/false); + // Span the full window width, anchored near the top. + positionPalette(m_palette); m_palette->activate(); } @@ -612,7 +608,7 @@ void OllieView::showFileSwitcher() m_filePalette->setItems({loading}); } - positionPalette(m_filePalette, /*fullWidth=*/true); + positionPalette(m_filePalette); m_filePalette->activate(); // Kick off (or serve from cache) the index; filesReady repopulates. @@ -707,7 +703,7 @@ void OllieView::showSymbolSwitcher() m_symbolPalette->setItems({loading}); } - positionPalette(m_symbolPalette, /*fullWidth=*/true); + positionPalette(m_symbolPalette); m_symbolPalette->activate(); m_indexer.requestSymbols(m_symbolSwitcherRoot); diff --git a/src/plugin/ollieplugin.h b/src/plugin/ollieplugin.h index 9d31486..9076ea7 100644 --- a/src/plugin/ollieplugin.h +++ b/src/plugin/ollieplugin.h @@ -86,10 +86,9 @@ private: QList buildFileItems(const QString &root, const QStringList &files) const; QList buildSymbolItems(const QString &root, const QList &symbols) const; - // Size and place a palette near the top of the active window. When - // \a fullWidth, it spans the window width (minus a small margin); otherwise - // it keeps its own width and is horizontally centered. - void positionPalette(PaletteWidget *palette, bool fullWidth); + // Size and place a palette: it spans the active window's width (minus a + // small margin), anchored near the top. + void positionPalette(PaletteWidget *palette); // One harvested, runnable action with the provenance needed to build a // unique id and to disambiguate labels shared by several commands. struct ActionEntry {