diff --git a/src/plugins/git/CMakeLists.txt b/src/plugins/git/CMakeLists.txt index 6f23999babf..691af23eb26 100644 --- a/src/plugins/git/CMakeLists.txt +++ b/src/plugins/git/CMakeLists.txt @@ -10,7 +10,7 @@ add_qtc_plugin(Git commitdata.cpp commitdata.h gerrit/authenticationdialog.cpp gerrit/authenticationdialog.h gerrit/branchcombobox.cpp gerrit/branchcombobox.h - gerrit/gerritdialog.cpp gerrit/gerritdialog.h gerrit/gerritdialog.ui + gerrit/gerritdialog.cpp gerrit/gerritdialog.h gerrit/gerritmodel.cpp gerrit/gerritmodel.h gerrit/gerritoptionspage.cpp gerrit/gerritoptionspage.h gerrit/gerritparameters.cpp gerrit/gerritparameters.h diff --git a/src/plugins/git/gerrit/gerritdialog.cpp b/src/plugins/git/gerrit/gerritdialog.cpp index 9ffe8bd5ba3..04021017900 100644 --- a/src/plugins/git/gerrit/gerritdialog.cpp +++ b/src/plugins/git/gerrit/gerritdialog.cpp @@ -24,16 +24,19 @@ ****************************************************************************/ #include "gerritdialog.h" -#include "ui_gerritdialog.h" + #include "gerritmodel.h" #include "gerritparameters.h" +#include "gerritremotechooser.h" #include "../gitplugin.h" -#include "../gitclient.h" #include +#include #include +#include +#include #include #include #include @@ -46,6 +49,15 @@ #include #include +#include +#include +#include +#include +#include +#include +#include +#include + using namespace Utils; namespace Gerrit { @@ -61,56 +73,119 @@ GerritDialog::GerritDialog(const QSharedPointer &p, , m_parameters(p) , m_server(s) , m_filterModel(new QSortFilterProxyModel(this)) - , m_ui(new Ui::GerritDialog) , m_model(new GerritModel(p, this)) , m_queryModel(new QStringListModel(this)) { - m_ui->setupUi(this); - m_ui->remoteComboBox->setParameters(m_parameters); - m_ui->remoteComboBox->setFallbackEnabled(true); + setWindowTitle(tr("Gerrit")); + resize(950, 706); + + m_repositoryLabel = new QLabel(this); + m_repositoryLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + + m_remoteComboBox = new GerritRemoteChooser(this); + m_remoteComboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); + m_remoteComboBox->setMinimumSize(QSize(40, 0)); + + auto changesGroup = new QGroupBox(tr("Changes")); + changesGroup->setMinimumSize(QSize(0, 350)); + + m_queryLineEdit = new FancyLineEdit(changesGroup); + m_queryLineEdit->setMinimumSize(QSize(400, 0)); + m_queryLineEdit->setPlaceholderText(tr("Change #, SHA-1, tr:id, owner:email or reviewer:email")); + m_queryLineEdit->setSpecialCompleter(new QCompleter(m_queryModel, this)); + m_queryLineEdit->setValidationFunction( + [this](FancyLineEdit *, QString *) { return m_model->state() != GerritModel::Error; }); + + auto filterLineEdit = new FancyLineEdit(changesGroup); + filterLineEdit->setMinimumSize(QSize(300, 0)); + filterLineEdit->setFiltering(true); + + m_treeView = new TreeView(changesGroup); + m_treeView->setMinimumSize(QSize(600, 0)); + m_treeView->setRootIsDecorated(false); + m_treeView->setUniformRowHeights(true); + m_treeView->setSortingEnabled(true); + + auto detailsGroup = new QGroupBox(tr("Details")); + detailsGroup->setMinimumSize(QSize(0, 175)); + + m_detailsBrowser = new QTextBrowser(detailsGroup); + m_detailsBrowser->setOpenExternalLinks(true); + + m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); + + auto queryLabel = new QLabel(tr("&Query:"), changesGroup); + queryLabel->setBuddy(m_queryLineEdit); + + m_remoteComboBox->setParameters(m_parameters); + m_remoteComboBox->setFallbackEnabled(true); m_queryModel->setStringList(m_parameters->savedQueries); - auto completer = new QCompleter(this); - completer->setModel(m_queryModel); - m_ui->queryLineEdit->setSpecialCompleter(completer); - m_ui->queryLineEdit->setValidationFunction([this](Utils::FancyLineEdit *, QString *) { - return m_model->state() != GerritModel::Error; - }); - m_ui->filterLineEdit->setFiltering(true); - connect(m_ui->filterLineEdit, &Utils::FancyLineEdit::filterChanged, - m_filterModel, &QSortFilterProxyModel::setFilterFixedString); - connect(m_ui->queryLineEdit, &QLineEdit::returnPressed, this, &GerritDialog::refresh); - connect(m_model, &GerritModel::stateChanged, m_ui->queryLineEdit, &Utils::FancyLineEdit::validate); - connect(m_ui->remoteComboBox, &GerritRemoteChooser::remoteChanged, - this, &GerritDialog::remoteChanged); m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_filterModel->setSourceModel(m_model); m_filterModel->setFilterRole(GerritModel::FilterRole); m_filterModel->setSortRole(GerritModel::SortRole); - m_ui->treeView->setModel(m_filterModel); - m_ui->treeView->setActivationMode(Utils::DoubleClickActivation); - connect(&m_progressIndicatorTimer, &QTimer::timeout, - [this]() { setProgressIndicatorVisible(true); }); + m_treeView->setModel(m_filterModel); + m_treeView->setActivationMode(Utils::DoubleClickActivation); + m_progressIndicatorTimer.setSingleShot(true); m_progressIndicatorTimer.setInterval(50); // don't show progress for < 50ms tasks - m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Large, - m_ui->treeView); - m_progressIndicator->attachToWidget(m_ui->treeView->viewport()); + m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Large, m_treeView); + m_progressIndicator->attachToWidget(m_treeView->viewport()); m_progressIndicator->hide(); - connect(m_model, &GerritModel::stateChanged, this, &GerritDialog::manageProgressIndicator); - - QItemSelectionModel *selectionModel = m_ui->treeView->selectionModel(); - connect(selectionModel, &QItemSelectionModel::currentChanged, - this, &GerritDialog::slotCurrentChanged); - connect(m_ui->treeView, &QAbstractItemView::activated, - this, &GerritDialog::slotActivated); - m_displayButton = addActionButton(tr("&Show"), [this]() { slotFetchDisplay(); }); m_cherryPickButton = addActionButton(tr("Cherry &Pick"), [this]() { slotFetchCherryPick(); }); m_checkoutButton = addActionButton(tr("C&heckout"), [this]() { slotFetchCheckout(); }); m_refreshButton = addActionButton(tr("&Refresh"), [this]() { refresh(); }); + m_refreshButton->setDefault(true); + + using namespace Layouting; + + Column { + Row { + queryLabel, + m_queryLineEdit, + st, + filterLineEdit + }, + m_treeView + }.attachTo(changesGroup); + + Column { + m_detailsBrowser + }.attachTo(detailsGroup); + + auto splitter = new QSplitter(this); + splitter->setOrientation(Qt::Vertical); + splitter->setChildrenCollapsible(false); + splitter->addWidget(changesGroup); + splitter->addWidget(detailsGroup); + + Column { + Row { m_repositoryLabel, st, tr("Remote:"), m_remoteComboBox }, + splitter, + m_buttonBox + }.attachTo(this); + + connect(filterLineEdit, &Utils::FancyLineEdit::filterChanged, + m_filterModel, &QSortFilterProxyModel::setFilterFixedString); + connect(m_queryLineEdit, &QLineEdit::returnPressed, + this, &GerritDialog::refresh); + connect(m_model, &GerritModel::stateChanged, + m_queryLineEdit, &Utils::FancyLineEdit::validate); + connect(m_remoteComboBox, &GerritRemoteChooser::remoteChanged, + this, &GerritDialog::remoteChanged); + connect(&m_progressIndicatorTimer, &QTimer::timeout, + this, [this] { setProgressIndicatorVisible(true); }); + connect(m_model, &GerritModel::stateChanged, + this, &GerritDialog::manageProgressIndicator); + + connect(m_treeView->selectionModel(), &QItemSelectionModel::currentChanged, + this, &GerritDialog::slotCurrentChanged); + connect(m_treeView, &QAbstractItemView::activated, + this, &GerritDialog::slotActivated); connect(m_model, &GerritModel::refreshStateChanged, m_refreshButton, &QWidget::setDisabled); @@ -125,8 +200,10 @@ GerritDialog::GerritDialog(const QSharedPointer &p, setCurrentPath(repository); slotCurrentChanged(); - m_ui->treeView->setFocus(); - m_refreshButton->setDefault(true); + m_treeView->setFocus(); + + connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); } FilePath GerritDialog::repositoryPath() const @@ -139,14 +216,14 @@ void GerritDialog::setCurrentPath(const FilePath &path) if (path == m_repository) return; m_repository = path; - m_ui->repositoryLabel->setText(Git::Internal::GitPlugin::msgRepositoryLabel(path)); + m_repositoryLabel->setText(Git::Internal::GitPlugin::msgRepositoryLabel(path)); updateRemotes(); } QPushButton *GerritDialog::addActionButton(const QString &text, const std::function &buttonSlot) { - QPushButton *button = m_ui->buttonBox->addButton(text, QDialogButtonBox::ActionRole); + QPushButton *button = m_buttonBox->addButton(text, QDialogButtonBox::ActionRole); connect(button, &QPushButton::clicked, this, buttonSlot); return button; } @@ -162,10 +239,7 @@ void GerritDialog::updateCompletions(const QString &query) m_parameters->saveQueries(Core::ICore::settings()); } -GerritDialog::~GerritDialog() -{ - delete m_ui; -} +GerritDialog::~GerritDialog() = default; void GerritDialog::slotActivated(const QModelIndex &i) { @@ -177,11 +251,11 @@ void GerritDialog::slotActivated(const QModelIndex &i) void GerritDialog::slotRefreshStateChanged(bool v) { if (!v && m_model->rowCount()) { - m_ui->treeView->expandAll(); + m_treeView->expandAll(); for (int c = 0; c < GerritModel::ColumnCount; ++c) - m_ui->treeView->resizeColumnToContents(c); - if (m_ui->treeView->columnWidth(GerritModel::TitleColumn) > maxTitleWidth) - m_ui->treeView->setColumnWidth(GerritModel::TitleColumn, maxTitleWidth); + m_treeView->resizeColumnToContents(c); + if (m_treeView->columnWidth(GerritModel::TitleColumn) > maxTitleWidth) + m_treeView->setColumnWidth(GerritModel::TitleColumn, maxTitleWidth); } } @@ -208,10 +282,10 @@ void GerritDialog::slotFetchCheckout() void GerritDialog::refresh() { - const QString &query = m_ui->queryLineEdit->text().trimmed(); + const QString &query = m_queryLineEdit->text().trimmed(); updateCompletions(query); m_model->refresh(m_server, query); - m_ui->treeView->sortByColumn(-1, Qt::DescendingOrder); + m_treeView->sortByColumn(-1, Qt::DescendingOrder); } void GerritDialog::scheduleUpdateRemotes() @@ -233,7 +307,7 @@ void GerritDialog::showEvent(QShowEvent *event) void GerritDialog::remoteChanged() { - const GerritServer server = m_ui->remoteComboBox->currentServer(); + const GerritServer server = m_remoteComboBox->currentServer(); if (QSharedPointer modelServer = m_model->server()) { if (*modelServer == server) return; @@ -245,11 +319,11 @@ void GerritDialog::remoteChanged() void GerritDialog::updateRemotes(bool forceReload) { - m_ui->remoteComboBox->setRepository(m_repository); + m_remoteComboBox->setRepository(m_repository); if (m_repository.isEmpty() || !m_repository.isDir()) return; *m_server = m_parameters->server; - m_ui->remoteComboBox->updateRemotes(forceReload); + m_remoteComboBox->updateRemotes(forceReload); } void GerritDialog::manageProgressIndicator() @@ -264,13 +338,13 @@ void GerritDialog::manageProgressIndicator() QModelIndex GerritDialog::currentIndex() const { - const QModelIndex index = m_ui->treeView->selectionModel()->currentIndex(); + const QModelIndex index = m_treeView->selectionModel()->currentIndex(); return index.isValid() ? m_filterModel->mapToSource(index) : QModelIndex(); } void GerritDialog::updateButtons() { - const bool enabled = !m_fetchRunning && m_ui->treeView->selectionModel()->currentIndex().isValid(); + const bool enabled = !m_fetchRunning && m_treeView->selectionModel()->currentIndex().isValid(); m_displayButton->setEnabled(enabled); m_cherryPickButton->setEnabled(enabled); m_checkoutButton->setEnabled(enabled); @@ -279,7 +353,7 @@ void GerritDialog::updateButtons() void GerritDialog::slotCurrentChanged() { const QModelIndex current = currentIndex(); - m_ui->detailsBrowser->setText(current.isValid() ? m_model->toHtml(current) : QString()); + m_detailsBrowser->setText(current.isValid() ? m_model->toHtml(current) : QString()); updateButtons(); } diff --git a/src/plugins/git/gerrit/gerritdialog.h b/src/plugins/git/gerrit/gerritdialog.h index 5d41798c275..d2aca30c37d 100644 --- a/src/plugins/git/gerrit/gerritdialog.h +++ b/src/plugins/git/gerrit/gerritdialog.h @@ -34,20 +34,28 @@ #include QT_BEGIN_NAMESPACE +class QDialogButtonBox; +class QLabel; class QModelIndex; class QSortFilterProxyModel; class QStringListModel; class QPushButton; +class QTextBrowser; QT_END_NAMESPACE -namespace Utils { class ProgressIndicator; } +namespace Utils { +class FancyLineEdit; +class ProgressIndicator; +class TreeView; +} // Utils namespace Gerrit { namespace Internal { -namespace Ui { class GerritDialog; } + class GerritChange; class GerritModel; class GerritParameters; +class GerritRemoteChooser; class GerritServer; class GerritDialog : public QDialog @@ -86,14 +94,13 @@ private: void setProgressIndicatorVisible(bool v); QModelIndex currentIndex() const; - QPushButton *addActionButton(const QString &text, const std::function &buttonSlot); void updateCompletions(const QString &query); + QPushButton *addActionButton(const QString &text, const std::function &buttonSlot); void updateButtons(); const QSharedPointer m_parameters; const QSharedPointer m_server; QSortFilterProxyModel *m_filterModel; - Ui::GerritDialog *m_ui; GerritModel *m_model; QStringListModel *m_queryModel; QPushButton *m_displayButton; @@ -106,6 +113,13 @@ private: bool m_fetchRunning = false; bool m_updatingRemotes = false; bool m_shouldUpdateRemotes = false; + + QLabel *m_repositoryLabel; + GerritRemoteChooser *m_remoteComboBox; + Utils::TreeView *m_treeView; + QTextBrowser *m_detailsBrowser; + QDialogButtonBox *m_buttonBox; + Utils::FancyLineEdit *m_queryLineEdit; }; } // namespace Internal diff --git a/src/plugins/git/gerrit/gerritdialog.ui b/src/plugins/git/gerrit/gerritdialog.ui deleted file mode 100644 index d44047a6552..00000000000 --- a/src/plugins/git/gerrit/gerritdialog.ui +++ /dev/null @@ -1,301 +0,0 @@ - - - Gerrit::Internal::GerritDialog - - - - 0 - 0 - 950 - 706 - - - - Gerrit - - - - - - - - - 0 - 0 - - - - Repository: Dummy - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Remote: - - - - - - - - 0 - 0 - - - - - 40 - 0 - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Vertical - - - false - - - - - 0 - 2 - - - - - 0 - 350 - - - - Changes - - - - - - - - &Query: - - - queryLineEdit - - - - - - - - 0 - 0 - - - - - 400 - 0 - - - - Change #, SHA-1, tr:id, owner:email or reviewer:email - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 300 - 0 - - - - - - - - - - - 600 - 0 - - - - false - - - true - - - true - - - - - - - - - 0 - 1 - - - - - 0 - 175 - - - - Details - - - - 5 - - - 5 - - - 5 - - - 5 - - - - - true - - - - - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Close - - - - - - - - Utils::FancyLineEdit - QLineEdit -
utils/fancylineedit.h
-
- - Utils::TreeView - QTreeView -
utils/itemviews.h
-
- - Gerrit::Internal::GerritRemoteChooser - QWidget -
git/gerrit/gerritremotechooser.h
- 1 -
-
- - - - buttonBox - accepted() - Gerrit::Internal::GerritDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - Gerrit::Internal::GerritDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - -
diff --git a/src/plugins/git/git.qbs b/src/plugins/git/git.qbs index 076334e9145..982fbf8bc8c 100644 --- a/src/plugins/git/git.qbs +++ b/src/plugins/git/git.qbs @@ -77,7 +77,6 @@ QtcPlugin { "branchcombobox.h", "gerritdialog.cpp", "gerritdialog.h", - "gerritdialog.ui", "gerritmodel.cpp", "gerritmodel.h", "gerritoptionspage.cpp",