@ -49,16 +49,16 @@ namespace
{
{
return QStringLiteral ( " <a href= \" %1 \" >%2</a> " ) . arg ( url , linkLabel ) ;
return QStringLiteral ( " <a href= \" %1 \" >%2</a> " ) . arg ( url , linkLabel ) ;
}
}
}
enum AdvSettingsCols
enum AdvSettingsCols
{
{
PROPERTY ,
PROPERTY ,
VALUE ,
VALUE ,
COL_COUNT
COL_COUNT
} ;
} ;
enum AdvSettingsRows
{
enum AdvSettingsRows
{
// qBittorrent section
// qBittorrent section
QBITTORRENT_HEADER ,
QBITTORRENT_HEADER ,
# if defined(Q_OS_WIN)
# if defined(Q_OS_WIN)
@ -87,11 +87,15 @@ enum AdvSettingsRows
ASYNC_IO_THREADS ,
ASYNC_IO_THREADS ,
FILE_POOL_SIZE ,
FILE_POOL_SIZE ,
CHECKING_MEM_USAGE ,
CHECKING_MEM_USAGE ,
# if (LIBTORRENT_VERSION_NUM < 20000)
// cache
// cache
DISK_CACHE ,
DISK_CACHE ,
DISK_CACHE_TTL ,
DISK_CACHE_TTL ,
# endif
OS_CACHE ,
OS_CACHE ,
# if (LIBTORRENT_VERSION_NUM < 20000)
COALESCE_RW ,
COALESCE_RW ,
# endif
# if (LIBTORRENT_VERSION_NUM >= 10202)
# if (LIBTORRENT_VERSION_NUM >= 10202)
PIECE_EXTENT_AFFINITY ,
PIECE_EXTENT_AFFINITY ,
# endif
# endif
@ -130,7 +134,8 @@ enum AdvSettingsRows
PEER_TURNOVER_INTERVAL ,
PEER_TURNOVER_INTERVAL ,
ROW_COUNT
ROW_COUNT
} ;
} ;
}
AdvancedSettings : : AdvancedSettings ( QWidget * parent )
AdvancedSettings : : AdvancedSettings ( QWidget * parent )
: QTableWidget ( parent )
: QTableWidget ( parent )
@ -146,13 +151,6 @@ AdvancedSettings::AdvancedSettings(QWidget *parent)
setAlternatingRowColors ( true ) ;
setAlternatingRowColors ( true ) ;
setSelectionMode ( QAbstractItemView : : NoSelection ) ;
setSelectionMode ( QAbstractItemView : : NoSelection ) ;
setEditTriggers ( QAbstractItemView : : NoEditTriggers ) ;
setEditTriggers ( QAbstractItemView : : NoEditTriggers ) ;
// Signals
connect ( & m_spinBoxCache , qOverload < int > ( & QSpinBox : : valueChanged )
, this , & AdvancedSettings : : updateCacheSpinSuffix ) ;
connect ( & m_comboBoxInterface , qOverload < int > ( & QComboBox : : currentIndexChanged )
, this , & AdvancedSettings : : updateInterfaceAddressCombo ) ;
connect ( & m_spinBoxSaveResumeDataInterval , qOverload < int > ( & QSpinBox : : valueChanged )
, this , & AdvancedSettings : : updateSaveResumeDataIntervalSuffix ) ;
// Load settings
// Load settings
loadAdvancedSettings ( ) ;
loadAdvancedSettings ( ) ;
resizeColumnToContents ( 0 ) ;
resizeColumnToContents ( 0 ) ;
@ -192,13 +190,17 @@ void AdvancedSettings::saveAdvancedSettings()
session - > setFilePoolSize ( m_spinBoxFilePoolSize . value ( ) ) ;
session - > setFilePoolSize ( m_spinBoxFilePoolSize . value ( ) ) ;
// Checking Memory Usage
// Checking Memory Usage
session - > setCheckingMemUsage ( m_spinBoxCheckingMemUsage . value ( ) ) ;
session - > setCheckingMemUsage ( m_spinBoxCheckingMemUsage . value ( ) ) ;
# if (LIBTORRENT_VERSION_NUM < 20000)
// Disk write cache
// Disk write cache
session - > setDiskCacheSize ( m_spinBoxCache . value ( ) ) ;
session - > setDiskCacheSize ( m_spinBoxCache . value ( ) ) ;
session - > setDiskCacheTTL ( m_spinBoxCacheTTL . value ( ) ) ;
session - > setDiskCacheTTL ( m_spinBoxCacheTTL . value ( ) ) ;
# endif
// Enable OS cache
// Enable OS cache
session - > setUseOSCache ( m_checkBoxOsCache . isChecked ( ) ) ;
session - > setUseOSCache ( m_checkBoxOsCache . isChecked ( ) ) ;
# if (LIBTORRENT_VERSION_NUM < 20000)
// Coalesce reads & writes
// Coalesce reads & writes
session - > setCoalesceReadWriteEnabled ( m_checkBoxCoalesceRW . isChecked ( ) ) ;
session - > setCoalesceReadWriteEnabled ( m_checkBoxCoalesceRW . isChecked ( ) ) ;
# endif
# if (LIBTORRENT_VERSION_NUM >= 10202)
# if (LIBTORRENT_VERSION_NUM >= 10202)
// Piece extent affinity
// Piece extent affinity
session - > setPieceExtentAffinity ( m_checkBoxPieceExtentAffinity . isChecked ( ) ) ;
session - > setPieceExtentAffinity ( m_checkBoxPieceExtentAffinity . isChecked ( ) ) ;
@ -290,6 +292,7 @@ void AdvancedSettings::saveAdvancedSettings()
session - > setPeerTurnoverInterval ( m_spinBoxPeerTurnoverInterval . value ( ) ) ;
session - > setPeerTurnoverInterval ( m_spinBoxPeerTurnoverInterval . value ( ) ) ;
}
}
# if (LIBTORRENT_VERSION_NUM < 20000)
void AdvancedSettings : : updateCacheSpinSuffix ( int value )
void AdvancedSettings : : updateCacheSpinSuffix ( int value )
{
{
if ( value = = 0 )
if ( value = = 0 )
@ -299,6 +302,7 @@ void AdvancedSettings::updateCacheSpinSuffix(int value)
else
else
m_spinBoxCache . setSuffix ( tr ( " MiB " ) ) ;
m_spinBoxCache . setSuffix ( tr ( " MiB " ) ) ;
}
}
# endif
void AdvancedSettings : : updateSaveResumeDataIntervalSuffix ( const int value )
void AdvancedSettings : : updateSaveResumeDataIntervalSuffix ( const int value )
{
{
@ -422,7 +426,7 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxCheckingMemUsage . setSuffix ( tr ( " MiB " ) ) ;
m_spinBoxCheckingMemUsage . setSuffix ( tr ( " MiB " ) ) ;
addRow ( CHECKING_MEM_USAGE , ( tr ( " Outstanding memory when checking torrents " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#checking_mem_usage " , " (?) " ) )
addRow ( CHECKING_MEM_USAGE , ( tr ( " Outstanding memory when checking torrents " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#checking_mem_usage " , " (?) " ) )
, & m_spinBoxCheckingMemUsage ) ;
, & m_spinBoxCheckingMemUsage ) ;
# if (LIBTORRENT_VERSION_NUM < 20000)
// Disk write cache
// Disk write cache
m_spinBoxCache . setMinimum ( - 1 ) ;
m_spinBoxCache . setMinimum ( - 1 ) ;
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
// When build as 32bit binary, set the maximum at less than 2GB to prevent crashes.
@ -434,6 +438,8 @@ void AdvancedSettings::loadAdvancedSettings()
# endif
# endif
m_spinBoxCache . setValue ( session - > diskCacheSize ( ) ) ;
m_spinBoxCache . setValue ( session - > diskCacheSize ( ) ) ;
updateCacheSpinSuffix ( m_spinBoxCache . value ( ) ) ;
updateCacheSpinSuffix ( m_spinBoxCache . value ( ) ) ;
connect ( & m_spinBoxCache , qOverload < int > ( & QSpinBox : : valueChanged )
, this , & AdvancedSettings : : updateCacheSpinSuffix ) ;
addRow ( DISK_CACHE , ( tr ( " Disk cache " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#cache_size " , " (?) " ) )
addRow ( DISK_CACHE , ( tr ( " Disk cache " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#cache_size " , " (?) " ) )
, & m_spinBoxCache ) ;
, & m_spinBoxCache ) ;
// Disk cache expiry
// Disk cache expiry
@ -443,14 +449,17 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxCacheTTL . setSuffix ( tr ( " s " , " seconds " ) ) ;
m_spinBoxCacheTTL . setSuffix ( tr ( " s " , " seconds " ) ) ;
addRow ( DISK_CACHE_TTL , ( tr ( " Disk cache expiry interval " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#cache_expiry " , " (?) " ) )
addRow ( DISK_CACHE_TTL , ( tr ( " Disk cache expiry interval " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#cache_expiry " , " (?) " ) )
, & m_spinBoxCacheTTL ) ;
, & m_spinBoxCacheTTL ) ;
# endif
// Enable OS cache
// Enable OS cache
m_checkBoxOsCache . setChecked ( session - > useOSCache ( ) ) ;
m_checkBoxOsCache . setChecked ( session - > useOSCache ( ) ) ;
addRow ( OS_CACHE , ( tr ( " Enable OS cache " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode " , " (?) " ) )
addRow ( OS_CACHE , ( tr ( " Enable OS cache " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#disk_io_write_mode " , " (?) " ) )
, & m_checkBoxOsCache ) ;
, & m_checkBoxOsCache ) ;
# if (LIBTORRENT_VERSION_NUM < 20000)
// Coalesce reads & writes
// Coalesce reads & writes
m_checkBoxCoalesceRW . setChecked ( session - > isCoalesceReadWriteEnabled ( ) ) ;
m_checkBoxCoalesceRW . setChecked ( session - > isCoalesceReadWriteEnabled ( ) ) ;
addRow ( COALESCE_RW , ( tr ( " Coalesce reads & writes " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#coalesce_reads " , " (?) " ) )
addRow ( COALESCE_RW , ( tr ( " Coalesce reads & writes " ) + ' ' + makeLink ( " https://www.libtorrent.org/reference-Settings.html#coalesce_reads " , " (?) " ) )
, & m_checkBoxCoalesceRW ) ;
, & m_checkBoxCoalesceRW ) ;
# endif
# if (LIBTORRENT_VERSION_NUM >= 10202)
# if (LIBTORRENT_VERSION_NUM >= 10202)
// Piece extent affinity
// Piece extent affinity
m_checkBoxPieceExtentAffinity . setChecked ( session - > usePieceExtentAffinity ( ) ) ;
m_checkBoxPieceExtentAffinity . setChecked ( session - > usePieceExtentAffinity ( ) ) ;
@ -489,6 +498,8 @@ void AdvancedSettings::loadAdvancedSettings()
m_spinBoxSaveResumeDataInterval . setMinimum ( 0 ) ;
m_spinBoxSaveResumeDataInterval . setMinimum ( 0 ) ;
m_spinBoxSaveResumeDataInterval . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxSaveResumeDataInterval . setMaximum ( std : : numeric_limits < int > : : max ( ) ) ;
m_spinBoxSaveResumeDataInterval . setValue ( session - > saveResumeDataInterval ( ) ) ;
m_spinBoxSaveResumeDataInterval . setValue ( session - > saveResumeDataInterval ( ) ) ;
connect ( & m_spinBoxSaveResumeDataInterval , qOverload < int > ( & QSpinBox : : valueChanged )
, this , & AdvancedSettings : : updateSaveResumeDataIntervalSuffix ) ;
updateSaveResumeDataIntervalSuffix ( m_spinBoxSaveResumeDataInterval . value ( ) ) ;
updateSaveResumeDataIntervalSuffix ( m_spinBoxSaveResumeDataInterval . value ( ) ) ;
addRow ( SAVE_RESUME_DATA_INTERVAL , tr ( " Save resume data interval " , " How often the fastresume file is saved. " ) , & m_spinBoxSaveResumeDataInterval ) ;
addRow ( SAVE_RESUME_DATA_INTERVAL , tr ( " Save resume data interval " , " How often the fastresume file is saved. " ) , & m_spinBoxSaveResumeDataInterval ) ;
// Outgoing port Min
// Outgoing port Min
@ -559,6 +570,8 @@ void AdvancedSettings::loadAdvancedSettings()
m_comboBoxInterface . addItem ( session - > networkInterfaceName ( ) , currentInterface ) ;
m_comboBoxInterface . addItem ( session - > networkInterfaceName ( ) , currentInterface ) ;
m_comboBoxInterface . setCurrentIndex ( i ) ;
m_comboBoxInterface . setCurrentIndex ( i ) ;
}
}
connect ( & m_comboBoxInterface , qOverload < int > ( & QComboBox : : currentIndexChanged )
, this , & AdvancedSettings : : updateInterfaceAddressCombo ) ;
addRow ( NETWORK_IFACE , tr ( " Network Interface " ) , & m_comboBoxInterface ) ;
addRow ( NETWORK_IFACE , tr ( " Network Interface " ) , & m_comboBoxInterface ) ;
// Network interface address
// Network interface address
updateInterfaceAddressCombo ( ) ;
updateInterfaceAddressCombo ( ) ;