| 40 | { |
| 41 | |
| 42 | Dialog::Dialog(QWidget *parent, Account *account) |
| 43 | : QDialog(parent) |
| 44 | , m_account(account) |
| 45 | { |
| 46 | auto mainWidget = new QWidget(this); |
| 47 | auto mainLayout = new QVBoxLayout; |
| 48 | setLayout(mainLayout); |
| 49 | mainLayout->addWidget(mainWidget); |
| 50 | |
| 51 | auto buttonBox = new QDialogButtonBox(); |
| 52 | |
| 53 | if (m_account->validAccount()) { |
| 54 | m_text = new QLabel(i18n("You are logged in as <b>%1</b>.<br/>%2", |
| 55 | m_account->name(), tokenLinkStatementText()), this); |
| 56 | |
| 57 | auto logOutButton = new QPushButton; |
| 58 | logOutButton->setText(i18nc("@action:button", "Log Out")); |
| 59 | logOutButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-cancel"))); |
| 60 | buttonBox->addButton(logOutButton, QDialogButtonBox::ActionRole); |
| 61 | connect(logOutButton, &QPushButton::clicked, this, &Dialog::revokeAccess); |
| 62 | |
| 63 | auto forceSyncButton = new QPushButton; |
| 64 | forceSyncButton->setText(i18nc("@action:button", "Force Sync")); |
| 65 | forceSyncButton->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"))); |
| 66 | buttonBox->addButton(forceSyncButton, QDialogButtonBox::ActionRole); |
| 67 | connect(forceSyncButton, &QPushButton::clicked, this, &Dialog::syncUser); |
| 68 | |
| 69 | connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); |
| 70 | connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| 71 | } else { |
| 72 | m_text = new QLabel(invalidAccountText(), this); |
| 73 | |
| 74 | buttonBox->addButton(QDialogButtonBox::Cancel); |
| 75 | |
| 76 | auto authorizeButton = new QPushButton; |
| 77 | buttonBox->addButton(authorizeButton, QDialogButtonBox::ActionRole); |
| 78 | authorizeButton->setText(i18nc("@action:button", "Authorize")); |
| 79 | authorizeButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok"))); |
| 80 | connect(authorizeButton, &QPushButton::clicked, this, &Dialog::authorizeClicked); |
| 81 | } |
| 82 | |
| 83 | m_text->setWordWrap(true); |
| 84 | m_text->setOpenExternalLinks(true); |
| 85 | setMinimumWidth(350); |
| 86 | mainLayout->addWidget(m_text); |
| 87 | |
| 88 | mainLayout->addWidget(buttonBox); |
| 89 | connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); |
| 90 | connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| 91 | |
| 92 | setWindowTitle(i18nc("@title:window", "GitHub Account")); |
| 93 | } |
| 94 | |
| 95 | void Dialog::authorizeClicked() |
| 96 | { |
nothing calls this directly
no test coverage detected