|
| 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 "nmcgui/nmcaccountsettings.h" |
| 16 | +#include "ui_accountsettings.h" |
| 17 | +#include "../common/utility.h" |
| 18 | +#include "guiutility.h" |
| 19 | + |
| 20 | +#include <QDesktopServices> |
| 21 | +#include <QUrl> |
| 22 | +#include <QPushButton> |
| 23 | +#include <QLabel> |
| 24 | +#include <QHBoxLayout> |
| 25 | +#include <QVBoxLayout> |
| 26 | +#include <QSpacerItem> |
| 27 | +#include <QSizePolicy> |
| 28 | + |
| 29 | +namespace OCC { |
| 30 | + |
| 31 | +NMCAccountSettings::NMCAccountSettings(AccountState *accountState, QWidget *parent) |
| 32 | + : AccountSettings(accountState, parent) |
| 33 | + , m_liveAccountButton(new CustomButton(QCoreApplication::translate("", "ADD_LIVE_BACKUP"), QIcon(QLatin1String(":/client/theme/NMCIcons/action-add.svg")).pixmap(24,24))) |
| 34 | + , m_liveTitle(new QLabel(QCoreApplication::translate("", "LIVE_BACKUPS"))) |
| 35 | + , m_liveDescription(new QLabel(QCoreApplication::translate("", "LIVE_DESCRIPTION"))) |
| 36 | +{ |
| 37 | + setDefaultSettings(); |
| 38 | + setLayout(); |
| 39 | + connect(m_liveAccountButton, &CustomButton::clicked, this, &NMCAccountSettings::slotAddFolder); |
| 40 | +} |
| 41 | + |
| 42 | +void NMCAccountSettings::setDefaultSettings() |
| 43 | +{ |
| 44 | + getUi()->encryptionMessage->setCloseButtonVisible(true); |
| 45 | + getUi()->selectiveSyncStatus->setVisible(false); |
| 46 | + getUi()->selectiveSyncNotification->setVisible(false); |
| 47 | + getUi()->accountStatus->setVisible(false); |
| 48 | + getUi()->bigFolderUi->setVisible(false); |
| 49 | + getUi()->gridLayout->setSpacing(8); |
| 50 | +} |
| 51 | + |
| 52 | +void NMCAccountSettings::setLayout() |
| 53 | +{ |
| 54 | + // Entferne alte Quota-Widgets |
| 55 | + getUi()->storageGroupBox->removeWidget(getUi()->quotaInfoLabel); |
| 56 | + getUi()->storageGroupBox->removeWidget(getUi()->quotaProgressBar); |
| 57 | + getUi()->storageGroupBox->removeWidget(getUi()->quotaInfoText); |
| 58 | + |
| 59 | + getUi()->gridLayout->removeWidget(getUi()->encryptionMessage); |
| 60 | + getUi()->gridLayout->addWidget(getUi()->encryptionMessage, 0, 0); |
| 61 | + |
| 62 | + // --- Live-Backup-Bereich --- |
| 63 | + auto *liveHLayout = new QHBoxLayout(); |
| 64 | + liveHLayout->setContentsMargins(8, 8, 8, 8); |
| 65 | + |
| 66 | + auto *liveVLayout = new QVBoxLayout(); |
| 67 | + m_liveWidget = new QWidget(this); // Membervariable statt lokale Variable |
| 68 | + m_liveWidget->setStyleSheet("QWidget { border-radius: 4px; }"); |
| 69 | + m_liveWidget->setLayout(liveHLayout); |
| 70 | + |
| 71 | + liveHLayout->addLayout(liveVLayout); |
| 72 | + liveHLayout->addStretch(); |
| 73 | + |
| 74 | + const QString styleSheet = QStringLiteral( |
| 75 | + "QPushButton { font-size: %5px; border: %1px solid; border-color: black; " |
| 76 | + "border-radius: 4px; background-color: %2; color: %3; } " |
| 77 | + "QPushButton:hover { background-color: %4; }"); |
| 78 | + |
| 79 | + m_liveAccountButton->setStyleSheet(styleSheet.arg("0", "#E20074", "white", "#c00063", "13")); |
| 80 | + m_liveAccountButton->setFixedSize(180, 32); |
| 81 | + m_liveAccountButton->setLeftIconMargin(4); |
| 82 | + |
| 83 | + liveHLayout->addWidget(m_liveAccountButton); |
| 84 | + |
| 85 | + liveVLayout->addWidget(m_liveTitle); |
| 86 | + m_liveTitle->setStyleSheet("font-size: 15px; font-weight: 600;"); |
| 87 | + |
| 88 | + liveVLayout->addWidget(m_liveDescription); |
| 89 | + m_liveDescription->setStyleSheet("font-size: 13px;"); |
| 90 | + m_liveDescription->setText(QCoreApplication::translate("", "LIVE_BACKUPS_DESCRIPTION")); |
| 91 | + m_liveDescription->setWordWrap(true); |
| 92 | + m_liveDescription->setFixedWidth(450); |
| 93 | + |
| 94 | + getUi()->gridLayout->addWidget(m_liveWidget, 4, 0); |
| 95 | + |
| 96 | + // --- Speicherbereich (Quota) --- |
| 97 | + auto *magentaHLayout = new QHBoxLayout(); |
| 98 | + magentaHLayout->setSpacing(32); |
| 99 | + |
| 100 | + auto *quotaVLayout = new QVBoxLayout(); |
| 101 | + quotaVLayout->setSpacing(4); |
| 102 | + quotaVLayout->addSpacing(12); |
| 103 | + |
| 104 | + quotaVLayout->addWidget(getUi()->quotaInfoLabel); |
| 105 | + getUi()->quotaInfoLabel->setStyleSheet("QLabel { font-size: 18px; padding: 8px; font-weight: 500; }"); |
| 106 | + |
| 107 | + quotaVLayout->addWidget(getUi()->quotaProgressBar); |
| 108 | + getUi()->quotaProgressBar->setStyleSheet( |
| 109 | + "QProgressBar { background-color: #e5e5e5; color: black; border: 1px solid black; border-radius: 4px; margin-left: 8px; } " |
| 110 | + "QProgressBar::chunk { background-color: #E20074; }"); |
| 111 | + getUi()->quotaProgressBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
| 112 | + |
| 113 | + quotaVLayout->addWidget(getUi()->quotaInfoText); |
| 114 | + getUi()->quotaInfoText->setStyleSheet("QLabel { font-size: 13px; padding: 8px; }"); |
| 115 | + |
| 116 | + quotaVLayout->addSpacing(20); |
| 117 | + magentaHLayout->addLayout(quotaVLayout); |
| 118 | + |
| 119 | + auto *storageLinkButton = new QPushButton(QCoreApplication::translate("", "STORAGE_EXTENSION"), this); |
| 120 | + storageLinkButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); |
| 121 | + storageLinkButton->setStyleSheet( |
| 122 | + "QPushButton { height: 32px; width: 180px; border: 1px solid black; background-color: #ededed; " |
| 123 | + "color: black; font-size: 13px; border-radius: 4px; } " |
| 124 | + "QPushButton:hover { background-color: white; }"); |
| 125 | + |
| 126 | + connect(storageLinkButton, &QPushButton::clicked, this, []() { |
| 127 | + QDesktopServices::openUrl(QUrl(QStringLiteral("https://cloud.telekom-dienste.de/tarife"))); |
| 128 | + }); |
| 129 | + |
| 130 | + magentaHLayout->addWidget(storageLinkButton); |
| 131 | + magentaHLayout->addSpacing(8); |
| 132 | + |
| 133 | + getUi()->gridLayout->addLayout(magentaHLayout, 5, 0); |
| 134 | + |
| 135 | + // --- Sichtbarkeit initial ausblenden --- |
| 136 | + getUi()->encryptionMessage->hide(); |
| 137 | + checkClientSideEncryptionState(); |
| 138 | + |
| 139 | + // --- Sichtbarkeit des Live-Backup-Bereichs je nach Tab --- |
| 140 | + auto *tabWidget = getUi()->tabWidget; |
| 141 | + auto *connectionSettingsTab = getUi()->connectionSettingsTab; |
| 142 | + |
| 143 | + if (tabWidget && connectionSettingsTab) { |
| 144 | + connect(tabWidget, &QTabWidget::currentChanged, this, |
| 145 | + [this, tabWidget, connectionSettingsTab](int index) { |
| 146 | + QWidget *currentTab = tabWidget->widget(index); |
| 147 | + bool hideLiveBackup = (currentTab == connectionSettingsTab); |
| 148 | + m_liveWidget->setVisible(!hideLiveBackup); |
| 149 | + }); |
| 150 | + |
| 151 | + // Initialzustand |
| 152 | + QWidget *currentTab = tabWidget->currentWidget(); |
| 153 | + bool hideLiveBackup = (currentTab == connectionSettingsTab); |
| 154 | + m_liveWidget->setVisible(!hideLiveBackup); |
| 155 | + } |
| 156 | +} |
| 157 | + |
| 158 | +} // namespace OCC |
0 commit comments