!13 fix contorlcenter UI

Merge pull request !13 from likehomedream/my-2.0-devel
This commit is contained in:
KevinDuan 2023-08-30 09:39:17 +00:00 committed by Gitee
commit c5e487fe91
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
17 changed files with 91 additions and 41 deletions

View File

@ -97,7 +97,6 @@
<file>resource/systemicons/kylin-settings-search.png</file>
<file>resource/systemicons/kylin-settings-security.png</file>
<file>resource/systemicons/kylin-settings-system.png</file>
<file>resource/systemicons/kylin-settings-time-language.png</file>
<file>resource/systemicons/kylin-settings-update.png</file>
<file>resource/background/1-warty-final-ubuntukylin.jpg</file>
<file>resource/time-cursor/left_ptr_watch_1.png</file>
@ -125,5 +124,6 @@
<file>resource/background/homepage-cursor.png</file>
<file>resource/background/homepage-global.png</file>
<file>resource/background/homepage-icons.png</file>
<file>resource/systemicons/kylin-settings-commoninfo.png</file>
</qresource>
</RCC>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 975 B

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 952 B

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -125,9 +125,8 @@ CursorImageWidget::CursorImageWidget(QWidget *parent, const QMap<QString, QStrin
blurEffect->setBlurRadius(10); // 设置模糊半径,可以根据需要调整
// 将模糊效果应用到 QGraphicsPixmapItem 上
backgroundItem->setGraphicsEffect(blurEffect);
backgroundItem->setGraphicsEffect(blurEffect);
graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
// scene->addPixmap(image);
graphicsView->setScene(scene);
graphicsView->fitInView(scene->sceneRect(), Qt::KeepAspectRatio);
graphicsView->show();
@ -158,8 +157,12 @@ CursorImageWidget::CursorImageWidget(QWidget *parent, const QMap<QString, QStrin
}
}
// 设置初始缩放倍数为0.9倍
qreal initialScale = 0.8;
graphicsView->scale(initialScale, initialScale);
// qreal initialScale = 0.8;
// graphicsView->scale(initialScale, initialScale);
qreal initialScale = 0.5;
QTransform transform;
transform.scale(initialScale, initialScale);
graphicsView->setTransform(transform);
}
void CursorImageWidget::updateIcon(const QString& widgetName, const QString& newFilePath)

View File

@ -60,6 +60,7 @@ void IconThemeWidget::initEditWidget()
IconEditWidget* widget = new IconEditWidget(viewportWidget);
widget->setdefaulticon(filePath);
widget->setdefaulticonname(widgetName);
mainLayout->addWidget(widget);
m_pathWidgetMap->insert(widgetName, widget);
@ -68,7 +69,12 @@ void IconThemeWidget::initEditWidget()
QPushButton* clickedButton = qobject_cast<QPushButton*>(sender());
if (clickedButton) {
IconEditWidget* clickedWidget = qobject_cast<IconEditWidget*>(clickedButton->parentWidget());
IconEditWidget* clickedWidget = nullptr;
QWidget *widget = clickedButton->parentWidget();
while (widget && !widget->inherits("IconEditWidget")) {
widget = widget->parentWidget();
}
clickedWidget = qobject_cast<IconEditWidget*>(widget);
if (clickedWidget) {
QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择SVG文件"), "", tr("SVG 文件 (*.svg)"));
@ -104,9 +110,10 @@ void IconThemeWidget::initSystemEditWidget()
for (auto it = m_systemiconpathmap->begin(); it != m_systemiconpathmap->end(); ++it) {
const QString& widgetName = it.key();
const QString& filePath = it.value();
qDebug() <<"key----------" <<widgetName <<"value-----------" <<it.value();
IconEditWidget* widget = new IconEditWidget(viewportWidget);
widget->setdefaulticon(filePath);
widget->setdefaulticonname(widgetName);
mainLayout->addWidget(widget);
m_systempathWidgetMap->insert(widgetName, widget);
@ -115,7 +122,12 @@ void IconThemeWidget::initSystemEditWidget()
QPushButton* clickedButton = qobject_cast<QPushButton*>(sender());
if (clickedButton) {
IconEditWidget* clickedWidget = qobject_cast<IconEditWidget*>(clickedButton->parentWidget());
IconEditWidget* clickedWidget = nullptr;
QWidget *widget = clickedButton->parentWidget();
while (widget && !widget->inherits("IconEditWidget")) {
widget = widget->parentWidget();
}
clickedWidget = qobject_cast<IconEditWidget*>(widget);
if (clickedWidget) {
QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择SVG文件"), "", tr("SVG 文件 (*.svg)"));
@ -169,7 +181,7 @@ void IconThemeWidget::initMaps()
void IconThemeWidget::initSystemMaps()
{
m_systemiconpathmap = new QMap<QString, QString>;
m_systemiconpathmap = new QMap<QString, QString> ;
QString directoryPath = ":/resource/systemicons/";
QStringList widgetNames = getWidgetNamesFromFilesInDirectory(directoryPath);
@ -177,8 +189,11 @@ void IconThemeWidget::initSystemMaps()
qDebug() << widgetNames[i];
QString cursorFileName = directoryPath + widgetNames[i] + ".png";
m_systemiconpathmap->insert(widgetNames[i], cursorFileName);
for (const auto& key : m_systemiconpathmap->keys()) {
const QString& value = m_systemiconpathmap->value(key);
qDebug() <<"key----------" <<m_systemiconpathmap->keys() <<"value-----------" <<value;
}
}
m_systemcustomiconpathmap= new QMap<QString, QString>;
m_systempathWidgetMap = new QMap<QString, IconEditWidget*>;
}

View File

@ -95,33 +95,29 @@ ImageWidget::ImageWidget(QWidget *parent, const QMap<QString, QString>* iconMap)
if (count == 11) {
int columnCount = 4;
int row = 1;
int col = 0; // 将col设置为0因为会在循环开始时自增
for (auto it = m_iconMap->begin(); it != m_iconMap->end(); ++it) {
const QString& widgetName = it.key();
const QString& filePath = it.value();
QList<QString> keys = m_iconMap->keys();
QString positions[11] = { keys[0], keys[9], keys[4], keys[5], keys[6],
keys[3], keys[10], keys[8], keys[1], keys[7], keys[2] };
QPixmap pixmap(filePath);
if (!pixmap.isNull()) {
QGraphicsPixmapItem* item = scene->addPixmap(pixmap.scaled(128, 128));
int posX[3] = { 208, 879, 1550 };
int posY[4] = { 275, 535, 795, 1055 };
int index = 0;
if (col == 0 && row == 1) {
// 设置第一个item的位置
item->setPos(col * 320, row * 320);
} else {
// 设置其他item的位置
item->setPos(col % columnCount * 320, row * 320);
for (int i = 0; i < 4; ++i) {
for (int j = 0; j < 3; ++j) {
if (index >= 11) {
break; // 处理超出索引范围的情况
}
col++;
if (col >= columnCount) {
col = 0;
row++;
}
} else {
qDebug() << "Failed to load image:" << filePath;
QString pixmapPath = m_iconMap->value(positions[index]);
QPixmap pixmap(pixmapPath);
QGraphicsPixmapItem* item = scene->addPixmap(pixmap.scaled(100, 100));
item->setData(0, keys[index]);
item->setData(1, pixmapPath);
item->setPos(posX[j], posY[i]);
++index;
}
}
}
@ -205,20 +201,35 @@ void ImageWidget::updateIcon(const QString& widgetName, const QString& newFilePa
{
QGraphicsScene* scene = graphicsView->scene();
QList<QGraphicsItem*> items = scene->items();
for (int i = 0; i < items.size(); ++i) {
QGraphicsItem* item = items.at(i);
// 输出item的内容例如位置和类型等信息
qDebug() << "Item" << i << ":"
<< "Position:" << item->pos()
<< "Type:" << item->type();
}
for (QGraphicsItem* item : items) {
QGraphicsPixmapItem* pixmapItem = dynamic_cast<QGraphicsPixmapItem*>(item);
qDebug()<<widgetName<<"!!!!!!!!!!!";
if (pixmapItem && pixmapItem->data(0).toString() == widgetName) {
qDebug()<<"!!!!!sss!!!!!!";
QPointF oldPosition = pixmapItem->pos();
scene->removeItem(pixmapItem);
delete pixmapItem;
QPixmap newPixmap(newFilePath);
if (!newPixmap.isNull()) {
QGraphicsPixmapItem* newPixmapItem = scene->addPixmap(newPixmap.scaled(128, 128));
newPixmapItem->setData(0, widgetName);
newPixmapItem->setData(1, newFilePath);
newPixmapItem->setPos(oldPosition);
if(widgetName.contains("kylin-setting")){
QGraphicsPixmapItem* newPixmapItem = scene->addPixmap(newPixmap.scaled(100, 100));
newPixmapItem->setData(0, widgetName);
newPixmapItem->setData(1, newFilePath);
newPixmapItem->setPos(oldPosition);
}else{
QGraphicsPixmapItem* newPixmapItem = scene->addPixmap(newPixmap.scaled(128, 128));
newPixmapItem->setData(0, widgetName);
newPixmapItem->setData(1, newFilePath);
newPixmapItem->setPos(oldPosition);
}
} else {
qDebug() << "Failed to load image:" << newFilePath;
}
@ -229,8 +240,17 @@ void ImageWidget::updateIcon(const QString& widgetName, const QString& newFilePa
IconEditWidget::IconEditWidget(QWidget *parent)
{
QVBoxLayout *widgetLayout = new QVBoxLayout(this);
// 创建一个 QFrame 作为边框容器
QFrame *frame = new QFrame(this);
frame->setFrameShape(QFrame::Box); // 设置边框样式
frame->setLineWidth(1); // 设置边框宽度为 2 像素
QVBoxLayout *innerLayout = new QVBoxLayout();
m_label = new QLabel();
QWidget *editwidget = new QWidget();
this->setFixedHeight(110);
QHBoxLayout *m_iconwidgetlayout = new QHBoxLayout();
m_icondefaultlabel = new QLabel();
m_icondefaultlabel->setFixedSize(48,48);
@ -249,8 +269,14 @@ IconEditWidget::IconEditWidget(QWidget *parent)
m_iconwidgetlayout->addWidget(m_icondecustomlabel);
m_iconwidgetlayout->addWidget(m_addiconbutton);
m_iconwidgetlayout->addWidget(m_tiplabel);
editwidget->setLayout(m_iconwidgetlayout);
innerLayout->addWidget(m_label);
innerLayout->addWidget(editwidget);
frame->setLayout(innerLayout);
widgetLayout->addWidget(frame);
this->setLayout(m_iconwidgetlayout);
}
void IconEditWidget::setdefaulticon(QString iconname)
@ -258,6 +284,11 @@ void IconEditWidget::setdefaulticon(QString iconname)
m_icondefaultlabel->setPixmap(QIcon::fromTheme(iconname).pixmap(48,48));
}
void IconEditWidget::setdefaulticonname(QString iconname)
{
m_label->setText(iconname);
}
void IconEditWidget::setcustomicon(QString iconFilePath)
{
QPixmap pixmap(iconFilePath);

View File

@ -81,8 +81,9 @@ class IconEditWidget : public QWidget
public:
IconEditWidget(QWidget *parent = nullptr);
void setdefaulticon(QString iconname);
void setdefaulticonname(QString iconname);
void setcustomicon(QString iconFilePath);
QLabel *m_label;
QPushButton *m_addiconbutton;
private: