Skip to content

Commit

Permalink
Fixed window position and size
Browse files Browse the repository at this point in the history
  • Loading branch information
nicola02nb committed Sep 18, 2024
1 parent 8cf685d commit e99a79d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
16 changes: 7 additions & 9 deletions src/UI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void MainWindow::changeEvent(QEvent *e)
if (windowState() == Qt::WindowMinimized) {
hide();
}
break;
default:
break;
}
Expand Down Expand Up @@ -234,31 +235,28 @@ void MainWindow::toggleWindow()
{
if (isHidden()) {
show();
minimizeWindowSize();
moveToBottomRight();
if (firstShow) {
checkForUpdates(firstShow);
firstShow = false;
}
minimizeWindowSize();
moveToBottomRight();
} else {
hide();
}
}

void MainWindow::minimizeWindowSize()
{
resize(minimumSize());
resize(sizeHint());
}

void MainWindow::moveToBottomRight()
{
QScreen *screen = QGuiApplication::primaryScreen();
QRect screenGeometry = screen->availableGeometry();

int x = screenGeometry.width() - width();
int y = screenGeometry.height() - height() - ui->notSupportedFrame->height()
- ui->missingheadsetcontrolFrame->height();
move(x, y);
QSize screenSize = screen->availableSize();
QSize finalPosition = screenSize - sizeHint();
move(finalPosition.width() - 5, finalPosition.height() - 35);
}

void MainWindow::resetGUI()
Expand Down
19 changes: 17 additions & 2 deletions src/UI/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QFrame" name="missingheadsetcontrolFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
Expand Down Expand Up @@ -759,7 +765,7 @@ Model:</string>
<item>
<widget class="QFrame" name="notificationFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -1029,6 +1035,9 @@ Model:</string>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
Expand Down Expand Up @@ -1118,7 +1127,7 @@ Model:</string>
<item>
<widget class="QFrame" name="equalizerFrame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand Down Expand Up @@ -1567,6 +1576,9 @@ Model:</string>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
Expand Down Expand Up @@ -1755,6 +1767,9 @@ Model:</string>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
Expand Down

0 comments on commit e99a79d

Please sign in to comment.