Skip to content

Commit

Permalink
more bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Nov 29, 2024
1 parent 71c8895 commit 5fe83f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
20 changes: 18 additions & 2 deletions Panel/Panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Panel::~Panel()
void Panel::animateIn(QRect trayIconGeometry)
{
isAnimating = true;

QPoint trayIconPos = trayIconGeometry.topLeft();
QRect screenGeometry = QApplication::primaryScreen()->geometry();
int trayIconCenterX = trayIconPos.x() + trayIconGeometry.width() / 2;
Expand Down Expand Up @@ -97,6 +98,7 @@ void Panel::animateOut()

QObject::connect(animation, &QPropertyAnimation::finished, this, [=, this]() {
animation->deleteLater();
this->hide();
visible = false;
isAnimating = false;
});
Expand Down Expand Up @@ -375,8 +377,20 @@ void Panel::clearLayout(QLayout *layout)

void Panel::populateApplications()
{
QVBoxLayout *vBoxLayout = qobject_cast<QVBoxLayout *>(ui->appFrame->layout());
clearLayout(vBoxLayout);
// Delete any existing layout in ui->appFrame
if (ui->appFrame->layout()) {
clearLayout(ui->appFrame->layout());
QLayout *oldLayout = ui->appFrame->layout();
delete oldLayout; // Delete safely to avoid memory leaks
}

// Create a new QVBoxLayout with margins and spacing
QVBoxLayout *vBoxLayout = new QVBoxLayout();
vBoxLayout->setContentsMargins(9, 9, 9, 9);
vBoxLayout->setSpacing(9);

// Set the new layout to the appFrame
ui->appFrame->setLayout(vBoxLayout);

QList<Application> applications = AudioManager::enumerateAudioApplications();

Expand Down Expand Up @@ -436,5 +450,7 @@ void Panel::populateApplications()
}
}

ui->appFrame->adjustSize();
ui->appFrame->updateGeometry();
this->adjustSize();
}
5 changes: 0 additions & 5 deletions Panel/Panel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,6 @@
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>9</number>
</property>
</layout>
</widget>
</item>
</layout>
Expand Down

0 comments on commit 5fe83f5

Please sign in to comment.