1
0
forked from blue/squawk

fix some bugs about disabled menus

This commit is contained in:
Blue 2022-06-03 09:44:48 +03:00
parent 645b92ba51
commit 7192286aeb
Signed by untrusted user: blue
GPG Key ID: 9B203B252A63EE38
9 changed files with 56 additions and 24 deletions

View File

@ -1,9 +1,18 @@
# Changelog
## Squawk 0.2.3 (UNRELEASED)
### Bug fixes
- "Add contact" and "Join conference" menu are enabled once again (pavavno)!
### Improvements
- deactivated accounts now don't appear in combobox of "Add contact" and "Join conference" dialogues
### New features
## Squawk 0.2.2 (May 05, 2022)
### Bug fixes
- now when you remove an account it actually gets removed
- segfault on unitialized Availability in some rare occesions
- segfault on uninitialized Availability in some rare occasions
- fixed crash when you open a dialog with someone that has only error messages in archive
- message height is now calculated correctly on Chinese and Japanese paragraphs
- the app doesn't crash on SIGINT anymore
@ -12,13 +21,13 @@
- there is a way to disable an account and it wouldn't connect when you change availability
- if you cancel password query an account becomes inactive and doesn't annoy you anymore
- if you filled password field and chose KWallet as a storage Squawk wouldn't ask you again for the same password
- if left the password field empty and chose KWallet as a storage Squawk will try to get that passord from KWallet before asking you to input it
- accounts now connect to the server asyncronously - if one is stopped on password prompt another is connecting
- if left the password field empty and chose KWallet as a storage Squawk will try to get that password from KWallet before asking you to input it
- accounts now connect to the server asynchronously - if one is stopped on password prompt another is connecting
- actualized translations, added English localization file
### New features
- new "About" window with links, license, gratitudes
- if the authentication failed Squawk will ask againg for your password and login
- if the authentication failed Squawk will ask again for your password and login
- now there is an amount of unread messages showing on top of Squawk launcher icon
- notifications now have buttons to open a conversation or to mark that message as read

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.4)
project(squawk VERSION 0.2.2 LANGUAGES CXX)
project(squawk VERSION 0.2.3 LANGUAGES CXX)
cmake_policy(SET CMP0076 NEW)
cmake_policy(SET CMP0079 NEW)

View File

@ -49,7 +49,7 @@ int main(int argc, char *argv[])
QApplication::setApplicationName("squawk");
QApplication::setOrganizationName("macaw.me");
QApplication::setApplicationDisplayName("Squawk");
QApplication::setApplicationVersion("0.2.2");
QApplication::setApplicationVersion("0.2.3");
app.setDesktopFileName("squawk");
QTranslator qtTranslator;

View File

@ -69,6 +69,23 @@ int Models::Accounts::rowCount ( const QModelIndex& parent ) const
return accs.size();
}
unsigned int Models::Accounts::size() const
{
return rowCount(QModelIndex());
}
unsigned int Models::Accounts::activeSize() const
{
unsigned int size = 0;
for (const Models::Account* acc : accs) {
if (acc->getActive()) {
++size;
}
}
return size;
}
QVariant Models::Accounts::headerData(int section, Qt::Orientation orientation, int role) const
{
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
@ -97,6 +114,7 @@ void Models::Accounts::addAccount(Account* account)
endInsertRows();
emit sizeChanged(accs.size());
emit changed();
}
void Models::Accounts::onAccountChanged(Item* item, int row, int col)
@ -157,12 +175,14 @@ void Models::Accounts::removeAccount(int index)
emit sizeChanged(accs.size());
}
std::deque<QString> Models::Accounts::getNames() const
std::deque<QString> Models::Accounts::getActiveNames() const
{
std::deque<QString> res;
for (std::deque<Models::Account*>::const_iterator i = accs.begin(), end = accs.end(); i != end; ++i) {
res.push_back((*i)->getName());
for (const Models::Account* acc : accs) {
if (acc->getActive()) {
res.push_back(acc->getName());
}
}
return res;

View File

@ -39,11 +39,13 @@ public:
QVariant data ( const QModelIndex& index, int role ) const override;
int columnCount ( const QModelIndex& parent ) const override;
int rowCount ( const QModelIndex& parent ) const override;
unsigned int size () const;
unsigned int activeSize () const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
Account* getAccount(int index);
std::deque<QString> getNames() const;
std::deque<QString> getActiveNames() const;
signals:
void changed();

View File

@ -63,7 +63,7 @@ Squawk::Squawk(Models::Roster& p_rosterModel, QWidget *parent) :
connect(m_ui->roster, &QTreeView::collapsed, this, &Squawk::onItemCollepsed);
connect(m_ui->roster->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &Squawk::onRosterSelectionChanged);
connect(rosterModel.accountsModel, &Models::Accounts::sizeChanged, this, &Squawk::onAccountsSizeChanged);
connect(rosterModel.accountsModel, &Models::Accounts::changed, this, &Squawk::onAccountsChanged);
connect(contextMenu, &QMenu::aboutToHide, this, &Squawk::onContextAboutToHide);
connect(m_ui->actionAboutSquawk, &QAction::triggered, this, &Squawk::onAboutSquawkCalled);
//m_ui->mainToolBar->addWidget(m_ui->comboBox);
@ -87,6 +87,8 @@ Squawk::Squawk(Models::Roster& p_rosterModel, QWidget *parent) :
m_ui->splitter->restoreState(settings.value("splitter").toByteArray());
}
settings.endGroup();
onAccountsChanged();
}
Squawk::~Squawk() {
@ -129,9 +131,9 @@ void Squawk::onPreferences()
}
}
void Squawk::onAccountsSizeChanged(unsigned int size)
void Squawk::onAccountsChanged()
{
unsigned int size = rosterModel.accountsModel->activeSize();
if (size > 0) {
m_ui->actionAddContact->setEnabled(true);
m_ui->actionAddConference->setEnabled(true);

View File

@ -116,7 +116,7 @@ private slots:
void onNewConference();
void onNewContactAccepted();
void onJoinConferenceAccepted();
void onAccountsSizeChanged(unsigned int size);
void onAccountsChanged();
void onAccountsClosed();
void onPreferencesClosed();
void onVCardClosed();

View File

@ -26,10 +26,10 @@ JoinConference::JoinConference(const Models::Accounts* accounts, QWidget* parent
m_ui(new Ui::JoinConference())
{
m_ui->setupUi ( this );
std::deque<QString> names = accounts->getNames();
std::deque<QString> names = accounts->getActiveNames();
for (std::deque<QString>::const_iterator i = names.begin(), end = names.end(); i != end; i++) {
m_ui->account->addItem(*i);
for (const QString& name : names) {
m_ui->account->addItem(name);
}
m_ui->account->setCurrentIndex(0);
@ -40,12 +40,11 @@ JoinConference::JoinConference(const QString& acc, const Models::Accounts* accou
m_ui(new Ui::JoinConference())
{
m_ui->setupUi ( this );
std::deque<QString> names = accounts->getNames();
std::deque<QString> names = accounts->getActiveNames();
int index = 0;
bool found = false;
for (std::deque<QString>::const_iterator i = names.begin(), end = names.end(); i != end; i++) {
const QString& name = *i;
for (const QString& name : names) {
m_ui->account->addItem(name);
if (!found) {
if (name == acc) {

View File

@ -25,10 +25,10 @@ NewContact::NewContact(const Models::Accounts* accounts, QWidget* parent):
m_ui(new Ui::NewContact())
{
m_ui->setupUi ( this );
std::deque<QString> names = accounts->getNames();
std::deque<QString> names = accounts->getActiveNames();
for (std::deque<QString>::const_iterator i = names.begin(), end = names.end(); i != end; i++) {
m_ui->account->addItem(*i);
for (const QString& name : names) {
m_ui->account->addItem(name);
}
m_ui->account->setCurrentIndex(0);
@ -40,7 +40,7 @@ NewContact::NewContact(const QString& acc, const Models::Accounts* accounts, QWi
{
m_ui->setupUi ( this );
std::deque<QString> names = accounts->getNames();
std::deque<QString> names = accounts->getActiveNames();
int index = 0;
bool found = false;