@@ -522,6 +522,22 @@ void TransactionView::editLabel()
522522 }
523523}
524524
525+ QPoint TransactionView::nextDialogPosition (int dialogWidth)
526+ {
527+ QPoint lastDialogPos;
528+ if (!m_openedDialogs.isEmpty ()) {
529+ TransactionDescDialog* lastDialog = m_openedDialogs.last ();
530+ lastDialogPos = lastDialog->pos () + QPoint (50 , 50 );
531+ } else {
532+ QWidget *parent = this ->parentWidget ();
533+ QRect parentRect = parent->frameGeometry ();
534+ QPoint center = parentRect.center ();
535+ int x = center.x () - dialogWidth / 2 ;
536+ lastDialogPos = mapToGlobal (QPoint (x, 0 ));
537+ }
538+ return lastDialogPos;
539+ }
540+
525541void TransactionView::showDetails ()
526542{
527543 if (!transactionView->selectionModel ())
@@ -531,6 +547,8 @@ void TransactionView::showDetails()
531547 {
532548 TransactionDescDialog *dlg = new TransactionDescDialog (selection.at (0 ));
533549 dlg->setAttribute (Qt::WA_DeleteOnClose);
550+ dlg->move (nextDialogPosition (dlg->width ()));
551+ m_openedDialogs.append (dlg);
534552 dlg->show ();
535553 }
536554}
@@ -637,6 +655,11 @@ bool TransactionView::eventFilter(QObject *obj, QEvent *event)
637655 return true ;
638656 }
639657 }
658+ if (event->type () == QEvent::EnabledChange) {
659+ if (!isEnabled ()) {
660+ closeOpenedDialogs ();
661+ }
662+ }
640663 return QWidget::eventFilter (obj, event);
641664}
642665
@@ -646,3 +669,12 @@ void TransactionView::updateWatchOnlyColumn(bool fHaveWatchOnly)
646669 watchOnlyWidget->setVisible (fHaveWatchOnly );
647670 transactionView->setColumnHidden (TransactionTableModel::Watchonly, !fHaveWatchOnly );
648671}
672+
673+ void TransactionView::closeOpenedDialogs ()
674+ {
675+ // close all dialogs opened from this view
676+ for (QDialog* dlg : m_openedDialogs) {
677+ dlg->close ();
678+ }
679+ m_openedDialogs.clear ();
680+ }
0 commit comments