From f26087350d2abce4b4eb2e66e298cfc98e890274 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 3 Feb 2018 20:21:08 +0200 Subject: [PATCH] Resolved issue #414. Add features from Qt Windows Extras. --HG-- branch : develop --- ChangeLog.txt | 1 + src/app/valentina/mainwindow.cpp | 33 ++++++++++++++++++++++++-- src/app/valentina/mainwindowsnogui.cpp | 28 ++++++++++++++++++++++ src/app/valentina/mainwindowsnogui.h | 10 ++++++++ src/app/valentina/valentina.pro | 10 ++++++++ 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index c8188e64f..5fac9eced 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -41,6 +41,7 @@ - [#392] Improve feature: Show progress bar while opening pattern file. - [#732] Tape app. Improve Database dialog. - [#804] New feature. Import measurements from CSV file in Tape app. +- [#414] Add features from Qt Windows Extras. # Version 0.5.1 - [#683] Tool Seam allowance's dialog is off screen on small resolutions. diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 6b7a0ec78..bd7c00123 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -88,6 +88,11 @@ #include #include +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#include +#include +#endif + #if defined(Q_OS_MAC) #include #include @@ -176,6 +181,9 @@ MainWindow::MainWindow(QWidget *parent) InitToolButtons(); m_progressBar->setVisible(false); +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + m_taskbarProgress->setVisible(false); +#endif m_statusLabel->setText(tr("Create new pattern piece to start working.")); statusBar()->addPermanentWidget(m_statusLabel, 1); statusBar()->addPermanentWidget(m_progressBar, 1); @@ -1456,6 +1464,10 @@ void MainWindow::showEvent( QShowEvent *event ) return; } +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + m_taskbarButton->setWindow(windowHandle()); +#endif + if (isInitialized) { return; @@ -2982,6 +2994,9 @@ void MainWindow::Clear() toolOptions->ClearPropertyBrowser(); toolOptions->itemClicked(nullptr); m_progressBar->setVisible(false); +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + m_taskbarProgress->setVisible(false); +#endif m_statusLabel->setVisible(true); } @@ -3457,7 +3472,11 @@ void MainWindow::ShowProgress() { if (m_progressBar->isVisible() && m_progressBar->value() + 1 <= m_progressBar->maximum()) { - m_progressBar->setValue(m_progressBar->value() + 1); + const int newValue = m_progressBar->value() + 1; + m_progressBar->setValue(newValue); +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + m_taskbarProgress->setValue(newValue); +#endif qApp->processEvents(); } } @@ -4558,9 +4577,19 @@ bool MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile) m_progressBar->setVisible(true); m_statusLabel->setVisible(false); - m_progressBar->setMaximum(doc->ElementsToParse()); + const int elements = doc->ElementsToParse(); + m_progressBar->setMaximum(elements); +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + m_taskbarProgress->setVisible(true); + m_taskbarProgress->setMaximum(elements); +#endif + FullParseFile(); + m_progressBar->setVisible(false); +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + m_taskbarProgress->setVisible(false); +#endif m_statusLabel->setVisible(true); if (guiEnabled) diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index 3b8b704b2..4495d7c51 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -58,6 +58,11 @@ #include #include +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#include +#include +#endif + #ifdef Q_OS_WIN # define PDFTOPS "pdftops.exe" #else @@ -134,12 +139,22 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) margins(), paperSize(), m_dialogSaveLayout(), +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + m_taskbarButton(new QWinTaskbarButton(this)), + m_taskbarProgress(nullptr), +#endif isTiled(false), isAutoCrop(false), isUnitePages(false), layoutPrinterName() { InitTempLayoutScene(); + +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + m_taskbarButton->setWindow(this->windowHandle()); + m_taskbarProgress = m_taskbarButton->progress(); + m_taskbarProgress->setMinimum(0); +#endif } //--------------------------------------------------------------------------------------------------------------------- @@ -182,6 +197,12 @@ bool MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator) DialogLayoutProgress progress(listDetails.count(), this); if (VApplication::IsGUIMode()) { +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + m_taskbarProgress->setVisible(true); + m_taskbarProgress->setValue(0); + m_taskbarProgress->setMaximum(listDetails.count()); + connect(&lGenerator, &VLayoutGenerator::Arranged, m_taskbarProgress, &QWinTaskbarProgress::setValue); +#endif connect(&lGenerator, &VLayoutGenerator::Start, &progress, &DialogLayoutProgress::Start); connect(&lGenerator, &VLayoutGenerator::Arranged, &progress, &DialogLayoutProgress::Arranged); connect(&lGenerator, &VLayoutGenerator::Error, &progress, &DialogLayoutProgress::Error); @@ -194,6 +215,13 @@ bool MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator) } lGenerator.Generate(); +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + if (VApplication::IsGUIMode()) + { + m_taskbarProgress->setVisible(false); + } +#endif + switch (lGenerator.State()) { case LayoutErrors::NoError: diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index 552a2d327..ba2e5fbcb 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -42,6 +42,11 @@ class QGraphicsScene; struct PosterData; class QGraphicsRectItem; +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +class QWinTaskbarButton; +class QWinTaskbarProgress; +#endif + class MainWindowsNoGUI : public VAbstractMainWindow { Q_OBJECT @@ -92,6 +97,11 @@ protected: QSharedPointer m_dialogSaveLayout; +#if defined(Q_OS_WIN32) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) + QWinTaskbarButton *m_taskbarButton; + QWinTaskbarProgress *m_taskbarProgress; +#endif + static QVector PrepareDetailsForLayout(const QHash &details); void ExportData(const QVector &listDetails); diff --git a/src/app/valentina/valentina.pro b/src/app/valentina/valentina.pro index 0dc1e5422..d6e38f63a 100644 --- a/src/app/valentina/valentina.pro +++ b/src/app/valentina/valentina.pro @@ -13,6 +13,11 @@ include(../../../common.pri) # library in installer. QT += core gui widgets xml svg printsupport xmlpatterns concurrent +# Use winextras only for Windows 7+ +win32:greaterThan(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 6) { + QT += winextras +} + # We want create executable file TEMPLATE = app @@ -304,6 +309,11 @@ win32:*g++* { $$[QT_INSTALL_BINS]/libstdc++-6.dll \ $$[QT_INSTALL_BINS]/libwinpthread-1.dll + # For support Windows 7+ + greaterThan(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 6) { + package.files += $$[QT_INSTALL_BINS]/Qt5WinExtras.dll + } + package.CONFIG = no_check_exist INSTALLS += package