summaryrefslogtreecommitdiffstats
path: root/qt-ui/mainwindow.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-25 12:49:48 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-25 13:07:20 -0700
commit0db80103caa7534db7eb9d169dc97d79ab259e4e (patch)
tree5ae1212fcc885086d4d6862b30b037400f73e92c /qt-ui/mainwindow.cpp
parent6721698fcdad179a6fd770cafd009c3467e6ac06 (diff)
downloadsubsurface-0db80103caa7534db7eb9d169dc97d79ab259e4e.tar.gz
Add spinner while opening or saving cloud storage
Right now this is quite ugly. And at least in my VM the transparency doesn't seem to work correctly. But at least we now have some visual indication that we are doing something while opening or saving cloud storage. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/mainwindow.cpp')
-rw-r--r--qt-ui/mainwindow.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 4d416d2be..7593caf47 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -58,7 +58,8 @@ MainWindow::MainWindow() : QMainWindow(),
actionPreviousDive(0),
helpView(0),
state(VIEWALL),
- survey(0)
+ survey(0),
+ spinner(0)
{
Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!");
m_Instance = this;
@@ -374,6 +375,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
int error;
+ startSpinner();
QByteArray fileNamePtr = QFile::encodeName(filename);
error = parse_file(fileNamePtr.data());
if (!error) {
@@ -382,6 +384,7 @@ void MainWindow::on_actionCloudstorageopen_triggered()
}
getNotificationWidget()->hideNotification();
process_dives(false, false);
+ stopSpinner();
refreshDisplay();
ui.actionAutoGroup->setChecked(autogroup);
}
@@ -397,10 +400,15 @@ void MainWindow::on_actionCloudstoragesave_triggered()
if (information()->isEditing())
information()->acceptChanges();
+ startSpinner();
+
if (save_dives(filename.toUtf8().data())) {
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
return;
}
+
+ stopSpinner();
+
getNotificationWidget()->showNotification(get_error_string(), KMessageWidget::Error);
set_filename(filename.toUtf8().data(), true);
setTitle(MWTF_FILENAME);
@@ -1762,3 +1770,24 @@ void MainWindow::setApplicationState(const QByteArray& state) {
}
#undef SET_CURRENT_INDEX
}
+
+void MainWindow::startSpinner()
+{
+ if (!spinner) {
+ spinner = new QtWaitingSpinner(Qt::WindowModal, this, true);
+ spinner->setRevolutionsPerSecond(1);
+ spinner->setColor(WHITE1);
+ spinner->setLineWidth(7);
+ spinner->setRoundness(40.0);
+ spinner->setMinimumTrailOpacity(0.25);
+ }
+ int shorterEdge = MIN(this->geometry().height(), this->geometry().width());
+ spinner->setInnerRadius(shorterEdge / 12);
+ spinner->setLineLength(shorterEdge / 8);
+ spinner->start();
+}
+
+void MainWindow::stopSpinner()
+{
+ spinner->stop();
+}