diff --git a/src/plugins/perforce/CMakeLists.txt b/src/plugins/perforce/CMakeLists.txt index c5c9ed265df..3b020dfa09c 100644 --- a/src/plugins/perforce/CMakeLists.txt +++ b/src/plugins/perforce/CMakeLists.txt @@ -3,7 +3,7 @@ add_qtc_plugin(Perforce SOURCES annotationhighlighter.cpp annotationhighlighter.h changenumberdialog.cpp changenumberdialog.h - pendingchangesdialog.cpp pendingchangesdialog.h pendingchangesdialog.ui + pendingchangesdialog.cpp pendingchangesdialog.h perforcechecker.cpp perforcechecker.h perforceeditor.cpp perforceeditor.h perforceplugin.cpp perforceplugin.h diff --git a/src/plugins/perforce/pendingchangesdialog.cpp b/src/plugins/perforce/pendingchangesdialog.cpp index 11b3119fc0d..0ee5d1d36e6 100644 --- a/src/plugins/perforce/pendingchangesdialog.cpp +++ b/src/plugins/perforce/pendingchangesdialog.cpp @@ -3,14 +3,29 @@ #include "pendingchangesdialog.h" -#include +#include +#include +#include +#include +#include +#include using namespace Perforce::Internal; -PendingChangesDialog::PendingChangesDialog(const QString &data, QWidget *parent) : QDialog(parent) +PendingChangesDialog::PendingChangesDialog(const QString &data, QWidget *parent) + : QDialog(parent) + , m_listWidget(new QListWidget(this)) { - m_ui.setupUi(this); + setWindowTitle(tr("P4 Pending Changes")); + + QDialogButtonBox *buttonBox = new QDialogButtonBox(this); + buttonBox->setOrientation(Qt::Horizontal); + buttonBox->setStandardButtons(QDialogButtonBox::Cancel); + QPushButton *submitButton = buttonBox->addButton(tr("Submit"), QDialogButtonBox::AcceptRole); + connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + if (!data.isEmpty()) { const QRegularExpression r(QLatin1String("Change\\s(\\d+?).*?\\s\\*?pending\\*?\\s(.+?)\n")); QListWidgetItem *item; @@ -19,25 +34,34 @@ PendingChangesDialog::PendingChangesDialog(const QString &data, QWidget *parent) const QRegularExpressionMatch match = it.next(); item = new QListWidgetItem(tr("Change %1: %2").arg(match.captured(1), match.captured(2).trimmed()), - m_ui.listWidget); - item->setData(234, match.captured(1).trimmed()); + m_listWidget); + item->setData(Qt::UserRole, match.captured(1).trimmed()); } } - m_ui.listWidget->setSelectionMode(QListWidget::SingleSelection); - if (m_ui.listWidget->count()) { - m_ui.listWidget->setCurrentRow(0); - m_ui.submitButton->setEnabled(true); + m_listWidget->setSelectionMode(QListWidget::SingleSelection); + if (m_listWidget->count()) { + m_listWidget->setCurrentRow(0); + submitButton->setEnabled(true); } else { - m_ui.submitButton->setEnabled(false); + submitButton->setEnabled(false); } + + using namespace Utils::Layouting; + + Column { + m_listWidget, + buttonBox + }.attachTo(this); + + resize(320, 250); } int PendingChangesDialog::changeNumber() const { - QListWidgetItem *item = m_ui.listWidget->item(m_ui.listWidget->currentRow()); + QListWidgetItem *item = m_listWidget->item(m_listWidget->currentRow()); if (!item) return -1; bool ok = true; - int i = item->data(234).toInt(&ok); - return ok ? i : -1; + const int number = item->data(Qt::UserRole).toInt(&ok); + return ok ? number : -1; } diff --git a/src/plugins/perforce/pendingchangesdialog.h b/src/plugins/perforce/pendingchangesdialog.h index 73cce0e4ad2..e90a08989a6 100644 --- a/src/plugins/perforce/pendingchangesdialog.h +++ b/src/plugins/perforce/pendingchangesdialog.h @@ -5,7 +5,9 @@ #include -#include "ui_pendingchangesdialog.h" +QT_BEGIN_NAMESPACE +class QListWidget; +QT_END_NAMESPACE namespace Perforce { namespace Internal { @@ -19,7 +21,7 @@ public: int changeNumber() const; private: - Ui::PendingChangesDialog m_ui; + QListWidget *m_listWidget = nullptr; }; } // namespace Perforce diff --git a/src/plugins/perforce/pendingchangesdialog.ui b/src/plugins/perforce/pendingchangesdialog.ui deleted file mode 100644 index 0cae43326ee..00000000000 --- a/src/plugins/perforce/pendingchangesdialog.ui +++ /dev/null @@ -1,92 +0,0 @@ - - - Perforce::Internal::PendingChangesDialog - - - P4 Pending Changes - - - - 6 - - - 9 - - - - - - - - 6 - - - 0 - - - - - Qt::Horizontal - - - - 131 - 31 - - - - - - - - Submit - - - - - - - Cancel - - - - - - - - - - - submitButton - clicked() - Perforce::Internal::PendingChangesDialog - accept() - - - 278 - 253 - - - 96 - 254 - - - - - cancelButton - clicked() - Perforce::Internal::PendingChangesDialog - reject() - - - 369 - 253 - - - 179 - 282 - - - - - diff --git a/src/plugins/perforce/perforce.qbs b/src/plugins/perforce/perforce.qbs index b9dab6d2a9d..7790ddf4208 100644 --- a/src/plugins/perforce/perforce.qbs +++ b/src/plugins/perforce/perforce.qbs @@ -17,7 +17,6 @@ QtcPlugin { "changenumberdialog.h", "pendingchangesdialog.cpp", "pendingchangesdialog.h", - "pendingchangesdialog.ui", "perforcechecker.cpp", "perforcechecker.h", "perforceeditor.cpp", diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 6ba890cf1ee..f588b57af5d 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -1364,14 +1365,14 @@ PerforceResponse PerforcePluginPrivate::runP4Cmd(const FilePath &workingDir, VcsOutputWindow::appendCommand(workingDir, {m_settings.p4BinaryPath.filePath(), actualArgs}); if (flags & ShowBusyCursor) - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); const PerforceResponse response = (flags & RunFullySynchronous) ? fullySynchronousProcess(workingDir, actualArgs, flags, stdInput, outputCodec) : synchronousProcess(workingDir, actualArgs, flags, stdInput, outputCodec); if (flags & ShowBusyCursor) - QApplication::restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); if (response.error && (flags & ErrorToWindow)) VcsOutputWindow::appendError(response.message);