Formatting
This commit is contained in:
parent
0caf76dfae
commit
b911f4f34e
|
@ -303,7 +303,7 @@ QList<QDBusObjectPath> Udisks2Lister::GetMountedPartitionsFromDBusArgument(const
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Udisks2Lister::JobCompleted(bool success, const QString &message) {
|
void Udisks2Lister::JobCompleted(const bool success, const QString &message) {
|
||||||
|
|
||||||
Q_UNUSED(message);
|
Q_UNUSED(message);
|
||||||
|
|
||||||
|
|
|
@ -74,12 +74,12 @@ class Udisks2Lister : public DeviceLister {
|
||||||
private slots:
|
private slots:
|
||||||
void DBusInterfaceAdded(const QDBusObjectPath &path, const InterfacesAndProperties &interfaces);
|
void DBusInterfaceAdded(const QDBusObjectPath &path, const InterfacesAndProperties &interfaces);
|
||||||
void DBusInterfaceRemoved(const QDBusObjectPath &path, const QStringList &interfaces);
|
void DBusInterfaceRemoved(const QDBusObjectPath &path, const QStringList &interfaces);
|
||||||
void JobCompleted(bool success, const QString &message);
|
void JobCompleted(const bool success, const QString &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isPendingJob(const QDBusObjectPath &job_path);
|
bool isPendingJob(const QDBusObjectPath &job_path);
|
||||||
void RemoveDevice(const QDBusObjectPath &device_path);
|
void RemoveDevice(const QDBusObjectPath &device_path);
|
||||||
QList<QDBusObjectPath> GetMountedPartitionsFromDBusArgument( const QDBusArgument &input);
|
QList<QDBusObjectPath> GetMountedPartitionsFromDBusArgument(const QDBusArgument &input);
|
||||||
|
|
||||||
struct Udisks2Job {
|
struct Udisks2Job {
|
||||||
Udisks2Job();
|
Udisks2Job();
|
||||||
|
|
|
@ -58,7 +58,7 @@ Chromaprinter::Chromaprinter(const QString &filename)
|
||||||
|
|
||||||
GstElement *Chromaprinter::CreateElement(const QString &factory_name, GstElement *bin) {
|
GstElement *Chromaprinter::CreateElement(const QString &factory_name, GstElement *bin) {
|
||||||
|
|
||||||
GstElement *ret = gst_element_factory_make( factory_name.toLatin1().constData(), factory_name.toLatin1().constData());
|
GstElement *ret = gst_element_factory_make(factory_name.toLatin1().constData(), factory_name.toLatin1().constData());
|
||||||
|
|
||||||
if (ret && bin) gst_bin_add(GST_BIN(bin), ret);
|
if (ret && bin) gst_bin_add(GST_BIN(bin), ret);
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,9 @@
|
||||||
|
|
||||||
SliderSlider::SliderSlider(Qt::Orientation orientation, QWidget* parent, uint max)
|
SliderSlider::SliderSlider(Qt::Orientation orientation, QWidget* parent, uint max)
|
||||||
: QSlider(orientation, parent),
|
: QSlider(orientation, parent),
|
||||||
m_sliding(false),
|
sliding_(false),
|
||||||
m_outside(false),
|
outside_(false),
|
||||||
m_prevValue(0) {
|
prev_value_(0) {
|
||||||
setRange(0, max);
|
setRange(0, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,22 +76,23 @@ void SliderSlider::wheelEvent(QWheelEvent *e) {
|
||||||
|
|
||||||
void SliderSlider::mouseMoveEvent(QMouseEvent *e) {
|
void SliderSlider::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
|
||||||
if (m_sliding) {
|
if (sliding_) {
|
||||||
// feels better, but using set value of 20 is bad of course
|
// feels better, but using set value of 20 is bad of course
|
||||||
QRect rect(-20, -20, width() + 40, height() + 40);
|
QRect rect(-20, -20, width() + 40, height() + 40);
|
||||||
|
|
||||||
if (orientation() == Qt::Horizontal && !rect.contains(e->pos())) {
|
if (orientation() == Qt::Horizontal && !rect.contains(e->pos())) {
|
||||||
if (!m_outside) QSlider::setValue(m_prevValue);
|
if (!outside_) QSlider::setValue(prev_value_);
|
||||||
m_outside = true;
|
outside_ = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_outside = false;
|
outside_ = false;
|
||||||
slideEvent(e);
|
slideEvent(e);
|
||||||
emit sliderMoved(value());
|
emit sliderMoved(value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
QSlider::mouseMoveEvent(e);
|
QSlider::mouseMoveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +125,8 @@ void SliderSlider::mousePressEvent(QMouseEvent *e) {
|
||||||
initStyleOption(&option);
|
initStyleOption(&option);
|
||||||
QRect sliderRect(style()->subControlRect(QStyle::CC_Slider, &option, QStyle::SC_SliderHandle, this));
|
QRect sliderRect(style()->subControlRect(QStyle::CC_Slider, &option, QStyle::SC_SliderHandle, this));
|
||||||
|
|
||||||
m_sliding = true;
|
sliding_ = true;
|
||||||
m_prevValue = QSlider::value();
|
prev_value_ = QSlider::value();
|
||||||
|
|
||||||
if (!sliderRect.contains(e->pos())) mouseMoveEvent(e);
|
if (!sliderRect.contains(e->pos())) mouseMoveEvent(e);
|
||||||
|
|
||||||
|
@ -133,21 +134,24 @@ void SliderSlider::mousePressEvent(QMouseEvent *e) {
|
||||||
|
|
||||||
void SliderSlider::mouseReleaseEvent(QMouseEvent*) {
|
void SliderSlider::mouseReleaseEvent(QMouseEvent*) {
|
||||||
|
|
||||||
if (!m_outside && QSlider::value() != m_prevValue)
|
if (!outside_ && QSlider::value() != prev_value_)
|
||||||
emit sliderReleased(value());
|
emit sliderReleased(value());
|
||||||
|
|
||||||
m_sliding = false;
|
sliding_ = false;
|
||||||
m_outside = false;
|
outside_ = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderSlider::setValue(int newValue) {
|
void SliderSlider::setValue(int newValue) {
|
||||||
// don't adjust the slider while the user is dragging it!
|
// don't adjust the slider while the user is dragging it!
|
||||||
|
|
||||||
if (!m_sliding || m_outside)
|
if (!sliding_ || outside_) {
|
||||||
QSlider::setValue(adjustValue(newValue));
|
QSlider::setValue(adjustValue(newValue));
|
||||||
else
|
}
|
||||||
m_prevValue = newValue;
|
else {
|
||||||
|
prev_value_ = newValue;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -157,28 +161,31 @@ void SliderSlider::setValue(int newValue) {
|
||||||
#define THICKNESS 7
|
#define THICKNESS 7
|
||||||
#define MARGIN 3
|
#define MARGIN 3
|
||||||
|
|
||||||
PrettySlider::PrettySlider(Qt::Orientation orientation, SliderMode mode, QWidget *parent, uint max)
|
PrettySlider::PrettySlider(const Qt::Orientation orientation, const SliderMode mode, QWidget *parent, const uint max)
|
||||||
: SliderSlider(orientation, parent, max), m_mode(mode) {
|
: SliderSlider(orientation, parent, max), m_mode(mode) {
|
||||||
|
|
||||||
if (m_mode == Pretty) {
|
if (m_mode == Pretty) {
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrettySlider::mousePressEvent(QMouseEvent *e) {
|
void PrettySlider::mousePressEvent(QMouseEvent *e) {
|
||||||
|
|
||||||
SliderSlider::mousePressEvent(e);
|
SliderSlider::mousePressEvent(e);
|
||||||
|
|
||||||
slideEvent(e);
|
slideEvent(e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrettySlider::slideEvent(QMouseEvent *e) {
|
void PrettySlider::slideEvent(QMouseEvent *e) {
|
||||||
|
|
||||||
if (m_mode == Pretty)
|
if (m_mode == Pretty) {
|
||||||
QSlider::setValue(
|
QSlider::setValue(orientation() == Qt::Horizontal ? QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x(), width() - 2) : QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().y(), height() - 2));
|
||||||
orientation() == Qt::Horizontal
|
}
|
||||||
? QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().x(), width() - 2)
|
else {
|
||||||
: QStyle::sliderValueFromPosition(minimum(), maximum(), e->pos().y(), height() - 2));
|
|
||||||
else
|
|
||||||
SliderSlider::slideEvent(e);
|
SliderSlider::slideEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,24 +216,25 @@ QSize PrettySlider::sizeHint() const {
|
||||||
/// CLASS VolumeSlider
|
/// CLASS VolumeSlider
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
VolumeSlider::VolumeSlider(QWidget *parent, uint max)
|
VolumeSlider::VolumeSlider(QWidget *parent, const uint max)
|
||||||
: SliderSlider(Qt::Horizontal, parent, max),
|
: SliderSlider(Qt::Horizontal, parent, max),
|
||||||
m_animCount(0),
|
anim_count_(0),
|
||||||
m_animTimer(new QTimer(this)),
|
timer_anim_(new QTimer(this)),
|
||||||
m_pixmapInset(QPixmap(drawVolumePixmap ())) {
|
pixmap_inset_(QPixmap(drawVolumePixmap())) {
|
||||||
|
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
|
|
||||||
// Store theme colors to check theme change at paintEvent
|
// Store theme colors to check theme change at paintEvent
|
||||||
m_previous_theme_text_color = palette().color(QPalette::WindowText);
|
previous_theme_text_color_ = palette().color(QPalette::WindowText);
|
||||||
m_previous_theme_highlight_color = palette().color(QPalette::Highlight);
|
previous_theme_highlight_color_ = palette().color(QPalette::Highlight);
|
||||||
|
|
||||||
drawVolumeSliderHandle();
|
drawVolumeSliderHandle();
|
||||||
generateGradient();
|
generateGradient();
|
||||||
|
|
||||||
setMinimumWidth(m_pixmapInset.width());
|
setMinimumWidth(pixmap_inset_.width());
|
||||||
setMinimumHeight(m_pixmapInset.height());
|
setMinimumHeight(pixmap_inset_.height());
|
||||||
|
|
||||||
QObject::connect(m_animTimer, &QTimer::timeout, this, &VolumeSlider::slotAnimTimer);
|
QObject::connect(timer_anim_, &QTimer::timeout, this, &VolumeSlider::slotAnimTimer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,21 +259,21 @@ void VolumeSlider::generateGradient() {
|
||||||
p.drawImage(0, 0, mask);
|
p.drawImage(0, 0, mask);
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
m_pixmapGradient = QPixmap::fromImage(gradient_image);
|
pixmap_gradient_ = QPixmap::fromImage(gradient_image);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeSlider::slotAnimTimer() {
|
void VolumeSlider::slotAnimTimer() {
|
||||||
|
|
||||||
if (m_animEnter) {
|
if (anim_enter_) {
|
||||||
m_animCount++;
|
++anim_count_;
|
||||||
update();
|
update();
|
||||||
if (m_animCount == ANIM_MAX - 1) m_animTimer->stop();
|
if (anim_count_ == ANIM_MAX - 1) timer_anim_->stop();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_animCount--;
|
--anim_count_;
|
||||||
update();
|
update();
|
||||||
if (m_animCount == 0) m_animTimer->stop();
|
if (anim_count_ == 0) timer_anim_->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -319,19 +327,19 @@ void VolumeSlider::paintEvent(QPaintEvent*) {
|
||||||
const int offset = int(double((width() - 2 * padding) * value()) / maximum());
|
const int offset = int(double((width() - 2 * padding) * value()) / maximum());
|
||||||
|
|
||||||
// If theme changed since last paintEvent, redraw the volume pixmap with new theme colors
|
// If theme changed since last paintEvent, redraw the volume pixmap with new theme colors
|
||||||
if (m_previous_theme_text_color != palette().color(QPalette::WindowText)) {
|
if (previous_theme_text_color_ != palette().color(QPalette::WindowText)) {
|
||||||
m_pixmapInset = drawVolumePixmap();
|
pixmap_inset_ = drawVolumePixmap();
|
||||||
m_previous_theme_text_color = palette().color(QPalette::WindowText);
|
previous_theme_text_color_ = palette().color(QPalette::WindowText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_previous_theme_highlight_color != palette().color(QPalette::Highlight)) {
|
if (previous_theme_highlight_color_ != palette().color(QPalette::Highlight)) {
|
||||||
drawVolumeSliderHandle();
|
drawVolumeSliderHandle();
|
||||||
m_previous_theme_highlight_color = palette().color(QPalette::Highlight);
|
previous_theme_highlight_color_ = palette().color(QPalette::Highlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
p.drawPixmap(0, 0, m_pixmapGradient, 0, 0, offset + padding, 0);
|
p.drawPixmap(0, 0, pixmap_gradient_, 0, 0, offset + padding, 0);
|
||||||
p.drawPixmap(0, 0, m_pixmapInset);
|
p.drawPixmap(0, 0, pixmap_inset_);
|
||||||
p.drawPixmap(offset - m_handlePixmaps[0].width() / 2 + padding, 0, m_handlePixmaps[m_animCount]);
|
p.drawPixmap(offset - handle_pixmaps_[0].width() / 2 + padding, 0, handle_pixmaps_[anim_count_]);
|
||||||
|
|
||||||
// Draw percentage number
|
// Draw percentage number
|
||||||
QStyleOptionViewItem opt;
|
QStyleOptionViewItem opt;
|
||||||
|
@ -350,20 +358,20 @@ void VolumeSlider::enterEvent(QEnterEvent*) {
|
||||||
void VolumeSlider::enterEvent(QEvent*) {
|
void VolumeSlider::enterEvent(QEvent*) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_animEnter = true;
|
anim_enter_ = true;
|
||||||
m_animCount = 0;
|
anim_count_ = 0;
|
||||||
|
|
||||||
m_animTimer->start(ANIM_INTERVAL);
|
timer_anim_->start(ANIM_INTERVAL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeSlider::leaveEvent(QEvent*) {
|
void VolumeSlider::leaveEvent(QEvent*) {
|
||||||
|
|
||||||
// This can happen if you enter and leave the widget quickly
|
// This can happen if you enter and leave the widget quickly
|
||||||
if (m_animCount == 0) m_animCount = 1;
|
if (anim_count_ == 0) anim_count_ = 1;
|
||||||
|
|
||||||
m_animEnter = false;
|
anim_enter_ = false;
|
||||||
m_animTimer->start(ANIM_INTERVAL);
|
timer_anim_->start(ANIM_INTERVAL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,6 +396,7 @@ QPixmap VolumeSlider::drawVolumePixmap () const {
|
||||||
path.addPolygon(poly);
|
path.addPolygon(poly);
|
||||||
painter.drawPolygon(poly);
|
painter.drawPolygon(poly);
|
||||||
painter.drawLine(6, 29, 104, 29);
|
painter.drawLine(6, 29, 104, 29);
|
||||||
|
|
||||||
// Return QPixmap
|
// Return QPixmap
|
||||||
return pixmap;
|
return pixmap;
|
||||||
|
|
||||||
|
@ -404,7 +413,7 @@ void VolumeSlider::drawVolumeSliderHandle() {
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
|
||||||
// repaint volume slider handle glow image with theme highlight color
|
// Repaint volume slider handle glow image with theme highlight color
|
||||||
painter.fillRect(pixmapHandleGlow_image.rect(), QBrush(palette().color(QPalette::Highlight)));
|
painter.fillRect(pixmapHandleGlow_image.rect(), QBrush(palette().color(QPalette::Highlight)));
|
||||||
painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
painter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
|
||||||
painter.drawImage(0, 0, pixmapHandleGlow);
|
painter.drawImage(0, 0, pixmapHandleGlow);
|
||||||
|
@ -417,7 +426,7 @@ void VolumeSlider::drawVolumeSliderHandle() {
|
||||||
float opacity = 0.0;
|
float opacity = 0.0;
|
||||||
const float step = 1.0 / ANIM_MAX;
|
const float step = 1.0 / ANIM_MAX;
|
||||||
QImage dst;
|
QImage dst;
|
||||||
m_handlePixmaps.clear();
|
handle_pixmaps_.clear();
|
||||||
for (int i = 0; i < ANIM_MAX; ++i) {
|
for (int i = 0; i < ANIM_MAX; ++i) {
|
||||||
dst = pixmapHandle.copy();
|
dst = pixmapHandle.copy();
|
||||||
|
|
||||||
|
@ -426,7 +435,7 @@ void VolumeSlider::drawVolumeSliderHandle() {
|
||||||
p.drawImage(0, 0, pixmapHandleGlow_image);
|
p.drawImage(0, 0, pixmapHandleGlow_image);
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
m_handlePixmaps.append(QPixmap::fromImage(dst));
|
handle_pixmaps_.append(QPixmap::fromImage(dst));
|
||||||
opacity += step;
|
opacity += step;
|
||||||
}
|
}
|
||||||
// END
|
// END
|
||||||
|
|
|
@ -44,7 +44,7 @@ class SliderSlider : public QSlider {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SliderSlider(Qt::Orientation, QWidget*, uint max = 0);
|
explicit SliderSlider(Qt::Orientation, QWidget*, const uint max = 0);
|
||||||
|
|
||||||
virtual void setValue(int);
|
virtual void setValue(int);
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class SliderSlider : public QSlider {
|
||||||
void mousePressEvent(QMouseEvent*) override;
|
void mousePressEvent(QMouseEvent*) override;
|
||||||
virtual void slideEvent(QMouseEvent*);
|
virtual void slideEvent(QMouseEvent*);
|
||||||
|
|
||||||
bool m_sliding;
|
bool sliding_;
|
||||||
|
|
||||||
/// we flip the value for vertical sliders
|
/// we flip the value for vertical sliders
|
||||||
int adjustValue(int v) const {
|
int adjustValue(int v) const {
|
||||||
|
@ -71,8 +71,8 @@ class SliderSlider : public QSlider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_outside;
|
bool outside_;
|
||||||
int m_prevValue;
|
int prev_value_;
|
||||||
|
|
||||||
SliderSlider(const SliderSlider&); // undefined
|
SliderSlider(const SliderSlider&); // undefined
|
||||||
SliderSlider& operator=(const SliderSlider&); // undefined
|
SliderSlider& operator=(const SliderSlider&); // undefined
|
||||||
|
@ -87,7 +87,7 @@ class PrettySlider : public SliderSlider {
|
||||||
Pretty
|
Pretty
|
||||||
} SliderMode;
|
} SliderMode;
|
||||||
|
|
||||||
explicit PrettySlider(Qt::Orientation orientation, SliderMode mode, QWidget* parent, uint max = 0);
|
explicit PrettySlider(const Qt::Orientation orientation, const SliderMode mode, QWidget* parent, const uint max = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void slideEvent(QMouseEvent*) override;
|
void slideEvent(QMouseEvent*) override;
|
||||||
|
@ -136,17 +136,17 @@ class VolumeSlider : public SliderSlider {
|
||||||
static const int ANIM_INTERVAL = 18;
|
static const int ANIM_INTERVAL = 18;
|
||||||
static const int ANIM_MAX = 18;
|
static const int ANIM_MAX = 18;
|
||||||
|
|
||||||
bool m_animEnter;
|
bool anim_enter_;
|
||||||
int m_animCount;
|
int anim_count_;
|
||||||
QTimer *m_animTimer;
|
QTimer *timer_anim_;
|
||||||
|
|
||||||
QPixmap m_pixmapInset;
|
QPixmap pixmap_inset_;
|
||||||
QPixmap m_pixmapGradient;
|
QPixmap pixmap_gradient_;
|
||||||
|
|
||||||
QColor m_previous_theme_text_color;
|
QColor previous_theme_text_color_;
|
||||||
QColor m_previous_theme_highlight_color;
|
QColor previous_theme_highlight_color_;
|
||||||
|
|
||||||
QList<QPixmap> m_handlePixmaps;
|
QList<QPixmap> handle_pixmaps_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VOLUMESLIDER_H
|
#endif // VOLUMESLIDER_H
|
||||||
|
|
Loading…
Reference in New Issue