Skip to content

Commit

Permalink
Added support for a new command
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar1jn committed Sep 6, 2022
1 parent 86a5eb9 commit ac82f7c
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 16 deletions.
40 changes: 24 additions & 16 deletions MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@ MainWindow::MainWindow(QWidget *parent)
{
SetupWindow();
SetupCentralWidget();
tabWidget = new QTabWidget(centralWidget);
QWidget* portalTab = new QWidget;
CreateMenuBar();
CreateTabWidget();
CreatePortalMenu();
SetLayouts();

menuBar = new MenuBar(this);

menuBar->setGeometry(QRect(0, 0, 800, 22));

setMenuBar(menuBar);

portalMenu = new PortalWidget(portalTab);

tabWidget->addTab(portalTab, tr("Portal"));

}

void MainWindow::SetupWindow()
Expand All @@ -41,14 +32,31 @@ void MainWindow::SetupCentralWidget() {

}

void MainWindow::SetLayouts()
void MainWindow::CreateMenuBar()
{
// QVBoxLayout* windowLayout = new QVBoxLayout(this);
menuBar = new MenuBar(this);

// windowLayout->setContentsMargins(5, 5, 5, 5);
menuBar->setGeometry(QRect(0, 0, 800, 22));

// windowLayout->addWidget(centralWidget);
setMenuBar(menuBar);
}

void MainWindow::CreateTabWidget()
{
tabWidget = new QTabWidget(centralWidget);
}

void MainWindow::CreatePortalMenu()
{
QWidget* portalTab = new QWidget;

portalMenu = new PortalWidget(portalTab);

tabWidget->addTab(portalTab, tr("Portal"));
}

void MainWindow::SetLayouts()
{
QVBoxLayout* centralLayout = new QVBoxLayout(centralWidget);

QWidget *topFiller = new QWidget;
Expand Down
3 changes: 3 additions & 0 deletions MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class MainWindow : public QMainWindow

void SetupWindow();
void SetupCentralWidget();
void CreateMenuBar();
void CreateTabWidget();
void CreatePortalMenu();
void SetLayouts();

MenuBar* menuBar;
Expand Down
7 changes: 7 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include "MainWindow.h"

#include <QApplication>
#include <thread>
#include <iostream>

void IOFunc()
{
std::cout << "test" << std::endl;
}

int main(int argc, char *argv[])
{
Expand Down
25 changes: 25 additions & 0 deletions portal/Portal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,31 @@ void Portal::SetFeatures()
}
}

PortalStatus* Portal::GetStatus()
{
if(!connected)
{
PortalStatus* status = new PortalStatus();

return status;
}

RWCommand statusCommand = RWCommand();
statusCommand.writeBuffer[1] = 'S';

PortalStatus* status = new PortalStatus();

if(!statusCommand.SendVerified('S', 15))
{
status->success = false;
return status;
}

status->success = true;

return status;
}

void Portal::Disconnect(bool allowWrite)
{
features = NONE;
Expand Down
5 changes: 5 additions & 0 deletions portal/Portal.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ enum PortalFeatures : int {
NONE = 0
};

typedef struct PortalStatus {
bool success;
} PortalStatus;

class Portal : public QObject
{
Q_OBJECT
Expand All @@ -30,6 +34,7 @@ class Portal : public QObject
void Deactivate();
void SetColor(int r, int g, int b);
void SetColorAlternative(int side, int r, int g, int b, int u, int duration);
PortalStatus* GetStatus();

bool connected;
int features;
Expand Down

0 comments on commit ac82f7c

Please sign in to comment.