Commit 51be09e1 authored by Kåre Särs's avatar Kåre Särs
Browse files

Build-plugin: Tweak the UI a bit

- Flash the target-filter line-edit when selectTarget is triggered
- Resize target columns: toContent, stretch, manual
- Add a tool-tip to show the full build / run commands
- Make the moved (up/down) target is visible after the move.
- Execute build & run when enter is pressed in target selection
parent aa180864
Pipeline #257595 canceled with stage
in 9 seconds
......@@ -253,10 +253,6 @@ const QString TargetModel::command(const QModelIndex &itemIndex)
if (i == 0) {
cmdIndex = childIndex.siblingAtColumn(1);
}
if (childIndex.data(Qt::CheckStateRole) == Qt::Checked) {
cmdIndex = childIndex.siblingAtColumn(1);
break;
}
}
}
return cmdIndex.data().toString();
......@@ -284,10 +280,6 @@ const QString TargetModel::cmdName(const QModelIndex &itemIndex)
if (i == 0) {
nameIndex = childIndex.siblingAtColumn(0);
}
if (childIndex.data(Qt::CheckStateRole) == Qt::Checked) {
nameIndex = childIndex.siblingAtColumn(0);
break;
}
}
}
return nameIndex.data().toString();
......@@ -333,14 +325,14 @@ QVariant TargetModel::data(const QModelIndex &index, int role) const
}
}
if (role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::CheckStateRole) {
if (role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::ToolTipRole) {
return QVariant();
}
int row = index.row();
if (index.internalId() == InvalidIndex) {
if (row < 0 || row >= m_targets.size() || role == Qt::CheckStateRole) {
if (row < 0 || row >= m_targets.size()) {
return QVariant();
}
......@@ -359,7 +351,7 @@ QVariant TargetModel::data(const QModelIndex &index, int role) const
return QVariant();
}
if (role == Qt::DisplayRole || role == Qt::EditRole) {
if (role == Qt::DisplayRole || role == Qt::EditRole || role == Qt::ToolTipRole) {
switch (index.column()) {
case 0:
return m_targets[rootIndex].commands[row].name;
......
......@@ -38,6 +38,7 @@
#include <QRegularExpressionMatch>
#include <QScrollBar>
#include <QString>
#include <QTimer>
#include <QAction>
......@@ -49,6 +50,7 @@
#include <KTextEditor/MovingInterface>
#include <KAboutData>
#include <KColorScheme>
#include <KLocalizedString>
#include <KMessageBox>
#include <KPluginFactory>
......@@ -228,7 +230,7 @@ KateBuildView::KateBuildView(KTextEditor::Plugin *plugin, KTextEditor::MainWindo
connect(m_targetsUi->addButton, &QToolButton::clicked, this, &KateBuildView::slotAddTargetClicked);
connect(m_targetsUi->buildButton, &QToolButton::clicked, this, &KateBuildView::slotBuildSelectedTarget);
connect(m_targetsUi->runButton, &QToolButton::clicked, this, &KateBuildView::slotBuildAndRunSelectedTarget);
connect(m_targetsUi, &TargetsUi::enterPressed, this, &KateBuildView::slotBuildSelectedTarget);
connect(m_targetsUi, &TargetsUi::enterPressed, this, &KateBuildView::slotBuildAndRunSelectedTarget);
m_proc.setOutputChannelMode(KProcess::SeparateChannels);
connect(&m_proc, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, &KateBuildView::slotProcExited);
......@@ -296,8 +298,6 @@ void KateBuildView::readSessionConfig(const KConfigGroup &cg)
slotAddProjectTarget();
m_targetsUi->targetsView->expandAll();
m_targetsUi->targetsView->resizeColumnToContents(0);
m_targetsUi->targetsView->resizeColumnToContents(1);
m_targetsUi->updateTargetsButtonStates();
}
......@@ -871,6 +871,16 @@ void KateBuildView::slotSelectTarget()
QPersistentModelIndex selected = m_targetsUi->targetsView->currentIndex();
m_targetsUi->targetFilterEdit->setText(QString());
m_targetsUi->targetFilterEdit->setFocus();
// Flash the target selection line-edit to show that something happened
// and where your focus went/should go
QPalette palette = m_targetsUi->targetFilterEdit->palette();
KColorScheme::adjustBackground(palette, KColorScheme::ActiveBackground);
m_targetsUi->targetFilterEdit->setPalette(palette);
QTimer::singleShot(500, this, [this]() {
m_targetsUi->targetFilterEdit->setPalette(QPalette());
});
m_targetsUi->targetsView->expandAll();
if (selected.isValid()) {
m_targetsUi->targetsView->setCurrentIndex(selected);
......@@ -992,7 +1002,6 @@ void KateBuildView::slotProcExited(int exitCode, QProcess::ExitStatus)
m_buildUi.errTreeWidget->resizeColumnToContents(1);
m_buildUi.errTreeWidget->resizeColumnToContents(2);
m_buildUi.errTreeWidget->horizontalScrollBar()->setValue(0);
// m_buildUi.errTreeWidget->setSortingEnabled(true);
m_win->showToolView(m_toolView);
}
......
......@@ -10,9 +10,9 @@
#include <QApplication>
#include <QDebug>
#include <QEvent>
#include <QHeaderView>
#include <QIcon>
#include <QKeyEvent>
#include <qnamespace.h>
TargetsUi::TargetsUi(QObject *view, QWidget *parent)
: QWidget(parent)
......@@ -64,8 +64,9 @@ TargetsUi::TargetsUi(QObject *view, QWidget *parent)
targetsView->setSelectionBehavior(QAbstractItemView::SelectItems);
targetsView->setEditTriggers(QAbstractItemView::AnyKeyPressed | QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
targetsView->expandAll();
targetsView->resizeColumnToContents(0);
targetsView->header()->setStretchLastSection(false);
targetsView->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
targetsView->header()->setSectionResizeMode(1, QHeaderView::Stretch);
QHBoxLayout *tLayout = new QHBoxLayout();
tLayout->addWidget(targetFilterEdit);
......@@ -98,16 +99,18 @@ TargetsUi::TargetsUi(QObject *view, QWidget *parent)
});
connect(moveTargetUp, &QToolButton::clicked, this, [this] {
const QModelIndex &currentIndex = proxyModel.mapToSource(targetsView->currentIndex());
const QPersistentModelIndex &currentIndex = proxyModel.mapToSource(targetsView->currentIndex());
if (currentIndex.isValid()) {
targetsModel.moveRowUp(currentIndex);
}
targetsView->scrollTo(targetsView->currentIndex());
});
connect(moveTargetDown, &QToolButton::clicked, this, [this] {
const QModelIndex &currentIndex = proxyModel.mapToSource(targetsView->currentIndex());
if (currentIndex.isValid()) {
targetsModel.moveRowDown(currentIndex);
}
targetsView->scrollTo(targetsView->currentIndex());
});
targetsView->installEventFilter(this);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment