New Config Dialog integrated in GUI.(without codecs)

This commit is contained in:
Jérémy Quentin
2009-06-30 11:01:52 -04:00
parent 04fe5e2e09
commit 26bf3c245f
12 changed files with 128 additions and 91 deletions

View File

@ -32,8 +32,8 @@
<Action name="action_displayVolumeControls" />
<Action name="action_displayDialpad" />
<Separator />
<Action name="action_configureAccounts" />
<Action name="action_configureAudio" />
<!-- <Action name="action_configureAccounts" /> -->
<!-- <Action name="action_configureAudio" /> -->
<Action name="action_configureSflPhone" />
<Separator />
<Action name="action_accountCreationWizard" />

View File

@ -24,7 +24,6 @@
#include "configurationmanager_interface_singleton.h"
QString AccountList::firstAccount = QString();
//Constructors
@ -131,11 +130,6 @@ QVector<Account *> AccountList::registeredAccounts() const
Account * AccountList::firstRegisteredAccount() const
{
Account * first = getAccountById(firstAccount);
if(first && (first->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED))
{
return first;
}
Account * current;
for (int i = 0; i < accounts->count(); ++i){
current = (*accounts)[i];
@ -147,10 +141,6 @@ Account * AccountList::firstRegisteredAccount() const
return NULL;
}
void AccountList::setAccountFirst(Account * account)
{
firstAccount = account->getAccountId();
}
AccountList::~AccountList()
{
@ -175,6 +165,8 @@ Account & AccountList::getAccount (int i)
Account * AccountList::getAccountById(const QString & id) const
{
if(id.isEmpty())
{ return NULL; }
for (int i = 0; i < accounts->size(); ++i)
{
if (!(*accounts)[i]->isNew() && (*accounts)[i]->getAccountId() == id)

View File

@ -34,7 +34,6 @@ class AccountList : public QObject{
private:
QVector<Account *> * accounts;
static QString firstAccount;
public:
@ -58,7 +57,6 @@ public:
Account * addAccount(QString & alias);
void removeAccount(Account * account);
void removeAccount(QListWidgetItem * item);
void setAccountFirst(Account * account);
void upAccount(int index);
void downAccount(int index);

View File

@ -575,7 +575,7 @@ void Call::call()
if(account.isEmpty())
{
qDebug() << "account is empty";
this->account = sflphone_kdeView::firstAccountId();
this->account = sflphone_kdeView::firstRegisteredAccount()->getAccountId();
}
if(!account.isEmpty())
{

View File

@ -70,8 +70,6 @@ void ConfigurationDialogKDE::slot()
qDebug() << "slot";
}
void ConfigurationDialogKDE::updateWidgets()
{
qDebug() << "updateWidgets";
@ -87,9 +85,8 @@ void ConfigurationDialogKDE::updateSettings()
bool ConfigurationDialogKDE::hasChanged()
{
qDebug() << "hasChanged = " << dlgAudio->hasChanged();
return dlgAudio->hasChanged();
qDebug() << "hasChanged";
return dlgAudio->hasChanged() || dlgAccounts->hasChanged();
}
void ConfigurationDialogKDE::updateButtons()
@ -100,10 +97,18 @@ void ConfigurationDialogKDE::updateButtons()
void ConfigurationDialogKDE::applyCustomSettings()
{
qDebug() << "updateButtons";
qDebug() << "applyCustomSettings";
dlgAccounts->applyCustomSettings();
// if(hasChanged())
// {
ConfigurationSkeleton::self()->writeConfig();
// }
updateButtons();
}
void ConfigurationDialogKDE::reload()
{
qDebug() << "reload";
ConfigurationSkeleton::self()->readConfig();
updateWidgets();
}

View File

@ -38,6 +38,8 @@ class DlgAddressBook;
class DlgRecord;
class DlgHooks;
class sflphone_kdeView;
/**
@author Jérémy Quentin <jeremy.quentin@gmail.com>
*/
@ -65,9 +67,21 @@ public slots:
void slot();
void updateWidgets();
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
* switched and then switched back, apply becomes disabled).
* Can't be resolved without a method to know if items managed by kconfig have changed.
*/
void updateButtons();
bool hasChanged();
/**
* reloads the informations before showing it.
*/
void reload();
private slots:
void applyCustomSettings();

View File

@ -23,20 +23,22 @@
#include <QtGui/QInputDialog>
#include "configurationmanager_interface_singleton.h"
#include "AccountList.h"
#include "sflphone_kdeview.h"
#include "sflphone_const.h"
#include "conf/ConfigurationDialog.h"
DlgAccounts::DlgAccounts(QWidget *parent)
DlgAccounts::DlgAccounts(KConfigDialog *parent)
: QWidget(parent)
{
setupUi(this);
AccountList * accountList = sflphone_kdeView::getAccountList();
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
QStyle * style = QApplication::style();
button_accountUp->setIcon(style->standardIcon(QStyle::SP_ArrowUp));
button_accountDown->setIcon(style->standardIcon(QStyle::SP_ArrowDown));
loadAccountList();
accountListHasChanged = false;
toolButton_accountsApply->setEnabled(false);
connect(edit1_alias, SIGNAL(textEdited(const QString &)),
this, SLOT(changedAccountList()));
@ -59,8 +61,11 @@ DlgAccounts::DlgAccounts(QWidget *parent)
connect(button_accountRemove, SIGNAL(clicked()),
this, SLOT(changedAccountList()));
connect(accountList, SIGNAL(accountListUpdated()),
connect(&configurationManager, SIGNAL(accountsChanged()),
this, SLOT(updateAccountStates()));
connect(this, SIGNAL(updateButtons()), parent, SLOT(updateButtons()));
}
@ -71,7 +76,6 @@ DlgAccounts::~DlgAccounts()
void DlgAccounts::saveAccountList()
{
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
AccountList * accountList = sflphone_kdeView::getAccountList();
disconnectAccountsChangedSignal();
//save the account being edited
if(listWidget_accountList->currentItem())
@ -134,7 +138,6 @@ void DlgAccounts::disconnectAccountsChangedSignal()
void DlgAccounts::saveAccount(QListWidgetItem * item)
{
AccountList * accountList = sflphone_kdeView::getAccountList();
if(! item) { qDebug() << "Attempting to save details of an account from a NULL item"; return; }
Account * account = accountList->getAccountByItem(item);
@ -152,7 +155,6 @@ void DlgAccounts::saveAccount(QListWidgetItem * item)
void DlgAccounts::loadAccount(QListWidgetItem * item)
{
AccountList * accountList = sflphone_kdeView::getAccountList();
if(! item ) { qDebug() << "Attempting to load details of an account from a NULL item"; return; }
Account * account = accountList->getAccountByItem(item);
@ -183,8 +185,7 @@ void DlgAccounts::loadAccount(QListWidgetItem * item)
void DlgAccounts::loadAccountList()
{
qDebug() << "loadAccountList";
AccountList * accountList = sflphone_kdeView::getAccountList();
accountList->updateAccounts();
accountList = new AccountList();
//initialize the QListWidget object with the AccountList
listWidget_accountList->clear();
for (int i = 0; i < accountList->size(); ++i){
@ -211,15 +212,17 @@ void DlgAccounts::addAccountToAccountList(Account * account)
void DlgAccounts::changedAccountList()
{
toolButton_accountsApply->setEnabled(true);
accountListHasChanged = true;
// ((ConfigurationDialogKDE *)parent())->updateButtons();
emit updateButtons();
toolButton_accountsApply->setEnabled(hasChanged());
}
void DlgAccounts::on_listWidget_accountList_currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous )
{
qDebug() << "on_listWidget_accountList_currentItemChanged";
AccountList * accountList = sflphone_kdeView::getAccountList();
qDebug() << "on_listWidget_accountList_currentItemChanged";
if(previous)
saveAccount(previous);
if(current)
@ -230,7 +233,6 @@ void DlgAccounts::on_listWidget_accountList_currentItemChanged ( QListWidgetItem
void DlgAccounts::on_button_accountUp_clicked()
{
qDebug() << "on_button_accountUp_clicked";
AccountList * accountList = sflphone_kdeView::getAccountList();
int currentRow = listWidget_accountList->currentRow();
QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow);
Account * account = accountList->getAccountByItem(prevItem);
@ -248,7 +250,6 @@ void DlgAccounts::on_button_accountUp_clicked()
void DlgAccounts::on_button_accountDown_clicked()
{
qDebug() << "on_button_accountDown_clicked";
AccountList * accountList = sflphone_kdeView::getAccountList();
int currentRow = listWidget_accountList->currentRow();
QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow);
Account * account = accountList->getAccountByItem(prevItem);
@ -265,7 +266,6 @@ void DlgAccounts::on_button_accountDown_clicked()
void DlgAccounts::on_button_accountAdd_clicked()
{
AccountList * accountList = sflphone_kdeView::getAccountList();
qDebug() << "on_button_accountAdd_clicked";
QString itemName = QInputDialog::getText(this, "New account", "Enter new account's alias");
itemName = itemName.simplified();
@ -282,7 +282,6 @@ void DlgAccounts::on_button_accountAdd_clicked()
void DlgAccounts::on_button_accountRemove_clicked()
{
qDebug() << "on_button_accountRemove_clicked";
AccountList * accountList = sflphone_kdeView::getAccountList();
int r = listWidget_accountList->currentRow();
QListWidgetItem * item = listWidget_accountList->takeItem(r);
accountList->removeAccount(item);
@ -293,9 +292,19 @@ void DlgAccounts::on_button_accountRemove_clicked()
void DlgAccounts::on_toolButton_accountsApply_clicked()
{
qDebug() << "on_toolButton_accountsApply_clicked";
toolButton_accountsApply->setEnabled(false);
saveAccountList();
loadAccountList();
applyCustomSettings();
}
void DlgAccounts::applyCustomSettings()
{
qDebug() << "applyCustomSettings";
if(hasChanged())
{
toolButton_accountsApply->setEnabled(false);
saveAccountList();
loadAccountList();
accountListHasChanged = false;
}
}
void DlgAccounts::on_edit1_alias_textChanged(const QString & text)
@ -303,7 +312,6 @@ void DlgAccounts::on_edit1_alias_textChanged(const QString & text)
qDebug() << "on_edit1_alias_textChanged";
AccountItemWidget * widget = (AccountItemWidget *) listWidget_accountList->itemWidget(listWidget_accountList->currentItem());
widget->setAccountText(text);
changedAccountList();
}
void DlgAccounts::updateAccountListCommands()
@ -332,7 +340,6 @@ void DlgAccounts::updateAccountListCommands()
void DlgAccounts::updateAccountStates()
{
qDebug() << "updateAccountStates";
AccountList * accountList = sflphone_kdeView::getAccountList();
qDebug() << accountList->size();
for (int i = 0; i < accountList->size(); i++)
{
@ -342,3 +349,10 @@ void DlgAccounts::updateAccountStates()
qDebug() << accountList->size();
}
bool DlgAccounts::hasChanged()
{
// qDebug() << "DlgAudio::hasChanged";
return accountListHasChanged;
}

View File

@ -22,9 +22,11 @@
#define DLGACCOUNTS_H
#include <QWidget>
#include <kconfigdialog.h>
#include "ui_dlgaccountsbase.h"
#include "Account.h"
#include "AccountList.h"
/**
@author Jérémy Quentin <jeremy.quentin@gmail.com>
@ -33,17 +35,22 @@ class DlgAccounts : public QWidget, public Ui_DlgAccountsBase
{
Q_OBJECT
public:
DlgAccounts(QWidget *parent = 0);
DlgAccounts(KConfigDialog *parent = 0);
~DlgAccounts();
void saveAccount(QListWidgetItem * item);
void loadAccount(QListWidgetItem * item);
private:
AccountList * accountList;
bool accountListHasChanged;
public slots:
void saveAccountList();
void loadAccountList();
void applyCustomSettings();
bool hasChanged();
private slots:
void changedAccountList();
@ -59,6 +66,10 @@ private slots:
void updateAccountStates();
void addAccountToAccountList(Account * account);
void updateAccountListCommands();
signals:
void updateButtons();
};

View File

@ -185,7 +185,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="page1_alsa">
<layout class="QVBoxLayout" name="verticalLayout_20">

View File

@ -67,11 +67,11 @@ int main(int argc, char **argv)
SFLPhone * fenetre = new SFLPhone();
// fenetre->move(QCursor::pos().x() - fenetre->geometry().width()/2, QCursor::pos().y() - fenetre->geometry().height()/2);
// fenetre->show();
fenetre->move(QCursor::pos().x() - fenetre->geometry().width()/2, QCursor::pos().y() - fenetre->geometry().height()/2);
fenetre->show();
ConfigurationDialogKDE * dlg = new ConfigurationDialogKDE(fenetre->getView());
dlg->show();
// ConfigurationDialogKDE * dlg = new ConfigurationDialogKDE(fenetre->getView());
// dlg->show();
return app.exec();
}

View File

@ -49,8 +49,9 @@
using namespace KABC;
ConfigurationDialog * sflphone_kdeView::configDialog;
ConfigurationDialogKDE * sflphone_kdeView::configDialog;
AccountList * sflphone_kdeView::accountList;
QString sflphone_kdeView::priorAccountId;
sflphone_kdeView::sflphone_kdeView(QWidget *parent)
: QWidget(parent)
@ -77,7 +78,7 @@ sflphone_kdeView::sflphone_kdeView(QWidget *parent)
accountList = new AccountList();
configDialog = new ConfigurationDialog(this);
configDialog = new ConfigurationDialogKDE(this);
configDialog->setModal(true);
wizard = new AccountWizard(this);
@ -173,24 +174,23 @@ void sflphone_kdeView::loadWindow()
updateSearchHistory();
}
QString sflphone_kdeView::firstAccountId()
{
Account * firstAccount = getAccountList()->firstRegisteredAccount();
if(firstAccount == NULL)
{
return QString();
}
return firstAccount->getAccountId();
}
QVector<Account *> sflphone_kdeView::registeredAccounts()
{
return getAccountList()->registeredAccounts();
return accountList->registeredAccounts();
}
Account * sflphone_kdeView::firstRegisteredAccount()
{
return getAccountList()->firstRegisteredAccount();
Account * priorAccount = accountList->getAccountById(priorAccountId);
if(priorAccount && priorAccount->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED )
{
return priorAccount;
}
else
{
return accountList->firstRegisteredAccount();
}
}
AccountList * sflphone_kdeView::getAccountList()
@ -1123,6 +1123,7 @@ void sflphone_kdeView::contextMenuEvent(QContextMenuEvent *event)
QVector<Account *> accounts = registeredAccounts();
for (int i = 0 ; i < accounts.size() ; i++)
{
qDebug() << i;
Account * account = accounts.at(i);
QAction * action = new ActionSetAccountFirst(account, &menu);
action->setCheckable(true);
@ -1179,7 +1180,8 @@ void sflphone_kdeView::editBeforeCall()
void sflphone_kdeView::setAccountFirst(Account * account)
{
qDebug() << "setAccountFirst : " << account->getAlias();
getAccountList()->setAccountFirst(account);
// getAccountList()->setAccountFirst(account);
priorAccountId = account->getAccountId();
updateStatusMessage();
}
@ -1195,24 +1197,23 @@ void sflphone_kdeView::on_listWidget_addressBook_currentItemChanged()
updateWindowCallState();
}
void sflphone_kdeView::on_action_configureAccounts_triggered()
{
configDialog->loadOptions();
configDialog->setPage(PAGE_ACCOUNTS);
configDialog->show();
}
// void sflphone_kdeView::on_action_configureAccounts_triggered()
// {
// configDialog->readSettings();
// configDialog->setPage(PAGE_ACCOUNTS);
// configDialog->show();
// }
void sflphone_kdeView::on_action_configureAudio_triggered()
{
configDialog->loadOptions();
configDialog->setPage(PAGE_AUDIO);
configDialog->show();
}
// void sflphone_kdeView::on_action_configureAudio_triggered()
// {
// configDialog->readSettings();
// configDialog->setPage(PAGE_AUDIO);
// configDialog->show();
// }
void sflphone_kdeView::on_action_configureSflPhone_triggered()
{
sflphone_kdeView::configDialog->loadOptions();
configDialog->setPage(PAGE_GENERAL);
configDialog->reload();
configDialog->show();
}
@ -1379,13 +1380,13 @@ void sflphone_kdeView::on_action_addressBook_triggered(bool checked)
void sflphone_kdeView::on_action_mailBox_triggered()
{
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
QString account = firstAccountId();
QString mailBoxNumber = configurationManager.getAccountDetails(account).value()[ACCOUNT_MAILBOX];
Call * call = callList->addDialingCall();
call->appendItemText(mailBoxNumber);
addCallToCallList(call);
listWidget_callList->setCurrentRow(listWidget_callList->count() - 1);
actionb(call, CALL_ACTION_ACCEPT);
Account * account = firstRegisteredAccount();
QString mailBoxNumber = account->getAccountDetail(ACCOUNT_MAILBOX);
Call * call = callList->addDialingCall();
call->appendItemText(mailBoxNumber);
addCallToCallList(call);
listWidget_callList->setCurrentRow(listWidget_callList->count() - 1);
actionb(call, CALL_ACTION_ACCEPT);
}
void sflphone_kdeView::on1_callStateChanged(const QString &callID, const QString &state)

View File

@ -32,15 +32,18 @@
#include <KXmlGuiWindow>
#include "ui_sflphone_kdeview_base.h"
#include "ConfigDialog.h"
#include "conf/ConfigurationDialog.h"
#include "CallList.h"
#include "AccountWizard.h"
#include "Contact.h"
#include "sflphone_kdeview.h"
#include "AccountList.h"
#include "ui_sflphone_kdeview_base.h"
class ConfigurationDialog;
class ConfigurationDialogKDE;
/**
* This is the main view class for sflphone-client-kde. Most of the non-menu,
* non-toolbar, and non-statusbar (e.g., non frame) GUI code should go
@ -50,19 +53,19 @@ class ConfigurationDialog;
* @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>
* @version 0.1
*/
class sflphone_kdeView : public QWidget, public Ui::SFLPhone_view
{
Q_OBJECT
private:
static ConfigurationDialog * configDialog;
static ConfigurationDialogKDE * configDialog;
static AccountList * accountList;
AccountWizard * wizard;
CallList * callList;
QErrorMessage * errorWindow;
//Account used prioritary if defined and registered. If not, the first registered account in accountList is used.
static QString priorAccountId;
protected:
@ -83,7 +86,6 @@ public:
void buildDialPad();
//Getters
static QString firstAccountId();
static Account * firstRegisteredAccount();
static QVector<Account *> registeredAccounts();
static AccountList * getAccountList();
@ -151,8 +153,8 @@ public slots:
void on_action_displayVolumeControls_triggered();
void on_action_displayDialpad_triggered();
void on_action_configureAccounts_triggered();
void on_action_configureAudio_triggered();
// void on_action_configureAccounts_triggered();
// void on_action_configureAudio_triggered();
void on_action_configureSflPhone_triggered();
void on_action_accountCreationWizard_triggered();
void on_action_accept_triggered();