bool QgsMessageBar::clearWidgets() { if ( !mCurrentItem && mItems.empty() ) return true; while ( mItems.count() > 0 ) { popWidget(); } popWidget(); return !mCurrentItem && mItems.empty(); }
void QgsMessageBar::pushItem( QgsMessageBarItem *item ) { resetCountdown(); // avoid duplicated widget popWidget( item ); showItem( item ); }
void QgsMessageBar::pushItem( QgsMessageBarItem *item ) { resetCountdown(); // avoid duplicated widget popWidget( item ); showItem( item ); // Log all messages that are sent to the message bar into the message log so the // user can get them back easier. QString formattedTitle = QString( "%1 : %2" ).arg( item->title(), item->text() ); QgsMessageLog::MessageLevel level; switch ( item->level() ) { case QgsMessageBar::INFO: level = QgsMessageLog::INFO; break; case QgsMessageBar::WARNING: level = QgsMessageLog::WARNING; break; case QgsMessageBar::CRITICAL: level = QgsMessageLog::CRITICAL; break; default: level = QgsMessageLog::NONE; break; } QgsMessageLog::logMessage( formattedTitle, tr( "Messages" ), level ); }
QgsMessageBar::QgsMessageBar( QWidget *parent ) : QFrame( parent ), mCurrentItem ( NULL ) { QPalette pal = palette(); pal.setBrush( backgroundRole(), pal.window() ); setPalette( pal ); setAutoFillBackground( true ); setFrameShape( QFrame::StyledPanel ); setFrameShadow( QFrame::Plain ); mLayout = new QGridLayout( this ); mLayout->setContentsMargins( 9, 1, 9, 1 ); setLayout( mLayout ); mLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding ), 0, 1, 1, 1 ); mCloseBtn = new QToolButton( this ); mCloseBtn->setToolTip( tr( "Close" ) ); mCloseBtn->setStyleSheet( "background-color: rgba(255, 255, 255, 0);" ); mCloseBtn->setCursor( Qt::PointingHandCursor ); mCloseBtn->setIcon( QgsApplication::getThemeIcon( "/mIconClose.png" ) ); connect( mCloseBtn, SIGNAL( clicked() ), this, SLOT( popWidget() ) ); mLayout->addWidget( mCloseBtn, 0, 2, 1, 1 ); // start hidden setVisible( false ); }
void QgsMessageBar::pushWidget( QWidget *widget, const QString &styleSheet ) { if ( !widget ) return; // avoid duplicated widget popWidget( widget ); pushItem( new QgsMessageBarItem( widget, styleSheet ) ); }
void QgsMessageBar::pushItem( QgsMessageBarItem *item ) { resetCountdown(); // avoid duplicated widget popWidget( item ); showItem( item ); // Log all messages that are sent to the message bar into the message log so the // user can get them back easier. QString formattedTitle = QStringLiteral( "%1 : %2" ).arg( item->title(), item->text() ); QgsMessageLog::logMessage( formattedTitle, tr( "Messages" ), item->level() ); }
void FirmwareUpdate::DownloadOver(bool err) { isFrameTurn = false; //QString outString; if (err){ // popWidget(); // // //outString = tr("The Lastest Firmware's Version was Downloaded."); // //DownloadPage->SetInfo(outString); // QList<int> outInfo; // outInfo.push_back(L_UPGRADE_DOWNLOAD_FINISHED); // DownloadPage->SetInfo(outInfo); // // //WizardLayout->setCurrentIndex(2); // //WizardLayout->setCurrentWidget(DownloadPage); popWidget(); //outString = tr("The Lastest Firmware's Version was Downloaded."); //DownloadPage->SetInfo(outString); QList<int> outInfo; //outInfo.push_back(L_UPGRADE_DOWNLOAD_FINISHED); outInfo.push_back(L_UPGRADE_DOWNLOAD_POPEXPLAIN); DownloadPage->SetInfo(outInfo); QString strPath; strPath = *DownInfo; GeniePlugin_FirmwareUpdate::writeGenieLog("Firmware save Path:" + strPath); CompletePage->SetInfo(strPath); CompletePage->setButtonEnabled(3); WizardLayout->setCurrentIndex(3); //WizardLayout->setCurrentWidget(DownloadPage); }else { //outString = tr("The Firmware Version is worng."); //outString = *DownInfo; //FinishPage->SetInfo(outString); QList<int> outInfo; outInfo.push_back(L_UPGRADE_FINISH_TITLE); outInfo.push_back(L_UPGRADE_FINISH_EXPLAIN); for(int i=0; i<intDownloadErr->size(); i++){ outInfo.push_back(intDownloadErr->value(i)); } FinishPage->SetInfo(outInfo, "NULL"); FinishPage->setButtonEnabled(4); //WizardLayout->setCurrentWidget(FinishPage); WizardLayout->setCurrentIndex(4); } isDownloading = true; }
void QgsMessageBar::updateCountdown() { if ( !mCountdownTimer->isActive() ) { resetCountdown(); return; } if ( mCountProgress->value() < 2 ) { popWidget(); } else { mCountProgress->setValue( mCountProgress->value() - 1 ); } }
QgsMessageBar::QgsMessageBar( QWidget *parent ) : QFrame( parent ), mCurrentItem( NULL ) { QPalette pal = palette(); pal.setBrush( backgroundRole(), pal.window() ); setPalette( pal ); setAutoFillBackground( true ); setFrameShape( QFrame::StyledPanel ); setFrameShadow( QFrame::Plain ); mLayout = new QGridLayout( this ); mLayout->setContentsMargins( 9, 1, 9, 1 ); setLayout( mLayout ); mItemCount = new QLabel( this ); mItemCount->setObjectName( "mItemCount" ); mItemCount->setToolTip( tr( "Remaining messages" ) ); mItemCount->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); mLayout->addWidget( mItemCount, 0, 1, 1, 1 ); mCloseMenu = new QMenu( this ); mCloseMenu->setObjectName( "mCloseMenu" ); mActionCloseAll = new QAction( tr( "Close all" ), this ); mCloseMenu->addAction( mActionCloseAll ); connect( mActionCloseAll, SIGNAL( triggered() ), this, SLOT( clearWidgets() ) ); mCloseBtn = new QToolButton( this ); mCloseBtn->setToolTip( tr( "Close" ) ); mCloseBtn->setMinimumWidth( 36 ); mCloseBtn->setStyleSheet( "QToolButton { background-color: rgba(255, 255, 255, 0); } " "QToolButton::menu-indicator { subcontrol-position: right bottom; subcontrol-origin: padding; bottom: 6px; }" ); mCloseBtn->setCursor( Qt::PointingHandCursor ); mCloseBtn->setIcon( QgsApplication::getThemeIcon( "/mIconClose.png" ) ); mCloseBtn->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); mCloseBtn->setMenu( mCloseMenu ); connect( mCloseBtn, SIGNAL( clicked() ), this, SLOT( popWidget() ) ); mLayout->addWidget( mCloseBtn, 0, 2, 1, 1 ); connect( this, SIGNAL( widgetAdded( QWidget* ) ), this, SLOT( updateItemCount() ) ); connect( this, SIGNAL( widgetRemoved( QWidget* ) ), this, SLOT( updateItemCount() ) ); // start hidden setVisible( false ); }
QgsMessageBar::QgsMessageBar( QWidget *parent ) : QFrame( parent ), mCurrentItem( NULL ) { QPalette pal = palette(); pal.setBrush( backgroundRole(), pal.window() ); setPalette( pal ); setAutoFillBackground( true ); setFrameShape( QFrame::StyledPanel ); setFrameShadow( QFrame::Plain ); mLayout = new QGridLayout( this ); mLayout->setContentsMargins( 9, 1, 9, 1 ); setLayout( mLayout ); mCountProgress = new QProgressBar( this ); mCountStyleSheet = QString( "QProgressBar { border: 1px solid rgba(0, 0, 0, 75%);" " border-radius: 2px; background: rgba(0, 0, 0, 0);" " image: url(:/images/themes/default/%1) }" "QProgressBar::chunk { background-color: rgba(0, 0, 0, 30%); width: 5px; }" ); mCountProgress->setStyleSheet( mCountStyleSheet.arg( "mIconTimerPause.png" ) ); mCountProgress->setObjectName( "mCountdown" ); mCountProgress->setFixedSize( 25, 14 ); mCountProgress->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); mCountProgress->setTextVisible( false ); mCountProgress->setRange( 0, 5 ); mCountProgress->setHidden( true ); mLayout->addWidget( mCountProgress, 0, 0, 1, 1 ); mItemCount = new QLabel( this ); mItemCount->setObjectName( "mItemCount" ); mItemCount->setToolTip( tr( "Remaining messages" ) ); mItemCount->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred ); mLayout->addWidget( mItemCount, 0, 2, 1, 1 ); mCloseMenu = new QMenu( this ); mCloseMenu->setObjectName( "mCloseMenu" ); mActionCloseAll = new QAction( tr( "Close all" ), this ); mCloseMenu->addAction( mActionCloseAll ); connect( mActionCloseAll, SIGNAL( triggered() ), this, SLOT( clearWidgets() ) ); mCloseBtn = new QToolButton( this ); mCloseMenu->setObjectName( "mCloseMenu" ); mCloseBtn->setToolTip( tr( "Close" ) ); mCloseBtn->setMinimumWidth( 40 ); mCloseBtn->setStyleSheet( "QToolButton { background-color: rgba(255, 255, 255, 0); } " "QToolButton::menu-indicator { subcontrol-position: right bottom; subcontrol-origin: padding; bottom: 2px; }" ); mCloseBtn->setCursor( Qt::PointingHandCursor ); mCloseBtn->setIcon( QgsApplication::getThemeIcon( "/mIconClose.png" ) ); mCloseBtn->setIconSize( QSize( 18, 18 ) ); mCloseBtn->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum ); mCloseBtn->setMenu( mCloseMenu ); connect( mCloseBtn, SIGNAL( clicked() ), this, SLOT( popWidget() ) ); mLayout->addWidget( mCloseBtn, 0, 3, 1, 1 ); mCountdownTimer = new QTimer( this ); mCountdownTimer->setInterval( 1000 ); connect( mCountdownTimer, SIGNAL( timeout() ), this, SLOT( updateCountdown() ) ); connect( this, SIGNAL( widgetAdded( QgsMessageBarItem* ) ), this, SLOT( updateItemCount() ) ); connect( this, SIGNAL( widgetRemoved( QgsMessageBarItem* ) ), this, SLOT( updateItemCount() ) ); // start hidden setVisible( false ); }