diff --git a/src/contactlistview.cpp b/src/contactlistview.cpp index 05f501b5..d375032d 100644 --- a/src/contactlistview.cpp +++ b/src/contactlistview.cpp @@ -326,7 +326,12 @@ void ContactListView::activate(const QModelIndex &index) { itemActivated(index); void ContactListView::itemActivated(const QModelIndex &index) { - model()->setData(index, QVariant(true), ContactListModel::ActivateRole); + if (activateAction == Activate) { + model()->setData(index, QVariant(true), ContactListModel::ActivateRole); + } else { + emit contactSelected( + model()->data(index, ContactListModel::ContactListItemRole).value()->contact()); + } } static QAbstractItemModel *realModel(QAbstractItemModel *model) diff --git a/src/contactlistview.h b/src/contactlistview.h index 1a285e51..dc445d6b 100644 --- a/src/contactlistview.h +++ b/src/contactlistview.h @@ -29,11 +29,14 @@ class ContactListItemMenu; class ContactListModel; class QLineEdit; class QWidget; +class PsiContact; class ContactListView : public HoverableTreeView { Q_OBJECT public: + enum ActivateAction { Activate, SignalSelected }; + ContactListView(QWidget *parent = nullptr); ContactListModel *realModel() const; @@ -47,6 +50,7 @@ class ContactListView : public HoverableTreeView { void activate(const QModelIndex &index); void toggleExpandedState(const QModelIndex &index); void ensureVisible(const QModelIndex &index); + void setActivateAction(ActivateAction action) { activateAction = action; } // reimplemented void setModel(QAbstractItemModel *model) override; @@ -58,6 +62,7 @@ public slots: void realExpanded(const QModelIndex &); void realCollapsed(const QModelIndex &); void modelItemsUpdated(); + void contactSelected(PsiContact *); protected: // reimplemented @@ -98,6 +103,7 @@ protected slots: private: QPointer contextMenu_; bool contextMenuActive_; + ActivateAction activateAction = Activate; }; #endif // CONTACTLISTVIEW_H diff --git a/src/filesharingproxy.cpp b/src/filesharingproxy.cpp index 578a8004..3c82938a 100644 --- a/src/filesharingproxy.cpp +++ b/src/filesharingproxy.cpp @@ -39,7 +39,7 @@ #include -#define HTTP_CHUNK (512 * 1024 * 1024) +#define HTTP_CHUNK (512 * 1024) template class ControlBase : public QObject { diff --git a/src/psicon.cpp b/src/psicon.cpp index 7f1548bc..5f3493f7 100644 --- a/src/psicon.cpp +++ b/src/psicon.cpp @@ -1997,7 +1997,9 @@ void PsiCon::invokeForwardMessage(const Jid &from, const QString &text) auto roster = new PsiRosterWidget(d->mainwin); roster->setContactList(d->contactList); - roster->setFilterModeEnabled(true); + roster->setPickContactMode(true); + connect(roster, &PsiRosterWidget::contactPick, this, + [](PsiContact *c) { qDebug("TODO forwarding to: %s", qPrintable(c->jid().full())); }); auto btn = new QPushButton(tr("Forward")); connect(btn, &QPushButton::clicked, dlg, [this, roster](bool) { qDebug("TODO: implement forwarding"); }); diff --git a/src/psirosterwidget.cpp b/src/psirosterwidget.cpp index 688bdd17..f4175f1e 100644 --- a/src/psirosterwidget.cpp +++ b/src/psirosterwidget.cpp @@ -178,6 +178,7 @@ void PsiRosterWidget::setContactList(PsiContactList *contactList) contactListModel_->invalidateLayout(); contactListModel_->setAccountsEnabled(true); contactListModel_->setGroupsEnabled(PsiOptions::instance()->getOption(enableGroupsOptionPath).toBool()); + // connect #ifdef MODELTEST new ModelTest(contactListModel_, this); #endif @@ -249,9 +250,19 @@ void PsiRosterWidget::filterEditTextChanged(const QString &text) #endif } -void PsiRosterWidget::quitFilteringMode() { setFilterModeEnabled(false); } +void PsiRosterWidget::quitFilteringMode() +{ + if (!pickContactMode_) { + setFilterModeEnabled(false); + } +} -void PsiRosterWidget::updateFilterMode() { setFilterModeEnabled(!filterEdit_->text().isEmpty()); } +void PsiRosterWidget::updateFilterMode() +{ + if (!pickContactMode_) { + setFilterModeEnabled(!filterEdit_->text().isEmpty()); + } +} void PsiRosterWidget::setFilterModeEnabled(bool enabled) { @@ -297,9 +308,18 @@ void PsiRosterWidget::setFilterModeEnabled(bool enabled) delete selection; } +void PsiRosterWidget::setPickContactMode(bool value) +{ + pickContactMode_ = value; + if (value) { + setFilterModeEnabled(true); + } + contactListPageView_->setActivateAction(value ? ContactListView::SignalSelected : ContactListView::Activate); +} + void PsiRosterWidget::clearFilterEdit() { - if (filterEdit_->text().isEmpty()) + if (filterEdit_->text().isEmpty() && !pickContactMode_) setFilterModeEnabled(false); else filterEdit_->setText(""); @@ -332,7 +352,7 @@ bool PsiRosterWidget::eventFilter(QObject *obj, QEvent *e) filterEdit_->setText(text); return true; } - } else if (ke->key() == Qt::Key_F3) { + } else if (ke->key() == Qt::Key_F3 && !pickContactMode_) { setFilterModeEnabled(!(filterEdit_->isVisible() && filterEdit_->text().isEmpty())); filterEdit_->setText(""); return true; @@ -340,11 +360,15 @@ bool PsiRosterWidget::eventFilter(QObject *obj, QEvent *e) if (obj == filterEdit_ || obj == filterPageView_ || obj == filterPage_) { if (ke->key() == Qt::Key_Escape) { - setFilterModeEnabled(false); + if (pickContactMode_) { + deleteLater(); + } else { + setFilterModeEnabled(false); + } return true; } - if (ke->key() == Qt::Key_Backspace && filterEdit_->text().isEmpty()) { + if (ke->key() == Qt::Key_Backspace && filterEdit_->text().isEmpty() && !pickContactMode_) { setFilterModeEnabled(false); return true; } diff --git a/src/psirosterwidget.h b/src/psirosterwidget.h index 229abba2..7ef85d67 100644 --- a/src/psirosterwidget.h +++ b/src/psirosterwidget.h @@ -27,6 +27,7 @@ class ContactListDragModel; class PsiContactList; class PsiContactListView; class PsiFilteredContactListView; +class PsiContact; class QLineEdit; class QMimeData; class QSortFilterProxyModel; @@ -40,6 +41,10 @@ class PsiRosterWidget : public QWidget { void setContactList(PsiContactList *contactList); + void setPickContactMode(bool); +signals: + void contactPick(PsiContact *); + public slots: void filterEditTextChanged(const QString &); void quitFilteringMode(); @@ -69,6 +74,7 @@ private slots: ContactListDragModel *contactListModel_; QSortFilterProxyModel *filterModel_; + bool pickContactMode_ = false; }; #endif // PSIROSTERWIDGET_H diff --git a/themes/chatview/psi/bubble/Dark.css b/themes/chatview/psi/bubble/Dark.css index 155d454b..d1ee41ec 100644 --- a/themes/chatview/psi/bubble/Dark.css +++ b/themes/chatview/psi/bubble/Dark.css @@ -55,11 +55,11 @@ blockquote>div { } .reactions_selector { - background-color: #111; + background-color: #033; } .context_menu { - background-color: black; + background-color: #033; } .context_menu>div+div { diff --git a/themes/chatview/psi/bubble/index.html b/themes/chatview/psi/bubble/index.html index dbe103f4..468040de 100644 --- a/themes/chatview/psi/bubble/index.html +++ b/themes/chatview/psi/bubble/index.html @@ -557,7 +557,7 @@ .context_menu>div { box-sizing: border-box; - padding: .3rem .5rem; + padding: .3rem 1rem; } .context_menu>div+div { diff --git a/version b/version index b82b31a2..fdc622e6 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.5.2035 (2024-07-08, 8bf57027) +1.5.2037 (2024-07-11, cc3d12bd)