forked from qt-creator/qt-creator
Perforce: PendingChangesDialog: Use Layouting
Change-Id: I0c4ea45f89b694df89ec304171779cb1b796280f Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -3,14 +3,29 @@
|
||||
|
||||
#include "pendingchangesdialog.h"
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QIntValidator>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
#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
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Perforce::Internal::PendingChangesDialog</class>
|
||||
<widget class="QDialog" name="Perforce::Internal::PendingChangesDialog">
|
||||
<property name="windowTitle">
|
||||
<string>P4 Pending Changes</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>131</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="submitButton">
|
||||
<property name="text">
|
||||
<string>Submit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>submitButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>Perforce::Internal::PendingChangesDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>278</x>
|
||||
<y>253</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>96</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>cancelButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>Perforce::Internal::PendingChangesDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>369</x>
|
||||
<y>253</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>179</x>
|
||||
<y>282</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -17,7 +17,6 @@ QtcPlugin {
|
||||
"changenumberdialog.h",
|
||||
"pendingchangesdialog.cpp",
|
||||
"pendingchangesdialog.h",
|
||||
"pendingchangesdialog.ui",
|
||||
"perforcechecker.cpp",
|
||||
"perforcechecker.h",
|
||||
"perforceeditor.cpp",
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QGuiApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user