Debian Codegraph @

src/plugin/test_folderlistmodel/simpleUI/terminalfolderapp.h

raw symbols SCIP
1 /**************************************************************************
2 *
3 * Copyright 2013 Canonical Ltd.
4 * Copyright 2013 Carlos J Mazieri <[email protected]>
5 *
6 * You may use this file under the terms of the BSD license as follows:
7 *
8 * "Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Nemo Mobile nor the names of its contributors
18 * may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
32 *
33 *
34 * Filename: terminalfolderapp.h
35 * Created : 29 Jul 2013
36 **/
37
38
39 #ifndef TERMINALFOLDERAPP_H
40 #define TERMINALFOLDERAPP_H
41
42 #include <QObject>
43 #include <QProcess>
44
45
46 /*!
47 * Since KDE and GNOME calling "x-terminal-emulator" do not give the real process id, closing a TerminalFolderApp
48 * is disabled by default.
49 *
50 * \ref TerminalFolderApp::closeTerminal() works for:
51 * \li Ubuntu Touch
52 * \li Meego, tested on Nemo Mobile and Nokia N9
53 */
54 #ifndef ENABLE_CLOSING
55 # define ENABLE_CLOSING 0
56 #endif
57
58 /*!
59 * \brief The TerminalFolderApp class opens a suitable Terminal application with a working directory
60 *
61 * It tries to find and open a terminal application in the sequence:
62 * \li "meego-terminal" for Nemo Mobile and Nokia N9
63 * \li "ubuntu-terminal-app" for Ubuntu Touch
64 * \li "x-terminal-emulator" for any Desktop such as KDE and Gnome
65 * \li TERM environment variable if defined
66 */
67 class TerminalFolderApp : public QObject
68 {
69 Q_OBJECT
70 public:
71 explicit TerminalFolderApp(QObject *parent = 0);
72 ~TerminalFolderApp();
73
74 public slots:
75 bool openTerminal(const QString& currentDir);
76
77 private:
78 void findTerminalApp();
79 void findDesktopParameter();
80
81
82 #if ENABLE_CLOSING
83 signals:
84 void openCounterChanged(int openedTerminals);
85 public slots:
86 bool closeTerminal(int index);
87 private:
88 bool killPid(Q_PID pid);
89 #endif
90
91 #if REGRESSION_TEST_FOLDERLISTMODEL
92 public:
93 #else
94 private:
95 #endif
96 QList<Q_PID> m_openPids;
97 QString m_terminalApp;
98 QStringList m_params; //!< used to pass workdir parameter
99 };
100 #endif // TERMINALFOLDERAPP_H