mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Recent list selectable from drop list, bug fixes
This commit is contained in:
parent
c24a508c38
commit
ecdf863c02
|
@ -1030,13 +1030,25 @@ QSplitter:handle{
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="searchContactFilterCBox">
|
||||
<widget class="QToolButton" name="searchContactFilterBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::InstantPopup</enum>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <QFileDialog>
|
||||
#include <QBuffer>
|
||||
#include <QMessageBox>
|
||||
#include <QComboBox>
|
||||
|
||||
ProfileForm::ProfileForm(QWidget *parent) :
|
||||
QWidget{parent}, qr{nullptr}
|
||||
|
|
|
@ -506,6 +506,7 @@ void FriendListWidget::moveWidget(FriendWidget* w, Status s, bool add)
|
|||
Time time = getTime(activityDate);
|
||||
CategoryWidget* categoryWidget = dynamic_cast<CategoryWidget*>(activityLayout->itemAt(time)->widget());
|
||||
categoryWidget->addFriendWidget(contact->getFriendWidget(), contact->getStatus());
|
||||
categoryWidget->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,6 +134,45 @@ void Widget::init()
|
|||
ui->myProfile->insertWidget(0, profilePicture);
|
||||
ui->myProfile->insertSpacing(1, 7);
|
||||
|
||||
filterMenu = new QMenu(this);
|
||||
filterGroup = new QActionGroup(this);
|
||||
filterDisplayGroup = new QActionGroup(this);
|
||||
|
||||
filterDisplayName = new QAction(this);
|
||||
filterDisplayName->setCheckable(true);
|
||||
filterDisplayName->setChecked(true);
|
||||
filterDisplayGroup->addAction(filterDisplayName);
|
||||
filterMenu->addAction(filterDisplayName);
|
||||
filterDisplayActivity = new QAction(this);
|
||||
filterDisplayActivity->setCheckable(true);
|
||||
filterDisplayGroup->addAction(filterDisplayActivity);
|
||||
filterMenu->addAction(filterDisplayActivity);
|
||||
filterMenu->addSeparator();
|
||||
|
||||
filterAllAction = new QAction(this);
|
||||
filterAllAction->setCheckable(true);
|
||||
filterAllAction->setChecked(true);
|
||||
filterGroup->addAction(filterAllAction);
|
||||
filterMenu->addAction(filterAllAction);
|
||||
filterOnlineAction = new QAction(this);
|
||||
filterOnlineAction->setCheckable(true);
|
||||
filterGroup->addAction(filterOnlineAction);
|
||||
filterMenu->addAction(filterOnlineAction);
|
||||
filterOfflineAction = new QAction(this);
|
||||
filterOfflineAction->setCheckable(true);
|
||||
filterGroup->addAction(filterOfflineAction);
|
||||
filterMenu->addAction(filterOfflineAction);
|
||||
filterFriendsAction = new QAction(this);
|
||||
filterFriendsAction->setCheckable(true);
|
||||
filterGroup->addAction(filterFriendsAction);
|
||||
filterMenu->addAction(filterFriendsAction);
|
||||
filterGroupsAction = new QAction(this);
|
||||
filterGroupsAction->setCheckable(true);
|
||||
filterGroup->addAction(filterGroupsAction);
|
||||
filterMenu->addAction(filterGroupsAction);
|
||||
|
||||
ui->searchContactFilterBox->setMenu(filterMenu);
|
||||
|
||||
ui->mainContent->setLayout(new QVBoxLayout());
|
||||
ui->mainHead->setLayout(new QVBoxLayout());
|
||||
ui->mainHead->layout()->setMargin(0);
|
||||
|
@ -205,7 +244,8 @@ void Widget::init()
|
|||
connect(timer, &QTimer::timeout, this, &Widget::onTryCreateTrayIcon);
|
||||
connect(offlineMsgTimer, &QTimer::timeout, this, &Widget::processOfflineMsgs);
|
||||
connect(ui->searchContactText, &QLineEdit::textChanged, this, &Widget::searchContacts);
|
||||
connect(ui->searchContactFilterCBox, &QComboBox::currentTextChanged, this, &Widget::searchContacts);
|
||||
connect(filterGroup, &QActionGroup::triggered, this, &Widget::searchContacts);
|
||||
connect(filterDisplayGroup, &QActionGroup::triggered, this, &Widget::changeDisplayMode);
|
||||
connect(ui->friendList, &QWidget::customContextMenuRequested, this, &Widget::friendListContextMenu);
|
||||
|
||||
// keyboard shortcuts
|
||||
|
@ -624,7 +664,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
newfriend->getFriendWidget()->onAvatarChange(friendId, avatar);
|
||||
}
|
||||
|
||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
||||
int filter = getFilterCriteria();
|
||||
newfriend->getFriendWidget()->search(ui->searchContactText->text(), filterOffline(filter));
|
||||
}
|
||||
|
||||
|
@ -718,7 +758,7 @@ void Widget::onFriendUsernameChanged(int friendId, const QString& username)
|
|||
void Widget::onFriendDisplayChanged(FriendWidget *friendWidget, Status s)
|
||||
{
|
||||
contactListWidget->moveWidget(friendWidget, s);
|
||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
||||
int filter = getFilterCriteria();
|
||||
switch (s)
|
||||
{
|
||||
case Status::Offline:
|
||||
|
@ -1016,7 +1056,7 @@ void Widget::onGroupTitleChanged(int groupnumber, const QString& author, const Q
|
|||
g->getChatForm()->addSystemInfoMessage(tr("%1 has set the title to %2").arg(author, title), ChatMessage::INFO, QDateTime::currentDateTime());
|
||||
|
||||
contactListWidget->renameGroupWidget(g->getGroupWidget(), title);
|
||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
||||
int filter = getFilterCriteria();
|
||||
g->getGroupWidget()->searchName(ui->searchContactText->text(), filterGroups(filter));
|
||||
}
|
||||
|
||||
|
@ -1076,7 +1116,7 @@ Group *Widget::createGroup(int groupId)
|
|||
connect(newgroup->getChatForm(), &GroupChatForm::sendAction, core, &Core::sendGroupAction);
|
||||
connect(newgroup->getChatForm(), &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
|
||||
|
||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
||||
int filter = getFilterCriteria();
|
||||
newgroup->getGroupWidget()->searchName(ui->searchContactText->text(), filterGroups(filter));
|
||||
|
||||
return newgroup;
|
||||
|
@ -1436,23 +1476,56 @@ Status Widget::getStatusFromString(QString status)
|
|||
void Widget::searchContacts()
|
||||
{
|
||||
QString searchString = ui->searchContactText->text();
|
||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
||||
int filter = getFilterCriteria();
|
||||
|
||||
contactListWidget->searchChatrooms(searchString, filterOnline(filter), filterOffline(filter), filterGroups(filter));
|
||||
|
||||
updateFilterText();
|
||||
|
||||
contactListWidget->reDraw();
|
||||
}
|
||||
|
||||
void Widget::changeDisplayMode()
|
||||
{
|
||||
if (filterDisplayGroup->checkedAction() == filterDisplayActivity)
|
||||
contactListWidget->setMode(FriendListWidget::Activity);
|
||||
else if (filterDisplayGroup->checkedAction() == filterDisplayName)
|
||||
contactListWidget->setMode(FriendListWidget::Name);
|
||||
|
||||
updateFilterText();
|
||||
}
|
||||
|
||||
void Widget::updateFilterText()
|
||||
{
|
||||
ui->searchContactFilterBox->setText(filterDisplayGroup->checkedAction()->text() + QStringLiteral(" | ") + filterGroup->checkedAction()->text());
|
||||
}
|
||||
|
||||
int Widget::getFilterCriteria() const
|
||||
{
|
||||
QAction* checked = filterGroup->checkedAction();
|
||||
|
||||
if (checked == filterOnlineAction)
|
||||
return Online;
|
||||
else if (checked == filterOfflineAction)
|
||||
return Offline;
|
||||
else if (checked == filterFriendsAction)
|
||||
return Friends;
|
||||
else if (checked == filterGroupsAction)
|
||||
return Groups;
|
||||
|
||||
return All;
|
||||
}
|
||||
|
||||
void Widget::searchCircle(CircleWidget *circleWidget)
|
||||
{
|
||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
||||
int filter = getFilterCriteria();
|
||||
circleWidget->search(ui->searchContactText->text(), true, filterOnline(filter), filterOffline(filter));
|
||||
}
|
||||
|
||||
void Widget::searchItem(GenericChatItemWidget *chatItem, GenericChatItemWidget::ItemType type)
|
||||
{
|
||||
bool hide;
|
||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
||||
int filter = getFilterCriteria();
|
||||
switch (type)
|
||||
{
|
||||
case GenericChatItemWidget::GroupItem:
|
||||
|
@ -1467,7 +1540,7 @@ void Widget::searchItem(GenericChatItemWidget *chatItem, GenericChatItemWidget::
|
|||
|
||||
bool Widget::groupsVisible() const
|
||||
{
|
||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
||||
int filter = getFilterCriteria();
|
||||
return !filterGroups(filter);
|
||||
}
|
||||
|
||||
|
@ -1475,21 +1548,11 @@ void Widget::friendListContextMenu(const QPoint &pos)
|
|||
{
|
||||
QMenu menu(this);
|
||||
QAction *addCircleAction = menu.addAction(tr("Add new circle..."));
|
||||
QAction *switchMode = menu.addAction("Switch between Recent and Name (BETA)");
|
||||
QAction *chosenAction = menu.exec(ui->friendList->mapToGlobal(pos));
|
||||
|
||||
if (chosenAction == addCircleAction)
|
||||
{
|
||||
contactListWidget->addCircleWidget();
|
||||
}
|
||||
else if (chosenAction == switchMode)
|
||||
{
|
||||
if (contactListWidget->getMode() == FriendListWidget::Name)
|
||||
contactListWidget->setMode(FriendListWidget::Activity);
|
||||
else
|
||||
contactListWidget->setMode(FriendListWidget::Name);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setActiveToolMenuButton(ActiveToolMenuButton newActiveButton)
|
||||
{
|
||||
|
@ -1509,12 +1572,17 @@ void Widget::retranslateUi()
|
|||
ui->retranslateUi(this);
|
||||
ui->nameLabel->setText(name);
|
||||
ui->statusLabel->setText(status);
|
||||
ui->searchContactFilterCBox->clear();
|
||||
ui->searchContactFilterCBox->addItem(tr("All"));
|
||||
ui->searchContactFilterCBox->addItem(tr("Online"));
|
||||
ui->searchContactFilterCBox->addItem(tr("Offline"));
|
||||
ui->searchContactFilterCBox->addItem(tr("Friends"));
|
||||
ui->searchContactFilterCBox->addItem(tr("Groups"));
|
||||
|
||||
filterDisplayName->setText(tr("By Name"));
|
||||
filterDisplayActivity->setText(tr("By Activity"));
|
||||
filterAllAction->setText(tr("All"));
|
||||
filterOnlineAction->setText(tr("Online"));
|
||||
filterOfflineAction->setText(tr("Offline"));
|
||||
filterFriendsAction->setText(tr("Friends"));
|
||||
filterGroupsAction->setText(tr("Groups"));
|
||||
ui->searchContactText->setPlaceholderText(tr("Search Contacts"));
|
||||
updateFilterText();
|
||||
|
||||
ui->searchContactText->setPlaceholderText(tr("Search Contacts"));
|
||||
statusOnline->setText(tr("Online", "Button to set your status to 'Online'"));
|
||||
statusAway->setText(tr("Away", "Button to set your status to 'Away'"));
|
||||
|
|
|
@ -50,6 +50,7 @@ class ProfileForm;
|
|||
class SettingsWidget;
|
||||
class AddFriendForm;
|
||||
class CircleWidget;
|
||||
class QActionGroup;
|
||||
|
||||
class Widget final : public QMainWindow
|
||||
{
|
||||
|
@ -186,6 +187,9 @@ private:
|
|||
void saveSplitterGeometry();
|
||||
void cycleContacts(bool forward);
|
||||
void searchContacts();
|
||||
void changeDisplayMode();
|
||||
void updateFilterText();
|
||||
int getFilterCriteria() const;
|
||||
static bool filterGroups(int index);
|
||||
static bool filterOnline(int index);
|
||||
static bool filterOffline(int index);
|
||||
|
@ -194,10 +198,23 @@ private:
|
|||
private:
|
||||
SystemTrayIcon *icon;
|
||||
QMenu *trayMenu;
|
||||
QAction *statusOnline,
|
||||
*statusAway,
|
||||
*statusBusy,
|
||||
*actionQuit;
|
||||
QAction *statusOnline;
|
||||
QAction *statusAway;
|
||||
QAction *statusBusy;
|
||||
QAction *actionQuit;
|
||||
|
||||
QMenu* filterMenu;
|
||||
|
||||
QActionGroup* filterGroup;
|
||||
QAction* filterAllAction;
|
||||
QAction* filterOnlineAction;
|
||||
QAction* filterOfflineAction;
|
||||
QAction* filterFriendsAction;
|
||||
QAction* filterGroupsAction;
|
||||
|
||||
QActionGroup* filterDisplayGroup;
|
||||
QAction* filterDisplayName;
|
||||
QAction* filterDisplayActivity;
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
QSplitter *centralLayout;
|
||||
|
|
|
@ -7,7 +7,7 @@ QLineEdit
|
|||
border-radius: 4px;
|
||||
}
|
||||
|
||||
QComboBox {
|
||||
QToolButton {
|
||||
background: none;
|
||||
background-color: @themeMedium;
|
||||
color: white;
|
||||
|
@ -15,14 +15,13 @@ QComboBox {
|
|||
border-radius: 4px;
|
||||
}
|
||||
|
||||
QComboBox:on {
|
||||
QToolButton:pressed {
|
||||
background-color: @themeMediumDark;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
QComboBox:drop-down {
|
||||
border-style: none;
|
||||
border-radius: 4px;
|
||||
QToolButton::menu-indicator {
|
||||
image: none
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user