File indexing completed on 2024-07-21 03:41:36

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2014 Arjun A.K. <arjunak234@gmail.com>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef EXECUTABLEFILEOPENDIALOG_H
0009 #define EXECUTABLEFILEOPENDIALOG_H
0010 
0011 #include <QDialog>
0012 
0013 class QCheckBox;
0014 
0015 /**
0016  * @brief Dialog shown when opening an executable file
0017  */
0018 class ExecutableFileOpenDialog : public QDialog
0019 {
0020     Q_OBJECT
0021 
0022 public:
0023     enum ReturnCode {
0024         OpenFile = 42,
0025         ExecuteFile,
0026     };
0027 
0028     enum Mode {
0029         // For executable scripts
0030         OpenOrExecute,
0031         // For native binary executables
0032         OnlyExecute,
0033         // For *.exe files, open with WINE is like execute the file
0034         // In this case, openAsExecute is true, we hide "Open" button and connect
0035         // "Execute" button to OpenFile action.
0036         OpenAsExecute,
0037     };
0038 
0039     explicit ExecutableFileOpenDialog(Mode mode, QWidget *parent = nullptr);
0040     explicit ExecutableFileOpenDialog(QWidget *parent = nullptr);
0041 
0042     bool isDontAskAgainChecked() const;
0043 
0044 private:
0045     void executeFile();
0046     void openFile();
0047 
0048     QCheckBox *m_dontAskAgain;
0049 };
0050 
0051 #endif // EXECUTABLEFILEOPENDIALOG_H