Exemple #1
0
void HistoryMessagesTab::clearTalkableHistory()
{
    if (!Storage)
        return;

    Q_ASSERT(TalkableTree->selectionModel());

    const QModelIndexList &selectedIndexes = TalkableTree->selectionModel()->selectedIndexes();
    QList<Talkable> talkables;

    MessageDialog *dialog = MessageDialog::create(
        m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"),
        tr("Do you really want to delete history?"));
    dialog->addButton(QMessageBox::Yes, tr("Delete history"));
    dialog->addButton(QMessageBox::No, tr("Cancel"));

    if (!dialog->ask())
        return;

    for (auto const &selectedIndex : selectedIndexes)
    {
        Talkable talkable = selectedIndex.data(TalkableRole).value<Talkable>();
        if (!talkable.isEmpty())
            Storage->deleteMessages(talkable);
    }

    updateData();
    displayTalkable(Talkable(), true);
}
Exemple #2
0
void StatusWindow::clearDescriptionsHistory()
{
    MessageDialog *dialog = MessageDialog::create(
        m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Clear Descriptions History"),
        tr("Do you really want to clear the descriptions history?"), this);
    dialog->addButton(QMessageBox::Yes, tr("Clear history"));
    dialog->addButton(QMessageBox::No, tr("Cancel"));

    if (!dialog->ask())
        return;

    m_descriptionManager->clearDescriptions();
    DescriptionSelect->setModel(m_descriptionManager->model());
    DescriptionSelect->setCurrentIndex(-1);
    DescriptionSelect->setEnabled(false);
    ClearDescriptionsHistoryButton->setEnabled(false);
}
Exemple #3
0
bool RosterReplacer::askForAddingContacts(const QMap<Buddy, Contact> &contactsToAdd, const QMap<Buddy, Contact> &contactsToRename)
{
	if (contactsToAdd.isEmpty() && contactsToRename.isEmpty())
		return true;

	QString questionString = tr("Kadu since version 0.10.0 automatically synchronizes Gadu-Gadu contact list with server. "
			"Now the first synchronization will be performed.<br/><br/>");

	if (!contactsToAdd.isEmpty())
	{
		QStringList contactsToAddStrings;
		for (QMap<Buddy, Contact>::const_iterator i = contactsToAdd.constBegin(); i != contactsToAdd.constEnd(); i++)
			contactsToAddStrings.append(i.key().display() + " (" + i.value().id() + ')');

		questionString += tr("The following contacts present on the server were not found on your local contact list:<br/>"
				"<b>%1</b>.<br/>If you do not agree to add those contacts to your local list, "
				"they will be removed from the server.<br/><br/>").arg(contactsToAddStrings.join("</b>, <b>"));
	}

	if (!contactsToRename.isEmpty())
	{
		QStringList contactsToRenameStrings;
		for (QMap<Buddy, Contact>::const_iterator i = contactsToRename.constBegin(); i != contactsToRename.constEnd(); i++)
			contactsToRenameStrings.append(i.value().display(true) + " (" + i.value().id() + ") -> " + i.key().display());

		if (contactsToAdd.isEmpty())
			questionString += tr("The following contacts from your local list are present on the server under different names:<br/>"
					"<b>%1</b>.<br/><br/>").arg(contactsToRenameStrings.join("</b>, <b>"));
		else
			questionString += tr("Moreover, the following contacts from your local list are present on the server under different names:<br/>"
					"<b>%1</b>.<br/><br/>").arg(contactsToRenameStrings.join("</b>, <b>"));
	}

	questionString += tr("Do you want to apply the above changes to your local contact list? "
			"Regardless of your choice, it will be sent to the server after making possible changes.");

	MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"), questionString);
	dialog->addButton(QMessageBox::Yes, tr("Apply changes"));
	dialog->addButton(QMessageBox::No, tr("Leave contact list unchanged"));

	return dialog->ask();
}
Exemple #4
0
void TabWidget::closeTab(ChatWidget *chatWidget)
{
	if (!chatWidget)
		return;

	if (m_configuration->deprecatedApi()->readBoolEntry("Chat", "ChatCloseTimer"))
	{
		unsigned int period = m_configuration->deprecatedApi()->readUnsignedNumEntry("Chat",
			"ChatCloseTimerPeriod", 2);

		if (QDateTime::currentDateTime() < chatWidget->lastReceivedMessageTime().addSecs(period))
		{
			MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"), tr("New message received, close window anyway?"));
			dialog->addButton(QMessageBox::Yes, tr("Close window"));
			dialog->addButton(QMessageBox::No, tr("Cancel"));

			if (!dialog->ask())
				return;
		}
	}

	delete chatWidget;
}
Exemple #5
0
void ChatWindow::closeEvent(QCloseEvent *e)
{
	kdebugf();

	if (m_configuration->deprecatedApi()->readBoolEntry("Chat", "ChatCloseTimer"))
	{
		int period = m_configuration->deprecatedApi()->readNumEntry("Chat", "ChatCloseTimerPeriod", 2);

		if (QDateTime::currentDateTime() < m_chatWidget->lastReceivedMessageTime().addSecs(period))
		{
			MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"), tr("New message received, close window anyway?"));
			dialog->addButton(QMessageBox::Yes, tr("Close window"));
			dialog->addButton(QMessageBox::No, tr("Cancel"));

			if (!dialog->ask())
			{
				e->ignore();
				return;
			}
		}
	}

 	QWidget::closeEvent(e);
}
Exemple #6
0
void ChatEditBox::openInsertImageDialog()
{
	ChatImageService *chatImageService = CurrentChat.chatAccount().protocolHandler()->chatImageService();
	if (!chatImageService)
		return;

	// QTBUG-849
	QString selectedFile = QFileDialog::getOpenFileName(this, tr("Insert image"), configuration()->deprecatedApi()->readEntry("Chat", "LastImagePath"),
							tr("Images (*.png *.PNG *.jpg *.JPG *.jpeg *.JPEG *.gif *.GIF *.bmp *.BMP);;All Files (*)"));
	if (!selectedFile.isEmpty())
	{
		QFileInfo f(selectedFile);

		configuration()->deprecatedApi()->writeEntry("Chat", "LastImagePath", f.absolutePath());

		if (!f.isReadable())
		{
			MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Kadu"), tr("This file is not readable"), QMessageBox::Ok, this);
			return;
		}

		Error imageSizeError = chatImageService->checkImageSize(f.size());
		if (!imageSizeError.message().isEmpty())
		{
			MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Kadu"), imageSizeError.message(), this);
			dialog->addButton(QMessageBox::Yes, tr("Send anyway"));
			dialog->addButton(QMessageBox::No, tr("Cancel"));

			switch (imageSizeError.severity())
			{
				case NoError:
					break;
				case ErrorLow:
					if (dialog->ask())
						return;
					break;
				case ErrorHigh:
					MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-error")), tr("Kadu"), imageSizeError.message(), QMessageBox::Ok, this);
					return;
				default:
					break;
			}
		}

		int tooBigCounter = 0;
		int disconnectedCounter = 0;

		foreach (const Contact &contact, CurrentChat.contacts())
		{
			if (contact.currentStatus().isDisconnected())
				disconnectedCounter++;
			else if (contact.maximumImageSize() == 0 || contact.maximumImageSize() * 1024 < f.size())
				tooBigCounter++;
		}

		QString message;
		if (1 == CurrentChat.contacts().count())
		{
			Contact contact = *CurrentChat.contacts().constBegin();
			if (tooBigCounter > 0)
				message = tr("This image has %1 KiB and may be too big for %2.")
						.arg((f.size() + 1023) / 1024).arg(contact.display(true)) + '\n';
			else if (disconnectedCounter > 0)
				message = tr("%1 appears to be offline and may not receive images.").arg(contact.display(true)) + '\n';
		}
		else
		{
			if (tooBigCounter > 0)
				message = tr("This image has %1 KiB and may be too big for %2 of %3 contacts in this conference.")
						.arg((f.size() + 1023) / 1024).arg(tooBigCounter).arg(CurrentChat.contacts().count()) + '\n';
			if (disconnectedCounter > 0)
				message += tr("%1 of %2 contacts appear to be offline and may not receive images.").arg(disconnectedCounter).arg(CurrentChat.contacts().count()) + '\n';
		}
		if (tooBigCounter > 0 || disconnectedCounter > 0)
			message += tr("Do you really want to send this image?");

		MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"), message, this);
		dialog->addButton(QMessageBox::Yes, tr("Send anyway"));
		dialog->addButton(QMessageBox::No, tr("Cancel"));

		if (!message.isEmpty() && !dialog->ask())
			return;

		InputBox->insertHtml(QString("<img src='%1' />").arg(selectedFile));
	}