Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
code
  • Loading branch information
ChaoCcWang committed Oct 16, 2021
1 parent 1f9f880 commit 532fb44
Show file tree
Hide file tree
Showing 597 changed files with 19,150 additions and 35,980 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ Makefile*
/TestApp/*
.idea

cmake-build*
cmake-build*
build_startalk/*
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.12)
project(qtalk_v2)
project(startalk)

set(CMAKE_CXX_STANDARD 14)

Expand Down Expand Up @@ -56,10 +56,12 @@ else ()

link_directories(Depends/qzxing/lib/x86)
link_directories(Depends/Screenshot/lib/x86)
message(win32)
endif ()

if($ENV{QTDIR})
set(QT_HOME ${QTDIR})
message(${QTDIR})
else()
message(please set qt venv)
endif()
Expand All @@ -74,25 +76,26 @@ endif ()

set(CMAKE_PREFIX_PATH ${QT_HOME})

INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
link_directories(.)
link_directories(..)

#star talk
ADD_DEFINITIONS(-D_STARTALK)


if (NOT WIN32)
add_subdirectory(qzxing)
add_subdirectory(qzxing)
endif()
add_subdirectory(EventBus)
add_subdirectory(quazip)
add_subdirectory(QtUtil)
add_subdirectory(Util)
add_subdirectory(LogicBase)
add_subdirectory(Screenshot)
add_subdirectory(EventBus)
add_subdirectory(breakpad)
add_subdirectory(UICom)
add_subdirectory(LogicManager)
add_subdirectory(CustomUi)
add_subdirectory(Platform)
add_subdirectory(DataCenter)
add_subdirectory(Emoticon)
add_subdirectory(UIPictureBrowser)
add_subdirectory(DataBasePlug)
Expand Down
3 changes: 1 addition & 2 deletions CustomUi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ project(CustomUi)

# 打开Qt的Moc功能和ui文件QRC文件处理功能
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

find_package(Qt5Widgets CONFIG REQUIRED)
Expand Down Expand Up @@ -56,4 +55,4 @@ set(CMAKE_DEBUG_POSTFIX "d")
ADD_LIBRARY(${PROJECT_NAME} SHARED ${SOURCE_FILES})

#添加链接库
target_link_libraries(${PROJECT_NAME} Qt5::Widgets SUICom QtUtil Platform EventBus)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Util DataCenter EventBus)
105 changes: 55 additions & 50 deletions CustomUi/GroupMemberPopWnd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Created by cc on 19-1-6.
//

#ifndef QTALK_V2_GROUPMEMBERPOPWND_HPP
#define QTALK_V2_GROUPMEMBERPOPWND_HPP
#ifndef STALK_V2_GROUPMEMBERPOPWND_HPP
#define STALK_V2_GROUPMEMBERPOPWND_HPP
#if _MSC_VER >= 1600
#pragma execution_character_set("utf-8")
#endif
Expand All @@ -20,16 +20,15 @@
#include <QHeaderView>
#include <QPainterPath>
#include "SearchEdit.hpp"
#include "../include/Line.h"
#include "CustomUi/Line.h"
#include "customui_global.h"
#include "UShadowWnd.h"
#include "../QtUtil/Utils/Log.h"
#include "../UICom/qimage/qimage.h"
#include "../UICom/StyleDefine.h"
#include "../Platform/AppSetting.h"
#include "Util/Log.h"
#include "Util/ui/qimage/qimage.h"
#include "Util/ui/StyleDefine.h"
#include "DataCenter/AppSetting.h"

enum
{
enum {
EM_DATA_XMPPID = Qt::UserRole + 1,
EM_DATA_USERNAME,
EM_DATA_USERHEAD,
Expand All @@ -38,8 +37,7 @@ enum
EM_DATA_SEARCHKEY
};

enum
{
enum {
EM_COLUMN_NAME,
EM_COLUMN_ROLE
};
Expand All @@ -53,19 +51,23 @@ class GroupItemPopSortModel : public QSortFilterProxyModel
}

protected:
bool lessThan(const QModelIndex &source_left, const QModelIndex &source_right) const override
bool lessThan(const QModelIndex &source_left,
const QModelIndex &source_right) const override
{
if (!source_left.isValid() || !source_right.isValid())
if (!source_left.isValid() || !source_right.isValid()) {
return false;
}

int leftRole = source_left.data(EM_DATA_USERROLE).toInt();
int rightRole = source_right.data(EM_DATA_USERROLE).toInt();
return leftRole < rightRole;
}
//
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const override
bool filterAcceptsRow(int source_row,
const QModelIndex &source_parent) const override
{
QModelIndex index = sourceModel()->index(source_row, EM_COLUMN_NAME, source_parent);
QModelIndex index = sourceModel()->index(source_row, EM_COLUMN_NAME,
source_parent);
QString userId = index.data(EM_DATA_XMPPID).toString();
userId = userId.section("@", 0, 0);
bool ret = index.data(EM_DATA_USERNAME).toString().contains(filterRegExp()) ||
Expand All @@ -86,62 +88,61 @@ class GroupItemPopDelegate : public QStyledItemDelegate

protected:
void paint(QPainter *painter,
const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE
const QStyleOptionViewItem &option,
const QModelIndex &index) const Q_DECL_OVERRIDE
{
QStyledItemDelegate::paint(painter, option, index);
painter->save();
painter->setRenderHint(QPainter::TextAntialiasing);
painter->fillRect(option.rect, QTalk::StyleDefine::instance().getGroupCardGroupMemberNormalColor());
painter->fillRect(option.rect,
st::StyleDefine::instance().getGroupCardGroupMemberNormalColor());
QRect rect = option.rect;

if (index.column() == EM_COLUMN_NAME)
{
if (index.column() == EM_COLUMN_NAME) {
QString strText = index.data(EM_DATA_USERNAME).toString();
painter->setPen(QTalk::StyleDefine::instance().getNavNameFontColor());
QTalk::setPainterFont(painter, AppSetting::instance().getFontLevel());
painter->drawText(QRect(rect.x() + 30, rect.y(), rect.width() - 30, rect.height()),
painter->setPen(st::StyleDefine::instance().getNavNameFontColor());
st::setPainterFont(painter, AppSetting::instance().getFontLevel());
painter->drawText(QRect(rect.x() + 30, rect.y(), rect.width() - 30,
rect.height()),
Qt::AlignVCenter, strText);
QString headPath = index.data(EM_DATA_USERHEAD).toString();
// bool isOnline = index.data(EM_DATA_ISONLINE).toBool();
// bool isOnline = index.data(EM_DATA_ISONLINE).toBool();
painter->setRenderHints(QPainter::Antialiasing, true);
QFileInfo headInfo(headPath);

if(!headInfo.exists() || headInfo.isDir())
if (!headInfo.exists() || headInfo.isDir()) {
headPath = ":/QTalk/image1/StarTalk_defaultHead.png";
}

if (!QFile(headPath).isOpen())
{
int dpi = QTalk::qimage::dpi();
QPixmap pixmap = QTalk::qimage::loadImage(headPath, true, true, 22 * dpi);
if (!QFile(headPath).isOpen()) {
int dpi = st::qimage::dpi();
QPixmap pixmap = st::qimage::loadImage(headPath, true, true, 22 * dpi);
QPainterPath path;
QRect headRect(rect.x(), rect.y() + 8, 22, 22);
path.addEllipse(headRect);
painter->setClipPath(path);
painter->drawPixmap(headRect, pixmap);
painter->fillPath(path, QTalk::StyleDefine::instance().getHeadPhotoMaskColor());
painter->fillPath(path, st::StyleDefine::instance().getHeadPhotoMaskColor());
}
}
else if (index.column() == EM_COLUMN_ROLE)
{
} else if (index.column() == EM_COLUMN_ROLE) {
int role = index.data(EM_DATA_USERROLE).toString().toInt();
QString strRole = tr("");

switch (role)
{
case 1:
strRole = tr("群主");
break;
switch (role) {
case 1:
strRole = tr("群主");
break;

case 2:
strRole = tr("管理员");
break;
case 2:
strRole = tr("管理员");
break;

case 0:
default:
break;
case 0:
default:
break;
}

painter->setPen(QTalk::StyleDefine::instance().getNavNameFontColor());
painter->setPen(st::StyleDefine::instance().getNavNameFontColor());
painter->drawText(rect, Qt::AlignVCenter, strRole);
}

Expand Down Expand Up @@ -219,8 +220,10 @@ class CUSTOMUISHARED_EXPORT GroupMemberPopWnd : public UShadowDialog
Lay->addWidget(topFrm);
Lay->addWidget(searchFrm);
this->setMoverAble(true, topFrm);
connect(_pCloseBtn, &QPushButton::clicked, this, &GroupMemberPopWnd::setVisible);
connect(_pSearchEdit, &Search_Edit::textChanged, this, &GroupMemberPopWnd::onSearch);
connect(_pCloseBtn, &QPushButton::clicked, this,
&GroupMemberPopWnd::setVisible);
connect(_pSearchEdit, &Search_Edit::textChanged, this,
&GroupMemberPopWnd::onSearch);
}
~GroupMemberPopWnd() override
= default;
Expand All @@ -232,12 +235,14 @@ class CUSTOMUISHARED_EXPORT GroupMemberPopWnd : public UShadowDialog
arMembers.clear();
}

void addItem(const QString &xmppId, const QString &name, const QString &headSrc, const int &userRole, const bool &isOnline, const QString &searchKey)
void addItem(const QString &xmppId, const QString &name, const QString &headSrc,
const int &userRole, const bool &isOnline, const QString &searchKey)
{
if(arMembers.contains(xmppId))
if (arMembers.contains(xmppId)) {
return;
else
} else {
arMembers.push_back(xmppId);
}

QStandardItem *item = new QStandardItem;
item->setData(xmppId, EM_DATA_XMPPID);
Expand Down Expand Up @@ -279,4 +284,4 @@ class CUSTOMUISHARED_EXPORT GroupMemberPopWnd : public UShadowDialog
};


#endif //QTALK_V2_GROUPMEMBERPOPWND_HPP
#endif //STALK_V2_GROUPMEMBERPOPWND_HPP
Loading

0 comments on commit 532fb44

Please sign in to comment.