void MainWindow::checkTextSettings()
{
    QFont consfont;
    if (consfont.fromString(settings.consolefont))
    {
        if (consfont!=consolebrowser->font())
            consolebrowser->setFont(consfont);
    }
    QFont textfont;
    if (textfont.fromString(settings.chatfont))
    {
        QHashIterator<QString, IrcTextBrowser *> chans(channelsJoined);
        while (chans.hasNext())
        {
            chans.next();
            IrcTextBrowser * brwsr = chans.value();
            brwsr->setFont(textfont);
        }

        QHashIterator<QString, MessageDialog *> chats(usersChatting);
        while (chats.hasNext())
        {
            chats.next();
            MessageDialog *msgdlg = chats.value();
            msgdlg->setFont(textfont);
        }
    }
}
Exemplo n.º 2
0
void Game::handleKeypress(const Common::Event &event) {
	if (event.kbd.flags & Common::KBD_CTRL) {
		if (_widepipeCtr == 8) {
			// Implement original game cheating keys here someday
		} else {
			if (event.kbd.keycode == (Common::KEYCODE_a +
					(DEBUG_STRING[_widepipeCtr] - 'a'))) {
				if (++_widepipeCtr == 8) {
					MessageDialog *dlg = new MessageDialog(_vm, 2,
						"CHEATING ENABLED", "(for your convenience).");
					dlg->show();
					delete dlg;
				}
			}
		}
	}

	switch (event.kbd.keycode) {
	case Common::KEYCODE_F1:
		_vm->_dialogs->_pendingDialog = DIALOG_GAME_MENU;
		break;
	case Common::KEYCODE_F5:
		_vm->_dialogs->_pendingDialog = DIALOG_SAVE;
		break;
	case Common::KEYCODE_F7:
		_vm->_dialogs->_pendingDialog = DIALOG_RESTORE;
		break;
	default:
		break;
	}
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
void GaduEditAccountWidget::showStatusToEveryoneToggled(bool toggled)
{
	if (toggled)
		return;

	int count = 0;

	const QVector<Contact> &contacts = m_contactManager->contacts(account());
	foreach (const Contact &contact, contacts)
		if (!contact.isAnonymous() && contact.ownerBuddy().isOfflineTo())
			count++;

	if (!count)
		return;

	MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Status Visibility"),
	                        tr("You are going to reveal your status to several buddies which are currently not allowed to see it.\n"
				  "Are you sure to allow them to know you are available?"));
	dialog->addButton(QMessageBox::Yes, tr("Make my status visible anyway"));
	dialog->addButton(QMessageBox::No, tr("Stay with private status"));
	dialog->setDefaultButton(QMessageBox::No);
	int decision = dialog->exec();

	if (decision == QMessageBox::Yes)
		return;

	ShowStatusToEveryone->setChecked(false);
}
void MainWindow::disconnectFromServer()
{
    irc->disconnectFromServer();

    ui->treeWidget->clearAllChannels();

    QHashIterator<QString, IrcTextBrowser *> chans(channelsJoined);
    while (chans.hasNext())
    {
        chans.next();
        IrcTextBrowser *browser = chans.value();
        int idx = ui->tabWidget->indexOf(browser);
        ui->tabWidget->removeTab(idx);
        delete browser;
    }
    channelsJoined.clear();

    QHashIterator<QString, MessageDialog *> chats(usersChatting);
    while(chats.hasNext())
    {
        chats.next();
        MessageDialog *dlg = chats.value();
        dlg->close();
        delete dlg;
    }
    usersChatting.clear();
}
Exemplo n.º 6
0
int MessageDialog::show2(const Common::String &message, const Common::String &btn1Message, const Common::String &btn2Message) {
	MessageDialog *dlg = new MessageDialog(message, btn1Message, btn2Message);
	dlg->draw();

	GfxButton *defaultButton = !btn2Message.empty() ? &dlg->_btn2 : &dlg->_btn1;
	GfxButton *selectedButton = dlg->execute(defaultButton);
	int result =  (selectedButton == defaultButton) ? 1 : 0;

	delete dlg;
	return result;
}
Exemplo n.º 7
0
void RingworldDemoGame::pauseGame() {
	g_globals->_events.setCursor(CURSOR_ARROW);
	MessageDialog *dlg = new MessageDialog(DEMO_PAUSED_MSG, EXIT_BTN_STRING, DEMO_RESUME_BTN_STRING);
	dlg->draw();

	GfxButton *selectedButton = dlg->execute(&dlg->_btn2);
	bool exitFlag  =  selectedButton != &dlg->_btn2;

	delete dlg;
	g_globals->_events.hideCursor();

	if (exitFlag)
		g_vm->quitGame();
}
Exemplo n.º 8
0
int FTPWindow::DeleteFile(FileObject * file) {
	MessageDialog md;

	int res = md.Create(m_hwnd, TEXT("Deleting file"), TEXT("Are you sure you want to delete this file?"));
	if (res != 1)
		return 0;

	res = m_ftpSession->DeleteFile(file->GetPath());
	if (res == -1)
		return -1;

	m_ftpSession->GetDirectory(file->GetParent()->GetPath());

	return 0;
}
Exemplo n.º 9
0
int FTPWindow::DeleteDirectory(FileObject * dir) {
	MessageDialog md;

	int res = md.Create(m_hwnd, TEXT("Deleting directory"), TEXT("Are you sure you want to delete this directory?"));
	if (res != 1)
		return 0;

	res = m_ftpSession->RmDir(dir->GetPath());
	if (res == -1)
		return -1;

	m_ftpSession->GetDirectory(dir->GetParent()->GetPath());

	return 0;
}
Exemplo n.º 10
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);
}
Exemplo n.º 11
0
void GaduEditAccountWidget::removeAccount()
{
	MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Confrim Account Removal"),
	                        tr("Are you sure do you want to remove account %1 (%2)?")
				.arg(account().accountIdentity().name())
				.arg(account().id()));
	dialog->addButton(QMessageBox::Yes, tr("Remove account"));
	dialog->addButton(QMessageBox::Cancel, tr("Cancel"));
	dialog->setDefaultButton(QMessageBox::Cancel);
	int decision = dialog->exec();

	if (decision == QMessageBox::Yes)
	{
		m_accountManager->removeAccountAndBuddies(account());
		deleteLater();
	}
}
MainWindow::~MainWindow()
{
    delete consolebrowser;
    delete smilebar;
    delete smilewidgetaction;
    delete smilebutton;
    delete channellistdialog;
    delete ui;
    QHashIterator<QString, MessageDialog *> chats(usersChatting);
    while(chats.hasNext())
    {
        chats.next();
        MessageDialog *dlg = chats.value();
        dlg->close();
        delete dlg;
    }
    usersChatting.clear();
}
void MainWindow::userDoubleClicked(const QString &nick)
{
    if (!usersChatting.contains(nick))
    {
        MessageDialog *msgdlg = new MessageDialog(nick, 0);
        connect(msgdlg, SIGNAL(messageReady(QString,QString)), irc, SLOT(sendMessage(QString,QString)));

        QFont chatfont;
        if (chatfont.fromString(settings.chatfont))
            msgdlg->setFont(chatfont);

        msgdlg->show();
        usersChatting.insert(nick, msgdlg);
    }

    MessageDialog *msgdlg = usersChatting.value(nick);
    if (msgdlg)
        msgdlg->show();
}
Exemplo n.º 14
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();
}
Exemplo n.º 15
0
void Game::handleKeypress(const Common::KeyState &kbd) {
	if (kbd.flags & Common::KBD_CTRL) {
		if (_widepipeCtr == 8) {
			// Implement original game cheating keys here someday
		} else {
			if (kbd.keycode == (Common::KEYCODE_a +
					(DEBUG_STRING[_widepipeCtr] - 'a'))) {
				if (++_widepipeCtr == 8) {
					MessageDialog *dlg = new MessageDialog(_vm, 2,
						"CHEATING ENABLED", "(for your convenience).");
					dlg->show();
					delete dlg;
				}
			}
		}
	}

	Scene &scene = _vm->_game->_scene;
	switch (kbd.keycode) {
	case Common::KEYCODE_F1:
		_vm->_dialogs->_pendingDialog = DIALOG_GAME_MENU;
		break;
	case Common::KEYCODE_F5:
		_vm->_dialogs->_pendingDialog = DIALOG_SAVE;
		break;
	case Common::KEYCODE_F7:
		_vm->_dialogs->_pendingDialog = DIALOG_RESTORE;
		break;
	case Common::KEYCODE_PAGEUP:
		scene._userInterface._scrollbarStrokeType = SCROLLBAR_UP;
		scene._userInterface.changeScrollBar();
		break;
	case Common::KEYCODE_PAGEDOWN:
		scene._userInterface._scrollbarStrokeType = SCROLLBAR_DOWN;
		scene._userInterface.changeScrollBar();
		break;


	default:
		break;
	}
}
Exemplo n.º 16
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;
}
Exemplo n.º 17
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);
}
Exemplo n.º 18
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));
	}
Exemplo n.º 19
0
bool YourAccounts::canChangeWidget()
{
	if (ForceWidgetChange)
		return true;

	if (!CurrentWidget)
		return true;

	if (StateNotChanged == CurrentWidget->stateNotifier()->state())
		return true;

	if (!IsCurrentWidgetEditAccount)
	{
		MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Unsaved changes"),
					tr("You have unsaved changes in current account.<br />Do you want to return to edit or discard changes?"));
		dialog->addButton(QMessageBox::Yes, tr("Return to edit"));
		dialog->addButton(QMessageBox::Ignore, tr("Discard changes"));
		dialog->addButton(QMessageBox::Cancel, tr("Cancel"));

		QMessageBox::StandardButton result = (QMessageBox::StandardButton) dialog->exec();

		switch (result)
		{
			case QMessageBox::Yes:
				return false;

			case QMessageBox::Ignore:
				CurrentWidget->cancel();
				return true;

			default:
				return false;
		}
	}

	if (StateChangedDataValid == CurrentWidget->stateNotifier()->state())
	{
		MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Unsaved changes"),
					tr("You have unsaved changes in current account.<br />Do you want to save them?"));
		dialog->addButton(QMessageBox::Save, tr("Save changes"));
		dialog->addButton(QMessageBox::Ignore, tr("Discard"));
		dialog->addButton(QMessageBox::Cancel, tr("Cancel"));

		QMessageBox::StandardButton result = (QMessageBox::StandardButton) dialog->exec();

		switch (result)
		{
			case QMessageBox::Save:
				CurrentWidget->apply();
				return true;

			case QMessageBox::Ignore:
				CurrentWidget->cancel();
				return true;

			default:
				return false;
		}
	}

	if (StateChangedDataInvalid == CurrentWidget->stateNotifier()->state())
	{
		MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Invalid changes"),
					tr("You have invalid changes in current account, which cannot be saved.<br />Do you want to stay in edit or discard changes?"));
		dialog->addButton(QMessageBox::Yes, tr("Stay in edit"));
		dialog->addButton(QMessageBox::Ignore, tr("Discard changes"));
		dialog->addButton(QMessageBox::Cancel, tr("Cancel"));

		QMessageBox::StandardButton result = (QMessageBox::StandardButton) dialog->exec();

		switch (result)
		{
			case QMessageBox::Yes:
				return false;

			case QMessageBox::Ignore:
				CurrentWidget->cancel();
				return true;

			default:
				return false;
		}
	}

	return true;
}
Exemplo n.º 20
0
MessageDialogTC::MessageDialogTC(MessageDialog &messageDialog, unsigned int dialogId) : BasicServerCommand(SC_MESSAGEDIALOG_TC) {
    addStringToBuffer(messageDialog.getTitle());
    addStringToBuffer(messageDialog.getText());
    addIntToBuffer(dialogId);
}