Show
Ignore:
Timestamp:
11/30/06 03:02:49 (2 years ago)
Author:
erijo
Message:

Patch from Anders Olofsson to make the history layout configurable. Also adds a new style format that can be used in the history. Fixes part of #1449.

With this commit, <font> tags are removed before the message is displayed. This means that the sender can no longer choose the font or color to show the message in. IMHO, this is a good thing. But if you have an other opinion, speak up and maybe I'll make it configurable.

Files:
1 modified

Legend:

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

    r4782 r4791  
    213213  chkSendFromClipboard->setChecked(mainwin->m_bSendFromClipboard); 
    214214  chkMsgChatView->setChecked(mainwin->m_bMsgChatView); 
    215  
    216   bool isCustomDate = true; 
    217   for (int i = 0; i < cmbDateFormat->count(); i++) 
    218   { 
    219     if (cmbDateFormat->text(i) == mainwin->m_nDateFormat) 
    220     { 
    221       cmbDateFormat->setCurrentItem(i); 
    222       isCustomDate = false; 
    223       break; 
    224     } 
    225   } 
    226  
    227   // Make sure the checkbox is actually toggled, so that widgets are enabled/disabled. 
    228   chkCustomDateFormat->setChecked(!isCustomDate); 
    229   chkCustomDateFormat->setChecked(isCustomDate); 
    230  
    231   customDateFormat->setText(mainwin->m_nDateFormat); 
    232  
    233   chkLineBreak->setChecked(mainwin->m_bAppendLineBreak); 
    234   cmbStyle->setCurrentItem(mainwin->m_nMsgStyle); 
     215  cmbChatDateFormat->lineEdit()->setText(mainwin->m_chatDateFormat); 
     216  chkChatVertSpacing->setChecked(mainwin->m_chatVertSpacing); 
     217  chkChatLineBreak->setChecked(mainwin->m_chatAppendLineBreak); 
     218  cmbChatStyle->setCurrentItem(mainwin->m_chatMsgStyle); 
     219  cmbHistStyle->setCurrentItem(mainwin->m_histMsgStyle); 
     220  chkHistVertSpacing->setChecked(mainwin->m_histVertSpacing); 
     221  cmbHistDateFormat->lineEdit()->setText(mainwin->m_histDateFormat); 
    235222  btnColorRcv->setPaletteBackgroundColor(mainwin->m_colorRcv); 
    236223  btnColorSnt->setPaletteBackgroundColor(mainwin->m_colorSnt); 
     
    528515  mainwin->m_bSendFromClipboard = chkSendFromClipboard->isChecked(); 
    529516  mainwin->m_bMsgChatView = chkMsgChatView->isChecked(); 
    530   mainwin->m_bAppendLineBreak = chkLineBreak->isChecked(); 
    531   mainwin->m_nMsgStyle = cmbStyle->currentItem(); 
    532   mainwin->m_nDateFormat = getCurrentDateFormat(); 
     517  mainwin->m_chatVertSpacing = chkChatVertSpacing->isChecked(); 
     518  mainwin->m_chatAppendLineBreak = chkChatLineBreak->isChecked(); 
     519  mainwin->m_chatMsgStyle = cmbChatStyle->currentItem(); 
     520  mainwin->m_chatDateFormat = cmbChatDateFormat->currentText(); 
     521  mainwin->m_histMsgStyle = cmbHistStyle->currentItem(); 
     522  mainwin->m_histVertSpacing = chkHistVertSpacing->isChecked(); 
     523  mainwin->m_histDateFormat = cmbHistDateFormat->currentText(); 
    533524  mainwin->m_colorRcv = btnColorRcv->paletteBackgroundColor(); 
    534525  mainwin->m_colorSnt = btnColorSnt->paletteBackgroundColor(); 
     
    15671558  lay->addWidget(boxRight); 
    15681559 
    1569   QGroupBox* boxOptions = new QGroupBox(1, Horizontal, tr("Options"), boxRight); 
    1570  
    1571   new QLabel(tr("Style:"), boxOptions); 
    1572   cmbStyle = new QComboBox(false, boxOptions); 
    1573   cmbStyle->insertItem("Default"); 
    1574   cmbStyle->insertItem("Compact"); 
    1575   cmbStyle->insertItem("Tiny"); 
    1576   cmbStyle->insertItem("Table"); 
    1577   cmbStyle->insertItem("History"); 
    1578   connect(cmbStyle, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer())); 
    1579  
    1580   chkLineBreak = new QCheckBox(tr("Insert Horizontal Line"), boxOptions); 
    1581   connect(chkLineBreak, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer())); 
    1582  
    1583   new QLabel(tr("Date Format:"), boxOptions); 
    1584   cmbDateFormat = new QComboBox(false, boxOptions); 
    1585   cmbDateFormat->insertItem("hh:mm:ss"); 
    1586   cmbDateFormat->insertItem("yyyy-MM-dd hh:mm:ss"); 
    1587   cmbDateFormat->insertItem("yyyy-MM-dd"); 
    1588   cmbDateFormat->insertItem("yyyy/MM/dd hh:mm:ss"); 
    1589   cmbDateFormat->insertItem("yyyy/MM/dd"); 
    1590   cmbDateFormat->insertItem("dd.MM.yyyy hh:mm:ss"); 
    1591   cmbDateFormat->insertItem("dd.MM.yyyy"); 
    1592   connect(cmbDateFormat, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer())); 
    1593  
    1594   chkCustomDateFormat = new QCheckBox(tr("Custom Date Format:"), boxOptions); 
    1595   connect(chkCustomDateFormat, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer())); 
    1596   connect(chkCustomDateFormat, SIGNAL(toggled(bool)), cmbDateFormat, SLOT(setDisabled(bool))); 
    1597  
    1598   customDateFormat = new QLineEdit(boxOptions); 
    1599   connect(chkCustomDateFormat, SIGNAL(toggled(bool)), customDateFormat, SLOT(setEnabled(bool))); 
    1600   connect(customDateFormat, SIGNAL(textChanged(const QString&)), this, SLOT(slot_refresh_msgViewer())); 
    1601   QWhatsThis::add(customDateFormat, tr( 
     1560  QGroupBox* boxChatOptions = new QGroupBox(1, Horizontal, tr("Chat Options"), boxRight); 
     1561 
     1562  static const int dateFormatsLength = 7; 
     1563  static const char *const dateFormats[dateFormatsLength] = { 
     1564      "hh:mm:ss", 
     1565      "yyyy-MM-dd hh:mm:ss", 
     1566      "yyyy-MM-dd", 
     1567      "yyyy/MM/dd hh:mm:ss", 
     1568      "yyyy/MM/dd", 
     1569      "dd.MM.yyyy hh:mm:ss", 
     1570      "dd.MM.yyyy" 
     1571  }; 
     1572 
     1573  new QLabel(tr("Style:"), boxChatOptions); 
     1574  cmbChatStyle = new QComboBox(false, boxChatOptions); 
     1575  cmbChatStyle->insertStringList(CMessageViewWidget::getStyleNames(false)); 
     1576  connect(cmbChatStyle, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer())); 
     1577 
     1578  chkChatVertSpacing = new QCheckBox(tr("Insert Vertical Spacing"), boxChatOptions); 
     1579  connect(chkChatVertSpacing, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer())); 
     1580  QWhatsThis::add(chkChatVertSpacing, tr("Insert extra space between messages.")); 
     1581 
     1582  chkChatLineBreak = new QCheckBox(tr("Insert Horizontal Line"), boxChatOptions); 
     1583  connect(chkChatLineBreak, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer())); 
     1584  QWhatsThis::add(chkChatLineBreak, tr("Insert a line between each message.")); 
     1585 
     1586  QLabel* lblChatDateFormat = new QLabel(tr("Date Format:"), boxChatOptions); 
     1587  cmbChatDateFormat = new QComboBox(true, boxChatOptions); 
     1588  for(int i = 0; i < dateFormatsLength; ++i) 
     1589    cmbChatDateFormat->insertItem(dateFormats[i]); 
     1590  connect(cmbChatDateFormat, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer())); 
     1591  connect(cmbChatDateFormat, SIGNAL(textChanged(const QString&)), this, SLOT(slot_refresh_msgViewer())); 
     1592 
     1593  QString helpDateFormat = tr( 
    16021594      "<p>Available custom date format variables.</p>\n" 
    16031595      "<table>\n" 
     
    16241616      "<tr><td>AP</td><td>use AM/PM display. AP will be replaced by either 'AM' or 'PM'</td></tr>\n" 
    16251617      "<tr><td>ap</td><td>use am/pm display. ap will be replaced by either 'am' or 'pm'</td></tr>\n" 
    1626       "</table>")); 
     1618      "</table>"); 
     1619 
     1620  QWhatsThis::add(lblChatDateFormat, helpDateFormat); 
     1621  QWhatsThis::add(cmbChatDateFormat, helpDateFormat); 
     1622 
     1623  QGroupBox* boxHistOptions = new QGroupBox(1, Horizontal, tr("History Options"), boxRight); 
     1624  new QLabel(tr("Style:"), boxHistOptions); 
     1625  cmbHistStyle = new QComboBox(false, boxHistOptions); 
     1626  cmbHistStyle->insertStringList(CMessageViewWidget::getStyleNames(true)); 
     1627  connect(cmbHistStyle, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer())); 
     1628 
     1629  chkHistVertSpacing = new QCheckBox(tr("Insert Vertical Spacing"), boxHistOptions); 
     1630  connect(chkHistVertSpacing, SIGNAL(toggled(bool)), this, SLOT(slot_refresh_msgViewer())); 
     1631  QWhatsThis::add(chkHistVertSpacing, tr("Insert extra space between messages.")); 
     1632 
     1633  QLabel* lblHistDateFormat = new QLabel(tr("Date Format:"), boxHistOptions); 
     1634  cmbHistDateFormat = new QComboBox(true, boxHistOptions); 
     1635  for(int i = 0; i < dateFormatsLength; ++i) 
     1636    cmbHistDateFormat->insertItem(dateFormats[i]); 
     1637  connect(cmbHistDateFormat, SIGNAL(activated(int)), this, SLOT(slot_refresh_msgViewer())); 
     1638  connect(cmbHistDateFormat, SIGNAL(textChanged(const QString&)), this, SLOT(slot_refresh_msgViewer())); 
     1639  QWhatsThis::add(lblHistDateFormat, helpDateFormat); 
     1640  QWhatsThis::add(cmbHistDateFormat, helpDateFormat); 
     1641 
    16271642 
    16281643  QGroupBox *boxColors = new QGroupBox(2, Horizontal, tr("Colors"), boxRight); 
     
    16611676  connect(btnColorChatBkg, SIGNAL(changed()), this, SLOT(slot_refresh_msgViewer())); 
    16621677 
    1663   tabViewer = new QTabWidget(w); 
     1678  tabViewer = new CETabWidget(w); 
    16641679  lay->addWidget(tabViewer); 
    16651680 
    1666   msgViewer = new CMessageViewWidget(0, gMainWindow, tabViewer); 
    1667   tabViewer->insertTab(msgViewer, "Marge"); 
     1681  msgChatViewer = new CMessageViewWidget(0, gMainWindow, tabViewer); 
     1682  tabViewer->insertTab(msgChatViewer, "Marge"); 
     1683 
     1684  msgHistViewer = new CMessageViewWidget(0, gMainWindow, tabViewer, 0, true); 
     1685  tabViewer->insertTab(msgHistViewer, "History"); 
    16681686 
    16691687  lay->activate(); 
    16701688 
    16711689  return w; 
    1672 } 
    1673  
    1674 QString OptionsDlg::getCurrentDateFormat() const 
    1675 { 
    1676   if (chkCustomDateFormat->isChecked()) 
    1677     return customDateFormat->text(); 
    1678   else 
    1679     return cmbDateFormat->currentText(); 
    16801690} 
    16811691 
     
    16971707  }; 
    16981708 
    1699   msgViewer->m_nMsgStyle = cmbStyle->currentItem(); 
    1700   msgViewer->m_bAppendLineBreak = chkLineBreak->isChecked(); 
    1701   msgViewer->m_colorSnt = btnColorSnt->paletteBackgroundColor(); 
    1702   msgViewer->m_colorRcv = btnColorRcv->paletteBackgroundColor(); 
    1703   msgViewer->m_colorSntHistory = btnColorSntHistory->paletteBackgroundColor(); 
    1704   msgViewer->m_colorRcvHistory = btnColorRcvHistory->paletteBackgroundColor(); 
    1705   msgViewer->m_colorNotice = btnColorNotice->paletteBackgroundColor(); 
    1706   tabViewer->setPaletteForegroundColor(btnColorTypingLabel->paletteBackgroundColor()); 
    1707   msgViewer->setPaletteBackgroundColor(btnColorChatBkg->paletteBackgroundColor()); 
    1708  
    1709   msgViewer->m_nDateFormat = getCurrentDateFormat(); 
    1710  
    1711   msgViewer->clear(); 
     1709  msgChatViewer->m_nMsgStyle = cmbChatStyle->currentItem(); 
     1710  msgChatViewer->m_extraSpacing = chkChatVertSpacing->isChecked(); 
     1711  msgChatViewer->m_appendLineBreak = chkChatLineBreak->isChecked(); 
     1712  msgChatViewer->m_colorSnt = btnColorSnt->paletteBackgroundColor(); 
     1713  msgChatViewer->m_colorRcv = btnColorRcv->paletteBackgroundColor(); 
     1714  msgChatViewer->m_colorSntHistory = btnColorSntHistory->paletteBackgroundColor(); 
     1715  msgChatViewer->m_colorRcvHistory = btnColorRcvHistory->paletteBackgroundColor(); 
     1716  msgChatViewer->m_colorNotice = btnColorNotice->paletteBackgroundColor(); 
     1717  tabViewer->setTabColor(msgChatViewer, btnColorTypingLabel->paletteBackgroundColor()); 
     1718  msgChatViewer->setPaletteBackgroundColor(btnColorChatBkg->paletteBackgroundColor()); 
     1719 
     1720  msgChatViewer->m_nDateFormat = cmbChatDateFormat->currentText(); 
     1721 
     1722  msgHistViewer->m_nMsgStyle = cmbHistStyle->currentItem(); 
     1723  msgHistViewer->m_extraSpacing = chkHistVertSpacing->isChecked(); 
     1724  msgHistViewer->m_colorSnt = btnColorSnt->paletteBackgroundColor(); 
     1725  msgHistViewer->m_colorRcv = btnColorRcv->paletteBackgroundColor(); 
     1726  msgHistViewer->setPaletteBackgroundColor(btnColorChatBkg->paletteBackgroundColor()); 
     1727  msgHistViewer->m_nDateFormat = cmbHistDateFormat->currentText(); 
     1728 
     1729  msgChatViewer->clear(); 
     1730  msgHistViewer->clear(); 
    17121731  for (unsigned int i = 0; i<7; i++) 
    17131732  { 
    1714     msgViewer->addMsg(i%2 == 0 ? D_RECEIVER : D_SENDER, (i<2), 
     1733    msgChatViewer->addMsg(i%2 == 0 ? D_RECEIVER : D_SENDER, (i<2), 
    17151734          QString(""), 
    17161735          date, 
     
    17181737          names[i % 2], 
    17191738          MLView::toRichText(tr(msgs[i]), true, true)); 
    1720   } 
    1721   msgViewer->addNotice(date, MLView::toRichText(tr(msgs[7]), true, true)); 
     1739 
     1740    msgHistViewer->addMsg(i%2 == 0 ? D_RECEIVER : D_SENDER, false, 
     1741          QString(""), 
     1742          date, 
     1743          true, false, false, false, 
     1744          names[i % 2], 
     1745          MLView::toRichText(tr(msgs[i]), true, true)); 
     1746  } 
     1747  msgChatViewer->addNotice(date, MLView::toRichText(tr(msgs[7]), true, true)); 
     1748 
     1749  msgHistViewer->updateContent(); 
    17221750} 
    17231751