From e53dacbf904343d6c14ff32694a73822e6837e34 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Thu, 8 Oct 2026 14:48:08 +0200 Subject: [PATCH] sam panel: fix tiny top-left controls (toolview already has a layout) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kate's createToolView returns a KateMDI::ToolView that already installs its own layout. The code created a second QVBoxLayout on it, which Qt silently rejects, leaving SamPanel unmanaged — pinned top-left at its size hint. Add to the existing layout when present, else create one. Also harden SamPanel: give the program editor, Run button, and output log minimum heights and explicit Expanding size policies so they never collapse. --- src/plugin/ollieplugin.cpp | 11 +++++++++-- src/plugin/sampanel.cpp | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/plugin/ollieplugin.cpp b/src/plugin/ollieplugin.cpp index d65176c..f1050c5 100644 --- a/src/plugin/ollieplugin.cpp +++ b/src/plugin/ollieplugin.cpp @@ -305,8 +305,15 @@ OllieView::OllieView(OlliePlugin *plugin, KTextEditor::MainWindow *mainWindow) QIcon::fromTheme(QStringLiteral("edit-find-replace")), i18n("Sam")); if (m_samToolView) { m_samPanel = new SamPanel(m_samToolView); - auto *tvLayout = new QVBoxLayout(m_samToolView); - tvLayout->setContentsMargins(0, 0, 0, 0); + // The tool view returned by Kate (KateMDI::ToolView) already installs + // its own layout; creating a second one here is silently rejected by Qt + // and leaves SamPanel un-managed (tiny, pinned top-left). Add to the + // existing layout when there is one, otherwise create it ourselves. + QLayout *tvLayout = m_samToolView->layout(); + if (!tvLayout) { + tvLayout = new QVBoxLayout(m_samToolView); + tvLayout->setContentsMargins(0, 0, 0, 0); + } tvLayout->addWidget(m_samPanel); connect(m_samPanel, &SamPanel::runRequested, this, &OllieView::runSamProgram); } diff --git a/src/plugin/sampanel.cpp b/src/plugin/sampanel.cpp index 6aeb581..e710bed 100644 --- a/src/plugin/sampanel.cpp +++ b/src/plugin/sampanel.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -69,9 +70,13 @@ SamPanel::SamPanel(QWidget *parent) }); m_editor->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); m_editor->setPlaceholderText(i18n("Enter sam command(s)…")); + m_editor->setMinimumHeight(72); // several lines, never collapsed + m_editor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layout->addWidget(m_editor, /*stretch*/ 2); m_runButton = new QPushButton(i18n("Run"), this); + m_runButton->setMinimumHeight(28); + m_runButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); connect(m_runButton, &QPushButton::clicked, this, [this]() { Q_EMIT runRequested(program()); }); layout->addWidget(m_runButton); @@ -79,6 +84,8 @@ SamPanel::SamPanel(QWidget *parent) m_output = new QTextEdit(this); m_output->setReadOnly(true); m_output->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); + m_output->setMinimumHeight(80); + m_output->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layout->addWidget(m_output, /*stretch*/ 1); }