Exemple #1
0
void DMDialog::sendDM()
{
    if( charsLeft() < 0 ) {
        QMessageBox *messageBox = new QMessageBox( QMessageBox::Warning, tr( "Message too long" ), tr( "Your message is too long." ) );
        QPushButton *accept = messageBox->addButton( tr( "&Truncate" ), QMessageBox::AcceptRole );
        QPushButton *reject = messageBox->addButton( tr( "&Edit" ), QMessageBox::RejectRole );
        messageBox->setInformativeText( tr( "You can still post it like this, but it will be truncated." ) );
        messageBox->setDefaultButton( accept );
        messageBox->setEscapeButton( reject );
        messageBox->exec();
        if ( messageBox->clickedButton() == reject )
            return;
        messageBox->deleteLater();
    }

    emit dmRequest( screenName, m_ui->messageTextEdit->toPlainText() );

    progress->start();
    m_ui->sendingLabel->setText( tr( "Sending..." ) );
    m_ui->charsLeftLabel->hide();
    m_ui->sendingLabel->show();
    m_ui->progressLabel->show();
    m_ui->resetButton->setEnabled( false );
    m_ui->sendButton->setEnabled( false );
    m_ui->messageTextEdit->setEnabled( false );
    m_ui->closeButton->setFocus();
}
Exemple #2
0
void gui_settings::ShowBox(bool confirm, const QString& title, const QString& text, const gui_save& entry, int* result = nullptr, QWidget* parent = nullptr)
{
	const std::string dialog_type = confirm ? "Confirmation" : "Info";

	if (entry.name.isEmpty() || GetValue(entry).toBool())
	{
		const QFlags<QMessageBox::StandardButton> buttons = confirm ? QMessageBox::Yes | QMessageBox::No : QMessageBox::Ok;
		const QMessageBox::Icon icon = confirm ? QMessageBox::Question : QMessageBox::Information;

		QMessageBox* mb = new QMessageBox(icon, title, text, buttons, parent);
		mb->deleteLater();

		if (!entry.name.isEmpty())
		{
			mb->setCheckBox(new QCheckBox(tr("Don't show again")));
		}

		connect(mb, &QMessageBox::finished, [&](int res)
		{
			if (result)
			{
				*result = res;
			}
			if (!entry.name.isEmpty() && mb->checkBox()->isChecked())
			{
				SetValue(entry, false);
				LOG_NOTICE(GENERAL, "%s Dialog for Entry %s is now disabled", dialog_type, sstr(entry.name));
			}
		});

		mb->exec();
	}
	else LOG_NOTICE(GENERAL, "%s Dialog for Entry %s was ignored", dialog_type, sstr(entry.name));
}
void MainWindow::onServerError(ServerResponseHandler::ServerError error) 
{
	QMessageBox *messageDialog;
	QPushButton *installButton;
	QPushButton *cancelButton;
	switch(error)
	{
		case MoodBoxCustomServer::Disconnect:
			Q_ASSERT_X(INFOMANAGER->isUserOnline(), "MainWindow::onServerError", "User is offline, but got Disconnect");
			offline(false);
			QMessageBox::information(this, tr(DISCONNECT_TITLE), tr(DISCONNECT_TEXT));
			break;

		case MoodBoxCustomServer::UnsupportedClientVersion:
			offline(false);
			messageDialog = new QMessageBox(QMessageBox::Information, tr(NOT_SUPPORTED_TITLE), tr(NOT_SUPPORTED_TEXT));
			installButton = messageDialog->addButton(tr(INSTALL_NEW_VERSION_BUTTON), QMessageBox::YesRole);
			cancelButton = messageDialog->addButton(tr(CANCEL_TEXT), QMessageBox::NoRole);
			messageDialog->exec();
			if (messageDialog->clickedButton() == installButton)
			{
				startInstallNewVersion();
			};
			messageDialog->deleteLater();
			break;

		case MoodBoxCustomServer::NotAuthenticated:
			Q_ASSERT_X(INFOMANAGER->isUserOnline() || isLoggingOn, "MainWindow::onServerError", "User is offline and not logging on, but got NotAuthenticated");
			if(INFOMANAGER->isUserOnline() || isLoggingOn)
			{
				relogon();
			}
			break;

		case MoodBoxCustomServer::NotificationServerRegistrationFailed:
			Q_ASSERT_X(INFOMANAGER->isUserOnline() || isLoggingOn, "MainWindow::onServerError", "User is offline and not logging on, but got NotificationServerRegistrationFailed");
			if(INFOMANAGER->isUserOnline() || isLoggingOn)
			{
				relogon();
			}
			break;
	}
}
void ControleurAppareils::effacerAppareil(const int &idAppareil)
{
    int usages = MappeurFiches::pourAppareil(idAppareil);
    if (usages == 0) {
        Appareil* appareil = MappeurAppareils::get(idAppareil);
        QMessageBox* confirmation = new QMessageBox(QMessageBox::Warning,
                        tr("Confirmation de la suppression"),
                        tr("Supprimer l'appareil?\n") + appareil->joliOut(),
                        QMessageBox::Yes | QMessageBox::No);
        confirmation->setDefaultButton(QMessageBox::No);
        if (confirmation->exec() == confirmation->Yes) {
            if (MappeurAppareils::supprimer(appareil)) {
                emit Application::get()->nombreAppareilsChange();
            }
        }
        confirmation->deleteLater();
        appareil->deleteLater();
    }
}