mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr1515'
This commit is contained in:
commit
19bf083b41
|
@ -368,7 +368,7 @@ QSplitter:handle{
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -1008,6 +1008,42 @@ QSplitter:handle{
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="searchContactsContainer" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="searchContactText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="searchContactFilterCBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="AdjustingScrollArea" name="friendList">
|
||||
<property name="sizePolicy">
|
||||
|
@ -1036,8 +1072,8 @@ QSplitter:handle{
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>285</width>
|
||||
<height>381</height>
|
||||
<width>284</width>
|
||||
<height>348</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5"/>
|
||||
|
@ -1802,7 +1838,7 @@ QSplitter:handle{
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>775</width>
|
||||
<height>22</height>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -1817,17 +1853,17 @@ QSplitter:handle{
|
|||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CroppingLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header location="global">src/widget/croppinglabel.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AdjustingScrollArea</class>
|
||||
<extends>QScrollArea</extends>
|
||||
<header>src/widget/adjustingscrollarea.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>CroppingLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>src/widget/croppinglabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../res.qrc"/>
|
||||
|
|
|
@ -133,10 +133,13 @@ void Widget::init()
|
|||
ui->mainHead->layout()->setMargin(0);
|
||||
ui->mainHead->layout()->setSpacing(0);
|
||||
|
||||
ui->addButton->setCheckable(true);
|
||||
ui->groupButton->setCheckable(false);
|
||||
ui->transferButton->setCheckable(true);
|
||||
ui->settingsButton->setCheckable(true);
|
||||
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"));
|
||||
|
||||
ui->searchContactText->setPlaceholderText("Search Contacts");
|
||||
|
||||
if (QStyleFactory::keys().contains(Settings::getInstance().getStyle())
|
||||
&& Settings::getInstance().getStyle() != "None")
|
||||
|
@ -200,6 +203,8 @@ void Widget::init()
|
|||
connect(timer, &QTimer::timeout, this, &Widget::onEventIconTick);
|
||||
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);
|
||||
|
||||
// keyboard shortcuts
|
||||
new QShortcut(Qt::CTRL + Qt::Key_Q, this, SLOT(close()));
|
||||
|
@ -645,6 +650,8 @@ void Widget::addFriend(int friendId, const QString &userId)
|
|||
newfriend->getChatForm()->onAvatarChange(friendId, avatar);
|
||||
newfriend->getFriendWidget()->onAvatarChange(friendId, avatar);
|
||||
}
|
||||
|
||||
searchContacts();
|
||||
}
|
||||
|
||||
void Widget::addFriendFailed(const QString&, const QString& errorInfo)
|
||||
|
@ -732,6 +739,7 @@ void Widget::onFriendUsernameChanged(int friendId, const QString& username)
|
|||
QString str = username; str.replace('\n', ' ');
|
||||
str.remove('\r'); str.remove(QChar((char)0)); // null terminator...
|
||||
f->setName(str);
|
||||
searchContacts();
|
||||
}
|
||||
|
||||
void Widget::onChatroomWidgetClicked(GenericChatroomWidget *widget)
|
||||
|
@ -989,6 +997,7 @@ void Widget::onGroupTitleChanged(int groupnumber, const QString& author, const Q
|
|||
g->setName(title);
|
||||
if (!author.isEmpty())
|
||||
g->getChatForm()->addSystemInfoMessage(tr("%1 has set the title to %2").arg(author, title), ChatMessage::INFO, QDateTime::currentDateTime());
|
||||
searchContacts();
|
||||
}
|
||||
|
||||
void Widget::onGroupPeerAudioPlaying(int groupnumber, int peernumber)
|
||||
|
@ -1047,6 +1056,7 @@ Group *Widget::createGroup(int groupId)
|
|||
connect(newgroup->getChatForm(), &GroupChatForm::sendMessage, core, &Core::sendGroupMessage);
|
||||
connect(newgroup->getChatForm(), &GroupChatForm::sendAction, core, &Core::sendGroupAction);
|
||||
connect(newgroup->getChatForm(), &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
|
||||
searchContacts();
|
||||
return newgroup;
|
||||
}
|
||||
|
||||
|
@ -1367,6 +1377,85 @@ Status Widget::getStatusFromString(QString status)
|
|||
return Status::Offline;
|
||||
}
|
||||
|
||||
void Widget::searchContacts()
|
||||
{
|
||||
QString searchString = ui->searchContactText->text();
|
||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
||||
|
||||
switch(filter)
|
||||
{
|
||||
case FilterCriteria::All:
|
||||
hideFriends(searchString, Status::Online);
|
||||
hideFriends(searchString, Status::Offline);
|
||||
|
||||
hideGroups(searchString);
|
||||
break;
|
||||
case FilterCriteria::Online:
|
||||
hideFriends(searchString, Status::Online);
|
||||
hideFriends(QString(), Status::Offline, true);
|
||||
|
||||
hideGroups(searchString);
|
||||
break;
|
||||
case FilterCriteria::Offline:
|
||||
hideFriends(QString(), Status::Online, true);
|
||||
hideFriends(searchString, Status::Offline);
|
||||
|
||||
hideGroups(QString(), true);
|
||||
break;
|
||||
case FilterCriteria::Friends:
|
||||
hideFriends(searchString, Status::Online);
|
||||
hideFriends(searchString, Status::Offline);
|
||||
|
||||
hideGroups(QString(), true);
|
||||
break;
|
||||
case FilterCriteria::Groups:
|
||||
hideFriends(QString(), Status::Online, true);
|
||||
hideFriends(QString(), Status::Offline, true);
|
||||
|
||||
hideGroups(searchString);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
contactListWidget->hide();
|
||||
contactListWidget->show();
|
||||
}
|
||||
|
||||
void Widget::hideFriends(QString searchString, Status status, bool hideAll)
|
||||
{
|
||||
QVBoxLayout* friends = contactListWidget->getFriendLayout(status);
|
||||
int friendCount = friends->count(), index;
|
||||
|
||||
for (index = 0; index<friendCount; index++)
|
||||
{
|
||||
FriendWidget* friendWidget = static_cast<FriendWidget*>(friends->itemAt(index)->widget());
|
||||
QString friendName = friendWidget->getName();
|
||||
|
||||
if (!friendName.contains(searchString, Qt::CaseInsensitive) | hideAll)
|
||||
friendWidget->setVisible(false);
|
||||
else
|
||||
friendWidget->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::hideGroups(QString searchString, bool hideAll)
|
||||
{
|
||||
QVBoxLayout* groups = contactListWidget->getGroupLayout();
|
||||
int groupCount = groups->count(), index;
|
||||
|
||||
for (index = 0; index<groupCount; index++)
|
||||
{
|
||||
GroupWidget* groupWidget = static_cast<GroupWidget*>(groups->itemAt(index)->widget());
|
||||
QString groupName = groupWidget->getName();
|
||||
|
||||
if (!groupName.contains(searchString, Qt::CaseInsensitive) | hideAll)
|
||||
groupWidget->setVisible(false);
|
||||
else
|
||||
groupWidget->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::setActiveToolMenuButton(ActiveToolMenuButton newActiveButton)
|
||||
{
|
||||
ui->addButton->setChecked(newActiveButton == Widget::AddButton);
|
||||
|
|
|
@ -55,6 +55,14 @@ protected:
|
|||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
public:
|
||||
enum FilterCriteria
|
||||
{
|
||||
All=0,
|
||||
Online,
|
||||
Offline,
|
||||
Friends,
|
||||
Groups
|
||||
};
|
||||
explicit Widget(QWidget *parent = 0);
|
||||
void init();
|
||||
void setCentralWidget(QWidget *widget, const QString &widgetName);
|
||||
|
@ -149,6 +157,9 @@ private slots:
|
|||
void onSetShowSystemTray(bool newValue);
|
||||
void onSplitterMoved(int pos, int index);
|
||||
void processOfflineMsgs();
|
||||
void searchContacts();
|
||||
void hideFriends(QString searchString, Status status, bool hideAll = false);
|
||||
void hideGroups(QString searchString, bool hideAll = false);
|
||||
|
||||
private:
|
||||
enum ActiveToolMenuButton {
|
||||
|
|
Loading…
Reference in New Issue
Block a user