Use qt5 connect() syntax

This commit is contained in:
thalieht
2018-04-18 16:59:41 +03:00
parent 7af83ab704
commit 6b4455e13d
37 changed files with 198 additions and 175 deletions

View File

@@ -118,7 +118,7 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
resizeColumnToContents(i);
// Context menu
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPeerListMenu(QPoint)));
connect(this, &QWidget::customContextMenuRequested, this, &PeerListWidget::showPeerListMenu);
// List delegate
m_listDelegate = new PeerListDelegate(this);
setItemDelegate(m_listDelegate);
@@ -128,10 +128,11 @@ PeerListWidget::PeerListWidget(PropertiesWidget *parent)
updatePeerHostNameResolutionState();
// SIGNAL/SLOT
header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayToggleColumnsMenu(const QPoint&)));
connect(header(), SIGNAL(sectionClicked(int)), SLOT(handleSortColumnChanged(int)));
connect(header(), &QWidget::customContextMenuRequested, this, &PeerListWidget::displayToggleColumnsMenu);
connect(header(), &QHeaderView::sectionClicked, this, &PeerListWidget::handleSortColumnChanged);
handleSortColumnChanged(header()->sortIndicatorSection());
m_copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copySelectedPeers()), nullptr, Qt::WidgetShortcut);
m_copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_copyHotkey, &QShortcut::activated, this, &PeerListWidget::copySelectedPeers);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777
@@ -192,7 +193,7 @@ void PeerListWidget::updatePeerHostNameResolutionState()
if (Preferences::instance()->resolvePeerHostNames()) {
if (!m_resolver) {
m_resolver = new Net::ReverseResolution(this);
connect(m_resolver, SIGNAL(ipResolved(QString,QString)), SLOT(handleResolved(QString,QString)));
connect(m_resolver.data(), &Net::ReverseResolution::ipResolved, this, &PeerListWidget::handleResolved);
loadPeers(m_properties->getCurrentTorrent(), true);
}
}

View File

@@ -38,7 +38,7 @@ PeersAdditionDlg::PeersAdditionDlg(QWidget *parent)
, m_ui(new Ui::addPeersDialog())
{
m_ui->setupUi(this);
connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(validateInput()));
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &PeersAdditionDlg::validateInput);
}
PeersAdditionDlg::~PeersAdditionDlg()

View File

@@ -93,25 +93,26 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
m_contentFilterLine = new LineEdit(this);
m_contentFilterLine->setPlaceholderText(tr("Filter files..."));
m_contentFilterLine->setFixedWidth(Utils::Gui::scaledSize(this, 300));
connect(m_contentFilterLine, SIGNAL(textChanged(QString)), this, SLOT(filterText(QString)));
connect(m_contentFilterLine, &LineEdit::textChanged, this, &PropertiesWidget::filterText);
m_ui->contentFilterLayout->insertWidget(3, m_contentFilterLine);
// SIGNAL/SLOTS
connect(m_ui->filesList, SIGNAL(clicked(const QModelIndex&)), m_ui->filesList, SLOT(edit(const QModelIndex&)));
connect(m_ui->selectAllButton, SIGNAL(clicked()), m_propListModel, SLOT(selectAll()));
connect(m_ui->selectNoneButton, SIGNAL(clicked()), m_propListModel, SLOT(selectNone()));
connect(m_ui->filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&)));
connect(m_ui->filesList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(openDoubleClickedFile(const QModelIndex&)));
connect(m_propListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
connect(m_ui->listWebSeeds, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayWebSeedListMenu(const QPoint&)));
connect(transferList, SIGNAL(currentTorrentChanged(BitTorrent::TorrentHandle *const)), this, SLOT(loadTorrentInfos(BitTorrent::TorrentHandle *const)));
connect(m_propListDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
connect(m_ui->stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
connect(BitTorrent::Session::instance(), SIGNAL(torrentSavePathChanged(BitTorrent::TorrentHandle *const)), this, SLOT(updateSavePath(BitTorrent::TorrentHandle *const)));
connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle *const)), this, SLOT(updateTorrentInfos(BitTorrent::TorrentHandle *const)));
connect(m_ui->filesList->header(), SIGNAL(sectionMoved(int,int,int)), this, SLOT(saveSettings()));
connect(m_ui->filesList->header(), SIGNAL(sectionResized(int,int,int)), this, SLOT(saveSettings()));
connect(m_ui->filesList->header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSettings()));
connect(m_ui->filesList, &QAbstractItemView::clicked
, m_ui->filesList, static_cast<void (QAbstractItemView::*)(const QModelIndex &)>(&QAbstractItemView::edit));
connect(m_ui->selectAllButton, &QPushButton::clicked, m_propListModel, &TorrentContentFilterModel::selectAll);
connect(m_ui->selectNoneButton, &QPushButton::clicked, m_propListModel, &TorrentContentFilterModel::selectNone);
connect(m_ui->filesList, &QWidget::customContextMenuRequested, this, &PropertiesWidget::displayFilesListMenu);
connect(m_ui->filesList, &QAbstractItemView::doubleClicked, this, &PropertiesWidget::openDoubleClickedFile);
connect(m_propListModel, &TorrentContentFilterModel::filteredFilesChanged, this, &PropertiesWidget::filteredFilesChanged);
connect(m_ui->listWebSeeds, &QWidget::customContextMenuRequested, this, &PropertiesWidget::displayWebSeedListMenu);
connect(transferList, &TransferListWidget::currentTorrentChanged, this, &PropertiesWidget::loadTorrentInfos);
connect(m_propListDelegate, &PropListDelegate::filteredFilesChanged, this, &PropertiesWidget::filteredFilesChanged);
connect(m_ui->stackedProperties, &QStackedWidget::currentChanged, this, &PropertiesWidget::loadDynamicData);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentSavePathChanged, this, &PropertiesWidget::updateSavePath);
connect(BitTorrent::Session::instance(), &BitTorrent::Session::torrentMetadataLoaded, this, &PropertiesWidget::updateTorrentInfos);
connect(m_ui->filesList->header(), &QHeaderView::sectionMoved, this, &PropertiesWidget::saveSettings);
connect(m_ui->filesList->header(), &QHeaderView::sectionResized, this, &PropertiesWidget::saveSettings);
connect(m_ui->filesList->header(), &QHeaderView::sortIndicatorChanged, this, &PropertiesWidget::saveSettings);
// set bar height relative to screen dpi
const int barHeight = Utils::Gui::scaledSize(this, 18);
@@ -136,8 +137,8 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
m_ui->trackerUpButton->setIconSize(Utils::Gui::smallIconSize());
m_ui->trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down"));
m_ui->trackerDownButton->setIconSize(Utils::Gui::smallIconSize());
connect(m_ui->trackerUpButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionUp()));
connect(m_ui->trackerDownButton, SIGNAL(clicked()), m_trackerList, SLOT(moveSelectionDown()));
connect(m_ui->trackerUpButton, &QPushButton::clicked, m_trackerList, &TrackerList::moveSelectionUp);
connect(m_ui->trackerDownButton, &QPushButton::clicked, m_trackerList, &TrackerList::moveSelectionDown);
m_ui->horizontalLayout_trackers->insertWidget(0, m_trackerList);
connect(m_trackerList->header(), SIGNAL(sectionMoved(int,int,int)), m_trackerList, SLOT(saveSettings()));
connect(m_trackerList->header(), SIGNAL(sectionResized(int,int,int)), m_trackerList, SLOT(saveSettings()));
@@ -155,23 +156,23 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow *mainWindow, Tran
m_tabBar = new PropTabBar();
m_tabBar->setContentsMargins(0, 5, 0, 0);
m_ui->verticalLayout->addLayout(m_tabBar);
connect(m_tabBar, SIGNAL(tabChanged(int)), m_ui->stackedProperties, SLOT(setCurrentIndex(int)));
connect(m_tabBar, SIGNAL(tabChanged(int)), this, SLOT(saveSettings()));
connect(m_tabBar, SIGNAL(visibilityToggled(bool)), SLOT(setVisibility(bool)));
connect(m_tabBar, SIGNAL(visibilityToggled(bool)), this, SLOT(saveSettings()));
connect(m_tabBar, &PropTabBar::tabChanged, m_ui->stackedProperties, &QStackedWidget::setCurrentIndex);
connect(m_tabBar, &PropTabBar::tabChanged, this, &PropertiesWidget::saveSettings);
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::setVisibility);
connect(m_tabBar, &PropTabBar::visibilityToggled, this, &PropertiesWidget::saveSettings);
// Dynamic data refresher
m_refreshTimer = new QTimer(this);
connect(m_refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData()));
connect(m_refreshTimer, &QTimer::timeout, this, &PropertiesWidget::loadDynamicData);
m_refreshTimer->start(3000); // 3sec
m_editHotkeyFile = new QShortcut(Qt::Key_F2, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile()));
connect(m_editHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::renameSelectedFile);
m_editHotkeyWeb = new QShortcut(Qt::Key_F2, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed()));
connect(m_ui->listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed()));
connect(m_editHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::editWebSeed);
connect(m_ui->listWebSeeds, &QListWidget::doubleClicked, this, &PropertiesWidget::editWebSeed);
m_deleteHotkeyWeb = new QShortcut(QKeySequence::Delete, m_ui->listWebSeeds, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds()));
connect(m_deleteHotkeyWeb, &QShortcut::activated, this, &PropertiesWidget::deleteSelectedUrlSeeds);
m_openHotkeyFile = new QShortcut(Qt::Key_Return, m_ui->filesList, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_openHotkeyFile, SIGNAL(activated()), SLOT(openSelectedFile()));
connect(m_openHotkeyFile, &QShortcut::activated, this, &PropertiesWidget::openSelectedFile);
}
PropertiesWidget::~PropertiesWidget()

View File

@@ -99,7 +99,8 @@ PropTabBar::PropTabBar(QWidget *parent)
addWidget(speedButton);
m_btnGroup->addButton(speedButton, SpeedTab);
// SIGNAL/SLOT
connect(m_btnGroup, SIGNAL(buttonClicked(int)), SLOT(setCurrentIndex(int)));
connect(m_btnGroup, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked)
, this, &PropTabBar::setCurrentIndex);
// Disable buttons focus
foreach (QAbstractButton *btn, m_btnGroup->buttons())
btn->setFocusPolicy(Qt::NoFocus);

View File

@@ -78,10 +78,10 @@ TrackerList::TrackerList(PropertiesWidget *properties)
resizeColumnToContents(i);
// Context menu
setContextMenuPolicy(Qt::CustomContextMenu);
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showTrackerListMenu(QPoint)));
connect(this, &QWidget::customContextMenuRequested, this, &TrackerList::showTrackerListMenu);
// Header context menu
header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayToggleColumnsMenu(const QPoint&)));
connect(header(), &QWidget::customContextMenuRequested, this, &TrackerList::displayToggleColumnsMenu);
// Set DHT, PeX, LSD items
m_DHTItem = new QTreeWidgetItem({ "", "** [DHT] **", "", "0", "", "", "0" });
insertTopLevelItem(0, m_DHTItem);
@@ -112,10 +112,13 @@ TrackerList::TrackerList(PropertiesWidget *properties)
headerItem()->setTextAlignment(COL_PEERS, (Qt::AlignRight | Qt::AlignVCenter));
headerItem()->setTextAlignment(COL_DOWNLOADED, (Qt::AlignRight | Qt::AlignVCenter));
// Set hotkeys
m_editHotkey = new QShortcut(Qt::Key_F2, this, SLOT(editSelectedTracker()), nullptr, Qt::WidgetShortcut);
connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(editSelectedTracker()));
m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, SLOT(deleteSelectedTrackers()), nullptr, Qt::WidgetShortcut);
m_copyHotkey = new QShortcut(QKeySequence::Copy, this, SLOT(copyTrackerUrl()), nullptr, Qt::WidgetShortcut);
m_editHotkey = new QShortcut(Qt::Key_F2, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_editHotkey, &QShortcut::activated, this, &TrackerList::editSelectedTracker);
connect(this, &QAbstractItemView::doubleClicked, this, &TrackerList::editSelectedTracker);
m_deleteHotkey = new QShortcut(QKeySequence::Delete, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_deleteHotkey, &QShortcut::activated, this, &TrackerList::deleteSelectedTrackers);
m_copyHotkey = new QShortcut(QKeySequence::Copy, this, nullptr, nullptr, Qt::WidgetShortcut);
connect(m_copyHotkey, &QShortcut::activated, this, &TrackerList::copyTrackerUrl);
// This hack fixes reordering of first column with Qt5.
// https://github.com/qtproject/qtbase/commit/e0fc088c0c8bc61dbcaf5928b24986cd61a22777

View File

@@ -71,8 +71,9 @@ void TrackersAdditionDlg::on_uTorrentListButton_clicked()
{
m_ui->uTorrentListButton->setEnabled(false);
Net::DownloadHandler *handler = Net::DownloadManager::instance()->downloadUrl(m_ui->list_url->text(), true);
connect(handler, SIGNAL(downloadFinished(QString, QString)), this, SLOT(parseUTorrentList(QString, QString)));
connect(handler, SIGNAL(downloadFailed(QString, QString)), this, SLOT(getTrackerError(QString, QString)));
connect(handler, static_cast<void (Net::DownloadHandler::*)(const QString &, const QString &)>(&Net::DownloadHandler::downloadFinished)
, this, &TrackersAdditionDlg::parseUTorrentList);
connect(handler, &Net::DownloadHandler::downloadFailed, this, &TrackersAdditionDlg::getTrackerError);
// Just to show that it takes times
setCursor(Qt::WaitCursor);
}