diff --git a/CMakeLists.txt b/CMakeLists.txt index cd41670..810e813 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ find_package(Qt5 COMPONENTS REQUIRED) # 添加qrc资源 -qt5_add_resources(QRC_FILES resources/img.qrc) +#qt5_add_resources(QRC_FILES resources/img.qrc) #include_directories(resources # src) diff --git a/README.md b/README.md index eb72278..5d46083 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # 文件重命名工具 -![](./assets/img.png) +![](screenshoot/img_3.png) ## 环境 - Clion 2022.1.2 - qt 5.14.2 @@ -31,25 +31,32 @@ ## 重复文件处理 当前文件夹有重复文件时,在新名后加“-旧名”字符串 -## 使用 +## Release -[v1.0.2 windows release](https://github.com/tianzhendong/FileRename/releases/download/v1.0.2/FileRename.zip +### windows +[windowsRelease-v1.0.2](https://github.com/tianzhendong/FileRename/releases/download/v1.0.2/FileRename.zip +) + +[windowsRelease-v1.0.3](https://github.com/tianzhendong/FileRename/releases/download/v1.0.3/windowsRelease-v1.0.3.zip ) ### 替换模式 - 输入新旧字符串,选择替换模式,点击确认 - 选择文件或者文件夹 -![](./assets/img_2.png) +![](screenshoot/img_4.png) ### 时间戳模式 - 选择时间戳模式,点击确认 - 选择文件或者文件夹 -![](./assets/img_1.png) +![](screenshoot/img_5.png) ## 更改日志 ### 20220620 v1.0.2 - [x] 新增打开文件目录功能(右下角listwidget支持) - [x] 新增删除文件功能(右下角listwidget支持) +### 20220620 v1.0.3 +- [x] 修改UI + diff --git a/assets/img.png b/assets/img.png deleted file mode 100644 index 6cc0f5f..0000000 Binary files a/assets/img.png and /dev/null differ diff --git a/assets/img_1.png b/assets/img_1.png deleted file mode 100644 index cb6345f..0000000 Binary files a/assets/img_1.png and /dev/null differ diff --git a/assets/img_2.png b/assets/img_2.png deleted file mode 100644 index c9c04a2..0000000 Binary files a/assets/img_2.png and /dev/null differ diff --git a/resources/close.png b/resources/close.png deleted file mode 100644 index a8c839d..0000000 Binary files a/resources/close.png and /dev/null differ diff --git a/resources/fullscreen3.png b/resources/fullscreen3.png deleted file mode 100644 index 466b711..0000000 Binary files a/resources/fullscreen3.png and /dev/null differ diff --git a/resources/fullscreen4.png b/resources/fullscreen4.png deleted file mode 100644 index 401b0a8..0000000 Binary files a/resources/fullscreen4.png and /dev/null differ diff --git a/resources/img.qrc b/resources/img.qrc deleted file mode 100644 index 43e7a68..0000000 --- a/resources/img.qrc +++ /dev/null @@ -1,11 +0,0 @@ - - - favicon.ico - - - close.png - fullscreen3.png - fullscreen4.png - min.png - - \ No newline at end of file diff --git a/resources/min.png b/resources/min.png deleted file mode 100644 index fbd7577..0000000 Binary files a/resources/min.png and /dev/null differ diff --git a/screenshoot/img_3.png b/screenshoot/img_3.png new file mode 100644 index 0000000..dd161f8 Binary files /dev/null and b/screenshoot/img_3.png differ diff --git a/screenshoot/img_4.png b/screenshoot/img_4.png new file mode 100644 index 0000000..397e7ef Binary files /dev/null and b/screenshoot/img_4.png differ diff --git a/screenshoot/img_5.png b/screenshoot/img_5.png new file mode 100644 index 0000000..bb4e02e Binary files /dev/null and b/screenshoot/img_5.png differ diff --git a/src/main.cpp b/src/main.cpp index a20479a..f0324b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,10 @@ #include -#include "widget.h" +#include "mainwindow.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); qRegisterMetaType>("QHash"); - Widget w; + MainWindow w; w.show(); return QApplication::exec(); } diff --git a/src/widget.cpp b/src/mainwindow.cpp similarity index 68% rename from src/widget.cpp rename to src/mainwindow.cpp index 4943609..05c3917 100644 --- a/src/widget.cpp +++ b/src/mainwindow.cpp @@ -1,40 +1,17 @@ // -// Created by 12038 on 2022/6/15. +// Created by 12038 on 2022/6/20. // -// You may need to build the project (run Qt uic code generator) to get "ui_Widget.h" resolved +// You may need to build the project (run Qt uic code generator) to get "ui_MainWindow.h" resolved -#include "widget.h" -#include "ui_widget.h" +#include "mainwindow.h" +#include "ui_MainWindow.h" -Widget::Widget(QWidget *parent) - : QWidget(parent) - , ui(new Ui::Widget) -{ - ui->setupUi(this); - //取消菜单栏 - this->setWindowFlags(Qt::FramelessWindowHint); - - //阴影边框效果 - QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(); - shadow->setBlurRadius(10); - shadow->setColor(Qt::black); - shadow->setOffset(0); - - ui->shadowWidget->setGraphicsEffect(shadow); - - //父窗口透明 - this->setAttribute(Qt::WA_TranslucentBackground); - - //最大化最小化关闭功能实现 - connect(ui->btnMax, SIGNAL(clicked()), this, SLOT(btnMaxClickedSlot())); - connect(ui->btnMin, SIGNAL(clicked()), this, SLOT(btnMinClickedSlot())); - connect(ui->btnClose, SIGNAL(clicked()), this, SLOT(btnCloseClickedSlot())); - - ui->btnMin->setStyleSheet("border-image: url(:/png/min.png)"); - ui->btnMax->setStyleSheet("border-image: url(:/png/fullscreen3.png)"); - ui->btnClose->setStyleSheet("border-image: url(:/png/close.png)"); +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), ui(new Ui::MainWindow) { + ui->setupUi(this); + this->setWindowTitle("文件批量重命名工具-byTianZD"); renameFile = new Rename(); myThread = new QThread(); @@ -85,10 +62,10 @@ Widget::Widget(QWidget *parent) renameFile, SLOT(openDirSlot())); connect(renameFile, SIGNAL(delActionFeedbackSignal(bool)), this, SLOT(delActionFeedbackSlot(bool))); + } -Widget::~Widget() -{ +MainWindow::~MainWindow() { renameFile->deleteLater(); myThread->exit(); myThread->wait(10 * 1000); @@ -97,29 +74,7 @@ Widget::~Widget() delete ui; } -void Widget::mousePressEvent(QMouseEvent *event) -{ -// QWidget::mousePressEvent(event); - QPoint mouseStartPoint = event->globalPos(); - QPoint windowLeftTopPoint = this->geometry().topLeft(); - this->mousePosInWindow = mouseStartPoint - windowLeftTopPoint; -} - -void Widget::mouseMoveEvent(QMouseEvent *event) -{ -// QWidget::mouseMoveEvent(event); - if(this->mousePosInWindow == QPoint()) return; - QPoint mousePoint = event->globalPos(); - QPoint windowLeftTopPoint = mousePoint - this->mousePosInWindow; - this->move(windowLeftTopPoint); -} - -void Widget::mouseReleaseEvent(QMouseEvent *) -{ - this->mousePosInWindow = QPoint(); -} - -void Widget::closeEvent(QCloseEvent *event) +void MainWindow::closeEvent(QCloseEvent *event) { QMessageBox::StandardButton button; button=QMessageBox::question(this,tr("退出程序"),QString(tr("确认退出程序?")),QMessageBox::Yes|QMessageBox::No); @@ -133,32 +88,27 @@ void Widget::closeEvent(QCloseEvent *event) } } -void Widget::btnMaxClickedSlot() +void MainWindow::btnMaxClickedSlot() { - ui->btnMax->setStyleSheet("border-image: url(:/png/fullscreen4.png)"); if(this->isMaximized()){ - ui->layoutMain->setMargin(9); - ui->btnMax->setStyleSheet("border-image: url(:/png/fullscreen3.png)"); this->showNormal(); } else{ - ui->layoutMain->setMargin(0); - ui->btnMax->setStyleSheet("border-image: url(:/png/fullscreen4.png)"); this->showMaximized(); } } -void Widget::btnMinClickedSlot() +void MainWindow::btnMinClickedSlot() { this->showMinimized(); } -void Widget::btnCloseClickedSlot() +void MainWindow::btnCloseClickedSlot() { this->close(); } -void Widget::selectFileClickedSlot() { +void MainWindow::selectFileClickedSlot() { if(!confirmFlag){ QMessageBox::information(this, "提示", "请先确认配置信息:模式为"+ui->comboBox->currentText()); return; @@ -177,7 +127,7 @@ void Widget::selectFileClickedSlot() { emit fileSelectedSignal(path, ui->leMd5Show->text(), ui->lineEdit->text()); } -void Widget::selectDirClickedSlot() { +void MainWindow::selectDirClickedSlot() { if(!confirmFlag){ QMessageBox::information(this, "提示", "请先确认配置信息:模式为"+ui->comboBox->currentText()); return; @@ -192,20 +142,20 @@ void Widget::selectDirClickedSlot() { emit getFilesSignal(dirPathUrl, ui->leMd5Show->text(), ui->lineEdit->text()); } -void Widget::processSlot(const int &now, const int &total) { +void MainWindow::processSlot(const int &now, const int &total) { ui->progressBar->setMaximum(total); ui->progressBar->setValue(now); } -void Widget::oldFileNameSlot(const QString &oldName) { +void MainWindow::oldFileNameSlot(const QString &oldName) { ui->listWidget->addItem(oldName); } -void Widget::newFileNameSlot(const QString &newName) { +void MainWindow::newFileNameSlot(const QString &newName) { ui->listWidget_2->addItem(newName); } -void Widget::btnConfirmClickedSlot() { +void MainWindow::btnConfirmClickedSlot() { QString s = ui->lineEdit->text(); if(s.contains('/') || s.contains('\\') || s.contains('<') || s.contains('>') || s.contains('?') || s.contains('*') || s.contains(':') || s.contains('|') || s.contains('"')){ QMessageBox::critical(this, "错误", "文件名中不能包含/\\|<>:?*等字符"); @@ -214,7 +164,7 @@ void Widget::btnConfirmClickedSlot() { confirmFlag = true; } -void Widget::on_listWidget_customContextMenuRequested(const QPoint &pos) +void MainWindow::on_listWidget_customContextMenuRequested(const QPoint &pos) { // ui->listWidget_2->currentTextChanged() QMenu *menu = new QMenu(this); @@ -237,7 +187,7 @@ void Widget::on_listWidget_customContextMenuRequested(const QPoint &pos) delete menu; } -void Widget::delActionFeedbackSlot(bool flag) { +void MainWindow::delActionFeedbackSlot(bool flag) { if(flag){ qDebug()<<"remove item"; QListWidgetItem * item = ui->listWidget_2->currentItem(); diff --git a/src/widget.h b/src/mainwindow.h similarity index 72% rename from src/widget.h rename to src/mainwindow.h index bace91d..9bfdb6d 100644 --- a/src/widget.h +++ b/src/mainwindow.h @@ -1,39 +1,36 @@ // -// Created by 12038 on 2022/6/15. +// Created by 12038 on 2022/6/20. // -#ifndef DUPLICATEFILESCHECK_WIDGET_H -#define DUPLICATEFILESCHECK_WIDGET_H +#ifndef DUPLICATEFILESCHECK_MAINWINDOW_H +#define DUPLICATEFILESCHECK_MAINWINDOW_H +#include #include -#include #include #include #include -#include "Rename.h" +#include "rename.h" #include #include #include #include #include + + QT_BEGIN_NAMESPACE -namespace Ui { class Widget; } +namespace Ui { class MainWindow; } QT_END_NAMESPACE -class Widget : public QWidget -{ +class MainWindow : public QMainWindow { Q_OBJECT public: - Widget(QWidget *parent = nullptr); - ~Widget(); + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow() override; protected: - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void mouseReleaseEvent(QMouseEvent *event); - void closeEvent(QCloseEvent *event); signals: @@ -59,7 +56,7 @@ private slots: void on_listWidget_customContextMenuRequested(const QPoint &pos); private: - Ui::Widget *ui; + Ui::MainWindow *ui; Rename * renameFile; QThread *myThread; @@ -68,9 +65,7 @@ private: QAction *delAction; QAction *openAction; - - }; -#endif //DUPLICATEFILESCHECK_WIDGET_H +#endif //DUPLICATEFILESCHECK_MAINWINDOW_H diff --git a/src/mainwindow.ui b/src/mainwindow.ui new file mode 100644 index 0000000..16140c4 --- /dev/null +++ b/src/mainwindow.ui @@ -0,0 +1,261 @@ + + + MainWindow + + + + 0 + 0 + 777 + 612 + + + + MainWindow + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + + + 10 + + + + Qt::LeftToRight + + + 配置 + + + Qt::AlignCenter + + + + + + + 12 + + + + false + + + false + + + + 替换 + + + + + 时间戳 + + + + + + + + + 12 + + + + + + + + + 12 + + + + + + + + + + + + 12 + + + + + + + + + 12 + + + + + + + + + + + + 12 + + + + QPushButton:hover +{ + background-color: #00aaff; +} +QPushButton:pressed +{ + background-color: rgb(0, 124, 186); + +} + + + 确认 + + + + + + + + + + + 10 + + + + 重命名 + + + Qt::AlignCenter + + + + + + + + + 12 + + + + QPushButton:hover +{ + background-color: #00aaff; +} +QPushButton:pressed +{ + background-color: rgb(0, 124, 186); + +} + + + 选择文件 + + + + + + + + 12 + + + + QPushButton:hover +{ + background-color: #00aaff; +} +QPushButton:pressed +{ + background-color: rgb(0, 124, 186); + +} + + + 选择目录 + + + + + + + + + + + + + + true + + + + + + + true + + + Qt::CustomContextMenu + + + + + + + + + 0 + + + + + + + + + + + + + + + diff --git a/src/widget.ui b/src/widget.ui deleted file mode 100644 index 70ed4ee..0000000 --- a/src/widget.ui +++ /dev/null @@ -1,549 +0,0 @@ - - - Widget - - - - 0 - 0 - 950 - 668 - - - - Widget - - - - 9 - - - 9 - - - 9 - - - 9 - - - - - #shadowWidget{ - background-color: rgb(255, 255, 255); - border-radius: 5px; - } - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - 9 - - - 9 - - - - - - 0 - 0 - - - - - 微软雅黑 - 12 - - - - 文件重命名工具 - - - Qt::AlignCenter - - - - - - - - 32 - 32 - - - - - 32 - 32 - - - - - 14 - 50 - false - - - - QPushButton - { - border:none; -border-image: url(../resources/min.jpeg) - } - - QPushButton:hover - { - background-color: rgb(232, 232, 232); - } - QPushButton:pressed - { - background-color: rgb(162, 162, 162); - } - - - - - - - - - - - - - - false - - - - 30 - 10 - - - - - 30 - 10 - - - - - 14 - 50 - false - - - - QPushButton - { - border:none; - } - - QPushButton:hover - { - background-color: rgb(232, 232, 232); - } - QPushButton:pressed - { - background-color: rgb(162, 162, 162); - } - - - - - - - - - - - - - - - 32 - 32 - - - - - 32 - 32 - - - - - 14 - 50 - false - - - - QPushButton -{ - border:none; - border-image: url(../resources/fullscreen3.jpeg) -} -QPushButton:hover -{ - background-color: rgb(232, 232, 232); -} -QPushButton:pressed -{ - background-color: rgb(162, 162, 162); -} - - - - - - - - - - false - - - - 30 - 10 - - - - - 30 - 10 - - - - - 14 - 50 - false - - - - QPushButton - { - border:none; - } - - QPushButton:hover - { - background-color: rgb(232, 232, 232); - } - QPushButton:pressed - { - background-color: rgb(162, 162, 162); - } - - - - - - - - - - - - - - - 30 - 30 - - - - - 30 - 30 - - - - - 14 - 50 - false - - - - QPushButton - { - border:none; - border-top-right-radius: 5px; -border-image: url(../resources/close.jpeg) - } - - QPushButton:hover - { - background-color: rgb(253, 0, 0); - } - QPushButton:pressed - { - background-color: rgb(211, 0, 0); - } - - - - - - - - - - - - - - - - - 0 - 0 - - - - - 10 - - - - - - 10 - - - - Qt::LeftToRight - - - 配置 - - - Qt::AlignCenter - - - - - - - 12 - - - - false - - - false - - - - 替换 - - - - - 时间戳 - - - - - - - - - 12 - - - - - - - - - 12 - - - - - - - - - - - - 12 - - - - - - - - - 12 - - - - - - - - - - - - 12 - - - - QPushButton:hover -{ - background-color: #00aaff; -} -QPushButton:pressed -{ - background-color: rgb(0, 124, 186); - -} - - - 确认 - - - - - - - - - - - 10 - - - - 重命名 - - - Qt::AlignCenter - - - - - - - - - 12 - - - - QPushButton:hover -{ - background-color: #00aaff; -} -QPushButton:pressed -{ - background-color: rgb(0, 124, 186); - -} - - - 选择文件 - - - - - - - - 12 - - - - QPushButton:hover -{ - background-color: #00aaff; -} -QPushButton:pressed -{ - background-color: rgb(0, 124, 186); - -} - - - 选择目录 - - - - - - - - - - - - - - true - - - - - - - true - - - Qt::CustomContextMenu - - - - - - - - - 0 - - - - - - - - - - - - - - - - -