mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-02 14:14:10 +00:00
19d98d6a74
find . \( -name "*.cpp" -or -name "*.h" -or -name "*.c" -or -name "*.cc" \) -exec clang-format -i {} \; If you reached this file doing a git blame, please see README.clang-format (added 2 commits in the future of this one)
51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
#include "closedialoghelper.h"
|
|
|
|
#include <QApplication>
|
|
#include <QDialog>
|
|
#include <QPushButton>
|
|
#include <QTest>
|
|
|
|
namespace TestingUtils
|
|
{
|
|
CloseDialogHelper::CloseDialogHelper(Okular::Part *p, QDialogButtonBox::StandardButton b)
|
|
: m_widget(p->widget())
|
|
, m_button(b)
|
|
, m_clicked(false)
|
|
{
|
|
QTimer::singleShot(0, this, &CloseDialogHelper::closeDialog);
|
|
}
|
|
|
|
CloseDialogHelper::CloseDialogHelper(QWidget *w, QDialogButtonBox::StandardButton b)
|
|
: m_widget(w)
|
|
, m_button(b)
|
|
, m_clicked(false)
|
|
{
|
|
QTimer::singleShot(0, this, &CloseDialogHelper::closeDialog);
|
|
}
|
|
|
|
CloseDialogHelper::CloseDialogHelper(QDialogButtonBox::StandardButton b)
|
|
: m_widget(nullptr)
|
|
, m_button(b)
|
|
, m_clicked(false)
|
|
{
|
|
QTimer::singleShot(0, this, &CloseDialogHelper::closeDialog);
|
|
}
|
|
|
|
CloseDialogHelper::~CloseDialogHelper()
|
|
{
|
|
QVERIFY(m_clicked);
|
|
}
|
|
|
|
void CloseDialogHelper::closeDialog()
|
|
{
|
|
QWidget *dialog = (m_widget) ? m_widget->findChild<QDialog *>() : qApp->activeModalWidget();
|
|
if (!dialog) {
|
|
QTimer::singleShot(0, this, &CloseDialogHelper::closeDialog);
|
|
return;
|
|
}
|
|
QDialogButtonBox *buttonBox = dialog->findChild<QDialogButtonBox *>();
|
|
buttonBox->button(m_button)->click();
|
|
m_clicked = true;
|
|
}
|
|
}
|