X-Git-Url: http://git.maemo.org/git/?p=fapman;a=blobdiff_plain;f=mainwindow.cpp;h=6ad7f064c9f79842d5886d846e10c953e34bf4c1;hp=02b325bf7a5b6920401c3d974212145f3887d407;hb=172a6626f6f1cd6445fc575e2d614a1821596900;hpb=ce11375f70d5fcfe5e7a8b3c58dd4ce2d99e983b diff --git a/mainwindow.cpp b/mainwindow.cpp index 02b325b..6ad7f06 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -33,6 +33,8 @@ #include #endif +#include + #include "mainwindow.h" #include "version.h" #include "ui_mainwindow.h" @@ -88,8 +90,11 @@ MainWindow::MainWindow(QWidget *parent) : iUpgradeAutoUpdate = true; iNextOperation = OpNone; + connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(orientationChanged())); + ui->centralWidget->loadWallpaper(); + /* QString stylesheet_mainscreen = "QPushButton {" "border-radius: 16px;" @@ -105,6 +110,7 @@ MainWindow::MainWindow(QWidget *parent) : "border-style: inset;" "background-color: rgba(255,255,255,150);" "}"; + */ if( ((QApplication*)QApplication::instance())->styleSheet().isEmpty() ) { @@ -119,7 +125,7 @@ MainWindow::MainWindow(QWidget *parent) : } if( stylesheet_file.isEmpty() ) { - ui->centralWidget->setStyleSheet(stylesheet_mainscreen); + //ui->centralWidget->setStyleSheet(stylesheet_mainscreen); } else { ((QApplication*)QApplication::instance())->setStyleSheet(stylesheet_file); } @@ -142,6 +148,8 @@ MainWindow::MainWindow(QWidget *parent) : iMediaObject = new Phonon::MediaObject(this); Phonon::AudioOutput* aout = new Phonon::AudioOutput(Phonon::NotificationCategory, this); Phonon::createPath(iMediaObject, aout); + + showFreeSpace(); } MainWindow::~MainWindow() @@ -508,6 +516,7 @@ void MainWindow::operationQueueFinished(QList last #endif } + showFreeSpace(); } } @@ -638,3 +647,76 @@ void MainWindow::on_actionLoad_file_triggered() iAptInterface->loadInstallFiles(installs); } } + +void MainWindow::orientationChanged() +{ + //ui->centralWidget->adjustSize(); + //ui->listWidget->adjustSize(); +} + + +void MainWindow::showFreeSpace() +{ + quint64 warn_limit_root = 5120; + quint64 warn_limit_opt = 51200; + struct statfs root_stat; + struct statfs opt_stat; + statfs("/",&root_stat); + statfs("/opt",&opt_stat); + quint64 free_root = root_stat.f_bavail * root_stat.f_bsize / 1024; + quint64 free_opt = opt_stat.f_bavail * opt_stat.f_bsize / 1024; + quint64 total_root = root_stat.f_blocks * root_stat.f_bsize / 1024; + quint64 total_opt = opt_stat.f_blocks * opt_stat.f_bsize / 1024; + qDebug() << "rootfs" << free_root << "/" << total_root << "kB free"; + qDebug() << "opt fs" << free_opt << "/" << total_opt << "kB free"; + + QString rootstr = QString("rootfs: %L1 / %L2 MB free").arg(free_root/1024).arg(total_root/1024); + QString optstr = QString("opt: %L1 / %L2 MB free").arg(free_opt/1024).arg(total_opt/1024); + + ui->label->setText("" + rootstr + "
" + optstr + "
"); + + /* + ui->progressBarRoot->setFormat(rootstr); + ui->progressBarRoot->setMaximum(total_root/1024); + ui->progressBarRoot->setValue(free_root/1024); + ui->progressBarOpt->setFormat(optstr); + ui->progressBarOpt->setMaximum(total_opt/1024); + ui->progressBarOpt->setValue(free_opt/1024); + */ + + if( free_root < warn_limit_root || free_opt < warn_limit_opt ) + { + ConfirmDialog d(false, this); + QString t; + if( free_root < warn_limit_root ) + t += QString("Root filesystem has %L1 kB available
").arg(free_root); + if( free_opt < warn_limit_opt ) + t += QString("Opt (home) filesystem has %L1 kB available
").arg(free_opt); + t += "
You may proceed, but consider freeing up space to prevent problems in the future"; + d.setText("Warning: Low disk space",t); + d.exec(); + } +} + +void MainWindow::on_listWidget_itemClicked(QListWidgetItem* item) +{ + if( item->text() == "Manage repositories" ) { + on_btnRepos_clicked(); + } + else if( item->text() == "Update catalogs" ) { + on_btnUpdate_clicked(); + } + else if( item->text() == "Install applications" ) { + on_btnListInstallable_clicked(); + } + else if( item->text() == "Remove applications" ) { + on_btnListInstalled_clicked(); + } + else if( item->text() == "Upgrade applications" ) { + on_btnUpgrade_clicked(); + } + else { + qDebug() << "Warning: Unhandled main menu item"; + } + item->setSelected(false); +}