Palette: make the M-x command palette full-width too
All three palettes now span the window width. positionPalette drops its fullWidth parameter (the centered path had no remaining callers) and always full-widths.
This commit is contained in:
parent
e791e403d8
commit
d9df62e7ed
|
|
@ -408,21 +408,17 @@ QList<OllieView::ActionEntry> 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->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);
|
||||
|
|
|
|||
|
|
@ -86,10 +86,9 @@ private:
|
|||
QList<PaletteItem> buildFileItems(const QString &root, const QStringList &files) const;
|
||||
QList<PaletteItem> buildSymbolItems(const QString &root, const QList<Symbol> &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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue