Skip to content

Commit

Permalink
UI fixes
Browse files Browse the repository at this point in the history
- fix handling form resize on device connect/disconnect
- update trayicon on device disconnect
- make "No Device Found" text translatable
  • Loading branch information
bbacskay authored and Odizinne committed Sep 15, 2024
1 parent 01a570d commit 58e0397
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 15 deletions.
24 changes: 22 additions & 2 deletions src/HeadsetControlQt/headsetcontrolqt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,14 +400,34 @@ void HeadsetControlQt::updateUIWithHeadsetInfo(const QJsonObject &headsetInfo)
void HeadsetControlQt::noDeviceFound()
{
toggleUIElements(false);
trayIcon->setToolTip("No Device Found");
trayIcon->setToolTip(tr("No Device Found"));
QString iconPath = getBatteryIcon(0, false, true, ui->themeComboBox->currentIndex());
#ifdef _WIN32
trayIcon->setIcon(QIcon(iconPath));
#elif __linux__
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString desktop = env.value("XDG_CURRENT_DESKTOP");
if (desktop.contains("KDE", Qt::CaseInsensitive)) {
QString kdeVersion = getKDEPlasmaVersion();
if (kdeVersion.startsWith("5")) {
trayIcon->setIcon(QIcon(iconPath));
} else if (kdeVersion.startsWith("6")) {
trayIcon->setIcon(QIcon::fromTheme(iconPath));
} else {
trayIcon->setIcon(QIcon(iconPath));
}
}
#endif
}

void HeadsetControlQt::toggleUIElements(bool show)
{
ui->settingsLabel->setVisible(show);
ui->frame->setVisible(show);
ui->deviceLabel->setVisible(show);
ui->frame_2->setVisible(show);
ui->notFoundLabel->setVisible(!show);
this->setFixedSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
this->setMinimumSize(380, 0);
this->adjustSize();
this->setFixedSize(this->size());
Expand Down Expand Up @@ -482,7 +502,7 @@ void HeadsetControlQt::trayIconActivated(QSystemTrayIcon::ActivationReason reaso

void HeadsetControlQt::closeEvent(QCloseEvent *event)
{
trayIcon->contextMenu()->actions().first()->setText("Show");
trayIcon->contextMenu()->actions().first()->setText(tr("Show"));
sendFirstMinimizeNotification();

}
Expand Down
2 changes: 1 addition & 1 deletion src/HeadsetControlQt/headsetcontrolqt.ui
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="settingsLabel">
<property name="minimumSize">
<size>
<width>0</width>
Expand Down
14 changes: 10 additions & 4 deletions src/Resources/tr/HeadsetControl-Qt_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>HeadsetControlQt</name>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.ui" line="26"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="493"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="513"/>
<source>HeadsetControl-Qt</source>
<translation></translation>
</message>
Expand Down Expand Up @@ -86,7 +86,8 @@
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="130"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="469"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="489"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="505"/>
<source>Show</source>
<translation></translation>
</message>
Expand Down Expand Up @@ -116,12 +117,17 @@
<translation></translation>
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="472"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="403"/>
<source>No Device Found</source>
<translation></translation>
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="492"/>
<source>Hide</source>
<translation></translation>
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="493"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="513"/>
<source>The application is still running in the background.</source>
<translation></translation>
</message>
Expand Down
14 changes: 10 additions & 4 deletions src/Resources/tr/HeadsetControl-Qt_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>HeadsetControlQt</name>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.ui" line="26"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="493"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="513"/>
<source>HeadsetControl-Qt</source>
<translation></translation>
</message>
Expand Down Expand Up @@ -86,7 +86,8 @@
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="130"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="469"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="489"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="505"/>
<source>Show</source>
<translation>Afficher</translation>
</message>
Expand Down Expand Up @@ -116,12 +117,17 @@
<translation>Pas de casque connecté</translation>
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="472"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="403"/>
<source>No Device Found</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="492"/>
<source>Hide</source>
<translation>Masquer</translation>
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="493"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="513"/>
<source>The application is still running in the background.</source>
<translation>L&apos;application tourne toujours en arrière plan.</translation>
</message>
Expand Down
14 changes: 10 additions & 4 deletions src/Resources/tr/HeadsetControl-Qt_hu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>HeadsetControlQt</name>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.ui" line="26"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="493"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="513"/>
<source>HeadsetControl-Qt</source>
<translation></translation>
</message>
Expand Down Expand Up @@ -86,7 +86,8 @@
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="130"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="469"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="489"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="505"/>
<source>Show</source>
<translation>Mutat</translation>
</message>
Expand Down Expand Up @@ -116,12 +117,17 @@
<translation>Nincs csatlakoztatva fejhallgató</translation>
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="472"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="403"/>
<source>No Device Found</source>
<translation>Eszköz nem található</translation>
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="492"/>
<source>Hide</source>
<translation>Elrejt</translation>
</message>
<message>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="493"/>
<location filename="../../HeadsetControlQt/headsetcontrolqt.cpp" line="513"/>
<source>The application is still running in the background.</source>
<translation>Az alkalmazás továbbra is fut a háttérben.</translation>
</message>
Expand Down

0 comments on commit 58e0397

Please sign in to comment.