Commit aee8f883 authored by Friedemann Kleint's avatar Friedemann Kleint Committed by hjk

DeviceProcessDialog: Introduce methods for modal/non-modal use.

Add methods to be able to use the dialog as a non-modal
dialog showing a list of processes or a modal-dialog
for selecting a process.

Connect double-click to 'Accept' for the modal
case (regression from 2.5).

Change-Id: If05a1c40ee6a41135d943e9919a1250db03eeffb
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 009d6b1e
......@@ -1560,6 +1560,7 @@ void DebuggerPluginPrivate::attachToRunningApplication()
void DebuggerPluginPrivate::attachToProcess(bool startServerOnly)
{
DeviceProcessesDialog *dlg = new DeviceProcessesDialog(mainWindow());
dlg->addAcceptButton(DeviceProcessesDialog::tr("&Attach to Process"));
dlg->showAllDevices();
if (dlg->exec() == QDialog::Rejected) {
delete dlg;
......
......@@ -120,11 +120,12 @@ public:
FilterLineEdit *processFilterLineEdit;
QPushButton *updateListButton;
QPushButton *killProcessButton;
QPushButton *attachProcessButton;
QPushButton *acceptButton;
QDialogButtonBox *buttonBox;
};
DeviceProcessesDialogPrivate::DeviceProcessesDialogPrivate(QWidget *parent)
: q(parent)
: q(parent), acceptButton(0), buttonBox(new QDialogButtonBox(parent))
{
processList = 0;
......@@ -150,13 +151,9 @@ DeviceProcessesDialogPrivate::DeviceProcessesDialogPrivate(QWidget *parent)
updateListButton = new QPushButton(DeviceProcessesDialog::tr("&Update List"), q);
killProcessButton = new QPushButton(DeviceProcessesDialog::tr("&Kill Process"), q);
attachProcessButton = new QPushButton(DeviceProcessesDialog::tr("&Attach to Process"), q);
QDialogButtonBox *buttonBox = new QDialogButtonBox(q);
buttonBox->setStandardButtons(QDialogButtonBox::Close);
buttonBox->addButton(updateListButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(killProcessButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(attachProcessButton, QDialogButtonBox::AcceptRole);
QFormLayout *leftColumn = new QFormLayout();
leftColumn->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
......@@ -259,8 +256,9 @@ void DeviceProcessesDialogPrivate::handleProcessKilled()
void DeviceProcessesDialogPrivate::updateButtons()
{
bool hasSelection = procView->selectionModel()->hasSelection();
attachProcessButton->setEnabled(hasSelection);
const bool hasSelection = procView->selectionModel()->hasSelection();
if (acceptButton)
acceptButton->setEnabled(hasSelection);
killProcessButton->setEnabled(hasSelection);
errorText->setVisible(!errorText->document()->isEmpty());
}
......@@ -281,6 +279,21 @@ DeviceProcess DeviceProcessesDialogPrivate::selectedProcess() const
//
///////////////////////////////////////////////////////////////////////
/*!
\class ProjectExplorer::DeviceProcessesDialog
\brief Shows a list of processes.
The dialog can be used as a
\list
\o Non-modal dialog showing a list of processes: Call addCloseButton()
to add a 'Close' button.
\o Modal dialog with an 'Accept' button to select a process: Call
addAcceptButton() passing the label text. This will create a
'Cancel' button as well.
\endlist
*/
DeviceProcessesDialog::DeviceProcessesDialog(QWidget *parent)
: QDialog(parent), d(new Internal::DeviceProcessesDialogPrivate(this))
{
......@@ -294,6 +307,20 @@ DeviceProcessesDialog::~DeviceProcessesDialog()
delete d;
}
void DeviceProcessesDialog::addAcceptButton(const QString &label)
{
d->acceptButton = new QPushButton(label);
d->buttonBox->addButton(d->acceptButton, QDialogButtonBox::AcceptRole);
connect(d->procView, SIGNAL(doubleClicked(QModelIndex)),
d->acceptButton, SLOT(animateClick()));
d->buttonBox->addButton(QDialogButtonBox::Cancel);
}
void DeviceProcessesDialog::addCloseButton()
{
d->buttonBox->addButton(QDialogButtonBox::Close);
}
void DeviceProcessesDialog::setDevice(const IDevice::ConstPtr &device)
{
d->profileChooser->hide();
......
......@@ -51,6 +51,8 @@ class PROJECTEXPLORER_EXPORT DeviceProcessesDialog : public QDialog
public:
explicit DeviceProcessesDialog(QWidget *parent = 0);
~DeviceProcessesDialog();
void addAcceptButton(const QString &label);
void addCloseButton();
void setDevice(const IDevice::ConstPtr &device);
void showAllDevices();
......
......@@ -336,6 +336,7 @@ void DeviceSettingsWidget::handleProcessListRequested()
{
QTC_ASSERT(currentDevice()->canCreateProcessModel(), return);
DeviceProcessesDialog dlg;
dlg.addCloseButton();
dlg.setDevice(currentDevice());
dlg.exec();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment