Skip to content

Commit

Permalink
Fix clang warkings
Browse files Browse the repository at this point in the history
  • Loading branch information
Rouiller committed Oct 8, 2019
1 parent be53832 commit a9a7bd0
Show file tree
Hide file tree
Showing 19 changed files with 112 additions and 150 deletions.
2 changes: 1 addition & 1 deletion c_plus_plus/src/steno/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
return QApplication::exec();
}
35 changes: 17 additions & 18 deletions c_plus_plus/src/steno/model/i_media_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,23 @@ namespace Model

class IMediaPlayer : public QWidget
{
Q_OBJECT

public:
IMediaPlayer(QWidget *parent = nullptr) : QWidget(parent) {}
virtual ~IMediaPlayer() {}
virtual void setMedia(const QUrl &url) = 0;
virtual void play() = 0;
virtual void setPosition(int position) = 0;
virtual void setVideoOutput(QVideoWidget *videoOutput) = 0;
virtual void setVolume(int volume) = 0;
virtual int volume() const = 0;

signals:
void stateChanged(QMediaPlayer::State state);
void positionChanged(qint64 position);
void durationChanged(qint64 duration);
void volumeChanged(int volume);
void errorOccured(QString error);
Q_OBJECT

public:
IMediaPlayer(QWidget *parent = nullptr) : QWidget(parent) {}
virtual void setMedia(const QUrl &url) = 0;
virtual void play() = 0;
virtual void setPosition(int position) = 0;
virtual void setVideoOutput(QVideoWidget *videoOutput) = 0;
virtual void setVolume(int volume) = 0;
virtual int volume() const = 0;

signals:
void stateChanged(QMediaPlayer::State state);
void positionChanged(qint64 position);
void durationChanged(qint64 duration);
void volumeChanged(int volume);
void errorOccured(const QString& error);
};

} // Model
Expand Down
5 changes: 0 additions & 5 deletions c_plus_plus/src/steno/model/media_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ MediaPlayer::MediaPlayer(QWidget *parent)
connect(m_mediaPlayer, QOverload<QMediaPlayer::Error>::of(&QMediaPlayer::error), [=]{ onErrorOccured(); });
}

MediaPlayer::~MediaPlayer()
{
delete m_mediaPlayer;
}

void MediaPlayer::setVideoOutput(QVideoWidget *videoOutput)
{
m_mediaPlayer->setVideoOutput(videoOutput);
Expand Down
27 changes: 13 additions & 14 deletions c_plus_plus/src/steno/model/media_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ namespace Model

class MediaPlayer : public IMediaPlayer
{
public:
explicit MediaPlayer(QWidget *parent = nullptr);
virtual ~MediaPlayer() override;
virtual void setMedia(const QUrl &url) override;
virtual void play() override;
virtual void setPosition(int position) override;
virtual void setVideoOutput(QVideoWidget *videoOutput) override;
virtual void setVolume(int volume) override;
virtual int volume() const override;

private:
void onErrorOccured();

QMediaPlayer* m_mediaPlayer;
public:
explicit MediaPlayer(QWidget *parent = nullptr);
void setMedia(const QUrl &url) override;
void play() override;
void setPosition(int position) override;
void setVideoOutput(QVideoWidget *videoOutput) override;
void setVolume(int volume) override;
int volume() const override;

private:
void onErrorOccured();

QMediaPlayer* m_mediaPlayer;
};

} // Model
Expand Down
8 changes: 4 additions & 4 deletions c_plus_plus/src/steno/view/components/sidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ namespace View

SideBar::SideBar(QWidget *parent)
: QListWidget(parent)
, itemSize(QSize(0, 40))
, m_itemSize(0, m_itemHeight)
{
setFixedWidth(150);
setFixedWidth(m_itemWidth);
}

void SideBar::add(QString name)
void SideBar::add(const QString& name)
{
addItem(name);

for (int i = 0; i < count(); i++)
{
item(i)->setSizeHint(itemSize);
item(i)->setSizeHint(m_itemSize);
}
}

Expand Down
14 changes: 8 additions & 6 deletions c_plus_plus/src/steno/view/components/sidebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ namespace View

class SideBar : public QListWidget
{
Q_OBJECT
Q_OBJECT

public:
SideBar(QWidget *parent = nullptr);
public:
SideBar(QWidget *parent = nullptr);

void add(QString name);
void add(const QString& name);

private:
const QSize itemSize;
private:
const uint8_t m_itemHeight = 40;
const uint8_t m_itemWidth = 150;
const QSize m_itemSize;
};

} // View
Expand Down
9 changes: 2 additions & 7 deletions c_plus_plus/src/steno/view/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ MainWindow::MainWindow(QWidget *parent)
{
ui->setupUi(this);

Model::MediaPlayer *mediaPlayer = new Model::MediaPlayer();
auto mediaPlayer = new Model::MediaPlayer();
mediaPlayerView = new View::MediaPlayerView(*mediaPlayer);

QFile File("view/stylesheets/globalStylesheet.qss");
File.open(QFile::ReadOnly);
qApp->setStyleSheet(QLatin1String(File.readAll()));
this->setStyleSheet(QLatin1String(File.readAll()));

addView(conferenceView);
addView(recordingView);
Expand All @@ -54,8 +54,3 @@ void MainWindow::addView(View::AbstractView *view)
sideBar->add(view->getName());
views->addWidget(view);
}

MainWindow::~MainWindow()
{
delete ui;
}
33 changes: 16 additions & 17 deletions c_plus_plus/src/steno/view/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ namespace View { class SideBar;

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
virtual ~MainWindow();

private:
void addView(View::AbstractView *view);

Ui::MainWindow *ui;
View::SideBar *sideBar;
QStackedWidget *views;
View::AbstractView *conferenceView;
View::AbstractView *recordingView;
View::AbstractView *mediaPlayerView;
View::AbstractView *transcriptionView;
View::AbstractView *settingsView;
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);

private:
void addView(View::AbstractView *view);

Ui::MainWindow *ui;
View::SideBar *sideBar;
QStackedWidget *views;
View::AbstractView *conferenceView;
View::AbstractView *recordingView;
View::AbstractView *mediaPlayerView;
View::AbstractView *transcriptionView;
View::AbstractView *settingsView;
};

#endif // MAINWINDOW_H
21 changes: 11 additions & 10 deletions c_plus_plus/src/steno/view/views/abstract_view.h
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
#ifndef ABSTRACT_VIEW_H
#define ABSTRACT_VIEW_H

#include <utility>

#include <QWidget>

namespace View
{

class AbstractView : public QWidget
{
Q_OBJECT

public:
Q_OBJECT

explicit AbstractView(const QString &name, QWidget *parent)
: QWidget(parent)
, name(name)
{}
public:
explicit AbstractView(QString name, QWidget *parent)
: QWidget(parent)
, name(std::move(name))
{}

const QString& getName() {return name;}
const QString& getName() {return name;}

private:
QString name;
private:
QString name;
};

} // View
Expand Down
5 changes: 0 additions & 5 deletions c_plus_plus/src/steno/view/views/conference_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,4 @@ ConferenceView::ConferenceView(QWidget *parent)
ui->setupUi(this);
}

ConferenceView::~ConferenceView()
{
delete ui;
}

} // View
9 changes: 4 additions & 5 deletions c_plus_plus/src/steno/view/views/conference_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ namespace View

class ConferenceView : public AbstractView
{
public:
explicit ConferenceView(QWidget *parent = nullptr);
virtual ~ConferenceView();
public:
explicit ConferenceView(QWidget *parent = nullptr);

private:
Ui::ConferenceView *ui;
private:
Ui::ConferenceView *ui;
};

} // View
Expand Down
17 changes: 6 additions & 11 deletions c_plus_plus/src/steno/view/views/media_player_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ MediaPlayerView::MediaPlayerView(Model::IMediaPlayer &videoPlayer, QWidget *pare
connect(&m_videoPlayer, &Model::IMediaPlayer::positionChanged, [=](qint64 position){ onPositionChanged(position); });
connect(&m_videoPlayer, &Model::IMediaPlayer::durationChanged, [=](qint64 duration){ onDurationChanged(duration); });
connect(&m_videoPlayer, &Model::IMediaPlayer::volumeChanged, [=](int volume){ setVolume(volume); });
connect(&m_videoPlayer, &Model::IMediaPlayer::errorOccured, [=](QString error){ onErrorOccured(error); });
}

MediaPlayerView::~MediaPlayerView()
{
delete m_ui;
connect(&m_videoPlayer, &Model::IMediaPlayer::errorOccured, [=](const QString& error){ onErrorOccured(error); });
}

void MediaPlayerView::onMediaStateChanged(QMediaPlayer::State state)
Expand All @@ -62,7 +57,7 @@ void MediaPlayerView::onDurationChanged(qint64 duration)
m_ui->positionSlider->setRange(0, static_cast<int>(duration));
}

void MediaPlayerView::onErrorOccured(QString error)
void MediaPlayerView::onErrorOccured(const QString& error)
{
m_ui->playButton->setEnabled(false);
m_ui->errorLabel->setText(error);
Expand All @@ -85,20 +80,20 @@ void MediaPlayerView::openFile()

int MediaPlayerView::volume() const
{
qreal linearVolume = QAudio::convertVolume(m_ui->volumeSlider->value() / qreal(100),
qreal linearVolume = QAudio::convertVolume(m_ui->volumeSlider->value() / qreal(m_maxVolume),
QAudio::LogarithmicVolumeScale,
QAudio::LinearVolumeScale);

return qRound(linearVolume * 100);
return qRound(linearVolume * m_maxVolume);
}

void MediaPlayerView::setVolume(int volume)
{
qreal logarithmicVolume = QAudio::convertVolume(volume / qreal(100),
qreal logarithmicVolume = QAudio::convertVolume(volume / qreal(m_maxVolume),
QAudio::LinearVolumeScale,
QAudio::LogarithmicVolumeScale);

m_ui->volumeSlider->setValue(qRound(logarithmicVolume * 100));
m_ui->volumeSlider->setValue(qRound(logarithmicVolume * m_maxVolume));
}

} // View
35 changes: 18 additions & 17 deletions c_plus_plus/src/steno/view/views/media_player_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ namespace View

class MediaPlayerView : public AbstractView
{
public:
explicit MediaPlayerView(Model::IMediaPlayer& videoPlayer, QWidget *parent = nullptr);
virtual ~MediaPlayerView();

public slots:
void onMediaStateChanged(QMediaPlayer::State state);
void onPositionChanged(qint64 position);
void onDurationChanged(qint64 duration);
void onErrorOccured(QString error);

private:
void openFile();
int volume() const;
void setVolume(int);

Ui::MediaPlayerView *m_ui;
Model::IMediaPlayer &m_videoPlayer;
public:
explicit MediaPlayerView(Model::IMediaPlayer& videoPlayer, QWidget *parent = nullptr);

public slots:
void onMediaStateChanged(QMediaPlayer::State state);
void onPositionChanged(qint64 position);
void onDurationChanged(qint64 duration);
void onErrorOccured(const QString &error);

private:
void openFile();
void setVolume(int);
int volume() const;

Ui::MediaPlayerView *m_ui;
Model::IMediaPlayer &m_videoPlayer;

const uint8_t m_maxVolume = 100;
};

} // View
Expand Down
5 changes: 0 additions & 5 deletions c_plus_plus/src/steno/view/views/recording_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,4 @@ RecordingView::RecordingView(QWidget *parent)
ui->setupUi(this);
}

RecordingView::~RecordingView()
{
delete ui;
}

} // View
9 changes: 4 additions & 5 deletions c_plus_plus/src/steno/view/views/recording_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ namespace View

class RecordingView : public AbstractView
{
public:
explicit RecordingView(QWidget *parent = nullptr);
virtual ~RecordingView();
public:
explicit RecordingView(QWidget *parent = nullptr);

private:
Ui::RecordingView *ui;
private:
Ui::RecordingView *ui;
};

} // View
Expand Down
5 changes: 0 additions & 5 deletions c_plus_plus/src/steno/view/views/settings_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,4 @@ SettingsView::SettingsView(QWidget *parent)
ui->setupUi(this);
}

SettingsView::~SettingsView()
{
delete ui;
}

} // View
Loading

0 comments on commit a9a7bd0

Please sign in to comment.