File indexing completed on 2024-04-28 13:41:59

0001 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
0002 //
0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #include "planstatuswidget.h"
0006 #include "kupsettings.h"
0007 #include "backupplan.h"
0008 
0009 #include <QBoxLayout>
0010 #include <QLabel>
0011 #include <QPushButton>
0012 
0013 #include <KLocalizedString>
0014 
0015 PlanStatusWidget::PlanStatusWidget(BackupPlan *pPlan, QWidget *pParent)
0016     : QGroupBox(pParent), mPlan(pPlan)
0017 {
0018     auto lVLayout1 = new QVBoxLayout;
0019     auto lVLayout2 = new QVBoxLayout;
0020     auto lHLayout1 = new QHBoxLayout;
0021     auto lHLayout2 = new QHBoxLayout;
0022 
0023     mDescriptionLabel = new QLabel(mPlan->mDescription);
0024     QFont lDescriptionFont = mDescriptionLabel->font();
0025     lDescriptionFont.setPointSizeF(lDescriptionFont.pointSizeF() + 2.0);
0026     lDescriptionFont.setBold(true);
0027     mDescriptionLabel->setFont(lDescriptionFont);
0028     mStatusIconLabel = new QLabel();
0029     //TODO: add dbus interface to be notified from daemon when this is updated.
0030     mStatusTextLabel = new QLabel(mPlan->statusText());
0031     auto lConfigureButton = new QPushButton(QIcon::fromTheme(QStringLiteral("configure")),
0032                                                     xi18nc("@action:button", "Configure"));
0033     connect(lConfigureButton, SIGNAL(clicked()), this, SIGNAL(configureMe()));
0034     auto lRemoveButton = new QPushButton(QIcon::fromTheme(QStringLiteral("list-remove")),
0035                                                  xi18nc("@action:button", "Remove"));
0036     connect(lRemoveButton, SIGNAL(clicked()), this, SIGNAL(removeMe()));
0037     auto lCopyButton = new QPushButton(QIcon::fromTheme(QStringLiteral("edit-duplicate")),
0038                                                xi18nc("@action:button", "Duplicate"));
0039     connect(lCopyButton, &QPushButton::clicked, this, &PlanStatusWidget::duplicateMe);
0040 
0041     lVLayout2->addWidget(mDescriptionLabel);
0042     lVLayout2->addWidget(mStatusTextLabel);
0043     lHLayout1->addLayout(lVLayout2);
0044     lHLayout1->addStretch();
0045     lHLayout1->addWidget(mStatusIconLabel);
0046     lVLayout1->addLayout(lHLayout1);
0047     lHLayout2->addStretch();
0048     lHLayout2->addWidget(lCopyButton);
0049     lHLayout2->addWidget(lConfigureButton);
0050     lHLayout2->addWidget(lRemoveButton);
0051     lVLayout1->addLayout(lHLayout2);
0052     setLayout(lVLayout1);
0053 
0054     updateIcon();
0055 }
0056 
0057 void PlanStatusWidget::updateIcon() {
0058     mStatusIconLabel->setPixmap(QIcon::fromTheme(BackupPlan::iconName(mPlan->backupStatus())).pixmap(64,64));
0059 }
0060