File indexing completed on 2024-10-06 04:26:03
0001 /* 0002 0003 SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 0009 #ifndef K3BTEMPDIRSELECTIONWIDGET_H 0010 #define K3BTEMPDIRSELECTIONWIDGET_H 0011 0012 #include <KConfigGroup> 0013 #include <KIO/Global> 0014 #include <QGroupBox> 0015 #include <QLabel> 0016 0017 class QLabel; 0018 class KUrlRequester; 0019 0020 0021 /** 0022 *@author Sebastian Trueg 0023 */ 0024 namespace K3b { 0025 class TempDirSelectionWidget : public QGroupBox 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit TempDirSelectionWidget( QWidget *parent = 0 ); 0031 ~TempDirSelectionWidget() override; 0032 0033 /** determines if the selection dialog should ask for a dir or a file */ 0034 enum mode { DIR, FILE }; 0035 0036 int selectionMode() const { return m_mode; } 0037 0038 /** 0039 * \return Free space in bytes 0040 */ 0041 KIO::filesize_t freeTempSpace() const; 0042 QString tempPath() const; 0043 QString tempDirectory() const; 0044 0045 /** 0046 * Use this if you don't want TempDirSelectionWidget to modify the 0047 * user input based on the mode. 0048 */ 0049 QString plainTempPath() const; 0050 0051 void setImageFileLabel(const QString &label); 0052 0053 public Q_SLOTS: 0054 void setTempPath( const QString& ); 0055 void setSelectionMode( int mode ); 0056 void setNeededSize( KIO::filesize_t bytes ); 0057 0058 /** 0059 * In file selection mode if the user enters a directory name it will 0060 * automatically be expended to this filename. 0061 * Default is k3b_image.iso 0062 */ 0063 void setDefaultImageFileName( const QString& name, bool forceChange = false ); 0064 0065 /** 0066 * saves the current path as the global default temp dir. 0067 */ 0068 void saveConfig(); 0069 0070 void readConfig( const KConfigGroup& ); 0071 void saveConfig( KConfigGroup ); 0072 0073 private Q_SLOTS: 0074 void slotUpdateFreeTempSpace(); 0075 void slotFixTempPath(); 0076 0077 private: 0078 void fixTempPath( bool forceNewImageName ); 0079 0080 QLabel* m_imageFileLabel; 0081 QLabel* m_labelCdSize; 0082 QLabel* m_labelFreeSpace; 0083 KUrlRequester* m_editDirectory; 0084 0085 KIO::filesize_t m_requestedSize; 0086 0087 int m_mode; 0088 0089 QString m_defaultImageFileName; 0090 }; 0091 } 0092 0093 #endif