sam panel: fix tiny top-left controls (toolview already has a layout)
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.
This commit is contained in:
parent
6341b1ad01
commit
e53dacbf90
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <QLabel>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QSizePolicy>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue