File indexing completed on 2024-10-06 04:25:58
0001 /* 0002 SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "k3bdevicemenu.h" 0007 #include "k3b.h" 0008 #include "k3bapplication.h" 0009 #include "k3bappdevicemanager.h" 0010 #include "projects/k3bdatamultisessionimportdialog.h" 0011 #include "misc/k3bmediaformattingdialog.h" 0012 #include "misc/k3bmediacopydialog.h" 0013 0014 #include "k3bmedium.h" 0015 #include "k3bdevice.h" 0016 #include "k3bmediacache.h" 0017 #include "k3bdevicehandler.h" 0018 0019 #include <KLocalizedString> 0020 #include <KActionCollection> 0021 #include <QIcon> 0022 #include <QAction> 0023 0024 0025 class K3b::DeviceMenu::Private 0026 { 0027 public: 0028 Private( DeviceMenu* parent ); 0029 0030 void _k_aboutToShow(); 0031 0032 void _k_copy(); 0033 void _k_format(); 0034 void _k_ripAudio(); 0035 void _k_ripVcd(); 0036 void _k_ripVideoDVD(); 0037 void _k_continueMultisession(); 0038 0039 private: 0040 DeviceMenu* q; 0041 QAction* actionContinueMultisession; 0042 QAction* actionCopy; 0043 QAction* actionFormat; 0044 QAction* actionRipAudio; 0045 QAction* actionRipVideoDVD; 0046 QAction* actionRipVcd; 0047 }; 0048 0049 0050 K3b::DeviceMenu::Private::Private( DeviceMenu* parent ) 0051 : 0052 q( parent ) 0053 { 0054 KActionCollection* dmActions = k3bappcore->appDeviceManager()->actionCollection(); 0055 q->addAction( dmActions->action( "device_diskinfo" ) ); 0056 q->addSeparator(); 0057 q->addAction( dmActions->action( "device_unmount" ) ); 0058 q->addAction( dmActions->action( "device_mount" ) ); 0059 q->addAction( dmActions->action( "device_eject" ) ); 0060 q->addAction( dmActions->action( "device_load" ) ); 0061 q->addSeparator(); 0062 q->addAction( dmActions->action( "device_set_read_speed" ) ); 0063 0064 q->addSeparator(); 0065 0066 // FIXME: Should we move these actions to K3b::AppDeviceManager? 0067 actionContinueMultisession = q->addAction( QIcon::fromTheme( "media-optical-data" ), i18n("Continue Multisession Project"), q, SLOT(_k_continueMultisession()) ); 0068 actionCopy = q->addAction( QIcon::fromTheme( "tools-media-optical-copy" ), i18n("Copy &Medium..."), q, SLOT(_k_copy()) ); 0069 actionFormat = q->addAction( QIcon::fromTheme( "tools-media-optical-erase" ), i18n("&Format/Erase rewritable disk..."), q, SLOT(_k_format()) ); 0070 actionRipAudio = q->addAction( QIcon::fromTheme( "tools-rip-audio-cd" ), i18n("Rip Audio CD..."), q, SLOT(_k_ripAudio()) ); 0071 actionRipVideoDVD = q->addAction( QIcon::fromTheme( "tools-rip-video-dvd" ), i18n("Rip Video DVD..."), q, SLOT(_k_ripVideoDVD()) ); 0072 actionRipVcd = q->addAction( QIcon::fromTheme( "tools-rip-video-cd"), i18n("Rip Video CD..."), q, SLOT(_k_ripVcd()) ); 0073 0074 actionCopy->setToolTip( i18n("Open the media copy dialog") ); 0075 actionCopy->setStatusTip( actionCopy->toolTip() ); 0076 actionFormat->setToolTip( i18n("Open the rewritable disk formatting/erasing dialog") ); 0077 actionFormat->setStatusTip( actionFormat->toolTip() ); 0078 } 0079 0080 0081 void K3b::DeviceMenu::Private::_k_aboutToShow() 0082 { 0083 K3b::Medium medium = k3bcore->mediaCache()->medium( k3bappcore->appDeviceManager()->currentDevice() ); 0084 0085 actionContinueMultisession->setVisible( 0086 medium.content() == K3b::Medium::ContentData && 0087 medium.diskInfo().appendable() ); 0088 0089 // non-empty cd/dvd/bd: copy 0090 actionCopy->setVisible( !medium.diskInfo().empty() ); 0091 0092 // rewritable: erase/format 0093 actionFormat->setVisible ( 0094 !medium.diskInfo().empty() && 0095 medium.diskInfo().rewritable() && 0096 medium.diskInfo().mediaType() != K3b::Device::MEDIA_DVD_PLUS_RW ); 0097 0098 // audio content: rip audio 0099 actionRipAudio->setVisible( medium.content() & K3b::Medium::ContentAudio ); 0100 0101 // video dvd: videodvd rip 0102 actionRipVideoDVD->setVisible( medium.content() & K3b::Medium::ContentVideoDVD ); 0103 0104 // video cd: vcd rip 0105 actionRipVcd->setVisible( medium.content() & K3b::Medium::ContentVideoCD ); 0106 } 0107 0108 0109 void K3b::DeviceMenu::Private::_k_copy() 0110 { 0111 K3b::MediaCopyDialog d( qApp->activeWindow() ); 0112 d.setReadingDevice( k3bappcore->appDeviceManager()->currentDevice() ); 0113 d.exec(); 0114 } 0115 0116 0117 void K3b::DeviceMenu::Private::_k_format() 0118 { 0119 K3b::MediaFormattingDialog d( qApp->activeWindow() ); 0120 d.setDevice( k3bappcore->appDeviceManager()->currentDevice() ); 0121 d.exec(); 0122 } 0123 0124 0125 void K3b::DeviceMenu::Private::_k_ripAudio() 0126 { 0127 k3bappcore->k3bMainWindow()->cddaRip( k3bappcore->appDeviceManager()->currentDevice() ); 0128 } 0129 0130 0131 void K3b::DeviceMenu::Private::_k_ripVcd() 0132 { 0133 k3bappcore->k3bMainWindow()->videoCdRip( k3bappcore->appDeviceManager()->currentDevice() ); 0134 } 0135 0136 0137 void K3b::DeviceMenu::Private::_k_ripVideoDVD() 0138 { 0139 k3bappcore->k3bMainWindow()->videoDvdRip( k3bappcore->appDeviceManager()->currentDevice() ); 0140 } 0141 0142 0143 void K3b::DeviceMenu::Private::_k_continueMultisession() 0144 { 0145 K3b::DataMultisessionImportDialog::importSession( 0, qApp->activeWindow() ); 0146 } 0147 0148 0149 K3b::DeviceMenu::DeviceMenu( QWidget* parent ) 0150 : QMenu( parent ), 0151 d( new Private(this) ) 0152 { 0153 connect( this, SIGNAL(aboutToShow()), 0154 this, SLOT(_k_aboutToShow()) ); 0155 } 0156 0157 0158 K3b::DeviceMenu::~DeviceMenu() 0159 { 0160 delete d; 0161 } 0162 0163 #include "moc_k3bdevicemenu.cpp"