2006-09-30 16:02:39 +00:00
/*
2017-05-17 21:14:46 +08:00
* Bittorrent Client using Qt and libtorrent .
* Copyright ( C ) 2017 Mike Tzou ( Chocobo1 )
* Copyright ( C ) 2010 Christophe Dumez < chris @ qbittorrent . org >
2006-09-30 16:02:39 +00:00
*
2007-07-14 14:31:59 +00:00
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation ; either version 2
* of the License , or ( at your option ) any later version .
2006-09-30 16:02:39 +00:00
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2007-07-14 14:31:59 +00:00
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*
2009-04-05 17:00:55 +00:00
* In addition , as a special exception , the copyright holders give permission to
* link this program with the OpenSSL project ' s " OpenSSL " library ( or with
* modified versions of it that use the same license as the " OpenSSL " library ) ,
* and distribute the linked executables . You must obey the GNU General Public
* License in all respects for all of the code used other than " OpenSSL " . If you
* modify file ( s ) , you may extend this exception to your version of the file ( s ) ,
* but you are not obligated to do so . If you do not wish to do so , delete this
* exception statement from your version .
2006-09-30 16:02:39 +00:00
*/
2018-06-14 12:54:23 +03:00
# include "torrentcreatordialog.h"
2016-04-28 19:02:05 +08:00
# include <QCloseEvent>
2006-09-30 16:02:39 +00:00
# include <QFileDialog>
# include <QMessageBox>
2016-04-28 19:02:05 +08:00
# include <QMimeData>
# include <QUrl>
2006-09-30 16:02:39 +00:00
2015-09-25 11:10:05 +03:00
# include "base/bittorrent/session.h"
2016-04-29 17:25:15 +08:00
# include "base/bittorrent/torrentinfo.h"
# include "base/global.h"
2016-04-28 19:02:05 +08:00
# include "base/utils/fs.h"
2018-06-14 12:54:23 +03:00
# include "ui_torrentcreatordialog.h"
2017-12-03 15:32:58 +08:00
# include "utils.h"
2008-11-01 21:42:56 +00:00
2022-03-23 23:56:47 +08:00
# define SETTINGS_KEY(name) u"TorrentCreator / " name
2016-04-28 19:02:05 +08:00
2023-06-28 13:27:24 +02:00
namespace
{
// When the root file/directory of the created torrent is a symlink, we want to keep the symlink name in the torrent.
// On Windows, however, QFileDialog::DontResolveSymlinks disables shortcuts (.lnk files) expansion, making it impossible to pick a file if its path contains a shortcut.
// As of NTFS symlinks, they don't seem to be resolved anyways.
# ifndef Q_OS_WIN
const QFileDialog : : Options FILE_DIALOG_OPTIONS { QFileDialog : : DontResolveSymlinks } ;
# else
const QFileDialog : : Options FILE_DIALOG_OPTIONS { } ;
# endif
}
2022-02-08 06:03:48 +03:00
TorrentCreatorDialog : : TorrentCreatorDialog ( QWidget * parent , const Path & defaultPath )
2016-04-28 19:02:05 +08:00
: QDialog ( parent )
2018-06-14 12:54:23 +03:00
, m_ui ( new Ui : : TorrentCreatorDialog )
2016-04-30 21:02:26 +08:00
, m_creatorThread ( new BitTorrent : : TorrentCreatorThread ( this ) )
2023-06-18 02:02:02 +08:00
, m_storeDialogSize ( SETTINGS_KEY ( u " Size " _s ) )
, m_storePieceSize ( SETTINGS_KEY ( u " PieceSize " _s ) )
, m_storePrivateTorrent ( SETTINGS_KEY ( u " PrivateTorrent " _s ) )
, m_storeStartSeeding ( SETTINGS_KEY ( u " StartSeeding " _s ) )
, m_storeIgnoreRatio ( SETTINGS_KEY ( u " IgnoreRatio " _s ) )
2021-08-08 13:27:22 +08:00
# ifdef QBT_USES_LIBTORRENT2
2023-06-18 02:02:02 +08:00
, m_storeTorrentFormat ( SETTINGS_KEY ( u " TorrentFormat " _s ) )
2020-09-09 15:08:14 +08:00
# else
2023-06-18 02:02:02 +08:00
, m_storeOptimizeAlignment ( SETTINGS_KEY ( u " OptimizeAlignment " _s ) )
, m_paddedFileSizeLimit ( SETTINGS_KEY ( u " PaddedFileSizeLimit " _s ) )
2020-09-09 15:08:14 +08:00
# endif
2023-06-18 02:02:02 +08:00
, m_storeLastAddPath ( SETTINGS_KEY ( u " LastAddPath " _s ) )
, m_storeTrackerList ( SETTINGS_KEY ( u " TrackerList " _s ) )
, m_storeWebSeedList ( SETTINGS_KEY ( u " WebSeedList " _s ) )
, m_storeComments ( SETTINGS_KEY ( u " Comments " _s ) )
, m_storeLastSavePath ( SETTINGS_KEY ( u " LastSavePath " _s ) )
, m_storeSource ( SETTINGS_KEY ( u " Source " _s ) )
2016-04-28 19:02:05 +08:00
{
m_ui - > setupUi ( this ) ;
m_ui - > buttonBox - > button ( QDialogButtonBox : : Ok ) - > setText ( tr ( " Create Torrent " ) ) ;
2023-07-02 12:56:41 +08:00
m_ui - > textInputPath - > setMode ( FileSystemPathEdit : : Mode : : ReadOnly ) ;
2016-04-28 19:02:05 +08:00
2018-06-14 12:54:23 +03:00
connect ( m_ui - > addFileButton , & QPushButton : : clicked , this , & TorrentCreatorDialog : : onAddFileButtonClicked ) ;
connect ( m_ui - > addFolderButton , & QPushButton : : clicked , this , & TorrentCreatorDialog : : onAddFolderButtonClicked ) ;
connect ( m_ui - > buttonBox , & QDialogButtonBox : : accepted , this , & TorrentCreatorDialog : : onCreateButtonClicked ) ;
connect ( m_ui - > buttonCalcTotalPieces , & QPushButton : : clicked , this , & TorrentCreatorDialog : : updatePiecesCount ) ;
2017-11-21 18:07:55 +08:00
2018-06-14 12:54:23 +03:00
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 ) ;
2016-04-30 21:02:26 +08:00
2015-06-24 12:19:42 +02:00
loadSettings ( ) ;
2016-04-30 18:43:41 +08:00
updateInputPath ( defaultPath ) ;
2021-08-08 13:27:22 +08:00
# ifdef QBT_USES_LIBTORRENT2
2020-09-09 15:08:14 +08:00
m_ui - > checkOptimizeAlignment - > hide ( ) ;
# else
m_ui - > widgetTorrentFormat - > hide ( ) ;
# endif
2006-09-30 16:02:39 +00:00
}
2018-06-14 12:54:23 +03:00
TorrentCreatorDialog : : ~ TorrentCreatorDialog ( )
2015-06-24 12:19:42 +02:00
{
2016-04-28 19:02:05 +08:00
saveSettings ( ) ;
delete m_ui ;
2007-12-31 16:57:35 +00:00
}
2022-02-08 06:03:48 +03:00
void TorrentCreatorDialog : : updateInputPath ( const Path & path )
2016-04-30 18:43:41 +08:00
{
if ( path . isEmpty ( ) ) return ;
2023-07-02 12:56:41 +08:00
m_ui - > textInputPath - > setSelectedPath ( path ) ;
2016-04-30 18:43:41 +08:00
updateProgressBar ( 0 ) ;
}
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : onAddFolderButtonClicked ( )
2015-06-24 12:19:42 +02:00
{
2023-07-02 12:56:41 +08:00
const QString oldPath = m_ui - > textInputPath - > selectedPath ( ) . data ( ) ;
2023-06-28 13:27:24 +02:00
const Path path { QFileDialog : : getExistingDirectory ( this , tr ( " Select folder " )
, oldPath , ( QFileDialog : : ShowDirsOnly | FILE_DIALOG_OPTIONS ) ) } ;
2016-04-30 18:43:41 +08:00
updateInputPath ( path ) ;
2007-04-04 18:55:38 +00:00
}
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : onAddFileButtonClicked ( )
2015-06-24 12:19:42 +02:00
{
2023-07-02 12:56:41 +08:00
const QString oldPath = m_ui - > textInputPath - > selectedPath ( ) . data ( ) ;
2023-06-28 13:27:24 +02:00
const Path path { QFileDialog : : getOpenFileName ( this , tr ( " Select file " ) , oldPath , QString ( ) , nullptr , FILE_DIALOG_OPTIONS ) } ;
2016-04-30 18:43:41 +08:00
updateInputPath ( path ) ;
2007-04-04 18:55:38 +00:00
}
2018-06-14 12:54:23 +03:00
int TorrentCreatorDialog : : getPieceSize ( ) const
2015-06-24 12:19:42 +02:00
{
2018-01-09 13:04:17 +08:00
const int pieceSizes [ ] = { 0 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 , 2048 , 4096 , 8192 , 16384 , 32768 } ; // base unit in KiB
2016-04-28 19:02:05 +08:00
return pieceSizes [ m_ui - > comboPieceSize - > currentIndex ( ) ] * 1024 ;
}
2021-08-08 13:27:22 +08:00
# ifdef QBT_USES_LIBTORRENT2
2020-09-09 15:08:14 +08:00
BitTorrent : : TorrentFormat TorrentCreatorDialog : : getTorrentFormat ( ) const
{
2020-11-16 10:02:11 +03:00
switch ( m_ui - > comboTorrentFormat - > currentIndex ( ) )
{
2020-09-09 15:08:14 +08:00
case 0 :
return BitTorrent : : TorrentFormat : : V2 ;
case 1 :
return BitTorrent : : TorrentFormat : : Hybrid ;
case 2 :
return BitTorrent : : TorrentFormat : : V1 ;
}
return BitTorrent : : TorrentFormat : : Hybrid ;
}
# else
2019-09-10 00:59:43 +08:00
int TorrentCreatorDialog : : getPaddedFileSizeLimit ( ) const
{
const int value = m_ui - > spinPaddedFileSizeLimit - > value ( ) ;
return ( ( value > = 0 ) ? ( value * 1024 ) : - 1 ) ;
}
2020-09-09 15:08:14 +08:00
# endif
2019-09-10 00:59:43 +08:00
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : dropEvent ( QDropEvent * event )
2016-04-28 19:02:05 +08:00
{
event - > acceptProposedAction ( ) ;
2020-11-16 10:02:11 +03:00
if ( event - > mimeData ( ) - > hasUrls ( ) )
{
2016-04-28 19:02:05 +08:00
// only take the first one
2022-02-08 06:03:48 +03:00
const QUrl firstItem = event - > mimeData ( ) - > urls ( ) . first ( ) ;
const Path path {
2022-03-12 22:00:58 +08:00
( firstItem . scheme ( ) . compare ( u " file " , Qt : : CaseInsensitive ) = = 0 )
2022-02-08 06:03:48 +03:00
? firstItem . toLocalFile ( ) : firstItem . toString ( )
} ;
2016-04-30 18:43:41 +08:00
updateInputPath ( path ) ;
2016-04-28 19:02:05 +08:00
}
}
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : dragEnterEvent ( QDragEnterEvent * event )
2016-04-28 19:02:05 +08:00
{
2023-06-18 02:02:02 +08:00
if ( event - > mimeData ( ) - > hasFormat ( u " text/plain " _s ) | | event - > mimeData ( ) - > hasFormat ( u " text/uri-list " _s ) )
2016-04-28 19:02:05 +08:00
event - > acceptProposedAction ( ) ;
2007-04-04 18:55:38 +00:00
}
2006-09-30 16:02:39 +00:00
// Main function that create a .torrent file
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : onCreateButtonClicked ( )
2015-06-24 12:19:42 +02:00
{
2023-06-28 13:27:24 +02:00
# ifdef Q_OS_WIN
// Resolve the path in case it contains a shortcut (otherwise, the following usages will consider it invalid)
2023-07-02 12:56:41 +08:00
const Path inputPath = Utils : : Fs : : toCanonicalPath ( m_ui - > textInputPath - > selectedPath ( ) ) ;
2023-06-28 13:27:24 +02:00
# else
2023-07-02 12:56:41 +08:00
const Path inputPath = m_ui - > textInputPath - > selectedPath ( ) ;
2023-06-28 13:27:24 +02:00
# endif
2016-04-28 19:02:05 +08:00
// test if readable
2022-02-08 06:03:48 +03:00
if ( ! Utils : : Fs : : isReadable ( inputPath ) )
2020-11-16 10:02:11 +03:00
{
2017-10-24 03:15:53 +03:00
QMessageBox : : critical ( this , tr ( " Torrent creation failed " ) , tr ( " Reason: Path to file/folder is not readable. " ) ) ;
2015-06-24 12:19:42 +02:00
return ;
}
2016-04-28 19:02:05 +08:00
// get save path
2022-06-26 19:25:48 +08:00
const Path lastSavePath = ( m_storeLastSavePath . get ( Utils : : Fs : : homePath ( ) ) / Path ( inputPath . filename ( ) + u " .torrent " ) ) ;
Path destPath { QFileDialog : : getSaveFileName ( this , tr ( " Select where to save the new torrent " ) , lastSavePath . data ( ) , tr ( " Torrent Files (*.torrent) " ) ) } ;
2022-02-08 06:03:48 +03:00
if ( destPath . isEmpty ( ) )
2015-06-24 12:19:42 +02:00
return ;
2022-03-04 13:25:22 +08:00
if ( ! destPath . hasExtension ( TORRENT_FILE_EXTENSION ) )
destPath + = TORRENT_FILE_EXTENSION ;
2022-02-08 06:03:48 +03:00
m_storeLastSavePath = destPath . parentPath ( ) ;
2010-08-13 14:02:19 +00:00
2016-04-28 19:02:05 +08:00
// Disable dialog & set busy cursor
2015-06-24 12:19:42 +02:00
setInteractionEnabled ( false ) ;
setCursor ( QCursor ( Qt : : WaitCursor ) ) ;
2016-04-28 19:02:05 +08:00
2017-12-05 23:17:29 +08:00
const QStringList trackers = m_ui - > trackersList - > toPlainText ( ) . trimmed ( )
2023-06-18 02:02:02 +08:00
. replace ( QRegularExpression ( u " \n \n [ \n ]+ " _s ) , u " \n \n " _s ) . split ( u ' \n ' ) ;
2020-11-16 10:02:11 +03:00
const BitTorrent : : TorrentCreatorParams params
{
2019-09-10 00:59:43 +08:00
m_ui - > checkPrivate - > isChecked ( )
2021-08-08 13:27:22 +08:00
# ifdef QBT_USES_LIBTORRENT2
2020-09-09 15:08:14 +08:00
, getTorrentFormat ( )
# else
2019-09-10 00:59:43 +08:00
, m_ui - > checkOptimizeAlignment - > isChecked ( )
2020-09-09 15:08:14 +08:00
, getPaddedFileSizeLimit ( )
# endif
, getPieceSize ( )
2022-02-08 06:03:48 +03:00
, inputPath
, destPath
2019-09-10 00:59:43 +08:00
, m_ui - > txtComment - > toPlainText ( )
, m_ui - > lineEditSource - > text ( )
, trackers
2022-03-12 22:00:58 +08:00
, m_ui - > URLSeedsList - > toPlainText ( ) . split ( u ' \n ' , Qt : : SkipEmptyParts )
2019-09-10 00:59:43 +08:00
} ;
2016-04-28 19:02:05 +08:00
2016-04-30 21:02:26 +08:00
// run the creator thread
2019-09-10 00:59:43 +08:00
m_creatorThread - > create ( params ) ;
2007-12-31 16:57:35 +00:00
}
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : handleCreationFailure ( const QString & msg )
2015-06-24 12:19:42 +02:00
{
// Remove busy cursor
setCursor ( QCursor ( Qt : : ArrowCursor ) ) ;
2017-10-24 03:15:53 +03:00
QMessageBox : : information ( this , tr ( " Torrent creation failed " ) , tr ( " Reason: %1 " ) . arg ( msg ) ) ;
2015-06-24 12:19:42 +02:00
setInteractionEnabled ( true ) ;
}
2015-04-19 18:17:47 +03:00
2022-02-08 06:03:48 +03:00
void TorrentCreatorDialog : : handleCreationSuccess ( const Path & path , const Path & branchPath )
2015-06-24 12:19:42 +02:00
{
// Remove busy cursor
setCursor ( QCursor ( Qt : : ArrowCursor ) ) ;
2020-11-16 10:02:11 +03:00
if ( m_ui - > checkStartSeeding - > isChecked ( ) )
{
2015-06-24 12:19:42 +02:00
// Create save path temp data
2022-02-08 06:03:48 +03:00
const nonstd : : expected < BitTorrent : : TorrentInfo , QString > result = BitTorrent : : TorrentInfo : : loadFromFile ( path ) ;
2021-10-06 21:45:37 +03:00
if ( ! result )
2020-11-16 10:02:11 +03:00
{
2017-10-24 03:15:53 +03:00
QMessageBox : : critical ( this , tr ( " Torrent creation failed " ) , tr ( " Reason: Created torrent is invalid. It won't be added to download list. " ) ) ;
2015-06-24 12:19:42 +02:00
return ;
}
2015-04-19 18:17:47 +03:00
2015-06-24 12:19:42 +02:00
BitTorrent : : AddTorrentParams params ;
2016-04-28 19:02:05 +08:00
params . savePath = branchPath ;
2015-06-24 12:19:42 +02:00
params . skipChecking = true ;
2020-11-16 10:02:11 +03:00
if ( m_ui - > checkIgnoreShareLimits - > isChecked ( ) )
{
2021-01-06 15:12:40 +03:00
params . ratioLimit = BitTorrent : : Torrent : : NO_RATIO_LIMIT ;
params . seedingTimeLimit = BitTorrent : : Torrent : : NO_SEEDING_TIME_LIMIT ;
2020-08-05 08:31:41 +03:00
}
2021-01-02 16:55:17 +03:00
params . useAutoTMM = false ; // otherwise if it is on by default, it will overwrite `savePath` to the default save path
2015-04-19 18:17:47 +03:00
2021-10-06 21:45:37 +03:00
BitTorrent : : Session : : instance ( ) - > addTorrent ( result . value ( ) , params ) ;
2015-06-24 12:19:42 +02:00
}
2018-03-06 23:49:12 +08:00
QMessageBox : : information ( this , tr ( " Torrent creator " )
2023-06-18 02:02:02 +08:00
, u " %1 \n %2 " _s . arg ( tr ( " Torrent created: " ) , path . toString ( ) ) ) ;
2016-04-30 18:43:41 +08:00
setInteractionEnabled ( true ) ;
2010-06-17 17:52:14 +00:00
}
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : updateProgressBar ( int progress )
2015-06-24 12:19:42 +02:00
{
2016-04-28 19:02:05 +08:00
m_ui - > progressBar - > setValue ( progress ) ;
2007-12-31 16:57:35 +00:00
}
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : updatePiecesCount ( )
2017-05-25 22:48:10 +08:00
{
2023-07-02 12:56:41 +08:00
const Path path = m_ui - > textInputPath - > selectedPath ( ) ;
2021-08-08 13:27:22 +08:00
# ifdef QBT_USES_LIBTORRENT2
2020-09-09 15:08:14 +08:00
const int count = BitTorrent : : TorrentCreatorThread : : calculateTotalPieces (
path , getPieceSize ( ) , getTorrentFormat ( ) ) ;
# else
2018-04-14 20:00:08 +03:00
const bool isAlignmentOptimized = m_ui - > checkOptimizeAlignment - > isChecked ( ) ;
2019-09-10 00:59:43 +08:00
const int count = BitTorrent : : TorrentCreatorThread : : calculateTotalPieces ( path
, getPieceSize ( ) , isAlignmentOptimized , getPaddedFileSizeLimit ( ) ) ;
2020-09-09 15:08:14 +08:00
# endif
2017-05-25 22:48:10 +08:00
m_ui - > labelTotalPieces - > setText ( QString : : number ( count ) ) ;
}
2019-09-10 00:59:43 +08:00
void TorrentCreatorDialog : : setInteractionEnabled ( const bool enabled ) const
2010-10-25 19:34:42 +00:00
{
2016-04-28 19:02:05 +08:00
m_ui - > textInputPath - > setEnabled ( enabled ) ;
2017-05-17 21:14:46 +08:00
m_ui - > addFileButton - > setEnabled ( enabled ) ;
m_ui - > addFolderButton - > setEnabled ( enabled ) ;
m_ui - > trackersList - > setEnabled ( enabled ) ;
m_ui - > URLSeedsList - > setEnabled ( enabled ) ;
m_ui - > txtComment - > setEnabled ( enabled ) ;
2016-04-28 19:02:05 +08:00
m_ui - > comboPieceSize - > setEnabled ( enabled ) ;
2019-09-10 00:59:43 +08:00
m_ui - > buttonCalcTotalPieces - > setEnabled ( enabled ) ;
2017-05-17 21:14:46 +08:00
m_ui - > checkPrivate - > setEnabled ( enabled ) ;
2016-04-28 19:02:05 +08:00
m_ui - > checkStartSeeding - > setEnabled ( enabled ) ;
m_ui - > buttonBox - > button ( QDialogButtonBox : : Ok ) - > setEnabled ( enabled ) ;
m_ui - > checkIgnoreShareLimits - > setEnabled ( enabled & & m_ui - > checkStartSeeding - > isChecked ( ) ) ;
2021-08-08 13:27:22 +08:00
# ifdef QBT_USES_LIBTORRENT2
2020-09-09 15:08:14 +08:00
m_ui - > widgetTorrentFormat - > setEnabled ( enabled ) ;
# else
2019-09-10 00:59:43 +08:00
m_ui - > checkOptimizeAlignment - > setEnabled ( enabled ) ;
m_ui - > spinPaddedFileSizeLimit - > setEnabled ( enabled ) ;
2020-09-09 15:08:14 +08:00
# endif
2010-10-25 19:34:42 +00:00
}
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : saveSettings ( )
2010-10-25 19:34:42 +00:00
{
2023-07-02 12:56:41 +08:00
m_storeLastAddPath = m_ui - > textInputPath - > selectedPath ( ) ;
2016-04-28 19:02:05 +08:00
2016-05-04 17:56:51 +08:00
m_storePieceSize = m_ui - > comboPieceSize - > currentIndex ( ) ;
2017-05-17 21:14:46 +08:00
m_storePrivateTorrent = m_ui - > checkPrivate - > isChecked ( ) ;
2016-05-04 17:56:51 +08:00
m_storeStartSeeding = m_ui - > checkStartSeeding - > isChecked ( ) ;
m_storeIgnoreRatio = m_ui - > checkIgnoreShareLimits - > isChecked ( ) ;
2021-08-08 13:27:22 +08:00
# ifdef QBT_USES_LIBTORRENT2
2020-09-09 15:08:14 +08:00
m_storeTorrentFormat = m_ui - > comboTorrentFormat - > currentIndex ( ) ;
# else
2018-04-14 03:24:08 +03:00
m_storeOptimizeAlignment = m_ui - > checkOptimizeAlignment - > isChecked ( ) ;
2019-09-10 00:59:43 +08:00
m_paddedFileSizeLimit = m_ui - > spinPaddedFileSizeLimit - > value ( ) ;
2020-09-09 15:08:14 +08:00
# endif
2016-04-28 19:02:05 +08:00
2017-05-17 21:14:46 +08:00
m_storeTrackerList = m_ui - > trackersList - > toPlainText ( ) ;
m_storeWebSeedList = m_ui - > URLSeedsList - > toPlainText ( ) ;
m_storeComments = m_ui - > txtComment - > toPlainText ( ) ;
2017-12-05 21:18:18 +08:00
m_storeSource = m_ui - > lineEditSource - > text ( ) ;
2016-04-28 19:02:05 +08:00
2016-05-04 17:56:51 +08:00
m_storeDialogSize = size ( ) ;
2009-07-23 09:11:05 +00:00
}
2018-06-14 12:54:23 +03:00
void TorrentCreatorDialog : : loadSettings ( )
2010-10-25 19:34:42 +00:00
{
2023-07-02 12:56:41 +08:00
m_ui - > textInputPath - > setSelectedPath ( m_storeLastAddPath . get ( Utils : : Fs : : homePath ( ) ) ) ;
2016-04-28 19:02:05 +08:00
2016-05-04 17:56:51 +08:00
m_ui - > comboPieceSize - > setCurrentIndex ( m_storePieceSize ) ;
2017-05-17 21:14:46 +08:00
m_ui - > checkPrivate - > setChecked ( m_storePrivateTorrent ) ;
2016-05-04 17:56:51 +08:00
m_ui - > checkStartSeeding - > setChecked ( m_storeStartSeeding ) ;
m_ui - > checkIgnoreShareLimits - > setChecked ( m_storeIgnoreRatio ) ;
2016-04-28 19:02:05 +08:00
m_ui - > checkIgnoreShareLimits - > setEnabled ( m_ui - > checkStartSeeding - > isChecked ( ) ) ;
2021-08-08 13:27:22 +08:00
# ifdef QBT_USES_LIBTORRENT2
2020-12-28 23:32:59 +08:00
m_ui - > comboTorrentFormat - > setCurrentIndex ( m_storeTorrentFormat . get ( 1 ) ) ;
2020-09-09 15:08:14 +08:00
# else
2020-12-28 23:32:59 +08:00
m_ui - > checkOptimizeAlignment - > setChecked ( m_storeOptimizeAlignment . get ( true ) ) ;
m_ui - > spinPaddedFileSizeLimit - > setValue ( m_paddedFileSizeLimit . get ( - 1 ) ) ;
2020-09-09 15:08:14 +08:00
# endif
2016-04-28 19:02:05 +08:00
2017-05-17 21:14:46 +08:00
m_ui - > trackersList - > setPlainText ( m_storeTrackerList ) ;
m_ui - > URLSeedsList - > setPlainText ( m_storeWebSeedList ) ;
m_ui - > txtComment - > setPlainText ( m_storeComments ) ;
2017-12-05 21:18:18 +08:00
m_ui - > lineEditSource - > setText ( m_storeSource ) ;
2010-12-04 10:31:14 +00:00
2022-06-02 20:41:42 +08:00
if ( const QSize dialogSize = m_storeDialogSize ; dialogSize . isValid ( ) )
resize ( dialogSize ) ;
2010-12-04 10:31:14 +00:00
}