139 lines
4.1 KiB
C++
139 lines
4.1 KiB
C++
//
|
|
// Created by arjun-flowylabs on 1/10/2026.
|
|
//
|
|
|
|
#include "MainWindow.h"
|
|
#include <QToolButton>
|
|
#include <QSvgWidget>
|
|
#include <QMouseEvent>
|
|
#include <QPushButton>
|
|
#include <QVBoxLayout>
|
|
#include <QLabel>
|
|
#include <QListWidget>
|
|
#include <QScreen>
|
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|
{
|
|
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
|
this->setAttribute(Qt::WA_AcceptTouchEvents, true);
|
|
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
|
this->resize(QSize(150, 175));
|
|
|
|
QWidget *centralWidget = new QWidget(this);
|
|
centralWidget->setObjectName("glass");
|
|
centralWidget->setStyleSheet(R"(
|
|
#glass {
|
|
background: rgba(25, 25, 25, 0.5);
|
|
border: none;
|
|
border-radius: 0px;
|
|
}
|
|
QLabel {
|
|
color: rgba(255, 255, 255, 0.9);
|
|
}
|
|
QToolButton {
|
|
background: transparent;
|
|
border: none;
|
|
border-radius: 4px;
|
|
padding: 4px;
|
|
}
|
|
QToolButton:hover {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
}
|
|
)");
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout(centralWidget);
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
|
layout->setSpacing(0);
|
|
|
|
QHBoxLayout *headerLayout = new QHBoxLayout();
|
|
m_handleBar = new QSvgWidget(QStringLiteral(":/assets/icons/mono/basic/menu-rec.svg"), centralWidget);
|
|
m_handleBar->setFixedSize(QSize(20, 20));
|
|
m_handleBar->setCursor(Qt::OpenHandCursor);
|
|
QLabel *label = new QLabel("STREAMS", centralWidget);
|
|
QToolButton *addButton = new QToolButton(centralWidget);
|
|
addButton->setIcon(QIcon(QStringLiteral(":/assets/icons/mono/basic/plus.svg")));
|
|
|
|
headerLayout->addWidget(m_handleBar);
|
|
headerLayout->addWidget(label);
|
|
headerLayout->addStretch();
|
|
headerLayout->addWidget(addButton);
|
|
|
|
QListWidget *listWidget = new QListWidget(centralWidget);
|
|
listWidget->addItems(QStringList{"echo-1", "beta-2", "dustin-anson", "priority-pickle"});
|
|
listWidget->setStyleSheet(R"(
|
|
QListWidget {
|
|
background: transparent;
|
|
border: none;
|
|
color: white;
|
|
font-size: 14px;
|
|
outline: none;
|
|
}
|
|
QListWidget::item {
|
|
padding: 2px;
|
|
border-radius: 0px;
|
|
margin: 2px 0px;
|
|
}
|
|
QListWidget::item:hover {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
}
|
|
QListWidget::item:selected {
|
|
background: rgba(255, 255, 255, 0.15);
|
|
}
|
|
)");
|
|
listWidget->viewport()->setStyleSheet("background: transparent;");
|
|
|
|
layout->addLayout(headerLayout);
|
|
|
|
QFrame *separator = new QFrame(centralWidget);
|
|
separator->setStyleSheet("background-color: rgba(255, 255, 255, 0.1);");
|
|
separator->setFrameShape(QFrame::HLine);
|
|
separator->setFixedHeight(1);
|
|
layout->addWidget(separator);
|
|
|
|
layout->addWidget(listWidget);
|
|
|
|
const QScreen *screen = QGuiApplication::primaryScreen();
|
|
const QRect screenSize = screen->geometry();
|
|
qDebug() << "Width of window: " << this->width();
|
|
qDebug() << "Height of window: " << this->height();
|
|
|
|
int x = screenSize.right() - this->width();
|
|
int y = (screenSize.bottom() / 2) - (this->height() / 2);
|
|
this->move(x, y);
|
|
this->setCentralWidget(centralWidget);
|
|
}
|
|
|
|
void MainWindow::resizeEvent(QResizeEvent *event)
|
|
{
|
|
QMainWindow::resizeEvent(event); // Let layout finish first
|
|
}
|
|
|
|
void MainWindow::mousePressEvent(QMouseEvent *event)
|
|
{
|
|
if (event->button() == Qt::LeftButton && m_handleBar->geometry().contains(event->pos()))
|
|
{
|
|
dragging = true;
|
|
dragPosition = event->globalPosition().toPoint() - frameGeometry().topLeft();
|
|
setCursor(Qt::ClosedHandCursor);
|
|
event->accept();
|
|
}
|
|
}
|
|
|
|
void MainWindow::mouseMoveEvent(QMouseEvent *event)
|
|
{
|
|
if (dragging && (event->buttons() & Qt::LeftButton))
|
|
{
|
|
move(event->globalPosition().toPoint() - dragPosition);
|
|
event->accept();
|
|
}
|
|
}
|
|
|
|
void MainWindow::mouseReleaseEvent(QMouseEvent *event)
|
|
{
|
|
dragging = false;
|
|
unsetCursor();
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
} |