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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="searchContactFilterCBox">
|
<widget class="QToolButton" name="searchContactFilterBox">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
ProfileForm::ProfileForm(QWidget *parent) :
|
ProfileForm::ProfileForm(QWidget *parent) :
|
||||||
QWidget{parent}, qr{nullptr}
|
QWidget{parent}, qr{nullptr}
|
||||||
|
|
|
@ -506,6 +506,7 @@ void FriendListWidget::moveWidget(FriendWidget* w, Status s, bool add)
|
||||||
Time time = getTime(activityDate);
|
Time time = getTime(activityDate);
|
||||||
CategoryWidget* categoryWidget = dynamic_cast<CategoryWidget*>(activityLayout->itemAt(time)->widget());
|
CategoryWidget* categoryWidget = dynamic_cast<CategoryWidget*>(activityLayout->itemAt(time)->widget());
|
||||||
categoryWidget->addFriendWidget(contact->getFriendWidget(), contact->getStatus());
|
categoryWidget->addFriendWidget(contact->getFriendWidget(), contact->getStatus());
|
||||||
|
categoryWidget->show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,6 +134,45 @@ void Widget::init()
|
||||||
ui->myProfile->insertWidget(0, profilePicture);
|
ui->myProfile->insertWidget(0, profilePicture);
|
||||||
ui->myProfile->insertSpacing(1, 7);
|
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->mainContent->setLayout(new QVBoxLayout());
|
||||||
ui->mainHead->setLayout(new QVBoxLayout());
|
ui->mainHead->setLayout(new QVBoxLayout());
|
||||||
ui->mainHead->layout()->setMargin(0);
|
ui->mainHead->layout()->setMargin(0);
|
||||||
|
@ -205,7 +244,8 @@ void Widget::init()
|
||||||
connect(timer, &QTimer::timeout, this, &Widget::onTryCreateTrayIcon);
|
connect(timer, &QTimer::timeout, this, &Widget::onTryCreateTrayIcon);
|
||||||
connect(offlineMsgTimer, &QTimer::timeout, this, &Widget::processOfflineMsgs);
|
connect(offlineMsgTimer, &QTimer::timeout, this, &Widget::processOfflineMsgs);
|
||||||
connect(ui->searchContactText, &QLineEdit::textChanged, this, &Widget::searchContacts);
|
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);
|
connect(ui->friendList, &QWidget::customContextMenuRequested, this, &Widget::friendListContextMenu);
|
||||||
|
|
||||||
// keyboard shortcuts
|
// keyboard shortcuts
|
||||||
|
@ -624,7 +664,7 @@ void Widget::addFriend(int friendId, const QString &userId)
|
||||||
newfriend->getFriendWidget()->onAvatarChange(friendId, avatar);
|
newfriend->getFriendWidget()->onAvatarChange(friendId, avatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
int filter = getFilterCriteria();
|
||||||
newfriend->getFriendWidget()->search(ui->searchContactText->text(), filterOffline(filter));
|
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)
|
void Widget::onFriendDisplayChanged(FriendWidget *friendWidget, Status s)
|
||||||
{
|
{
|
||||||
contactListWidget->moveWidget(friendWidget, s);
|
contactListWidget->moveWidget(friendWidget, s);
|
||||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
int filter = getFilterCriteria();
|
||||||
switch (s)
|
switch (s)
|
||||||
{
|
{
|
||||||
case Status::Offline:
|
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());
|
g->getChatForm()->addSystemInfoMessage(tr("%1 has set the title to %2").arg(author, title), ChatMessage::INFO, QDateTime::currentDateTime());
|
||||||
|
|
||||||
contactListWidget->renameGroupWidget(g->getGroupWidget(), title);
|
contactListWidget->renameGroupWidget(g->getGroupWidget(), title);
|
||||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
int filter = getFilterCriteria();
|
||||||
g->getGroupWidget()->searchName(ui->searchContactText->text(), filterGroups(filter));
|
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::sendAction, core, &Core::sendGroupAction);
|
||||||
connect(newgroup->getChatForm(), &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
|
connect(newgroup->getChatForm(), &GroupChatForm::groupTitleChanged, core, &Core::changeGroupTitle);
|
||||||
|
|
||||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
int filter = getFilterCriteria();
|
||||||
newgroup->getGroupWidget()->searchName(ui->searchContactText->text(), filterGroups(filter));
|
newgroup->getGroupWidget()->searchName(ui->searchContactText->text(), filterGroups(filter));
|
||||||
|
|
||||||
return newgroup;
|
return newgroup;
|
||||||
|
@ -1436,23 +1476,56 @@ Status Widget::getStatusFromString(QString status)
|
||||||
void Widget::searchContacts()
|
void Widget::searchContacts()
|
||||||
{
|
{
|
||||||
QString searchString = ui->searchContactText->text();
|
QString searchString = ui->searchContactText->text();
|
||||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
int filter = getFilterCriteria();
|
||||||
|
|
||||||
contactListWidget->searchChatrooms(searchString, filterOnline(filter), filterOffline(filter), filterGroups(filter));
|
contactListWidget->searchChatrooms(searchString, filterOnline(filter), filterOffline(filter), filterGroups(filter));
|
||||||
|
|
||||||
|
updateFilterText();
|
||||||
|
|
||||||
contactListWidget->reDraw();
|
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)
|
void Widget::searchCircle(CircleWidget *circleWidget)
|
||||||
{
|
{
|
||||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
int filter = getFilterCriteria();
|
||||||
circleWidget->search(ui->searchContactText->text(), true, filterOnline(filter), filterOffline(filter));
|
circleWidget->search(ui->searchContactText->text(), true, filterOnline(filter), filterOffline(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::searchItem(GenericChatItemWidget *chatItem, GenericChatItemWidget::ItemType type)
|
void Widget::searchItem(GenericChatItemWidget *chatItem, GenericChatItemWidget::ItemType type)
|
||||||
{
|
{
|
||||||
bool hide;
|
bool hide;
|
||||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
int filter = getFilterCriteria();
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case GenericChatItemWidget::GroupItem:
|
case GenericChatItemWidget::GroupItem:
|
||||||
|
@ -1467,7 +1540,7 @@ void Widget::searchItem(GenericChatItemWidget *chatItem, GenericChatItemWidget::
|
||||||
|
|
||||||
bool Widget::groupsVisible() const
|
bool Widget::groupsVisible() const
|
||||||
{
|
{
|
||||||
int filter = ui->searchContactFilterCBox->currentIndex();
|
int filter = getFilterCriteria();
|
||||||
return !filterGroups(filter);
|
return !filterGroups(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1475,20 +1548,10 @@ void Widget::friendListContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
QAction *addCircleAction = menu.addAction(tr("Add new circle..."));
|
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));
|
QAction *chosenAction = menu.exec(ui->friendList->mapToGlobal(pos));
|
||||||
|
|
||||||
if (chosenAction == addCircleAction)
|
if (chosenAction == addCircleAction)
|
||||||
{
|
|
||||||
contactListWidget->addCircleWidget();
|
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)
|
void Widget::setActiveToolMenuButton(ActiveToolMenuButton newActiveButton)
|
||||||
|
@ -1509,12 +1572,17 @@ void Widget::retranslateUi()
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
ui->nameLabel->setText(name);
|
ui->nameLabel->setText(name);
|
||||||
ui->statusLabel->setText(status);
|
ui->statusLabel->setText(status);
|
||||||
ui->searchContactFilterCBox->clear();
|
|
||||||
ui->searchContactFilterCBox->addItem(tr("All"));
|
filterDisplayName->setText(tr("By Name"));
|
||||||
ui->searchContactFilterCBox->addItem(tr("Online"));
|
filterDisplayActivity->setText(tr("By Activity"));
|
||||||
ui->searchContactFilterCBox->addItem(tr("Offline"));
|
filterAllAction->setText(tr("All"));
|
||||||
ui->searchContactFilterCBox->addItem(tr("Friends"));
|
filterOnlineAction->setText(tr("Online"));
|
||||||
ui->searchContactFilterCBox->addItem(tr("Groups"));
|
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"));
|
ui->searchContactText->setPlaceholderText(tr("Search Contacts"));
|
||||||
statusOnline->setText(tr("Online", "Button to set your status to 'Online'"));
|
statusOnline->setText(tr("Online", "Button to set your status to 'Online'"));
|
||||||
statusAway->setText(tr("Away", "Button to set your status to 'Away'"));
|
statusAway->setText(tr("Away", "Button to set your status to 'Away'"));
|
||||||
|
|
|
@ -50,6 +50,7 @@ class ProfileForm;
|
||||||
class SettingsWidget;
|
class SettingsWidget;
|
||||||
class AddFriendForm;
|
class AddFriendForm;
|
||||||
class CircleWidget;
|
class CircleWidget;
|
||||||
|
class QActionGroup;
|
||||||
|
|
||||||
class Widget final : public QMainWindow
|
class Widget final : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -186,6 +187,9 @@ private:
|
||||||
void saveSplitterGeometry();
|
void saveSplitterGeometry();
|
||||||
void cycleContacts(bool forward);
|
void cycleContacts(bool forward);
|
||||||
void searchContacts();
|
void searchContacts();
|
||||||
|
void changeDisplayMode();
|
||||||
|
void updateFilterText();
|
||||||
|
int getFilterCriteria() const;
|
||||||
static bool filterGroups(int index);
|
static bool filterGroups(int index);
|
||||||
static bool filterOnline(int index);
|
static bool filterOnline(int index);
|
||||||
static bool filterOffline(int index);
|
static bool filterOffline(int index);
|
||||||
|
@ -194,10 +198,23 @@ private:
|
||||||
private:
|
private:
|
||||||
SystemTrayIcon *icon;
|
SystemTrayIcon *icon;
|
||||||
QMenu *trayMenu;
|
QMenu *trayMenu;
|
||||||
QAction *statusOnline,
|
QAction *statusOnline;
|
||||||
*statusAway,
|
QAction *statusAway;
|
||||||
*statusBusy,
|
QAction *statusBusy;
|
||||||
*actionQuit;
|
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;
|
Ui::MainWindow *ui;
|
||||||
QSplitter *centralLayout;
|
QSplitter *centralLayout;
|
||||||
|
|
|
@ -7,7 +7,7 @@ QLineEdit
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QComboBox {
|
QToolButton {
|
||||||
background: none;
|
background: none;
|
||||||
background-color: @themeMedium;
|
background-color: @themeMedium;
|
||||||
color: white;
|
color: white;
|
||||||
|
@ -15,14 +15,13 @@ QComboBox {
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QComboBox:on {
|
QToolButton:pressed {
|
||||||
background-color: @themeMediumDark;
|
background-color: @themeMediumDark;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
QComboBox:drop-down {
|
QToolButton::menu-indicator {
|
||||||
border-style: none;
|
image: none
|
||||||
border-radius: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user