File indexing completed on 2024-04-28 05:45:53
0001 /* 0002 SPDX-FileCopyrightText: 2008-2010 Volker Lanz <vl@fidra.de> 0003 SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org> 0004 SPDX-FileCopyrightText: 2014-2018 Andrius Štikonas <andrius@stikonas.eu 0005 SPDX-FileCopyrightText: 2015 Teo Mrnjavac <teo@kde.org> 0006 SPDX-FileCopyrightText: 2019 Albert Astals Cid <aacid@kde.org> 0007 0008 SPDX-License-Identifier: GPL-3.0-or-later 0009 */ 0010 0011 #ifndef KPMCORE_PARTWIDGET_H 0012 #define KPMCORE_PARTWIDGET_H 0013 0014 #include "util/libpartitionmanagerexport.h" 0015 0016 #include "fs/filesystem.h" 0017 #include "partwidgetbase.h" 0018 0019 #include <QColor> 0020 0021 class Partition; 0022 0023 class QPaintEvent; 0024 class QResizeEvent; 0025 0026 /** Widget that represents a Partition. 0027 0028 Represents a single Partition (possibly with its children, in case of an extended Partition) in the GUI. 0029 0030 @author Volker Lanz <vl@fidra.de> 0031 */ 0032 class LIBKPMCORE_EXPORT PartWidget : public PartWidgetBase 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 explicit PartWidget(QWidget* parent, Partition* p = nullptr); 0038 0039 void init(Partition* p); 0040 void setActive(bool b) { 0041 m_Active = b; 0042 } 0043 bool isActive() const { 0044 return m_Active; /**< @return true if this is the currently active widget */ 0045 } 0046 void updateChildren(); 0047 0048 Partition* partition() { 0049 return m_Partition; /**< @return the widget's Partition */ 0050 } 0051 0052 const Partition* partition() const { 0053 return m_Partition; /**< @return the widget's Partition */ 0054 } 0055 0056 void setFileSystemColorCode( const std::vector<QColor>& colorCode ); 0057 0058 protected: 0059 void paintEvent(QPaintEvent* event) override; 0060 void resizeEvent(QResizeEvent* event) override; 0061 0062 QColor activeColor(const QColor& col) const; 0063 0064 void drawGradient(QPainter* painter, const QColor& color, const QRect& rect, bool active = false) const; 0065 0066 private: 0067 Partition* m_Partition; 0068 bool m_Active; 0069 std::vector<QColor> m_fileSystemColorCode; 0070 }; 0071 0072 #endif 0073