Changeset 4702

Show
Ignore:
Timestamp:
10/15/06 23:32:51 (2 years ago)
Author:
erijo
Message:

New "Date format" option to customize the date and time displayed in message and history windows. Thanks to Loki for contributing the patch.

Closes #1389.

Location:
trunk/qt-gui/src
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt-gui/src/ewidgets.cpp

    r4699 r4702  
    669669  m_nPPID = nPPID; 
    670670  m_nMsgStyle = m->m_nMsgStyle; 
     671  m_nDateFormat = m->m_nDateFormat; 
    671672  m_bAppendLineBreak = m->m_bAppendLineBreak; 
    672673  m_colorRcv = m->m_colorRcv; 
     
    702703  m_szId = NULL; // avoid desalocation error at destructor 
    703704  m_nMsgStyle = m->m_nMsgStyle; 
     705  m_nDateFormat = m->m_nDateFormat; 
    704706  m_bAppendLineBreak = m->m_bAppendLineBreak; 
    705707  m_colorRcv = m->m_colorRcv; 
     
    777779  } 
    778780      
     781  QString my_date = date.toString( m_nDateFormat ); 
    779782   
    780783  switch (m_nMsgStyle) { 
     
    783786                  .arg(color) 
    784787                  .arg(eventDescription) 
    785                   .arg(date.time().toString()) 
     788                  .arg(my_date) 
    786789                  .arg(isDirect ? 'D' : '-') 
    787790                  .arg(isMultiRec ? 'M' : '-') 
     
    797800                  .arg(color) 
    798801                  .arg(eventDescription) 
    799                   .arg(date.time().toString()) 
     802                  .arg(my_date) 
    800803                  .arg(isDirect ? 'D' : '-') 
    801804                  .arg(isMultiRec ? 'M' : '-') 
     
    817820                  .arg(color) 
    818821                  .arg(eventDescription) 
    819                   .arg(date.time().toString()) 
     822                  .arg(my_date) 
    820823                  .arg(contactName); 
    821824      s.append(QString("<font color=\"%1\">%2</font>") 
     
    834837                  .arg(color) 
    835838                  .arg(eventDescription) 
    836                   .arg(date.time().toString()) 
     839                  .arg(my_date) 
    837840                  .arg(color) 
    838841                  .arg(contactName); 
     
    847850                  .arg(eventDescription) 
    848851                  .arg(contactName) 
    849                   .arg(date.toString()) 
     852                  .arg(my_date) 
    850853                  .arg(isDirect ? 'D' : '-') 
    851854                  .arg(isMultiRec ? 'M' : '-') 
     
    872875  QDateTime date; 
    873876  date.setTime_t(e->Time()); 
    874   QString sd = date.time().toString(); 
     877  QString sd = date.time().toString( m_nDateFormat ); 
    875878  bool bUseHTML = false; 
    876879 
  • trunk/qt-gui/src/ewidgets.h

    r4699 r4702  
    212212 
    213213  unsigned short m_nMsgStyle; 
     214  QString m_nDateFormat; 
    214215  bool m_bAppendLineBreak; 
    215216  QColor m_colorRcvHistory; 
  • trunk/qt-gui/src/mainwin.cpp

    r4699 r4702  
    441441  licqConf.ReadBool("SingleLineChatMode", m_bSingleLineChatMode, false); 
    442442  licqConf.ReadBool("CheckSpellingEnabled", m_bCheckSpellingEnabled, false); 
     443  licqConf.ReadStr("DateFormat", szTemp, "hh:mm:ss"); 
     444  m_nDateFormat = QString::fromLatin1(szTemp); 
    443445 
    444446  licqConf.ReadStr("ReceiveMessageColor", szTemp, "red"); 
     
    35813583  licqConf.WriteStr("TabOnTypingColor", m_colorTabTyping.name()); 
    35823584  licqConf.WriteStr("ChatBackground", m_colorChatBkg.name()); 
    3583    
     3585  licqConf.WriteStr("DateFormat", m_nDateFormat.latin1()); 
     3586 
    35843587  licqConf.WriteBool("showPopAlias", m_bPopAlias); 
    35853588  licqConf.WriteBool("showPopName", m_bPopName); 
  • trunk/qt-gui/src/mainwin.h

    r4699 r4702  
    180180                 m_nSortColumn, 
    181181                 m_nMsgStyle; 
     182  QString m_nDateFormat; 
    182183                  
    183184  QColor m_colorRcvHistory, 
  • trunk/qt-gui/src/optionsdlg.cpp

    r4699 r4702  
    212212  chkSendFromClipboard->setChecked(mainwin->m_bSendFromClipboard); 
    213213  chkMsgChatView->setChecked(mainwin->m_bMsgChatView); 
    214    
     214 
     215  bool isCustomDate = true; 
     216  for (int i = 0; i < cmbDateFormat->count(); i++) 
     217  { 
     218    if (cmbDateFormat->text(i) == mainwin->m_nDateFormat) 
     219    { 
     220      cmbDateFormat->setCurrentItem(i); 
     221      isCustomDate = false; 
     222      break; 
     223    } 
     224  } 
     225 
     226  // Make sure the checkbox is actually toggled, so that widgets are enabled/disabled. 
     227  chkCustomDateFormat->setChecked(!isCustomDate); 
     228  chkCustomDateFormat->setChecked(isCustomDate); 
     229 
     230  customDateFormat->setText(mainwin->m_nDateFormat); 
     231 
    215232  chkLineBreak->setChecked(mainwin->m_bAppendLineBreak); 
    216233  cmbStyle->setCurrentItem(mainwin->m_nMsgStyle); 
     
    510527  mainwin->m_bAppendLineBreak = chkLineBreak->isChecked(); 
    511528  mainwin->m_nMsgStyle = cmbStyle->currentItem(); 
     529  mainwin->m_nDateFormat = getCurrentDateFormat(); 
    512530  mainwin->m_colorRcv = btnColorRcv->paletteBackgroundColor(); 
    513531  mainwin->m_colorSnt = btnColorSnt->paletteBackgroundColor(); 
     
    15421560  QVBox* boxRight = new QVBox(w); 
    15431561  lay->addWidget(boxRight); 
    1544    
     1562 
    15451563  QGroupBox* boxOptions = new QGroupBox(1, Horizontal, tr("Options"), boxRight); 
    15461564 
     
    15531571  cmbStyle->insertItem("History"); 
    15541572  connect(cmbStyle, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer())); 
    1555    
     1573 
    15561574  chkLineBreak = new QCheckBox(tr("Insert Horizontal Line"), boxOptions); 
    15571575  connect(chkLineBreak, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer())); 
    1558    
     1576 
     1577  new QLabel(tr("Date Format:"), boxOptions); 
     1578  cmbDateFormat = new QComboBox(false, boxOptions); 
     1579  cmbDateFormat->insertItem("hh:mm:ss"); 
     1580  cmbDateFormat->insertItem("yyyy-MM-dd hh:mm:ss"); 
     1581  cmbDateFormat->insertItem("yyyy-MM-dd"); 
     1582  cmbDateFormat->insertItem("yyyy/MM/dd hh:mm:ss"); 
     1583  cmbDateFormat->insertItem("yyyy/MM/dd"); 
     1584  connect(cmbDateFormat, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer())); 
     1585 
     1586  chkCustomDateFormat = new QCheckBox(tr("Custom Date Format"), boxOptions); 
     1587  connect(chkCustomDateFormat, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer())); 
     1588  connect(chkCustomDateFormat, SIGNAL(toggled(bool)), cmbDateFormat, SLOT(setDisabled(bool))); 
     1589 
     1590  customDateFormat = new QLineEdit(boxOptions); 
     1591  connect(chkCustomDateFormat, SIGNAL(toggled(bool)), customDateFormat, SLOT(setEnabled(bool))); 
     1592  connect(customDateFormat, SIGNAL(textChanged(const QString&)), this, SLOT(slot_refresh_msgViewer())); 
     1593  QWhatsThis::add(customDateFormat, tr( 
     1594      "<p>Available custom date format variables.</p>" 
     1595      "<table>" 
     1596      "<tr><th>Expression</th><th>Output</th></tr>" 
     1597      "<tr><td>d</td>   <td>the day as number without a leading zero (1-31)</td></tr>" 
     1598      "<tr><td>dd</td>  <td>the day as number with a leading zero (01-31)</td></tr>" 
     1599      "<tr><td>ddd</td> <td>the abbreviated localized day name (e.g. 'Mon'..'Sun')</td></tr>" 
     1600      "<tr><td>dddd</td><td>the long localized day name (e.g. 'Monday'..'Sunday')</td></tr>" 
     1601      "<tr><td>M</td>   <td>the month as number without a leading zero (1-12)</td></tr>" 
     1602      "<tr><td>MM</td>  <td>the month as number with a leading zero (01-12)</td></tr>" 
     1603      "<tr><td>MMM</td> <td>the abbreviated localized month name (e.g. 'Jan'..'Dec')</td></tr>" 
     1604      "<tr><td>MMMM</td><td>the long localized month name (e.g. 'January'..'December')</td></tr>" 
     1605      "<tr><td>yy</td>  <td>the year as two digit number (00-99)</td></tr>" 
     1606      "<tr><td>yyyy</td><td>the year as four digit number (1752-8000)</td></tr>" 
     1607      "<tr><td colspan=2></td></tr>" 
     1608      "<tr><td>h</td>   <td>the hour without a leading zero (0..23 or 1..12 if AM/PM display)</td></tr>" 
     1609      "<tr><td>hh</td>  <td>the hour with a leading zero (00..23 or 01..12 if AM/PM display</td></tr>" 
     1610      "<tr><td>m</td>   <td>the minute without a leading zero (0..59</td></tr>" 
     1611      "<tr><td>mm</td>  <td>the minute with a leading zero (00..59</td></tr>" 
     1612      "<tr><td>s</td>   <td>the second whithout a leading zero (0..59)</td></tr>" 
     1613      "<tr><td>ss</td>  <td>the second whith a leading zero (00..59</td></tr>" 
     1614      "<tr><td>z</td>   <td>the milliseconds without leading zeroes (0..999)</td></tr>" 
     1615      "<tr><td>zzz</td> <td>the milliseconds with leading zeroes (000..999</td></tr>" 
     1616      "<tr><td>AP</td>  <td>use AM/PM display. AP will be replaced by either 'AM' or 'PM'</td></tr>" 
     1617      "<tr><td>ap</td>  <td>use am/pm display. ap will be replaced by either 'am' or 'pm'</td></tr>" 
     1618      "</table>")); 
     1619 
    15591620  QGroupBox *boxColors = new QGroupBox(2, Horizontal, tr("Colors"), boxRight); 
    15601621 
    15611622  new QLabel(tr("Message Received:"), boxColors); 
    15621623  btnColorRcv = new CColorOption(boxColors); 
    1563    
     1624 
    15641625  new QLabel(tr("Message Sent:"), boxColors); 
    15651626  btnColorSnt = new CColorOption(boxColors); 
     
    15871648  connect(btnColorTypingLabel, SIGNAL(changed()), this, SLOT(slot_refresh_msgViewer())); 
    15881649  connect(btnColorChatBkg, SIGNAL(changed()), this, SLOT(slot_refresh_msgViewer())); 
    1589    
     1650 
    15901651  tabViewer = new QTabWidget(w); 
    15911652  lay->addWidget(tabViewer); 
    1592    
     1653 
    15931654  msgViewer = new CMessageViewWidget(0, gMainWindow, tabViewer); 
    15941655  tabViewer->insertTab(msgViewer, "Marge"); 
    1595    
     1656 
    15961657  lay->activate(); 
    15971658 
     
    15991660} 
    16001661 
     1662QString OptionsDlg::getCurrentDateFormat() const 
     1663{ 
     1664  if (chkCustomDateFormat->isChecked()) 
     1665    return customDateFormat->text(); 
     1666  else 
     1667    return cmbDateFormat->currentText(); 
     1668} 
     1669 
    16011670void OptionsDlg::slot_refresh_msgViewer() 
    16021671{ 
    1603   QDateTime date; 
     1672  // Don't update the time at every refresh 
     1673  static QDateTime date = QDateTime::currentDateTime(); 
     1674 
    16041675  const char *names[2] = {"Marge", "Homer"}; 
    16051676  const char *msgs[7] = { 
     
    16111682      "Cool, I'll see you there :)", 
    16121683      "We'll be waiting!"}; 
    1613    
     1684 
    16141685  msgViewer->m_nMsgStyle = cmbStyle->currentItem(); 
    16151686  msgViewer->m_bAppendLineBreak = chkLineBreak->isChecked(); 
     
    16201691  tabViewer->setPaletteForegroundColor(btnColorTypingLabel->paletteBackgroundColor()); 
    16211692  msgViewer->setPaletteBackgroundColor(btnColorChatBkg->paletteBackgroundColor()); 
    1622    
     1693 
     1694  msgViewer->m_nDateFormat = getCurrentDateFormat(); 
     1695 
    16231696  msgViewer->clear(); 
    16241697  for (unsigned int i = 0; i<7; i++) 
  • trunk/qt-gui/src/optionsdlg.h

    r4699 r4702  
    163163   QTabWidget *tabViewer; 
    164164   QComboBox *cmbStyle; 
     165   QComboBox *cmbDateFormat; 
     166   QCheckBox *chkCustomDateFormat; 
     167   QLineEdit *customDateFormat; 
    165168   QCheckBox *chkLineBreak; 
    166169   CColorOption *btnColorRcv; 
     
    201204  void slot_chkOnEventsToggled(bool); 
    202205  void slot_refresh_msgViewer(); 
     206 
     207private: 
     208  QString getCurrentDateFormat() const; 
    203209}; 
    204210