Exemple #1
0
/** 
 * maybeSave	-	some thing to do before the next operation
 *
 * @return true if all preparation has done; false if the user cancel the operation.
 */
bool MainWindow::maybeSave()
{
    if (isModified){
        // Create an warning dialog
        QMessageBox box;
        box.setWindowTitle(tr("Warning"));
        box.setIcon(QMessageBox::Warning);
        box.setText(tr("The current file %1 has been changed. Save?").arg(curFile));

        QPushButton *yesBtn = box.addButton(tr("Yes(&Y)"),
                                            QMessageBox::YesRole);
        box.addButton(tr("No(&N)"), QMessageBox::NoRole);
        QPushButton *cancelBut = box.addButton(tr("Cancel(&C)"),
                                           QMessageBox::RejectRole);

        box.exec();
        if (box.clickedButton() == yesBtn)
            return save();
        if (box.clickedButton() == cancelBut)
            return false;
    }
    return true;
}
void subMainWindow::closeEvent(QCloseEvent *)
{
    if(noSave)
    {
        QMessageBox saveWarnBox;
        saveWarnBox.setWindowTitle(tr("警告"));
        QPushButton *save = saveWarnBox.addButton(tr("保存"),QMessageBox::ActionRole);
        QPushButton *cancel = saveWarnBox.addButton(tr("不保存"),QMessageBox::ActionRole);
        saveWarnBox.setIconPixmap(tr(":/res/qt.ico"));
        saveWarnBox.setText(tr("是否保存图片?"));

        saveWarnBox.exec();

        if(save == saveWarnBox.clickedButton())
        {
            saveImage();
        }
        if(cancel == saveWarnBox.clickedButton())
        {
            return;
        }
    }
}
Exemple #3
0
bool MdiChild::maybeSave()  // 是否需要保存
{
    if (document()->isModified()) { // 如果文档被更改过
        QMessageBox box;
        box.setWindowTitle(tr("多文档编辑器"));
        box.setText(tr("是否保存对“%1”的更改?")
                    .arg(userFriendlyCurrentFile()));
        box.setIcon(QMessageBox::Warning);

        // 添加按钮,QMessageBox::YesRole可以表明这个按钮的行为
        QPushButton *yesBtn = box.addButton(tr("是(&Y)"),QMessageBox::YesRole);

        box.addButton(tr("否(&N)"),QMessageBox::NoRole);
        QPushButton *cancelBtn = box.addButton(tr("取消"),
                                               QMessageBox::RejectRole);
        box.exec(); // 弹出对话框,让用户选择是否保存修改,或者取消关闭操作
        if (box.clickedButton() == yesBtn)// 如果用户选择是,则返回保存操作的结果
            return save();
        else if (box.clickedButton() == cancelBtn) // 如果选择取消,则返回false
            return false;
    }
    return true; // 如果文档没有更改过,则直接返回true
}
void QmitkPolhemusTrackerWidget::on_m_AdjustHemisphere_clicked()
{
  int _tool = GetSelectedToolIndex();
  QMessageBox msgBox;
  QString _text;
  if (_tool == -1)
  {
    _text.append("Adjusting hemisphere for all tools.");
    msgBox.setText(_text);
    _text.clear();
    _text = tr("Please make sure, that the entire tools (including tool tip AND sensor) are placed in the positive x hemisphere. Press 'Adjust hemisphere' if you are ready.");
    msgBox.setInformativeText(_text);
  }
  else
  {
    _text.append("Adjusting hemisphere for tool '");
    _text.append(m_Controls->m_ToolSelection->currentText());
    _text.append(tr("' at port %2.").arg(_tool));
    msgBox.setText(_text);
    _text.clear();
    _text = tr("Please make sure, that the entire tool (including tool tip AND sensor) is placed in the positive x hemisphere. Press 'Adjust hemisphere' if you are ready.");
    msgBox.setInformativeText(_text);
  }

  QPushButton *adjustButton = msgBox.addButton(tr("Adjust hemisphere"), QMessageBox::ActionRole);
  QPushButton *cancelButton = msgBox.addButton(QMessageBox::Cancel);
  msgBox.exec();
  if (msgBox.clickedButton() == adjustButton) {
    // adjust
    m_TrackingDevice->AdjustHemisphere(_tool);
    MITK_INFO << "Adjusting Hemisphere for tool " << m_Controls->m_ToolSelection->currentText().toStdString();
  }
  else if (msgBox.clickedButton() == cancelButton) {
    // abort
    MITK_INFO << "Cancel 'Adjust hemisphere'. No harm done...";
  }
}
void PlaneGUI::on_pushButton_2_clicked()
{
    FinalProject::UsefulFunctions useThis;
    std::string first_name = airport.selected_passenger->Get_First();
    std::string last_name = airport.selected_passenger->Get_Last();
    int age = airport.selected_passenger->Get_Age();
    int row_chosen = ui->row_chosen_2->text().toInt();
    std::string seat_chosen = ui->seat_chosen_2->text().toUtf8().constData();

    if (first_name == "" || last_name == "" || age == 0 || row_chosen == 0 || seat_chosen == "") {
        // Missing Stuff!
        cout << "Something SHitty!" << endl;
    }
    else {
        // Offer A reservation
        QMessageBox msgBox;
        msgBox.setWindowTitle("Reserve Seat");
        msgBox.setText("Are you sure you would like to reserve seat " + QString::number(row_chosen) + QString::fromStdString(seat_chosen));
        msgBox.setStandardButtons(QMessageBox::Yes);
        msgBox.addButton(QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::No);
        if(msgBox.exec() == QMessageBox::Yes){
            int row_assigned = row_chosen;
            int seat_assigned = useThis.getIntFromSeatLetter(seat_chosen) + 1;
            // do something
            if (airport.Check_For_Duplicate_Passenger(first_name,last_name,age)) {
                airport.selected_passenger = airport.Get_Duplicate_Passenger(first_name,last_name,age);

                airport.selected_flight->Add_Passenger_To_Flight(airport.selected_passenger,row_assigned,seat_assigned);

                airport.selected_flight->assigned_plane->Reserve_From_External_File(row_assigned-1, seat_assigned-1,
                                                                            airport.selected_flight->most_recently_added);
            }
            else {
                airport.selected_flight->Add_Passenger_To_Flight(first_name,last_name,age, row_assigned,
                                                            seat_assigned);
                airport.selected_flight->assigned_plane->Reserve_From_External_File((row_assigned - 1),
                                                                               (seat_assigned - 1),
                                                                               airport.selected_flight->most_recently_added);
                airport.all_passengers[airport.current_passenger_amount] = airport.selected_flight->most_recently_added; // add the most recently added passenger to the list of all passengers
                airport.current_passenger_amount++;
            }
            ui->stackedWidget->setCurrentIndex(0);
        }else {
            // do something else
            ui->stackedWidget->setCurrentIndex(0);
        }
    }
}
Exemple #6
0
int main(int argv, char **args)
{
  QApplication app(argv, args);

    QStateMachine machine;

//![0]
    QState *s1 = new QState();
    QState *s11 = new QState(s1);
    QState *s12 = new QState(s1);
    QState *s13 = new QState(s1);
    s1->setInitialState(s11);
    machine.addState(s1);
//![0]

//![2]
    s12->addTransition(quitButton, SIGNAL(clicked()), s12);
//![2]

//![1]
    QFinalState *s2 = new QFinalState();
    s1->addTransition(quitButton, SIGNAL(clicked()), s2);
    machine.addState(s2);
    machine.setInitialState(s1);

    QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
//![1]

  QButton *interruptButton = new QPushButton("Interrupt Button");
  QWidget *mainWindow = new QWidget();

//![3]
    QHistoryState *s1h = new QHistoryState(s1);

    QState *s3 = new QState();
    s3->assignProperty(label, "text", "In s3");
    QMessageBox *mbox = new QMessageBox(mainWindow);
    mbox->addButton(QMessageBox::Ok);
    mbox->setText("Interrupted!");
    mbox->setIcon(QMessageBox::Information);
    QObject::connect(s3, SIGNAL(entered()), mbox, SLOT(exec()));
    s3->addTransition(s1h);
    machine.addState(s3);

    s1->addTransition(interruptButton, SIGNAL(clicked()), s3);
//![3]

  return app.exec();
}
Exemple #7
0
void TimeLapseWidget::stopPressed() {

    stopShooting();

    // Only ask about the movie if there are any pictures to make into a movie
    if (numPics>0) {
        QMessageBox msgBox;
        msgBox.setText(tr("%1 images were taken before \"Stop\" was pressed.\n").arg(numPics));
        msgBox.setInformativeText(tr("Do you want to make a movie with these images?"));

        // msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        QPushButton *yesButton = msgBox.addButton(QMessageBox::Yes);
        msgBox.addButton(QMessageBox::No);
        QPushButton *noAndDeleteButton = msgBox.addButton(tr("No, and delete images"), QMessageBox::ActionRole);

        msgBox.exec();

        if (msgBox.clickedButton() == yesButton) {
            makeMovie();
        } else if (msgBox.clickedButton() == noAndDeleteButton) {
            removeImages();
        }
    }
}
Exemple #8
0
void MainWindow::delete_clicked()
{
    QString tk_id;
    if (current_tab==2)
    {
        //tk_id=tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),0)).toString();
    //else
        tk_id=tasks_full_model->data(tasks_full_model->index(ui->tableView_2->currentIndex().row(),0)).toString();

    QMessageBox m;
    m.setText(trUtf8("Θέλετε να διαγράψετε την επιλεγμένη κίνηση"));
    m.setInformativeText(trUtf8("ΠΡΟΣΟΧΗ!!!"));
    QAbstractButton *acc = m.addButton(trUtf8("Ναί"),
                    QMessageBox::ActionRole);
    QAbstractButton *rej = m.addButton(trUtf8("Όχι"), QMessageBox::ActionRole);

    m.move(100, 100);
    QFont serifFont("Times", 18, QFont::Bold);
    m.setFont(serifFont);
    m.setDefaultButton((QPushButton*)rej);

    m.exec();
    if (m.clickedButton() == rej)
        return;

    if (m.clickedButton() == acc)
    {
        QSqlQuery query(db1);
        //qDebug()<<"TID"<<tk_id;
        query.exec("delete from tasks where id="+tk_id);
    }
    refresh_tasks();
    refresh_full_tasks();
    ui->pushDelete->setEnabled(FALSE);
    }
}
Exemple #9
0
bool LightscreenWindow::closingWithoutTray()
{
    if (settings()->value("options/disableHideAlert", false).toBool()) {
        return false;
    }

    QMessageBox msgBox;
    msgBox.setWindowTitle(tr("Lightscreen"));
    msgBox.setText(tr("You have chosen to hide Lightscreen when there's no system tray icon, so you will not be able to access the program <b>unless you have selected a hotkey to do so</b>.<br>What do you want to do?"));
    msgBox.setIcon(QMessageBox::Warning);

    msgBox.setStyleSheet("QPushButton { padding: 4px 8px; }");

    auto enableButton      = msgBox.addButton(tr("Hide but enable tray"), QMessageBox::ActionRole);
    auto enableQuietButton = msgBox.addButton(tr("Hide and don't warn"), QMessageBox::ActionRole);
    auto hideButton        = msgBox.addButton(tr("Just hide"), QMessageBox::ActionRole);
    auto abortButton       = msgBox.addButton(QMessageBox::Cancel);

    Q_UNUSED(abortButton);

    msgBox.exec();

    if (msgBox.clickedButton() == hideButton) {
        return true;
    } else if (msgBox.clickedButton() == enableQuietButton) {
        settings()->setValue("options/disableHideAlert", true);
        applySettings();
        return true;
    } else if (msgBox.clickedButton() == enableButton) {
        settings()->setValue("options/tray", true);
        applySettings();
        return true;
    }

    return false; // Cancel.
}
Exemple #10
0
void Widget::on_commitButton_clicked()
{
    QString name = ui->cnameLineEdit->text();
    QString sex = ui->cmaleRadioButton->isChecked() ? tr("男") : tr("女");
    QString id = ui->cidLineEdit->text();
    QString phone = ui->cphoneLineEdit->text();
    QString checkintime = ui->ccheckintimeDateEdit->text();

    QList<QTableWidgetItem*> items = ui->orderRoomTableWidget->selectedItems();
    QStringList roomnos;
    foreach (QTableWidgetItem * item, items)
    {
        roomnos << item->text();
    }

    if (name.isEmpty() || id.length() != 18 || phone.length() != 11)
    {
        QMessageBox::information(this, tr("预定管理"), tr("用户信息不完整"));
    }
    else if (items.isEmpty())
    {
        QMessageBox::information(this, tr("预定管理"), tr("没有选定预定房间"));
    }
    else
    {
        QString roomno;
        foreach (QString str, roomnos)
        {
            roomno += str + " ";
        }

        QString text = tr("姓名:") + name + tr("\n性别:") + sex + tr("\n身份证号:") + id +
                       tr("\n联系电话:") + phone + tr("\n预定入住时间:") + checkintime +
                       tr("\n预定的房号:") + roomno;
        QMessageBox box;
        box.setWindowTitle(tr("信息确认"));
        box.setText(text);
        box.addButton(tr("确定"), QMessageBox::AcceptRole);
        box.addButton(tr("取消"), QMessageBox::RejectRole);


        if (box.exec() == QMessageBox::AcceptRole)
        {
            // ## 提交成功,将信息录入数据库,同时,更新此界面
            dealOrderPage();
            resetOrderPage();
        }
    }
Exemple #11
0
void MainWindow::about(){
    QMessageBox msgBox;
    msgBox.setWindowTitle("About");
    msgBox.addButton(QMessageBox::Ok);
    msgBox.setText("<p align='center'>Binary Decision Diagram(BDD)<br>"
                        "Version 0.1<br>"
                        "By Ali Diouri<br>"
                      "[email protected]<br>"
               "Licensed under BSD 3-Clause License</p>");
    msgBox.setIcon(QMessageBox::Information);
    int selection = msgBox.exec();
    if(selection == QMessageBox::Yes) {
        this->activateWindow();
        lineEdit->setFocus();
    }
}
void PlaneGUI::on_cancel_flight_clicked()
{
    QMessageBox msgBox;
    msgBox.setWindowTitle("Cancel Flight");
    msgBox.setText("Are you sure you would like to cancel this flight?");
    msgBox.setStandardButtons(QMessageBox::Yes);
    msgBox.addButton(QMessageBox::No);
    msgBox.setDefaultButton(QMessageBox::No);
    if(msgBox.exec() == QMessageBox::Yes){
        // do something
        airport.Return_Flight();
        ui->stackedWidget->setCurrentIndex(0);
    }else {
        // do something else
    }
}
Exemple #13
0
void Cmap_button::delete_attempt()
{
    QMessageBox msg;
    msg.setText( tr( "Are you really sure that you want to delete " )
                 + this->text + tr( " ?" ) );
    msg.addButton( tr( "Delete" ), QMessageBox::AcceptRole );
    msg.addButton( tr( "Cancel" ), QMessageBox::RejectRole );
    if ( msg.exec() == QDialog::Rejected )
    {
        //remove map files
        QFile f;
        f.remove( this->absolute_map_path );
        f.remove( this->absolute_map_path + ".preview" );
    }

    QTimer::singleShot( 500, this, SIGNAL(please_refresh_as_we_deleted_something()) );
}
Exemple #14
0
int MainWindow::execCmdList(QDomElement node)
{
    QMessageBox info;
    info.addButton(QMessageBox::Ok);
    info.setText(("开始进行系统备份,请按照提示执行"));
    info.exec();
    QString cmd,errorString;
    int cmdType = 0,errorCheckType=0,timeOut=0;
//    QStringList par;
//    par<<"";
    int checkValue;
    while(!node.isNull()){
        cmd = node.attributeNode("cmd").nodeValue();
        errorString = node.attributeNode("errorString").nodeValue();
        cmdType = node.attributeNode("type").nodeValue().toInt();
        errorCheckType = node.attributeNode("errorCheckType").nodeValue().toInt();
        timeOut = node.attributeNode("timeOut").nodeValue().toInt();
        node = node.nextSiblingElement();
        qDebug()<<cmd <<errorString<<cmdType<<errorCheckType<<timeOut;
        switch(cmdType){
        case 1:
            qDebug()<<"cmd-->" << cmd;
 //           this->pointer->waitForFinished(timeOut*1000);
            this->pointer->start(cmd);
            this->pointer->waitForFinished(timeOut*1000);
            checkValue = this->checkError(errorCheckType,&errorString);
            if(checkValue < 0){
                return checkValue;
            }
            break;
        case 2:
            qDebug()<<"status :"<<cmd;
            break;
        case 3:
            info.setText((cmd));
            info.exec();
            break;
        case 4:

            break;
        default:
            break;
        }
    }
    return 1;
}
Exemple #15
0
bool ClosableImage::confirmDeleteImage()
{
    if (Settings::instance()->dontShowDeleteImageConfirm())
        return true;

    QMessageBox msgBox;
    msgBox.setIcon(QMessageBox::Question);
    msgBox.setWindowTitle(tr("Really delete image?"));
    msgBox.setText(tr("Are you sure you want to delete this image?"));
    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
    QCheckBox dontPrompt(QObject::tr("Do not ask again"), &msgBox);
    dontPrompt.blockSignals(true);
    msgBox.addButton(&dontPrompt, QMessageBox::ActionRole);
    int ret = msgBox.exec();
    if (dontPrompt.checkState() == Qt::Checked && ret == QMessageBox::Yes)
        Settings::instance()->setDontShowDeleteImageConfirm(true);
    return (ret == QMessageBox::Yes);
}
Exemple #16
0
void AddNewMLPDialog::accept()
{
	if(checkLayers()){
		done(1);
	}else{
		QMessageBox msgBox;
		msgBox.setIcon(QMessageBox::Critical);
		msgBox.setWindowTitle("Capas incorrectas");
		msgBox.setText("Debe especificar un numero de capas y elementos correctos");
		QPushButton *connectButton = msgBox.addButton(tr("Corregir"), QMessageBox::ActionRole);
		msgBox.setStandardButtons(QMessageBox::Cancel);
		msgBox.setDefaultButton(connectButton);
		int ret = msgBox.exec();
		if(ret == QMessageBox::Cancel){
			done(0);
		}
	}
}
Exemple #17
0
void AgregarCarga::on_aceptar_clicked()
{
    if(ui->deposito->isChecked())
        guardar();
    else
    {
        qlonglong cliente = ui->cliente->itemData(ui->cliente->currentIndex()).toLongLong();
        int grano = ui->grano->itemData(ui->grano->currentIndex()).toInt();

        if(!chequearCompra(cliente, grano) && validarCarga())
        {
            // PREGUNTAR SI SE QUIERE REALIZAR CONTRATO DE COMPRA
            QMessageBox msgBox;
            QString message = "No existe contrato de compra para ";
            message.append(ui->cliente->currentText());
            message.append(". Desea crear un nuevo contrato?");
            msgBox.setText(message);
            msgBox.setWindowTitle("Nueva Carga");
            msgBox.addButton("Aceptar", QMessageBox::YesRole);
            msgBox.addButton("Cancelar", QMessageBox::NoRole);
            msgBox.setIcon(QMessageBox::Question);

            int ret = msgBox.exec();
            int exits;
            ConcretarOfrecido *nuevacompra = new ConcretarOfrecido();

            switch(ret){
                case 0:
                    exits = nuevacompra->nuevaCompra(cliente,grano);
                    if(exits)
                        guardarYcalzar();
                    else
                        QMessageBox::warning(0, QObject::tr("Error"),"Ha ocurrido un error, por favor intentelo de nuevo.");
                    break;
                 case 1:
                    guardarYcalzar();
                break;
            }
        }
        else
           guardarYcalzar();

    }
}
void TimeLapseGenMain::loadImagesIntoMemory()
{
    QPixmap *lapseImage;
    imageFileInfo *fileInfo;
    //QFileInfo info;

    QProgressDialog progress("Loading Images ....", QString(), 0, selectedFileNames.count(), this);

    progress.setWindowModality(Qt::WindowModal);
    progress.show();

    lapseImage = new QPixmap(selectedFileNames[0]);

    ui->labelImage->setPixmap(lapseImage->scaled(600, 400, Qt::KeepAspectRatio, Qt::SmoothTransformation));

    for (int i=0; i < selectedFileNames.count(); i++){
        fileInfo = new imageFileInfo();

        QFileInfo info(selectedFileNames[i]);
        fileInfo->setCreatedTime(info.created());
        fileInfo->setFilePath(info.filePath());
        fileInfo->setFilename(info.fileName());

        ImageFileInfoList.append(*fileInfo);

        progress.setValue(i);
    }

    mencoderPresent = true;
    avconvPresent   = true;

    /* Check if we have required tools to generate timelapse */
    if ( !checkMencoder() )
    {
        QMessageBox msg;
        msg.setText("Unable to find mencoder tool...\nInstall it by running 'sudo apt-get install mencoder' on the terminal");
        msg.setIcon(QMessageBox::Warning);
        msg.addButton(QMessageBox::Ok);
        msg.exec();
        //QMessageBox::info(this, "Tools Required", "Unable to find mencoder tool...\nInstall it by running 'sudo apt-get install mencoder' on the terminal", QMessageBox::Ok);
        mencoderPresent = false;
    }
}
Exemple #19
0
void Priorities::slotDeleteRecords(void)
{
    QList<QVariant> list;
    QSqlQuery       stored;
    QString         m_name;

    unsigned i(0);
    unsigned m_code = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), i).data(Qt::DisplayRole).toUInt();

    if (m_selectionModel->currentIndex().column() != 1){
         m_name = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), 1).data(Qt::DisplayRole).toString();
    } else {
         m_name = m_selectionModel->currentIndex().data(Qt::DisplayRole).toString();
    }

    if (m_selectionModel->isSelected(m_selectionModel->currentIndex())){
        QMessageBox answer;
                    answer.setText(QString(tr("Подтверждаете удаление <b>%1</b>?").arg(m_name)));
                    answer.setWindowTitle(QString(tr("Удаление")));
                    answer.setIcon(QMessageBox::Question);

        QPushButton *m_delete = answer.addButton(QString(tr("Удалить")), QMessageBox::ActionRole);
        QPushButton *m_cancel = answer.addButton(QString(tr("Отмена")),  QMessageBox::ActionRole);

        answer.exec();

        if (answer.clickedButton() == m_delete){
            list.append(m_code);
            stored = execStored(currentDatabase(), "DeletePriorityType", storageHashTable(list));
            stored.finish();

            slotRefreshRecords();

        } else if (answer.clickedButton() == m_cancel){
            treeView->clearSelection();
            answer.reject();
        }
    } else {
        Communicate::showing(QString("Не удается удалить,\n запись не выбрана"), 3000);
    }
    m_selectedItem = false;
}
Exemple #20
0
void LLWebPage::javaScriptAlert(QWebFrame* frame, const QString& msg)
{
    Q_UNUSED(frame);
    QMessageBox *msgBox = new QMessageBox;
    msgBox->setWindowTitle(tr("JavaScript Alert - %1").arg(mainFrame()->url().host()));
    msgBox->setText(msg);
    msgBox->addButton(QMessageBox::Ok);

    QGraphicsProxyWidget *proxy = webView->scene()->addWidget(msgBox);
    proxy->setWindowFlags(Qt::Window); // this makes the item a panel (and will make it get a window 'frame')
    proxy->setPanelModality(QGraphicsItem::SceneModal);
    proxy->setPos((webView->boundingRect().width() - msgBox->sizeHint().width())/2,
                  (webView->boundingRect().height() - msgBox->sizeHint().height())/2);
    proxy->setActive(true); // make it the active item

    connect(msgBox, SIGNAL(finished(int)), proxy, SLOT(deleteLater()));
    msgBox->show();

    webView->scene()->setFocusItem(proxy);
}
Exemple #21
0
void LazyWord::about()			// shwo the about information
{
	QMessageBox msgBox;
	msgBox.setText(tr("\tLazyWord is based on the stardict at present(not all),which can help Lazy man like me to remember the word where you store inthe stardict and import them into LazyWord's Databases! \n"
                             "\tNow enjoy yourself!Enjoy Lazing!\n"
                                "\tCopyright © 2009-2010 frankyue\n"
                                "\tE-mail:[email protected]"
                                ));
	msgBox.setDetailedText(tr("website: http://github.com/frankyue/lazyword/tree/master"));
	msgBox.setStandardButtons(QMessageBox::Ok );
	QPushButton *diag = msgBox.addButton(tr("Help"), QMessageBox::HelpRole);
	msgBox.exec();
	if (msgBox.clickedButton() == diag) 
		{
			QWidget *uiwidget= new QWidget(0,Qt::Dialog);
			ui.setupUi(uiwidget);
			//uiwidget->setGeometry(100,1000,1000,150);
			uiwidget->show();			
		}	
}
Exemple #22
0
int MainWindow::deniedEvent(QString &login){
    QMessageBox* note =
        new QMessageBox(QMessageBox::Information, tr("The application was not accepted"),
                        login + tr(" has not received your application."),
                        QMessageBox::Retry|QMessageBox::Cancel);
    note->addButton(tr("Delete"), QMessageBox::ApplyRole);

    int result = note->exec();
    qDebug() << result << note->clickedButton() << note->buttonRole(note->clickedButton());
    delete note;
    switch(note->buttonRole(note->clickedButton())){
        case QMessageBox::AcceptRole:
            return account.friendRequest(login, contact_action::add).statusCode;
        case QMessageBox::RejectRole:
            break;
        case QMessageBox::ApplyRole:
            return on_DeleteContactButton_clicked();
        default: break;
    }
    return 0;
}
Exemple #23
0
void DiaryEditor::on_handinBtn_clicked()
{
//    获取数据

    QString title = ui->titleEdit->text ();
    QString content = ui->contentEdit->toPlainText ();
     QString date = ui->dateEdit->text ();
     QString name = ui->nameEdit->text ();

     QString *info = new QString[4];
    info[0]= title;
    info[1] = content;
    info[2] = date;
    info[3] = name;
    //to be del
        QMessageBox *msg = new 	QMessageBox;
        msg->addButton (QMessageBox::Ok);
        msg->setText (tr("日志已发出!"));
        msg->show ();
    emit handinDiary(this,info);
}
// Execute this while closing the app
void EditorWindow::closeEvent (QCloseEvent *ev)
{
    // show a dialog asking whether to go to
    QMessageBox msgBox;
    msgBox.setText ("Quit tuxtorial");
    msgBox.setInformativeText ("Do you want to quit or hide to system tray");

    QPushButton *hideButton = msgBox.addButton ("Hide", QMessageBox::RejectRole);
    QPushButton *quitButton = msgBox.addButton ("Quit", QMessageBox::AcceptRole);

    msgBox.exec ();
    if(msgBox.clickedButton () == hideButton)
    {
        ev->ignore ();
        this->hide ();
    }
    else
    {
        CleanUp ();
    }
}
Exemple #25
0
void AppControler::showErrorMessage(const QString &type, const QString &msg)
{
    QMessageBox::Icon icon;
    QMessageBox msgBox;

    if(type=="critical"){
        icon = QMessageBox::Critical;
    }
    else{
        icon = QMessageBox::Warning;
    }

    msgBox.setWindowTitle("Error");
    msgBox.setIcon(icon);
    msgBox.setText(msg);
    msgBox.addButton(QMessageBox::Ok);

    msgBox.exec();
    if(type=="critical"){
        QApplication::exit(1);
    }
}
void RegisterWindow::registerSelected(){
	// Envoi de la requête à la base de données
	User newUser;
	newUser.pseudo = idText->text().toStdString();
	newUser.passwd = mdpText->text().toStdString();
	newUser.email = emailText->text().toStdString();

	try
	{
		_db.registerUser(newUser);
		this->close();
		profilwindow  = new ProfilWindow(_db, newUser);
	}
	catch(std::runtime_error&)
	{
		QMessageBox msgBox;
		msgBox.setWindowTitle("Erreur");
		msgBox.setText("Personne déja existante");
		msgBox.addButton("Ok",QMessageBox::YesRole);
		msgBox.exec();
	}
}
Exemple #27
0
void Carga::eliminarCarga(int id){

    QMessageBox msgBox;
    msgBox.setText("¿Está seguro que desea eliminar la carga seleccionada?");
    msgBox.setWindowTitle("Eliminar carga");
    msgBox.addButton("Aceptar", QMessageBox::YesRole);
    msgBox.addButton("Cancelar", QMessageBox::NoRole);
    msgBox.setIcon(QMessageBox::Question);

    int ret = msgBox.exec();
    QSqlQuery query;
    switch(ret){
        case 0:
            query.prepare("DELETE FROM cargas WHERE _id = :id");
            query.bindValue(":id",id);
            query.exec();
            loadCargas(start,end);
            break;
        default:
            break;
    }
}
void UpdateChecker::manifestDownloadError(const QString &message)
{
   LOG_ERROR_MESSAGE("Error downloading manifest: " + std::string(message.toUtf8().constData()));

   URLDownloader* pURLDownloader = qobject_cast<URLDownloader*>(sender());
   if (pURLDownloader && pURLDownloader->manuallyInvoked())
   {
      // WA_DeleteOnClose
      QMessageBox* pMsg = new QMessageBox(
            safeMessageBoxIcon(QMessageBox::Warning),
            QString::fromUtf8("Error Checking for Updates"),
            QString::fromUtf8("An error occurred while checking for updates:\n\n")
            + message,
            QMessageBox::NoButton,
            pOwnerWindow_,
            Qt::Sheet | Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
      pMsg->setWindowModality(Qt::WindowModal);
      pMsg->setAttribute(Qt::WA_DeleteOnClose);
      pMsg->addButton(new QPushButton(QString::fromUtf8("OK")), QMessageBox::AcceptRole);
      pMsg->show();
   }
}
void FontSettingsPage::maybeSaveColorScheme()
{
    if (d_ptr->m_value.colorScheme() == d_ptr->m_ui->schemeEdit->colorScheme())
        return;

    QMessageBox *messageBox = new QMessageBox(QMessageBox::Warning,
                                              tr("Color Scheme Changed"),
                                              tr("The color scheme \"%1\" was modified, do you want to save the changes?")
                                                  .arg(d_ptr->m_ui->schemeEdit->colorScheme().displayName()),
                                              QMessageBox::Discard | QMessageBox::Save,
                                              d_ptr->m_ui->schemeComboBox->window());

    // Change the text of the discard button
    QPushButton *discardButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard));
    discardButton->setText(tr("Discard"));
    messageBox->addButton(discardButton, QMessageBox::DestructiveRole);
    messageBox->setDefaultButton(QMessageBox::Save);

    if (messageBox->exec() == QMessageBox::Save) {
        const ColorScheme &scheme = d_ptr->m_ui->schemeEdit->colorScheme();
        scheme.save(d_ptr->m_value.colorSchemeFileName(), Core::ICore::mainWindow());
    }
}
Exemple #30
0
void MainWindow::on_pushButton_backup_clicked()
{
    QDomElement node = backupDoc.documentElement();
    qDebug()<<node.tagName();
    node = node.firstChildElement();
    qDebug()<<node.tagName();
    while(!node.isNull()){
        if(node.attributeNode("name").nodeValue() == ui->comboBox_backup_plan->currentText()){
            qDebug()<<node.attributeNode("name").nodeValue() << node.tagName();
            break;
        }
        node=node.nextSiblingElement();
    }
    if(node.isNull()){
        QMessageBox info;
        info.addButton(QMessageBox::Ok);
        info.setText(tr("找不到备份方案,请升级后尝试"));
        info.exec();
        return ;
    }
    execCmdList(node.firstChildElement());

}