~ubuntu-branches/ubuntu/saucy/kvirc/saucy

« back to all changes in this revision

Viewing changes to src/kvirc/ui/KviInputEditor.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2013-05-18 19:36:33 UTC
  • mfrom: (22.1.4 sid)
  • Revision ID: package-import@ubuntu.com-20130518193633-kuhzryg7jstqvxpr
Tags: 4:4.2.0-2
Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include "KviPixmapUtils.h"
43
43
#include "KviQString.h"
44
44
#include "kvi_out.h"
45
 
#include "KviTalPopupMenu.h"
46
45
#include "KviTextIconWindow.h"
47
46
#include "KviTextIconManager.h"
48
47
#include "KviUserInput.h"
62
61
#include <QKeyEvent>
63
62
#include <QDragEnterEvent>
64
63
#include <QInputContext>
 
64
#include <QMenu>
65
65
 
66
66
// from KviApplication.cpp
67
 
extern KviTalPopupMenu         * g_pInputPopup;
 
67
extern QMenu         * g_pInputPopup;
68
68
extern KviTextIconWindow       * g_pTextIconWindow;
69
69
extern KviColorWindow          * g_pColorWindow;
70
70
 
122
122
        setFocusPolicy(Qt::StrongFocus);
123
123
        setAcceptDrops(true);
124
124
 
125
 
        m_pIconMenu = new KviTalPopupMenu();
126
 
        connect(m_pIconMenu,SIGNAL(activated(int)),this,SLOT(iconPopupActivated(int)));
 
125
    m_pIconMenu = new QMenu();
 
126
    connect(m_pIconMenu,SIGNAL(triggered(QAction*)),this,SLOT(iconPopupActivated(QAction *)));
127
127
 
128
128
        setCursor(Qt::IBeamCursor);
129
129
 
166
166
        //set the font
167
167
        QFont newFont(KVI_OPTION_FONT(KviOption_fontInput));
168
168
        newFont.setKerning(false);
 
169
#if QT_VERSION >= 0x040700
 
170
        newFont.setStyleStrategy(QFont::StyleStrategy(newFont.styleStrategy() | QFont::ForceIntegerMetrics));
 
171
#endif
169
172
        setFont(newFont);
170
173
 
171
174
        if(bRefreshCachedMetrics)
797
800
                        }
798
801
                }
799
802
 
800
 
                int iId = g_pInputPopup->insertItem(__tr2qs("&Undo") + ACCEL_KEY(Z),this,SLOT(undo()));
801
 
                g_pInputPopup->setItemEnabled(iId,isUndoAvailable());
802
 
                iId = g_pInputPopup->insertItem(__tr2qs("&Redo") + ACCEL_KEY(Y),this,SLOT(redo()));
803
 
                g_pInputPopup->setItemEnabled(iId,isRedoAvailable());
804
 
                iId = g_pInputPopup->insertItem(__tr2qs("Cu&t") + ACCEL_KEY(X),this,SLOT(cut()));
805
 
                g_pInputPopup->setItemEnabled(iId,hasSelection());
806
 
                iId = g_pInputPopup->insertItem(__tr2qs("&Copy") + ACCEL_KEY(C),this,SLOT(copyToClipboard()));
807
 
                g_pInputPopup->setItemEnabled(iId,hasSelection());
808
 
                iId = g_pInputPopup->insertItem(__tr2qs("&Paste") + ACCEL_KEY(V),this,SLOT(pasteClipboardWithConfirmation()));
809
 
                g_pInputPopup->setItemEnabled(iId,!szClip.isEmpty() && !m_bReadOnly);
810
 
                iId = g_pInputPopup->insertItem(__tr2qs("Paste (Slowly)"),this,SLOT(pasteSlow()));
 
803
        QAction * pAction = g_pInputPopup->addAction(__tr2qs("&Undo") + ACCEL_KEY(Z),this,SLOT(undo()));
 
804
        pAction->setEnabled(isUndoAvailable());
 
805
        pAction = g_pInputPopup->addAction(__tr2qs("&Redo") + ACCEL_KEY(Y),this,SLOT(redo()));
 
806
        pAction->setEnabled(isRedoAvailable());
 
807
        pAction = g_pInputPopup->addAction(__tr2qs("Cu&t") + ACCEL_KEY(X),this,SLOT(cut()));
 
808
        pAction->setEnabled(hasSelection());
 
809
        pAction = g_pInputPopup->addAction(__tr2qs("&Copy") + ACCEL_KEY(C),this,SLOT(copyToClipboard()));
 
810
        pAction->setEnabled(hasSelection());
 
811
        pAction = g_pInputPopup->addAction(__tr2qs("&Paste") + ACCEL_KEY(V),this,SLOT(pasteClipboardWithConfirmation()));
 
812
        pAction->setEnabled(!szClip.isEmpty() && !m_bReadOnly);
 
813
        pAction = g_pInputPopup->addAction(__tr2qs("Paste (Slowly)"),this,SLOT(pasteSlow()));
811
814
                if ((iType == KviWindow::Channel) || (iType == KviWindow::Query) || (iType == KviWindow::DccChat))
812
 
                        g_pInputPopup->setItemEnabled(iId,!szClip.isEmpty() && !m_bReadOnly);
 
815
            pAction->setEnabled(!szClip.isEmpty() && !m_bReadOnly);
813
816
                else
814
 
                        g_pInputPopup->setItemEnabled(iId,false);
815
 
                iId = g_pInputPopup->insertItem(__tr2qs("Paste &File") + ACCEL_KEY(L),this,SLOT(pasteFile()));
 
817
            pAction->setEnabled(false);
 
818
        pAction = g_pInputPopup->addAction(__tr2qs("Paste &File") + ACCEL_KEY(L),this,SLOT(pasteFile()));
816
819
                if ((iType != KviWindow::Channel) && (iType != KviWindow::Query) && (iType != KviWindow::DccChat))
817
 
                        g_pInputPopup->setItemEnabled(iId,false);
 
820
            pAction->setEnabled(false);
818
821
                else
819
 
                        g_pInputPopup->setItemEnabled(iId,!m_bReadOnly);
 
822
            pAction->setEnabled(!m_bReadOnly);
820
823
                if(m_bSpSlowFlag)
821
824
                {
822
 
                        iId = g_pInputPopup->insertItem(__tr2qs("Stop Paste"),this,SLOT(stopPasteSlow())); /*G&N 2005*/
 
825
            pAction = g_pInputPopup->addAction(__tr2qs("Stop Paste"),this,SLOT(stopPasteSlow())); /*G&N 2005*/
823
826
                }
824
 
                iId = g_pInputPopup->insertItem(__tr2qs("Clear"),this,SLOT(clear()));
825
 
                g_pInputPopup->setItemEnabled(iId,!m_szTextBuffer.isEmpty() && !m_bReadOnly);
826
 
                g_pInputPopup->insertSeparator();
827
 
                iId = g_pInputPopup->insertItem(__tr2qs("Select All"),this,SLOT(selectAll()));
828
 
                g_pInputPopup->setItemEnabled(iId,(!m_szTextBuffer.isEmpty()));
 
827
        pAction = g_pInputPopup->addAction(__tr2qs("Clear"),this,SLOT(clear()));
 
828
        pAction->setEnabled(!m_szTextBuffer.isEmpty() && !m_bReadOnly);
 
829
        g_pInputPopup->addSeparator();
 
830
        pAction = g_pInputPopup->addAction(__tr2qs("Select All"),this,SLOT(selectAll()));
 
831
        pAction->setEnabled((!m_szTextBuffer.isEmpty()));
829
832
 
830
 
                g_pInputPopup->insertSeparator();
 
833
        g_pInputPopup->addSeparator();
831
834
                m_pIconMenu->clear();
832
835
 
833
836
                KviPointerHashTable<QString,KviTextIcon> * d = g_pTextIconManager->textIconDict();
850
853
                        if(pIcon)
851
854
                        {
852
855
                                pPix = pIcon->pixmap();
853
 
                                if(pPix) m_pIconMenu->insertItem(*pPix,*iter);
 
856
                                if(pPix) m_pIconMenu->addAction(*pPix,*iter);
854
857
                        }
855
858
                }
856
859
 
857
 
                g_pInputPopup->insertItem(*(g_pIconManager->getSmallIcon(KviIconManager::BigGrin)),__tr2qs("Insert Icon"),m_pIconMenu);
 
860
        pAction = g_pInputPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::BigGrin)),__tr2qs("Insert Icon"));
 
861
        pAction->setMenu(m_pIconMenu);
858
862
 
859
863
                QInputContext *qic = g_pApp->inputContext();
860
864
                if (qic) {
869
873
        }
870
874
}
871
875
 
872
 
void KviInputEditor::iconPopupActivated(int iId)
 
876
void KviInputEditor::iconPopupActivated(QAction *pAction)
873
877
{
874
878
        if(!m_bReadOnly)
875
879
        {
876
 
                QString szText = m_pIconMenu->text(iId);
 
880
        QString szText = pAction->text();
877
881
                if(!szText.isEmpty())
878
882
                {
879
883
                        szText.prepend(KviControlCodes::Icon);