void TransfersDialog::download(const QString &link) {
    unsigned int friend_id;
    unsigned int item_id;
    QString name;

    mainwindow->show();
    mainwindow->raise();
    mainwindow->activateWindow();

    if (!parseMixologyLink(link, &friend_id, &name, &item_id)) {
        QMessageBox::warning (this, "Unable to read link", "The Mixologist was passed a malformed link by your browser or another program", QMessageBox::Ok);
    }

    QSettings settings(*mainSettings, QSettings::IniFormat, this);
    if (settings.value("Transfers/MixologyLinkAsk", DEFAULT_MIXOLOGY_LINK_ASK).toBool()) {
        QMessageBox confirmBox(this);
        confirmBox.setIconPixmap(QPixmap(IMAGE_DOWNLOAD));
        confirmBox.setWindowTitle("Mixology Link");
        confirmBox.setText(QString("The Mixologist has received a mixology link!\n") +
                           "Request: " + name + "\n" +
                           "Friend: " + peers->getPeerName(friend_id) + "\n" +
                           "Continue?");
        confirmBox.addButton(QMessageBox::Yes);
        confirmBox.addButton(QMessageBox::No);
        confirmBox.setDefaultButton(QMessageBox::Yes);
        int result = confirmBox.exec();
        if (result == QMessageBox::No) return;
    }

    handleMixologyLink(friend_id, name, item_id, false);
}
void TransfersDialog::handleMixologyLink(unsigned int friend_id, const QString &name, unsigned int item_id, bool popupMessages) {
    if (friend_id == peers->getOwnLibraryMixerId()) {
        QMessageBox::warning (this, "The Mixologist", "FYI, you just tried to connect to yourself", QMessageBox::Ok);
        return;
    } else if (!peers->isFriend(friend_id)) {
        /* If not in friends list, download friends list and try again. */
        librarymixerconnect->downloadFriends(true);
        if (!peers->isFriend(friend_id)) {
            QMessageBox::warning (this,  "The Mixologist", "You can't connect to someone that's not your friend on LibraryMixer", QMessageBox::Ok);
            return;
        }
    }

    if (item_id != 0 && !name.isEmpty()) {
        files->LibraryMixerRequest(friend_id, item_id, name);
        if (popupMessages) {
            //We must construct our own QMessageBox rather than use a static function in order to avoid making a system sound on window popup
            QMessageBox confirmBox(this);
            confirmBox.setIconPixmap(QPixmap(IMAGE_DOWNLOAD));
            confirmBox.setWindowTitle(name);
            confirmBox.setText("A request will be sent to " + peers->getPeerName(friend_id));
            confirmBox.addButton("OK", QMessageBox::RejectRole);
            confirmBox.exec();
        }
    }
    else mainwindow->peersDialog->getOrCreateChat(friend_id, true);
}
Beispiel #3
0
// Called when we close the program
void MainWindow::closeEvent(QCloseEvent *e)
{
    Preferences pref;
    SessionStatus status = Session::instance()->getSessionStatus();

    // has active transfers or sessions speed > 0 (we have incoming peers)
    if (pref.confirmOnExit() && (Session::instance()->hasActiveTransfers() || (status.payload_download_rate > 0) || (status.payload_upload_rate > 0))) {
        if (e->spontaneous() || force_exit) {
            if(!isVisible())
                show();

            QMessageBox confirmBox(QMessageBox::Question, tr("Exiting qDonkey"),
                                   tr("Some files are currently transferring.\nAre you sure you want to quit qDonkey?"),
                                   QMessageBox::NoButton, this);

            QPushButton *noBtn = confirmBox.addButton(tr("No"), QMessageBox::NoRole);
            QPushButton *yesBtn = confirmBox.addButton(tr("Yes"), QMessageBox::YesRole);
            QPushButton *alwaysBtn = confirmBox.addButton(tr("Always"), QMessageBox::YesRole);
            confirmBox.setDefaultButton(yesBtn);
            confirmBox.exec();

            if(!confirmBox.clickedButton() || confirmBox.clickedButton() == noBtn)
            {
                // Cancel exit
                e->ignore();
                force_exit = false;
                return;
            }

            if(confirmBox.clickedButton() == alwaysBtn)
            {
                // Remember choice
                Preferences().setConfirmOnExit(false);
            }
        }
    }

    hide();

    if(systrayIcon) {
        systrayIcon->hide();
    }

    // Save window size, columns size
    writeSettings();

    // Accept exit
    e->accept();
    qApp->exit();
}