forked from blue/squawk
started to work on settings
This commit is contained in:
parent
62a59eb7a1
commit
6bee149e6b
10 changed files with 260 additions and 2 deletions
|
@ -25,6 +25,7 @@ Squawk::Squawk(QWidget *parent) :
|
|||
QMainWindow(parent),
|
||||
m_ui(new Ui::Squawk),
|
||||
accounts(0),
|
||||
preferences(0),
|
||||
rosterModel(),
|
||||
conversations(),
|
||||
contextMenu(new QMenu()),
|
||||
|
@ -55,6 +56,7 @@ Squawk::Squawk(QWidget *parent) :
|
|||
m_ui->comboBox->setCurrentIndex(static_cast<int>(Shared::Availability::offline));
|
||||
|
||||
connect(m_ui->actionAccounts, &QAction::triggered, this, &Squawk::onAccounts);
|
||||
connect(m_ui->actionPreferences, &QAction::triggered, this, &Squawk::onPreferences);
|
||||
connect(m_ui->actionAddContact, &QAction::triggered, this, &Squawk::onNewContact);
|
||||
connect(m_ui->actionAddConference, &QAction::triggered, this, &Squawk::onNewConference);
|
||||
connect(m_ui->actionQuit, &QAction::triggered, this, &Squawk::close);
|
||||
|
@ -117,6 +119,22 @@ void Squawk::onAccounts()
|
|||
}
|
||||
}
|
||||
|
||||
void Squawk::onPreferences()
|
||||
{
|
||||
if (preferences == 0) {
|
||||
preferences = new Settings();
|
||||
preferences->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(preferences, &Settings::destroyed, this, &Squawk::onPreferencesClosed);
|
||||
|
||||
preferences->show();
|
||||
} else {
|
||||
preferences->show();
|
||||
preferences->raise();
|
||||
preferences->activateWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Squawk::onAccountsSizeChanged(unsigned int size)
|
||||
{
|
||||
if (size > 0) {
|
||||
|
@ -173,6 +191,9 @@ void Squawk::closeEvent(QCloseEvent* event)
|
|||
if (accounts != 0) {
|
||||
accounts->close();
|
||||
}
|
||||
if (preferences != 0) {
|
||||
preferences->close();
|
||||
}
|
||||
|
||||
for (Conversations::const_iterator itr = conversations.begin(), end = conversations.end(); itr != end; ++itr) {
|
||||
disconnect(itr->second, &Conversation::destroyed, this, &Squawk::onConversationClosed);
|
||||
|
@ -190,11 +211,16 @@ void Squawk::closeEvent(QCloseEvent* event)
|
|||
}
|
||||
|
||||
|
||||
void Squawk::onAccountsClosed(QObject* parent)
|
||||
void Squawk::onAccountsClosed()
|
||||
{
|
||||
accounts = 0;
|
||||
}
|
||||
|
||||
void Squawk::onPreferencesClosed()
|
||||
{
|
||||
preferences = 0;
|
||||
}
|
||||
|
||||
void Squawk::newAccount(const QMap<QString, QVariant>& account)
|
||||
{
|
||||
rosterModel.addAccount(account);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue