1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 Petar Perisin <petar.perisin@gmail.com>
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #pragma once
27 
28 #include <QDialog>
29 #include <QTimer>
30 
31 #include <projectexplorer/devicesupport/deviceprocesslist.h>
32 
33 QT_BEGIN_NAMESPACE
34 class QLabel;
35 class QCheckBox;
36 QT_END_NAMESPACE
37 
38 namespace ProjectExplorer {
39 class KitChooser;
40 class Kit;
41 }
42 
43 namespace Utils { class PathChooser; }
44 
45 namespace Debugger {
46 namespace Internal {
47 
48 class UnstartedAppWatcherDialog : public QDialog
49 {
50     Q_OBJECT
51 
52 public:
53     explicit UnstartedAppWatcherDialog(QWidget *parent = nullptr);
54 
55     ProjectExplorer::Kit *currentKit() const;
56     ProjectExplorer::DeviceProcessItem currentProcess() const;
57     bool hideOnAttach() const;
58     bool continueOnAttach() const;
59     void startWatching();
60 
61     bool event(QEvent *) override;
62 
63 signals:
64     void processFound();
65 
66 private:
67     void selectExecutable();
68     void pidFound(const ProjectExplorer::DeviceProcessItem &p);
69     void startStopWatching(bool start);
70     void findProcess();
71     void stopAndCheckExecutable();
72     void kitChanged();
73 
74     enum UnstartedAppWacherState
75     {
76         InvalidWacherState,
77         NotWatchingState,
78         WatchingState,
79         FoundState
80     };
81 
82     void startStopTimer(bool start);
83     bool checkExecutableString() const;
84     void setWaitingState(UnstartedAppWacherState state);
85 
86     ProjectExplorer::KitChooser *m_kitChooser;
87     Utils::PathChooser *m_pathChooser;
88     QLabel *m_waitingLabel;
89     QCheckBox *m_hideOnAttachCheckBox;
90     QCheckBox *m_continueOnAttachCheckBox;
91     QPushButton *m_watchingPushButton;
92     ProjectExplorer::DeviceProcessItem m_process;
93     QTimer m_timer;
94 };
95 
96 } // namespace Internal
97 } // namespace Debugger
98