void ApplicationUI::showToast(QString message) { SystemToast* toast = new SystemToast(this); toast->setBody(message); toast->setPosition(SystemUiPosition::MiddleCenter); toast->show(); }
void ApplicationUI::showAlert(QString text) { SystemToast *alert = new SystemToast(); alert->setBody(text); alert->show(); }
void ApplicationUI::createToast(QString msg){ SystemToast *toast = new SystemToast(this); toast->setBody(msg); toast->setPosition(SystemUiPosition::MiddleCenter); toast->show(); }
void ApplicationUI::onFileOpenMsgFinished ( bb::system::SystemUiResult::Type type ) { if (type == SystemUiResult::ButtonSelection && this->m_FileOpenRetries < 3) { emit this->updateListView(); } else { this->m_FileOpenRetries = 0; SystemToast* exitFileMsg = new SystemToast(); QString exitMsg = "The app could not open the necessary file needed "; exitMsg.append("to update the list data, and will exit"); exitFileMsg->setBody(exitMsg); exitFileMsg->setPosition(SystemUiPosition::MiddleCenter); exitFileMsg->show(); bool result = QObject::connect( exitFileMsg, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onExitMessageFinished())); Q_ASSERT(result); } }
void SmartSeq::startGame(){ SystemToast *toast = new SystemToast(this); toast->setBody("Great!\nOff we go!"); toast->show(); _score=0; _sequence = ""; _clue = ""; _attemps=0; _root->setProperty("scoreText",QString("%1 pts").arg(_score)); _root->setProperty("answerEnable",true); toast->setBody("The first two characters \n of the sequence are..."); toast->show(); _game->reset(); int firstIndex = _game->getNext(); int secondIndex = _game->getNext(); QString initialSeq = QString("%1%2").arg(_alphabet[firstIndex]).arg(_alphabet[secondIndex]); _sequence+=initialSeq; _root->setProperty("clueText",_clue_format.arg(initialSeq)); _root->setProperty("sequenceText",_sequence); };
void ApplicationUI::onDownloadProgress ( qint64 bytesSent, qint64 bytesTotal ) { if (bytesSent == 0 || bytesTotal == 0) { SystemToast* infoMessage = new SystemToast(); infoMessage->setBody("No data to download or display"); infoMessage->setPosition(SystemUiPosition::MiddleCenter); infoMessage->show(); bool result = QObject::connect( infoMessage, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onExitMessageFinished())); Q_UNUSED(result); Q_ASSERT(result); } else { int currentProgress = (bytesSent * 100) / bytesTotal; SystemProgressToast* pProgToast = new SystemProgressToast(); pProgToast->setBody("Contacting network to download file ..."); pProgToast->setProgress(currentProgress); pProgToast->setState(SystemUiProgressState::Active); pProgToast->setPosition(SystemUiPosition::MiddleCenter); pProgToast->show(); } }
void ApplicationUI::onFileOpenFailed () { SystemToast* fileOpenMsg = new SystemToast(); SystemUiButton* btnRetryFileOpen = fileOpenMsg->button(); this->m_FileOpenRetries += 1; QString btnMsg = "Retry " + QString::number(this->m_FileOpenRetries) + " of 3"; btnRetryFileOpen->setLabel(btnMsg); fileOpenMsg->setPosition(SystemUiPosition::MiddleCenter); fileOpenMsg->setBody("File failed to open"); bool result = QObject::connect( fileOpenMsg, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onFileOpenMsgFinished(bb::system::SystemUiResult::Type))); Q_UNUSED(result); Q_ASSERT(result); fileOpenMsg->show(); }
void ApplicationUI::ShowToast(QString Msg) { using namespace bb::system; SystemToast *toast = new SystemToast(this); toast->setBody(Msg); toast->show(); }
void QBNetwork::showError(const QString &message) { m_userName = ""; emit error(message); qDebug() << message; SystemToast *toast = new SystemToast(this); toast->setBody(message); toast->show(); }
void ApplicationUI::onReadReply() { // We got a reply!!! qDebug() << "We got a reply!!!"; // Retrieve the reply QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); // If reply exists if (reply) { // If the reply ain't an error reply if (reply->error() == QNetworkReply::NoError) { // If the reply length is more than 0 (if it's not empty) const int available = reply->bytesAvailable(); if (available > 0) { // Save the reply to a variable const QByteArray buffer(reply->readAll()); // Print the variable to the console, this is for debugging only qDebug() << "Buffer :" << buffer; // Retrieve the file name QString fileName = reply->url().toString().split("/").last().remove("/"); // Create the new file and writes it QFile thisFile("/accounts/1000/shared/documents/" + (fileName.isEmpty() ? "downloadApp.file" : fileName)); // Print the file path to the console, this is for debugging only qDebug() << "File name :" << thisFile.fileName(); // Try to open the file if (thisFile.open(QIODevice::ReadWrite)) { qDebug() << "File was opened, writing to file"; // Write to the file thisFile.write(buffer); thisFile.flush(); thisFile.close(); // Warn the user that the file is now in the Documents folder SystemToast* pToast = new SystemToast(); pToast->setBody(thisFile.fileName().split("/").last() + " saved to your Documents folder"); pToast->setPosition(SystemUiPosition::MiddleCenter); pToast->show(); } // Memory management thisFile.deleteLater(); } } // end of : if (reply->error() == QNetworkReply::NoError) // Memory management reply->deleteLater(); } // end of : if (reply) }
void AccountList::clearClip() { bb::system::Clipboard clipboard; clipboard.clear(); SystemToast *toast = new SystemToast(this); toast->setBody("clipboard cleared"); toast->setPosition(SystemUiPosition::MiddleCenter); //toast->setModality(bb::system::SystemUiModality::Global); //this actually doesn't works toast->show(); }
void ApplicationUI::onNetworkConnectionFailed () { // Connection was re-established if(this->m_pNetConfigMngr->isOnline() && this->m_RetryToastIsDisplayed) { this->m_RetryToastIsDisplayed = false; this->m_pCurrentToast->cancel(); } else if (this->m_ConnectionRetries < 3) { this->m_pNetwrkConnIcon->setImageSource( QUrl("asset:///images/redDot.png")); this->m_ConnectionRetries += 1; SystemToast* retryMessage = new SystemToast(); this->m_pCurrentToast = retryMessage; SystemUiButton* toastRetryBtn = retryMessage->button(); bool result = QObject::connect( retryMessage, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onToastFinished(bb::system::SystemUiResult::Type))); Q_ASSERT(result); QString btnMsg = "Retry " + QString::number(m_ConnectionRetries) + " of 3"; retryMessage->setBody("The connection has failed"); retryMessage->setPosition(SystemUiPosition::MiddleCenter); toastRetryBtn->setLabel(btnMsg); retryMessage->show(); this->m_RetryToastIsDisplayed = true; } else { QString msg = "The app could not re-establish a connection, and will exit"; SystemToast* exitMessage = new SystemToast(); exitMessage->setBody(msg); exitMessage->setPosition(SystemUiPosition::MiddleCenter); exitMessage->show(); bool result = QObject::connect( exitMessage, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onExitMessageFinished())); Q_ASSERT(result); this->m_RetryToastIsDisplayed = false; } }
void AccountList::copyToClipboard(QString str) { bb::system::Clipboard clipboard; clipboard.clear(); clipboard.insert("text/plain", str.toAscii()); QTimer::singleShot(30000, this, SLOT(clearClip())); SystemToast *toast = new SystemToast(this); toast->setBody("password copied to clipboard\n(will be deleted in 30 seconds)"); toast->setPosition(SystemUiPosition::MiddleCenter); toast->show(); }
void Bb10Ui::showEditIdentityPage() { const Network *net = Client::network(m_networkInfo.networkId); if (net->connectionState() != Network::Disconnected) { SystemToast* toast = new SystemToast(this); toast->setBody("Please disconnect current network to edit identity."); toast->setPosition(SystemUiPosition::MiddleCenter); toast->show(); return; } if (!m_simpleSetupPage) m_simpleSetupPage = new SimpleSetupPage(); m_navPane->push(m_simpleSetupPage->getPage()); m_simpleSetupPage->displayIdentity(m_identity); m_simpleSetupPage->displayNetworkInfo(m_networkInfo); m_simpleSetupPage->setDefaultChannels(m_defaultChannels); }
void SocialInvocation::childCardDone(const bb::system::CardDoneMessage &doneMessage) { SystemToast* toast = new SystemToast(this); if (doneMessage.dataType().compare("application/json") == 0) { // The data type from the venue search card is application/json // so we need to convert the json data to a map here. This will match // the json format from the Foursquare docs at http://developer.foursquare.com JsonDataAccess jda; const QVariantMap venueMap = jda.loadFromBuffer(doneMessage.data()).toMap(); toast->setBody(QString("User Picked: ") + venueMap.value("name","").toString()); } else { toast->setBody(doneMessage.data()); } toast->show(); }
void Bb10Ui::showJoinChannelDlg() { const Network *net = Client::network(m_networkInfo.networkId); if (net->connectionState() != Network::Initialized) { SystemToast* toast = new SystemToast(this); toast->setBody("Please connect to a network to join channel."); toast->setPosition(SystemUiPosition::MiddleCenter); toast->show(); return; } SystemPrompt* prompt = new SystemPrompt(); prompt->setModality(SystemUiModality::Application); prompt->setTitle("Join a channel"); prompt->inputField()->setDefaultText("#"); prompt->confirmButton()->setLabel("Join"); connect(prompt, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onPromptFinished(bb::system::SystemUiResult::Type))); prompt->show(); }
// Waits for the device to make a connection and // if it fails to connect, it displays the // connection retry dialog. void ApplicationUI::waitForConnection () { QTime resumeTime= QTime::currentTime().addSecs(3); SystemToast* waitToast = new SystemToast(); QString waitMsg = "Waiting for network connection ... "; waitToast->setBody(waitMsg); waitToast->setPosition(SystemUiPosition::MiddleCenter); waitToast->show(); // Pause the app to wait for a connection while( QTime::currentTime() < resumeTime ) QCoreApplication::processEvents(QEventLoop::AllEvents, 100); if(m_pNetConfigMngr->isOnline() == false) { displayConnRetryDialog(); } }
void RatingsProcessor::showError(const QString &message) { SystemToast *toast = new SystemToast(this); toast->setBody(message); toast->show(); }
void Bb10Ui::messagesInserted(const QModelIndex &parent, int start, int end) { Q_UNUSED(parent); bool hasFocus = Application::instance()->isFullscreen(); for (int i = start; i <= end; i++) { QModelIndex idx = Client::messageModel()->index(i, ChatLineModel::ContentsColumn); if (!idx.isValid()) { continue; } Message::Flags flags = (Message::Flags)idx.data(ChatLineModel::FlagsRole).toInt(); if (flags.testFlag(Message::Backlog) || flags.testFlag(Message::Self)) continue; BufferId bufId = idx.data(ChatLineModel::BufferIdRole).value<BufferId>(); BufferInfo::Type bufType = Client::networkModel()->bufferType(bufId); // check if bufferId belongs to the shown chatlists // All chats will be shown, but keep this code here until I get the filter working. //if (!m_chatViews.contains(bufId)) { // continue; //} // check if it's the buffer currently displayed if (hasFocus && bufId == m_currentBufferId) { continue; } // This is a hack. // We need a way to notify ListView to update a single item. QModelIndex source_index = Client::bufferModel()->mapFromSource(Client::networkModel()->bufferIndex(bufId)); qobject_cast<DataModelAdapter*>(m_channelListView->dataModel())->handleBufferModelDataChanged(source_index, source_index); // only show notifications for higlights or queries if (bufType != BufferInfo::QueryBuffer && !(flags & Message::Highlight)) continue; // and of course: don't notify for ignored messages if (Client::ignoreListManager() && Client::ignoreListManager()->match(idx.data(MessageModel::MessageRole).value<Message>(), Client::networkModel()->networkName(bufId))) { qDebug() << "xxxxx Bb10Ui::messagesInserted early return for ignored message"; continue; } // seems like we have a legit notification candidate! QModelIndex senderIdx = Client::messageModel()->index(i, ChatLineModel::SenderColumn); QString sender = senderIdx.data(ChatLineModel::EditRole).toString(); QString contents = idx.data(ChatLineModel::DisplayRole).toString(); QString bufferName = (bufType == BufferInfo::QueryBuffer) ? "Private msg" : Client::networkModel()->bufferName(bufId); QString body = "[" + bufferName + "] " + sender + " says: " + contents; if (hasFocus) { SystemToast* toast = new SystemToast(this); toast->setBody(body); toast->setPosition(SystemUiPosition::MiddleCenter); toast->show(); } else { Notification* pNotification = new Notification(); pNotification->setTitle("Quassel IRC for BB10"); pNotification->setBody(body); pNotification->setInvokeRequest(m_invokeRequest); QUrl url = QUrl("file://" + QDir("./app/public/quassel.png").absolutePath()); //QUrl url = QUrl("app/public/quassel.png"); qDebug() << "xxxxx Bb10Ui::messagesInserted url.isValid = " << url.isValid() << " isLocalFile = " << url.isLocalFile() << " path = " << url.path(); pNotification->setIconUrl(url); // FIXME: call setData to add bufferId, so that we can open the page. pNotification->notify(); } } }
void YouMailBB10::showAuthFailedToast() { SystemToast *toast = new SystemToast(this); // leak? toast->setBody("Authentication failed, please try again."); toast->show(); }
void SmartSeq::updateGame(QString answer){ static bool bEnd=false; _root->setProperty("answerEnable",false); SystemToast *toast = new SystemToast(this); answer = answer.toLower(); //check answer if (answer.compare(QString(_alphabet[_game->getNext()]))==0){ if (_attemps==5){ if (!bEnd) bEnd=true; else { bEnd=false; toast->setBody("Hooray!\n You are a smart guy...\n Start a new game to try again."); toast->show(); if (_game) delete _game; _game = new Game(); _score=0; _attemps=0; _sequence = ""; _clue = "?"; _root->setProperty("scoreText",QString("%1 pts").arg(_score)); _root->setProperty("sequenceText",_sequence); _root->setProperty("clueText",_clue_format.arg(_clue)); _root->setProperty("answerEnable",false); return; } toast->setBody("Ok, you got it!\n Let's try something more difficult..."); toast->show(); _attemps=1; _score+=1; _sequence=""; if (_game) delete _game; _game = new EvenSeq(); int firstIndex = _game->getNext(); int secondIndex = _game->getNext(); QString initialSeq = QString("%1%2").arg(_alphabet[firstIndex]).arg(_alphabet[secondIndex]); _sequence+=initialSeq; _root->setProperty("clueText",_clue_format.arg(initialSeq)); _root->setProperty("sequenceText",_sequence); _root->setProperty("scoreText",QString("%1 pts").arg(_score)); }else{ _score+=1; _attemps+=1; _sequence += answer; _root->setProperty("sequenceText",_sequence); _root->setProperty("scoreText",QString("%1 pts").arg(_score)); toast->setBody("Well done!\n So the next is..."); toast->show(); int nextIndex = _game->getNext(); QString nextClue = QString("%1").arg(_alphabet[nextIndex]); _root->setProperty("clueText",_clue_format.arg(nextClue)); _sequence+=nextClue; _root->setProperty("sequenceText",_sequence); } _root->setProperty("answerEnable",true); }else { toast->setBody("Opss... \n I am afraid You were wrong \n Try again from the beginning!"); toast->show(); _score=0; _attemps=0; _sequence = ""; _clue = "?"; _root->setProperty("scoreText",QString("%1 pts").arg(_score)); _root->setProperty("sequenceText",_sequence); _root->setProperty("clueText",_clue_format.arg(_clue)); _root->setProperty("answerEnable",false); } _root->setProperty("answerText",""); };