fix: frameless window - all corners rounded + resize fixed
- CentralWidget with bottom-left/bottom-right radius 8px - Event filter on central widget to forward mouse events for resize - Consolidated windowFlags (Qt::Window | Frameless | MinMax | Close) - setMouseTracking(true) for cursor updates - Removed WA_TranslucentBackground causing black corners - Status bar fully removed (setStatusBar(nullptr))
This commit is contained in:
+48
-19
@@ -24,25 +24,23 @@ MainMainWindow::MainMainWindow(QWidget *parent)
|
|||||||
: QMainWindow(parent), m_currentFolderId(-1), m_currentMailId(-1)
|
: QMainWindow(parent), m_currentFolderId(-1), m_currentMailId(-1)
|
||||||
{
|
{
|
||||||
qDebug() << "[MainMainWindow] Constructor start";
|
qDebug() << "[MainMainWindow] Constructor start";
|
||||||
|
// Enable mouse tracking for resize cursor
|
||||||
|
setMouseTracking(true);
|
||||||
setupUI();
|
setupUI();
|
||||||
qDebug() << "[MainMainWindow] setupUI done";
|
qDebug() << "[MainMainWindow] setupUI done";
|
||||||
connectModels();
|
connectModels();
|
||||||
qDebug() << "[MainMainWindow] connectModels done";
|
qDebug() << "[MainMainWindow] connectModels done";
|
||||||
setWindowTitle("Wino Mail DTK");
|
setWindowTitle("Wino Mail DTK");
|
||||||
resize(1280, 820);
|
resize(1280, 820);
|
||||||
// Setup progress bar in status bar
|
// Note: status bar is removed in createTitleBar(), no progress bar in status bar
|
||||||
m_progressBar = new QProgressBar(this);
|
|
||||||
m_progressBar->setMaximumWidth(120);
|
|
||||||
m_progressBar->setVisible(false);
|
|
||||||
statusBar()->addPermanentWidget(m_progressBar);
|
|
||||||
// Connect mail service progress/status signals
|
// Connect mail service progress/status signals
|
||||||
connect(m_mailService, &MailService::progressChanged, this, &MainMainWindow::onProgressChanged);
|
connect(m_mailService, &MailService::progressChanged, this, &MainMainWindow::onProgressChanged);
|
||||||
connect(m_mailService, &MailService::statusMessage, this, &MainMainWindow::onStatusMessage);
|
connect(m_mailService, &MailService::statusMessage, this, &MainMainWindow::onStatusMessage);
|
||||||
connect(m_mailService, &MailService::mailSent, this, [this](const QString &) {
|
connect(m_mailService, &MailService::mailSent, this, [this](const QString &) {
|
||||||
statusBar()->showMessage(tr("Message sent"), 5000);
|
// statusBar()->showMessage(tr("Message sent"), 5000); // no status bar
|
||||||
});
|
});
|
||||||
connect(m_mailService, &MailService::mailSendFailed, this, [this](const QString &, const QString &error) {
|
connect(m_mailService, &MailService::mailSendFailed, this, [this](const QString &, const QString &error) {
|
||||||
statusBar()->showMessage(tr("Send failed: %1").arg(error), 8000);
|
// statusBar()->showMessage(tr("Send failed: %1").arg(error), 8000); // no status bar
|
||||||
});
|
});
|
||||||
// Provide account service to settings view
|
// Provide account service to settings view
|
||||||
m_settingsView->setAccountService(m_accountService);
|
m_settingsView->setAccountService(m_accountService);
|
||||||
@@ -66,6 +64,16 @@ void MainMainWindow::setupUI()
|
|||||||
|
|
||||||
// === Central widget ===
|
// === Central widget ===
|
||||||
QWidget *central = new QWidget();
|
QWidget *central = new QWidget();
|
||||||
|
central->setObjectName("CentralWidget");
|
||||||
|
central->setStyleSheet(
|
||||||
|
"QWidget#CentralWidget {"
|
||||||
|
" background-color: #f5f5f7;"
|
||||||
|
" border-bottom-left-radius: 8px;"
|
||||||
|
" border-bottom-right-radius: 8px;"
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
// Install event filter to handle resize from window edges
|
||||||
|
central->installEventFilter(this);
|
||||||
QHBoxLayout *centralLayout = new QHBoxLayout(central);
|
QHBoxLayout *centralLayout = new QHBoxLayout(central);
|
||||||
centralLayout->setContentsMargins(0, 0, 0, 0);
|
centralLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
centralLayout->setSpacing(0);
|
centralLayout->setSpacing(0);
|
||||||
@@ -590,10 +598,9 @@ void MainMainWindow::showTemplatesManager()
|
|||||||
void MainMainWindow::createTitleBar()
|
void MainMainWindow::createTitleBar()
|
||||||
{
|
{
|
||||||
// Enable frameless window
|
// Enable frameless window
|
||||||
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
|
Qt::WindowFlags flags = Qt::Window | Qt::FramelessWindowHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint;
|
||||||
|
setWindowFlags(flags);
|
||||||
|
|
||||||
// Set Resizeable
|
|
||||||
setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint);
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
HWND hwnd = (HWND)this->winId();
|
HWND hwnd = (HWND)this->winId();
|
||||||
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
|
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
|
||||||
@@ -601,10 +608,10 @@ void MainMainWindow::createTitleBar()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Remove status bar (item 4)
|
// Remove status bar (item 4)
|
||||||
//setStatusBar(nullptr);
|
setStatusBar(nullptr);
|
||||||
|
|
||||||
// Apply rounded corners and border to main window (items 1, 2)
|
// Apply rounded corners and border to main window (items 1, 2)
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
// Use mask for rounded corners instead of WA_TranslucentBackground to avoid black corners
|
||||||
setStyleSheet(
|
setStyleSheet(
|
||||||
"MainMainWindow {"
|
"MainMainWindow {"
|
||||||
" background-color: #f5f5f7;"
|
" background-color: #f5f5f7;"
|
||||||
@@ -896,18 +903,40 @@ void MainMainWindow::changeEvent(QEvent *event)
|
|||||||
|
|
||||||
void MainMainWindow::onProgressChanged(int percent)
|
void MainMainWindow::onProgressChanged(int percent)
|
||||||
{
|
{
|
||||||
if (percent < 0 || percent > 100) {
|
Q_UNUSED(percent);
|
||||||
m_progressBar->setVisible(false);
|
// No progress bar in status bar anymore
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
bool MainMainWindow::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
// Handle resize from central widget edges
|
||||||
|
if (watched == centralWidget()) {
|
||||||
|
if (event->type() == QEvent::MouseButtonPress) {
|
||||||
|
QMouseEvent *me = static_cast<QMouseEvent*>(event);
|
||||||
|
if (me->button() == Qt::LeftButton) {
|
||||||
|
// Forward to main window's mousePressEvent
|
||||||
|
mousePressEvent(me);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else if (event->type() == QEvent::MouseMove) {
|
||||||
|
QMouseEvent *me = static_cast<QMouseEvent*>(event);
|
||||||
|
mouseMoveEvent(me);
|
||||||
|
return true;
|
||||||
|
} else if (event->type() == QEvent::MouseButtonRelease) {
|
||||||
|
QMouseEvent *me = static_cast<QMouseEvent*>(event);
|
||||||
|
if (me->button() == Qt::LeftButton) {
|
||||||
|
mouseReleaseEvent(me);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_progressBar->setValue(percent);
|
return QMainWindow::eventFilter(watched, event);
|
||||||
m_progressBar->setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMainWindow::onStatusMessage(const QString &msg)
|
void MainMainWindow::onStatusMessage(const QString &msg)
|
||||||
{
|
{
|
||||||
// Show temporary message in status bar (timeout 5000 ms)
|
Q_UNUSED(msg);
|
||||||
statusBar()->showMessage(msg, 5000);
|
// No status bar anymore
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMainWindow::onAddAccountRequested()
|
void MainMainWindow::onAddAccountRequested()
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ protected:
|
|||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
|
bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
|
||||||
void changeEvent(QEvent *event) override;
|
void changeEvent(QEvent *event) override;
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onNavChanged(int index);
|
void onNavChanged(int index);
|
||||||
@@ -144,6 +145,4 @@ private:
|
|||||||
|
|
||||||
int m_currentFolderId;
|
int m_currentFolderId;
|
||||||
int m_currentMailId;
|
int m_currentMailId;
|
||||||
|
|
||||||
QProgressBar *m_progressBar;
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user