|
| 1 | +/* |
| 2 | + launcherdialog.cpp |
| 3 | +
|
| 4 | + This file is part of GammaRay, the Qt application inspection and |
| 5 | + manipulation tool. |
| 6 | +
|
| 7 | + Copyright (C) 2017 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com |
| 8 | + Author: Giulio Camuffo <giulio.camuffo@kdab.com> |
| 9 | +
|
| 10 | + Licensees holding valid commercial KDAB GammaRay licenses may use this file in |
| 11 | + accordance with GammaRay Commercial License Agreement provided with the Software. |
| 12 | +
|
| 13 | + Contact info@kdab.com if any conditions of this licensing are not clear to you. |
| 14 | +
|
| 15 | + This program is free software; you can redistribute it and/or modify |
| 16 | + it under the terms of the GNU General Public License as published by |
| 17 | + the Free Software Foundation, either version 2 of the License, or |
| 18 | + (at your option) any later version. |
| 19 | +
|
| 20 | + This program is distributed in the hope that it will be useful, |
| 21 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | + GNU General Public License for more details. |
| 24 | +
|
| 25 | + You should have received a copy of the GNU General Public License |
| 26 | + along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 27 | +*/ |
| 28 | + |
| 29 | +#include <QDialog> |
| 30 | + |
| 31 | +#include "launcherdialog.h" |
| 32 | +#include "launcherwindow.h" |
| 33 | +#include "ui_launcherwindow.h" |
| 34 | + |
| 35 | +namespace GammaRay { |
| 36 | + |
| 37 | +LauncherDialog::Result LauncherDialog::exec(Mode mode) |
| 38 | +{ |
| 39 | + LauncherWindow launcher(false); |
| 40 | + launcher.ui->tabWidget->removeTab(launcher.ui->tabWidget->indexOf(launcher.ui->launchPage)); |
| 41 | + |
| 42 | + switch (mode) { |
| 43 | + case Mode::Connect: |
| 44 | + launcher.ui->tabWidget->setCurrentWidget(launcher.ui->connectPage); |
| 45 | + break; |
| 46 | + case Mode::Attach: |
| 47 | + launcher.ui->tabWidget->setCurrentWidget(launcher.ui->attachPage); |
| 48 | + break; |
| 49 | + } |
| 50 | + |
| 51 | + int ret = launcher.exec(); |
| 52 | + Result result; |
| 53 | + result.m_valid = ret == QDialog::Accepted; |
| 54 | + |
| 55 | + QWidget *current = launcher.ui->tabWidget->currentWidget(); |
| 56 | + if (current == launcher.ui->connectPage) { |
| 57 | + result.m_mode = Mode::Connect; |
| 58 | + } else if (current == launcher.ui->attachPage) { |
| 59 | + result.m_mode = Mode::Attach; |
| 60 | + } else { |
| 61 | + result.m_valid = false; |
| 62 | + return result; |
| 63 | + } |
| 64 | + |
| 65 | + switch (result.m_mode) { |
| 66 | + case Mode::Connect: |
| 67 | + result.m_url = launcher.ui->connectPage->url(); |
| 68 | + break; |
| 69 | + case Mode::Attach: |
| 70 | + result.m_procPid = launcher.ui->attachPage->pid(); |
| 71 | + result.m_procExe = launcher.ui->attachPage->name(); |
| 72 | + break; |
| 73 | + } |
| 74 | + |
| 75 | + |
| 76 | + return result; |
| 77 | +} |
| 78 | + |
| 79 | +} |
0 commit comments