From 0b57e6a77fc0f83b11ccde1d3785797406cfb16d Mon Sep 17 00:00:00 2001 From: blue Date: Sun, 3 Nov 2019 21:46:40 +0300 Subject: [PATCH] Refactoring of signal/slots connection to new qt syntax --- core/conference.cpp | 18 ++++++++--------- core/networkaccess.cpp | 6 +++--- signalcatcher.cpp | 2 +- ui/models/accounts.cpp | 4 ++-- ui/models/contact.cpp | 8 ++++---- ui/models/group.cpp | 4 ++-- ui/models/item.cpp | 28 +++++++++++++------------- ui/models/room.cpp | 1 - ui/squawk.cpp | 40 ++++++++++++++++++------------------- ui/utils/badge.cpp | 2 +- ui/utils/message.cpp | 2 +- ui/utils/messageline.cpp | 2 +- ui/widgets/accounts.cpp | 21 ++++++++++--------- ui/widgets/chat.cpp | 2 +- ui/widgets/conversation.cpp | 22 ++++++++++---------- ui/widgets/room.cpp | 2 +- 16 files changed, 81 insertions(+), 83 deletions(-) diff --git a/core/conference.cpp b/core/conference.cpp index 1305419..56a1e8f 100644 --- a/core/conference.cpp +++ b/core/conference.cpp @@ -30,15 +30,15 @@ Core::Conference::Conference(const QString& p_jid, const QString& p_account, boo muc = true; name = p_name; - connect(room, SIGNAL(joined()), this, SLOT(onRoomJoined())); - connect(room, SIGNAL(left()), this, SLOT(onRoomLeft())); - connect(room, SIGNAL(nameChanged(const QString&)), this, SLOT(onRoomNameChanged(const QString&))); - connect(room, SIGNAL(subjectChanged(const QString&)), this, SLOT(onRoomSubjectChanged(const QString&))); - connect(room, SIGNAL(participantAdded(const QString&)), this, SLOT(onRoomParticipantAdded(const QString&))); - connect(room, SIGNAL(participantChanged(const QString&)), this, SLOT(onRoomParticipantChanged(const QString&))); - connect(room, SIGNAL(participantRemoved(const QString&)), this, SLOT(onRoomParticipantRemoved(const QString&))); - connect(room, SIGNAL(nickNameChanged(const QString&)), this, SLOT(onRoomNickNameChanged(const QString&))); - connect(room, SIGNAL(error(const QXmppStanza::Error&)), this, SLOT(onRoomError(const QXmppStanza::Error&))); + connect(room, &QXmppMucRoom::joined, this, &Conference::onRoomJoined); + connect(room, &QXmppMucRoom::left, this, &Conference::onRoomLeft); + connect(room, &QXmppMucRoom::nameChanged, this, &Conference::onRoomNameChanged); + connect(room, &QXmppMucRoom::subjectChanged, this, &Conference::onRoomSubjectChanged); + connect(room, &QXmppMucRoom::participantAdded, this, &Conference::onRoomParticipantAdded); + connect(room, &QXmppMucRoom::participantChanged, this, &Conference::onRoomParticipantChanged); + connect(room, &QXmppMucRoom::participantRemoved, this, &Conference::onRoomParticipantRemoved); + connect(room, &QXmppMucRoom::nickNameChanged, this, &Conference::onRoomNickNameChanged); + connect(room, &QXmppMucRoom::error, this, &Conference::onRoomError); room->setNickName(nick); if (autoJoin) { diff --git a/core/networkaccess.cpp b/core/networkaccess.cpp index 002f9d7..090f4e7 100644 --- a/core/networkaccess.cpp +++ b/core/networkaccess.cpp @@ -323,9 +323,9 @@ void Core::NetworkAccess::startDownload(const QString& messageId, const QString& Download* dwn = new Download({{messageId}, 0, 0, true}); QNetworkRequest req(url); dwn->reply = manager->get(req); - connect(dwn->reply, SIGNAL(downloadProgress(qint64, qint64)), SLOT(onDownloadProgress(qint64, qint64))); - connect(dwn->reply, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(onRequestError(QNetworkReply::NetworkError))); - connect(dwn->reply, SIGNAL(finished()), SLOT(onRequestFinished())); + connect(dwn->reply, &QNetworkReply::downloadProgress, this, &NetworkAccess::onDownloadProgress); + connect(dwn->reply, qOverload(&QNetworkReply::error), this, &NetworkAccess::onRequestError); + connect(dwn->reply, &QNetworkReply::finished, this, &NetworkAccess::onRequestFinished); downloads.insert(std::make_pair(url, dwn)); emit downloadFileProgress(messageId, 0); } diff --git a/signalcatcher.cpp b/signalcatcher.cpp index 3460d0e..9ac3aae 100644 --- a/signalcatcher.cpp +++ b/signalcatcher.cpp @@ -38,7 +38,7 @@ SignalCatcher::SignalCatcher(QCoreApplication *p_app, QObject *parent): } snInt = new QSocketNotifier(sigintFd[1], QSocketNotifier::Read, this); - connect(snInt, SIGNAL(activated(int)), this, SLOT(handleSigInt())); + connect(snInt, &QSocketNotifier::activated, this, &SignalCatcher::handleSigInt); } SignalCatcher::~SignalCatcher() diff --git a/ui/models/accounts.cpp b/ui/models/accounts.cpp index b7f16ef..79ed159 100644 --- a/ui/models/accounts.cpp +++ b/ui/models/accounts.cpp @@ -89,7 +89,7 @@ void Models::Accounts::addAccount(Account* account) } accs.insert(before, account); - connect(account, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onAccountChanged(Models::Item*, int, int))); + connect(account, &Account::childChanged, this, &Accounts::onAccountChanged); endInsertRows(); emit sizeChanged(accs.size()); @@ -143,7 +143,7 @@ void Models::Accounts::removeAccount(int index) { Account* account = accs[index]; beginRemoveRows(QModelIndex(), index, index); - disconnect(account, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onAccountChanged(Models::Item*, int, int))); + disconnect(account, &Account::childChanged, this, &Accounts::onAccountChanged); accs.erase(accs.begin() + index); endRemoveRows(); diff --git a/ui/models/contact.cpp b/ui/models/contact.cpp index 9b5b436..eee6b4e 100644 --- a/ui/models/contact.cpp +++ b/ui/models/contact.cpp @@ -229,7 +229,7 @@ void Models::Contact::refresh() void Models::Contact::_removeChild(int index) { Item* child = childItems[index]; - disconnect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh())); + disconnect(child, &Item::childChanged, this, &Contact::refresh); Item::_removeChild(index); refresh(); } @@ -237,7 +237,7 @@ void Models::Contact::_removeChild(int index) void Models::Contact::appendChild(Models::Item* child) { Item::appendChild(child); - connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh())); + connect(child, &Item::childChanged, this, &Contact::refresh); refresh(); } @@ -324,7 +324,7 @@ void Models::Contact::toOfflineState() emit childIsAboutToBeRemoved(this, 0, childItems.size()); for (int i = 0; i < childItems.size(); ++i) { Item* item = childItems[i]; - disconnect(item, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh())); + disconnect(item, &Item::childChanged, this, &Contact::refresh); Item::_removeChild(i); item->deleteLater(); } @@ -363,7 +363,7 @@ Models::Contact::Contact(const Models::Contact& other): Presence* pCopy = new Presence(*pres); presences.insert(pCopy->getName(), pCopy); Item::appendChild(pCopy); - connect(pCopy, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh())); + connect(pCopy, &Item::childChanged, this, &Contact::refresh); } refresh(); diff --git a/ui/models/group.cpp b/ui/models/group.cpp index d857710..5e4411e 100644 --- a/ui/models/group.cpp +++ b/ui/models/group.cpp @@ -32,7 +32,7 @@ Models::Group::~Group() void Models::Group::appendChild(Models::Item* child) { Item::appendChild(child); - connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh())); + connect(child, &Item::childChanged, this, &Group::refresh); changed(1); refresh(); } @@ -59,7 +59,7 @@ QVariant Models::Group::data(int column) const void Models::Group::_removeChild(int index) { Item* child = childItems[index]; - disconnect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh())); + disconnect(child, &Item::childChanged, this, &Group::refresh); Item::_removeChild(index); changed(1); refresh(); diff --git a/ui/models/item.cpp b/ui/models/item.cpp index 7ab877a..f90f5e6 100644 --- a/ui/models/item.cpp +++ b/ui/models/item.cpp @@ -88,13 +88,13 @@ void Models::Item::appendChild(Models::Item* child) childItems.insert(before, child); child->parent = this; - QObject::connect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SIGNAL(childChanged(Models::Item*, int, int))); - QObject::connect(child, SIGNAL(childIsAboutToBeInserted(Item*, int, int)), this, SIGNAL(childIsAboutToBeInserted(Item*, int, int))); - QObject::connect(child, SIGNAL(childInserted()), this, SIGNAL(childInserted())); - QObject::connect(child, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)), this, SIGNAL(childIsAboutToBeRemoved(Item*, int, int))); - QObject::connect(child, SIGNAL(childRemoved()), this, SIGNAL(childRemoved())); - QObject::connect(child, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)), this, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int))); - QObject::connect(child, SIGNAL(childMoved()), this, SIGNAL(childMoved())); + QObject::connect(child, &Item::childChanged, this, &Item::childChanged); + QObject::connect(child, &Item::childIsAboutToBeInserted, this, &Item::childIsAboutToBeInserted); + QObject::connect(child, &Item::childInserted, this, &Item::childInserted); + QObject::connect(child, &Item::childIsAboutToBeRemoved, this, &Item::childIsAboutToBeRemoved); + QObject::connect(child, &Item::childRemoved, this, &Item::childRemoved); + QObject::connect(child, &Item::childIsAboutToBeMoved, this, &Item::childIsAboutToBeMoved); + QObject::connect(child, &Item::childMoved, this, &Item::childMoved); if (moving) { emit childMoved(); @@ -168,13 +168,13 @@ void Models::Item::_removeChild(int index) { Item* child = childItems[index]; - QObject::disconnect(child, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onChildChanged(Models::Item*, int, int))); - QObject::disconnect(child, SIGNAL(childIsAboutToBeInserted(Item*, int, int)), this, SIGNAL(childIsAboutToBeInserted(Item*, int, int))); - QObject::disconnect(child, SIGNAL(childInserted()), this, SIGNAL(childInserted())); - QObject::disconnect(child, SIGNAL(childIsAboutToBeRemoved(Item*, int, int)), this, SIGNAL(childIsAboutToBeRemoved(Item*, int, int))); - QObject::disconnect(child, SIGNAL(childRemoved()), this, SIGNAL(childRemoved())); - QObject::disconnect(child, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int)), this, SIGNAL(childIsAboutToBeMoved(Item*, int, int, Item*, int))); - QObject::disconnect(child, SIGNAL(childMoved()), this, SIGNAL(childMoved())); + QObject::disconnect(child, &Item::childChanged, this, &Item::childChanged); + QObject::disconnect(child, &Item::childIsAboutToBeInserted, this, &Item::childIsAboutToBeInserted); + QObject::disconnect(child, &Item::childInserted, this, &Item::childInserted); + QObject::disconnect(child, &Item::childIsAboutToBeRemoved, this, &Item::childIsAboutToBeRemoved); + QObject::disconnect(child, &Item::childRemoved, this, &Item::childRemoved); + QObject::disconnect(child, &Item::childIsAboutToBeMoved, this, &Item::childIsAboutToBeMoved); + QObject::disconnect(child, &Item::childMoved, this, &Item::childMoved); childItems.erase(childItems.begin() + index); child->parent = 0; diff --git a/ui/models/room.cpp b/ui/models/room.cpp index 6addead..204b2b5 100644 --- a/ui/models/room.cpp +++ b/ui/models/room.cpp @@ -238,7 +238,6 @@ void Models::Room::toOfflineState() emit childIsAboutToBeRemoved(this, 0, childItems.size()); for (int i = 0; i < childItems.size(); ++i) { Item* item = childItems[i]; - disconnect(item, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(refresh())); Item::_removeChild(i); item->deleteLater(); } diff --git a/ui/squawk.cpp b/ui/squawk.cpp index 0c27fc6..396eeb6 100644 --- a/ui/squawk.cpp +++ b/ui/squawk.cpp @@ -69,12 +69,12 @@ void Squawk::onAccounts() if (accounts == 0) { accounts = new Accounts(rosterModel.accountsModel, this); accounts->setAttribute(Qt::WA_DeleteOnClose); - connect(accounts, SIGNAL(destroyed(QObject*)), this, SLOT(onAccountsClosed(QObject*))); - connect(accounts, SIGNAL(newAccount(const QMap&)), this, SIGNAL(newAccountRequest(const QMap&))); - connect(accounts, SIGNAL(changeAccount(const QString&, const QMap&)), this, SIGNAL(modifyAccountRequest(const QString&, const QMap&))); - connect(accounts, SIGNAL(connectAccount(const QString&)), this, SIGNAL(connectAccount(const QString&))); - connect(accounts, SIGNAL(disconnectAccount(const QString&)), this, SIGNAL(disconnectAccount(const QString&))); - connect(accounts, SIGNAL(removeAccount(const QString&)), this, SIGNAL(removeAccountRequest(const QString&))); + connect(accounts, &Accounts::destroyed, this, &Squawk::onAccountsClosed); + connect(accounts, &Accounts::newAccount, this, &Squawk::newAccountRequest); + connect(accounts, &Accounts::changeAccount, this, &Squawk::modifyAccountRequest); + connect(accounts, &Accounts::connectAccount, this, &Squawk::connectAccount); + connect(accounts, &Accounts::disconnectAccount, this, &Squawk::disconnectAccount); + connect(accounts, &Accounts::removeAccount, this, &Squawk::removeAccountRequest); accounts->show(); } else { @@ -99,8 +99,8 @@ void Squawk::onNewContact() { NewContact* nc = new NewContact(rosterModel.accountsModel, this); - connect(nc, SIGNAL(accepted()), this, SLOT(onNewContactAccepted())); - connect(nc, SIGNAL(rejected()), nc, SLOT(deleteLater())); + connect(nc, &NewContact::accepted, this, &Squawk::onNewContactAccepted); + connect(nc, &NewContact::rejected, nc, &NewContact::deleteLater); nc->exec(); } @@ -109,8 +109,8 @@ void Squawk::onNewConference() { JoinConference* jc = new JoinConference(rosterModel.accountsModel, this); - connect(jc, SIGNAL(accepted()), this, SLOT(onJoinConferenceAccepted())); - connect(jc, SIGNAL(rejected()), jc, SLOT(deleteLater())); + connect(jc, &JoinConference::accepted, this, &Squawk::onJoinConferenceAccepted); + connect(jc, &JoinConference::rejected, jc, &JoinConference::deleteLater); jc->exec(); } @@ -299,12 +299,12 @@ void Squawk::onRosterItemDoubleClicked(const QModelIndex& item) if (created) { conv->setAttribute(Qt::WA_DeleteOnClose); - connect(conv, SIGNAL(destroyed(QObject*)), this, SLOT(onConversationClosed(QObject*))); - connect(conv, SIGNAL(sendMessage(const Shared::Message&)), this, SLOT(onConversationMessage(const Shared::Message&))); - connect(conv, SIGNAL(requestArchive(const QString&)), this, SLOT(onConversationRequestArchive(const QString&))); - connect(conv, SIGNAL(requestLocalFile(const QString&, const QString&)), this, SLOT(onConversationRequestLocalFile(const QString&, const QString&))); - connect(conv, SIGNAL(downloadFile(const QString&, const QString&)), this, SLOT(onConversationDownloadFile(const QString&, const QString&))); - connect(conv, SIGNAL(shown()), this, SLOT(onConversationShown())); + connect(conv, &Conversation::destroyed, this, &Squawk::onConversationClosed); + connect(conv, &Conversation::sendMessage, this, &Squawk::onConversationMessage); + connect(conv, &Conversation::requestArchive, this, &Squawk::onConversationRequestArchive); + connect(conv, &Conversation::requestLocalFile, this, &Squawk::onConversationRequestLocalFile); + connect(conv, &Conversation::downloadFile, this, &Squawk::onConversationDownloadFile); + connect(conv, &Conversation::shown, this, &Squawk::onConversationShown); conversations.insert(std::make_pair(*id, conv)); @@ -517,10 +517,10 @@ void Squawk::removeAccount(const QString& account) Conversations::const_iterator lItr = itr; ++itr; Conversation* conv = lItr->second; - disconnect(conv, SIGNAL(destroyed(QObject*)), this, SLOT(onConversationClosed(QObject*))); - disconnect(conv, SIGNAL(sendMessage(const Shared::Message&)), this, SLOT(onConversationMessage(const Shared::Message&))); - disconnect(conv, SIGNAL(requestArchive(const QString&)), this, SLOT(onConversationRequestArchive(const QString&))); - disconnect(conv, SIGNAL(shown()), this, SLOT(onConversationShown())); + disconnect(conv, &Conversation::destroyed, this, &Squawk::onConversationClosed); + disconnect(conv, &Conversation::sendMessage, this, &Squawk::onConversationMessage); + disconnect(conv, &Conversation::requestArchive, this, &Squawk::onConversationRequestArchive); + disconnect(conv, &Conversation::shown, this, &Squawk::onConversationShown); conv->close(); conversations.erase(lItr); } else { diff --git a/ui/utils/badge.cpp b/ui/utils/badge.cpp index 94277f2..ef15bd2 100644 --- a/ui/utils/badge.cpp +++ b/ui/utils/badge.cpp @@ -42,7 +42,7 @@ Badge::Badge(const QString& p_id, const QString& p_text, const QIcon& icon, QWid layout->setContentsMargins(2, 2, 2, 2); - connect(closeButton, SIGNAL(clicked()), this, SIGNAL(close())); + connect(closeButton, &QPushButton::clicked, this, &Badge::close); } Badge::~Badge() diff --git a/ui/utils/message.cpp b/ui/utils/message.cpp index 2498d84..951037a 100644 --- a/ui/utils/message.cpp +++ b/ui/utils/message.cpp @@ -125,7 +125,7 @@ void Message::addDownloadDialog() fileComment->setText(tr("%1 is offering you to download a file").arg(sender->text())); } fileComment->show(); - connect(downloadButton, SIGNAL(clicked()), this, SLOT(onDownload())); + connect(downloadButton, &QPushButton::clicked, this, &Message::onDownload); bodyLayout->insertWidget(2, fileComment); bodyLayout->insertWidget(3, downloadButton); hasDownloadButton = true; diff --git a/ui/utils/messageline.cpp b/ui/utils/messageline.cpp index 57894e8..06efa85 100644 --- a/ui/utils/messageline.cpp +++ b/ui/utils/messageline.cpp @@ -127,7 +127,7 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg) if (msg.hasOutOfBandUrl()) {\ emit requestLocalFile(msg.getId(), msg.getOutOfBandUrl()); - connect(message, SIGNAL(downloadFile(const QString&, const QString&)), this, SIGNAL(downloadFile(const QString&, const QString&))); + connect(message, &Message::downloadFile, this, &MessageLine::downloadFile); } return res; diff --git a/ui/widgets/accounts.cpp b/ui/widgets/accounts.cpp index cb526cf..62e9ed3 100644 --- a/ui/widgets/accounts.cpp +++ b/ui/widgets/accounts.cpp @@ -29,14 +29,13 @@ Accounts::Accounts(Models::Accounts* p_model, QWidget *parent) : { m_ui->setupUi(this); - connect(m_ui->addButton, SIGNAL(clicked(bool)), this, SLOT(onAddButton(bool))); - connect(m_ui->editButton, SIGNAL(clicked(bool)), this, SLOT(onEditButton(bool))); - connect(m_ui->connectButton, SIGNAL(clicked(bool)), this, SLOT(onConnectButton(bool))); - connect(m_ui->deleteButton, SIGNAL(clicked(bool)), this, SLOT(onDeleteButton(bool))); + connect(m_ui->addButton, &QPushButton::clicked, this, &Accounts::onAddButton); + connect(m_ui->editButton, &QPushButton::clicked, this, &Accounts::onEditButton); + connect(m_ui->connectButton, &QPushButton::clicked, this, &Accounts::onConnectButton); + connect(m_ui->deleteButton, &QPushButton::clicked, this, &Accounts::onDeleteButton); m_ui->tableView->setModel(model); - connect(m_ui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), - this, SLOT(onSelectionChanged(const QItemSelection&, const QItemSelection&))); - connect(p_model, SIGNAL(changed()), this, SLOT(updateConnectButton())); + connect(m_ui->tableView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &Accounts::onSelectionChanged); + connect(p_model, &Models::Accounts::changed, this, &Accounts::updateConnectButton); } Accounts::~Accounts() = default; @@ -44,8 +43,8 @@ Accounts::~Accounts() = default; void Accounts::onAddButton(bool clicked) { Account* acc = new Account(); - connect(acc, SIGNAL(accepted()), this, SLOT(onAccountAccepted())); - connect(acc, SIGNAL(rejected()), this, SLOT(onAccountRejected())); + connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted); + connect(acc, &Account::rejected, this, &Accounts::onAccountRejected); acc->exec(); } @@ -84,8 +83,8 @@ void Accounts::onEditButton(bool clicked) {"resource", mAcc->getResource()} }); acc->lockId(); - connect(acc, SIGNAL(accepted()), this, SLOT(onAccountAccepted())); - connect(acc, SIGNAL(rejected()), this, SLOT(onAccountRejected())); + connect(acc, &Account::accepted, this, &Accounts::onAccountAccepted); + connect(acc, &Account::rejected, this, &Accounts::onAccountRejected); editing = true; acc->exec(); } diff --git a/ui/widgets/chat.cpp b/ui/widgets/chat.cpp index 5e0b390..c876679 100644 --- a/ui/widgets/chat.cpp +++ b/ui/widgets/chat.cpp @@ -26,7 +26,7 @@ Chat::Chat(Models::Contact* p_contact, QWidget* parent): updateState(); setStatus(p_contact->getStatus()); - connect(contact, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onContactChanged(Models::Item*, int, int))); + connect(contact, &Models::Contact::childChanged, this, &Chat::onContactChanged); line->setMyName(p_contact->getAccountName()); } diff --git a/ui/widgets/conversation.cpp b/ui/widgets/conversation.cpp index c281258..36e7b6e 100644 --- a/ui/widgets/conversation.cpp +++ b/ui/widgets/conversation.cpp @@ -59,15 +59,15 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co statusIcon = m_ui->statusIcon; statusLabel = m_ui->statusLabel; - connect(&ker, SIGNAL(enterPressed()), this, SLOT(onEnterPressed())); - connect(&res, SIGNAL(resized()), this, SLOT(onScrollResize())); - connect(&vis, SIGNAL(shown()), this, SLOT(onScrollResize())); - connect(&vis, SIGNAL(hidden()), this, SLOT(onScrollResize())); - connect(m_ui->sendButton, SIGNAL(clicked(bool)), this, SLOT(onEnterPressed())); - connect(line, SIGNAL(resize(int)), this, SLOT(onMessagesResize(int))); - connect(line, SIGNAL(downloadFile(const QString&, const QString&)), this, SIGNAL(downloadFile(const QString&, const QString&))); - connect(line, SIGNAL(requestLocalFile(const QString&, const QString&)), this, SIGNAL(requestLocalFile(const QString&, const QString&))); - connect(m_ui->attachButton, SIGNAL(clicked(bool)), this, SLOT(onAttach())); + connect(&ker, &KeyEnterReceiver::enterPressed, this, &Conversation::onEnterPressed); + connect(&res, &Resizer::resized, this, &Conversation::onScrollResize); + connect(&vis, &VisibilityCatcher::shown, this, &Conversation::onScrollResize); + connect(&vis, &VisibilityCatcher::hidden, this, &Conversation::onScrollResize); + connect(m_ui->sendButton, &QPushButton::clicked, this, &Conversation::onEnterPressed); + connect(line, &MessageLine::resize, this, &Conversation::onMessagesResize); + connect(line, &MessageLine::downloadFile, this, &Conversation::downloadFile); + connect(line, &MessageLine::requestLocalFile, this, &Conversation::requestLocalFile); + connect(m_ui->attachButton, &QPushButton::clicked, this, &Conversation::onAttach); m_ui->messageEditor->installEventFilter(&ker); @@ -76,7 +76,7 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co vs->installEventFilter(&vis); vs->setBackgroundRole(QPalette::Base); vs->setAutoFillBackground(true); - connect(vs, SIGNAL(valueChanged(int)), this, SLOT(onSliderValueChanged(int))); + connect(vs, &QScrollBar::valueChanged, this, &Conversation::onSliderValueChanged); m_ui->scrollArea->installEventFilter(&res); applyVisualEffects(); @@ -317,7 +317,7 @@ void Conversation::addAttachedFile(const QString& path) Badge* badge = new Badge(path, info.fileName(), QIcon::fromTheme(type.iconName())); - connect(badge, SIGNAL(close()), this, SLOT(onBadgeClose())); + connect(badge, &Badge::close, this, &Conversation::onBadgeClose); filesToAttach.push_back(badge); //TODO neet to check if there are any duplicated ids filesLayout->addWidget(badge); if (filesLayout->count() == 1) { diff --git a/ui/widgets/room.cpp b/ui/widgets/room.cpp index b1f9c9c..98fc97d 100644 --- a/ui/widgets/room.cpp +++ b/ui/widgets/room.cpp @@ -26,7 +26,7 @@ Room::Room(Models::Room* p_room, QWidget* parent): line->setMyName(room->getNick()); setStatus(room->getSubject()); - connect(room, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onRoomChanged(Models::Item*, int, int))); + connect(room, &Models::Room::childChanged, this, &Room::onRoomChanged); } Room::~Room()