Use constant instead of hard-coded literals for number of available account types

This commit is contained in:
kas 2022-10-19 09:25:44 +02:00
parent 94e466afd7
commit ce8e66e829
3 changed files with 3 additions and 2 deletions

View File

@ -26,6 +26,7 @@ class Account : public QObject {
public:
enum Kind { GitHub, Bitbucket, Beanstalk, GitLab, Gitea };
static const int NUM_KINDS = 5;
struct Comment {
QString body;

View File

@ -743,7 +743,7 @@ SideBar::SideBar(TabWidget *tabs, QWidget *parent) : QWidget(parent) {
plusMenu->addSeparator();
for (int i = 0; i < 4; ++i) {
for (int i = 0; i < Account::NUM_KINDS; ++i) {
Account::Kind kind = static_cast<Account::Kind>(i);
QString text = tr("Add %1 Account").arg(Account::name(kind));
QAction *add = plusMenu->addAction(text);

View File

@ -83,7 +83,7 @@ public:
layout->addWidget(init);
layout->addWidget(addSeparator());
for (int i = 0; i < 4; ++i) {
for (int i = 0; i < Account::NUM_KINDS; ++i) {
Account::Kind kind = static_cast<Account::Kind>(i);
QString text = tr("Add %1 account").arg(Account::name(kind));
QPushButton *account = addButton(Account::icon(kind), text);