use sideways header for main window
This commit is contained in:
+3
-1
@@ -17,12 +17,14 @@ qt_add_executable(llink
|
|||||||
main.cpp
|
main.cpp
|
||||||
src/MainWindow.cpp
|
src/MainWindow.cpp
|
||||||
src/MainWindow.h
|
src/MainWindow.h
|
||||||
|
src/VerticalLabel.cpp
|
||||||
|
src/VerticalLabel.h
|
||||||
)
|
)
|
||||||
|
|
||||||
qt_add_resources(llink
|
qt_add_resources(llink
|
||||||
PREFIX_PATH "/"
|
PREFIX_PATH "/"
|
||||||
FILES
|
FILES
|
||||||
assets/icons/mono/basic/menu-rec.svg
|
assets/icons/mono/basic/menu.svg
|
||||||
assets/icons/mono/basic/plus.svg
|
assets/icons/mono/basic/plus.svg
|
||||||
assets/logo.png
|
assets/logo.png
|
||||||
)
|
)
|
||||||
|
|||||||
+51
-24
@@ -8,19 +8,20 @@
|
|||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QLabel>
|
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QApplication>
|
#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_TranslucentBackground, true);
|
||||||
this->setAttribute(Qt::WA_AcceptTouchEvents, true);
|
this->setAttribute(Qt::WA_AcceptTouchEvents, true);
|
||||||
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
|
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
|
||||||
this->resize(QSize(150, 150));
|
this->resize(QSize(150, 200));
|
||||||
|
|
||||||
QWidget *centralWidget = new QWidget(this);
|
QWidget *centralWidget = new QWidget(this);
|
||||||
centralWidget->setObjectName("glass");
|
centralWidget->setObjectName("glass");
|
||||||
@@ -49,29 +50,54 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout(centralWidget);
|
QHBoxLayout *mainLayout = new QHBoxLayout(centralWidget);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
layout->setSpacing(0);
|
mainLayout->setSpacing(0);
|
||||||
|
|
||||||
QHBoxLayout *headerLayout = new QHBoxLayout();
|
// Left sidebar - slim vertical strip
|
||||||
m_handleBar = new QSvgWidget(QStringLiteral(":/assets/icons/mono/basic/menu-rec.svg"), centralWidget);
|
QVBoxLayout *sidebarLayout = new QVBoxLayout();
|
||||||
m_handleBar->setFixedSize(QSize(20, 20));
|
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);
|
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);
|
QToolButton *addButton = new QToolButton(centralWidget);
|
||||||
connect(addButton, &QToolButton::clicked, this, []() {
|
connect(addButton, &QToolButton::clicked, this, []() {
|
||||||
qDebug() << "addButtonClicked";
|
qDebug() << "addButtonClicked";
|
||||||
});
|
});
|
||||||
addButton->setIcon(QIcon(QStringLiteral(":/assets/icons/mono/basic/plus.svg")));
|
addButton->setIcon(QIcon(QStringLiteral(":/assets/icons/mono/basic/plus.svg")));
|
||||||
|
addButton->setFixedSize(16, 16);
|
||||||
|
addButton->setIconSize(QSize(12, 12));
|
||||||
|
|
||||||
headerLayout->addWidget(m_handleBar);
|
sidebarLayout->addWidget(m_handleBar, 0, Qt::AlignHCenter);
|
||||||
headerLayout->addWidget(label);
|
sidebarLayout->addWidget(label, 1, Qt::AlignHCenter);
|
||||||
headerLayout->addStretch();
|
sidebarLayout->addWidget(addButton, 0, Qt::AlignHCenter);
|
||||||
headerLayout->addWidget(addButton);
|
|
||||||
|
// 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);
|
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);
|
QListWidgetItem *item = new QListWidgetItem(listWidget);
|
||||||
item->setCheckState(Qt::Checked);
|
item->setCheckState(Qt::Checked);
|
||||||
item->setText("do this");
|
item->setText("do this");
|
||||||
@@ -97,22 +123,23 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|||||||
)");
|
)");
|
||||||
listWidget->viewport()->setStyleSheet("background: transparent;");
|
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);
|
contentLayout->addWidget(listWidget);
|
||||||
separator->setStyleSheet("background-color: rgba(255, 255, 255, 0.1);");
|
contentLayout->addWidget(actionLabel);
|
||||||
separator->setFrameShape(QFrame::HLine);
|
|
||||||
separator->setFixedHeight(1);
|
|
||||||
layout->addWidget(separator);
|
|
||||||
|
|
||||||
layout->addWidget(listWidget);
|
mainLayout->addLayout(sidebarLayout);
|
||||||
|
mainLayout->addWidget(separator);
|
||||||
|
mainLayout->addLayout(contentLayout, 1);
|
||||||
|
|
||||||
const QScreen *screen = QGuiApplication::primaryScreen();
|
const QScreen *screen = QGuiApplication::primaryScreen();
|
||||||
const QRect screenSize = screen->geometry();
|
const QRect screenSize = screen->geometry();
|
||||||
qDebug() << "Width of window: " << this->width();
|
qDebug() << "Width of window: " << this->width();
|
||||||
qDebug() << "Height of window: " << this->height();
|
qDebug() << "Height of window: " << this->height();
|
||||||
|
|
||||||
int x = screenSize.right() - this->width();
|
int x = screenSize.left();
|
||||||
int y = (screenSize.bottom() / 2) - (this->height() / 2);
|
int y = (screenSize.bottom() / 2) - (this->height() / 2);
|
||||||
this->move(x, y);
|
this->move(x, y);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// Created by arjun-flowylabs on 1/13/2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "VerticalLabel.h"
|
||||||
|
VerticalLabel::VerticalLabel(const QString &text, QWidget *parent) : QLabel(text, parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize VerticalLabel::sizeHint() const
|
||||||
|
{
|
||||||
|
QSize s = QLabel::sizeHint();
|
||||||
|
return QSize(s.height(), s.width());
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize VerticalLabel::minimumSizeHint() const
|
||||||
|
{
|
||||||
|
QSize s = QLabel::minimumSizeHint();
|
||||||
|
return QSize(s.height(), s.width());
|
||||||
|
}
|
||||||
|
|
||||||
|
void VerticalLabel::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.setPen(palette().color(QPalette::WindowText));
|
||||||
|
painter.setFont(font());
|
||||||
|
painter.translate(0, height());
|
||||||
|
painter.rotate(-90);
|
||||||
|
painter.drawText(QRect(0, 0, height(), width()), Qt::AlignCenter, text());
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
//
|
||||||
|
// Created by arjun-flowylabs on 1/13/2026.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef LLINK_VERTICALLABEL_H
|
||||||
|
#define LLINK_VERTICALLABEL_H
|
||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
class VerticalLabel : public QLabel
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit VerticalLabel(const QString &text, QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
|
QSize minimumSizeHint() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LLINK_VERTICALLABEL_H
|
||||||
Reference in New Issue
Block a user