diff --git a/CMakeLists.txt b/CMakeLists.txt index 048fd70586..e4238d640a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,174 +1,177 @@ # kdevplatform version set(KDEVPLATFORM_VERSION_MAJOR 4) set(KDEVPLATFORM_VERSION_MINOR 90) set(KDEVPLATFORM_VERSION_PATCH 92) # plugin versions listed in the .desktop files set(KDEV_PLUGIN_VERSION 25) # Increase this to reset incompatible item-repositories set(KDEV_ITEMREPOSITORY_VERSION 85) # library version / SO version set(KDEVPLATFORM_LIB_VERSION 10.0.0) set(KDEVPLATFORM_LIB_SOVERSION 10) ################################################################################ cmake_minimum_required(VERSION 2.8.12) project(KDevPlatform) # we need some parts of the ECM CMake helpers find_package (ECM 0.0.9 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${KDevPlatform_SOURCE_DIR}/cmake/modules ${ECM_MODULE_PATH}) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMAddTests) include(ECMOptionalAddSubdirectory) include(ECMInstallIcons) include(ECMSetupVersion) include(ECMMarkAsTest) include(ECMMarkNonGuiExecutable) include(ECMGenerateHeaders) include(ECMPackageConfigHelpers) include(GenerateExportHeader) include(FeatureSummary) include(WriteBasicConfigVersionFile) include(CheckFunctionExists) include(KDEInstallDirs) include(KDECMakeSettings) include(KDevPlatformMacros) set(QT_MIN_VERSION "5.4.0") find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus Widgets WebKitWidgets Concurrent Test) find_package(Qt5QuickWidgets ${QT_MIN_VERSION}) set_package_properties(Qt5QuickWidgets PROPERTIES PURPOSE "Qt5 QuickWidgets library (part of Qt >=5.3). Required for the Welcome Page plugin." ) set(KF5_DEP_VERSION "5.16.0") find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS Archive Config GuiAddons WidgetsAddons IconThemes I18n ItemModels ItemViews JobWidgets KCMUtils KIO NewStuff Notifications NotifyConfig Parts Service Sonnet TextEditor ThreadWeaver WindowSystem Declarative XmlGui ) find_package(Grantlee5) set_package_properties(Grantlee5 PROPERTIES PURPOSE "Grantlee templating library, needed for file templates" URL "http://www.grantlee.org/" TYPE RECOMMENDED) set(Boost_ADDITIONAL_VERSIONS 1.39.0 1.39) find_package(Boost 1.35.0) set_package_properties(Boost PROPERTIES PURPOSE "Boost libraries for enabling the classbrowser" URL "http://www.boost.org" TYPE REQUIRED) add_definitions( -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050400 -DQT_NO_URL_CAST_FROM_STRING -DQT_STRICT_ITERATORS -DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS ) # Turn off missing-field-initializers warning for GCC to avoid noise from false positives with empty {} # See discussion: http://mail.kde.org/pipermail/kdevelop-devel/2014-February/046910.html check_cxx_compiler_flag(-Wno-missing-field-initializers HAVE_MFI_FLAG) check_cxx_compiler_flag(-Werror=undefined-bool-conversion HAVE_UBC_FLAG) check_cxx_compiler_flag(-Werror=tautological-undefined-compare HAVE_TUC_FLAG) if (HAVE_MFI_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers") endif() if (HAVE_UBC_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=undefined-bool-conversion") endif() if (HAVE_TUC_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=tautological-undefined-compare") endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-kdevplatform.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdevplatform.h ) include_directories(${KDevPlatform_SOURCE_DIR} ${KDevPlatform_BINARY_DIR}) string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER) if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "debug" OR CMAKE_BUILD_TYPE_TOLOWER STREQUAL "") set(COMPILER_OPTIMIZATIONS_DISABLED TRUE) else() set(COMPILER_OPTIMIZATIONS_DISABLED FALSE) endif() add_subdirectory(sublime) add_subdirectory(interfaces) add_subdirectory(project) add_subdirectory(language) add_subdirectory(shell) add_subdirectory(util) add_subdirectory(outputview) add_subdirectory(vcs) add_subdirectory(pics) add_subdirectory(debugger) add_subdirectory(documentation) add_subdirectory(serialization) add_subdirectory(template) add_subdirectory(tests) add_subdirectory(plugins) set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KDevPlatform") ecm_configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KDevPlatformConfig.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/KDevPlatformConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} ) +if(APPLE) + target_link_libraries(KDevPlatformShell PRIVATE "-framework AppKit") +endif() ecm_setup_version(${KDEVPLATFORM_VERSION_MAJOR}.${KDEVPLATFORM_VERSION_MINOR}.${KDEVPLATFORM_VERSION_PATCH} VARIABLE_PREFIX KDEVPLATFORM VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kdevplatform_version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KDevPlatformConfigVersion.cmake" SOVERSION ${KDEVPLATFORM_LIB_SOVERSION}) install( FILES "${KDevPlatform_BINARY_DIR}/kdevplatform_version.h" "${KDevPlatform_BINARY_DIR}/config-kdevplatform.h" DESTINATION "${KDE_INSTALL_INCLUDEDIR}/kdevplatform" ) install( FILES "${KDevPlatform_BINARY_DIR}/KDevPlatformConfig.cmake" "${KDevPlatform_BINARY_DIR}/KDevPlatformConfigVersion.cmake" cmake/modules/KDevPlatformMacros.cmake DESTINATION "${CMAKECONFIG_INSTALL_DIR}" ) install( EXPORT KDevPlatformTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" NAMESPACE KDev:: FILE KDevPlatformTargets.cmake ) include(CTest) # CTestCustom.cmake has to be in the CTEST_BINARY_DIR. # in the KDE build system, this is the same as CMAKE_BINARY_DIR. configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt index 0e55f96de8..336aaaa3b4 100644 --- a/shell/CMakeLists.txt +++ b/shell/CMakeLists.txt @@ -1,172 +1,181 @@ add_definitions(-DTRANSLATION_DOMAIN=\"kdevplatform\") add_subdirectory(tests) set(KDevPlatformShell_LIB_SRCS workingsetcontroller.cpp workingsets/workingset.cpp workingsets/workingsetfilelabel.cpp workingsets/workingsettoolbutton.cpp workingsets/workingsettooltipwidget.cpp workingsets/workingsetwidget.cpp workingsets/closedworkingsetswidget.cpp workingsets/workingsethelpers.cpp mainwindow.cpp mainwindow_p.cpp plugincontroller.cpp ktexteditorpluginintegration.cpp shellextension.cpp core.cpp uicontroller.cpp projectcontroller.cpp project.cpp partcontroller.cpp #document.cpp partdocument.cpp textdocument.cpp documentcontroller.cpp languagecontroller.cpp statusbar.cpp runcontroller.cpp unitylauncher.cpp sessioncontroller.cpp session.cpp sessionlock.cpp sessionchooserdialog.cpp savedialog.cpp sourceformattercontroller.cpp completionsettings.cpp openprojectpage.cpp openprojectdialog.cpp projectinfopage.cpp selectioncontroller.cpp documentationcontroller.cpp debugcontroller.cpp launchconfiguration.cpp launchconfigurationdialog.cpp loadedpluginsdialog.cpp testcontroller.cpp projectsourcepage.cpp debug.cpp configdialog.cpp editorconfigpage.cpp environmentconfigurebutton.cpp checkerstatus.cpp problem.cpp problemmodelset.cpp problemmodel.cpp problemstore.cpp watcheddocumentset.cpp filteredproblemstore.cpp progresswidget/progressmanager.cpp progresswidget/statusbarprogresswidget.cpp progresswidget/overlaywidget.cpp progresswidget/progressdialog.cpp areadisplay.cpp settings/uipreferences.cpp settings/pluginpreferences.cpp settings/sourceformattersettings.cpp settings/editstyledialog.cpp settings/projectpreferences.cpp settings/environmentwidget.cpp settings/environmentgroupmodel.cpp settings/environmentpreferences.cpp settings/languagepreferences.cpp settings/bgpreferences.cpp settings/templateconfig.cpp settings/templatepage.cpp ) +if(APPLE) + set(KDevPlatformShell_LIB_SRCS ${KDevPlatformShell_LIB_SRCS} + macdockprogressview.mm + ) +endif() + kconfig_add_kcfg_files(KDevPlatformShell_LIB_SRCS settings/uiconfig.kcfgc settings/projectconfig.kcfgc settings/languageconfig.kcfgc settings/bgconfig.kcfgc ) ki18n_wrap_ui(KDevPlatformShell_LIB_SRCS projectinfopage.ui launchconfigurationdialog.ui projectsourcepage.ui settings/uiconfig.ui settings/editstyledialog.ui settings/sourceformattersettings.ui settings/projectpreferences.ui settings/environmentwidget.ui settings/languagepreferences.ui settings/bgpreferences.ui settings/templateconfig.ui settings/templatepage.ui ) qt5_add_resources(KDevPlatformShell_LIB_SRCS kdevplatformshell.qrc) kdevplatform_add_library(KDevPlatformShell SOURCES ${KDevPlatformShell_LIB_SRCS}) target_link_libraries(KDevPlatformShell LINK_PUBLIC KF5::XmlGui KDev::Sublime KDev::OutputView KDev::Interfaces LINK_PRIVATE Qt5::Quick Qt5::QuickWidgets KF5::GuiAddons KF5::IconThemes KF5::KIOFileWidgets KF5::KIOWidgets KF5::Parts KF5::Notifications KF5::NotifyConfig KF5::TextEditor KF5::ThreadWeaver KF5::JobWidgets KF5::ItemViews KF5::WindowSystem KF5::KCMUtils #for KPluginSelector, not sure why it is in kcmutils KF5::NewStuff # template config page KF5::Archive # template config page KDev::Debugger KDev::Project KDev::Vcs KDev::Language KDev::Util KDev::Documentation ) +if(APPLE) + target_link_libraries(KDevPlatformShell PRIVATE "-framework AppKit") +endif() install(FILES mainwindow.h plugincontroller.h shellextension.h core.h uicontroller.h projectcontroller.h project.h partcontroller.h partdocument.h textdocument.h documentcontroller.h languagecontroller.h session.h sessioncontroller.h sessionlock.h sourceformattercontroller.h selectioncontroller.h runcontroller.h launchconfiguration.h environmentconfigurebutton.h checkerstatus.h problem.h problemmodel.h problemmodelset.h problemconstants.h filteredproblemstore.h DESTINATION ${KDE_INSTALL_INCLUDEDIR}/kdevplatform/shell COMPONENT Devel ) diff --git a/shell/macdockprogressview.h b/shell/macdockprogressview.h new file mode 100644 index 0000000000..58b6ed580b --- /dev/null +++ b/shell/macdockprogressview.h @@ -0,0 +1,40 @@ +/* + * Copyright 2016 René J.V. Bertin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + */ + +#ifndef MACDOCKPROGRESSVIEW_H + +namespace KDevelop +{ + +class MacDockProgressView +{ +public: + static void setRange(int min, int max); + + static void setProgress(int value); + + static void setProgressVisible(bool visible); +}; + +} + +#define MACDOCKPROGRESSVIEW_H +#endif diff --git a/shell/macdockprogressview.mm b/shell/macdockprogressview.mm new file mode 100644 index 0000000000..23557ae99e --- /dev/null +++ b/shell/macdockprogressview.mm @@ -0,0 +1,211 @@ +/* + * Copyright 2016 René J.V. Bertin + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + */ + +#include "macdockprogressview.h" +#include +#include + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +#import +#import +#import +#import +#import +#import +#import + +using namespace KDevelop; + +@interface MacDockProgressViewPrivate : NSView { + int min; + int max; + int value; + NSColor *bgColour, *fgColour; + NSTimer *indeterminateTimer; +} + ++ (MacDockProgressViewPrivate *)sharedProgressView; + +- (id)init; +- (void)dealloc; +- (void)removeTimer; +- (void)rangeStartsAt:(int)v1 endsAt:(int)v2; +- (void)setValue:(int)v; +- (void)updateBadge; + +@end + +static MacDockProgressViewPrivate *sharedProgressView = nil; + +@implementation MacDockProgressViewPrivate + ++ (MacDockProgressViewPrivate *)sharedProgressView +{ + if (sharedProgressView == nil) { + sharedProgressView = [[MacDockProgressViewPrivate alloc] init]; + [sharedProgressView rangeStartsAt:0 endsAt:100]; + } + return sharedProgressView; +} + +- (id)init +{ + self = [super init]; + bgColour = fgColour = nil; + indeterminateTimer = nil; + min = max = value = 0; + return self; +} + +- (void)dealloc +{ + [self removeTimer]; + [bgColour release]; + [fgColour release]; + [super dealloc]; +} + +- (void)removeTimer +{ + if (indeterminateTimer != nil) { + [indeterminateTimer invalidate]; + [indeterminateTimer release]; + indeterminateTimer = nil; + } +} + +- (void)rangeStartsAt:(int)v1 endsAt:(int)v2 +{ + min = v1; + max = v2; + // (re)set the colours to the standard progressbar colour scheme + [bgColour release]; + [fgColour release]; + bgColour = [[NSColor blackColor] retain]; + fgColour = [[NSColor lightGrayColor] retain]; + if (v1 == v2 ) { + if (indeterminateTimer == nil) { + indeterminateTimer = [[NSTimer timerWithTimeInterval:1 + target:self + selector:@selector(updateBadge) + userInfo:nil + repeats:YES] retain]; + if (indeterminateTimer) { + [[NSRunLoop currentRunLoop] addTimer:indeterminateTimer forMode:NSDefaultRunLoopMode]; + } + } + } else { + [self removeTimer]; + } + [self updateBadge]; +} + +- (void)setValue:(int)v +{ + value = v; + [self updateBadge]; +} + +- (void)updateBadge +{ + [[NSApp dockTile] display]; +} + +- (void)drawRect:(NSRect)rect +{ + Q_UNUSED(rect) + NSRect boundary = [self bounds]; + [[NSApp applicationIconImage] drawInRect:boundary + fromRect:NSZeroRect + operation:NSCompositeCopy + fraction:1.0]; + NSRect progressBoundary = boundary; + progressBoundary.size.height *= 0.1; + progressBoundary.size.width *= 0.8; + progressBoundary.origin.x = (NSWidth(boundary) - NSWidth(progressBoundary)) / 2.0; + progressBoundary.origin.y = NSHeight(boundary) * 0.1; + + double percent = 0.50; + if (min != max) { + double range = max - min; + percent = (value - min) / range; + if (percent > 1) { + percent = 1; + } else if (percent < 0) { + percent = 0; + } + } else { + // poor man's indefinite busy progressbar obtained by swapping + // fg and bg colours with the bar at the 50% point. + std::swap(fgColour, bgColour); + } + + NSRect currentProgress = progressBoundary; + currentProgress.size.width *= percent; + [bgColour setFill]; + [NSBezierPath fillRect:progressBoundary]; + [fgColour setFill]; + [NSBezierPath fillRect:currentProgress]; + [bgColour setStroke]; + [NSBezierPath strokeRect:progressBoundary]; +} + +@end + +void MacDockProgressView::setRange(int min, int max) +{ + [[MacDockProgressViewPrivate sharedProgressView] rangeStartsAt:min endsAt:max]; +} + +void MacDockProgressView::setProgress(int value) +{ + [[MacDockProgressViewPrivate sharedProgressView] setValue:value]; +} + +void MacDockProgressView::setProgressVisible(bool visible) +{ + if (visible) { + [[NSApp dockTile] setContentView:[MacDockProgressViewPrivate sharedProgressView]]; + } else { + [[NSApp dockTile] setContentView:nil]; + } + [[NSApp dockTile] display]; +} + +#else + +void MacDockProgressView::setRange(int min, int max) +{ + Q_UNUSED(min) + Q_UNUSED(max) +} + +void MacDockProgressView::setProgress(int value) +{ + Q_UNUSED(value) +} + +void MacDockProgressView::setProgressVisible(bool visible) +{ + Q_UNUSED(visible) +} + +#endif diff --git a/shell/progresswidget/statusbarprogresswidget.cpp b/shell/progresswidget/statusbarprogresswidget.cpp index 1a32ea892b..e6321f9e7f 100644 --- a/shell/progresswidget/statusbarprogresswidget.cpp +++ b/shell/progresswidget/statusbarprogresswidget.cpp @@ -1,265 +1,285 @@ /* statusbarprogresswidget.cpp (C) 2004 Till Adam Don Sanders David Faure Copyright 2004 David Faure Includes StatusbarProgressWidget which is based on KIOLittleProgressDlg by Matt Koss KMail is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 or above, as published by the Free Software Foundation. KMail is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA In addition, as a special exception, the copyright holders give permission to link the code of this program with any edition of the Qt library by Trolltech AS, Norway (or with modified versions of Qt that use the same license as Qt), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than Qt. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include "statusbarprogresswidget.h" #include "progressdialog.h" #include "progressmanager.h" +#ifdef Q_OS_OSX +#include "../macdockprogressview.h" +#endif #include #include #include #include #include #include #include #include #include #include using namespace KDevelop; //----------------------------------------------------------------------------- StatusbarProgressWidget::StatusbarProgressWidget( ProgressDialog* progressDialog, QWidget* parent, bool button ) : QFrame( parent ), mCurrentItem( 0 ), mProgressDialog( progressDialog ), mDelayTimer( 0 ), mCleanTimer( 0 ) { m_bShowButton = button; int w = fontMetrics().width( QStringLiteral(" 999.9 kB/s 00:00:01 ") ) + 8; box = new QHBoxLayout( this ); box->setMargin(0); box->setSpacing(0); m_pButton = new QPushButton( this ); m_pButton->setAttribute(Qt::WA_MacMiniSize); m_pButton->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); QIcon smallIcon = QIcon::fromTheme( QStringLiteral("go-up") ); m_pButton->setIcon( smallIcon ); box->addWidget( m_pButton ); stack = new QStackedWidget( this ); int maximumHeight = fontMetrics().height(); stack->setMaximumHeight( maximumHeight ); box->addWidget( stack ); m_pButton->setToolTip( i18n("Open detailed progress dialog") ); m_pProgressBar = new QProgressBar( this ); m_pProgressBar->installEventFilter( this ); m_pProgressBar->setMinimumWidth( w ); stack->insertWidget( 1,m_pProgressBar ); m_pLabel = new QLabel( QString(), this ); m_pLabel->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); m_pLabel->installEventFilter( this ); m_pLabel->setMinimumWidth( w ); stack->insertWidget( 2, m_pLabel ); #ifndef Q_OS_MAC // Currently on OSX this causes the button to be cut-off // It isn't necessary because on OSX the button's minimumSizeHint is small enough m_pButton->setMaximumHeight( maximumHeight ); #endif setMinimumWidth( minimumSizeHint().width() ); mode = None; setMode(); connect( m_pButton, &QPushButton::clicked, progressDialog, &ProgressDialog::slotToggleVisibility ); connect ( ProgressManager::instance(), &ProgressManager::progressItemAdded, this, &StatusbarProgressWidget::slotProgressItemAdded ); connect ( ProgressManager::instance(), &ProgressManager::progressItemCompleted, this, &StatusbarProgressWidget::slotProgressItemCompleted ); connect ( ProgressManager::instance(), &ProgressManager::progressItemUsesBusyIndicator, this, &StatusbarProgressWidget::updateBusyMode ); connect ( progressDialog, &ProgressDialog::visibilityChanged, this, &StatusbarProgressWidget::slotProgressDialogVisible ); mDelayTimer = new QTimer( this ); mDelayTimer->setSingleShot( true ); connect ( mDelayTimer, &QTimer::timeout, this, &StatusbarProgressWidget::slotShowItemDelayed ); mCleanTimer = new QTimer( this ); mCleanTimer->setSingleShot( true ); connect ( mCleanTimer, &QTimer::timeout, this, &StatusbarProgressWidget::slotClean ); } // There are three cases: no progressitem, one progressitem (connect to it directly), // or many progressitems (display busy indicator). Let's call them 0,1,N. // In slot..Added we can only end up in 1 or N. // In slot..Removed we can end up in 0, 1, or we can stay in N if we were already. void StatusbarProgressWidget::updateBusyMode() { connectSingleItem(); // if going to 1 item mDelayTimer->start( 1000 ); } void StatusbarProgressWidget::slotProgressItemAdded( ProgressItem *item ) { if ( item->parent() ) return; // we are only interested in top level items updateBusyMode(); } void StatusbarProgressWidget::slotProgressItemCompleted( ProgressItem *item ) { if ( item->parent() ) { item->deleteLater(); item = 0; return; // we are only interested in top level items } item->deleteLater(); item = 0; connectSingleItem(); // if going back to 1 item if ( ProgressManager::instance()->isEmpty() ) { // No item // Done. In 5s the progress-widget will close, then we can clean up the statusbar mCleanTimer->start( 5000 ); } else if ( mCurrentItem ) { // Exactly one item activateSingleItemMode(); } } void StatusbarProgressWidget::connectSingleItem() { if ( mCurrentItem ) { disconnect ( mCurrentItem, &ProgressItem::progressItemProgress, this, &StatusbarProgressWidget::slotProgressItemProgress ); mCurrentItem = 0; } mCurrentItem = ProgressManager::instance()->singleItem(); if ( mCurrentItem ) { connect ( mCurrentItem, &ProgressItem::progressItemProgress, this, &StatusbarProgressWidget::slotProgressItemProgress ); } } void StatusbarProgressWidget::activateSingleItemMode() { m_pProgressBar->setMaximum( 100 ); m_pProgressBar->setValue( mCurrentItem->progress() ); m_pProgressBar->setTextVisible( true ); +#ifdef Q_OS_OSX + MacDockProgressView::setRange( 0, 100 ); + MacDockProgressView::setProgress( mCurrentItem->progress() ); +#endif } void StatusbarProgressWidget::slotShowItemDelayed() { bool noItems = ProgressManager::instance()->isEmpty(); if ( mCurrentItem ) { activateSingleItemMode(); } else if ( !noItems ) { // N items m_pProgressBar->setMaximum( 0 ); m_pProgressBar->setTextVisible( false ); +#ifdef Q_OS_OSX + MacDockProgressView::setRange( 0, 0 ); + MacDockProgressView::setProgress( 0 ); +#endif } if ( !noItems && mode == None ) { mode = Progress; setMode(); } } void StatusbarProgressWidget::slotProgressItemProgress( ProgressItem *item, unsigned int value ) { Q_ASSERT( item == mCurrentItem); // the only one we should be connected to Q_UNUSED( item ); m_pProgressBar->setValue( value ); +#ifdef Q_OS_OSX + MacDockProgressView::setProgress( value ); +#endif } void StatusbarProgressWidget::setMode() { switch ( mode ) { case None: if ( m_bShowButton ) { m_pButton->hide(); } // show the empty label in order to make the status bar look better stack->show(); stack->setCurrentWidget( m_pLabel ); +#ifdef Q_OS_OSX + MacDockProgressView::setProgressVisible( false ); +#endif break; case Progress: stack->show(); stack->setCurrentWidget( m_pProgressBar ); if ( m_bShowButton ) { m_pButton->show(); } +#ifdef Q_OS_OSX + MacDockProgressView::setProgressVisible( true ); +#endif break; } } void StatusbarProgressWidget::slotClean() { // check if a new item showed up since we started the timer. If not, clear if ( ProgressManager::instance()->isEmpty() ) { m_pProgressBar->setValue( 0 ); //m_pLabel->clear(); mode = None; setMode(); } } bool StatusbarProgressWidget::eventFilter( QObject *, QEvent *ev ) { if ( ev->type() == QEvent::MouseButtonPress ) { QMouseEvent *e = (QMouseEvent*)ev; if ( e->button() == Qt::LeftButton && mode != None ) { // toggle view on left mouse button // Consensus seems to be that we should show/hide the fancy dialog when the user // clicks anywhere in the small one. mProgressDialog->slotToggleVisibility(); return true; } } return false; } void StatusbarProgressWidget::slotProgressDialogVisible( bool b ) { // Update the hide/show button when the detailed one is shown/hidden if ( b ) { m_pButton->setIcon( QIcon::fromTheme( QStringLiteral("go-down") ) ); m_pButton->setToolTip( i18n("Hide detailed progress window") ); setMode(); } else { m_pButton->setIcon( QIcon::fromTheme( QStringLiteral("go-up") ) ); m_pButton->setToolTip( i18n("Show detailed progress window") ); } }