Changeset cd554b1


Ignore:
Timestamp:
Jul 30, 2013 5:27:46 PM (11 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
7112fa8
Parents:
835dab4e
Message:

Make the GRUB settings editor have the save/refresh buttons dynamically avilable depending on if there are unsaved changes. Also setup the utility so that if there is ever more than one BE, GRUB will automatically be set to visible mode (with same countdown timer length).

Location:
src-qt4/pc-bootconfig
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-bootconfig/mainUI.cpp

    r835dab4e rcd554b1  
    2626  //Update the custom GRUB entries 
    2727  updateGRUBentries(); 
     28  //Setup the Signals/slots for change to GRUB values 
     29  connect(ui->line_GRUBthemefile,SIGNAL(textChanged(QString)),this,SLOT(GRUBchangedefaults()) ); 
     30  connect(ui->line_GRUBfontfile,SIGNAL(textChanged(QString)),this,SLOT(GRUBchangedefaults()) ); 
     31  connect(ui->spin_GRUBtimer,SIGNAL(valueChanged(int)),this,SLOT(GRUBchangedefaults()) ); 
     32  connect(ui->check_GRUBshowcountdown,SIGNAL(stateChanged(int)),this,SLOT(GRUBchangedefaults()) ); 
     33  connect(ui->text_GRUBentries,SIGNAL(textChanged()),this,SLOT(GRUBchangeentries()) ); 
    2834} 
    2935 
     
    7783} 
    7884 
    79  
    8085//Boot Environment Management Functions 
    8186void mainUI::beadmActivate(QString name){  
     87        qDebug() << "Activate BE:" << name; 
    8288        QString cmd = "beadm activate "+name; 
    8389        runLongCMD(cmd); 
     
    8591 
    8692void mainUI::beadmCreate(QString name){  
     93        qDebug() << "Create BE:" << name; 
    8794        QString cmd ="beadm create "+name; 
    8895        runLongCMD(cmd); 
     
    9097 
    9198void mainUI::beadmCopy(QString name, QString newname){  
     99        qDebug() << "Copy BE:" << name + " -> " + newname; 
    92100        QString cmd ="beadm create -e "+name+" "+newname; 
    93101        runLongCMD(cmd); 
     
    95103 
    96104void mainUI::beadmRemove(QString name){  
     105        qDebug() << "Remove BE:" << name; 
    97106        QString cmd ="beadm destroy -F "+name; 
    98107        runLongCMD(cmd); 
     
    100109 
    101110void mainUI::beadmRename(QString name, QString newname){  
     111        qDebug() << "Rename BE:" << name + " -> " + newname;     
    102112        QString cmd ="beadm rename "+name+" "+newname; 
    103113        runLongCMD(cmd); 
     
    105115 
    106116void mainUI::beadmMount(QString name, QString mntpt){  
     117        qDebug() << "Mount BE:" << name + " on " + mntpt; 
    107118        QString cmd ="beadm mount "+name+" "+mntpt; 
    108119        runLongCMD(cmd); 
     
    110121 
    111122void mainUI::beadmUnmount(QString name){  
     123        qDebug() << "Unmount BE:" << name; 
    112124        QString cmd ="beadm umount "+name; 
    113125        runLongCMD(cmd); 
     
    116128QStringList mainUI::beadmList(){ 
    117129        //Output format (per line): <name>::<isrunning>::<isactivated>::<mountpoint>::<space>::<datecreated>::<timecreated> 
    118          
     130        qDebug() << "List BE's"; 
    119131        proc->start( "beadm list -H" ); 
    120132        proc->waitForFinished(); 
     
    138150//GRUB Configuration Management Functions 
    139151bool mainUI::loadGRUBdefaults(QString &themefile, QString &fontfile, int &countdown, bool &showcountdown){ 
     152  qDebug() << "Load GRUB defaults:" << file_GRUBdefaults; 
    140153  QFile file(file_GRUBdefaults); 
    141154  if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ return false; } 
    142155  QTextStream in(&file); 
     156  //initialize outputs 
    143157  themefile.clear(); fontfile.clear(); 
     158  int hcount = 0; //initilization 
     159  countdown = 0; //initialization 
     160  showcountdown = false; 
    144161  while( !in.atEnd() ){ 
    145162    QString line = in.readLine(); 
     
    148165    if(var == "GRUB_THEME"){ themefile.append(val); } 
    149166    else if(var == "GRUB_FONT"){ fontfile.append(val); } 
    150     else if(var == "GRUB_HIDDEN_TIMEOUT"){ countdown = val.toInt(); } 
     167    else if(var == "GRUB_HIDDEN_TIMEOUT"){ hcount = val.toInt(); } 
     168    else if(var == "GRUB_TIMEOUT"){ countdown = val.toInt(); } 
    151169    else if(var == "GRUB_HIDDEN_TIMEOUT_QUIET"){ showcountdown = (val != "true"); } 
    152170  } 
    153171  file.close(); 
    154   //qDebug() << "GRUB defaults:" << themefile << fontfile << countdown << showcountdown; 
     172  //Check to determine which countdown procedure to use 
     173  //qDebug() << "GRUB defaults:" << themefile << fontfile << countdown << hcount << showcountdown; 
     174  if(!showcountdown){ countdown = hcount; } //use the hidden countdown time if hidden 
    155175  return true;   
    156176} 
    157177 
    158178bool mainUI::saveGRUBdefaults(QString themefile, QString fontfile, int countdown, bool showcountdown){ 
     179  qDebug() << "Save GRUB defaults:" << file_GRUBdefaults; 
    159180  QFile file(file_GRUBdefaults+".new"); 
    160181  if(!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){ return false; } 
     
    162183  if(!themefile.isEmpty()){ out << "GRUB_THEME="+themefile+"\n"; } 
    163184  if(!fontfile.isEmpty()){ out << "GRUB_FONT="+fontfile+"\n"; } 
    164   out << "GRUB_HIDDEN_TIMEOUT="+ QString::number(countdown)+"\n"; 
    165   if(showcountdown){ out << "GRUB_HIDDEN_TIMEOUT_QUIET=false\n"; } 
    166   else{ out << "GRUB_HIDDEN_TIMEOUT_QUIET=true\n"; } 
     185   
     186  if(showcountdown){  
     187    out << "GRUB_HIDDEN_TIMEOUT_QUIET=false\n";  
     188    out << "GRUB_TIMEOUT="+ QString::number(countdown)+"\n"; 
     189  }else{  
     190    out << "GRUB_HIDDEN_TIMEOUT_QUIET=true\n";  
     191    out << "GRUB_HIDDEN_TIMEOUT="+ QString::number(countdown)+"\n"; 
     192  } 
    167193  file.close(); 
    168194  QString cmd="mv "+file_GRUBdefaults+".new "+file_GRUBdefaults; 
     
    172198 
    173199bool mainUI::loadGRUBcustomentries(QStringList &filecontents){ 
     200  qDebug() << "Load GRUB custom entries:" << file_GRUBentries; 
    174201  filecontents.clear(); 
    175202  QFile file(file_GRUBentries); 
     
    186213 
    187214bool mainUI::saveGRUBcustomentries(QStringList filecontents){ 
     215  qDebug() << "Save GRUB custom entries:" << file_GRUBentries; 
    188216  QFile file(file_GRUBentries+".new"); 
    189217  if(!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)){ return false; } 
     
    240268    ui->group_GRUBsettings->setEnabled(false); 
    241269  } 
     270  if( ui->tree_BE->topLevelItemCount() > 1){ 
     271    ui->check_GRUBshowcountdown->setVisible(false); 
     272  }else{ 
     273    ui->check_GRUBshowcountdown->setVisible(true); 
     274  } 
    242275  //Make sure that the save button is disabled - no changes yet 
    243   //ui->tool_GRUBsavedefaults->setEnabled(false); 
     276  ui->tool_GRUBsavedefaults->setEnabled(false); 
     277  ui->tool_GRUBresetdefaults->setEnabled(false); 
    244278} 
    245279 
     
    254288  } 
    255289  //Make sure that the save button is disabled - no changes yet 
    256   //ui->tool_GRUBsaveentries->setEnabled(false); 
     290  ui->tool_GRUBsaveentries->setEnabled(false); 
     291  ui->tool_GRUBresetentries->setEnabled(false); 
    257292} 
    258293 
    259294//UI Buttons - Boot Environments 
    260295void mainUI::on_tool_BEadd_clicked(){ 
     296  //Check to see if we need to reset the GRUB defaults afterwards 
     297  bool updateGRUB=false; 
     298  if( ui->tree_BE->topLevelItemCount() == 1){updateGRUB=true;} //moving from 1 to 2 
    261299  //Get the new name from the user 
    262300  bool ok; 
     
    266304      beadmCreate(newname); 
    267305      updateBEList(); 
     306      if(updateGRUB){ on_tool_GRUBsavedefaults_clicked();  updateGRUBdefaults();} 
    268307    } 
    269308  }      
     
    282321 int index = getSelectedBE(); 
    283322  if(index != -1){ 
     323    bool updateGRUB=false; 
     324    if( ui->tree_BE->topLevelItemCount() == 1){updateGRUB=true;} //moving from 1 to 2 
    284325    QString name = ui->tree_BE->topLevelItem(index)->text(0); 
    285326    //Get the new name from the user 
     
    290331        beadmCopy(name,newname); 
    291332        updateBEList(); 
     333        if(updateGRUB){ on_tool_GRUBsavedefaults_clicked();  updateGRUBdefaults();} 
    292334      } 
    293335    } 
     
    314356  int index = getSelectedBE(); 
    315357  if(index != -1){ 
     358    //Check to see if we need to reset the GRUB defaults afterwards 
     359    bool updateGRUB=false; 
     360    if( ui->tree_BE->topLevelItemCount() == 2){updateGRUB=true;} //moving from 2 to 1 
     361    qDebug() << "BE Rem num:" << ui->tree_BE->topLevelItemCount(); 
    316362    QString name = ui->tree_BE->topLevelItem(index)->text(0); 
    317363    if(ui->tree_BE->topLevelItemCount() == 1){ 
     
    327373      beadmRemove(name); 
    328374      updateBEList(); 
     375      if(updateGRUB){ on_tool_GRUBsavedefaults_clicked();  updateGRUBdefaults(); } 
    329376    } 
    330377  }      
     
    338385  int countdown = ui->spin_GRUBtimer->value(); 
    339386  bool showcountdown = ui->check_GRUBshowcountdown->isChecked(); 
     387  //always show the countdown if more than one BE 
     388  if( ui->tree_BE->topLevelItemCount() > 1 ){ showcountdown=true; } 
    340389         
    341390  //Save the values to the file 
     
    379428 
    380429//UI Buttons - other 
    381 void mainUI::on_tool_close_clicked(){ 
     430void mainUI::on_actionClose_triggered(){ 
    382431  this->close(); 
    383432} 
     433 
     434void mainUI::GRUBchangedefaults(){ 
     435  ui->tool_GRUBsavedefaults->setEnabled(true); 
     436  ui->tool_GRUBresetdefaults->setEnabled(true); 
     437} 
     438 
     439void mainUI::GRUBchangeentries(){ 
     440    ui->tool_GRUBsaveentries->setEnabled(true); 
     441    ui->tool_GRUBresetentries->setEnabled(true); 
     442} 
  • src-qt4/pc-bootconfig/mainUI.h

    reb2e9cc rcd554b1  
    7373        void on_tool_GRUBresetentries_clicked(); 
    7474        //UI Buttons - other 
    75         void on_tool_close_clicked(); 
     75        void on_actionClose_triggered(); 
     76        void GRUBchangedefaults(); 
     77        void GRUBchangeentries(); 
    7678         
    7779}; 
  • src-qt4/pc-bootconfig/mainUI.ui

    reb2e9cc rcd554b1  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>676</width> 
    10     <height>286</height> 
     9    <width>640</width> 
     10    <height>262</height> 
    1111   </rect> 
    1212  </property> 
     
    180180            <widget class="QSpinBox" name="spin_GRUBtimer"> 
    181181             <property name="statusTip"> 
    182               <string>Amount of time before the default option is started</string> 
     182              <string>Amount of time before the default option is started (0 deactivates automatic booting)</string> 
    183183             </property> 
    184184             <property name="suffix"> 
     
    186186             </property> 
    187187             <property name="minimum"> 
    188               <number>-1</number> 
     188              <number>0</number> 
    189189             </property> 
    190190            </widget> 
     
    200200            <layout class="QHBoxLayout" name="horizontalLayout_3"> 
    201201             <item> 
    202               <widget class="QLineEdit" name="line_GRUBfontfile"/> 
     202              <widget class="QLineEdit" name="line_GRUBfontfile"> 
     203               <property name="statusTip"> 
     204                <string>Font file for GRUB to use</string> 
     205               </property> 
     206              </widget> 
    203207             </item> 
    204208             <item> 
     
    221225            <widget class="QCheckBox" name="check_GRUBshowcountdown"> 
    222226             <property name="statusTip"> 
    223               <string>Hide the countdown timer</string> 
     227              <string>Display the GRUB menu during the countdown</string> 
    224228             </property> 
    225229             <property name="text"> 
     
    238242            <layout class="QHBoxLayout" name="horizontalLayout_2"> 
    239243             <item> 
    240               <widget class="QLineEdit" name="line_GRUBthemefile"/> 
     244              <widget class="QLineEdit" name="line_GRUBthemefile"> 
     245               <property name="statusTip"> 
     246                <string>Theme file for GRUB to use</string> 
     247               </property> 
     248              </widget> 
    241249             </item> 
    242250             <item> 
     
    372380     </widget> 
    373381    </item> 
    374     <item> 
    375      <layout class="QHBoxLayout" name="horizontalLayout_7"> 
    376       <item> 
    377        <spacer name="horizontalSpacer_3"> 
    378         <property name="orientation"> 
    379          <enum>Qt::Horizontal</enum> 
    380         </property> 
    381         <property name="sizeHint" stdset="0"> 
    382          <size> 
    383           <width>40</width> 
    384           <height>20</height> 
    385          </size> 
    386         </property> 
    387        </spacer> 
    388       </item> 
    389       <item> 
    390        <widget class="QToolButton" name="tool_close"> 
    391         <property name="statusTip"> 
    392          <string>Close the window</string> 
    393         </property> 
    394         <property name="text"> 
    395          <string>Close</string> 
    396         </property> 
    397         <property name="icon"> 
    398          <iconset resource="pc-bootconfig.qrc"> 
    399           <normaloff>:/icons/close.png</normaloff>:/icons/close.png</iconset> 
    400         </property> 
    401         <property name="toolButtonStyle"> 
    402          <enum>Qt::ToolButtonTextBesideIcon</enum> 
    403         </property> 
    404        </widget> 
    405       </item> 
    406      </layout> 
    407     </item> 
    408382   </layout> 
    409383  </widget> 
     
    413387     <x>0</x> 
    414388     <y>0</y> 
    415      <width>676</width> 
     389     <width>640</width> 
    416390     <height>20</height> 
    417391    </rect> 
    418392   </property> 
     393   <widget class="QMenu" name="menuFile"> 
     394    <property name="title"> 
     395     <string>File</string> 
     396    </property> 
     397    <addaction name="actionClose"/> 
     398   </widget> 
     399   <addaction name="menuFile"/> 
    419400  </widget> 
    420401  <widget class="QStatusBar" name="statusbar"/> 
     402  <action name="actionClose"> 
     403   <property name="icon"> 
     404    <iconset resource="pc-bootconfig.qrc"> 
     405     <normaloff>:/icons/close.png</normaloff>:/icons/close.png</iconset> 
     406   </property> 
     407   <property name="text"> 
     408    <string>Close</string> 
     409   </property> 
     410  </action> 
    421411 </widget> 
    422412 <resources> 
Note: See TracChangeset for help on using the changeset viewer.