File indexing completed on 2024-04-28 05:46:35

0001 /*
0002     SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de>
0003     SPDX-FileCopyrightText: 2014-2017 Andrius Štikonas <andrius@stikonas.eu>
0004     SPDX-FileCopyrightText: 2016 Teo Mrnjavac <teo@kde.org>
0005 
0006     SPDX-License-Identifier: GPL-3.0-or-later
0007 */
0008 
0009 #if !defined(SIZEDIALOGWIDGET_H)
0010 
0011 #define SIZEDIALOGWIDGET_H
0012 
0013 #include "ui_sizedialogwidgetbase.h"
0014 
0015 #include <QWidget>
0016 
0017 /** Central widget for the SizeDialogBase
0018     @author Volker Lanz <vl@fidra.de>
0019 */
0020 class SizeDialogWidget : public QWidget, public Ui::SizeDialogWidgetBase
0021 {
0022 public:
0023     SizeDialogWidget(QWidget* parent) : QWidget(parent), Ui::SizeDialogWidgetBase() {
0024         setupUi(this);
0025         hidePosixPermissions();
0026     }
0027 
0028 public:
0029     PartResizerWidget& partResizerWidget() {
0030         Q_ASSERT(m_PartResizerWidget);
0031         return *m_PartResizerWidget;
0032     }
0033 
0034     QLabel& labelFreeBefore() {
0035         Q_ASSERT(m_LabelFreeBefore);
0036         return *m_LabelFreeBefore;
0037     }
0038     QDoubleSpinBox& spinFreeBefore() {
0039         Q_ASSERT(m_SpinFreeBefore);
0040         return *m_SpinFreeBefore;
0041     }
0042     QLabel& labelFreeAfter() {
0043         Q_ASSERT(m_LabelFreeAfter);
0044         return *m_LabelFreeAfter;
0045     }
0046     QDoubleSpinBox& spinFreeAfter() {
0047         Q_ASSERT(m_SpinFreeAfter);
0048         return *m_SpinFreeAfter;
0049     }
0050     QDoubleSpinBox& spinCapacity() {
0051         Q_ASSERT(m_SpinCapacity);
0052         return *m_SpinCapacity;
0053     }
0054 
0055     QLabel& labelMinSize() {
0056         Q_ASSERT(m_LabelMinSize);
0057         return *m_LabelMinSize;
0058     }
0059     QLabel& labelMaxSize() {
0060         Q_ASSERT(m_LabelMaxSize);
0061         return *m_LabelMaxSize;
0062     }
0063 
0064     QRadioButton& radioPrimary() {
0065         Q_ASSERT(m_RadioPrimary);
0066         return *m_RadioPrimary;
0067     }
0068     QRadioButton& radioExtended() {
0069         Q_ASSERT(m_RadioExtended);
0070         return *m_RadioExtended;
0071     }
0072     QRadioButton& radioLogical() {
0073         Q_ASSERT(m_RadioLogical);
0074         return *m_RadioLogical;
0075     }
0076 
0077     QRadioButton& radioRootPermissions() {
0078         Q_ASSERT(m_permissionOnlyRoot);
0079         return *m_permissionOnlyRoot;
0080     }
0081 
0082     QComboBox& comboFileSystem() {
0083         Q_ASSERT(m_ComboFileSystem);
0084         return *m_ComboFileSystem;
0085     }
0086 
0087     QCheckBox& checkBoxEncrypt() {
0088         Q_ASSERT(m_CheckBoxEncrypt);
0089         return *m_CheckBoxEncrypt;
0090     }
0091 
0092     KNewPasswordWidget& editPassphrase() {
0093         Q_ASSERT(m_EditPassphrase);
0094         return *m_EditPassphrase;
0095     }
0096     QLabel& textLVName() {
0097         Q_ASSERT(m_LabelTextLVName);
0098         return *m_LabelTextLVName;
0099     }
0100     QLineEdit& lvName() {
0101         Q_ASSERT(m_EditLVName);
0102         return *m_EditLVName;
0103     }
0104 
0105     QLabel& textLabel() {
0106         Q_ASSERT(m_LabelTextLabel);
0107         return *m_LabelTextLabel;
0108     }
0109     QLineEdit& label() {
0110         Q_ASSERT(m_EditLabel);
0111         return *m_EditLabel;
0112     }
0113     const QLineEdit& label() const {
0114         Q_ASSERT(m_EditLabel);
0115         return *m_EditLabel;
0116     }
0117     QLabel& noSetLabel() {
0118         Q_ASSERT(m_LabelTextNoSetLabel);
0119         return *m_LabelTextNoSetLabel;
0120     }
0121 
0122     void hideRole() {
0123         delete m_LabelRole;
0124         m_LabelRole = nullptr;
0125         delete m_RadioPrimary;
0126         m_RadioPrimary = nullptr;
0127         delete m_RadioExtended;
0128         m_RadioExtended = nullptr;
0129         delete m_RadioLogical;
0130         m_RadioLogical = nullptr;
0131         delete m_groupBox_type;
0132         m_groupBox_type = nullptr;
0133     }
0134     void hideFileSystem() {
0135         delete m_LabelFileSystem;
0136         m_LabelFileSystem = nullptr;
0137         delete m_ComboFileSystem;
0138         m_ComboFileSystem = nullptr;
0139         delete m_CheckBoxEncrypt;
0140         m_CheckBoxEncrypt = nullptr;
0141         delete m_EditPassphrase;
0142         m_EditPassphrase = nullptr;
0143     }
0144     void hideLabel() {
0145         delete m_LabelTextLabel;
0146         m_LabelTextLabel = nullptr;
0147         delete m_EditLabel;
0148         m_EditLabel = nullptr;
0149         delete m_LabelTextNoSetLabel;
0150         m_LabelTextNoSetLabel = nullptr;
0151     }
0152 
0153     void hidePosixPermissions() {
0154         m_groupBox_permissions->hide();
0155         m_labelPermission->hide();
0156     }
0157 
0158     void showPosixPermissions() {
0159         m_groupBox_permissions->show();
0160         m_labelPermission->show();
0161     }
0162 
0163     bool isPermissionOnlyRoot() const {
0164         return !m_permissionEveryone->isChecked();
0165     }
0166 
0167     void hideBeforeAndAfter() {
0168         labelFreeBefore().hide();
0169         spinFreeBefore().hide();
0170         labelFreeAfter().hide();
0171         spinFreeAfter().hide();
0172     }
0173 };
0174 
0175 #endif