poll merge squash
This commit is contained in:
parent
308a0486b6
commit
40bee90610
21 changed files with 2753 additions and 261 deletions
|
|
@ -1,41 +1,163 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <vector>
|
||||
#include <QMainWindow>
|
||||
#include <QApplication>
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include <QIcon>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
//#include <QMessageBox>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QCheckBox>
|
||||
#include <QTimer>
|
||||
/*
|
||||
* #else
|
||||
* class QSlider;
|
||||
* class QLabel;
|
||||
* class QGridLayout;
|
||||
* class QPushButton;
|
||||
* class QWidget;
|
||||
* class QMainWindow;
|
||||
* #endif
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "contclasses.h"
|
||||
//#include <Q>
|
||||
//#include <QWidgets>
|
||||
//class EndpointHandler;
|
||||
|
||||
/*
|
||||
* class ToggleButton : public QAbstractButton {
|
||||
* Q_OBJECT
|
||||
*
|
||||
* public:
|
||||
* ToggleButton(QWidget *parent = nullptr);
|
||||
* void checkStateSet();
|
||||
* bool hitButton(const QPoint &pos) const;
|
||||
* void nextCheckState();
|
||||
* void changeEvent(QEvent *e) override;
|
||||
* bool event(QEvent *e) override;
|
||||
* void focusInEvent(QFocusEvent *e) override;
|
||||
* void focusOutEvent(QFocusEvent *e) override;
|
||||
* void keyPressEvent(QKeyEvent *e) override;
|
||||
* void keyReleaseEvent(QKeyEvent *e) override;
|
||||
* void mouseMoveEvent(QMouseEvent *e) override;
|
||||
* void mousePressEvent(QMouseEvent *e) override;
|
||||
* void mouseReleaseEvent(QMouseEvent *e) override;
|
||||
* void paintEvent(QPaintEvent *e) override = 0;
|
||||
* void timerEvent(QTimerEvent *e) override;
|
||||
* ToggleButton(QWidget *parent = nullptr);
|
||||
* };
|
||||
*/
|
||||
enum CustomQEvent {
|
||||
EndpointWidgetObsolete = 1001,
|
||||
EndpointWidgetCreated = 1002,
|
||||
EndpointDefaultChange = 1003,
|
||||
SessionWidgetCreated = 1004,
|
||||
SessionWidgetObsolete = 1005
|
||||
};
|
||||
|
||||
class EndpointWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
template <typename T>
|
||||
class CustomWidgetEvent : public QEvent {
|
||||
|
||||
public:
|
||||
EndpointWidget(EndpointHandler* eph, QWidget *parent = nullptr);
|
||||
//void populateEndpointWidget(EndpointHandler *eph);
|
||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
CustomWidgetEvent(QEvent::Type type, T payload);
|
||||
T payload;
|
||||
|
||||
};
|
||||
//Q_DECLARE_METATYPE(EndpointWidgetEvent)
|
||||
|
||||
class ExtendedCheckBox : public QCheckBox {
|
||||
Q_OBJECT
|
||||
protected:
|
||||
void customEvent(QEvent* ev) override;
|
||||
|
||||
public:
|
||||
//c++11: this inherits all parent's constructors unconditionally
|
||||
using QCheckBox::QCheckBox;
|
||||
//alternative being calling parent ctor directly after declaring child ctor:
|
||||
//B(int x) : A(x) { }
|
||||
};
|
||||
|
||||
|
||||
class SessionWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SessionWidget(uint64_t idx, SessionHandler* sh, QWidget *parent /* = nullptr */);
|
||||
~SessionWidget();
|
||||
|
||||
public slots:
|
||||
void updateMainVolume(int newValue);
|
||||
void updateMute(int checked);
|
||||
|
||||
private:
|
||||
EndpointHandler* eph;
|
||||
QPushButton *muteButton = nullptr;
|
||||
QLabel *mainLabel = nullptr;
|
||||
QSlider *mainSlider = nullptr;
|
||||
uint64_t idx;
|
||||
QGridLayout *layout = nullptr;
|
||||
QCheckBox *muteButton = nullptr;
|
||||
SessionHandler* sh;
|
||||
QTimer* volumePoller = nullptr;
|
||||
};
|
||||
|
||||
class EndpointWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EndpointWidget(uint64_t idx, EndpointHandler* eph, QWidget *parent = nullptr);
|
||||
|
||||
EndpointHandler* getEndpointHandler();
|
||||
std::map<Roles, ExtendedCheckBox*> getDefaultRolesWidgets();
|
||||
|
||||
void setIndex(uint64_t idx);
|
||||
uint64_t getIndex();
|
||||
void setVolume(int channel, float volume);
|
||||
|
||||
~EndpointWidget();
|
||||
//void updateMainVolume(float newValue);
|
||||
//void updateVolume(uint32_t channel, float newValue);
|
||||
//void updateMute(bool muted);
|
||||
|
||||
//void populateEndpointWidget(EndpointHandler *eph);
|
||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
||||
public slots:
|
||||
void updateMainVolume(int newValue);
|
||||
void updateMute(int checked);
|
||||
|
||||
protected:
|
||||
void customEvent(QEvent* ev) override;
|
||||
|
||||
private slots:
|
||||
void addSessionWidget(CustomWidgetEvent<SessionHandler*>* ev);
|
||||
void removeSessionWidget(CustomWidgetEvent<SessionHandler*>* ev);
|
||||
|
||||
private:
|
||||
int row;
|
||||
QCheckBox *muteButton = nullptr;
|
||||
QLabel *mainLabel = nullptr, *leftChannelLabel = nullptr, *rightChannelLabel = nullptr;
|
||||
QSlider *mainSlider = nullptr;
|
||||
QSlider *leftChannelSlider = nullptr;
|
||||
QSlider *rightChannelSlider = nullptr;
|
||||
std::vector<QSlider*> channelSliders;
|
||||
std::vector<QLabel*> channelLabels;
|
||||
QGridLayout *layout = nullptr;
|
||||
QGridLayout *mainMuteLayout = nullptr;
|
||||
std::map<Roles, ExtendedCheckBox*> defaultRolesCheckBoxes;
|
||||
|
||||
EndpointHandler* eph;
|
||||
size_t defaultRolesVectorSize = 4;
|
||||
QTimer* timer = nullptr;
|
||||
uint64_t idx;
|
||||
std::vector<SessionWidget*> sessionWidgets;
|
||||
//std::vector<EndpointHandler*> *ephs;
|
||||
//std::vector<QSlider> *sliders;
|
||||
|
||||
//public slots:
|
||||
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
||||
//signals:
|
||||
//void valueChanged(int value);
|
||||
|
|
@ -48,7 +170,19 @@ class MainWindow : public QMainWindow {
|
|||
//QWidget *centralWidget;
|
||||
|
||||
public:
|
||||
MainWindow(std::vector<EndpointHandler*> *ephs, QWidget *parent = nullptr);
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
void reloadEndpointWidgets();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void customEvent(QEvent* ev) override;
|
||||
|
||||
private slots:
|
||||
void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
void removeEndpointWidget(CustomWidgetEvent<uint64_t>* ev);
|
||||
void addEndpointWidget(CustomWidgetEvent<EndpointHandler*>* ev);
|
||||
void reorderEndpointWidgetCollection();
|
||||
//TODO: destroy/empty existing EndpointWidgets
|
||||
//void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
||||
private:
|
||||
|
|
@ -56,8 +190,12 @@ private:
|
|||
std::vector<EndpointWidget*> ews;
|
||||
QWidget *widget;
|
||||
QGridLayout *layout;
|
||||
//QLabel *pintas;
|
||||
|
||||
QSystemTrayIcon *trayIcon;
|
||||
QMenu *trayIconMenu;
|
||||
QAction *trayIconMenuQuit;
|
||||
QTimer *ewsUpdateTimer;
|
||||
static constexpr uint64_t ewsUpdateTimerFrequency = 500;
|
||||
//public slots:
|
||||
// void setEndpointHandlers(std::vector<EndpointHandler*> *ephs);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue