use sideways header for main window

This commit is contained in:
talksik
2026-01-13 17:29:32 -08:00
parent fa10f986b4
commit 69cd38e1c8
4 changed files with 110 additions and 25 deletions
+51 -24
View File
@@ -8,19 +8,20 @@
#include <QMouseEvent>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>
#include <QListWidget>
#include <QScreen>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QApplication>
#include "VerticalLabel.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_trayIcon(nullptr)
{
this->setAttribute(Qt::WA_TranslucentBackground, true);
this->setAttribute(Qt::WA_AcceptTouchEvents, true);
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
this->resize(QSize(150, 150));
this->resize(QSize(150, 200));
QWidget *centralWidget = new QWidget(this);
centralWidget->setObjectName("glass");
@@ -49,29 +50,54 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
}
)");
QVBoxLayout *layout = new QVBoxLayout(centralWidget);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
QHBoxLayout *mainLayout = new QHBoxLayout(centralWidget);
mainLayout->setContentsMargins(0, 0, 0, 0);
mainLayout->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));
// Left sidebar - slim vertical strip
QVBoxLayout *sidebarLayout = new QVBoxLayout();
sidebarLayout->setContentsMargins(2, 4, 2, 4);
sidebarLayout->setSpacing(4);
m_handleBar = new QSvgWidget(QStringLiteral(":/assets/icons/mono/basic/menu.svg"), centralWidget);
m_handleBar->setFixedSize(QSize(16, 16));
m_handleBar->setCursor(Qt::OpenHandCursor);
QLabel *label = new QLabel("STREAMS", centralWidget);
label->setStyleSheet("font-weight: bold;");
// Rotated 90° "STREAMS" label
VerticalLabel *label = new VerticalLabel("STREAMS", centralWidget);
label->setStyleSheet("font-weight: bold; font-size: 10px; letter-spacing: 2px; color: rgba(255, 255, 255, 0.9);");
QToolButton *addButton = new QToolButton(centralWidget);
connect(addButton, &QToolButton::clicked, this, []() {
qDebug() << "addButtonClicked";
});
addButton->setIcon(QIcon(QStringLiteral(":/assets/icons/mono/basic/plus.svg")));
addButton->setFixedSize(16, 16);
addButton->setIconSize(QSize(12, 12));
headerLayout->addWidget(m_handleBar);
headerLayout->addWidget(label);
headerLayout->addStretch();
headerLayout->addWidget(addButton);
sidebarLayout->addWidget(m_handleBar, 0, Qt::AlignHCenter);
sidebarLayout->addWidget(label, 1, Qt::AlignHCenter);
sidebarLayout->addWidget(addButton, 0, Qt::AlignHCenter);
// Vertical separator
QFrame *separator = new QFrame(centralWidget);
separator->setStyleSheet("background-color: rgba(255, 255, 255, 0.1);");
separator->setFrameShape(QFrame::VLine);
separator->setFixedWidth(1);
// Right side with list
QVBoxLayout *contentLayout = new QVBoxLayout();
contentLayout->setContentsMargins(0, 0, 0, 0);
contentLayout->setSpacing(0);
QListWidget *listWidget = new QListWidget(centralWidget);
listWidget->addItems(QStringList{"justin, axio", "peter", "peter, faber", "daniel, justin, kim"});
listWidget->addItems(QStringList{
"[j,a] what are we going to...",
"[p] going to it",
"[p, f] change the ui",
"[d,j,k] drop off the money",
});
listWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
QListWidgetItem *item = new QListWidgetItem(listWidget);
item->setCheckState(Qt::Checked);
item->setText("do this");
@@ -97,22 +123,23 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
)");
listWidget->viewport()->setStyleSheet("background: transparent;");
layout->addLayout(headerLayout);
QLabel *actionLabel = new QLabel("Hold space");
actionLabel->setStyleSheet("color: lightgrey;");
actionLabel->setAlignment(Qt::AlignHCenter);
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);
contentLayout->addWidget(listWidget);
contentLayout->addWidget(actionLabel);
layout->addWidget(listWidget);
mainLayout->addLayout(sidebarLayout);
mainLayout->addWidget(separator);
mainLayout->addLayout(contentLayout, 1);
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 x = screenSize.left();
int y = (screenSize.bottom() / 2) - (this->height() / 2);
this->move(x, y);