File indexing completed on 2024-04-21 04:50:08

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 
0009 
0010 #ifndef K3B_H
0011 #define K3B_H
0012 
0013 #include "option/k3boptiondialog.h"
0014 
0015 #include <KSharedConfig>
0016 #include <KXmlGuiWindow>
0017 
0018 #include <QList>
0019 #include <QUrl>
0020 
0021 namespace K3b {
0022     class Doc;
0023     class View;
0024     class ExternalBinManager;
0025 
0026     namespace Device {
0027         class DeviceManager;
0028         class Device;
0029     }
0030 
0031     class MainWindow : public KXmlGuiWindow
0032     {
0033         Q_OBJECT
0034 
0035     public:
0036         /** constructor of MainWindow, calls all init functions to create the application.
0037          * @see initMenuBar initToolBar
0038          */
0039         MainWindow();
0040         ~MainWindow() override;
0041 
0042         /** opens a file specified by commandline option */
0043         Doc* openDocument( const QUrl& url = QUrl() );
0044 
0045         Device::DeviceManager* deviceManager() const;
0046         ExternalBinManager* externalBinManager() const;
0047         KSharedConfig::Ptr config() const;
0048 
0049         /**
0050          * @returns a pointer to the currently visible view or 0 if no project was created
0051          */
0052         View* activeView() const;
0053         /**
0054          * @returns a pointer to the doc associated with the currently visible view or 0 if no project was created
0055          */
0056         Doc* activeDoc() const;
0057 
0058         QList<Doc*> projects() const;
0059 
0060         bool eject();
0061         void showOptionDialog( OptionDialog::ConfigPage page = OptionDialog::Misc );
0062 
0063         /** Creates the main view of the KDockMainWindow instance and initializes the MDI view area including any needed
0064          *  connections.
0065          *  must be called after construction
0066          */
0067         void initView();
0068 
0069     public Q_SLOTS:
0070         K3b::Doc* slotNewAudioDoc();
0071         K3b::Doc* slotNewDataDoc();
0072         K3b::Doc* slotNewMixedDoc();
0073         K3b::Doc* slotNewVcdDoc();
0074         K3b::Doc* slotNewMovixDoc();
0075         K3b::Doc* slotNewVideoDvdDoc();
0076         K3b::Doc* slotContinueMultisession();
0077 
0078         void slotClearProject();
0079 
0080         void slotWriteImage();
0081         void slotWriteImage( const QUrl& url );
0082         void formatMedium( K3b::Device::Device* );
0083         void slotFormatMedium();
0084         void mediaCopy( K3b::Device::Device* );
0085         void slotMediaCopy();
0086         void cddaRip( K3b::Device::Device* );
0087         void slotCddaRip();
0088         void videoDvdRip( K3b::Device::Device* );
0089         void slotVideoDvdRip();
0090         void videoCdRip( K3b::Device::Device* );
0091         void slotVideoCdRip();
0092 
0093         void showDiskInfo( K3b::Device::Device* );
0094 
0095         void slotErrorMessage(const QString&);
0096         void slotWarningMessage(const QString&);
0097 
0098         void slotConfigureKeys();
0099         void slotCheckSystem();
0100         void slotManualCheckSystem();
0101 
0102         void addUrls( const QList<QUrl>& urls );
0103 
0104     Q_SIGNALS:
0105         void initializationInfo( const QString& );
0106         void configChanged( KSharedConfig::Ptr c );
0107 
0108     protected:
0109         /** queryClose is called by KMainWindow on each closeEvent of a window. Against the
0110          * default implementation (only returns true), this overridden function retrieves all modified documents
0111          * from the open document list and asks the user to select which files to save before exiting the application.
0112          * @see KMainWindow#queryClose
0113          * @see KMainWindow#closeEvent
0114          */
0115         bool queryClose() override;
0116 
0117         /** saves the window properties for each open window during session end to the session config file, including saving the currently
0118          * opened file by a temporary filename provided by KApplication.
0119          * @see KMainWindow#saveProperties
0120          */
0121         void saveProperties(KConfigGroup &_cfg) override;
0122 
0123         /** reads the session config file and restores the application's state including the last opened files and documents by reading the
0124          * temporary files saved by saveProperties()
0125          * @see KMainWindow#readProperties
0126          */
0127         void readProperties(const KConfigGroup &_cfg) override;
0128 
0129         /**
0130          * checks if doc is modified and asks the user for saving if so.
0131          * returns false if the user chose cancel.
0132          */
0133         bool canCloseDocument( Doc* );
0134 
0135     private Q_SLOTS:
0136         /** open a file and load it into the document*/
0137         void slotFileOpen();
0138         /** opens a file from the recent files menu */
0139         void slotFileOpenRecent(const QUrl& url);
0140         /** save a document */
0141         void slotFileSave();
0142         /** save a document by a new filename*/
0143         void slotFileSaveAs();
0144         void slotFileSaveAll();
0145         /** asks for saving if the file is modified, then closes the actual file and window*/
0146         void slotFileClose();
0147         void slotFileClose( Doc* doc );
0148         void slotFileCloseAll();
0149 
0150         void slotSettingsConfigure();
0151 
0152         /** checks if the currently visible tab is a k3bview
0153             or not and dis- or enables some actions */
0154         void slotCurrentDocChanged();
0155 
0156         void slotFileQuit();
0157 
0158         /** toggles the statusbar
0159          */
0160         void slotViewStatusBar();
0161 
0162         /** changes the statusbar contents for the standard label permanently, used to indicate current actions.
0163          * @param text the text that is displayed in the statusbar
0164          */
0165         void slotStatusMsg(const QString &text);
0166 
0167         void slotShowMenuBar();
0168 
0169         void slotProjectAddFiles();
0170 
0171         void slotEditToolbars();
0172         void slotNewToolBarConfig();
0173 
0174         void slotDataImportSession();
0175         void slotDataClearImportedSession();
0176         void slotEditBootImages();
0177 
0178         void createClient(K3b::Doc* doc);
0179 
0180         /**
0181          * Run slotCheckSystem with a timer
0182          */
0183         void slotCheckSystemTimed();
0184 
0185     private:
0186         bool fileSave( Doc* doc = 0 );
0187         bool fileSaveAs( Doc* doc = 0 );
0188         void closeProject( Doc* );
0189 
0190         /** save general Options like all bar positions and status as well as the geometry and the recent file list to the configuration
0191          * file
0192          */
0193         void saveOptions();
0194         /** read general Options again and initialize all variables like the recent file list */
0195         void readOptions();
0196 
0197         /** initializes the KActions of the application */
0198         void initActions();
0199 
0200         /** sets up the statusbar for the main window by initializing a statuslabel.
0201          */
0202         void initStatusBar();
0203 
0204         class Private;
0205         Private* d;
0206     };
0207 }
0208 
0209 #endif // K3B_H