Browse Source

修改UI

master v1.0.3
tianzhendong 2 years ago
parent
commit
de2108dcba
  1. 2
      CMakeLists.txt
  2. 12
      README.md
  3. BIN
      resources/close.png
  4. BIN
      resources/demo.gif
  5. BIN
      resources/fullscreen3.png
  6. BIN
      resources/fullscreen4.png
  7. BIN
      resources/img.png
  8. 11
      resources/img.qrc
  9. BIN
      resources/min.png
  10. BIN
      screenshoot/demo.gif
  11. BIN
      screenshoot/img.png
  12. 4
      src/main.cpp
  13. 99
      src/mainwindow.cpp
  14. 30
      src/mainwindow.h
  15. 113
      src/mainwindow.ui
  16. 419
      src/widget.ui

2
CMakeLists.txt

@ -24,7 +24,7 @@ aux_source_directory(${PROJECT_SOURCE_DIR}/resources DIR_RESOURCES_SRCS)
aux_source_directory(${PROJECT_SOURCE_DIR}/src DIR_SRC_SRCS)
# qrc
qt5_add_resources(QRC_FILES resources/img.qrc)
#qt5_add_resources(QRC_FILES resources/img.qrc)
#SOURCE_GROUP("Resource Files" FILES ${QRC_SOURCE_FILES})
# debug releasereleasecmd

12
README.md

@ -1,8 +1,8 @@
# 重复文件检测工具
![](resources/img.png)
![](screenshoot/img.png)
![](resources/demo.gif)
![](screenshoot/demo.gif)
## 环境
- Clion 2022.1.2
@ -14,9 +14,13 @@
## 下载
[v1.0.2 windows release](https://github.com/tianzhendong/duplicateFilesCheck/releases/download/v1.0.2/duplicateFilesCheckv1.0.2.zip)
[windowsRelease-v1.0.2](https://github.com/tianzhendong/duplicateFilesCheck/releases/download/v1.0.2/duplicateFilesCheckv1.0.2.zip)
[windowsRelease-v1.0.3](https://github.com/tianzhendong/duplicateFilesCheck/releases/download/v1.0.3/duplicateFilesCheckv1.0.3.zip)
## 更新记录
### 20220619 v1.0.2
- [x] 增加打开文件目录功能
- [x] 增加删除文件功能
- [x] 增加删除文件功能
### 20220620 v1.0.3
- [x] 修改UI

BIN
resources/close.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 342 B

BIN
resources/demo.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 KiB

BIN
resources/fullscreen3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 352 B

BIN
resources/fullscreen4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 B

BIN
resources/img.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

11
resources/img.qrc

@ -1,11 +0,0 @@
<RCC>
<qresource prefix="img">
<file>favicon.ico</file>
</qresource>
<qresource prefix="png">
<file>close.png</file>
<file>fullscreen3.png</file>
<file>fullscreen4.png</file>
<file>min.png</file>
</qresource>
</RCC>

BIN
resources/min.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 B

BIN
screenshoot/demo.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
screenshoot/img.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

4
src/main.cpp

@ -1,10 +1,10 @@
#include <QApplication>
#include "widget.h"
#include "mainwindow.h"
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
qRegisterMetaType<QHash<QByteArray,QStringList>>("QHash<QByteArray,QStringList>");
Widget w;
MainWindow w;
w.show();
return QApplication::exec();
}

99
src/widget.cpp → src/mainwindow.cpp

@ -1,41 +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 "mainwindow.h"
#include "ui_MainWindow.h"
#include <QProcess>
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow) {
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)");
this->setWindowTitle("重复文件检测工具-byTianZD");
duplicateFiles = new DuplicateFiles();
myThread = new QThread();
@ -80,10 +56,10 @@ Widget::Widget(QWidget *parent)
duplicateFiles, SLOT(openDirSlot()));
connect(duplicateFiles, SIGNAL(delActionFeedbackSignal(bool)),
this, SLOT(delActionFeedbackSlot(bool)));
}
Widget::~Widget()
{
MainWindow::~MainWindow() {
duplicateFiles->deleteLater();
myThread->exit();
myThread->wait(10 * 1000);
@ -92,29 +68,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);
@ -128,32 +82,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::calMd5ofFileSlot() {
void MainWindow::calMd5ofFileSlot() {
QString path = QFileDialog::getOpenFileName(
this, "选择文件",
"./",
@ -161,29 +110,29 @@ void Widget::calMd5ofFileSlot() {
emit calFileMd5Signal(path);
}
void Widget::showFileMd5Slot(const QByteArray & md5) {
void MainWindow::showFileMd5Slot(const QByteArray & md5) {
ui->leMd5Show->setText("");
ui->leMd5Show->setText(md5);
}
void Widget::selectDirSlot() {
void MainWindow::selectDirSlot() {
ui->progressBar->setValue(0);
QString dirPathUrl = QFileDialog::getExistingDirectory(this, "选择文件夹", "./");
ui->lineDIrShow->setText(dirPathUrl);
emit getFilesSignal(dirPathUrl);
}
void Widget::filesSlot(const QStringList &files) {
void MainWindow::filesSlot(const QStringList &files) {
ui->listWidget_2->clear();
ui->listWidget_2->addItems(files);
}
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::duplicateFilesSlot(const QHash<QByteArray, QStringList> &duplicateFiles) {
void MainWindow::duplicateFilesSlot(const QHash<QByteArray, QStringList> &duplicateFiles) {
ui->listWidget->clear();
this->duplicateResults = duplicateFiles;
for(QHash<QByteArray, QStringList>::const_iterator itr = duplicateFiles.begin(); itr != duplicateFiles.end(); itr++){
@ -191,12 +140,12 @@ void Widget::duplicateFilesSlot(const QHash<QByteArray, QStringList> &duplicateF
}
}
void Widget::currentTextChangedSlot(const QString &currentText) {
void MainWindow::currentTextChangedSlot(const QString &currentText) {
ui->listWidget_2->clear();
ui->listWidget_2->addItems(this->duplicateResults[currentText.toLocal8Bit()]);
}
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);
@ -218,7 +167,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();
@ -226,6 +175,4 @@ void Widget::delActionFeedbackSlot(bool flag) {
ui->listWidget_2->removeItemWidget(item);
delete item;
}
}
}

30
src/widget.h → src/mainwindow.h

@ -1,12 +1,12 @@
//
// 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 <QMainWindow>
#include <QMouseEvent>
#include <QWidget>
#include <QPoint>
#include <QGraphicsDropShadowEffect>
#include <QMessageBox>
@ -17,23 +17,21 @@
#include <QFileDialog>
#include <QMenu>
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);
protected:
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
~MainWindow() override;
protected:
void closeEvent(QCloseEvent *event);
signals:
@ -58,7 +56,7 @@ private slots:
void on_listWidget_customContextMenuRequested(const QPoint &pos);
private:
Ui::Widget *ui;
Ui::MainWindow *ui;
DuplicateFiles * duplicateFiles;
QThread *myThread;
@ -67,9 +65,7 @@ private:
QAction *delAction;
QAction *openAction;
};
#endif //DUPLICATEFILESCHECK_WIDGET_H
#endif //DUPLICATEFILESCHECK_MAINWINDOW_H

113
src/mainwindow.ui

@ -0,0 +1,113 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>628</width>
<height>474</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="shadowWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>目录重复文件检测</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_7">
<item row="2" column="0">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<widget class="QListWidget" name="listWidget_2">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="btnSelectDir">
<property name="text">
<string>选择目录</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineDIrShow"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>文件Md5计算</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="1">
<widget class="QLineEdit" name="leMd5Show"/>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="btnSelectFile">
<property name="text">
<string>选择文件</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

419
src/widget.ui

@ -1,419 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Widget</class>
<widget class="QWidget" name="Widget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Widget</string>
</property>
<layout class="QGridLayout" name="layoutMain">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="shadowWidget" native="true">
<property name="styleSheet">
<string notr="true">#shadowWidget{
background-color: rgb(255, 255, 255);
border-radius: 5px;
}
</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelTitle">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>微软雅黑</family>
<pointsize>14</pointsize>
</font>
</property>
<property name="text">
<string> 重复文件检测工具</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnMin">
<property name="minimumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton
{
border:none;
}
QPushButton:hover
{
background-color: rgb(232, 232, 232);
}
QPushButton:pressed
{
background-color: rgb(162, 162, 162);
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnMin_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>36</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton
{
border:none;
}
QPushButton:hover
{
background-color: rgb(232, 232, 232);
}
QPushButton:pressed
{
background-color: rgb(162, 162, 162);
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnMax">
<property name="minimumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton
{
border:none;
}
QPushButton:hover
{
background-color: rgb(232, 232, 232);
}
QPushButton:pressed
{
background-color: rgb(162, 162, 162);
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnMin_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>36</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton
{
border:none;
}
QPushButton:hover
{
background-color: rgb(232, 232, 232);
}
QPushButton:pressed
{
background-color: rgb(162, 162, 162);
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="btnClose">
<property name="minimumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>36</width>
<height>36</height>
</size>
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">QPushButton
{
border:none;
border-top-right-radius: 5px;
}
QPushButton:hover
{
background-color: rgb(253, 0, 0);
}
QPushButton:pressed
{
background-color: rgb(211, 0, 0);
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="title">
<string>文件Md5计算</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="btnSelectFile">
<property name="text">
<string>选择文件</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leMd5Show"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>目录重复文件检测</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="btnSelectDir">
<property name="text">
<string>选择目录</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineDIrShow"/>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
<item>
<widget class="QListWidget" name="listWidget_2">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading…
Cancel
Save