forked from qt-creator/qt-creator
Add auto-scroll feature for results pane
Change-Id: Iff209384c2bf30b3ce2b9241ce1c719a44592e65 Reviewed-by: David Schulz <david.schulz@theqtcompany.com> Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMenu>
|
||||
#include <QScrollBar>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
@@ -46,7 +47,8 @@ namespace Internal {
|
||||
TestResultsPane::TestResultsPane(QObject *parent) :
|
||||
Core::IOutputPane(parent),
|
||||
m_context(new Core::IContext(this)),
|
||||
m_wasVisibleBefore(false)
|
||||
m_wasVisibleBefore(false),
|
||||
m_autoScroll(false)
|
||||
{
|
||||
m_outputWidget = new QWidget;
|
||||
QVBoxLayout *outputLayout = new QVBoxLayout;
|
||||
@@ -144,6 +146,9 @@ TestResultsPane::~TestResultsPane()
|
||||
|
||||
void TestResultsPane::addTestResult(const TestResult &result)
|
||||
{
|
||||
const QScrollBar *scrollBar = m_treeView->verticalScrollBar();
|
||||
m_atEnd = scrollBar ? scrollBar->value() == scrollBar->maximum() : true;
|
||||
|
||||
m_model->addTestResult(result);
|
||||
if (!m_treeView->isVisible())
|
||||
popup(Core::IOutputPane::NoModeSwitch);
|
||||
@@ -181,6 +186,9 @@ void TestResultsPane::clearContents()
|
||||
m_filterModel->clearTestResults();
|
||||
navigateStateChanged();
|
||||
m_summaryWidget->setVisible(false);
|
||||
m_autoScroll = AutotestPlugin::instance()->settings()->autoScroll;
|
||||
connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||
this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
void TestResultsPane::visibilityChanged(bool visible)
|
||||
@@ -381,6 +389,14 @@ void TestResultsPane::onTestRunFinished()
|
||||
updateSummaryLabel();
|
||||
m_summaryWidget->setVisible(true);
|
||||
m_model->removeCurrentTestMessage();
|
||||
disconnect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged,
|
||||
this, &TestResultsPane::onScrollBarRangeChanged);
|
||||
}
|
||||
|
||||
void TestResultsPane::onScrollBarRangeChanged(int, int max)
|
||||
{
|
||||
if (m_autoScroll && m_atEnd)
|
||||
m_treeView->verticalScrollBar()->setValue(max);
|
||||
}
|
||||
|
||||
void TestResultsPane::onTestTreeModelChanged()
|
||||
|
@@ -88,6 +88,7 @@ private:
|
||||
void createToolButtons();
|
||||
void onTestRunStarted();
|
||||
void onTestRunFinished();
|
||||
void onScrollBarRangeChanged(int, int max);
|
||||
void onTestTreeModelChanged();
|
||||
|
||||
QWidget *m_outputWidget;
|
||||
@@ -103,6 +104,8 @@ private:
|
||||
QToolButton *m_filterButton;
|
||||
QMenu *m_filterMenu;
|
||||
bool m_wasVisibleBefore;
|
||||
bool m_autoScroll;
|
||||
bool m_atEnd;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -30,11 +30,12 @@ static const char metricsKey[] = "Metrics";
|
||||
static const char omitInternalKey[] = "OmitInternal";
|
||||
static const char omitRunConfigWarnKey[] = "OmitRCWarnings";
|
||||
static const char limitResultOutputKey[] = "LimitResultOutput";
|
||||
static const char autoScrollKey[] = "AutoScrollResults";
|
||||
static const int defaultTimeout = 60000;
|
||||
|
||||
TestSettings::TestSettings()
|
||||
: timeout(defaultTimeout), metrics(Walltime), omitInternalMssg(true), omitRunConfigWarn(false),
|
||||
limitResultOutput(true)
|
||||
limitResultOutput(true), autoScroll(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,6 +47,7 @@ void TestSettings::toSettings(QSettings *s) const
|
||||
s->setValue(QLatin1String(omitInternalKey), omitInternalMssg);
|
||||
s->setValue(QLatin1String(omitRunConfigWarnKey), omitRunConfigWarn);
|
||||
s->setValue(QLatin1String(limitResultOutputKey), limitResultOutput);
|
||||
s->setValue(QLatin1String(autoScrollKey), autoScroll);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
@@ -75,6 +77,7 @@ void TestSettings::fromSettings(const QSettings *s)
|
||||
omitInternalMssg = s->value(root + QLatin1String(omitInternalKey), true).toBool();
|
||||
omitRunConfigWarn = s->value(root + QLatin1String(omitRunConfigWarnKey), false).toBool();
|
||||
limitResultOutput = s->value(root + QLatin1String(limitResultOutputKey), true).toBool();
|
||||
autoScroll = s->value(root + QLatin1String(autoScrollKey), true).toBool();
|
||||
}
|
||||
|
||||
bool TestSettings::equals(const TestSettings &rhs) const
|
||||
@@ -82,7 +85,8 @@ bool TestSettings::equals(const TestSettings &rhs) const
|
||||
return timeout == rhs.timeout && metrics == rhs.metrics
|
||||
&& omitInternalMssg == rhs.omitInternalMssg
|
||||
&& omitRunConfigWarn == rhs.omitRunConfigWarn
|
||||
&& limitResultOutput == rhs.limitResultOutput;
|
||||
&& limitResultOutput == rhs.limitResultOutput
|
||||
&& autoScroll == rhs.autoScroll;
|
||||
}
|
||||
|
||||
QString TestSettings::metricsTypeToOption(const MetricsType type)
|
||||
|
@@ -50,6 +50,7 @@ struct TestSettings
|
||||
bool omitInternalMssg;
|
||||
bool omitRunConfigWarn;
|
||||
bool limitResultOutput;
|
||||
bool autoScroll;
|
||||
};
|
||||
|
||||
inline bool operator==(const TestSettings &s1, const TestSettings &s2) { return s1.equals(s2); }
|
||||
|
@@ -42,6 +42,7 @@ void TestSettingsWidget::setSettings(const TestSettings &settings)
|
||||
m_ui.omitInternalMsgCB->setChecked(settings.omitInternalMssg);
|
||||
m_ui.omitRunConfigWarnCB->setChecked(settings.omitRunConfigWarn);
|
||||
m_ui.limitResultOutputCB->setChecked(settings.limitResultOutput);
|
||||
m_ui.autoScrollCB->setChecked(settings.autoScroll);
|
||||
|
||||
switch (settings.metrics) {
|
||||
case MetricsType::Walltime:
|
||||
@@ -71,6 +72,7 @@ TestSettings TestSettingsWidget::settings() const
|
||||
result.omitInternalMssg = m_ui.omitInternalMsgCB->isChecked();
|
||||
result.omitRunConfigWarn = m_ui.omitRunConfigWarnCB->isChecked();
|
||||
result.limitResultOutput = m_ui.limitResultOutputCB->isChecked();
|
||||
result.autoScroll = m_ui.autoScrollCB->isChecked();
|
||||
|
||||
if (m_ui.walltimeRB->isChecked())
|
||||
result.metrics = MetricsType::Walltime;
|
||||
|
@@ -6,29 +6,16 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>463</width>
|
||||
<height>338</height>
|
||||
<width>407</width>
|
||||
<height>228</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>10</y>
|
||||
<width>435</width>
|
||||
<height>307</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="toolTip">
|
||||
@@ -58,68 +45,8 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="omitInternalMsgCB">
|
||||
<property name="toolTip">
|
||||
<string>Hides internal messages by default. You can still enable them by using the test results filter.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Omit internal messages</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="omitRunConfigWarnCB">
|
||||
<property name="toolTip">
|
||||
<string>Hides warnings related to a guessed run configuration.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Omit run configuration warnings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="limitResultOutputCB">
|
||||
<property name="toolTip">
|
||||
<string>Limit result output to 100000 characters.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Limit result output</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@@ -134,37 +61,15 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Benchmark Metrics</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="walltimeRB">
|
||||
<property name="sizePolicy">
|
||||
@@ -255,25 +160,8 @@
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
@@ -288,7 +176,85 @@
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="omitInternalMsgCB">
|
||||
<property name="toolTip">
|
||||
<string>Hides internal messages by default. You can still enable them by using the test results filter.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Omit internal messages</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="omitRunConfigWarnCB">
|
||||
<property name="toolTip">
|
||||
<string>Hides warnings related to a guessed run configuration.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Omit run configuration warnings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="limitResultOutputCB">
|
||||
<property name="toolTip">
|
||||
<string>Limit result output to 100000 characters.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Limit result output</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoScrollCB">
|
||||
<property name="toolTip">
|
||||
<string>Automatically scroll down when new items are added and scrollbar is at bottom.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Automatically scroll results</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Reference in New Issue
Block a user