Skip to content
Extraits de code Groupes Projets
Vérifiée Valider de909d57 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

MISC: Make the classes final as they won't be inherited, make static member...

MISC: Make the classes final as they won't be inherited, make static member instead of defines and get ride of a goto
parent 5ad4ccc0
Branches
Aucune étiquette associée trouvée
1 requête de fusion!1MISC: Some changes done to cmake files and project organisation
......@@ -4,7 +4,7 @@
#include "Timer.h"
#include <QWidget>
class AudioVisualizer : public QWidget {
class AudioVisualizer final : public QWidget {
Q_OBJECT
public:
......
......@@ -7,7 +7,7 @@
class QMenu;
class QAction;
class MainWindow : public QMainWindow {
class MainWindow final : public QMainWindow {
Q_OBJECT
public:
......
......@@ -18,8 +18,7 @@ Timer::Timer(QImage img, QWidget *parent)
, img(img)
{
QPixmap pixmap(QPixmap::fromImage(img));
bg = scene->addPixmap(pixmap) /*->setAcceptedMouseButtons(Qt::NoButton)*/;
//scene->setBackgroundBrush(img);
bg = scene->addPixmap(pixmap);
setFixedHeight(pixmap.height());
setMaximumHeight(img.height() + horizontalScrollBar()->height() - TO_ADD_TO_IMAGE_HEIGHT);
setScene(scene);
......@@ -30,19 +29,13 @@ Timer::mousePressEvent(QMouseEvent *event)
{
QPoint pos = event->pos();
pos.rx() += horizontalScrollBar()->value();
QGraphicsItem *got;
TimingBar *bar;
int x = event->pos().x() + horizontalScrollBar()->value();
fprintf(stderr, "BEFORE IF\n");
if ((got = scene->itemAt(pos, QTransform())) != nullptr && got != bg) {
//got->hide();
goto pass;
QGraphicsItem *got;
if ((got = scene->itemAt(pos, QTransform())) == nullptr || got == bg) {
scene->addItem(new TimingBar(QLine(x, 0, x, img.height() - TO_ADD_TO_IMAGE_HEIGHT),
event->button() == Qt::LeftButton ? startColour : endColour));
}
fprintf(stderr, "AFTER IF\n");
bar = new TimingBar(QLine(x, 0, x, img.height() - TO_ADD_TO_IMAGE_HEIGHT),
event->button() == Qt::LeftButton ? startColour : endColour);
scene->addItem(bar);
pass:
QGraphicsView::mousePressEvent(event);
}
......@@ -10,13 +10,10 @@
#include <QVBoxLayout>
#include <QScrollBar>
#define BAR_WIDTH 4
#define BAR_DEMI_WIDTH ((int)(BAR_WIDTH / 2))
TimingBar::TimingBar(QLine line, QColor color, QWidget *parent)
: QGraphicsLineItem(line)
{
setPen(QPen(QBrush(color), BAR_WIDTH, Qt::SolidLine, Qt::FlatCap));
setPen(QPen(QBrush(color), bar_width, Qt::SolidLine, Qt::FlatCap));
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemSendsGeometryChanges);
setAcceptHoverEvents(true);
setCursor(Qt::PointingHandCursor);
......
......@@ -5,11 +5,15 @@
#include <QGraphicsItem>
#include <QGraphicsLineItem>
class TimingBar : public QGraphicsLineItem {
class TimingBar final : public QGraphicsLineItem {
public:
TimingBar(QLine, QColor, QWidget *parent = nullptr);
~TimingBar() = default;
private:
static inline constexpr int bar_demi_width = 2;
static inline constexpr int bar_width = 2 * bar_demi_width;
protected:
//void mousePressEvent(QGraphicsSceneMouseEvent*);
QVariant itemChange(GraphicsItemChange, const QVariant &) override;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment