source: src-qt4/pc-mounttray/fsDialog.cpp @ bb6089a

9.1-release9.2-releasereleng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1
Last change on this file since bb6089a was bb6089a, checked in by beanpole135 <ken@…>, 20 months ago

Add the ability for the mount tray to monitor/warn the user about disks that are almost full. Also add a new dialog that will show the current disk usage for the entire system. Still need to clean up the menu a bit, and add the ability to change settings for this.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#include "fsDialog.h"
2
3FSDialog::FSDialog() : QDialog(){
4  generateUI();
5}
6
7FSDialog::~FSDialog(){
8}
9
10void FSDialog::generateUI(){
11  //Auto-generate the UI
12  QVBoxLayout *vlayout = new QVBoxLayout();
13  //Filesystem display widgets
14  QScrollArea *scroll = new QScrollArea(this);
15  QVBoxLayout *sclLayout = new QVBoxLayout();
16  QWidget *wgt = new QWidget();
17    //Auto fill the scroll area
18    QStringList fsList = FSWatcher::getFSmountpoints();
19    //Format: mountpoint::filesystem::totalspace(K)::usedspace(K)::percentUsed
20    for(int i=0; i<fsList.length(); i++){
21      //Get the data for this item
22      QString name = fsList[i].section("::",0,0);
23      QString filesystem = fsList[i].section("::",1,1);
24      int totalK = fsList[i].section("::",2,2).toInt();
25      int usedK = fsList[i].section("::",3,3).toInt();
26      int percent = fsList[i].section("::",4,4).toInt();
27      //qDebug() << "Dialog Item:" << name << filesystem << totalK << usedK << percent;
28      //Set the font/color for the name based upon status
29      if(percent < 75){ name.prepend("<b><FONT COLOR='#00FF00'>"); name.append("</b>"); } //green
30      else if(percent < 90){ name.prepend("<b><FONT COLOR='#FFFF00'>"); name.append("</b>"); } //yellow
31      else{ name.prepend("<b><FONT COLOR='#FF0000'>"); name.append("</b>"); } //red
32      //Create items for the data
33      QLabel *mntpnt = new QLabel(name);
34      QLabel *fstype = new QLabel(filesystem.toUpper());
35      QProgressBar *prgbar = new QProgressBar();
36        prgbar->setMaximum(totalK); prgbar->setMinimum(0);
37        prgbar->setValue(usedK);
38      QLabel *info = new QLabel( FSWatcher::intToDisplay(usedK)+"/"+FSWatcher::intToDisplay(totalK) );
39     
40      //Now add the items to a layout
41      QHBoxLayout *tmp= new QHBoxLayout();
42      tmp->addWidget(mntpnt);
43      tmp->addWidget(fstype);
44      tmp->addWidget(prgbar);
45      tmp->addWidget(info);
46      //Add the tmp layout to the main scroll area layout
47      sclLayout->addLayout(tmp);
48    }
49    wgt->setLayout(sclLayout);
50    scroll->setWidget(wgt);
51  vlayout->addWidget(scroll);
52  //Now add the close button to the bottom
53  QPushButton *closeButton = new QPushButton("Close");
54  vlayout->addWidget(closeButton);
55  connect(closeButton,SIGNAL(clicked()),this,SLOT(closeDialog()));
56  //Now set the layout for the dialog
57  this->setLayout(vlayout);
58}
59
60void FSDialog::closeDialog(){
61  this->close();
62}
Note: See TracBrowser for help on using the repository browser.