release 0.6.7 (see the debian changelog for a proper list of changes)
[fapman] / mainwindow.cpp
index d63700f..844f065 100644 (file)
@@ -138,27 +138,17 @@ MainWindow::MainWindow(QWidget *parent) :
        }
 
 
-       /*
-       // does not work
-
-       QDBusConnection conn = QDBusConnection::connectToBus(QDBusConnection::SystemBus, "faster_application_manager");
-
-       QString service = "com.nokia.icd";
-       QString path = "/com/nokia/icd";
-       QString method = "connect";
-
-       QDBusInterface net(service, path, service, conn, this);
-       net.call(method,"[ANY]",0);
-       */
-
        iMediaObject = new Phonon::MediaObject(this);
        Phonon::AudioOutput* aout = new Phonon::AudioOutput(Phonon::NotificationCategory, this);
        Phonon::createPath(iMediaObject, aout);
 
        showFreeSpace();
 
+       iNetworkConfigurationManager = new QNetworkConfigurationManager(this);
+       iNetworkSession = new QNetworkSession(iNetworkConfigurationManager->defaultConfiguration(),this);
+
        show();
-       orientationChanged();
+       rescaleMenuView();
 }
 
 MainWindow::~MainWindow()
@@ -166,6 +156,11 @@ MainWindow::~MainWindow()
        // save "need repo refresh" status
        iSettings->qsettings()->setValue("need_repo_refresh", iAptInterface->needRepoRefresh());
 
+       if( iNetworkSession && iNetworkSession->isOpen() ) {
+               iNetworkSession->close();
+       }
+       // iNetworkSession automatically deleted by parent
+
        delete iWinPackageView; iWinPackageView=0;
        delete iWinRepoView; iWinRepoView=0;
        delete iAptInterface; iAptInterface=0;
@@ -176,6 +171,20 @@ MainWindow::~MainWindow()
        //iMediaObject and aout automatically deleted by their parent
 }
 
+void MainWindow::openNetworkConnection()
+{
+       if( iNetworkSession->isOpen() )
+               return;
+
+       iNetworkSession->open();
+       if( !iNetworkSession->waitForOpened(20000) )
+       {
+               ConfirmDialog d(false, this);
+               d.setText("Network error","Unable to open a network connection");
+               d.exec();
+       }
+}
+
 void MainWindow::changeEvent(QEvent *e)
 {
     QMainWindow::changeEvent(e);
@@ -197,6 +206,8 @@ void MainWindow::on_btnUpdate_clicked()
 {      
        // update catalogs
 
+       openNetworkConnection();
+
        busyDialog(true, tr("Operation in progress"), tr("Updating catalogs"));
 
        iAptInterface->addQueuedOperation(AAptInterface::ModeAptGetUpdate);
@@ -243,6 +254,8 @@ void MainWindow::on_btnListInstallable_clicked()
 {
        //install
 
+       openNetworkConnection();
+
        int listupd = -1;
        int dpkgupd = -1;
        if( iAptInterface->lastListUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
@@ -270,6 +283,8 @@ void MainWindow::on_btnUpgrade_clicked()
 {
        // upgrade
 
+       openNetworkConnection();
+
        int listupd = -1;
        int dpkgupd = -1;
        if( iAptInterface->lastListUpdate() < QDateTime::currentDateTime().addSecs(-KListExpireTime) )
@@ -660,6 +675,17 @@ void MainWindow::on_actionLoad_file_triggered()
 
 void MainWindow::resizeEvent(QResizeEvent* event)
 {
+       rescaleMenuView();
+
+       if( iDimmer ) {
+               iDimmer->resize( this->size() );
+       }
+
+       QMainWindow::resizeEvent(event);
+}
+
+void MainWindow::rescaleMenuView()
+{
        QRect sg = ui->listWidget->rect();
 
        if( sg.width() > sg.height() ) {
@@ -667,12 +693,6 @@ void MainWindow::resizeEvent(QResizeEvent* event)
        } else {
                ui->listWidget->setGridSize( QSize((sg.width()-12)/3, (sg.height()-12)/3) );
        }
-
-       if( iDimmer ) {
-               iDimmer->resize( this->size() );
-       }
-
-       QMainWindow::resizeEvent(event);
 }
 
 void MainWindow::orientationChanged()