void BugReportController::onPromptFinishedCreateComment(bb::system::SystemUiResult::Type result) { using namespace bb::cascades; using namespace bb::system; if(result != bb::system::SystemUiResult::ConfirmButtonSelection) { SystemDialog* prompt = qobject_cast<SystemDialog*>(sender()); prompt->deleteLater(); return; } SystemDialog* prompt = qobject_cast<SystemDialog*>(sender()); prompt->deleteLater(); const QUrl url(GITHUB_URL + REPOSITORY + "/issues/" + QString::number(m_TmpLabel) + "/comments"); QString label_str = m_Labels.key(m_TmpLabel); QByteArray datas; datas += QString("{").toAscii(); datas += QString(QString("\"body\": \"") + m_TmpBody + "\"").toAscii(); datas += QString("}").toAscii(); QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); request.setRawHeader("Authorization", (QString("token ") + GITHUB_ACCESS_TOKEN).toAscii()); QNetworkReply* reply = m_NetworkAccessManager->post(request, datas); bool ok = connect(reply, SIGNAL(finished()), this, SLOT(checkReplyInsertComment())); Q_ASSERT(ok); Q_UNUSED(ok); }
void DriveController::onPromptFinishedShareFile(bb::system::SystemUiResult::Type result) { using namespace bb::cascades; using namespace bb::system; qDebug() << "onPromptFinishedShareFile " << result; if(result == bb::system::SystemUiResult::ConfirmButtonSelection) { SystemDialog* prompt = qobject_cast<SystemDialog*>(sender()); if(prompt != NULL) { QString url; m_Mutex.lockForRead(); for(int i = 0 ; i < m_DriveItems.length() ; ++i) if(m_DriveItems.at(i)->getID() == m_SelectedItemForSharing) { url = m_DriveItems.at(i)->getOpenLink(); break; } m_Mutex.unlock(); m_Google->shareId(m_SelectedItemForSharing, url); prompt->deleteLater(); } } }
void NetImageManager::onSslErrors(QNetworkReply * reply, const QList<QSslError> & errors) { foreach (QSslError e, errors) qDebug() << "SSL error: " << e; SystemDialog *dialog = new SystemDialog("OK"); dialog->setTitle(tr("SSL errors received")); dialog->setBody(tr("We have received information about a security breach in the protocol. Press \"OK\" to terminate the application")); // Connect your functions to handle the predefined signals for the buttons. // The slot will check the SystemUiResult to see which button was clicked. bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onDialogFinished(bb::system::SystemUiResult::Type))); if (success) { // Signal was successfully connected. // Now show the dialog box in your UI dialog->show(); } else { // Failed to connect to signal. dialog->deleteLater(); } }
void BugReportController::insertComment(const QString &body, int issueNumber) { // get the list of issues m_TmpBody = body; m_TmpLabel = issueNumber; if(body.isEmpty()) { bb::system::SystemToast *toast = new bb::system::SystemToast(this); toast->setBody(tr("A comment should not be empty.")); toast->setPosition(bb::system::SystemUiPosition::MiddleCenter); toast->show(); return; } using namespace bb::cascades; using namespace bb::system; SystemDialog *dialog = new SystemDialog("Yes", "No"); dialog->setTitle(tr("Create a new comment")); dialog->setBody(tr("Do you want to submit this comment? Please make sure that the content of the message is anonymous.")); bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onPromptFinishedCreateComment(bb::system::SystemUiResult::Type))); if (success) { dialog->show(); } else { dialog->deleteLater(); } }
void BalanceController::deleteRecord(int id) { using namespace bb::cascades; using namespace bb::system; SystemDialog *dialog = new SystemDialog("Yes", "No"); dialog->setTitle(tr("Delete record")); dialog->setBody(tr("Are you sure you want to delete this record? ")); bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onPromptFinishedDeleteRecord(bb::system::SystemUiResult::Type))); if (success) { m_tmp_id = id; // Signal was successfully connected. // Now show the dialog box in your UI. dialog->show(); } else { // Failed to connect to signal. // This is not normal in most cases and can be a critical // situation for your app! Make sure you know exactly why // this has happened. Add some code to recover from the // lost connection below this line. dialog->deleteLater(); } }
void DriveController::openForSharing(const QString &id, const QString &type) { // ---------------------------------------------------------------------------------------------- // get the dataModel of the listview if not already available using namespace bb::cascades; if(m_ListView == NULL) { qWarning() << "did not received the listview. quit."; return; } GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel()); if(type == "application/vnd.google-apps.folder") { if(dataModel != NULL) dataModel->clear(); m_Google->getFileList(id); } else { using namespace bb::cascades; using namespace bb::system; SystemDialog *dialog = new SystemDialog("Yes", "No"); dialog->setTitle("Share"); dialog->setBody("Do you want to share this document?"); bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onPromptFinishedShareFile(bb::system::SystemUiResult::Type))); if (success) { // Signal was successfully connected. // Now show the dialog box in your UI. m_SelectedItemForSharing = id; dialog->show(); } else { // Failed to connect to signal. // This is not normal in most cases and can be a critical // situation for your app! Make sure you know exactly why // this has happened. Add some code to recover from the // lost connection below this line. dialog->deleteLater(); } } }
// A public function to display a SystemDialog in your UI void ApplicationUI::showDialog() { // Set up the SystemDialog with a title and some body text. // Label the two standard buttons with specific text. // Add a custom button as well. SystemDialog *dialog = new SystemDialog("Save as", "Discard changes", "Cancel"); dialog->setTitle("Save changes"); dialog->setBody("Save your changes and close the document?"); dialog->setEmoticonsEnabled(true); // Connect the finished() signal to the onDialogFinished() slot. // The slot will check the SystemUiResult to see which // button was tapped. bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onDialogFinished(bb::system::SystemUiResult::Type))); if (success) { // Signal was successfully connected. // Now show the dialog box in your UI. dialog->show(); } else { // Failed to connect to signal. // This is not normal in most cases and can be a critical // situation for your app! Make sure you know exactly why // this has happened. Add some code to recover from the // lost connection below this line. dialog->deleteLater(); } }