|
| 1 | +/* |
| 2 | +* Copyright (C) by Eugen Fischer |
| 3 | +* |
| 4 | +* This program is free software; you can redistribute it and/or modify |
| 5 | +* it under the terms of the GNU General Public License as published by |
| 6 | +* the Free Software Foundation; either version 2 of the License, or |
| 7 | +* (at your option) any later version. |
| 8 | +* |
| 9 | +* This program is distributed in the hope that it will be useful, but |
| 10 | +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 11 | +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | +* for more details. |
| 13 | +*/ |
| 14 | + |
| 15 | +#include "nmcflow2authwidget.h" |
| 16 | + |
| 17 | +#include <QCoreApplication> |
| 18 | +#include <QDesktopServices> |
| 19 | +#include <QIcon> |
| 20 | +#include <QLabel> |
| 21 | +#include <QPainter> |
| 22 | +#include <QPushButton> |
| 23 | +#include <QHBoxLayout> |
| 24 | +#include <QVBoxLayout> |
| 25 | + |
| 26 | +#include "QProgressIndicator.h" |
| 27 | +#include "theme.h" |
| 28 | + |
| 29 | +namespace OCC { |
| 30 | + |
| 31 | +NMCFlow2AuthWidget::NMCFlow2AuthWidget(QWidget *parent) |
| 32 | + : Flow2AuthWidget(parent) |
| 33 | +{ |
| 34 | + // Bestehende UI-Elemente ausblenden |
| 35 | + if (getUi().logoLabel) { |
| 36 | + getUi().logoLabel->hide(); |
| 37 | + getUi().logoLabel->setFixedSize(0, 0); |
| 38 | + } |
| 39 | + if (getUi().label) { |
| 40 | + getUi().label->hide(); |
| 41 | + getUi().label->setFixedSize(0, 0); |
| 42 | + } |
| 43 | + if (getUi().copyLinkButton) { |
| 44 | + getUi().copyLinkButton->hide(); |
| 45 | + } |
| 46 | + if (getUi().openLinkButton) { |
| 47 | + getUi().openLinkButton->hide(); |
| 48 | + } |
| 49 | + if (auto *progressInd = getProgressIndicator()) { |
| 50 | + progressInd->setVisible(false); |
| 51 | + progressInd->setFixedSize(0, 0); |
| 52 | + } |
| 53 | + if (getUi().statusLabel) { |
| 54 | + getUi().statusLabel->setVisible(false); |
| 55 | + getUi().statusLabel->setFixedSize(0, 0); |
| 56 | + } |
| 57 | + |
| 58 | + // Bestehendes Layout und Child-Widgets entfernen |
| 59 | + if (auto *oldLayout = layout()) { |
| 60 | + QLayoutItem *item; |
| 61 | + while ((item = oldLayout->takeAt(0)) != nullptr) { |
| 62 | + if (auto *widget = item->widget()) { |
| 63 | + widget->setParent(nullptr); |
| 64 | + } |
| 65 | + delete item; |
| 66 | + } |
| 67 | + delete oldLayout; |
| 68 | + } |
| 69 | + |
| 70 | + // Login-Button |
| 71 | + auto loginButton = new QPushButton(QCoreApplication::translate("", "LOGIN")); |
| 72 | + loginButton->setFocusPolicy(Qt::NoFocus); |
| 73 | + loginButton->setFixedSize(130, 32); |
| 74 | + loginButton->setStyleSheet( |
| 75 | + "QPushButton { font-size: 15px; border: none; border-radius: 4px; background-color: #E20074; color: white; }" |
| 76 | + "QPushButton:hover { background-color: #c00063; }" |
| 77 | + ); |
| 78 | + connect(loginButton, &QPushButton::clicked, this, &NMCFlow2AuthWidget::slotOpenBrowser); |
| 79 | + |
| 80 | + // Logo + Titel |
| 81 | + auto logoLabel = new QLabel(this); |
| 82 | + logoLabel->setPixmap(QIcon(":/client/theme/NMCIcons/tlogocarrier.svg").pixmap(36, 36)); |
| 83 | + logoLabel->setFixedSize(36, 36); |
| 84 | + |
| 85 | + auto titleLabel = new QLabel(tr("MagentaCLOUD"), this); |
| 86 | + titleLabel->setStyleSheet("font-weight: bold; font-size: 15px;"); |
| 87 | + |
| 88 | + auto logoTitleLayout = new QHBoxLayout; |
| 89 | + logoTitleLayout->setSpacing(8); |
| 90 | + logoTitleLayout->addWidget(logoLabel); |
| 91 | + logoTitleLayout->addWidget(titleLabel); |
| 92 | + logoTitleLayout->addStretch(); |
| 93 | + |
| 94 | + // Überschrift |
| 95 | + auto headerLabel = new QLabel(QCoreApplication::translate("", "SETUP_HEADER_TEXT_1")); |
| 96 | + headerLabel->setStyleSheet("font-size: 24px; font-weight: normal;"); |
| 97 | + headerLabel->setWordWrap(true); |
| 98 | + headerLabel->setFixedWidth(282); |
| 99 | + |
| 100 | + // Anweisungs-Label |
| 101 | + auto label = new QLabel(tr("Wechseln Sie bitte zu Ihrem Browser und melden Sie sich dort an, um Ihr Konto zu verbinden."), this); |
| 102 | + label->setStyleSheet("font-size: 14px;"); |
| 103 | + label->setWordWrap(true); |
| 104 | + label->setFixedWidth(282); |
| 105 | + |
| 106 | + // Linke Seite |
| 107 | + auto leftLayout = new QVBoxLayout; |
| 108 | + leftLayout->addLayout(logoTitleLayout); |
| 109 | + leftLayout->addSpacing(24); |
| 110 | + leftLayout->addWidget(headerLabel); |
| 111 | + leftLayout->addSpacing(16); |
| 112 | + leftLayout->addWidget(label); |
| 113 | + leftLayout->addSpacing(24); |
| 114 | + leftLayout->addWidget(loginButton); |
| 115 | + leftLayout->addStretch(); |
| 116 | + |
| 117 | + // Rechtes Logo |
| 118 | + auto bigLogoLabel = new QLabel(this); |
| 119 | + bigLogoLabel->setPixmap(QIcon(":/client/theme/NMCIcons/applicationLogo.svg").pixmap(175, 175)); |
| 120 | + bigLogoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
| 121 | + bigLogoLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 122 | + |
| 123 | + auto rightLayout = new QVBoxLayout; |
| 124 | + rightLayout->addStretch(); |
| 125 | + rightLayout->addWidget(bigLogoLabel); |
| 126 | + rightLayout->addStretch(); |
| 127 | + |
| 128 | + // Hauptlayout |
| 129 | + auto mainLayout = new QHBoxLayout; |
| 130 | + mainLayout->setContentsMargins(16, 16, 16, 16); |
| 131 | + mainLayout->setSpacing(24); |
| 132 | + mainLayout->addLayout(leftLayout); |
| 133 | + mainLayout->addStretch(); |
| 134 | + mainLayout->addLayout(rightLayout); |
| 135 | + |
| 136 | + // Fehlerlabel wieder einfügen |
| 137 | + if (getUi().errorLabel) { |
| 138 | + mainLayout->addWidget(getUi().errorLabel); |
| 139 | + } |
| 140 | + setLayout(mainLayout); |
| 141 | +} |
| 142 | + |
| 143 | +// Styling bewusst ignorieren |
| 144 | +void NMCFlow2AuthWidget::customizeStyle() {} |
| 145 | + |
| 146 | +// Spinner einblenden / ungenutzt |
| 147 | +void NMCFlow2AuthWidget::startSpinner() {} |
| 148 | + |
| 149 | +// Spinner ausblenden / ungenutzt |
| 150 | +void NMCFlow2AuthWidget::stopSpinner(bool showStatusLabel) |
| 151 | +{ |
| 152 | + Q_UNUSED(showStatusLabel); |
| 153 | +} |
| 154 | + |
| 155 | +// Statusänderung unterdrücken |
| 156 | +void NMCFlow2AuthWidget::slotStatusChanged(Flow2Auth::PollStatus status, int secondsLeft) |
| 157 | +{ |
| 158 | + Q_UNUSED(status); |
| 159 | + Q_UNUSED(secondsLeft); |
| 160 | +} |
| 161 | + |
| 162 | +} // namespace OCC |
0 commit comments