2010-07-29 22:03:24 +02:00
|
|
|
/* This file is part of Clementine.
|
2010-11-20 14:27:10 +01:00
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
2010-07-29 22:03:24 +02:00
|
|
|
|
|
|
|
Clementine is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FREESPACEBAR_H
|
|
|
|
#define FREESPACEBAR_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
class FreeSpaceBar : public QWidget {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
public:
|
2014-02-10 16:03:54 +01:00
|
|
|
FreeSpaceBar(QWidget* parent = nullptr);
|
2010-07-29 22:03:24 +02:00
|
|
|
|
|
|
|
static const int kBarHeight;
|
|
|
|
static const int kBarBorderRadius;
|
|
|
|
static const int kMarkerSpacing;
|
2010-07-30 23:47:38 +02:00
|
|
|
static const int kLabelBoxSize;
|
|
|
|
static const int kLabelBoxPadding;
|
|
|
|
static const int kLabelSpacing;
|
2010-07-29 22:03:24 +02:00
|
|
|
|
|
|
|
static const QRgb kColorBg1;
|
|
|
|
static const QRgb kColorBg2;
|
2010-07-30 00:16:12 +02:00
|
|
|
static const QRgb kColorAdd1;
|
|
|
|
static const QRgb kColorAdd2;
|
2010-07-29 22:03:24 +02:00
|
|
|
static const QRgb kColorBar1;
|
|
|
|
static const QRgb kColorBar2;
|
|
|
|
static const QRgb kColorBorder;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
void set_free_bytes(qint64 bytes) {
|
|
|
|
free_ = bytes;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
void set_additional_bytes(qint64 bytes) {
|
|
|
|
additional_ = bytes;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
void set_total_bytes(qint64 bytes) {
|
|
|
|
total_ = bytes;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_free_text(const QString& text) {
|
|
|
|
free_text_ = text;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
void set_additional_text(const QString& text) {
|
|
|
|
additional_text_ = text;
|
|
|
|
update();
|
|
|
|
}
|
|
|
|
void set_used_text(const QString& text) {
|
|
|
|
used_text_ = text;
|
|
|
|
update();
|
|
|
|
}
|
2010-07-29 22:03:24 +02:00
|
|
|
|
|
|
|
QSize sizeHint() const;
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
protected:
|
2010-07-29 22:03:24 +02:00
|
|
|
void paintEvent(QPaintEvent*);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-07-30 23:47:38 +02:00
|
|
|
struct Label {
|
|
|
|
Label(const QString& t, const QColor& c) : text(t), color(c) {}
|
|
|
|
|
|
|
|
QString text;
|
|
|
|
QColor color;
|
|
|
|
};
|
|
|
|
|
|
|
|
QString TextForSize(const QString& prefix, qint64 size) const;
|
|
|
|
|
|
|
|
void DrawBar(QPainter* p, const QRect& r);
|
|
|
|
void DrawText(QPainter* p, const QRect& r);
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
private:
|
2010-07-30 23:47:38 +02:00
|
|
|
qint64 free_;
|
|
|
|
qint64 additional_;
|
|
|
|
qint64 total_;
|
|
|
|
|
|
|
|
QString free_text_;
|
|
|
|
QString additional_text_;
|
|
|
|
QString used_text_;
|
2010-07-29 22:03:24 +02:00
|
|
|
};
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
#endif // FREESPACEBAR_H
|