forked from qt-creator/qt-creator
Fossil: Inline fossilcommitpanel.ui
Change-Id: I9be4ed8cd598bc6c9b1bdef00b8eb28d2f0ac0dd Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -10,7 +10,6 @@ add_qtc_plugin(Fossil
|
||||
constants.h
|
||||
fossil.qrc
|
||||
fossilclient.cpp fossilclient.h
|
||||
fossilcommitpanel.ui
|
||||
fossilcommitwidget.cpp fossilcommitwidget.h
|
||||
fossileditor.cpp fossileditor.h
|
||||
fossilplugin.cpp fossilplugin.h
|
||||
|
@@ -26,7 +26,6 @@ QtcPlugin {
|
||||
"revisioninfo.h",
|
||||
"fossil.qrc",
|
||||
"revertdialog.ui",
|
||||
"fossilcommitpanel.ui",
|
||||
]
|
||||
|
||||
Group {
|
||||
|
@@ -1,177 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Fossil::Internal::FossilCommitPanel</class>
|
||||
<widget class="QWidget" name="Fossil::Internal::FossilCommitPanel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>374</width>
|
||||
<height>270</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="infoGroup">
|
||||
<property name="title">
|
||||
<string>Current Information</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="localRootLabel">
|
||||
<property name="text">
|
||||
<string>Local root:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="localRootLineEdit">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="currentBranchLabel">
|
||||
<property name="text">
|
||||
<string>Branch:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="currentBranchLineEdit">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="currentTagsLabel">
|
||||
<property name="text">
|
||||
<string>Tags:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="currentTagsLineEdit">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="editGroup">
|
||||
<property name="title">
|
||||
<string>Commit Information</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="branchLabel">
|
||||
<property name="text">
|
||||
<string>New branch:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="branchLineEdit"/>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="invalidBranchLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>:/projectexplorer/images/compile_error.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QCheckBox" name="isPrivateCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Create a private check-in that is never synced.
|
||||
Children of private check-ins are automatically private.
|
||||
Private check-ins are not pushed to the remote repository by default.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Private</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="tagsLabel">
|
||||
<property name="text">
|
||||
<string>Tags:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="tagsLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>Tag names to apply; comma-separated.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="authorLabel">
|
||||
<property name="text">
|
||||
<string>Author:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="authorLineEdit"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>160</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
|
||||
#include "fossilcommitwidget.h"
|
||||
|
||||
#include "branchinfo.h"
|
||||
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
@@ -10,12 +11,18 @@
|
||||
|
||||
#include <utils/completingtextedit.h>
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/infolabel.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDir>
|
||||
#include <QLineEdit>
|
||||
#include <QRegularExpression>
|
||||
#include <QSyntaxHighlighter>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Fossil {
|
||||
namespace Internal {
|
||||
|
||||
@@ -31,7 +38,7 @@ static QTextCharFormat commentFormat()
|
||||
class FossilSubmitHighlighter : QSyntaxHighlighter
|
||||
{
|
||||
public:
|
||||
explicit FossilSubmitHighlighter(Utils::CompletingTextEdit *parent);
|
||||
explicit FossilSubmitHighlighter(CompletingTextEdit *parent);
|
||||
void highlightBlock(const QString &text) final;
|
||||
|
||||
private:
|
||||
@@ -39,7 +46,7 @@ private:
|
||||
const QRegularExpression m_keywordPattern;
|
||||
};
|
||||
|
||||
FossilSubmitHighlighter::FossilSubmitHighlighter(Utils::CompletingTextEdit *parent) : QSyntaxHighlighter(parent),
|
||||
FossilSubmitHighlighter::FossilSubmitHighlighter(CompletingTextEdit *parent) : QSyntaxHighlighter(parent),
|
||||
m_commentFormat(commentFormat()),
|
||||
m_keywordPattern("\\[([0-9a-f]{5,40})\\]")
|
||||
{
|
||||
@@ -65,35 +72,83 @@ void FossilSubmitHighlighter::highlightBlock(const QString &text)
|
||||
|
||||
FossilCommitWidget::FossilCommitWidget() : m_commitPanel(new QWidget)
|
||||
{
|
||||
m_commitPanelUi.setupUi(m_commitPanel);
|
||||
m_localRootLineEdit = new QLineEdit;
|
||||
m_localRootLineEdit->setFocusPolicy(Qt::NoFocus);
|
||||
m_localRootLineEdit->setReadOnly(true);
|
||||
|
||||
m_currentBranchLineEdit = new QLineEdit;
|
||||
m_currentBranchLineEdit->setFocusPolicy(Qt::NoFocus);
|
||||
m_currentBranchLineEdit->setReadOnly(true);
|
||||
|
||||
m_currentTagsLineEdit = new QLineEdit;
|
||||
m_currentTagsLineEdit->setFocusPolicy(Qt::NoFocus);
|
||||
m_currentTagsLineEdit->setReadOnly(true);
|
||||
|
||||
m_branchLineEdit = new QLineEdit;
|
||||
|
||||
m_invalidBranchLabel = new InfoLabel;
|
||||
m_invalidBranchLabel->setMinimumSize(QSize(50, 20));
|
||||
m_invalidBranchLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
m_invalidBranchLabel->setType(InfoLabel::Error);
|
||||
|
||||
m_isPrivateCheckBox = new QCheckBox(tr("Private"));
|
||||
m_isPrivateCheckBox->setToolTip(tr("Create a private check-in that is never synced.\n"
|
||||
"Children of private check-ins are automatically private.\n"
|
||||
"Private check-ins are not pushed to the remote repository by default."));
|
||||
|
||||
m_tagsLineEdit = new QLineEdit;
|
||||
m_tagsLineEdit->setToolTip(tr("Tag names to apply; comma-separated."));
|
||||
|
||||
m_authorLineEdit = new QLineEdit;
|
||||
|
||||
using namespace Layouting;
|
||||
|
||||
Column {
|
||||
Group {
|
||||
title(tr("Current Information")),
|
||||
Form {
|
||||
tr("Local root:"), m_localRootLineEdit,
|
||||
tr("Branch:"), m_currentBranchLineEdit,
|
||||
tr("Tags:"), m_currentTagsLineEdit
|
||||
}
|
||||
},
|
||||
Group {
|
||||
title(tr("Commit Information")),
|
||||
Grid {
|
||||
tr("New branch:"), m_branchLineEdit, m_invalidBranchLabel, m_isPrivateCheckBox, br,
|
||||
tr("Tags:"), m_tagsLineEdit, br,
|
||||
tr("Author:"), m_authorLineEdit, st,
|
||||
}
|
||||
}
|
||||
}.attachTo(m_commitPanel, WithoutMargins);
|
||||
|
||||
insertTopWidget(m_commitPanel);
|
||||
new FossilSubmitHighlighter(descriptionEdit());
|
||||
m_branchValidator = new QRegularExpressionValidator(QRegularExpression("[^\\n]*"), this);
|
||||
|
||||
connect(m_commitPanelUi.branchLineEdit, &QLineEdit::textChanged,
|
||||
connect(m_branchLineEdit, &QLineEdit::textChanged,
|
||||
this, &FossilCommitWidget::branchChanged);
|
||||
}
|
||||
|
||||
void FossilCommitWidget::setFields(const Utils::FilePath &repoPath, const BranchInfo &branch,
|
||||
void FossilCommitWidget::setFields(const FilePath &repoPath, const BranchInfo &branch,
|
||||
const QStringList &tags, const QString &userName)
|
||||
{
|
||||
m_commitPanelUi.localRootLineEdit->setText(repoPath.toUserOutput());
|
||||
m_commitPanelUi.currentBranchLineEdit->setText(branch.name);
|
||||
const QString tagsText = tags.join(", ");
|
||||
m_commitPanelUi.currentTagsLineEdit->setText(tagsText);
|
||||
m_commitPanelUi.authorLineEdit->setText(userName);
|
||||
m_localRootLineEdit->setText(repoPath.toUserOutput());
|
||||
m_currentBranchLineEdit->setText(branch.name);
|
||||
m_currentTagsLineEdit->setText(tags.join(", "));
|
||||
m_authorLineEdit->setText(userName);
|
||||
|
||||
branchChanged();
|
||||
}
|
||||
|
||||
QString FossilCommitWidget::newBranch() const
|
||||
{
|
||||
return m_commitPanelUi.branchLineEdit->text().trimmed();
|
||||
return m_branchLineEdit->text().trimmed();
|
||||
}
|
||||
|
||||
QStringList FossilCommitWidget::tags() const
|
||||
{
|
||||
QString tagsText = m_commitPanelUi.tagsLineEdit->text().trimmed();
|
||||
QString tagsText = m_tagsLineEdit->text().trimmed();
|
||||
if (tagsText.isEmpty())
|
||||
return {};
|
||||
|
||||
@@ -102,19 +157,19 @@ QStringList FossilCommitWidget::tags() const
|
||||
|
||||
QString FossilCommitWidget::committer() const
|
||||
{
|
||||
return m_commitPanelUi.authorLineEdit->text();
|
||||
return m_authorLineEdit->text();
|
||||
}
|
||||
|
||||
bool FossilCommitWidget::isPrivateOptionEnabled() const
|
||||
{
|
||||
return m_commitPanelUi.isPrivateCheckBox->isChecked();
|
||||
return m_isPrivateCheckBox->isChecked();
|
||||
}
|
||||
|
||||
bool FossilCommitWidget::canSubmit(QString *whyNot) const
|
||||
{
|
||||
QString message = cleanupDescription(descriptionText()).trimmed();
|
||||
|
||||
if (m_commitPanelUi.invalidBranchLabel->isVisible() || message.isEmpty()) {
|
||||
if (m_invalidBranchLabel->isVisible() || message.isEmpty()) {
|
||||
if (whyNot)
|
||||
*whyNot = tr("Message check failed.");
|
||||
return false;
|
||||
@@ -125,15 +180,15 @@ bool FossilCommitWidget::canSubmit(QString *whyNot) const
|
||||
|
||||
void FossilCommitWidget::branchChanged()
|
||||
{
|
||||
m_commitPanelUi.invalidBranchLabel->setVisible(!isValidBranch());
|
||||
m_invalidBranchLabel->setVisible(!isValidBranch());
|
||||
|
||||
updateSubmitAction();
|
||||
}
|
||||
|
||||
bool FossilCommitWidget::isValidBranch() const
|
||||
{
|
||||
int pos = m_commitPanelUi.branchLineEdit->cursorPosition();
|
||||
QString text = m_commitPanelUi.branchLineEdit->text();
|
||||
int pos = m_branchLineEdit->cursorPosition();
|
||||
QString text = m_branchLineEdit->text();
|
||||
return m_branchValidator->validate(text, pos) == QValidator::Acceptable;
|
||||
}
|
||||
|
||||
|
@@ -3,15 +3,19 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui_fossilcommitpanel.h"
|
||||
|
||||
#include <vcsbase/submiteditorwidget.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QValidator;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
namespace Utils {
|
||||
class FilePath;
|
||||
class InfoLabel;
|
||||
}
|
||||
|
||||
namespace Fossil {
|
||||
namespace Internal {
|
||||
@@ -22,7 +26,7 @@ class BranchInfo;
|
||||
Some extra fields have been added to the standard SubmitEditorWidget,
|
||||
to help to conform to the commit style that is used by both git and Fossil*/
|
||||
|
||||
class FossilCommitWidget : public VcsBase::SubmitEditorWidget
|
||||
class FossilCommitWidget final : public VcsBase::SubmitEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -37,18 +41,23 @@ public:
|
||||
QString committer() const;
|
||||
bool isPrivateOptionEnabled() const;
|
||||
|
||||
protected:
|
||||
bool canSubmit(QString *whyNot = nullptr) const;
|
||||
|
||||
private slots:
|
||||
void branchChanged();
|
||||
|
||||
private:
|
||||
bool canSubmit(QString *whyNot = nullptr) const final;
|
||||
|
||||
void branchChanged();
|
||||
bool isValidBranch() const;
|
||||
|
||||
QWidget *m_commitPanel;
|
||||
Ui::FossilCommitPanel m_commitPanelUi;
|
||||
QValidator *m_branchValidator;
|
||||
|
||||
QLineEdit *m_localRootLineEdit;
|
||||
QLineEdit *m_currentBranchLineEdit;
|
||||
QLineEdit *m_currentTagsLineEdit;
|
||||
QLineEdit *m_branchLineEdit;
|
||||
Utils::InfoLabel *m_invalidBranchLabel;
|
||||
QCheckBox *m_isPrivateCheckBox;
|
||||
QLineEdit *m_tagsLineEdit;
|
||||
QLineEdit *m_authorLineEdit;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user