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: 2018 Abhijeet Sharma <sharma.abhijeet2096@gmail.com>
0005     SPDX-FileCopyrightText: 2019 Yuri Chornoivan <yurchor@ukr.net>
0006 
0007     SPDX-License-Identifier: GPL-3.0-or-later
0008 */
0009 
0010 #if !defined(PARTPROPSWIDGET_H)
0011 
0012 #define PARTPROPSWIDGET_H
0013 
0014 #include "ui_partpropswidgetbase.h"
0015 
0016 #include "mainwindow.h"
0017 #include "util/guihelpers.h"
0018 
0019 /** Central widget in the PartPropsDialog.
0020     @author Volker Lanz <vl@fidra.de>
0021 */
0022 class PartPropsWidget : public QWidget, public Ui::PartPropsWidgetBase
0023 {
0024 public:
0025     explicit PartPropsWidget(QWidget* parent) : QWidget(parent) {
0026         setupUi(this);
0027 
0028         m_PartWidget->setFileSystemColorCode(GuiHelpers::fileSystemColorCodesFromSettings());
0029         MainWindow* mw = nullptr;
0030         const auto widgets = qApp->topLevelWidgets();
0031         for (auto &widget : widgets)
0032         {
0033             mw = qobject_cast< MainWindow* >( widget );
0034             if ( mw )
0035                 break;
0036         }
0037         if ( mw )
0038         {
0039             connect( mw, &MainWindow::settingsChanged,
0040                      this, [this]
0041             {
0042                 m_PartWidget->setFileSystemColorCode(GuiHelpers::fileSystemColorCodesFromSettings());
0043             });
0044         }
0045 
0046     }
0047 
0048 public:
0049     PartWidget& partWidget() {
0050         Q_ASSERT(m_PartWidget);
0051         return *m_PartWidget;
0052     }
0053 
0054     QLabel& mountPoint() {
0055         Q_ASSERT(m_LabelMountPoint);
0056         return *m_LabelMountPoint;
0057     }
0058     QLabel& devicePath() {
0059         Q_ASSERT(m_LabelDevicePath);
0060         return *m_LabelDevicePath;
0061     }
0062     QLabel& role() {
0063         Q_ASSERT(m_LabelRole);
0064         return *m_LabelRole;
0065     }
0066     QLabel& capacity() {
0067         Q_ASSERT(m_LabelCapacity);
0068         return *m_LabelCapacity;
0069     }
0070 
0071     QLabel& textAvailable() {
0072         Q_ASSERT(m_LabelTextAvailable);
0073         return *m_LabelTextAvailable;
0074     }
0075     QLabel& available() {
0076         Q_ASSERT(m_LabelAvailable);
0077         return *m_LabelAvailable;
0078     }
0079 
0080     QLabel& textUsed() {
0081         Q_ASSERT(m_LabelTextUsed);
0082         return *m_LabelTextUsed;
0083     }
0084     QLabel& used() {
0085         Q_ASSERT(m_LabelUsed);
0086         return *m_LabelUsed;
0087     }
0088 
0089     QLabel& textFileSystem() {
0090         Q_ASSERT(m_LabelFileSystem);
0091         return *m_LabelFileSystem;
0092     }
0093     QComboBox& fileSystem() {
0094         Q_ASSERT(m_ComboFileSystem);
0095         return *m_ComboFileSystem;
0096     }
0097     const QComboBox& fileSystem() const {
0098         Q_ASSERT(m_ComboFileSystem);
0099         return *m_ComboFileSystem;
0100     }
0101 
0102     QCheckBox& checkRecreate() {
0103         Q_ASSERT(m_CheckRecreate);
0104         return *m_CheckRecreate;
0105     }
0106 
0107     QLabel& firstSector() {
0108         Q_ASSERT(m_LabelFirstSector);
0109         return *m_LabelFirstSector;
0110     }
0111     QLabel& lastSector() {
0112         Q_ASSERT(m_LabelLastSector);
0113         return *m_LabelLastSector;
0114     }
0115     QLabel& numSectors() {
0116         Q_ASSERT(m_LabelNumSectors);
0117         return *m_LabelNumSectors;
0118     }
0119     QLabel& status() {
0120         Q_ASSERT(m_LabelStatus);
0121         return *m_LabelStatus;
0122     }
0123 
0124     QLabel& textUuid() {
0125         Q_ASSERT(m_LabelTextUuid);
0126         return *m_LabelTextUuid;
0127     }
0128     QLabel& uuid() {
0129         Q_ASSERT(m_LabelUuid);
0130         return *m_LabelUuid;
0131     }
0132 
0133     QLabel& textLabel() {
0134         Q_ASSERT(m_LabelTextLabel);
0135         return *m_LabelTextLabel;
0136     }
0137     QLineEdit& label() {
0138         Q_ASSERT(m_EditLabel);
0139         return *m_EditLabel;
0140     }
0141 
0142     QLabel& partitionTextUuid() {
0143         Q_ASSERT(m_LabelTextPartitionUuid);
0144         return *m_LabelTextPartitionUuid;
0145     }
0146     QLabel& partitionUuid() {
0147         Q_ASSERT(m_LabelPartitionUuid);
0148         return *m_LabelPartitionUuid;
0149     }
0150 
0151     QLabel& partitionTextLabel() {
0152         Q_ASSERT(m_LabelTextPartitionLabel);
0153         return *m_LabelTextPartitionLabel;
0154     }
0155     QLabel& partitionLabel() {
0156         Q_ASSERT(m_LabelPartitionLabel);
0157         return *m_LabelPartitionLabel;
0158     }
0159     const QLineEdit& label() const {
0160         Q_ASSERT(m_EditLabel);
0161         return *m_EditLabel;
0162     }
0163     QLabel& noSetLabel() {
0164         Q_ASSERT(m_LabelTextNoSetLabel);
0165         return *m_LabelTextNoSetLabel;
0166     }
0167 
0168     QLabel& textFlags() {
0169         Q_ASSERT(m_LabelTextFlags);
0170         return *m_LabelTextFlags;
0171     }
0172     QListWidget& listFlags() {
0173         Q_ASSERT(m_ListFlags);
0174         return *m_ListFlags;
0175     }
0176     const QListWidget& listFlags() const {
0177         Q_ASSERT(m_ListFlags);
0178         return *m_ListFlags;
0179     }
0180     QFrame& lineFlags() {
0181         Q_ASSERT(m_LineListFlags);
0182         return *m_LineListFlags;
0183     }
0184 
0185     void showAvailable(bool b) {
0186         available().setVisible(b);
0187         textAvailable().setVisible(b);
0188     }
0189     void showUsed(bool b) {
0190         used().setVisible(b);
0191         textUsed().setVisible(b);
0192     }
0193     void showFileSystem(bool b) {
0194         fileSystem().setVisible(b);
0195         textFileSystem().setVisible(b);
0196     }
0197     void showCheckRecreate(bool b) {
0198         checkRecreate().setVisible(b);
0199     }
0200     void showListFlags(bool b) {
0201         listFlags().setVisible(b);
0202         textFlags().setVisible(b);
0203         lineFlags().setVisible(b);
0204     }
0205     void showLabel(bool b) {
0206         textLabel().setVisible(b);
0207         label().setVisible(b);
0208     }
0209     void showUuid(bool b) {
0210         textUuid().setVisible(b);
0211         uuid().setVisible(b);
0212     }
0213 };
0214 
0215 #endif