diff --git a/TrayMenuManager.cpp b/TrayMenuManager.cpp index 6d2ec5a..abbb976 100644 --- a/TrayMenuManager.cpp +++ b/TrayMenuManager.cpp @@ -236,9 +236,17 @@ void TrayMenuManager::buildAccountsMenu() const { if (pThisDevice->menu() == nullptr) { pThisDevice->setMenu(new QMenu()); } + pThisDevice->menu()->clear(); for (const auto& acc : accounts) { - auto accountAction = new QAction(acc.tailnet + " (" + acc.account + ")"); + bool isActive = acc.account.endsWith('*'); + QString accountName = acc.account; + if (isActive) + accountName = accountName.chopped(1); + auto accountAction = new QAction(acc.tailnet + " (" + accountName + ")"); + accountAction->setCheckable(true); + accountAction->setChecked(isActive); + pThisDevice->menu()->addAction(accountAction); accountAction->setData(acc.id); connect(accountAction, &QAction::triggered, this, [this, accountAction](bool) { diff --git a/models.h b/models.h index 13f563a..acc5361 100644 --- a/models.h +++ b/models.h @@ -69,9 +69,6 @@ class TailAccountInfo : public QObject // This handles fragmented lines as well from the command line output // so even if a line starts with the ID and then break it will make sure to parse it correctly static QList parseAllFound(const QString& rawData) { - qDebug() << "Will parse accounts from data:"; - qDebug() << rawData; - QList retVal; // Split input into individual lines @@ -83,8 +80,7 @@ class TailAccountInfo : public QObject // Reconstruct broken lines into complete entries // And we skip the first line since it's the header line for (int i = 1; i < lines.length(); i++) { - const QString& line = lines[i]; - qDebug() << line; + const QString& line = lines[i].trimmed(); if (isIdLine(line)) { if (!currentEntry.isEmpty()) { entries.append(currentEntry); @@ -93,7 +89,7 @@ class TailAccountInfo : public QObject currentEntry = line; } else { - currentEntry += " " + line.trimmed(); + currentEntry += "\t" + line.trimmed(); } } @@ -103,6 +99,7 @@ class TailAccountInfo : public QObject // Iterate over each reconstructed entry and apply the regular expression for (const QString& entry : entries) { + qDebug() << "Parsing entry: " << entry; retVal.emplace_back(TailAccountInfo::parse(entry)); }