add history UI
This commit is contained in:
parent
07719dc0a9
commit
62c489e827
|
@ -27,6 +27,7 @@ SOURCES += \
|
|||
src/module/cursorthemewidget.cpp \
|
||||
src/module/globalthemefeature.cpp \
|
||||
src/module/globalthemewidget.cpp \
|
||||
src/module/historywidget.cpp \
|
||||
src/module/iconthemewidget.cpp \
|
||||
src/module/iconwidgetfeature.cpp \
|
||||
src/module/infocreatefeature.cpp \
|
||||
|
@ -48,6 +49,7 @@ HEADERS += \
|
|||
src/module/cursorthemewidget.h \
|
||||
src/module/globalthemefeature.h \
|
||||
src/module/globalthemewidget.h \
|
||||
src/module/historywidget.h \
|
||||
src/module/iconthemewidget.h \
|
||||
src/module/iconwidgetfeature.h \
|
||||
src/module/infocreatefeature.h \
|
||||
|
|
|
@ -24,6 +24,7 @@ void Bridge::wallpaperPathChanged(QString path)
|
|||
void Bridge::coverPathChanged(QString path)
|
||||
{
|
||||
m_coverpath = path;
|
||||
m_configfilemanager->copyCovertoCacheDir(m_coverpath,m_builderConfig);
|
||||
}
|
||||
|
||||
void Bridge::radiusChanged(int radius)
|
||||
|
|
|
@ -41,7 +41,7 @@ private:
|
|||
QMap<QString, QString> *m_timecursorpathmap = nullptr;
|
||||
|
||||
QString m_wallpaperpath = ":/resource/background/1-warty-final-ubuntukylin.jpg";
|
||||
QString m_coverpath = ":/resource/background/1-warty-final-ubuntukylin.jpg";
|
||||
QString m_coverpath = ":/resource/background/background-light.png";
|
||||
QDir m_builderConfig;
|
||||
QDir m_buildericons;
|
||||
QDir m_builderappicon;
|
||||
|
|
|
@ -28,9 +28,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(m_maininterface, &MainInterface::cursorMapChanged, m_bridge, &Bridge::cursorMapChanged);
|
||||
connect(m_maininterface, &MainInterface::timeCursorMapChanged, m_bridge, &Bridge::timeCursorMapChanged);
|
||||
connect(m_maininterface, &MainInterface::startCopy, m_bridge, &Bridge::startCopy);
|
||||
connect(m_maininterface, &MainInterface::backtoHome, this ,[=](){
|
||||
m_stackedWidget->setCurrentIndex(0);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -49,15 +47,67 @@ void MainWindow::initUI()
|
|||
m_maininterface = new MainInterface();
|
||||
|
||||
m_entrywidget = new QWidget();
|
||||
m_globalbtn = new EntryButton(m_entrywidget);
|
||||
m_iconbtn = new EntryButton(m_entrywidget);
|
||||
m_cursorbtn = new EntryButton(m_entrywidget);
|
||||
m_globalbtn = new EntryButton();
|
||||
m_iconbtn = new EntryButton();
|
||||
m_cursorbtn = new EntryButton();
|
||||
|
||||
QVBoxLayout* alllayout = new QVBoxLayout;
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout;
|
||||
layout->addWidget(m_globalbtn);
|
||||
layout->addWidget(m_iconbtn);
|
||||
layout->addWidget(m_cursorbtn);
|
||||
|
||||
|
||||
QWidget *guideWidget = new QWidget();
|
||||
|
||||
QHBoxLayout *labellayout = new QHBoxLayout();
|
||||
QLabel *Label = new QLabel(guideWidget);
|
||||
Label->setText("主题打包上传工具 ");
|
||||
QLabel *guideLabel = new QLabel(guideWidget);
|
||||
QString str = "<a href=\" \">"+tr("使用指南") + "</a>";
|
||||
guideLabel->setText(str);
|
||||
guideLabel->setTextFormat(Qt::RichText);
|
||||
guideLabel->setCursor(Qt::PointingHandCursor);
|
||||
guideLabel->setOpenExternalLinks(false);
|
||||
|
||||
|
||||
labellayout->addStretch(1);
|
||||
labellayout->addWidget(Label);
|
||||
labellayout->addWidget(guideLabel);
|
||||
labellayout->addStretch(1);
|
||||
|
||||
guideWidget->setLayout(labellayout);
|
||||
|
||||
connect(guideLabel, &QLabel::linkActivated,this, [=]() {
|
||||
QDialog* helpDialog = new QDialog(this);
|
||||
helpDialog->setWindowTitle("帮助");
|
||||
QLabel* helpText = new QLabel(helpDialog);
|
||||
helpText->setText("这是帮助信息");
|
||||
QVBoxLayout* layout = new QVBoxLayout(helpDialog);
|
||||
layout->addWidget(helpText);
|
||||
helpDialog->setLayout(layout);
|
||||
helpDialog->show();
|
||||
});
|
||||
|
||||
HistoryWidget *historyWidget = new HistoryWidget();
|
||||
historyWidget->setMinimumHeight(2000);
|
||||
|
||||
QDir builderDir = QDir::homePath()+"/.cache/theme-build/";
|
||||
if(!builderDir.exists()|| builderDir.isEmpty()){
|
||||
alllayout->addStretch(1);
|
||||
alllayout->addLayout(layout);
|
||||
alllayout->addStretch(1);
|
||||
alllayout->addWidget(guideWidget);
|
||||
alllayout->addStretch(1);
|
||||
}else{
|
||||
alllayout->addStretch(1);
|
||||
alllayout->addLayout(layout);
|
||||
alllayout->addStretch(1);
|
||||
alllayout->addWidget(guideWidget);
|
||||
alllayout->addWidget(historyWidget);
|
||||
}
|
||||
|
||||
QIcon icon = QIcon(QPixmap(":/resource/background/homepage-global.png"));
|
||||
m_globalbtn->setEntry(icon,"全局主题");
|
||||
QIcon icon1 = QIcon(QPixmap(":/resource/background/homepage-icons.png"));
|
||||
|
@ -65,10 +115,14 @@ void MainWindow::initUI()
|
|||
QIcon icon2 = QIcon(QPixmap(":/resource/background/homepage-cursor.png"));
|
||||
m_cursorbtn->setEntry(icon2,"光标主题");
|
||||
|
||||
m_entrywidget->setLayout(layout);
|
||||
m_entrywidget->setLayout(alllayout);
|
||||
|
||||
QScrollArea* scrollArea = new QScrollArea;
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setWidget(m_entrywidget);
|
||||
|
||||
m_stackedWidget = new QStackedWidget(this);
|
||||
m_stackedWidget->addWidget(m_entrywidget);
|
||||
m_stackedWidget->addWidget(scrollArea);
|
||||
m_stackedWidget->addWidget(m_maininterface);
|
||||
|
||||
QVBoxLayout* mainLayout = new QVBoxLayout;
|
||||
|
|
|
@ -3,11 +3,15 @@
|
|||
|
||||
#include "maininterface.h"
|
||||
#include "./fileProcess/bridge.h"
|
||||
#include "./module/historywidget.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QApplication>
|
||||
#include <QPushButton>
|
||||
#include <QtWidgets>
|
||||
#include <QScrollArea>
|
||||
#include <QLabel>
|
||||
|
||||
class EntryButton : public QPushButton
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -84,13 +84,17 @@ void GlobalThemeWidget::initCoverWidget()
|
|||
QPushButton *coverbtn = new QPushButton(cover);
|
||||
coverbtn->setFixedSize(160,100);
|
||||
QLabel *tip = new QLabel(cover);
|
||||
|
||||
QPixmap pixmap(m_coverpath);
|
||||
coverbtn->setIcon(QIcon(pixmap));
|
||||
coverbtn->setIconSize(coverbtn->size());
|
||||
|
||||
tip->setText("<html>尺寸:1640*1080<br>大小:不超过 5 MB<br>格式:PNG</html>");
|
||||
|
||||
coverlayout->addWidget(coverbtn);
|
||||
coverlayout->addWidget(tip);
|
||||
cover->setLayout(coverlayout);
|
||||
|
||||
|
||||
connect(coverbtn, &QPushButton::clicked, this, [=]() {
|
||||
QString newFilePath = QFileDialog::getOpenFileName(this, tr("选择图片文件"), "", tr("图片文件 (*.png *.jpg)"));
|
||||
bool legalFile = FileCheck::isLegalWallPaperFile(newFilePath,"cover");
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
QWidget *m_accentcolorwidget;
|
||||
QVBoxLayout *m_previewlayout;
|
||||
QString m_wallpaperpath = ":/resource/background/background-light.png";
|
||||
QString m_coverpath = ":/resource/background/background-light.png";
|
||||
QString m_coverpath = ":/resource/background/background-glazing.png";
|
||||
QWidget *m_viewportwidget;
|
||||
QScrollArea *m_scrollArea;
|
||||
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
#include "historywidget.h"
|
||||
|
||||
|
||||
HistoryWidget::HistoryWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *alllayout = new QVBoxLayout();
|
||||
|
||||
QWidget *textWidget = new QWidget();
|
||||
QHBoxLayout *textlayout = new QHBoxLayout();
|
||||
QLabel *historyLabel = new QLabel(textWidget);
|
||||
historyLabel->setText("历史记录");
|
||||
QLabel *tipsLabel = new QLabel(textWidget);
|
||||
tipsLabel->setText("仅保留30天内的记录");
|
||||
|
||||
textlayout->addWidget(historyLabel);
|
||||
textlayout->addStretch(1);
|
||||
textlayout->addWidget(tipsLabel);
|
||||
textWidget->setLayout(textlayout);
|
||||
alllayout->addWidget(textWidget);
|
||||
QDir builderDir = QDir(QDir::homePath() + "/.cache/theme-build/");
|
||||
QStringList folders = builderDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
QList<QString> validFolders;
|
||||
|
||||
QDateTime currentDate = QDateTime::currentDateTime();
|
||||
|
||||
foreach (QString folder, folders) {
|
||||
QString yearStr = folder.mid(0, 4);
|
||||
QString monthStr = folder.mid(4, 2);
|
||||
QString dayStr = folder.mid(6, 2);
|
||||
QString hourStr = folder.mid(8, 2);
|
||||
QString minuteStr = folder.mid(10, 2);
|
||||
QString secondStr = folder.mid(12, 2);
|
||||
|
||||
QDateTime folderDateTime = QDateTime::fromString(yearStr + monthStr + dayStr + hourStr + minuteStr + secondStr, "yyyyMMddhhmmss");
|
||||
|
||||
if (folderDateTime.isValid() && folderDateTime.daysTo(currentDate) <= 30) {
|
||||
qDebug() << "Processing folder: " << folder;
|
||||
validFolders.append(folder);
|
||||
}
|
||||
}
|
||||
QGridLayout *layout = new QGridLayout;
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
foreach (QString folder, validFolders) {
|
||||
HistoryButton *button = new HistoryButton(this);
|
||||
button->setHistoryTime(folder);
|
||||
button->setCover();
|
||||
button->setThemeName();
|
||||
button->setThemeType();
|
||||
button->initUI();
|
||||
|
||||
layout->addWidget(button, row, col);
|
||||
|
||||
col++;
|
||||
if (col == 4) {
|
||||
col = 0;
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *widget = new QWidget(this);
|
||||
widget->setLayout(layout);
|
||||
alllayout->addWidget(widget);
|
||||
alllayout->addStretch(1);
|
||||
this->setLayout(alllayout);
|
||||
}
|
||||
|
||||
HistoryButton::HistoryButton(QWidget* parent): QPushButton(parent)
|
||||
{
|
||||
this->setFixedSize(240, 280);
|
||||
}
|
||||
void HistoryButton::setHistoryTime(const QString &text)
|
||||
{
|
||||
m_historytime = text;
|
||||
}
|
||||
|
||||
void HistoryButton::setCover()
|
||||
{
|
||||
QString filePath = QDir::homePath() + "/.cache/theme-build/" + m_historytime + "/config/preview";
|
||||
QString previewFilePath;
|
||||
|
||||
QFileInfo pngFileInfo(filePath + ".png");
|
||||
if (pngFileInfo.exists()) {
|
||||
previewFilePath = pngFileInfo.filePath();
|
||||
} else {
|
||||
QFileInfo jpgFileInfo(filePath + ".jpg");
|
||||
if (jpgFileInfo.exists()) {
|
||||
previewFilePath = jpgFileInfo.filePath();
|
||||
} else {
|
||||
previewFilePath = nullptr;
|
||||
}
|
||||
}
|
||||
m_coverpath = previewFilePath;
|
||||
}
|
||||
|
||||
void HistoryButton::setThemeName()
|
||||
{
|
||||
QString filePath = QDir::homePath() + "/.cache/theme-build/" + m_historytime + "/debian/control";
|
||||
|
||||
QFile file(filePath);
|
||||
if (file.exists() && file.open(QIODevice::ReadOnly)) {
|
||||
QString content(file.readAll());
|
||||
file.close();
|
||||
|
||||
QString sourceString = "Source:";
|
||||
int sourceIndex = content.indexOf(sourceString);
|
||||
|
||||
if (sourceIndex != -1) {
|
||||
int startIndex = sourceIndex + sourceString.length();
|
||||
QString fieldValue = content.mid(startIndex).trimmed().split("\n").at(0);
|
||||
|
||||
qDebug() << "Source field value: " << fieldValue;
|
||||
m_themename = fieldValue;
|
||||
} else {
|
||||
qDebug() << "No Source field found.";
|
||||
}
|
||||
} else {
|
||||
qDebug() << "File not found or cannot open file.";
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryButton::setThemeType()
|
||||
{
|
||||
QString filePath = QDir::homePath() + "/.cache/theme-build/" + m_historytime;
|
||||
QDir themeDir(filePath);
|
||||
|
||||
if (themeDir.exists("globalTheme")) {
|
||||
m_themetype = "globalTheme";
|
||||
} else {
|
||||
if (themeDir.exists("cursorTheme")) {
|
||||
m_themetype = "cursorTheme";
|
||||
} else if (themeDir.exists("iconTheme")) {
|
||||
m_themetype = "iconTheme";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryButton::initUI()
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
|
||||
QLabel* imageLabel = new QLabel;
|
||||
imageLabel->setFixedSize(QSize(208, 137));
|
||||
layout->addWidget(imageLabel);
|
||||
|
||||
QString imagePath = nullptr;
|
||||
if(nullptr == m_coverpath){
|
||||
imagePath = ":/resource/background/background-light.png";
|
||||
}else{
|
||||
imagePath = m_coverpath;
|
||||
};
|
||||
|
||||
QImage image(imagePath);
|
||||
if (!image.isNull())
|
||||
{
|
||||
QImage scaledImage = image.scaled(QSize(208, 137), Qt::KeepAspectRatio);
|
||||
imageLabel->setPixmap(QPixmap::fromImage(scaledImage));
|
||||
}
|
||||
QLabel* label1 = new QLabel();
|
||||
if(m_themename != nullptr){
|
||||
label1->setText(m_themename);
|
||||
}else{
|
||||
label1->setText("未命名");
|
||||
}
|
||||
layout->addWidget(label1);
|
||||
|
||||
QLabel* label2 = new QLabel(m_historytime);
|
||||
layout->addWidget(label2);
|
||||
|
||||
QPushButton* button = new QPushButton(m_themetype);
|
||||
layout->addWidget(button);
|
||||
this->setLayout(layout);
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
#ifndef HISTORYWIDGET_H
|
||||
#define HISTORYWIDGET_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
#include <QDateTime>
|
||||
#include <QGridLayout>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
|
||||
class HistoryButton : public QPushButton
|
||||
{
|
||||
public:
|
||||
HistoryButton(QWidget* parent = nullptr);
|
||||
void setHistoryTime(const QString &text);
|
||||
void setCover();
|
||||
void setThemeName();
|
||||
void setThemeType();
|
||||
void initUI();
|
||||
|
||||
private:
|
||||
QString m_historytime = nullptr;
|
||||
QString m_coverpath = nullptr;
|
||||
QString m_themename = nullptr;
|
||||
QString m_themetype = nullptr;
|
||||
};
|
||||
|
||||
|
||||
class HistoryWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HistoryWidget(QWidget *parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
};
|
||||
|
||||
#endif // HISTORYWIDGET_H
|
Loading…
Reference in New Issue