mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:23:23 +00:00
Undo: hide multi-dive-edit warning message on subsequent edit
When a different field is edited, hide any old multi-dive-edit warning message. The reason is that we might want to add an "undo" button to the message. But this will undo the wrong command if we don't hide the message. Sadly, this means that we can't use animated show / hide, because an animatedHide() followed immediately by an animatedShow() does not necessarily show the message. In other words, and animatedShow() does not interupt a started animatedHide()!? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
f51e402e04
commit
a20c22d907
3 changed files with 11 additions and 2 deletions
|
@ -81,6 +81,12 @@ signals:
|
|||
void diveSiteDiveCountChanged(dive_site *ds);
|
||||
void diveSiteChanged(dive_site *ds, int field); // field according to LocationInformationModel
|
||||
void diveSiteDivesChanged(dive_site *ds); // The dives associated with that site changed
|
||||
|
||||
// This signal is emited every time a command is executed.
|
||||
// This is used to hide an old multi-dives-edited warning message.
|
||||
// This is necessary, so that the user can't click on the "undo" button and undo
|
||||
// an unrelated command.
|
||||
void commandExecuted();
|
||||
public:
|
||||
// Desktop uses the QTreeView class to present the list of dives. The layout
|
||||
// of this class gives us a very fundamental problem, as we can not easily
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "command_base.h"
|
||||
#include "core/qthelper.h" // for updateWindowTitle()
|
||||
#include "core/subsurface-qt/DiveListNotifier.h"
|
||||
|
||||
namespace Command {
|
||||
|
||||
|
@ -42,6 +43,7 @@ bool execute(Base *cmd)
|
|||
{
|
||||
if (cmd->workToBeDone()) {
|
||||
undoStack.push(cmd);
|
||||
emit diveListNotifier.commandExecuted();
|
||||
return true;
|
||||
} else {
|
||||
delete cmd;
|
||||
|
|
|
@ -80,6 +80,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
|||
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &MainTab::divesChanged);
|
||||
connect(&diveListNotifier, &DiveListNotifier::tripChanged, this, &MainTab::tripChanged);
|
||||
connect(&diveListNotifier, &DiveListNotifier::diveSiteChanged, this, &MainTab::diveSiteEdited);
|
||||
connect(&diveListNotifier, &DiveListNotifier::commandExecuted, this, &MainTab::closeWarning);
|
||||
|
||||
connect(ui.editDiveSiteButton, &QToolButton::clicked, MainWindow::instance(), &MainWindow::startDiveSiteEdit);
|
||||
connect(ui.location, &DiveLocationLineEdit::entered, MapWidget::instance(), &MapWidget::centerOnIndex);
|
||||
|
@ -200,7 +201,7 @@ void MainTab::closeMessage()
|
|||
|
||||
void MainTab::closeWarning()
|
||||
{
|
||||
ui.multiDiveWarningMessage->animatedHide();
|
||||
ui.multiDiveWarningMessage->hide();
|
||||
}
|
||||
|
||||
void MainTab::displayMessage(QString str)
|
||||
|
@ -723,7 +724,7 @@ void MainTab::divesEdited(int i)
|
|||
return;
|
||||
ui.multiDiveWarningMessage->setCloseButtonVisible(false);
|
||||
ui.multiDiveWarningMessage->setText(tr("Warning: edited %1 dives").arg(i));
|
||||
ui.multiDiveWarningMessage->animatedShow();
|
||||
ui.multiDiveWarningMessage->show();
|
||||
}
|
||||
|
||||
static QStringList stringToList(const QString &s)
|
||||
|
|
Loading…
Add table
Reference in a new issue