Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Albresky committed Mar 25, 2022
1 parent ea7df00 commit 88fcccc
Show file tree
Hide file tree
Showing 40 changed files with 1,173 additions and 0 deletions.
123 changes: 123 additions & 0 deletions FileOperator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#include "FileOperator.h"
#include "commonHeaders.h"

bool isFolder(const QString& pathName)
{
// File do not exist or FileName is Empty
if (pathName.isEmpty() || !QDir().exists(pathName))
{
qDebug()<<"isEmpty OR do not exist => "<< pathName;
return false;
}

QFileInfo FileInfo(pathName);

if(FileInfo.isDir())
{
qDebug()<<"Folder Exist"<<" => "<< pathName;
return true;
}

qDebug()<<"is not Folder"<<" => "<< pathName;
return false;
}

bool isFile(const QString& pathName)
{
// File do not exist or FileName is Empty
if (pathName.isEmpty() || !QDir().exists(pathName))
{
qDebug()<<"isEmpty OR do not exist => "<< pathName;
return false;
}

QFileInfo FileInfo(pathName);

if(FileInfo.isFile())
{
qDebug()<<"File Exist"<<" => "<< pathName;
return true;
}

qDebug()<<"is not File"<<" => "<< pathName;
return false;
}


bool FileCopy(QString _res, QString _target)
{
QFile qfile;
if(qfile.copy(_res, _target))
{
qDebug()<<"FileCopy Success => "<< _target;
return true;
}
else
{
qDebug()<<"FileCopy Fail => "<< _target;
return false;
}
}

bool copyPic(QString resFile,const QString& targetDir,QString num)
{
if(!FileCopy(resFile,targetDir+"\\"+num+".jpg"))
{
qDebug()<<"pic copy OK!";
return false;
}
return true;
}

bool storeIni(const QStringList &fileNameList,QString& targetDir)
{
QString IniName = "picname.ini";
QFile file(IniName);
if(!isFile(IniName))
{
file.open(QIODevice::ReadWrite|QIODevice::Text);
}
QStringList existNames;
QTextStream _ini(&file);
while(!_ini.atEnd())
{
QString str=_ini.readLine();
qDebug()<<str;
existNames.append(str);
}
file.close();
file.open(QIODevice::ReadWrite|QIODevice::Append|QIODevice::Text);
for(int i=0;i<fileNameList.size();++i)
{
QString s=fileNameList[i];
if(existNames.indexOf(s)==-1)
{
_ini<<s<<"\r\n";
qDebug()<<"storeIni()|prefix=>"<<prefix;
if(!copyPic(prefix+"\\"+s,targetDir,QString::number(i)))
return false;
}
}
file.close();
return true;
}


bool createFile(const QString& fileName)
{
if(isFile(fileName))
{
qDebug()<<"file exixts! skip create";
return false;
}
QFile qfile(fileName);
if(qfile.open(QIODevice::ReadWrite))
{
qDebug()<<"Create File Success => "<<fileName;
qfile.close();
return true;
}
return false;
}


14 changes: 14 additions & 0 deletions FileOperator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef FILEOPERATOR_H
#define FILEOPERATOR_H

#include "commonHeaders.h"
#include <QTextStream>

bool isFolder(const QString& pathName);
bool isFile(const QString& pathName);
bool fileCopy(const QString _res, const QString _target);
bool copyPic(QString resFile, const QString& targetDir,QString num);
bool storeIni(const QStringList &fileNameList, QString& targetDir);
bool createFile(const QString& fileName);

#endif // FILEOPERATOR_H
50 changes: 50 additions & 0 deletions WinFocus.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
FileOperator.cpp \
aboutwindow.cpp \
commonHeaders.cpp \
config.cpp \
configwindow.cpp \
main.cpp \
mainwindow.cpp \
pathOperator.cpp \
picOperator.cpp

HEADERS += \
FileOperator.h \
aboutwindow.h \
commonHeaders.h \
config.h \
configwindow.h \
mainwindow.h \
pathOperator.h \
picOperator.h

FORMS += \
aboutwindow.ui \
configwindow.ui \
mainwindow.ui

TRANSLATIONS += \
WinFocus_zh_CN.ts
CONFIG += lrelease
CONFIG += embed_translations

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

RESOURCES += \
res/res.qrc

RC_ICONS = $$PWD/res/icon.ico
3 changes: 3 additions & 0 deletions WinFocus_zh_CN.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN"></TS>
48 changes: 48 additions & 0 deletions aboutwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "aboutwindow.h"
#include "ui_aboutwindow.h"
#include <QDesktopServices>
#include <QLatin1String>

aboutWindow::aboutWindow(QWidget *parent) :
QWidget(parent),
ui(new Ui::aboutWindow)
{
ui->setupUi(this);
setWindowIcon(QIcon(":/icon.ico"));
setWindowTitle("关于");
setFixedSize(300,200);

setWindowFlags(windowFlags()&~Qt::WindowMinMaxButtonsHint);

ui->name->setText(tr("<font style='font-size:18px;font-family:Microsoft YaHei;color:black'><b>WinFocus</b></font><font style='font-size:12px'>&nbsp;(x64)</font>"));

ui->version->setText(tr("<font style='font-size:14px'>版本: 1.0</font>"));
ui->builtdate->setText(tr("<font style='font-size:14px'>Built on Mar 22 2022</font>"));
ui->author->setText(tr("<font style='font-size:14px'>Built by 代码之火</font>"));
ui->blog->setText(tr("<font style='font-size:14px'>Blog@</font><font style='font-size:13px'><a href='url'>https://cosyspark.space</a></font><br><br>"));
ui->github->setText(tr("<font style='font-size:14px'>Github@<font style='font-size:13px'><a href='url'>https://github.com/Albresky</a></font"));

connect(ui->blog,&QLabel::linkActivated,this,&aboutWindow::blog_linkActivated);
connect(ui->github,&QLabel::linkActivated,this,&aboutWindow::github_linkActivated);
}

aboutWindow::~aboutWindow()
{
delete ui;
}



void aboutWindow::blog_linkActivated()
{
QDesktopServices::openUrl(QUrl(QLatin1String("https://cosyspark.space")));
qDebug()<<"blog hyperLink triggered";
}


void aboutWindow::github_linkActivated()
{
QDesktopServices::openUrl(QUrl(QLatin1String("https://github.com/Albresky")));
qDebug()<<"blog hyperLink triggered";
}

27 changes: 27 additions & 0 deletions aboutwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef ABOUTWINDOW_H
#define ABOUTWINDOW_H

#include <QWidget>

namespace Ui {
class aboutWindow;
}

class aboutWindow : public QWidget
{
Q_OBJECT

public:
explicit aboutWindow(QWidget *parent = nullptr);
~aboutWindow();

private slots:
void blog_linkActivated();

void github_linkActivated();

private:
Ui::aboutWindow *ui;
};

#endif // ABOUTWINDOW_H
122 changes: 122 additions & 0 deletions aboutwindow.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>aboutWindow</class>
<widget class="QWidget" name="aboutWindow">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>200</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="blog">
<property name="geometry">
<rect>
<x>30</x>
<y>150</y>
<width>251</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Blog</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
<widget class="QLabel" name="name">
<property name="geometry">
<rect>
<x>150</x>
<y>10</y>
<width>121</width>
<height>41</height>
</rect>
</property>
<property name="text">
<string>Name</string>
</property>
</widget>
<widget class="QLabel" name="version">
<property name="geometry">
<rect>
<x>180</x>
<y>50</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Version</string>
</property>
</widget>
<widget class="QLabel" name="builtdate">
<property name="geometry">
<rect>
<x>130</x>
<y>80</y>
<width>141</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>BuiltDate</string>
</property>
</widget>
<widget class="QLabel" name="author">
<property name="geometry">
<rect>
<x>150</x>
<y>110</y>
<width>121</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Author</string>
</property>
</widget>
<widget class="QLabel" name="github">
<property name="geometry">
<rect>
<x>30</x>
<y>170</y>
<width>251</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>Github</string>
</property>
</widget>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>91</width>
<height>91</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">image: url(:/logo.png);</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
3 changes: 3 additions & 0 deletions commonHeaders.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "commonHeaders.h"

QString prefix="";
Loading

0 comments on commit 88fcccc

Please sign in to comment.