File indexing completed on 2024-10-13 04:22:13
0001 /* 0002 SPDX-FileCopyrightText: 2010 Michal Malek <michalm@jabster.pl> 0003 SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 0009 #include "k3bprojectinterface.h" 0010 #include "k3bprojectinterfaceadaptor.h" 0011 #include "k3bburnprogressdialog.h" 0012 #include "k3bdoc.h" 0013 #include "k3bview.h" 0014 #include "k3bmsf.h" 0015 #include "k3bcore.h" 0016 #include "k3bdevicemanager.h" 0017 #include "k3bjob.h" 0018 0019 #include <QTimer> 0020 #include <QDBusConnection> 0021 0022 namespace K3b { 0023 0024 ProjectInterface::ProjectInterface( Doc* doc, const QString& dbusPath ) 0025 : 0026 QObject( doc ), 0027 m_doc( doc ) 0028 { 0029 static int id = 0; 0030 if( !dbusPath.isEmpty() ) { 0031 m_dbusPath = dbusPath; 0032 } 0033 else { 0034 m_dbusPath = QString( "/projects/%1" ).arg( id ); 0035 ++id; 0036 } 0037 0038 new K3bProjectInterfaceAdaptor( this ); 0039 QDBusConnection::sessionBus().registerObject( m_dbusPath, this ); 0040 } 0041 0042 0043 ProjectInterface::~ProjectInterface() 0044 { 0045 QDBusConnection::sessionBus().unregisterObject( m_dbusPath ); 0046 } 0047 0048 0049 QString ProjectInterface::dbusPath() const 0050 { 0051 return m_dbusPath; 0052 } 0053 0054 0055 void ProjectInterface::addUrls( const QStringList& urls ) 0056 { 0057 QList<QUrl> urlList; 0058 for( auto& url : urls ) { urlList.push_back( QUrl::fromUserInput( url ) ); } 0059 m_doc->addUrls( urlList ); 0060 } 0061 0062 0063 void ProjectInterface::addUrl( const QString& url ) 0064 { 0065 m_doc->addUrl( QUrl::fromLocalFile(url) ); 0066 } 0067 0068 0069 void ProjectInterface::burn() 0070 { 0071 // we want to return this method immediately 0072 QTimer::singleShot( 0, m_doc->view(), SLOT(slotBurn()) ); 0073 } 0074 0075 0076 bool ProjectInterface::directBurn() 0077 { 0078 if( m_doc->burner() ) { 0079 JobProgressDialog* dlg = 0; 0080 if( m_doc->onlyCreateImages() ) 0081 dlg = new JobProgressDialog( m_doc->view() ); 0082 else 0083 dlg = new BurnProgressDialog( m_doc->view() ); 0084 0085 Job* job = m_doc->newBurnJob( dlg ); 0086 0087 dlg->startJob( job ); 0088 0089 delete job; 0090 delete dlg; 0091 0092 return true; 0093 } 0094 else 0095 return false; 0096 } 0097 0098 0099 void ProjectInterface::setBurnDevice( const QString& name ) 0100 { 0101 if( Device::Device* dev = k3bcore->deviceManager()->findDevice( name ) ) 0102 m_doc->setBurner( dev ); 0103 } 0104 0105 0106 int ProjectInterface::length() const 0107 { 0108 return m_doc->length().lba(); 0109 } 0110 0111 0112 KIO::filesize_t ProjectInterface::size() const 0113 { 0114 return m_doc->size(); 0115 } 0116 0117 0118 const QString& ProjectInterface::imagePath() const 0119 { 0120 return m_doc->tempDir(); 0121 } 0122 0123 0124 QString ProjectInterface::projectType() const 0125 { 0126 switch( m_doc->type() ) { 0127 case Doc::AudioProject: 0128 return "audiocd"; 0129 case Doc::DataProject: 0130 return "data"; 0131 case Doc::MixedProject: 0132 return "mixedcd"; 0133 case Doc::VcdProject: 0134 return "videocd"; 0135 case Doc::MovixProject: 0136 return "emovix"; 0137 case Doc::VideoDvdProject: 0138 return "videodvd"; 0139 default: 0140 return "unknown"; 0141 } 0142 } 0143 0144 } // namespace K3b 0145 0146 #include "moc_k3bprojectinterface.cpp"