Changeset 6482c61


Ignore:
Timestamp:
12/08/14 12:23:08 (7 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, enter/10, releng/10.1.1, releng/10.1.2
Children:
0b94f953
Parents:
7ff7807
Message:

(ken) Convert pc-mounttray to Qt5

Location:
src-qt5/pc-mounttray
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src-qt5/pc-mounttray/devCheck.cpp

    r3667cdb r6482c61  
    5454 
    5555bool DevCheck::isValid(QString node){ 
    56   bool ok = FALSE; 
     56  bool ok = false; 
    5757  if(activeDevs.contains(node)){ return false; } //currently active node - skip it 
    5858  for(int i=0; i<validDevs.length(); i++){ 
    5959    if(node.startsWith(validDevs[i]) && node!="mdctl"){  
    60         ok = TRUE;  
     60        ok = true;  
    6161        break;  
    6262    } 
     
    128128  else{ node = dev; fullDev = DEVICEDIR + dev; } 
    129129  //Do not allow sym-links 
    130   if(!QFile::symLinkTarget(fullDev).isEmpty()){ return FALSE; } 
     130  if(!QFile::symLinkTarget(fullDev).isEmpty()){ return false; } 
    131131  //Do not allow currently active devices 
    132   if(activeDevs.contains(node)){ return FALSE; } 
     132  if(activeDevs.contains(node)){ return false; } 
    133133  //Double check for valid device types (just in case) 
    134134  QString detType; 
     
    141141  //Make sure it is a no-child device (except memory disks or CD's, those need to be the parent) 
    142142  int children = devChildren(node).length(); 
    143   if( !node.startsWith("md") && detType!="CD9660" && detType!="ISO" && children>0 ){ return FALSE; } 
     143  if( !node.startsWith("md") && detType!="CD9660" && detType!="ISO" && children>0 ){ return false; } 
    144144  //Make sure we quit before running commands on any invalid device nodes 
    145   if(detType.isEmpty() || !QFile::exists(fullDev) ){return FALSE;} 
     145  if(detType.isEmpty() || !QFile::exists(fullDev) ){return false;} 
    146146  //Get the camctl info and refine the device type if possible 
    147147  QString camctl; 
     
    181181  if(!valid){ //don't bother continuing - already invalid 
    182182    if(DEBUG_MODE){ qDebug() << "Invalid Device:" << node << detType << dlabel << fs; }  
    183     return FALSE;  
     183    return false;  
    184184  }  
    185185  
  • src-qt5/pc-mounttray/fsWatcher.cpp

    r3667cdb r6482c61  
    44  //setup the timer 
    55  timer = new QTimer(); 
    6   timer->setSingleShot(TRUE); 
     6  timer->setSingleShot(true); 
    77  QObject::connect(timer, SIGNAL(timeout()), this, SLOT(checkFS())); 
    88} 
     
    129129  if(!badDevs.isEmpty()){ 
    130130    //check to make sure these are new "bad" devices 
    131     bool newFound = FALSE; 
     131    bool newFound = false; 
    132132    for(int i=0; i<badDevs.length(); i++){ 
    133       if( oldBadDevs.indexOf(badDevs[i]) == -1){ newFound = TRUE; }          
     133      if( oldBadDevs.indexOf(badDevs[i]) == -1){ newFound = true; }          
    134134    } 
    135135    if(newFound){ 
  • src-qt5/pc-mounttray/main.cpp

    r3667cdb r6482c61  
    1010#include <QtGui> 
    1111#include <QProcessEnvironment> 
    12 #include <qtsingleapplication.h> 
     12#include <pcbsd-SingleApplication.h> 
    1313 
    1414#include "mountTray.h" 
     
    3434   //Check for "-v" flag for debugging 
    3535   QString flag = QString(argv[1]); 
    36    if( flag == "-v" || flag == "-debug" ){ DEBUG_MODE=TRUE; } 
    37    else{ DEBUG_MODE=FALSE; } 
     36   if( flag == "-v" || flag == "-debug" ){ DEBUG_MODE=true; } 
     37   else{ DEBUG_MODE=false; } 
    3838    
    3939   //Now start the application 
     
    5050     } 
    5151   } 
    52    QtSingleApplication a(argc, argv); 
    53    if ( a.isRunning() ) 
    54      return !(a.sendMessage("show")); 
     52   PCSingleApplication a(argc, argv); 
     53   if ( !a.isPrimaryProcess() ){ return 0; } 
    5554 
    5655   QTranslator translator; 
     
    6665 
    6766   // Init our program 
    68    QObject::connect(&a, SIGNAL(messageReceived(const QString&)), &tray, SLOT(slotSingleInstance()) ); 
     67   QObject::connect(&a, SIGNAL(InputsAvailable(QStringList)), &tray, SLOT(slotSingleInstance()) ); 
    6968   QObject::connect(&a, SIGNAL(aboutToQuit()),&tray,SLOT(closeTray())); 
    7069   tray.programInit(); 
  • src-qt5/pc-mounttray/menuItem.cpp

    r3667cdb r6482c61  
    7575    if(filesystem == "AVDISK" || (filesystem=="UDF" && devType=="CD9660") ){ 
    7676      //non-mountable audio/video disk (cd/dvd usually) 
    77       devIcon->setEnabled(TRUE);  //Make the icon full color 
     77      devIcon->setEnabled(true);  //Make the icon full color 
    7878      devIcon->setToolTip(device+"\n"+tr("Audio/Video Disk")); 
    7979      pushMount->setText(tr("Play")); 
    8080      pushMount->setIcon(QIcon(":icons/play.png")); 
    81       checkAutomount->setVisible(FALSE); 
     81      checkAutomount->setVisible(false); 
    8282    }else if( isMounted() ){ 
    8383      if(mountpoint.isEmpty()){ 
     
    8686        mountpoint = output.section(" on ",1,1).section(" (",0,0).replace(" ","-"); 
    8787      } 
    88       devIcon->setEnabled(TRUE);  //Make the icon full color 
     88      devIcon->setEnabled(true);  //Make the icon full color 
    8989      devIcon->setToolTip(device+"\n"+QString(tr("Mounted at %1")).arg(mountpoint)); 
    9090      pushMount->setText(tr("Eject")); 
    9191      pushMount->setIcon(QIcon(":icons/eject.png")); 
    92       if(devType != "ISO"){ checkAutomount->setVisible(TRUE); } 
    93       else{ checkAutomount->setVisible(FALSE); } 
     92      if(devType != "ISO"){ checkAutomount->setVisible(true); } 
     93      else{ checkAutomount->setVisible(false); } 
    9494    }else{         
    95       devIcon->setEnabled(FALSE); //Grey out the icon if not mounted 
     95      devIcon->setEnabled(false); //Grey out the icon if not mounted 
    9696      devIcon->setToolTip(device); 
    9797      pushMount->setText(tr("Mount")); 
    9898      pushMount->setIcon(QIcon(":icons/mount.png")); 
    99       checkAutomount->setVisible(FALSE); 
     99      checkAutomount->setVisible(false); 
    100100    } 
    101101  }else{ 
     
    114114//Device information 
    115115bool MenuItem::isConnected(){ 
    116   if( QFile::exists(device) ){ return TRUE; } 
    117   else{ return FALSE; } 
     116  if( QFile::exists(device) ){ return true; } 
     117  else{ return false; } 
    118118} 
    119119 
     
    253253    QString search = devLabel->text() +" "+ devType +" "+ filesystem; 
    254254    QString chk = pcbsd::Utils::runShellCommandSearch(cmd, search); 
    255     if( chk.isEmpty() ){ return FALSE; } 
    256     else{ return TRUE; } 
    257   }else{ 
    258     return FALSE; 
     255    if( chk.isEmpty() ){ return false; } 
     256    else{ return true; } 
     257  }else{ 
     258    return false; 
    259259  } 
    260260} 
     
    395395void MenuItem::updateSizes(){ 
    396396  //this method only works if the device is currently mounted 
    397   bool ok = FALSE; 
     397  bool ok = false; 
    398398  if(isMounted()){ 
    399399    QString cmd = "df \""+mountpoint+"\""; 
     
    405405      maxSize = line.section(" ",1,1,QString::SectionSkipEmpty).simplified(); 
    406406      currentSize = line.section(" ",2,2,QString::SectionSkipEmpty).simplified(); 
    407       ok=TRUE; 
     407      ok=true; 
    408408    }else{ 
    409409      maxSize.clear(); 
     
    418418    currentSpace->setMaximum( maxSize.toInt() ); 
    419419    currentSpace->setValue( currentSize.toInt() ); 
    420     currentSpace->setVisible(TRUE); 
     420    currentSpace->setVisible(true); 
    421421    //display the actual size available in the tooltip 
    422422    QString diskAvailable = getSizeDisplay( maxSize.toInt() - currentSize.toInt() ); 
     
    426426    currentSpace->setToolTip( QString( tr("%1 of disk space available") ).arg(diskAvailable) ); 
    427427  }else{ 
    428     currentSpace->setVisible(FALSE); 
     428    currentSpace->setVisible(false); 
    429429  } 
    430430         
  • src-qt5/pc-mounttray/mountTray.cpp

    r3667cdb r6482c61  
    5757  qDebug() << "-Starting up the DEVD watcher"; 
    5858  devdTimer = new QTimer(); 
    59   devdTimer->setSingleShot(TRUE); 
     59  devdTimer->setSingleShot(true); 
    6060  connect(devdTimer,SIGNAL(timeout()),this,SLOT(slotDevChanges())); 
    6161  startupDevdProc(); 
     
    114114 
    115115void MountTray::scanInitialDevices(){ 
    116   slotDevChanges(FALSE); 
     116  slotDevChanges(false); 
    117117  return; 
    118118} 
     
    400400  QString filename = QDir::homePath()+"/.mounttray.settings"; 
    401401  //Set the defaults 
    402   useDiskWatcher=TRUE; useDiskTimerDevd=TRUE; 
     402  useDiskWatcher=true; useDiskTimerDevd=true; 
    403403  diskTimerMaxMS=3600000; //1 hour refresh timer 
    404404  //Now load the file 
     
    416416        QString val = line.section(")",1,30,QString::SectionSkipEmpty).simplified(); 
    417417        if(var=="UseDiskSpaceMonitoring"){  
    418           if(val.toLower() == "true"){ useDiskWatcher = TRUE;} 
    419           else{ useDiskWatcher = FALSE; } 
     418          if(val.toLower() == "true"){ useDiskWatcher = true;} 
     419          else{ useDiskWatcher = false; } 
    420420        }else if(var=="UseDiskSpaceDevdTiming"){ 
    421           if(val.toLower() == "true"){ useDiskTimerDevd = TRUE;} 
    422           else{ useDiskTimerDevd = FALSE; }      
     421          if(val.toLower() == "true"){ useDiskTimerDevd = true;} 
     422          else{ useDiskTimerDevd = false; }      
    423423        }else if(var=="DiskSpaceTimingMaxMilliseconds"){ 
    424424          diskTimerMaxMS = val.toInt();  
  • src-qt5/pc-mounttray/mountTray.h

    r3667cdb r6482c61  
    5050  void slotDoneWithInit(); 
    5151  void newDevdMessage(); 
    52   void slotDevChanges(bool showPopup = TRUE); 
     52  void slotDevChanges(bool showPopup = true); 
    5353  void slotTrayActivated(QSystemTrayIcon::ActivationReason); 
    5454  void slotOpenMediaDir(); 
  • src-qt5/pc-mounttray/pc-mounttray.pro

    r3667cdb r6482c61  
    11TEMPLATE        = app 
    22LANGUAGE        = C++ 
    3 QT      += core gui network 
     3QT      += core gui widgets network 
    44 
    55CONFIG  += qt warn_on release 
    66 
    7 LIBS    += -L../libpcbsd -lQtSolutions_SingleApplication-head -lpcbsd-utils 
     7LIBS    += -L../libpcbsd -L/usr/local/lib -lpcbsd-ui -lpcbsd-utils 
    88 
    99HEADERS += mountTray.h \ 
     
    2424RESOURCES += pc-mounttray.qrc 
    2525 
    26 INCLUDEPATH += ../libpcbsd/utils /usr/local/include 
     26INCLUDEPATH += ../libpcbsd/utils ../libpcbsd/ui /usr/local/include 
    2727 
    28 QMAKE_LIBDIR = /usr/local/lib/qt4 /usr/local/lib 
     28QMAKE_LIBDIR = /usr/local/lib/qt5 
    2929 
    3030TRANSLATIONS =  i18n/MountTray_af.ts \ 
     
    9797 
    9898dotrans.path=/usr/local/share/pcbsd/i18n/ 
    99 dotrans.extra=cd i18n && lrelease-qt4 -nounfinished *.ts && cp *.qm $(INSTALL_ROOT)/usr/local/share/pcbsd/i18n/ 
     99dotrans.extra=cd i18n && /usr/local/lib/qt5/bin/lrelease -nounfinished *.ts && cp *.qm $(INSTALL_ROOT)/usr/local/share/pcbsd/i18n/ 
    100100 
    101101INSTALLS += target dotrans 
  • src-qt5/pc-mounttray/settingsDialog.cpp

    r3667cdb r6482c61  
    1010    QFormLayout *flayout = new QFormLayout; 
    1111    groupDiskWatch = new QGroupBox(tr("Monitor disk storage space")); 
    12       groupDiskWatch->setCheckable(TRUE); 
    13       groupDiskWatch->setFlat(FALSE); //make sure the frame is drawn 
     12      groupDiskWatch->setCheckable(true); 
     13      groupDiskWatch->setFlat(false); //make sure the frame is drawn 
    1414    checkDiskAutoTimer = new QCheckBox(tr("Perform check on device notifications")); 
    1515    QLabel *spinLabel = new QLabel(tr("Maximum time between checks (minutes)")); 
     
    2626    closeButton = new QPushButton(QIcon(":icons/application-exit.png"),tr("Cancel")); 
    2727    applyButton = new QPushButton(QIcon(":icons/checkmark.png"),tr("Apply")); 
    28       applyButton->setEnabled(FALSE); 
     28      applyButton->setEnabled(false); 
    2929    hb->addWidget(applyButton); 
    3030    hb->addWidget(closeButton); 
     
    6262  diskRefreshMS = spinDiskRefreshMin->value() * 60000; 
    6363  //Flag that there are saved values and quit 
    64   SettingsChanged=TRUE; 
     64  SettingsChanged=true; 
    6565  this->close(); 
    6666} 
    6767 
    6868void SettingsDialog::slotCloseDialog(){ 
    69   SettingsChanged=FALSE; 
     69  SettingsChanged=false; 
    7070  this->close(); 
    7171} 
    7272 
    7373void SettingsDialog::slotUpdateUI(){ 
    74   applyButton->setEnabled(TRUE); 
     74  applyButton->setEnabled(true); 
    7575  //Could do check for visible/invisible options here as well 
    7676} 
Note: See TracChangeset for help on using the changeset viewer.