File indexing completed on 2024-10-06 04:26:02

0001 /*
0002     SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 
0007 #ifndef _K3B_SYSTEM_PROBLEM_DIALOG_H_
0008 #define _K3B_SYSTEM_PROBLEM_DIALOG_H_
0009 
0010 #include <QString>
0011 #include <QDialog>
0012 
0013 class QCheckBox;
0014 class QCloseEvent;
0015 
0016 namespace K3b {
0017     namespace Device {
0018         class Device;
0019     }
0020 
0021     class SystemProblem
0022     {
0023     public:
0024         enum Type
0025         {
0026             CRITICAL,
0027             NON_CRITICAL,
0028             WARNING
0029         };
0030         
0031         explicit SystemProblem( Type type = NON_CRITICAL,
0032                        const QString& problem = QString(),
0033                        const QString& details = QString(),
0034                        const QString& solution = QString() );
0035 
0036         Type type;
0037         QString problem;
0038         QString details;
0039         QString solution;
0040     };
0041 
0042 
0043     /**
0044      * The SystemProblem checks for problems with the system setup
0045      * that could prevent K3b from functioning properly. Examples are
0046      * missing external applications like cdrecord or versions of
0047      * external applications that are too old.
0048      *
0049      * Usage:
0050      * <pre>
0051      * if( SystemProblemDialog::readCheckSystemConfig() )
0052      *    SystemProblemDialog::checkSystem( this );
0053      * </pre>
0054      */
0055     class SystemProblemDialog : public QDialog
0056     {
0057         Q_OBJECT
0058 
0059     public:
0060         enum NotificationLevel {
0061             AlwaysNotify,
0062             NotifyOnlyErrors
0063         };
0064 
0065         /**
0066          * Determines if the system problem dialog should be shown or not.
0067          * It basically reads a config entry. But in addition it
0068          * always forces the system check if a new version has been installed
0069          * or K3b is started for the first time.
0070          */
0071         static bool readCheckSystemConfig();
0072         static void checkSystem(QWidget* parent = 0, NotificationLevel level = NotifyOnlyErrors, bool forceCheck = false);
0073 
0074     protected:
0075         void done(int) override;
0076 
0077     private Q_SLOTS:
0078         void slotShowDeviceSettings();
0079         void slotShowBinSettings();
0080 
0081     private:
0082         SystemProblemDialog( const QList<SystemProblem>& problems,
0083                              bool showDeviceSettingsButton,
0084                              bool showBinSettingsButton,
0085                              bool forceCheck = false,
0086                              QWidget* parent = 0);
0087         static int dmaActivated( Device::Device* );
0088 #ifndef Q_OS_WIN32
0089         static QList<Device::Device*> checkForAutomounting();
0090 #endif
0091         QCheckBox* m_checkDontShowAgain;
0092     };
0093 }
0094 
0095 #endif