init cursor UI
This commit is contained in:
parent
3768f6eac0
commit
da945b9a00
|
@ -4,4 +4,99 @@ CursorThemeWidget::CursorThemeWidget(QWidget *parent) : WidgetBase(parent)
|
|||
{
|
||||
this->initThemeLabel("创建光标图标");
|
||||
this->initImportButton("导入图标");
|
||||
init();
|
||||
|
||||
connect(m_importButton , &QPushButton::clicked, this, [=](){
|
||||
this->importCursor();
|
||||
});
|
||||
}
|
||||
|
||||
void CursorThemeWidget::init()
|
||||
{
|
||||
QString name = qgetenv("USER");
|
||||
m_cursorpath = HOMEPATH +name + "/.cache/theme-build/cursor/";
|
||||
QWidget* newWidget = new QWidget(this);
|
||||
|
||||
newWidget->setFixedHeight(291);
|
||||
newWidget->setFixedWidth(480);
|
||||
m_allLayout->takeAt(1);
|
||||
|
||||
m_listwidget = new QListWidget(newWidget);
|
||||
m_listwidget->setViewMode(QListView::IconMode);
|
||||
m_listwidget->setFixedSize(newWidget->size());
|
||||
m_listwidget->setFlow(QListView::LeftToRight);
|
||||
m_listwidget->setMovement(QListView::Static);
|
||||
m_listwidget->setIconSize(QSize(48, 48));
|
||||
|
||||
QString fixedPath = m_cursorpath;
|
||||
|
||||
QStringList fileNames = QDir(fixedPath).entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||
foreach (QString fileName, fileNames) {
|
||||
QListWidgetItem *item = new QListWidgetItem(QIcon(QIcon::fromTheme("folder")), fileName);
|
||||
m_listwidget->addItem(item);
|
||||
}
|
||||
|
||||
connect(m_listwidget, &QListWidget::itemDoubleClicked, [&](QListWidgetItem *item) {
|
||||
|
||||
int row = m_listwidget->row(item);
|
||||
|
||||
QString clicked_path = m_cursorpath+m_listwidget->currentItem()->data(Qt::DisplayRole).toString();
|
||||
|
||||
FileOperate::deleteDirectoryFiles(clicked_path);
|
||||
m_listwidget->takeItem(row);
|
||||
delete item;
|
||||
});
|
||||
|
||||
int index = m_allLayout->indexOf(m_buttonWidget);
|
||||
m_allLayout->insertWidget(index, newWidget);
|
||||
}
|
||||
|
||||
void CursorThemeWidget::importCursor()
|
||||
{
|
||||
m_fd= new QFileDialog(this);
|
||||
m_fd->setFileMode(QFileDialog::Directory);
|
||||
m_fd->setDirectory(HOMEPATH+qgetenv("USER"));
|
||||
m_fd->setAcceptMode(QFileDialog::AcceptOpen);
|
||||
m_fd->setViewMode(QFileDialog::List);
|
||||
m_fd->setWindowTitle(tr("Select Import Dir"));
|
||||
m_fd->setLabelText(QFileDialog::Accept, tr("Select"));
|
||||
m_fd->setLabelText(QFileDialog::Reject, tr("Cancel"));
|
||||
|
||||
connect(m_fd, &QFileDialog::urlSelected, this, [=](const QUrl &url){
|
||||
QStringList str_list = url.toString().split("/");
|
||||
QListWidgetItem *item = new QListWidgetItem(QIcon(QIcon::fromTheme("folder")), str_list.last());
|
||||
item->setData(Qt::UserRole, str_list.last());
|
||||
m_listwidget->addItem(item);
|
||||
});
|
||||
|
||||
|
||||
|
||||
openFileDialog();
|
||||
}
|
||||
|
||||
void CursorThemeWidget::openFileDialog()
|
||||
{
|
||||
if (m_fd->exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
QString selectedDirectory;
|
||||
selectedDirectory = m_fd->selectedFiles().first();
|
||||
|
||||
// bool isLegal = ThemesCheck::checkIconsDir(selectedDirectory);
|
||||
// if(isLegal){
|
||||
QStringList str_list = selectedDirectory.split("/");
|
||||
|
||||
QString path = m_cursorpath+str_list.last();
|
||||
|
||||
QDir dir(path);
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(path);
|
||||
}
|
||||
|
||||
FileOperate::copyDirectoryFiles(selectedDirectory,path,true);
|
||||
|
||||
qDebug()<<"path----------------"<<path;
|
||||
//选中的图标文件加显示在界面中
|
||||
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -5,14 +5,32 @@
|
|||
#include "widgetbase.h"
|
||||
#include <QWidget>
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QPushButton>
|
||||
#include <QStringList>
|
||||
#include <QListWidget>
|
||||
#include <QDebug>
|
||||
|
||||
class CursorThemeWidget : public WidgetBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CursorThemeWidget(QWidget *parent = nullptr);
|
||||
void init();
|
||||
void importCursor();
|
||||
|
||||
signals:
|
||||
// bool check(QString path);
|
||||
void openFileDialog();
|
||||
Q_SIGNALS:
|
||||
void readyToBuild();
|
||||
|
||||
|
||||
private:
|
||||
QFileDialog *m_fd;
|
||||
QString m_cursorpath;
|
||||
QListWidget *m_listwidget;
|
||||
};
|
||||
|
||||
#endif // CUESORTHEMEWIDGET_H
|
||||
|
|
|
@ -29,15 +29,11 @@ void IconThemeWidget::init()
|
|||
{
|
||||
QString name = qgetenv("USER");
|
||||
m_iconpath = HOMEPATH +name + "/.cache/theme-build/icon/";
|
||||
// m_allLayout->insertWidget(new QLabel(tr("WidgetA")));
|
||||
// 创建新的 widget
|
||||
QWidget* newWidget = new QWidget(this);
|
||||
|
||||
newWidget->setFixedHeight(291);
|
||||
newWidget->setFixedWidth(480);
|
||||
// QLineEdit* lll= new QLineEdit(tr("WidgetA"),newWidget);
|
||||
m_allLayout->takeAt(1);
|
||||
// m_allLayout->insertWidget(1,spacer);
|
||||
|
||||
// 创建一个QListView
|
||||
m_listwidget = new QListWidget(newWidget);
|
||||
|
@ -54,7 +50,6 @@ void IconThemeWidget::init()
|
|||
QStringList fileNames = QDir(fixedPath).entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
|
||||
foreach (QString fileName, fileNames) {
|
||||
QListWidgetItem *item = new QListWidgetItem(QIcon(QIcon::fromTheme("folder")), fileName);
|
||||
// DeletableItem *item = new DeletableItem(QIcon(QIcon::fromTheme("folder")), fileName);
|
||||
m_listwidget->addItem(item);
|
||||
}
|
||||
|
||||
|
@ -64,13 +59,11 @@ void IconThemeWidget::init()
|
|||
|
||||
QString clicked_path = m_iconpath+m_listwidget->currentItem()->data(Qt::DisplayRole).toString();
|
||||
|
||||
//删除.cache中的文件目录
|
||||
FileOperate::deleteDirectoryFiles(clicked_path);
|
||||
m_listwidget->takeItem(row);
|
||||
delete item;
|
||||
});
|
||||
|
||||
// 将新的 widget 插入到 m_allLayout 中
|
||||
int index = m_allLayout->indexOf(m_buttonWidget);
|
||||
qDebug()<< index;
|
||||
m_allLayout->insertWidget(index, newWidget);
|
||||
|
@ -116,7 +109,6 @@ void IconThemeWidget::openFileDialog()
|
|||
if (m_fd->exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
// 处理icon文件,新建一个文件夹为theme-build/ 将文件复制到theme-build/
|
||||
QString selectedDirectory;
|
||||
selectedDirectory = m_fd->selectedFiles().first();
|
||||
|
||||
|
|
|
@ -162,7 +162,6 @@ void MainWindow::initUI()
|
|||
|
||||
void MainWindow::createIconClicked()
|
||||
{
|
||||
qDebug()<<"ICON ICON ICON";
|
||||
m_stackWidget->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
|
@ -183,10 +182,10 @@ void MainWindow::createGlobalClicked()
|
|||
|
||||
void MainWindow::createInterfaceHidden()
|
||||
{
|
||||
m_createThemeInterface->setHidden(true);
|
||||
m_buildPackage->setHidden(true);
|
||||
m_backToCreateInterface->setHidden(false);
|
||||
m_buildThemeCheck->setHidden(false);
|
||||
// m_createThemeInterface->setHidden(true);
|
||||
// m_buildPackage->setHidden(true);
|
||||
// m_backToCreateInterface->setHidden(false);
|
||||
// m_buildThemeCheck->setHidden(false);
|
||||
}
|
||||
|
||||
void MainWindow::backToCreateInterface()
|
||||
|
|
Loading…
Reference in New Issue