@ -59,7 +59,7 @@ namespace
TorrentCreatorDialog : : TorrentCreatorDialog ( QWidget * parent , const Path & defaultPath )
TorrentCreatorDialog : : TorrentCreatorDialog ( QWidget * parent , const Path & defaultPath )
: QDialog ( parent )
: QDialog ( parent )
, m_ui ( new Ui : : TorrentCreatorDialog )
, m_ui ( new Ui : : TorrentCreatorDialog )
, m_creatorThread ( new BitTorrent : : TorrentCreatorThread ( this ) )
, m_threadPool ( this )
, m_storeDialogSize ( SETTINGS_KEY ( u " Size " _s ) )
, m_storeDialogSize ( SETTINGS_KEY ( u " Size " _s ) )
, m_storePieceSize ( SETTINGS_KEY ( u " PieceSize " _s ) )
, m_storePieceSize ( SETTINGS_KEY ( u " PieceSize " _s ) )
, m_storePrivateTorrent ( SETTINGS_KEY ( u " PrivateTorrent " _s ) )
, m_storePrivateTorrent ( SETTINGS_KEY ( u " PrivateTorrent " _s ) )
@ -90,13 +90,11 @@ TorrentCreatorDialog::TorrentCreatorDialog(QWidget *parent, const Path &defaultP
connect ( m_ui - > buttonCalcTotalPieces , & QPushButton : : clicked , this , & TorrentCreatorDialog : : updatePiecesCount ) ;
connect ( m_ui - > buttonCalcTotalPieces , & QPushButton : : clicked , this , & TorrentCreatorDialog : : updatePiecesCount ) ;
connect ( m_ui - > checkStartSeeding , & QCheckBox : : clicked , m_ui - > checkIgnoreShareLimits , & QWidget : : setEnabled ) ;
connect ( m_ui - > checkStartSeeding , & QCheckBox : : clicked , m_ui - > checkIgnoreShareLimits , & QWidget : : setEnabled ) ;
connect ( m_creatorThread , & BitTorrent : : TorrentCreatorThread : : creationSuccess , this , & TorrentCreatorDialog : : handleCreationSuccess ) ;
connect ( m_creatorThread , & BitTorrent : : TorrentCreatorThread : : creationFailure , this , & TorrentCreatorDialog : : handleCreationFailure ) ;
connect ( m_creatorThread , & BitTorrent : : TorrentCreatorThread : : updateProgress , this , & TorrentCreatorDialog : : updateProgressBar ) ;
loadSettings ( ) ;
loadSettings ( ) ;
updateInputPath ( defaultPath ) ;
updateInputPath ( defaultPath ) ;
m_threadPool . setMaxThreadCount ( 1 ) ;
# ifdef QBT_USES_LIBTORRENT2
# ifdef QBT_USES_LIBTORRENT2
m_ui - > checkOptimizeAlignment - > hide ( ) ;
m_ui - > checkOptimizeAlignment - > hide ( ) ;
# else
# else
@ -233,8 +231,14 @@ void TorrentCreatorDialog::onCreateButtonClicked()
, m_ui - > URLSeedsList - > toPlainText ( ) . split ( u ' \n ' , Qt : : SkipEmptyParts )
, m_ui - > URLSeedsList - > toPlainText ( ) . split ( u ' \n ' , Qt : : SkipEmptyParts )
} ;
} ;
// run the creator thread
auto * torrentCreator = new BitTorrent : : TorrentCreator ( params ) ;
m_creatorThread - > create ( params ) ;
connect ( this , & QDialog : : rejected , torrentCreator , & BitTorrent : : TorrentCreator : : requestInterruption ) ;
connect ( torrentCreator , & BitTorrent : : TorrentCreator : : creationSuccess , this , & TorrentCreatorDialog : : handleCreationSuccess ) ;
connect ( torrentCreator , & BitTorrent : : TorrentCreator : : creationFailure , this , & TorrentCreatorDialog : : handleCreationFailure ) ;
connect ( torrentCreator , & BitTorrent : : TorrentCreator : : updateProgress , this , & TorrentCreatorDialog : : updateProgressBar ) ;
// run the torrentCreator in a thread
m_threadPool . start ( torrentCreator ) ;
}
}
void TorrentCreatorDialog : : handleCreationFailure ( const QString & msg )
void TorrentCreatorDialog : : handleCreationFailure ( const QString & msg )
@ -286,11 +290,11 @@ void TorrentCreatorDialog::updatePiecesCount()
{
{
const Path path = m_ui - > textInputPath - > selectedPath ( ) ;
const Path path = m_ui - > textInputPath - > selectedPath ( ) ;
# ifdef QBT_USES_LIBTORRENT2
# ifdef QBT_USES_LIBTORRENT2
const int count = BitTorrent : : TorrentCreatorThread : : calculateTotalPieces (
const int count = BitTorrent : : TorrentCreator : : calculateTotalPieces (
path , getPieceSize ( ) , getTorrentFormat ( ) ) ;
path , getPieceSize ( ) , getTorrentFormat ( ) ) ;
# else
# else
const bool isAlignmentOptimized = m_ui - > checkOptimizeAlignment - > isChecked ( ) ;
const bool isAlignmentOptimized = m_ui - > checkOptimizeAlignment - > isChecked ( ) ;
const int count = BitTorrent : : TorrentCreatorThread : : calculateTotalPieces ( path
const int count = BitTorrent : : TorrentCreator : : calculateTotalPieces ( path
, getPieceSize ( ) , isAlignmentOptimized , getPaddedFileSizeLimit ( ) ) ;
, getPieceSize ( ) , isAlignmentOptimized , getPaddedFileSizeLimit ( ) ) ;
# endif
# endif
m_ui - > labelTotalPieces - > setText ( QString : : number ( count ) ) ;
m_ui - > labelTotalPieces - > setText ( QString : : number ( count ) ) ;