mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 01:23:24 +00:00
Makes the 'auto' edition behave in a better way.
This patch makes the auto editon behave in a better way, now you can scroll the notes widget without marking it as editable, and also adds a bit of code cleanup, and a better logic for editing the other widgets. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
16addbf373
commit
3464bcf6ef
2 changed files with 20 additions and 10 deletions
|
@ -52,7 +52,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
|||
ui->divemaster->installEventFilter(this);
|
||||
ui->buddy->installEventFilter(this);
|
||||
ui->suit->installEventFilter(this);
|
||||
ui->notes->installEventFilter(this);
|
||||
ui->notes->viewport()->installEventFilter(this);
|
||||
ui->rating->installEventFilter(this);
|
||||
ui->visibility->installEventFilter(this);
|
||||
|
||||
|
@ -126,18 +126,27 @@ void MainTab::equipmentPlusUpdate()
|
|||
addWeight->setGeometry(ui->weightGroup->contentsRect().width() - 30, 2, 24,24);
|
||||
}
|
||||
|
||||
void MainTab::enableEdition()
|
||||
{
|
||||
if (ui->editAccept->isVisible() || !currentDive)
|
||||
return;
|
||||
|
||||
ui->editAccept->setChecked(true);
|
||||
ui->editAccept->show();
|
||||
ui->editReset->show();
|
||||
on_editAccept_clicked(true);
|
||||
}
|
||||
|
||||
bool MainTab::eventFilter(QObject* object, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::FocusIn || event->type() == QEvent::MouseButtonPress) {
|
||||
if (ui->editAccept->isVisible() || !currentDive)
|
||||
return false;
|
||||
|
||||
ui->editAccept->setChecked(true);
|
||||
ui->editAccept->show();
|
||||
ui->editReset->show();
|
||||
on_editAccept_clicked(true);
|
||||
if (event->type() == QEvent::FocusIn && (object == ui->rating || object == ui->visibility)){
|
||||
enableEdition();
|
||||
}
|
||||
return false;
|
||||
|
||||
if (event->type() == QEvent::MouseButtonPress) {
|
||||
enableEdition();
|
||||
}
|
||||
return false; // don't "eat" the event.
|
||||
}
|
||||
|
||||
void MainTab::clearEquipment()
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
QPushButton *addCylinder;
|
||||
QPushButton *addWeight;
|
||||
enum { NONE, DIVE, TRIP } editMode;
|
||||
void enableEdition();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue