1 | /* |
2 | This file is part of the KDE libraries |
3 | SPDX-FileCopyrightText: 2014 Arjun A.K. <arjunak234@gmail.com> |
4 | |
5 | SPDX-License-Identifier: LGPL-2.0-or-later |
6 | */ |
7 | |
8 | #ifndef EXECUTABLEFILEOPENDIALOG_H |
9 | #define EXECUTABLEFILEOPENDIALOG_H |
10 | |
11 | #include <QDialog> |
12 | |
13 | #include "ui_executablefileopendialog.h" |
14 | |
15 | class QMimeType; |
16 | |
17 | /*! |
18 | * Dialog shown when opening an executable file |
19 | * |
20 | * \internal |
21 | */ |
22 | class ExecutableFileOpenDialog : public QDialog |
23 | { |
24 | Q_OBJECT |
25 | |
26 | public: |
27 | enum ReturnCode { |
28 | OpenFile = 42, |
29 | ExecuteFile, |
30 | }; |
31 | |
32 | enum Mode { |
33 | // For executable scripts |
34 | OpenOrExecute, |
35 | // For native binary executables |
36 | OnlyExecute, |
37 | // For *.exe files, open with WINE is like execute the file |
38 | // In this case, openAsExecute is true, we hide "Open" button and connect |
39 | // "Execute" button to OpenFile action. |
40 | OpenAsExecute, |
41 | }; |
42 | |
43 | explicit ExecutableFileOpenDialog(const QUrl &url, const QMimeType &mimeType, Mode mode, QWidget *parent = nullptr); |
44 | |
45 | bool isDontAskAgainChecked() const; |
46 | |
47 | protected: |
48 | void showEvent(QShowEvent *event) override; |
49 | |
50 | private: |
51 | void executeFile(); |
52 | void openFile(); |
53 | |
54 | Ui_ExecutableFileOpenDialog m_ui; |
55 | }; |
56 | |
57 | #endif // EXECUTABLEFILEOPENDIALOG_H |
58 | |