This commit is contained in:
Jérémy Quentin
2009-07-22 18:28:20 -04:00
parent c613547eea
commit ba7afd3f9a
9 changed files with 275 additions and 189 deletions

View File

@ -79,6 +79,7 @@ SFLPhoneView::SFLPhoneView(QWidget *parent)
}
accountList = new AccountList(false);
accountList->updateAccounts();
configDialog = new ConfigurationDialog(this);
configDialog->setObjectName("configDialog");
@ -87,6 +88,12 @@ SFLPhoneView::SFLPhoneView(QWidget *parent)
wizard = new AccountWizard(this);
wizard->setModal(false);
QPalette pal = QPalette(palette());
pal.setColor(QPalette::AlternateBase, Qt::lightGray);
setPalette(pal);
stackedWidget_screen->setCurrentWidget(page_callList);
connect(&callManager, SIGNAL(callStateChanged(const QString &, const QString &)),
this, SLOT(on1_callStateChanged(const QString &, const QString &)));
connect(&callManager, SIGNAL(incomingCall(const QString &, const QString &, const QString &)),
@ -112,14 +119,6 @@ SFLPhoneView::SFLPhoneView(QWidget *parent)
connect(accountList, SIGNAL(accountListUpdated()),
this, SLOT(updateWindowCallState()));
accountList->updateAccounts();
QPalette pal = QPalette(palette());
pal.setColor(QPalette::AlternateBase, Qt::lightGray);
setPalette(pal);
stackedWidget_screen->setCurrentWidget(page_callList);
}
@ -130,7 +129,7 @@ SFLPhoneView::~SFLPhoneView()
void SFLPhoneView::loadWindow()
{
qDebug() << "loadWindow";
qDebug() << "\nloadWindow";
updateWindowCallState();
updateRecordButton();
updateVolumeButton();
@ -142,6 +141,7 @@ void SFLPhoneView::loadWindow()
updateAddressBookEnabled();
updateAddressBook();
updateStatusMessage();
qDebug() << "Finished loadWindow\n";
}
Account * SFLPhoneView::accountInUse()
@ -633,6 +633,7 @@ void SFLPhoneView::updateAddressBook()
{
if(loadAddressBook())
{
qDebug() << "add loaded";
QString textSearched = lineEdit_addressBook->text();
if(textSearched.isEmpty())
{
@ -652,7 +653,7 @@ void SFLPhoneView::updateAddressBook()
}
else
{
lineEdit_addressBook->setText(i18n("Address book loading..."));
lineEdit_addressBook->setClickMessage(i18n("Address book loading..."));
lineEdit_addressBook->setEnabled(false);
label_addressBookFull->setVisible(false);
}
@ -662,7 +663,6 @@ void SFLPhoneView::updateAddressBook()
void SFLPhoneView::alternateColors(QListWidget * listWidget)
{
qDebug() << "alternateColors";
for(int i = 0 ; i < listWidget->count(); i++)
{
QListWidgetItem* item = listWidget->item(i);
@ -1350,7 +1350,7 @@ void SFLPhoneView::on1_volumeChanged(const QString & /*device*/, double value)
void SFLPhoneView::enableAddressBook()
{
qDebug() << "\nenableAddressBook\n";
lineEdit_addressBook->clear();
lineEdit_addressBook->setClickMessage(QString());
lineEdit_addressBook->setEnabled(true);
AddressBook * ab = StdAddressBook::self(true);
disconnect(ab, SIGNAL(addressBookChanged(AddressBook *)),
@ -1376,8 +1376,10 @@ bool SFLPhoneView::loadAddressBook()
void SFLPhoneView::updateAddressBookEnabled()
{
emit addressBookEnableAsked(isAddressBookEnabled());
if(! isAddressBookEnabled() && stackedWidget_screen->currentWidget() == page_addressBook)
qDebug() << "updateAddressBookEnabled";
bool enabled = isAddressBookEnabled();
emit addressBookEnableAsked(enabled);
if(! enabled && stackedWidget_screen->currentWidget() == page_addressBook)
{
changeScreen(SCREEN_MAIN);
}
@ -1393,6 +1395,7 @@ bool SFLPhoneView::isAddressBookEnabled()
void SFLPhoneView::changeScreen(int screen)
{
qDebug() << "changeScreen";
switch(screen)
{
case SCREEN_MAIN:

View File

@ -66,34 +66,37 @@ ConfigurationDialog::~ConfigurationDialog()
void ConfigurationDialog::updateWidgets()
{
qDebug() << "updateWidgets";
qDebug() << "\nupdateWidgets";
dlgAudio->updateWidgets();
dlgAccounts->updateWidgets();
}
void ConfigurationDialog::updateSettings()
{
qDebug() << "updateSettings";
qDebug() << "\nupdateSettings";
dlgAudio->updateSettings();
dlgAccounts->updateSettings();
qDebug() << "alsaPlugin = " << ConfigurationSkeleton::self()->alsaPlugin();
}
bool ConfigurationDialog::hasChanged()
{
qDebug() << "hasChanged" << dlgAudio->hasChanged() << dlgAccounts->hasChanged();
return dlgAudio->hasChanged() || dlgAccounts->hasChanged();
bool res = dlgAudio->hasChanged() || dlgAccounts->hasChanged();
qDebug() << "hasChanged" << res;
return res;
}
void ConfigurationDialog::updateButtons()
{
qDebug() << "updateButtons";
enableButtonApply( hasChanged() );
bool changed = hasChanged();
qDebug() << "updateButtons , hasChanged = " << changed;
// if(hasChanged())
// enableButtonApply( true );
enableButtonApply( changed );
}
void ConfigurationDialog::applyCustomSettings()
{
qDebug() << "applyCustomSettings";
qDebug() << "\napplyCustomSettings";
// if(hasChanged())
// {
ConfigurationSkeleton::self()->writeConfig();

View File

@ -81,16 +81,16 @@ public slots:
*/
void updateSettings();
/**
* Should be implemented in KConfigDialog but for no reason, is not.
* For the moment it is here but has to be removed if implemented in KConfigDialog
* because causes problems for a few cases (item managed by kconfig switched, item not managed
* Is implemented in KConfigDialog only from KDE4.3
* It it implemented here for KDE4.2 users.
* I didn't test with KDE4.3 so I leave it even for 4.3 users.
* Causes problems for a few cases (item managed by kconfig switched, item not managed
* switched and then switched back, apply becomes disabled).
* Can't be resolved without a method to know if items managed by kconfig have changed.
* Disable/Enable Apply Button according to hasChanged() result
*/
void updateButtons();
/**
* Same as updateButtons, should be implemented in KConfigDialog.
* @return whether any custom widget has changed in the dialog.
*/
bool hasChanged();

View File

@ -206,13 +206,13 @@ void ConfigurationSkeleton::writeConfig()
qDebug() << "Writing Display settings";
//Notification settings
if(notifOnCalls() != configurationManager.getNotify()) configurationManager.setNotify();
if(notifOnMessages() != configurationManager.getMailNotify()) configurationManager.setMailNotify();
// if(notifOnCalls() != configurationManager.getNotify()) configurationManager.setNotify();
// if(notifOnMessages() != configurationManager.getMailNotify()) configurationManager.setMailNotify();
//Window display settings
//WARNING états inversés
if(displayOnStart() == configurationManager.isStartHidden()) configurationManager.startHidden();
if(displayOnCalls() != configurationManager.popupMode()) configurationManager.switchPopupMode();
// if(displayOnStart() == configurationManager.isStartHidden()) configurationManager.startHidden();
// if(displayOnCalls() != configurationManager.popupMode()) configurationManager.switchPopupMode();
/////////////////////////
////Accounts settings////
@ -224,8 +224,8 @@ void ConfigurationSkeleton::writeConfig()
//Stun settings
if(enableStun() != configurationManager.isStunEnabled()) configurationManager.enableStun();
configurationManager.setStunServer(stunServer());
// if(enableStun() != configurationManager.isStunEnabled()) configurationManager.enableStun();
// configurationManager.setStunServer(stunServer());
//////////////////////
////Audio settings////

View File

@ -54,6 +54,8 @@ DlgAccounts::DlgAccounts(KConfigDialog *parent)
this, SLOT(changedAccountList()));
connect(edit6_mailbox, SIGNAL(textEdited(const QString &)),
this, SLOT(changedAccountList()));
connect(checkBox_conformRFC, SIGNAL(stateChanged(int)),
this, SLOT(changedAccountList()));
connect(button_accountUp, SIGNAL(clicked()),
this, SLOT(changedAccountList()));
connect(button_accountDown, SIGNAL(clicked()),
@ -72,6 +74,7 @@ DlgAccounts::DlgAccounts(KConfigDialog *parent)
void DlgAccounts::saveAccountList()
{
qDebug() << "saveAccountList";
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
disconnectAccountsChangedSignal();
//save the account being edited
@ -119,16 +122,18 @@ void DlgAccounts::saveAccountList()
void DlgAccounts::connectAccountsChangedSignal()
{
qDebug() << "connectAccountsChangedSignal";
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
connect(&configurationManager, SIGNAL(accountsChanged()),
this, SLOT(on1_accountsChanged()));
this, SLOT(updateAccountStates()));
}
void DlgAccounts::disconnectAccountsChangedSignal()
{
qDebug() << "disconnectAccountsChangedSignal";
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
disconnect(&configurationManager, SIGNAL(accountsChanged()),
this, SLOT(on1_accountsChanged()));
this, SLOT(updateAccountStates()));
}
@ -146,6 +151,8 @@ void DlgAccounts::saveAccount(QListWidgetItem * item)
account->setAccountDetail(ACCOUNT_USERNAME, edit4_user->text());
account->setAccountDetail(ACCOUNT_PASSWORD, edit5_password->text());
account->setAccountDetail(ACCOUNT_MAILBOX, edit6_mailbox->text());
account->setAccountDetail(ACCOUNT_RESOLVE_ONCE, checkBox_conformRFC->isChecked() ? "FALSE" : "TRUE");
account->setAccountDetail(ACCOUNT_EXPIRE, QString::number(spinbox_regExpire->value()));
account->setAccountDetail(ACCOUNT_ENABLED, account->isChecked() ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE);
}
@ -173,8 +180,10 @@ void DlgAccounts::loadAccount(QListWidgetItem * item)
edit4_user->setText( account->getAccountDetail(ACCOUNT_USERNAME));
edit5_password->setText( account->getAccountDetail(ACCOUNT_PASSWORD));
edit6_mailbox->setText( account->getAccountDetail(ACCOUNT_MAILBOX));
QString status = account->getAccountDetail(ACCOUNT_STATUS);
edit7_state->setText( "<FONT COLOR=\"" + account->getStateColorName() + "\">" + status + "</FONT>" );
checkBox_conformRFC->setChecked( account->getAccountDetail(ACCOUNT_RESOLVE_ONCE) != "TRUE" );
int val = account->getAccountDetail(ACCOUNT_EXPIRE).toInt();
spinbox_regExpire->setValue(val);
updateStatusLabel(account);
frame2_editAccounts->setEnabled(true);
}
@ -208,7 +217,7 @@ void DlgAccounts::changedAccountList()
qDebug() << "changedAccountList";
accountListHasChanged = true;
emit updateButtons();
toolButton_accountsApply->setEnabled(hasChanged());
toolButton_accountsApply->setEnabled(true);
}
@ -317,34 +326,54 @@ void DlgAccounts::updateAccountListCommands()
void DlgAccounts::updateAccountStates()
{
qDebug() << "updateAccountStates";
qDebug() << accountList->size();
for (int i = 0; i < accountList->size(); i++)
{
Account * current = accountList->getAccountAt(i);
current->updateState();
}
qDebug() << accountList->size();
updateStatusLabel(listWidget_accountList->currentItem());
}
void DlgAccounts::updateStatusLabel(QListWidgetItem * item)
{
if(! item ) { return; }
Account * account = accountList->getAccountByItem(item);
updateStatusLabel(account);
}
void DlgAccounts::updateStatusLabel(Account * account)
{
if(! account ) { return; }
QString status = account->getAccountDetail(ACCOUNT_STATUS);
edit7_state->setText( "<FONT COLOR=\"" + account->getStateColorName() + "\">" + status + "</FONT>" );
}
bool DlgAccounts::hasChanged()
{
// qDebug() << "DlgAudio::hasChanged";
return accountListHasChanged;
bool res = accountListHasChanged;
qDebug() << "DlgAccounts::hasChanged " << res;
return res;
}
void DlgAccounts::updateSettings()
{
saveAccountList();
toolButton_accountsApply->setEnabled(false);
accountListHasChanged = false;
if(accountListHasChanged)
{
saveAccountList();
toolButton_accountsApply->setEnabled(false);
accountListHasChanged = false;
}
}
void DlgAccounts::updateWidgets()
{
loadAccountList();
toolButton_accountsApply->setEnabled(false);
accountListHasChanged = false;
qDebug() << "DlgAccounts::updateWidgets";
if(accountListHasChanged)
{
loadAccountList();
toolButton_accountsApply->setEnabled(false);
accountListHasChanged = false;
}
}

View File

@ -66,6 +66,8 @@ private slots:
void updateAccountStates();
void addAccountToAccountList(Account * account);
void updateAccountListCommands();
void updateStatusLabel(QListWidgetItem * item);
void updateStatusLabel(Account * account);
signals:

View File

@ -229,154 +229,196 @@
</widget>
</item>
<item>
<widget class="QFrame" name="frame2_editAccounts">
<widget class="QTabWidget" name="frame2_editAccounts">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
<property name="currentIndex">
<number>0</number>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label1_alias">
<property name="text">
<string>Alias</string>
</property>
<property name="buddy">
<cstring>edit1_alias</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="edit1_alias">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label2_protocol">
<property name="text">
<string>Protocol</string>
</property>
<property name="buddy">
<cstring>edit2_protocol</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="edit2_protocol">
<item>
<widget class="QWidget" name="tab_basic">
<attribute name="title">
<string>Basic</string>
</attribute>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label1_alias">
<property name="text">
<string>SIP</string>
<string>Alias</string>
</property>
</item>
<item>
<property name="buddy">
<cstring>edit1_alias</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="edit1_alias">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label2_protocol">
<property name="text">
<string>IAX</string>
<string>Protocol</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label3_server">
<property name="text">
<string>Server</string>
</property>
<property name="buddy">
<cstring>edit3_server</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="edit3_server">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label4_user">
<property name="text">
<string>Username</string>
</property>
<property name="buddy">
<cstring>edit4_user</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="edit4_user"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label5_password">
<property name="text">
<string>Password</string>
</property>
<property name="buddy">
<cstring>edit5_password</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="edit5_password">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label6_mailbox">
<property name="text">
<string>Voicemail</string>
</property>
<property name="buddy">
<cstring>edit6_mailbox</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="edit6_mailbox"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label7_state">
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="edit7_state">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
<property name="buddy">
<cstring>edit2_protocol</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="edit2_protocol">
<item>
<property name="text">
<string>SIP</string>
</property>
</item>
<item>
<property name="text">
<string>IAX</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label3_server">
<property name="text">
<string>Server</string>
</property>
<property name="buddy">
<cstring>edit3_server</cstring>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="edit3_server">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label4_user">
<property name="text">
<string>Username</string>
</property>
<property name="buddy">
<cstring>edit4_user</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="edit4_user"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label5_password">
<property name="text">
<string>Password</string>
</property>
<property name="buddy">
<cstring>edit5_password</cstring>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="edit5_password">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label6_mailbox">
<property name="text">
<string>Voicemail</string>
</property>
<property name="buddy">
<cstring>edit6_mailbox</cstring>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="edit6_mailbox"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label7_state">
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="edit7_state">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_advanced">
<attribute name="title">
<string>Advanced</string>
</attribute>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_regExpire">
<property name="text">
<string>Registration expire</string>
</property>
<property name="buddy">
<cstring>spinbox_regExpire</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KIntSpinBox" name="spinbox_regExpire">
<property name="maximum">
<number>16777215</number>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox_conformRFC">
<property name="text">
<string>Conform to RFC 3263</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
@ -437,6 +479,11 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>
<header>knuminput.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>

View File

@ -44,7 +44,7 @@ DlgAudio::DlgAudio(KConfigDialog *parent)
sortableCodecList->setModel(model);
// loadAlsaSettings();
connect(box_alsaPlugin, SIGNAL(currentIndexChanged(int)),
connect(box_alsaPlugin, SIGNAL(activated(int)),
parent, SLOT(updateButtons()));
connect(this, SIGNAL(updateButtons()),
@ -63,7 +63,7 @@ DlgAudio::~DlgAudio()
void DlgAudio::updateWidgets()
{
ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self();
box_alsaPlugin->setCurrentIndex(box_alsaPlugin->findText(skeleton->alsaPlugin()));
// box_alsaPlugin->setCurrentIndex(box_alsaPlugin->findText(skeleton->alsaPlugin()));
loadAlsaSettings();
codecTableHasChanged = false;
@ -89,7 +89,7 @@ bool DlgAudio::hasChanged()
bool alsaPluginHasChanged =
skeleton->interface() == ConfigurationSkeleton::EnumInterface::ALSA
&& skeleton->alsaPlugin() != box_alsaPlugin->currentText();
qDebug() << alsaPluginHasChanged << codecTableHasChanged;
qDebug() << "DlgAudio::hasChanged" << alsaPluginHasChanged << codecTableHasChanged;
return alsaPluginHasChanged || codecTableHasChanged;
}
@ -127,6 +127,7 @@ void DlgAudio::loadAlsaSettings()
void DlgAudio::codecTableChanged()
{
qDebug() << "codecTableChanged";
codecTableHasChanged = true;
emit updateButtons();
}

View File

@ -20,7 +20,6 @@
#ifndef __SFLPHONE_CONST_H
#define __SFLPHONE_CONST_H
#include <libintl.h>
#include <QtCore/QString>
/* @file sflphone_const.h
@ -115,6 +114,8 @@
#define ACCOUNT_ENABLED "Account.enable"
#define ACCOUNT_MAILBOX "Account.mailbox"
#define ACCOUNT_HOSTNAME "hostname"
#define ACCOUNT_RESOLVE_ONCE "Account.resolveOnce"
#define ACCOUNT_EXPIRE "Account.expire"
#define ACCOUNT_USERNAME "username"
#define ACCOUNT_PASSWORD "password"
#define ACCOUNT_STATUS "Status"