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

« back to all changes in this revision

Viewing changes to src/modules/options/OptionsWidget_servers.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:
53
53
#include "KviProxyDataBase.h"
54
54
#include "KviKvsScript.h"
55
55
#include "KviPointerHashTable.h"
56
 
#include "KviTalPopupMenu.h"
57
56
#include "KviTalToolTip.h"
58
57
 
59
58
#include <QLineEdit>
66
65
#include <QHeaderView>
67
66
#include <QIcon>
68
67
#include <QShortcut>
 
68
#include <QMenu>
69
69
 
70
70
#if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) || defined(COMPILE_ON_MAC)
71
71
        #include <QStyleFactory>
230
230
        while(d->pcName)
231
231
        {
232
232
                tmp = QString("%1 (%2)").arg(d->pcName,d->pcDescription);
233
 
                m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp);
234
 
                m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp);
 
233
        m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp);
 
234
        m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp);
235
235
                if(KviQString::equalCI(d->pcName,n->encoding()))
236
236
                        srvcurrent = i + 1;
237
237
                if(KviQString::equalCI(d->pcName,n->textEncoding()))
786
786
        while(d->pcName)
787
787
        {
788
788
                tmp = QString("%1 (%2)").arg(d->pcName,d->pcDescription);
789
 
                m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp);
790
 
                m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp);
 
789
        m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp);
 
790
        m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp);
791
791
                if(KviQString::equalCI(d->pcName,s->encoding()))
792
792
                        srvcurrent = i + 1;
793
793
                if(KviQString::equalCI(d->pcName,s->textEncoding()))
815
815
        KviPointerList<KviProxy> * proxylist = g_pProxyDataBase->proxyList();
816
816
        for(KviProxy * p = proxylist->first();p;p = proxylist->next())
817
817
        {
818
 
                m_pProxyEditor->insertItem(m_pProxyEditor->count(),QString("%1:%2").arg(p->hostName()).arg(p->port()));
 
818
        m_pProxyEditor->insertItem(m_pProxyEditor->count(),QString("%1:%2").arg(p->hostName()).arg(p->port()));
819
819
        }
820
820
        if(m_pProxyEditor->count() > (s->proxy()+2))
821
821
                m_pProxyEditor->setCurrentIndex(s->proxy()+2);
892
892
 
893
893
        iRow = 0;
894
894
 
 
895
        m_pEnableSTARTTLSCheck = new QCheckBox(__tr2qs_ctx("Switch to SSL/TLS by using the STARTTLS extension","options"),tab);
 
896
        gl->addWidget(m_pEnableSTARTTLSCheck,iRow,0,1,2);
 
897
        KviTalToolTip::add(m_pEnableSTARTTLSCheck,__tr2qs_ctx("<center>This check enables the use of the <b>Transport Layer Security</b> " \
 
898
                "protocol. If you enable the Extended Capabilities below then the TLS protocol support will be detected by using " \
 
899
                "a CAP LS command. Without Extended Capabilities the STARTTLS command will be forcibly sent at the beginning of the " \
 
900
                "connection.</center>","options"));
 
901
#ifndef COMPILE_SSL_SUPPORT
 
902
        m_pEnableSTARTTLSCheck->setEnabled(false);
 
903
#endif
 
904
        m_pEnableSTARTTLSCheck->setChecked(s->enabledSTARTTLS());
 
905
 
 
906
        iRow++;
 
907
 
 
908
 
895
909
        QGroupBox * pCapGroup = new QGroupBox(__tr2qs_ctx("Extended Capabilities","options"),tab);
896
910
        gl->addWidget(pCapGroup,iRow,0,1,2);
897
911
 
906
920
        m_pEnableCAPCheck->setChecked(s->enabledCAP());
907
921
 
908
922
 
909
 
 
910
 
        m_pEnableSTARTTLSCheck = new QCheckBox(__tr2qs_ctx("Switch to SSL/TLS by using the STARTTLS extension","options"),tab);
911
 
        pCapLayout->addWidget(m_pEnableSTARTTLSCheck,1,0);
912
 
 
913
 
        m_pEnableSTARTTLSCheck->setEnabled(s->enabledCAP());
914
 
        QObject::connect(m_pEnableCAPCheck,SIGNAL(toggled(bool)),m_pEnableSTARTTLSCheck,SLOT(setEnabled(bool)));
915
 
        KviTalToolTip::add(m_pEnableSTARTTLSCheck,__tr2qs_ctx("<center>This check enables the use of the <b>Transport Layer Security</b> " \
916
 
                "protocol. If you enable the proper global option in the Connection/SSL tab, the TLS protocol will be used for this server if available.</center>","options"));
917
 
#ifndef COMPILE_SSL_SUPPORT
918
 
        m_pEnableSTARTTLSCheck->setEnabled(false);
919
 
#endif
920
 
        m_pEnableSTARTTLSCheck->setChecked(s->enabledCAP() && s->enabledSTARTTLS());
921
 
 
922
 
 
923
923
        QGroupBox * pSASLGroup = new QGroupBox(__tr2qs_ctx("SASL Authentication","options"),tab);
924
924
        pCapLayout->addWidget(pSASLGroup,2,0);
925
925
 
1258
1258
 
1259
1259
        createLayout();
1260
1260
 
1261
 
        m_pContextPopup = new KviTalPopupMenu(this);
1262
 
        m_pImportPopup = new KviTalPopupMenu(this);
 
1261
    m_pContextPopup = new QMenu(this);
 
1262
    m_pImportPopup = new QMenu(this);
1263
1263
 
1264
1264
        connect(m_pImportPopup,SIGNAL(aboutToShow()),this,SLOT(importPopupAboutToShow()));
1265
 
        connect(m_pImportPopup,SIGNAL(activated(int)),this,SLOT(importPopupActivated(int)));
 
1265
    connect(m_pImportPopup,SIGNAL(triggered(QAction *)),this,SLOT(importPopupActivated(QAction *)));
1266
1266
 
1267
1267
        m_pServerDetailsDialog = 0;
1268
1268
        m_pNetworkDetailsDialog = 0;
1371
1371
        connect(m_pDetailsButton,SIGNAL(clicked()),this,SLOT(detailsClicked()));
1372
1372
        KviTalToolTip::add(m_pDetailsButton,__tr2qs_ctx("<center>Click here to edit advanced options for this entry</center>","options"));
1373
1373
 
1374
 
        m_pRecentPopup = new KviTalPopupMenu(gbox);
 
1374
    m_pRecentPopup = new QMenu(gbox);
1375
1375
        connect(m_pRecentPopup,SIGNAL(aboutToShow()),this,SLOT(recentServersPopupAboutToShow()));
1376
 
        connect(m_pRecentPopup,SIGNAL(activated(int)),this,SLOT(recentServersPopupClicked(int)));
 
1376
    connect(m_pRecentPopup,SIGNAL(triggered(QAction *)),this,SLOT(recentServersPopupClicked(QAction *)));
1377
1377
 
1378
1378
        QToolButton * tb = new QToolButton(gbox);
1379
1379
        tb->setIcon(QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Time))));
1479
1479
{
1480
1480
        g_pApp->fillRecentServersPopup(m_pRecentPopup);
1481
1481
 
1482
 
        m_pRecentPopup->insertSeparator();
1483
 
        m_pRecentPopup->insertItem(__tr2qs("Clear Recent Servers List"));
 
1482
    m_pRecentPopup->addSeparator();
 
1483
        m_pRecentPopup->addAction(__tr2qs("Clear Recent Servers List"));
1484
1484
}
1485
1485
 
1486
 
void OptionsWidget_servers::recentServersPopupClicked(int id)
 
1486
void OptionsWidget_servers::recentServersPopupClicked(QAction *pAction)
1487
1487
{
1488
1488
        if(!g_pActiveWindow)
1489
1489
                return; // doh
1492
1492
        if(!c)
1493
1493
                return;
1494
1494
 
1495
 
        QString szItemText = m_pRecentPopup->text(id);
 
1495
    QString szItemText = pAction->text();
1496
1496
        szItemText.remove(QChar('&'));
1497
1497
        if(szItemText.isEmpty())
1498
1498
                return;
1798
1798
 
1799
1799
void OptionsWidget_servers::customContextMenuRequested(const QPoint &pnt)
1800
1800
{
1801
 
        int id;
1802
1801
        QTreeWidgetItem *it=(QTreeWidgetItem *) m_pTreeWidget->itemAt(pnt);
1803
1802
        bool bServer = (it && ((IrcServerOptionsTreeWidgetItem *)it)->m_pServerData);
1804
1803
        m_pContextPopup->clear();
1805
 
        m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KviIconManager::World)),__tr2qs_ctx("New Network","options"),this,SLOT(newNetwork()));
1806
 
        id = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KviIconManager::Cut)),__tr2qs_ctx("Remove Network","options"),this,SLOT(removeCurrent()));
1807
 
        m_pContextPopup->setItemEnabled(id,!bServer);
1808
 
        m_pContextPopup->insertSeparator();
1809
 
        id = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KviIconManager::Server)),__tr2qs_ctx("&New Server","options"),this,SLOT(newServer()));
1810
 
        id = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KviIconManager::Cut)),__tr2qs_ctx("Re&move Server","options"),this,SLOT(removeCurrent()));
1811
 
        m_pContextPopup->setItemEnabled(id,bServer);
1812
 
        id = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KviIconManager::Copy)),__tr2qs_ctx("&Copy Server","options"),this,SLOT(copyServer()));
1813
 
        m_pContextPopup->setItemEnabled(id,bServer);
1814
 
        id = m_pContextPopup->insertItem(*(g_pIconManager->getSmallIcon(KviIconManager::Paste)),__tr2qs_ctx("&Paste Server","options"),this,SLOT(pasteServer()));
1815
 
        m_pContextPopup->setItemEnabled(id,m_pClipboard);
 
1804
        m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::World)),__tr2qs_ctx("New Network","options"),this,SLOT(newNetwork()));
 
1805
    m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Cut)),__tr2qs_ctx("Remove Network","options"),this,SLOT(removeCurrent()))
 
1806
        ->setEnabled(!bServer);
 
1807
    m_pContextPopup->addSeparator();
 
1808
    m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Server)),__tr2qs_ctx("&New Server","options"),this,SLOT(newServer()));
 
1809
    m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Cut)),__tr2qs_ctx("Re&move Server","options"),this,SLOT(removeCurrent()))
 
1810
        ->setEnabled(bServer);
 
1811
    m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Copy)),__tr2qs_ctx("&Copy Server","options"),this,SLOT(copyServer()));
 
1812
    m_pContextPopup->setEnabled(bServer);
 
1813
    m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Paste)),__tr2qs_ctx("&Paste Server","options"),this,SLOT(pasteServer()))
 
1814
        ->setEnabled(m_pClipboard);
1816
1815
 
1817
 
        m_pContextPopup->insertSeparator();
1818
 
        //      m_pContextPopup->insertItem(__c2q(__tr("Merge list from server.ini","options")),this,SLOT(importFromIni()));
1819
 
        m_pContextPopup->insertItem(__tr2qs_ctx("Clear List","options"),this,SLOT(clearList()));
1820
 
        m_pContextPopup->insertSeparator();
1821
 
        m_pContextPopup->insertItem(__tr2qs_ctx("Import List","options"),m_pImportPopup);
 
1816
    m_pContextPopup->addSeparator();
 
1817
        //      m_pContextPopup->addAction(__c2q(__tr("Merge list from server.ini","options")),this,SLOT(importFromIni()));
 
1818
        m_pContextPopup->addAction(__tr2qs_ctx("Clear List","options"),this,SLOT(clearList()));
 
1819
    m_pContextPopup->addSeparator();
 
1820
    m_pContextPopup->addAction(__tr2qs_ctx("Import List","options"))->setMenu(m_pImportPopup);
1822
1821
        m_pContextPopup->popup(QCursor::pos());
1823
1822
}
1824
1823
 
1831
1830
 
1832
1831
        if(!l)return;
1833
1832
 
1834
 
        int id;
 
1833
    QAction *pAction;
1835
1834
 
1836
1835
        for(KviModuleExtensionDescriptor * d = l->first();d;d = l->next())
1837
1836
        {
1838
1837
                if(d->icon())
1839
 
                        id = m_pImportPopup->insertItem(*(d->icon()),d->visibleName());
 
1838
            pAction = m_pImportPopup->addAction(*(d->icon()),d->visibleName());
1840
1839
                else
1841
 
                        id = m_pImportPopup->insertItem(d->visibleName());
1842
 
                m_pImportPopup->setItemParameter(id,d->id());
 
1840
            pAction = m_pImportPopup->addAction(d->visibleName());
 
1841
        pAction->setData(d->id());
1843
1842
        }
1844
1843
}
1845
1844
 
1846
 
void OptionsWidget_servers::importPopupActivated(int id)
 
1845
void OptionsWidget_servers::importPopupActivated(QAction *pAction)
1847
1846
{
1848
1847
        // ensure that we have all the modules : they could have been unloaded while the popup was displayed
1849
1848
        g_pModuleManager->loadModulesByCaps("serverimport");
1866
1865
                m_pImportFilter = 0;
1867
1866
        }
1868
1867
 
1869
 
        id = m_pImportPopup->itemParameter(id);
 
1868
    bool bOk=false;
 
1869
    int id = pAction->data().toInt(&bOk);
 
1870
    if(!bOk)
 
1871
        return;
1870
1872
 
1871
1873
        m_pImportFilter = (KviMexServerImport *)KviModuleExtensionManager::instance()->allocateExtension("serverimport",id,0);
1872
1874
 
1993
1995
                        IrcServerOptionsTreeWidgetItem * it = new IrcServerOptionsTreeWidgetItem(net,
1994
1996
                                                        *(g_pIconManager->getSmallIcon(KviIconManager::Server)),m_pClipboard);
1995
1997
 
 
1998
                        it->m_pServerData->generateUniqueId(); // FIXME: This isn't necessairly unique...
 
1999
 
1996
2000
                        net->setExpanded(true);
1997
2001
 
1998
2002
                        it->setSelected(true);