Changeset be298e4


Ignore:
Timestamp:
04/17/13 06:27:47 (15 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.1-release, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
7639577, 89c5083
Parents:
81d9e3d
Message:

Clean up the new mount-tray disk place dialog, it now looks nice and highlights the devices that are almost full.

Location:
src-qt4/pc-mounttray
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-mounttray/fsDialog.cpp

    rbb6089a rbe298e4  
    1111  //Auto-generate the UI 
    1212  QVBoxLayout *vlayout = new QVBoxLayout(); 
    13   //Filesystem display widgets 
    14   QScrollArea *scroll = new QScrollArea(this); 
    15   QVBoxLayout *sclLayout = new QVBoxLayout(); 
    16   QWidget *wgt = new QWidget(); 
     13  //Filesystem display widget 
     14  QTreeWidget *tree = new QTreeWidget(this); 
     15    tree->setIndentation(0); 
     16    //tree->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred ); 
     17    //setup the column headers 
     18    tree->setColumnCount(4); 
     19    QStringList header; 
     20    header << tr("Mount Point") << tr("Filesystem") << tr("Used/Total") << tr("Percent %"); 
     21    tree->setHeaderLabels(header); 
     22     
    1723    //Auto fill the scroll area 
    1824    QStringList fsList = FSWatcher::getFSmountpoints(); 
     
    2531      int usedK = fsList[i].section("::",3,3).toInt(); 
    2632      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) ); 
     33      //Create item for the data 
     34      QStringList text; //column text 
     35      text << name << filesystem.toUpper() << FSWatcher::intToDisplay(usedK)+"/"+FSWatcher::intToDisplay(totalK) << QString::number(percent)+"%"; 
     36      QTreeWidgetItem *tmp = new QTreeWidgetItem(text); 
    3937       
    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); 
     38      //set the item background based upon urgency 
     39      if(percent < 75){} //do nothing 
     40      else if(percent < 90){ // yellow 
     41        QBrush color(QColor(237,233,12)); 
     42        tmp->setBackground(0,color); tmp->setBackground(1,color); 
     43        tmp->setBackground(2,color); tmp->setBackground(3,color); 
     44      } 
     45      else{  //red 
     46        QBrush color(QColor(237,12,53)); 
     47        tmp->setBackground(0,color); tmp->setBackground(1,color); 
     48        tmp->setBackground(2,color); tmp->setBackground(3,color); 
     49      }    
     50      //Now add the item to the widget 
     51      tree->addTopLevelItem(tmp); 
    4852    } 
    49     wgt->setLayout(sclLayout); 
    50     scroll->setWidget(wgt); 
    51   vlayout->addWidget(scroll); 
     53     
     54  vlayout->addWidget(tree); 
     55  //Make sure the widget is the smallest size possible 
     56  tree->resizeColumnToContents(0); tree->resizeColumnToContents(1); 
     57  tree->resizeColumnToContents(2); tree->resizeColumnToContents(3); 
    5258  //Now add the close button to the bottom 
     59  QHBoxLayout *hb = new QHBoxLayout(); 
     60  hb->addStretch(); 
    5361  QPushButton *closeButton = new QPushButton("Close"); 
    54   vlayout->addWidget(closeButton); 
     62  hb->addWidget(closeButton); 
     63  hb->addStretch(); 
     64  vlayout->addLayout(hb); 
    5565  connect(closeButton,SIGNAL(clicked()),this,SLOT(closeDialog())); 
    5666  //Now set the layout for the dialog 
    5767  this->setLayout(vlayout); 
     68  //Now resize the dialog to fit the widget appropriately 
     69  this->adjustSize(); 
    5870} 
    5971 
  • src-qt4/pc-mounttray/fsDialog.h

    rbb6089a rbe298e4  
    88#include <QHBoxLayout> 
    99#include <QPushButton> 
    10 #include <QScrollArea> 
    11 #include <QLabel> 
    12 #include <QProgressBar> 
    13 #include <QWidget> 
     10#include <QTreeWidget> 
     11#include <QTreeWidgetItem> 
     12#include <QBrush> 
     13#include <QColor> 
    1414 
    1515#include "fsWatcher.h" 
Note: See TracChangeset for help on using the changeset viewer.