add m_exteriorwidget and m_filletwidget

This commit is contained in:
likehomedream 2023-07-21 11:28:16 +08:00
parent 1e6ee865a9
commit df52097723
2 changed files with 91 additions and 9 deletions

View File

@ -1,4 +1,4 @@
#include "globalthemewidget.h"
#include "globalthemewidget.h"
#include <QApplication>
#include <QDebug>
#include <QPalette>
@ -30,19 +30,26 @@ void GlobalThemeWidget::init()
initGlobalWidget();
int index = m_allLayout->indexOf(m_buttonWidget);
m_allLayout->insertWidget(index, m_globalwidget);
m_allLayout->insertWidget(index, m_scrollArea);
}
void GlobalThemeWidget::initGlobalWidget()
{
m_globalwidget = new QWidget(this);
m_globallayout = new QVBoxLayout();
// m_globalwidget = new QWidget(this);
// m_globallayout = new QVBoxLayout();
m_scrollArea = new QScrollArea(this); // 创建滚动区域
m_scrollArea->setFrameStyle(QFrame::NoFrame);
m_scrollArea->setWidgetResizable(true);
m_globalwidget = new QWidget(m_scrollArea);
m_globallayout = new QVBoxLayout(m_globalwidget);
// m_globallayout = new QVBoxLayout();
m_globalwidget->setFixedHeight(291);
m_globalwidget->setFixedWidth(480);
// m_globalwidget->setFixedHeight(291);
// m_globalwidget->setFixedWidth(480);
m_accentcolorwidget = new QWidget(m_globalwidget);
m_accentcolorwidget->setFixedHeight(68);
m_accentcolorlayout = new QHBoxLayout(m_accentcolorwidget);
@ -81,6 +88,7 @@ void GlobalThemeWidget::initGlobalWidget()
m_accentcolorlayout->addStretch(1);
m_coverwidget = new QWidget(m_globalwidget);
m_coverwidget->setFixedHeight(133);
m_coverlayout = new QHBoxLayout(m_coverwidget);
@ -148,10 +156,73 @@ void GlobalThemeWidget::initGlobalWidget()
m_wallpaperlayout->addWidget(m_wallpaperbutton);
m_wallpaperlayout->addStretch();
m_globallayout->addWidget(m_accentcolorwidget);
m_exteriorwidget = new QWidget(m_globalwidget);
m_exteriorwidget->setFixedHeight(68);
m_exteriorlayout = new QHBoxLayout(m_exteriorwidget);
QLabel *exteriorlabel = new QLabel(m_exteriorwidget);
exteriorlabel->setText("窗口外观");
m_radiowhite = new QRadioButton(m_exteriorwidget);
m_radiowhite->setText("浅色");
m_radiowhite->setChecked(true);
m_radioblack = new QRadioButton(m_exteriorwidget);
m_radioblack->setText("深色");
m_exteriorlayout->addWidget(exteriorlabel);
m_exteriorlayout->addWidget(m_radiowhite);
m_exteriorlayout->addWidget(m_radioblack);
m_exteriorlayout->addStretch(1);
m_filletwidget = new QWidget(m_globalwidget);
m_filletwidget->setFixedHeight(68);
m_filletlayout = new QHBoxLayout(m_filletwidget);
QLabel *filletlabel = new QLabel(m_filletwidget);
filletlabel->setText("控件圆角");
QPushButton *showButton = new QPushButton(m_filletwidget);
showButton->setDisabled(true);
int value;
m_filletslider = new QSlider(m_filletwidget);
m_filletslider->setOrientation(Qt::Horizontal);
m_filletslider->setFixedWidth(210);
m_filletslider->setRange(0,18);
m_filletslider->setSingleStep(1);
m_filletslider->setTickPosition(QSlider::TicksBelow);
m_filletslider->setTickInterval(1);
m_filletslider->setValue(6);
value = m_filletslider->value();
showButton->setText(QString::number(m_filletslider->value())+"px");
// 连接QSlider的valueChanged信号到槽函数
QObject::connect(m_filletslider, &QSlider::valueChanged, [=]() {
showButton->setText(QString::number(m_filletslider->value())+"px"); // 更新按钮文本为QSlider的当前值
});
m_filletlayout->addWidget(filletlabel);
m_filletlayout->addWidget(m_filletslider);
m_filletlayout->addWidget(showButton);
m_filletlayout->addStretch(1);
m_globallayout->addWidget(m_coverwidget);
m_globallayout->addWidget(m_wallpaperwidget);
m_globallayout->addWidget(m_accentcolorwidget);
m_globallayout->addWidget(m_exteriorwidget);
m_globallayout->addWidget(m_filletwidget);
m_globalwidget->setLayout(m_globallayout);
// 将 m_globalwidget 设置为滚动区域的视口部件
m_scrollArea->setWidget(m_globalwidget);
// 将滚动区域添加到当前窗口的布局
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_scrollArea);
setLayout(layout);
}
@ -295,5 +366,4 @@ void GlobalThemeWidget::openFileDialog()
}
}

View File

@ -8,6 +8,9 @@
#include <QFileDialog>
#include <QMouseEvent>
#include <QImage>
#include <QRadioButton>
#include <QSlider>
#include <QScrollArea>
class GlobalThemeWidget : public WidgetBase
{
@ -32,7 +35,7 @@ Q_SIGNALS:
private:
QString m_globalpath = "";
QString m_globalthemename = "";
QScrollArea* m_scrollArea;
QWidget *m_globalwidget;
QVBoxLayout *m_globallayout;
QWidget *m_accentcolorwidget;
@ -52,6 +55,15 @@ private:
QPushButton *m_wallpaperbutton;
QLabel *m_wallpaperimagelabel;
QWidget *m_exteriorwidget;
QHBoxLayout *m_exteriorlayout;
QRadioButton *m_radiowhite;
QRadioButton *m_radioblack;
QWidget *m_filletwidget;
QHBoxLayout *m_filletlayout;
QSlider *m_filletslider;
bool iscover = true;
QFileDialog *m_fd;