Changeset d2cbe8c


Ignore:
Timestamp:
01/08/14 13:23:28 (8 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
2550222
Parents:
1558ce6
Message:

Large update to the PCDM keyboard layout switcher:
*Fix detection of current keyboard settings
*Make sure that system settings are not changed unless "apply" is clicked
*Make sure that keyboard variants are being detected/available properly.
*Fix a logic bug preventing the keyboard from being changed outside the GUI

Location:
src-qt4/PCDM/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/PCDM/src/dialogKeyboard.cpp

    r4eecf13 rd2cbe8c  
    2121  keyboardModels = kModel; 
    2222  keyboardLayouts = kLayouts; 
     23  //Load the current defaults 
     24  QString junk; 
     25  Backend::readDefaultSysEnvironment(junk, dModel, dLayout, dVariant); 
    2326  connectKeyboardSlots(); 
    2427} 
     
    2629void widgetKeyboard::slotClose() 
    2730{ 
     31  //Close without changing the KBD layout 
     32  Backend::changeKbMap(dModel, dLayout, dVariant); //reset to initial defaults 
    2833  close(); 
    2934} 
     
    3136void widgetKeyboard::slotApply() 
    3237{ 
    33   slotUpdateKbOnSys(); 
     38  //slotUpdateKbOnSys(); 
     39  Backend::changeKbMap(cModel, cLayout, cVariant); //use Current values 
     40  Backend::saveDefaultSysEnvironment( QString(getenv("LANG")) , cModel, cLayout, cVariant); 
    3441  this->close(); 
    3542} 
     
    4451  // Set the default keyboard stuff 
    4552  setKbDefaults(); 
    46   slotCurrentKbLayoutChanged(0); 
     53  //slotCurrentKbLayoutChanged(0); 
    4754  groupKeyboard->setEnabled(true); 
    4855 
     
    6976{ 
    7077  QString model, layout, variant; 
    71  
    72   if ( ! (comboBoxKeyboardModel->currentIndex() == -1) ) 
     78  //Backend::log("[DEBUG] Update Keyboard on system"); 
     79  if ( comboBoxKeyboardModel->currentIndex() == -1 ){ 
     80     Backend::log("[DEBUG] Invalid kbd model index"); 
    7381     return; 
    74   if ( ! listKbLayouts->currentItem() ) 
     82  }else if ( ! listKbLayouts->currentItem() ){ 
     83     Backend::log("[DEBUG] Invalid kbd layout item"); 
    7584     return; 
    76   if ( ! listKbVariants->currentItem() ) 
     85  }else if ( ! listKbVariants->currentItem() ){ 
     86     Backend::log("[DEBUG] Invalid kbd variant item"); 
    7787     return; 
     88  } 
    7889 
    7990  model = comboBoxKeyboardModel->currentText(); 
     
    92103    variant = ""; 
    93104  } 
    94    
     105  //Backend::log("[DEBUG] Current KBD settings: "+model+", "+layout+", "+variant); 
    95106  Backend::changeKbMap(model, layout, variant); 
    96   Backend::saveDefaultSysEnvironment( QString(getenv("LANG")) , model, layout, variant); 
     107  //Save the settings for later 
     108  cModel = model; cLayout = layout; cVariant = variant; 
    97109} 
    98110 
     
    111123 
    112124    // Get the code we should search for 
    113     laycode = laycode.remove(0, laycode.indexOf("(") + 1); 
    114     laycode.truncate(laycode.indexOf(")") ); 
     125    laycode = laycode.section("- (",1,1).section(")",0,0); 
    115126 
    116127    listKbVariants->addItem("<none>"); 
     
    128139void widgetKeyboard::setKbDefaults() 
    129140{ 
    130         // Find the "us" key layout as the default 
    131         for ( int i = 0; i < listKbLayouts->count(); i++ ) 
    132                 if ( listKbLayouts->item(i)->text().indexOf("(us)") != -1 ) 
    133                         listKbLayouts->setCurrentRow(i); 
    134  
    135  
    136         comboBoxKeyboardModel->setCurrentIndex(2); 
     141  // Now update the GUI to reflect the current settings 
     142  for ( int i = 0; i < listKbLayouts->count(); i++ ){ 
     143    if ( listKbLayouts->item(i)->text().contains("- ("+dLayout+")") ){ 
     144      listKbLayouts->setCurrentRow(i); 
     145      break; 
     146    } 
     147  } 
     148   
     149  for( int i=0; i<comboBoxKeyboardModel->count(); i++){ 
     150    if( comboBoxKeyboardModel->itemText(i).contains("- ("+dModel+")") ){ 
     151      comboBoxKeyboardModel->setCurrentIndex(i); 
     152      break; 
     153    } 
     154  } 
     155  //Now fill the list of layout variants 
     156  listKbVariants->clear(); 
     157  listKbVariants->addItem("<none>"); 
     158  listKbVariants->addItems(Backend::keyVariants(dLayout, savedKeyVariants)); 
     159  //Now highlight the current variant 
     160  if(dVariant.isEmpty()){  
     161    listKbVariants->setCurrentRow(0);  
     162  }else{ 
     163    for(int i=1; i<listKbVariants->count(); i++){ //skip the first item (already accounted for) 
     164      if(listKbVariants->item(i)->text().contains("- ("+dVariant+")") ){ 
     165        listKbVariants->setCurrentRow(i); 
     166        break; 
     167      } 
     168    } 
     169  } 
    137170} 
  • src-qt4/PCDM/src/dialogKeyboard.h

    r1620346 rd2cbe8c  
    4242    QStringList keyboardModels; 
    4343    QStringList keyboardLayouts; 
     44    QString dLayout, dModel, dVariant; //original defaults 
     45    QString cLayout, cModel, cVariant; //current settiings 
    4446 
    4547signals: 
  • src-qt4/PCDM/src/pcdm-backend.cpp

    r4eecf13 rd2cbe8c  
    185185   bool ok = (kbp.exitCode() == 0); 
    186186   if(!ok){ 
    187      qDebug() << "Change KB Map Failed: "<<prog+" "+args.join(" "); 
    188      qDebug() << kbp.readAllStandardOutput(); 
     187     Backend::log("setxkbmap Failed: "+QString(kbp.readAllStandardOutput()) ); 
    189188   } 
    190189   return ok; 
Note: See TracChangeset for help on using the changeset viewer.