Index: src/irc/query.cpp =================================================================== --- src/irc/query.cpp (revision 921743) +++ src/irc/query.cpp (working copy) @@ -82,21 +82,35 @@ // link "Whois", "Ignore" ... menu items into ircview popup KMenu* popup=textView->getPopup(); popup->addSeparator(); - popup->insertItem(i18n("&Whois"),Konversation::Whois); - popup->insertItem(i18n("&Version"),Konversation::Version); - popup->insertItem(i18n("&Ping"),Konversation::Ping); + KAction *whoisAction = new KAction(i18n("&Whois"), popup); + connect(whoisAction, SIGNAL(triggered(bool)), this, SLOT(slotWhoIs())); + KAction *versionAction = new KAction(i18n("&Version"), popup); + connect(versionAction, SIGNAL(triggered(bool)), this, SLOT(slotVersion())); + KAction *pingAction = new KAction(i18n("&Ping"), popup); + connect(pingAction, SIGNAL(triggered(bool)), this, SLOT(slotPing())); + + popup->addAction(whoisAction); + popup->addAction(versionAction); + popup->addAction(pingAction); popup->addSeparator(); - popup->insertItem(i18n("Ignore"), Konversation::IgnoreNick); - popup->insertItem(i18n("Unignore"), Konversation::UnignoreNick); + KAction *ignoreAction = new KAction(i18n("Ignore"), popup); + connect(ignoreAction, SIGNAL(triggered(bool)), this, SLOT(slotIgnore())); + KAction *unIgnoreAction = new KAction(i18n("Unignore"), popup); + connect(unIgnoreAction, SIGNAL(triggered(bool)), this, SLOT(slotUnIgnore())); + + popup->setItemVisible(Konversation::IgnoreNick, false); popup->setItemVisible(Konversation::UnignoreNick, false); if (KAuthorized::authorizeKAction("allow_downloading")) - popup->insertItem(SmallIcon("2rightarrow"),i18n("Send &File..."),Konversation::DccSend); + { + KAction *dccAction = new KAction(KIcon("arrow-right-double"),i18n("Send &File..."), popup); + connect(dccAction, SIGNAL(triggered(bool)), this, SLOT(slotDcc())); + } + KAction *watchAction = new KAction(i18n("Add to Watched Nicks"), popup); + connect(watchAction, SIGNAL(triggered(bool)), this, SLOT(slotWatch())); - popup->insertItem(i18n("Add to Watched Nicks"), Konversation::AddNotify); - // This box holds the input line KHBox* inputBox=new KHBox(this); inputBox->setObjectName("input_log_box"); @@ -374,102 +388,7 @@ } } -void Query::popup(int id) -{ - // get the nickname to the context menu popup - QString name = textView->getContextNick(); - // if there was none (right click into the text view) assume query partner - if (name.isEmpty()) name = getName(); - switch (id) - { - case Konversation::Whois: - sendQueryText(Preferences::self()->commandChar()+"WHOIS "+name+' '+name); - break; - - case Konversation::IgnoreNick: - { - if (KMessageBox::warningContinueCancel( - this, - i18n("Do you want to ignore %1?",name), - i18n("Ignore"), - KGuiItem(i18n("Ignore")), - KStandardGuiItem::cancel(), - "IgnoreNick") - == KMessageBox::Continue) - { - sendQueryText(Preferences::self()->commandChar()+"IGNORE -ALL "+name); - - int rc = KMessageBox::questionYesNo(this, - i18n("Do you want to close this query after ignoring this nickname?"), - i18n("Close This Query"), - KGuiItem(i18n("Close")), - KGuiItem(i18n("Keep Open")), - "CloseQueryAfterIgnore"); - - if (rc == KMessageBox::Yes && m_server) - QTimer::singleShot(0, this, SLOT(closeWithoutAsking())); - } - - break; - } - case Konversation::UnignoreNick: - { - if (KMessageBox::warningContinueCancel( - this, - i18n("Do you want to stop ignoring %1?", name), - i18n("Unignore"), - KGuiItem(i18n("Unignore")), - KStandardGuiItem::cancel(), - "UnignoreNick") - == - KMessageBox::Continue) - { - sendQueryText(Preferences::self()->commandChar()+"UNIGNORE "+name); - } - - break; - } - case Konversation::AddNotify: - { - if (m_server->getServerGroup()) - { - if (!Preferences::isNotify(m_server->getServerGroup()->id(), name)) - Preferences::addNotify(m_server->getServerGroup()->id(),name); - } - break; - } - case Konversation::DccSend: - sendQueryText(Preferences::self()->commandChar()+"DCC SEND "+name); - break; - - case Konversation::Version: - sendQueryText(Preferences::self()->commandChar()+"CTCP "+name+" VERSION"); - break; - - case Konversation::Ping: - sendQueryText(Preferences::self()->commandChar()+"CTCP "+name+" PING"); - break; - - case Konversation::Topic: - m_server->requestTopic(getTextView()->currentChannel()); - break; - case Konversation::Names: - m_server->queue("NAMES " + getTextView()->currentChannel(), Server::LowPriority); - break; - case Konversation::Join: - m_server->queue("JOIN " + getTextView()->currentChannel()); - break; - - default: - kDebug() << "Query::popup(): Popup id " << id << " does not belong to me!" << endl; - break; - } - - // delete context menu nickname - textView->clearContextNick(); -} - void Query::sendFileMenu() { emit sendFile(getName()); @@ -693,4 +612,84 @@ } } +void Query::slotWhoIs() +{ + sendQueryText(Preferences::self()->commandChar() + "WHOIS " + name + ' ' + name); +} +void Query::slotVersion() +{ + sendQueryText(Preferences::self()->commandChar() + "CTCP " + name + " VERSION"); +} + +void Query::slotPing() +{ + sendQueryText(Preferences::self()->commandChar() + "CTCP " + name + " PING"); +} + +void Query::slotIgnore() +{ + if (KMessageBox::warningContinueCancel( + this, + i18n("Do you want to ignore %1?",name), + i18n("Ignore"), + KGuiItem(i18n("Ignore")), + KStandardGuiItem::cancel(), + "IgnoreNick") + == KMessageBox::Continue) + { + sendQueryText(Preferences::self()->commandChar()+"IGNORE -ALL "+name); + + int rc = KMessageBox::questionYesNo(this, + i18n("Do you want to close this query after ignoring this nickname?"), + i18n("Close This Query"), + KGuiItem(i18n("Close")), + KGuiItem(i18n("Keep Open")), + "CloseQueryAfterIgnore"); + if (rc == KMessageBox::Yes && m_server) + QTimer::singleShot(0, this, SLOT(closeWithoutAsking())); + } +} + +void Query::slotUnIgnore() +{ + if (KMessageBox::warningContinueCancel( + this, + i18n("Do you want to stop ignoring %1?", name), + i18n("Unignore"), + KGuiItem(i18n("Unignore")), + KStandardGuiItem::cancel(), + "UnignoreNick") == KMessageBox::Continue) + { + sendQueryText(Preferences::self()->commandChar()+"UNIGNORE "+name); + } +} + +void Query::slotDcc() +{ + sendQueryText(Preferences::self()->commandChar()+"DCC SEND "+name); +} + +void Query::slotWatch() +{ + if (m_server->getServerGroup()) + { + if (!Preferences::isNotify(m_server->getServerGroup()->id(), name)) + Preferences::addNotify(m_server->getServerGroup()->id(),name); + } +} +void Query::slotJoin() +{ + m_server->queue("JOIN " + getTextView()->currentChannel()); +} + +void Query::slotName() +{ + m_server->queue("NAMES " + getTextView()->currentChannel(), Server::LowPriority); +} + +void Query::slotTopic() +{ + m_server->requestTopic(getTextView()->currentChannel()); +} + // #include "./irc/query.moc" Index: src/irc/query.h =================================================================== --- src/irc/query.h (revision 921743) +++ src/irc/query.h (working copy) @@ -91,10 +91,19 @@ void filesDropped(const QStringList& files); // connected to IRCInput::textPasted() - used to handle large/multiline pastes void textPasted(const QString& text); - void popup(int id); void nickInfoChanged(); void closeWithoutAsking(); virtual void serverOnline(bool online); + void slotWhoIs(); + void slotVersion(); + void slotPing(); + void slotIgnore(); + void slotUnIgnore(); + void slotDcc(); + void slotWatch(); + void slotJoin(); + void slotName(); + void slotTopic(); protected: void setName(const QString& newName);