From 6da227925ae3405497583e36f65206b13799b47a Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 23 Sep 2022 13:52:03 +0200 Subject: [PATCH] Bazaar: Inline bazaarcommitpanel.ui Change-Id: I5b72560b283584075b30e4bb313a5c143f5c2548 Reviewed-by: Alessandro Portale Reviewed-by: --- src/plugins/bazaar/CMakeLists.txt | 1 - src/plugins/bazaar/bazaar.qbs | 1 - src/plugins/bazaar/bazaarcommitpanel.ui | 114 ---------------------- src/plugins/bazaar/bazaarcommitwidget.cpp | 76 ++++++++++++--- src/plugins/bazaar/bazaarcommitwidget.h | 15 +-- 5 files changed, 68 insertions(+), 139 deletions(-) delete mode 100644 src/plugins/bazaar/bazaarcommitpanel.ui diff --git a/src/plugins/bazaar/CMakeLists.txt b/src/plugins/bazaar/CMakeLists.txt index faf27eef25d..97d9c0153f8 100644 --- a/src/plugins/bazaar/CMakeLists.txt +++ b/src/plugins/bazaar/CMakeLists.txt @@ -3,7 +3,6 @@ add_qtc_plugin(Bazaar SOURCES annotationhighlighter.cpp annotationhighlighter.h bazaarclient.cpp bazaarclient.h - bazaarcommitpanel.ui bazaarcommitwidget.cpp bazaarcommitwidget.h bazaareditor.cpp bazaareditor.h bazaarplugin.cpp bazaarplugin.h diff --git a/src/plugins/bazaar/bazaar.qbs b/src/plugins/bazaar/bazaar.qbs index 78eb4a326ae..1b24a20cd79 100644 --- a/src/plugins/bazaar/bazaar.qbs +++ b/src/plugins/bazaar/bazaar.qbs @@ -15,7 +15,6 @@ QtcPlugin { "annotationhighlighter.h", "bazaarclient.cpp", "bazaarclient.h", - "bazaarcommitpanel.ui", "bazaarcommitwidget.cpp", "bazaarcommitwidget.h", "bazaareditor.cpp", diff --git a/src/plugins/bazaar/bazaarcommitpanel.ui b/src/plugins/bazaar/bazaarcommitpanel.ui deleted file mode 100644 index b0bb2d94101..00000000000 --- a/src/plugins/bazaar/bazaarcommitpanel.ui +++ /dev/null @@ -1,114 +0,0 @@ - - - Bazaar::Internal::BazaarCommitPanel - - - - 0 - 0 - 374 - 229 - - - - - 0 - - - - - General Information - - - - - - Branch: - - - - - - - true - - - - - - - Performs a local commit in a bound branch. -Local commits are not pushed to the master branch until a normal commit is performed. - - - Local commit - - - - - - - - - - Commit Information - - - - - - QFormLayout::ExpandingFieldsGrow - - - - - Author: - - - - - - - - - - Email: - - - - - - - - - - Fixed bugs: - - - - - - - - - - - - Qt::Horizontal - - - - 161 - 20 - - - - - - - - - - - - diff --git a/src/plugins/bazaar/bazaarcommitwidget.cpp b/src/plugins/bazaar/bazaarcommitwidget.cpp index 99789bd252b..f5c8fde6ef3 100644 --- a/src/plugins/bazaar/bazaarcommitwidget.cpp +++ b/src/plugins/bazaar/bazaarcommitwidget.cpp @@ -6,15 +6,19 @@ #include #include + #include +#include #include +#include +#include +#include +#include +#include #include #include -#include -#include - //see the git submit widget for details of the syntax Highlighter //TODO Check to see when the Highlighter has been moved to a base class and use that instead @@ -28,6 +32,52 @@ static QTextCharFormat commentFormat() return TextEditor::TextEditorSettings::fontSettings().toTextCharFormat(TextEditor::C_COMMENT); } +class BazaarCommitPanel : public QWidget +{ + Q_DECLARE_TR_FUNCTIONS(Bazaar::Internal::BazaarCommitPanel) + +public: + BazaarCommitPanel() + { + branchLineEdit = new QLineEdit; + branchLineEdit->setReadOnly(true); + + isLocalCheckBox = new QCheckBox(tr("Local commit")); + isLocalCheckBox->setToolTip(tr("Performs a local commit in a bound branch.\n" + "Local commits are not pushed to the master " + "branch until a normal commit is performed.")); + + authorLineEdit = new QLineEdit; + emailLineEdit = new QLineEdit; + fixedBugsLineEdit = new QLineEdit; + + using namespace Utils::Layouting; + Column { + Group { + title(tr("General Information")), + Form { + tr("Branch:"), branchLineEdit, br, + empty, isLocalCheckBox + } + }, + Group { + title(tr("Commit Information")), + Form { + tr("Author:"), authorLineEdit, br, + tr("Email:"), emailLineEdit, br, + tr("Fixed bugs:"), fixedBugsLineEdit + }, + } + }.attachTo(this, WithoutMargins); + } + + QLineEdit *branchLineEdit; + QCheckBox *isLocalCheckBox; + QLineEdit *authorLineEdit; + QLineEdit *emailLineEdit; + QLineEdit *fixedBugsLineEdit; +}; + // Highlighter for Bazaar submit messages. Make the first line bold, indicates // comments as such (retrieving the format from the text editor) and marks up // keywords (words in front of a colon as in 'Task: '). @@ -89,9 +139,9 @@ void BazaarSubmitHighlighter::highlightBlock(const QString &text) } -BazaarCommitWidget::BazaarCommitWidget() : m_bazaarCommitPanel(new QWidget) +BazaarCommitWidget::BazaarCommitWidget() + : m_bazaarCommitPanel(new BazaarCommitPanel) { - m_bazaarCommitPanelUi.setupUi(m_bazaarCommitPanel); insertTopWidget(m_bazaarCommitPanel); new BazaarSubmitHighlighter(descriptionEdit()); } @@ -99,16 +149,16 @@ BazaarCommitWidget::BazaarCommitWidget() : m_bazaarCommitPanel(new QWidget) void BazaarCommitWidget::setFields(const BranchInfo &branch, const QString &userName, const QString &email) { - m_bazaarCommitPanelUi.branchLineEdit->setText(branch.branchLocation); - m_bazaarCommitPanelUi.isLocalCheckBox->setVisible(branch.isBoundToBranch); - m_bazaarCommitPanelUi.authorLineEdit->setText(userName); - m_bazaarCommitPanelUi.emailLineEdit->setText(email); + m_bazaarCommitPanel->branchLineEdit->setText(branch.branchLocation); + m_bazaarCommitPanel->isLocalCheckBox->setVisible(branch.isBoundToBranch); + m_bazaarCommitPanel->authorLineEdit->setText(userName); + m_bazaarCommitPanel->emailLineEdit->setText(email); } QString BazaarCommitWidget::committer() const { - const QString author = m_bazaarCommitPanelUi.authorLineEdit->text(); - const QString email = m_bazaarCommitPanelUi.emailLineEdit->text(); + const QString author = m_bazaarCommitPanel->authorLineEdit->text(); + const QString email = m_bazaarCommitPanel->emailLineEdit->text(); if (author.isEmpty()) return QString(); @@ -123,12 +173,12 @@ QString BazaarCommitWidget::committer() const QStringList BazaarCommitWidget::fixedBugs() const { - return m_bazaarCommitPanelUi.fixedBugsLineEdit->text().split(QRegularExpression("\\s+")); + return m_bazaarCommitPanel->fixedBugsLineEdit->text().split(QRegularExpression("\\s+")); } bool BazaarCommitWidget::isLocalOptionEnabled() const { - return m_bazaarCommitPanelUi.isLocalCheckBox->isChecked(); + return m_bazaarCommitPanel->isLocalCheckBox->isChecked(); } } // namespace Internal diff --git a/src/plugins/bazaar/bazaarcommitwidget.h b/src/plugins/bazaar/bazaarcommitwidget.h index ba55f5303e2..e9bf5eba779 100644 --- a/src/plugins/bazaar/bazaarcommitwidget.h +++ b/src/plugins/bazaar/bazaarcommitwidget.h @@ -3,14 +3,12 @@ #pragma once -#include "ui_bazaarcommitpanel.h" - #include -namespace Bazaar { -namespace Internal { +namespace Bazaar::Internal { class BranchInfo; +class BazaarCommitPanel; /*submit editor widget based on git SubmitEditor Some extra fields have been added to the standard SubmitEditorWidget, @@ -21,17 +19,14 @@ class BazaarCommitWidget : public VcsBase::SubmitEditorWidget public: BazaarCommitWidget(); - void setFields(const BranchInfo &branch, - const QString &userName, const QString &email); + void setFields(const BranchInfo &branch, const QString &userName, const QString &email); QString committer() const; QStringList fixedBugs() const; bool isLocalOptionEnabled() const; private: - QWidget *m_bazaarCommitPanel; - Ui::BazaarCommitPanel m_bazaarCommitPanelUi; + BazaarCommitPanel *m_bazaarCommitPanel; }; -} // namespace Internal -} // namespace Bazaar +} // Bazaar::Insteral