Commit ad099080 authored by Andreas Traczyk's avatar Andreas Traczyk

mainwindow: prevent incoming call from resizing window

- Also, clicking incoming call notification, restores window to
  previous state.

Change-Id: If52d770095cc066e170f847e9eb18a1da0fc84ea
parent 7cc79c08
......@@ -92,9 +92,6 @@ MainWindow::MainWindow(QWidget* parent) :
connect(&sysIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayActivated(QSystemTrayIcon::ActivationReason)));
connect(&CallModel::instance(), SIGNAL(incomingCall(Call*)),
this, SLOT(onIncomingCall(Call*)));
#ifdef Q_OS_WIN
HMENU sysMenu = ::GetSystemMenu((HWND) winId(), FALSE);
if (sysMenu != NULL) {
......@@ -228,18 +225,15 @@ MainWindow::trayActivated(QSystemTrayIcon::ActivationReason reason)
void
MainWindow::notificationClicked() {
showNormal();
if (currentWindowState_ == Qt::WindowMaximized) {
showMaximized();
} else {
showNormal();
}
activateWindow();
raise();
}
void
MainWindow::onIncomingCall(Call* call)
{
Q_UNUSED(call);
QWidget::showNormal();
}
void
MainWindow::createThumbBar()
{
......@@ -260,12 +254,17 @@ MainWindow::createThumbBar()
}
void
MainWindow::switchNormalMaximize()
MainWindow::changeEvent(QEvent* e)
{
if(isMaximized())
showNormal();
else
showMaximized();
if (e->type() == QEvent::WindowStateChange) {
QWindowStateChangeEvent* event = static_cast<QWindowStateChangeEvent*>(e);
if (event->oldState() == Qt::WindowNoState && windowState() == Qt::WindowMaximized) {
currentWindowState_ = Qt::WindowMaximized;
} else if (event->oldState() == Qt::WindowMaximized && windowState() == Qt::WindowNoState) {
currentWindowState_ = Qt::WindowNoState;
}
}
QWidget::changeEvent(e);
}
void
......
......@@ -27,9 +27,6 @@
#include "navwidget.h"
#include "settingswidget.h"
// LRC
#include "call.h"
static constexpr char IDM_ABOUTBOX = 0x0010;
static constexpr uint32_t QtMaxDimension = 16777215;
......@@ -61,6 +58,7 @@ protected:
void closeEvent(QCloseEvent* event);
void resizeEvent(QResizeEvent *event);
void keyReleaseEvent(QKeyEvent* ke);
void changeEvent(QEvent* e);
signals:
void keyReleased(QKeyEvent*ke);
......@@ -71,8 +69,6 @@ public slots:
private slots:
void slotCurrentChanged(int index);
void trayActivated(QSystemTrayIcon::ActivationReason reason);
void onIncomingCall(Call* call);
void switchNormalMaximize();
void notificationClicked();
void slotScreenChanged(QScreen* screen);
......@@ -85,6 +81,7 @@ private:
int lastAccountCount_;
Qt::WindowFlags flags_;
float currentScalingRatio_;
Qt::WindowState currentWindowState_{ Qt::WindowState::WindowNoState };
void readSettingsFromRegistry();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment