📄 settingssub.cxx
字号:
//// The contents of this file are subject to the Mozilla Public License// Version 1.0 (the "License"); you may not use this file except in// compliance with the License. You may obtain a copy of the License at// http://www.mozilla.org/MPL/// // Software distributed under the License is distributed on an "AS IS"// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See// the License for the specific language governing rights and limitations// under the License.// // The Original Code is CPhone, a cross platform voip gui.//// The Initial Developer of the Original Code is Derek Smithies.//// Copyright (C) 2002 Indranet Technologies Ltd, // http://www.indranet-technologies.com// All Rights Reserved.//// Contributor(s): _______________/* * * $Log: settingsSub.cxx,v $ * Revision 1.5 2003/05/09 04:34:46 dereksmithies * Tidy up gatekeeper finding. Works reliably. * * Revision 1.4 2003/05/09 03:08:24 dereksmithies * Fix Microtelco handling, and message display * * Revision 1.3 2003/05/06 22:40:36 dereksmithies * Fixes to get it working correctly on microtelco. * * Revision 1.2 2003/04/04 04:37:49 dereksmithies * Major upgrade. * Ixj & microtelco support added. Fix threading issues. * * Revision 1.1.1.1 2002/05/12 22:55:05 dereksmithies * Initial release. * * * * */#include <ptlib.h>#include <qapplication.h>#include <qcheckbox.h>#include <qlineedit.h>#include <qlistview.h>#include <qobjcoll.h>#include <qpushbutton.h>#include <qradiobutton.h>#include <qslider.h>#include <qspinbox.h>#include "settingsSub.h"#include "cpendpoint.h"#include "message.h"#include "vdisplay.h"#define CUSTOM_EVENT_SETUP (QEvent::User + 1)#define CUSTOM_EVENT_FAIL_MT (QEvent::User + 2)/* * Constructs a Settings which is a child of 'parent', with the * name 'name' and widget flags set to 'f' * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */Settings::Settings(ConnectOptions & co) : FormConnectionSettings( 0, "Settings", FALSE, WDestructiveClose), connectOpts(co){ move(300, 300); controlsSet = FALSE; CPhone::Current().SetWindowId(eSettings, winId()); QApplication::postEvent(this, new QCustomEvent(CUSTOM_EVENT_SETUP));}/* * Destroys the object and frees any allocated resources */Settings::~Settings(){}void Settings::Setup(){ InitialiseCodecSettings(); CheckBoxAutoAnswer->setChecked(connectOpts.autoAnswer); CheckBoxDisableFastStart->setChecked(connectOpts.noFastStart); CheckBoxDisableH245Tunnel->setChecked(connectOpts.noH245Tunnelling); CheckBoxDefaultAudio->setChecked(connectOpts.useDefaultAudioBandwidth); CheckBoxDefaultVideo->setChecked(connectOpts.useDefaultVideoBandwidth); SpinBoxFramesEthernetPacket->setValue(connectOpts.packetUtilization); SpinBoxBandwidthAudio->setValue(connectOpts.audioBandwidth); SpinBoxBandwidthVideo->setValue(connectOpts.videoBandwidth); LineEditGatekeeper->setText((const char *)connectOpts.gatekeeperName.GetPointer()); LineEditGatekeeper->setEnabled(!connectOpts.searchForGatekeeper); LineEditUserName->setText((const char *)connectOpts.userName.GetPointer()); PushButtonNatTraversal->setDown(connectOpts.doNatTraversal); LineEditNatTraversal->setText((const char *)connectOpts.externalNatAddress.GetPointer()); PushButtonEnableMicroTelco->setDown(connectOpts.doMicroTelco); LineEditMicroTelcoAccount->setText((const char *)connectOpts.microTelcoAccount.GetPointer()); LineEditMicroTelcoPassword->setText((const char *)connectOpts.microTelcoPassword.GetPointer()); SpinBoxLowUdp->setValue(connectOpts.lowUdpPort); SpinBoxHighUdp->setValue(connectOpts.highUdpPort); CheckBoxSearchForAGatekeeper->setChecked(connectOpts.searchForGatekeeper); ///// controlsSet = TRUE; UpdateCurrentGatekeeperText(); UpdateMicroTelcoText(); CheckBoxDefaultVideoBandwidth_slot(); //Update spinboxes to reflect CheckBoxDefaultAudioBandwidth_slot(); //status of them being enabled. BOOL inACall = !CPhone::GetUi().WaitingForACall(); OnConnectionEstablished(inACall); PushButtonNatTraversal_Slot(); //Update text on toggle button.}void Settings::closeEvent(QCloseEvent *e){ CPhone::Current().ForgetExists(eSettings, winId()); e->accept();}void Settings::InitialiseCodecSettings(){ ListViewActiveCodecs->setSorting(-1); ListViewActiveCodecs->setColumnWidthMode(0, QListView::Maximum); ListViewDormantCodecs->setSorting(-1); ListViewDormantCodecs->setColumnWidthMode(0, QListView::Maximum); PStringList activeCodecs = connectOpts.GetEnabledCapabilities(); PStringList dormantCodecs = connectOpts.GetDisabledCapabilities(); PINDEX i; for(i=0; i < activeCodecs.GetSize(); i++) AddItemToList(ListViewActiveCodecs, activeCodecs[i]); for(i=0; i < dormantCodecs.GetSize(); i++) AddItemToList(ListViewDormantCodecs, dormantCodecs[i]);}void Settings::AddItemToList(QListView *srcList, PString label){ QListViewItem *lastItem = srcList->firstChild(); if (lastItem != NULL) { QListViewItem *lead = lastItem->nextSibling(); while (lead != NULL) { lastItem = lead; lead = lead->nextSibling(); } } QListViewItem *item; if(lastItem == NULL) item = new QListViewItem(srcList); else item = new QListViewItem(srcList, lastItem); item->setText( 0, label.GetPointer() );} BOOL Settings::isNameInCodecList(PString name, QListView *srcList){ QListViewItem *item = srcList->firstChild(); while (item != NULL) { if (item->text(0).compare(name.GetPointer()) == 0) return TRUE; item = item->nextSibling(); } return FALSE;}//Remove all the old codec kesy in the PConfig structure. Put new ones //in. The order of insertion is important, as it determines the //priority ranking of the codec.void Settings::SaveCodecSettings(){ PStringList dormantCodecs; PStringList activeCodecs; QListViewItem *item = ListViewActiveCodecs->firstChild(); while (item != NULL) { activeCodecs.AppendString((const char *)item->text(0)); item = item->nextSibling(); } connectOpts.SetEnabledCapabilities(activeCodecs); CPhone::GetUi().RebuildCapabilityTable();}void Settings::MakeCodecActive_slot(){ QListViewItem *next; QListViewItem *item = ListViewDormantCodecs->firstChild(); while (item != NULL) { next = item->nextSibling(); if(item->isSelected()) { QString codecName = item->text(0); delete item; AddItemToList(ListViewActiveCodecs, PString((const char *)codecName)); } item = next; } SaveCodecSettings();}void Settings::MakeCodecDormant_slot(){ QListViewItem *next; QListViewItem *item = ListViewActiveCodecs->firstChild(); while (item != NULL) { next = item->nextSibling(); if(item->isSelected()) { QString codecName = item->text(0); delete item; AddItemToList(ListViewDormantCodecs, PString((const char *)codecName)); } item = next; } SaveCodecSettings();}void Settings::MoveCodecUp_slot(){ PStringList list = GetSelectedCapabilities(); if (list.GetSize() == 0) return; //First check that we can move everything down; QListViewItem *thisCodec,*parentCodec,*grandParentCodec; thisCodec = FindThisCodec(QString((const char *)list[0])); if(thisCodec->itemAbove() == NULL) { return; } //We can move all items up. for(PINDEX i= 0; i < list.GetSize(); i++) { thisCodec = FindThisCodec(QString((const char *)list[i])); if(thisCodec == NULL) return; parentCodec = thisCodec->itemAbove(); if(parentCodec == NULL) return; grandParentCodec = parentCodec->itemAbove(); if(grandParentCodec == NULL) { thisCodec->moveItem(ListViewActiveCodecs->firstChild()); ListViewActiveCodecs->firstChild()->moveItem(thisCodec); } else thisCodec->moveItem(grandParentCodec); } SaveCodecSettings();}void Settings::MoveCodecDown_slot(){ PStringList list = GetSelectedCapabilities(); if (list.GetSize() == 0) return; //First check that we can move everything down; QListViewItem *thisCodec; thisCodec = FindThisCodec(QString((const char *)list[list.GetSize()-1])); if(thisCodec == NULL) return; if(thisCodec->nextSibling() == NULL) return; //We can move all items down. for(unsigned int i= list.GetSize(); i>0; i--) { thisCodec = FindThisCodec(QString((const char *)list[i-1])); if(thisCodec == NULL) return; thisCodec->moveItem(thisCodec->nextSibling()); } SaveCodecSettings();}PStringList Settings::GetSelectedCapabilities(){ PStringList list; QListViewItem *item = ListViewActiveCodecs->firstChild(); while (item != NULL) { if(item->isSelected()) list.AppendString(PString((const char *)item->text(0))); item = item->nextSibling(); } return list;}QListViewItem * Settings::FindThisCodec(QString sourceCodec) { QListViewItem *thisCodec = ListViewActiveCodecs->firstChild(); while (thisCodec != NULL) { if (thisCodec->text(0) == sourceCodec) { return thisCodec;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -