Changeset 4857

Show
Ignore:
Timestamp:
02/16/07 05:47:30 (19 months ago)
Author:
flynd
Message:

Added option to use double Return instead of Ctrl+Return as requested in #1492.

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

Legend:

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

    r4844 r4857  
    409409  delete MLEditWrap::editFont; 
    410410  MLEditWrap::editFont = new QFont(f); 
     411  licqConf.ReadBool("UseDoubleReturn", MLEditWrap::useDoubleReturn, false); 
    411412 
    412413  licqConf.ReadBool("GridLines", m_bGridLines, false); 
     
    35353536                     *MLEditWrap::editFont == defaultFont) ? 
    35363537                     "default" : MLEditWrap::editFont->toString().latin1()); 
     3538  licqConf.WriteBool("UseDoubleReturn", MLEditWrap::useDoubleReturn); 
    35373539  licqConf.WriteBool("GridLines", m_bGridLines); 
    35383540  licqConf.WriteBool("FontStyles", m_bFontStyles); 
  • trunk/qt-gui/src/mledit.cpp

    r4800 r4857  
    3333 
    3434QFont *MLEditWrap::editFont = NULL; 
     35bool MLEditWrap::useDoubleReturn = false; 
    3536 
    3637MLEditWrap::MLEditWrap (bool wordWrap, QWidget* parent, bool /* doQuotes */, const char *name) 
    37   : MLEditWrapBase(parent, name), m_fixSetTextNewlines(true) 
     38  : MLEditWrapBase(parent, name), 
     39    m_fixSetTextNewlines(true), 
     40    m_lastKeyWasReturn(false) 
    3841{ 
    3942  setTextFormat(Qt::PlainText); 
     
    124127  const bool isControl = e->state() & ControlButton; 
    125128 
     129  // Get flag from last time and reset it before any possible returns 
     130  bool lastKeyWasReturn = m_lastKeyWasReturn; 
     131  m_lastKeyWasReturn = false; 
     132 
    126133  if (isShift && e->key() == Key_Insert) 
    127134    return paste(); 
     
    150157    case Key_Return: 
    151158    case Key_Enter: 
    152       emit signal_CtrlEnterPressed(); 
     159      if (useDoubleReturn) 
     160        insert("\n"); 
     161      else 
     162        emit signal_CtrlEnterPressed(); 
    153163      break; 
    154164    default: 
     
    156166    } 
    157167    return; 
     168  } 
     169 
     170  if ((e->state() & Qt::KeyButtonMask) == 0) 
     171  { 
     172    switch (e->key()) 
     173    { 
     174      case Key_Return: 
     175      case Key_Enter: 
     176        if (lastKeyWasReturn && useDoubleReturn) 
     177        { 
     178          // Return pressed twice, remove the previous line break and emit signal 
     179          moveCursor(QTextEdit::MoveBackward, true); 
     180          del(); 
     181          emit signal_CtrlEnterPressed(); 
     182          return; 
     183        } 
     184        else 
     185        { 
     186          // Return pressed once 
     187          m_lastKeyWasReturn = true; 
     188        } 
     189        break; 
     190    } 
    158191  } 
    159192 
  • trunk/qt-gui/src/mledit.h

    r4531 r4857  
    6868 
    6969  static QFont *editFont; 
     70  static bool useDoubleReturn; 
    7071 
    7172protected: 
     
    8586private: 
    8687  bool m_fixSetTextNewlines; 
     88  bool m_lastKeyWasReturn; 
    8789}; 
    8890 
  • trunk/qt-gui/src/optionsdlg.cpp

    r4849 r4857  
    250250  chkMsgWinSticky->setChecked(mainwin->m_bMsgWinSticky); 
    251251  chkSingleLineChatMode->setChecked(mainwin->m_bSingleLineChatMode); 
     252  chkUseDoubleReturn->setChecked(MLEditWrap::useDoubleReturn); 
    252253  popPicture->setChecked(mainwin->m_bPopPicture); 
    253254  popAlias->setChecked(mainwin->m_bPopAlias); 
     
    546547  mainwin->m_bMsgWinSticky = chkMsgWinSticky->isChecked(); 
    547548  mainwin->m_bSingleLineChatMode = chkSingleLineChatMode->isChecked(); 
     549  MLEditWrap::useDoubleReturn = chkUseDoubleReturn->isChecked(); 
    548550 
    549551  mainwin->m_bPopPicture = popPicture->isChecked(); 
     
    832834    "and insert new lines with Ctrl+Enter, opposite of the normal mode")); 
    833835 
     836  chkUseDoubleReturn = new QCheckBox(tr("Use double return"), boxMainWin); 
     837  QWhatsThis::add(chkUseDoubleReturn, tr("Hitting Return twice will be used instead of Ctrl+Return " 
     838    "to send messages and close input dialogs. Multiple new lines can be inserted with Ctrl+Return.")); 
     839 
    834840  chkMsgChatView = new QCheckBox(tr("Chatmode Messageview"), boxMainWin); 
    835841  QWhatsThis::add(chkMsgChatView, tr("Show the current chat history in Send Window")); 
  • trunk/qt-gui/src/optionsdlg.h

    r4844 r4857  
    114114             *chkSysBack, *chkSendFromClipboard, *chkMsgChatView, *chkAutoPosReplyWin, 
    115115             *chkFlashTaskbar, *chkAutoSendThroughServer, *chkTabbedChatting, 
    116              *chkMainWinSticky, *chkMsgWinSticky, *chkSingleLineChatMode, 
     116             *chkMainWinSticky, *chkMsgWinSticky, *chkSingleLineChatMode, *chkUseDoubleReturn, 
    117117             *chkEnableMainwinMouseMovement, *chkShowHistory, *chkSendTN, *chkShowNotices; 
    118118   QRadioButton *rdbDockDefault, *rdbDockThemed, *rdbDockSmall;