windows: implemented export progress on taskbar button
This commit is contained in:
@@ -37,6 +37,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
// Qt on Windows has a bug that "de-maximizes" the window when widgets are added, resizing the window beforehand
|
||||
// works around that issue and we just set it to whatever size is available
|
||||
resize(qApp->desktop()->availableGeometry(this).size());
|
||||
|
||||
// Set up taskbar button progress bar (used for some modal tasks like exporting)
|
||||
taskbar_btn_id_ = RegisterWindowMessage("TaskbarButtonCreated");
|
||||
taskbar_interface_ = nullptr;
|
||||
#endif
|
||||
|
||||
// Create empty central widget - we don't actually want a central widget but some of Qt's docking/undocking fails
|
||||
@@ -108,6 +112,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (taskbar_interface_) {
|
||||
taskbar_interface_->Release();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::OpenSequence(Sequence *sequence)
|
||||
{
|
||||
// See if this sequence is already open, and switch to it if so
|
||||
@@ -151,6 +164,22 @@ void MainWindow::CloseSequence(Sequence *sequence)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
void MainWindow::SetTaskbarButtonState(TBPFLAG flags)
|
||||
{
|
||||
if (taskbar_interface_) {
|
||||
taskbar_interface_->SetProgressState(reinterpret_cast<HWND>(this->winId()), flags);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::SetTaskbarButtonProgress(int value, int max)
|
||||
{
|
||||
if (taskbar_interface_) {
|
||||
taskbar_interface_->SetProgressValue(reinterpret_cast<HWND>(this->winId()), value, max);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::SetFullscreen(bool fullscreen)
|
||||
{
|
||||
if (fullscreen) {
|
||||
@@ -239,6 +268,31 @@ void MainWindow::closeEvent(QCloseEvent *e)
|
||||
QMainWindow::closeEvent(e);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message, long *result)
|
||||
{
|
||||
if (static_cast<MSG*>(message)->message == taskbar_btn_id_) {
|
||||
// Attempt to create taskbar button progress handle
|
||||
HRESULT hr = CoCreateInstance(CLSID_TaskbarList,
|
||||
NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_ITaskbarList3,
|
||||
reinterpret_cast<void**>(&taskbar_interface_));
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = taskbar_interface_->HrInit();
|
||||
|
||||
if (FAILED(hr)) {
|
||||
taskbar_interface_->Release();
|
||||
taskbar_interface_ = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QMainWindow::nativeEvent(eventType, message, result);
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::UpdateTitle()
|
||||
{
|
||||
if (project_panel_->project()) {
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
#include "panel/pixelsampler/pixelsamplerpanel.h"
|
||||
#include "project/project.h"
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
#include <shobjidl.h>
|
||||
#endif
|
||||
|
||||
OLIVE_NAMESPACE_ENTER
|
||||
|
||||
/**
|
||||
@@ -47,10 +51,18 @@ class MainWindow : public QMainWindow {
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
|
||||
virtual ~MainWindow() override;
|
||||
|
||||
void OpenSequence(Sequence* sequence);
|
||||
|
||||
void CloseSequence(Sequence* sequence);
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
void SetTaskbarButtonState(TBPFLAG flags);
|
||||
|
||||
void SetTaskbarButtonProgress(int value, int max);
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
void ProjectOpen(Project *p);
|
||||
void SetFullscreen(bool fullscreen);
|
||||
@@ -61,6 +73,10 @@ public slots:
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* e) override;
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
TimelinePanel* AppendTimelinePanel();
|
||||
|
||||
@@ -81,6 +97,12 @@ private:
|
||||
CurvePanel* curve_panel_;
|
||||
PixelSamplerPanel* pixel_sampler_panel_;
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
unsigned int taskbar_btn_id_;
|
||||
|
||||
ITaskbarList3* taskbar_interface_;
|
||||
#endif
|
||||
|
||||
private slots:
|
||||
void FocusedPanelChanged(PanelWidget* panel);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user