InstallScreen::InstallScreen()
{
    m_mainLayout = new QVBoxLayout;
    m_mainLayout->setSpacing( 0 );
    m_currentPackage = 0;
        
    // log file
    m_logFile.setFileName( "/tmp/oci_log.txt" );
    if( !m_logFile.open( QIODevice::Truncate | QIODevice::WriteOnly ) ) {
        qDebug() << "Could not open Data File";
    }
    m_outData = new QTextStream( &m_logFile );
    
    // status widget and its layout
    m_statusWidget = new QTextBrowser;
    m_statusWidget->setObjectName( "statusWidget" );
    m_statusWidget->setStyleSheet( "QTextBrowser#statusWidget{ background-color : white; border-bottom: 1px solid rgb(196, 181, 147); border-left : 1px solid rgb(196,181,147); border-top : 1px solid rgb(196,181,147); border-right : 1px solid rgb(196,181,147); }" );
    m_statusWidget->setMinimumSize( 500, 180 );
       
    // Cancel button
    m_cancelButton = new QPushButton( i18n( "Cancel" ) );
    QHBoxLayout *buttonLayout = new QHBoxLayout();
    buttonLayout->addSpacing( 400 );
    buttonLayout->addWidget( m_cancelButton );
    
    // Current message label, Progress Bar
    m_currentPackageStatusLabel = new QLabel( i18n( "Please Wait..." ) );
    m_progressBar = new QProgressBar;
    m_progressBar->setMinimum( 0 );
    m_progressBar->setMaximum( 100 );
    m_progressBar->setRange( 0, 100 );
    m_progressBar->setTextVisible( true );
    
    // total progress message label, Total Progress Bar
    m_totProgBarStatusLabel = new QLabel( i18n( "Total Progress:" ) );
    m_totalProgressBar = new QProgressBar;
    m_totalProgressBar->setMinimum( 0 );
    m_totalProgressBar->setRange( 0, 100 );
    m_totalProgressBar->setTextVisible( true );
    
    // All set! Now add widgets to the m_mainLayout
    m_mainLayout->addWidget( m_statusWidget );
    m_mainLayout->addWidget( horizontalLine() );
    m_mainLayout->addWidget( m_currentPackageStatusLabel );
    m_mainLayout->addWidget( m_progressBar );
    m_mainLayout->addWidget( m_totProgBarStatusLabel );
    m_mainLayout->addWidget( m_totalProgressBar );
    m_mainLayout->addWidget( horizontalLine() );
    m_mainLayout->addLayout( buttonLayout );
    
    // Signals and slots
    QObject::connect( m_cancelButton, SIGNAL( clicked() ), this, SLOT( cancelInstallation() ) );
    
    setLayout( m_mainLayout );
}
예제 #2
0
void PluginDialog::on_button_downloadFromURL_clicked()
{
    bool ok;
    QString URL = QInputDialog::getText(this, tr("Download from URL"), tr("URL to zip file:"), QLineEdit::Normal, "", &ok);
    if(ok && !URL.isEmpty())
    {
        QProgressDialog progressDialog(tr("Installing plugin from URL..."), tr("Cancel"), 0, 4, this);
        progressDialog.setWindowModality(Qt::WindowModal);
        progressDialog.setAutoReset(true);
        progressDialog.setAutoClose(true);
        connect(pluginManager, SIGNAL(installationProgress(int)), &progressDialog, SLOT(setValue(int)));
        connect(pluginManager, SIGNAL(installationError(QString)), &progressDialog, SLOT(close()));
        connect(pluginManager, SIGNAL(installationError(QString)), this, SLOT(pluginInstallError(QString)));
        connect(&progressDialog, SIGNAL(canceled()), this, SLOT(cancelInstallation()));
        progressDialog.show();
        QStringList toInstall;
        toInstall << URL;
        pluginManager->installPlugins(toInstall);
        while(progressDialog.isVisible())
        {
            qApp->processEvents(QEventLoop::WaitForMoreEvents);
        }
    }