Skip to content

Commit

Permalink
Add options to disable Windows integrations. (#351 #342)
Browse files Browse the repository at this point in the history
  • Loading branch information
iwalton3 committed Mar 12, 2023
1 parent 953ee16 commit dc2a5ad
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 32 deletions.
10 changes: 10 additions & 0 deletions resources/settings/settings_description.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@
"value": "userWebClient",
"default": "",
"hidden": true
},
{
"value": "enableWindowsMediaIntegration",
"default": true,
"platforms": [ "windows" ]
},
{
"value": "enableWindowsTaskbarIntegration",
"default": true,
"platforms": [ "windows" ]
}
]
},
Expand Down
75 changes: 43 additions & 32 deletions src/taskbar/TaskbarComponentWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,32 @@ void TaskbarComponentWin::setWindow(QQuickWindow* window)
qDebug() << "Taskbar initialization started";
TaskbarComponent::setWindow(window);

m_button = new QWinTaskbarButton(m_window);
m_button->setWindow(m_window);
bool EnableTaskbar = SettingsComponent::Get().getSetting("enableWindowsTaskbarIntegration", true).toBool();
bool EnableMediaControls = SettingsComponent::Get().getSetting("enableWindowsMediaIntegration", true).toBool();

m_toolbar = new QWinThumbnailToolBar(m_window);
m_toolbar->setWindow(m_window);
if (EnableTaskbar) {
m_button = new QWinTaskbarButton(m_window);
m_button->setWindow(m_window);

m_prev = new QWinThumbnailToolButton(m_toolbar);
connect(m_prev, &QWinThumbnailToolButton::clicked, this, &TaskbarComponentWin::onPrevClicked);
m_toolbar = new QWinThumbnailToolBar(m_window);
m_toolbar->setWindow(m_window);

m_pause = new QWinThumbnailToolButton(m_toolbar);
connect(m_pause, &QWinThumbnailToolButton::clicked, this, &TaskbarComponentWin::onPauseClicked);
m_prev = new QWinThumbnailToolButton(m_toolbar);
connect(m_prev, &QWinThumbnailToolButton::clicked, this, &TaskbarComponentWin::onPrevClicked);

m_next = new QWinThumbnailToolButton(m_toolbar);
connect(m_next, &QWinThumbnailToolButton::clicked, this, &TaskbarComponentWin::onNextClicked);
m_pause = new QWinThumbnailToolButton(m_toolbar);
connect(m_pause, &QWinThumbnailToolButton::clicked, this, &TaskbarComponentWin::onPauseClicked);

m_prev->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipBackward));
m_next->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipForward));
m_next = new QWinThumbnailToolButton(m_toolbar);
connect(m_next, &QWinThumbnailToolButton::clicked, this, &TaskbarComponentWin::onNextClicked);

m_toolbar->addButton(m_prev);
m_toolbar->addButton(m_pause);
m_toolbar->addButton(m_next);
m_prev->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipBackward));
m_next->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipForward));

m_toolbar->addButton(m_prev);
m_toolbar->addButton(m_pause);
m_toolbar->addButton(m_next);
}

connect(&PlayerComponent::Get(), &PlayerComponent::positionUpdate, this, &TaskbarComponentWin::setProgress);
connect(&PlayerComponent::Get(), &PlayerComponent::playing, this, &TaskbarComponentWin::playing);
Expand All @@ -66,7 +71,9 @@ void TaskbarComponentWin::setWindow(QQuickWindow* window)
setControlsVisible(false);
setPaused(false);

initializeMediaTransport((HWND)window->winId());
if (EnableMediaControls) {
initializeMediaTransport((HWND)window->winId());
}
}

/////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -126,29 +133,33 @@ void TaskbarComponentWin::setControlsVisible(bool value)
/////////////////////////////////////////////////////////////////////////////////////////
void TaskbarComponentWin::setProgress(quint64 value)
{
qint64 duration = PlayerComponent::Get().getDuration();
int progress = 0;
if (duration != 0) {
progress = (int) (value / duration / 10);
if (m_button) {
qint64 duration = PlayerComponent::Get().getDuration();
int progress = 0;
if (duration != 0) {
progress = (int) (value / duration / 10);
}
m_button->progress()->setValue(progress);
}
m_button->progress()->setValue(progress);
}

/////////////////////////////////////////////////////////////////////////////////////////
void TaskbarComponentWin::setPaused(bool value)
{
if (value)
{
// m_pause->setToolTip("Resume");
m_pause->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPlay));
}
else
{
// m_pause->setToolTip("Pause");
m_pause->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPause));
}
if (m_button) {
if (value)
{
// m_pause->setToolTip("Resume");
m_pause->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPlay));
}
else
{
// m_pause->setToolTip("Pause");
m_pause->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPause));
}

m_button->progress()->setPaused(value);
m_button->progress()->setPaused(value);
}

if (m_initialized)
{
Expand Down

0 comments on commit dc2a5ad

Please sign in to comment.