MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
m_drawOwnLocationCrosshair(false),
+ m_errorShown(false),
m_loggedIn(false),
m_refresh(false),
m_ownLocationCrosshair(0),
qDeleteAll(m_queue.begin(), m_queue.end());
m_queue.clear();
+
+ qDeleteAll(m_error_queue.begin(), m_error_queue.end());
+ m_error_queue.clear();
}
void MainWindow::buildFullScreenButton()
void MainWindow::dialogFinished(int status)
{
qDebug() << __PRETTY_FUNCTION__;
- qDebug() << status;
+
QDialog *dialog = m_queue.takeFirst();
- if(!dialog->objectName().isEmpty()) {
+ LoginDialog *loginDialog = qobject_cast<LoginDialog *>(dialog);
+ if(loginDialog) {
if(status != 0) {
buildWebView();
- static_cast<LoginDialog *>(dialog)->userInput(m_email, m_password);
+ loginDialog->userInput(m_email, m_password);
QStringList urlParts;
urlParts.append(FACEBOOK_LOGINBASE);
dialog->deleteLater();
- if(!m_queue.isEmpty())
- showInformationBox();
+ if(!m_error_queue.isEmpty() && m_errorShown == false) {
+ showErrorInformationBox();
+ } else {
+ if(!m_queue.isEmpty()) {
+ showInformationBox();
+ }
+ }
}
void MainWindow::drawFullScreenButton(const QSize &size)
}
}
+void MainWindow::errorDialogFinished(int status)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ qDebug() << status;
+ QDialog *dialog = m_error_queue.takeFirst();
+
+ dialog->deleteLater();
+ m_errorShown = false;
+
+ if(!m_error_queue.isEmpty()) {
+ showErrorInformationBox();
+ }
+}
+
void MainWindow::gpsTimeout()
{
qDebug() << __PRETTY_FUNCTION__;
{
qDebug() << __PRETTY_FUNCTION__;
- m_queue.append(dialog);
+ // check is dialog is modal, for now all modal dialogs have hihger priority i.e. errors
+ if(dialog->isModal()) {
+ m_error_queue.append(dialog);
+ } else {
+ m_queue.append(dialog);
+ }
- if(m_queue.count() == 1)
+ // show error dialog if there is only one error dialog in the queue and no error dialog is shown
+ if(m_error_queue.count() == 1 && m_errorShown == false)
+ showErrorInformationBox();
+ else if(m_queue.count() == 1 && m_errorShown == false)
showInformationBox();
}
showNormal();
}
+void MainWindow::showErrorInformationBox()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(m_error_queue.count()) {
+ m_errorShown = true;
+ QDialog *dialog = m_error_queue.first();
+ connect(dialog, SIGNAL(finished(int)),
+ this, SLOT(errorDialogFinished(int)));
+ dialog->show();
+ }
+}
+
void MainWindow::showInformationBox()
{
qDebug() << __PRETTY_FUNCTION__;
- QDialog *dialog = m_queue.takeFirst();
- connect(dialog, SIGNAL(finished(int)),
- this, SLOT(dialogFinished(int)));
- dialog->show();
- m_queue.insert(0, dialog);
+ if(m_queue.count()) {
+ QDialog *dialog = m_queue.first();
+ connect(dialog, SIGNAL(finished(int)),
+ this, SLOT(dialogFinished(int)));
+ dialog->show();
+ }
}
void MainWindow::startLoginProcess()
qDebug() << __PRETTY_FUNCTION__;
LoginDialog *loginDialog = new LoginDialog();
- loginDialog->setObjectName(QString("loginDialog"));
emit fetchUsernameFromSettings();
void setOwnLocationCrosshairVisibility(bool visible);
/**
+ * @brief Shows queued error information box
+ *
+ */
+ void showErrorInformationBox();
+
+ /**
* @brief Shows queued information box
*
* @fn showInformationBox
void drawOwnLocationCrosshair(int width, int height);
/**
+ * @brief Slot to intercept signal when error dialog/information note is processed
+ *
+ * @param status Status of the dialog
+ */
+ void errorDialogFinished(int status);
+
+ /**
* @brief Slot for gps timeout.
*
* Called when request timeout occurs.
*/
void toggleFullScreen();
+ /**
+ * @brief Slot to intercept signal from webview's networkaccessmanager
+ *
+ * @param reply Network reply (contains errors)
+ */
void webViewRequestFinished(QNetworkReply* reply);
/*******************************************************************************
******************************************************************************/
private:
bool m_drawOwnLocationCrosshair; ///< Flag for making ownLocationCrosshair visible or not
+ bool m_errorShown; ///< Indicates if error dialog/note is shown
bool m_loggedIn; ///< Indicates login state
bool m_refresh; ///< Indicates when webpage is refreshed
QLabel *m_osmLicense; ///< Label for Open Street Map license
QLabel *m_ownLocationCrosshair; ///< Label that show ownLocationCrosshair
+ QList<QDialog *> m_error_queue; ///< QList type error dialog queue
+ QList<QDialog *> m_queue; ///< QList type dialog queue
+
QMenu *m_viewMenu; ///< Object that hold the view menu items
QString m_email; ///< Placeholder for email
SettingsDialog *m_settingsDialog; ///< Settings dialog
- QList<QDialog *> m_queue;
};
#endif // MAINWINDOW_H