waydock/src/dock.cpp

57 lines
1.8 KiB
C++
Raw Normal View History

2025-04-15 22:01:07 -04:00
#include "dock.h"
/// @brief Create dock windows on all screens
/// @param app Qt Application callback
void Dock::createDockWindows(QApplication* app) {
for (int i = 0; i < this->m_screens.size(); ++i) {
QScreen* screen = this->m_screens[i];
qDebug() << "Creating dock window for screen:" << screen->name();
QWidget* container = new QWidget(nullptr, Qt::FramelessWindowHint | Qt::Tool);
2025-04-16 23:16:55 -04:00
// container->setAttribute(Qt::WA_TranslucentBackground);
// container->setAttribute(Qt::WA_NoSystemBackground);
2025-04-15 22:01:07 -04:00
container->setWindowFlag(Qt::WindowStaysOnTopHint);
2025-04-16 23:16:55 -04:00
container->setObjectName("rootWindow");
container->setAutoFillBackground(true);
2025-04-15 22:01:07 -04:00
container->resize(screen->geometry().size().width() / 2, 60);
2025-04-16 23:16:55 -04:00
container->setStyleSheet(R"(
#rootWindow {
background-color: rgba(0,0,0,0.6);
}
)");
this->m_dockWindows.push_front(container);
2025-04-15 22:01:07 -04:00
QLabel* label = new QLabel(QString("✨ Dock %1 ✨").arg(i));
label->setAlignment(Qt::AlignCenter);
label->setStyleSheet(R"(
QLabel {
color: white;
font-size: 18px;
}
)");
2025-04-16 23:16:55 -04:00
QPushButton* button = new QPushButton(QString("Start"));
QHBoxLayout* layout = new QHBoxLayout(container);
2025-04-15 22:01:07 -04:00
layout->addWidget(label);
2025-04-16 23:16:55 -04:00
layout->addWidget(button);
2025-04-15 22:01:07 -04:00
layout->setContentsMargins(0, 0, 0, 0);
QRect screenRect = screen->geometry();
int x = screenRect.center().x() - container->width() / 2;
int y = screenRect.bottom() - container->height();
container->move(x, y);
container->show();
}
app->exec();
}
Dock::Dock(QApplication* app) {
this->createDockWindows(app);
}
Dock::~Dock() {};