Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deprecated handle #211

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions common-plugin/networkdialog/item/netitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ WiredConnection *WiredItem::connection()
QString WiredItem::symbolicIcon(const bool &connected) const
{
QString icon = connected ? QString("network-wired-symbolic") : QString("network-none-symbolic");
return ThemeManager::instance()->getIcon(icon);
return ThemeManager::ref().getIcon(icon);
}

void WiredItem::updateView()
Expand Down Expand Up @@ -405,7 +405,7 @@ void WirelessItem::initConnection()
void WirelessItem::updateSrcirityIcon()
{
if (m_accessPoint && m_accessPoint->secured()) {
QString srcirityIcon = ThemeManager::instance()->getIcon("security");
QString srcirityIcon = ThemeManager::ref().getIcon("security");
// 更新加密图标
m_securityAction->setIcon(QIcon(srcirityIcon));
} else {
Expand All @@ -422,7 +422,7 @@ void WirelessItem::updateWifiIcon()
QString strength = getStrengthStateString(m_accessPoint->strength());
QString iconRes = QString(isWlan6 ? QString("wireless6-%1-symbolic")
: QString("wireless-%1-symbolic")).arg(strength);
QString icon = ThemeManager::instance()->getIcon(iconRes);
QString icon = ThemeManager::ref().getIcon(iconRes);
m_wifiLabel->setIcon(QIcon(icon));
}

Expand Down Expand Up @@ -547,7 +547,7 @@ void WirelessItem::createPasswordEdit()
connect(m_connectButton, &DPushButton::clicked, this, &WirelessItem::onConnectNetwork);
connect(m_passwdEdit->lineEdit(), &QLineEdit::returnPressed, this, &WirelessItem::onConnectNetwork);
connect(m_passwdEdit->lineEdit(), &QLineEdit::textChanged, this, &WirelessItem::checkInputValid);
ThemeManager::instance()->updateInputStyle(m_passwdEdit);
ThemeManager::ref().updateInputStyle(m_passwdEdit);
}

void WirelessItem::createSsidEdit()
Expand Down Expand Up @@ -588,7 +588,7 @@ void WirelessItem::createSsidEdit()
connect(cancelButtion, &DPushButton::clicked, this, &WirelessItem::onCancel);
connect(connectButton, &DPushButton::clicked, this, &WirelessItem::onConnectHidden);
connect(m_ssidEdit->lineEdit(), &QLineEdit::returnPressed, this, &WirelessItem::onConnectHidden);
ThemeManager::instance()->updateInputStyle(m_ssidEdit);
ThemeManager::ref().updateInputStyle(m_ssidEdit);
}

void WirelessItem::initExpandUi()
Expand Down
14 changes: 7 additions & 7 deletions common-plugin/networkdialog/networkpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <NetworkManagerQt/WirelessDevice>

#include <DHiDPIHelper>
#include <DIcon>
#include <DApplicationHelper>
#include <DDBusSender>
#include <DGuiApplicationHelper>
Expand Down Expand Up @@ -369,7 +369,7 @@ void NetworkPanel::updateItems()
if (device->isEnabled() && !device->hotspotEnabled()) {
QList<AccessPoints *> aps = accessPoints(device);
// 按连接状态、强度、名称排序
qSort(aps.begin(), aps.end(), [](AccessPoints *a, AccessPoints *b) {
std::sort(aps.begin(), aps.end(), [](AccessPoints *a, AccessPoints *b) {
int aStatus = static_cast<int>(a->status()) & 3;
int bStatus = static_cast<int>(b->status()) & 3;
if (aStatus ^ bStatus)
Expand Down Expand Up @@ -481,7 +481,7 @@ void NetworkPanel::refreshItems()
rmRows << i;
}
// 将row按照从大到小的顺序排序,否则会出现删除错误的问题
qSort(rmRows.begin(), rmRows.end(), [=](int &row1, int &row2) { return row1 > row2; });
std::sort(rmRows.begin(), rmRows.end(), [](const int row1, const int row2) { return row1 > row2; });
for (int row : rmRows)
m_model->removeRow(row);

Expand Down Expand Up @@ -619,7 +619,7 @@ QWidget *NetworkPanel::itemApplet()
void NetworkPanel::setControlBackground()
{
QPalette backgroud = m_applet->palette();
backgroud.setColor(QPalette::Background, ThemeManager::instance()->backgroundColor());
backgroud.setColor(QPalette::Window, ThemeManager::ref().backgroundColor());
m_applet->setAutoFillBackground(true);
m_applet->setPalette(backgroud);
}
Expand Down Expand Up @@ -835,7 +835,7 @@ void NetworkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
QRect rct = option.rect;
rct.setY(rct.top() + rct.height() - 2);
rct.setHeight(2);
painter->fillRect(rct, ThemeManager::instance()->lineColor());
painter->fillRect(rct, ThemeManager::ref().lineColor());
}
// 鼠标移动的时候不
bool isHoverItem = cantHover(index);
Expand All @@ -844,7 +844,7 @@ void NetworkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
rect.setHeight(rect.height() - 2);

if (!isHoverItem && (option.state & QStyle::State_MouseOver)) {
painter->fillRect(rect, ThemeManager::instance()->itemBackgroundColor());
painter->fillRect(rect, ThemeManager::ref().itemBackgroundColor());
}

// 绘制无线网络左侧的刷新按钮
Expand Down Expand Up @@ -1053,7 +1053,7 @@ void NetworkDelegate::drawRefreshButton(QPainter *painter, const QStyleOptionVie
return;

QRect rctIcon(option.rect.width() - SWITCH_WIDTH - 36, option.rect.top() + (option.rect.height() - 20) / 2, 20, 20);
QPixmap pixmap = DHiDPIHelper::loadNxPixmap(ThemeManager::instance()->getIcon("refresh"));
QPixmap pixmap = DIcon::loadNxPixmap(ThemeManager::ref().getIcon("refresh"));
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
if (m_refreshAngle.contains(index)) {
Expand Down
4 changes: 2 additions & 2 deletions common-plugin/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ inline int comparePluginApi(const QString &pluginApi1, const QString &pluginApi2
return 0;

// 拆分版本号
QStringList subPluginApis1 = pluginApi1.split(".", QString::SkipEmptyParts, Qt::CaseSensitive);
QStringList subPluginApis2 = pluginApi2.split(".", QString::SkipEmptyParts, Qt::CaseSensitive);
QStringList subPluginApis1 = pluginApi1.split(".", Qt::SkipEmptyParts, Qt::CaseSensitive);
QStringList subPluginApis2 = pluginApi2.split(".", Qt::SkipEmptyParts, Qt::CaseSensitive);
for (int i = 0; i < subPluginApis1.size(); ++i) {
auto subPluginApi1 = subPluginApis1[i];
if (subPluginApis2.size() > i) {
Expand Down
6 changes: 3 additions & 3 deletions common-plugin/widgets/tipswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ void TipsWidget::setContext(const QList<QPair<QString, QStringList>> &textList)
int height = 0;
int titleWidth = 0;
for (QPair<QString, QStringList> textPair : m_textList)
titleWidth = qMax(titleWidth, fontMetrics().width(textPair.first));
titleWidth = qMax(titleWidth, fontMetrics().horizontalAdvance(textPair.first));

for (QPair<QString, QStringList> textPair : m_textList) {
QString key = textPair.first;
QStringList values = textPair.second;
if (values.size() > 0) {
for (const QString &value : values) {
QString text = m_spliter + value;
width = qMax(width, fontMetrics().width(text) + MARGIN * 2);
width = qMax(width, fontMetrics().horizontalAdvance(text) + MARGIN * 2);
height += fontMetrics().boundingRect(text).height();
}
} else {
Expand Down Expand Up @@ -61,7 +61,7 @@ int TipsWidget::calcValueX()
int nCurrentTextWidth = fontMetrics().boundingRect(textPair.first).width();
nMaxWidth = qMax(nMaxWidth, nCurrentTextWidth);
}
return MARGIN + nMaxWidth + fontMetrics().width(m_spliter);
return MARGIN + nMaxWidth + fontMetrics().horizontalAdvance(m_spliter);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions dock-network-plugin/networkplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,18 +230,18 @@ void NetworkPlugin::updateQuickPanel()
NetDeviceStatus status = DeviceStatusHandler::wirelessStatus(wirelessList);
updateQuickPanelDescription(status, wirelessConnectionCount, wirelessConnection, NetworkPluginHelper::MenuWirelessEnable);
m_quickPanel->setText(tr("Wireless Network"));
m_quickPanel->setIcon(QIcon::fromTheme(ThemeManager::instance()->getIcon("wireless-80-symbolic")));
m_quickPanel->setIcon(QIcon::fromTheme(ThemeManager::ref().getIcon("wireless-80-symbolic")));
} else if (!wiredList.isEmpty()) {
NetDeviceStatus status = DeviceStatusHandler::wiredStatus(wiredList);
updateQuickPanelDescription(status, wiredConnectionCount, wiredConnection, NetworkPluginHelper::MenuWiredEnable);
m_quickPanel->setText(tr("Wired Network"));
m_quickPanel->setIcon(QIcon::fromTheme(ThemeManager::instance()->getIcon("network-wired-symbolic")));
m_quickPanel->setIcon(QIcon::fromTheme(ThemeManager::ref().getIcon("network-wired-symbolic")));
} else {
m_quickPanel->setText(pluginDisplayName());
m_quickPanel->setDescription(description());
m_quickPanel->setActive(false);
m_quickPanel->setUserData(NetworkPluginHelper::MenuSettings);
m_quickPanel->setIcon(QIcon::fromTheme(ThemeManager::instance()->getIcon("wireless-disconnect")));
m_quickPanel->setIcon(QIcon::fromTheme(ThemeManager::ref().getIcon("wireless-disconnect")));
}
}

Expand Down
2 changes: 1 addition & 1 deletion dss-network-plugin/dockpopupwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define DOCKPOPUPWINDOW_H

#include <darrowrectangle.h>
#include <dregionmonitor.h>
#include <DRegionMonitor>
#include <DWindowManagerHelper>

DWIDGET_USE_NAMESPACE
Expand Down
2 changes: 1 addition & 1 deletion dss-network-plugin/network_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ NetworkModule::NetworkModule(QObject *parent)
m_networkHelper = new NetworkPluginHelper(m_networkDialog, this);

installTranslator(QLocale::system().name());
ThemeManager::instance()->setThemeType(m_isLockModel ? ThemeManager::LockType : ThemeManager::GreeterType);
ThemeManager::ref().setThemeType(m_isLockModel ? ThemeManager::LockType : ThemeManager::GreeterType);
if (m_isLockModel) {
m_networkDialog->setServerName("dde-network-dialog" + QString::number(getuid()) + "lock");
} else {
Expand Down
2 changes: 1 addition & 1 deletion dss-network-plugin/notification/actionbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ QSize ActionButton::contentSize(const QString &text, bool is_menu) const
const QFontMetrics fm(appNamefont);

if (m_showStyle == OSD::BUBBLEWINDOW) {
int text_width = fm.width(text) + 15;
int text_width = fm.horizontalAdvance(text) + 15;
int max_width = qMax(text_width, OSD::ButtonSize(m_showStyle).width());
if (is_menu) {
max_width = qMax(MenuWidth + 2 * MenuPadding + text_width, OSD::ButtonSize(m_showStyle).width());
Expand Down
2 changes: 1 addition & 1 deletion src/realize/netinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void NetworkDeviceRealize::setDeviceStatus(const DeviceStatus &status)
void NetworkDeviceRealize::sortWiredItem(QList<WiredConnection *> &items)
{
// 按照最后面的数字从小到大排序,如果名字中没有数字,就按照创建的先后顺序来排序(path数字的大小)
qSort(items.begin(), items.end(), [ ] (WiredConnection *conn1, WiredConnection *conn2) {
std::sort(items.begin(), items.end(), [ ] (WiredConnection *conn1, WiredConnection *conn2) {
QString lastChar1 = conn1->connection()->id().right(1);
QString lastChar2 = conn2->connection()->id().right(1);
int rightCount = 3;
Expand Down
9 changes: 5 additions & 4 deletions src/realize/networkinterprocesser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <QJsonDocument>
#include <QTimer>
#include <QMultiMap>

namespace dde {
namespace network {
Expand Down Expand Up @@ -211,7 +212,7 @@ void NetworkInterProcesser::onDevicesChanged(const QString &value)
return tmpIndexValue.toInt();
};

qSort(m_devices.begin(), m_devices.end(), [ = ] (NetworkDeviceBase *dev1, NetworkDeviceBase *dev2) {
std::sort(m_devices.begin(), m_devices.end(), [ = ] (NetworkDeviceBase *dev1, NetworkDeviceBase *dev2) {
if (dev1->deviceType() == DeviceType::Wired && dev2->deviceType() == DeviceType::Wireless)
return true;

Expand Down Expand Up @@ -393,15 +394,15 @@ void NetworkInterProcesser::activeConnInfoChanged(const QString &conns)
QJsonParseError error;
m_activeConnectionInfo = QJsonDocument::fromJson(conns.toUtf8(), &error).array();
if (error.error == QJsonParseError::NoError) {
QMap<NetworkDeviceBase *, QJsonObject> deviceInfoMap;
QMultiMap<NetworkDeviceBase *, QJsonObject> deviceInfoMap;
for (QJsonValue jsonValue : m_activeConnectionInfo) {
QJsonObject connInfo = jsonValue.toObject();
const QString devPath = connInfo.value("Device").toString();
NetworkDeviceBase *device = findDevices(devPath);
if (!device)
continue;

deviceInfoMap.insertMulti(device, connInfo);
deviceInfoMap.insert(device, connInfo);
}

for (auto it = deviceInfoMap.begin(); it != deviceInfoMap.end(); it++) {
Expand Down Expand Up @@ -606,7 +607,7 @@ void NetworkInterProcesser::updateNetworkDetails()
}

if (m_devices.size() > 0) {
qSort(m_networkDetails.begin(), m_networkDetails.end(), [ & ] (NetworkDetails *detail1, NetworkDetails *detail2) {
std::sort(m_networkDetails.begin(), m_networkDetails.end(), [ & ] (NetworkDetails *detail1, NetworkDetails *detail2) {
int index1 = -1;
int index2 = -1;
for (int i = 0; i < m_devices.size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/realize/networkmanagerprocesser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void NetworkManagerProcesser::sortDevice()
return tmpIndexValue.toInt();
};
// 有线网络始终在无线网络的前面,如果两者都是有线或者无线网络,则按照path的顺序来排序
qSort(m_devices.begin(), m_devices.end(), [ = ](NetworkDeviceBase *device1, NetworkDeviceBase *device2) {
std::sort(m_devices.begin(), m_devices.end(), [ = ](NetworkDeviceBase *device1, NetworkDeviceBase *device2) {
if (device1->deviceType() == DeviceType::Wired && device2->deviceType() == DeviceType::Wireless)
return true;

Expand Down