Skip to content

Commit

Permalink
[feature] for v2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
klesh committed Sep 5, 2019
1 parent 1c419de commit 2eca577
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 44 deletions.
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# File to URL

![demo](https://github.com/klesh/fu/raw/v2.0.0/fu2.gif)

# Introduction

`fu` stands for `File Uploader`, a utility design to help you upload images/files and produce Markdown/HTML snippets with couple of clicks.

# Features

* Upload `Raw Image Data` or `Files` from Clipboard to server
* Multiple files to multiple servers with one click
* Upload to your own FTP/SFTP, or your NAS through LocalStorage protocol
* Upload to public image hosting service like `imgur.com` and `qiniu.com`
* Compress image before upload
* Adding wartermark for image
* Customizable output format, HTML/Markdown/Raw or whatever plain-text format you like
* Tagging support
* Reuse previous uploaded clips
* Search history clips by similarity (base on `pHash`)
* Easy to backup/restore your data
* i18n support


# Installation

[Go to releases page](https://github.com/klesh/fu/releases) download archive according to your OS.

## Windows

Download the `.7z` file from releases page. extract to whereever you want.

If you want it to be launched at login, please make a shortcut in your `Startup` folder.

## MacOS

currently unavailable

## Linux

currently unavailable


# Build Dependencies

* Qt5
* libqcurl
* qt-phash

# FAQ

Q: How to add imgur.com?

A: go to http://api.imgur.com/ register an application, you will receive a Client-ID, then you can create a imgur.com entry in `Preferences`. You may have to setup proxy field if you run into a "blocked by imgur.com " error.

# Like it ?

* Star this respository right away!
* Recommend to your friends.
* Twitter/Facebook/Reddit it already.
* Pull Requests are all welcome.

# License

LGPL
1 change: 0 additions & 1 deletion fu.pro
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ for(tsfile, TRANSLATIONS) {
}

DEFINES += LANGS=\\\"$${LANGS}\\\"
message($$LANGS)
CONFIG(release, debug|release) {
BUILD = release
}
Expand Down
Binary file added fu2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 24 additions & 13 deletions i18n/fu.en_us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
<message>
<location filename="../src/configdialog.ui" line="176"/>
<location filename="../src/configdialog.ui" line="620"/>
<location filename="../src/configdialog.cpp" line="26"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -249,62 +248,61 @@
</message>
<message>
<location filename="../src/configdialog.ui" line="724"/>
<location filename="../src/configdialog.cpp" line="25"/>
<source>Ok</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="233"/>
<location filename="../src/configdialog.cpp" line="231"/>
<source>Please enter the name of server</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="307"/>
<location filename="../src/configdialog.cpp" line="305"/>
<source>new server</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="381"/>
<location filename="../src/configdialog.cpp" line="379"/>
<source>Select an image file as watermark</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="381"/>
<location filename="../src/configdialog.cpp" line="379"/>
<source>Images (*.png *.gif *.jpg)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="439"/>
<location filename="../src/configdialog.cpp" line="437"/>
<source>Please enter the name of output format</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="442"/>
<location filename="../src/configdialog.cpp" line="440"/>
<source>Please enter the template of output format</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="470"/>
<location filename="../src/configdialog.cpp" line="468"/>
<source>new format</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="511"/>
<location filename="../src/configdialog.cpp" line="509"/>
<source>No tag is selected!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="513"/>
<location filename="../src/configdialog.cpp" line="511"/>
<source>Are you sure to delete all selected tags?</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="541"/>
<location filename="../src/configdialog.cpp" line="539"/>
<source>Restart needed</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="541"/>
<location filename="../src/configdialog.cpp" line="539"/>
<source>In order to switch language, you need to restart this program.</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -609,6 +607,19 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LocalStorageUploader</name>
<message>
<location filename="../src/protocols/localstorageprotocol.cpp" line="50"/>
<source>Failed to create folder</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/protocols/localstorageprotocol.cpp" line="57"/>
<source>Failed to open file for writing.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MigrationV0</name>
<message>
Expand Down
37 changes: 24 additions & 13 deletions i18n/fu.zh_cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
<message>
<location filename="../src/configdialog.ui" line="176"/>
<location filename="../src/configdialog.ui" line="620"/>
<location filename="../src/configdialog.cpp" line="26"/>
<source>Cancel</source>
<translation>取消</translation>
</message>
Expand Down Expand Up @@ -249,62 +248,61 @@
</message>
<message>
<location filename="../src/configdialog.ui" line="724"/>
<location filename="../src/configdialog.cpp" line="25"/>
<source>Ok</source>
<translation>确认</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="233"/>
<location filename="../src/configdialog.cpp" line="231"/>
<source>Please enter the name of server</source>
<translation>请输入服务器的名称</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="307"/>
<location filename="../src/configdialog.cpp" line="305"/>
<source>new server</source>
<translation>新建的服务器</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="381"/>
<location filename="../src/configdialog.cpp" line="379"/>
<source>Select an image file as watermark</source>
<translation>请选择一个图片文件作为水印</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="381"/>
<location filename="../src/configdialog.cpp" line="379"/>
<source>Images (*.png *.gif *.jpg)</source>
<translation>图像文件 (*.png *.gif *.jpg)</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="439"/>
<location filename="../src/configdialog.cpp" line="437"/>
<source>Please enter the name of output format</source>
<translation>请输入输出格式的名称</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="442"/>
<location filename="../src/configdialog.cpp" line="440"/>
<source>Please enter the template of output format</source>
<translation>请输出输出格式的模板</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="470"/>
<location filename="../src/configdialog.cpp" line="468"/>
<source>new format</source>
<translation>新建的格式</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="511"/>
<location filename="../src/configdialog.cpp" line="509"/>
<source>No tag is selected!</source>
<translation>未选择任何标签</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="513"/>
<location filename="../src/configdialog.cpp" line="511"/>
<source>Are you sure to delete all selected tags?</source>
<translation>您确认要删除所选的标签吗?</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="541"/>
<location filename="../src/configdialog.cpp" line="539"/>
<source>Restart needed</source>
<translation>需要重启</translation>
</message>
<message>
<location filename="../src/configdialog.cpp" line="541"/>
<location filename="../src/configdialog.cpp" line="539"/>
<source>In order to switch language, you need to restart this program.</source>
<translation>为了切换语言,您需要重新启动本程序</translation>
</message>
Expand Down Expand Up @@ -609,6 +607,19 @@
<translation>本地存储</translation>
</message>
</context>
<context>
<name>LocalStorageUploader</name>
<message>
<location filename="../src/protocols/localstorageprotocol.cpp" line="50"/>
<source>Failed to create folder</source>
<translation>创建文件夹失败</translation>
</message>
<message>
<location filename="../src/protocols/localstorageprotocol.cpp" line="57"/>
<source>Failed to open file for writing.</source>
<translation>无法打开文件进行写入</translation>
</message>
</context>
<context>
<name>MigrationV0</name>
<message>
Expand Down
33 changes: 19 additions & 14 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ bool Application::prepare(const QString &dbPath)
{
// create folder
QFileInfo dbFileInfo(dbPath);
if (!dbFileInfo.exists() && !dbFileInfo.dir().exists()) {
bool firstRun = !dbFileInfo.exists();
if (firstRun && !dbFileInfo.dir().exists()) {
dbFileInfo.dir().mkdir(".");
}

Expand All @@ -116,24 +117,28 @@ bool Application::prepare(const QString &dbPath)
_sqlDb = QSqlDatabase::addDatabase("QSQLITE");
_sqlDb.setDatabaseName(_dbPath);
_sqlDb.open();
_tagService = new TagService();
_serverService = new ServerService();
_settingService = new SettingService();
_formatService = new FormatService();
_clipService = new ClipService();
_uploadService = new UploadService();

auto lang = _settingService->lang();
if (!firstRun) {
auto lang = _settingService->lang();

// setup i18n
qDebug() << "lang" << lang;
if (!lang.isEmpty()) {
QTranslator *qTranslator = new QTranslator(this);
qDebug() << "lang" << QString("fu.%1.qm").arg(lang);
qTranslator->load(QString("fu.%1.qm").arg(lang), "./i18n");
installTranslator(qTranslator);
// setup i18n
qDebug() << "lang" << lang;
if (!lang.isEmpty()) {
QTranslator *qTranslator = new QTranslator(this);
qDebug() << "lang" << QString("fu.%1.qm").arg(lang);
qTranslator->load(QString("fu.%1.qm").arg(lang), "./i18n");
installTranslator(qTranslator);
}
qDebug() << "lang set to " << lang;
}

_serverService = new ServerService();
_tagService = new TagService();
_formatService = new FormatService();
_clipService = new ClipService();
_uploadService = new UploadService();

#ifdef Q_OS_WIN
auto f = font();
f.setFamily("Microsoft YaHei");
Expand Down
1 change: 1 addition & 0 deletions src/protocols/ftpprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class FtpUploader : public Uploader

class FtpProtocol : public Protocol
{
Q_OBJECT
QList<ProtocolSettingInfo> _settingInfos;
public:
FtpProtocol();
Expand Down
1 change: 1 addition & 0 deletions src/protocols/imgurprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ImgurUploader: public Uploader

class ImgurProtocol : public Protocol
{
Q_OBJECT
QList<ProtocolSettingInfo> _settingInfos;
public:
ImgurProtocol();
Expand Down
18 changes: 15 additions & 3 deletions src/protocols/localstorageprotocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,24 @@ void LocalStorageUploader::upload(QIODevice *stream, UploadJob &job)
QString path = formatPath(_settings["folder"].toString(), job.name);
QString fullpath = joinPath(_settings["root"].toString(), path);

QFile outputFile(fullpath);
if (outputFile.exists() && !job.overwrite) {
QFileInfo fi(fullpath);

if (fi.exists() && !job.overwrite) {
job.status = Duplicated;
return;
}
outputFile.open(QIODevice::WriteOnly);
if (!fi.dir().exists() && !fi.dir().mkpath(".")) {
job.status = Error;
job.msg = tr("Failed to create folder");
return;
}

QFile outputFile(fullpath);
if (!outputFile.open(QIODevice::WriteOnly)) {
job.status = Error;
job.msg = tr("Failed to open file for writing.");
return;
}
const size_t BUFFER_SIZE = 1024 * 256;
char *buffer = new char[BUFFER_SIZE];
while (!stream->atEnd()) {
Expand Down
2 changes: 2 additions & 0 deletions src/protocols/localstorageprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class LocalStorageUploader : public Uploader
{
Q_OBJECT
QVariantMap _settings;

public:
Expand All @@ -16,6 +17,7 @@ class LocalStorageUploader : public Uploader

class LocalStorageProtocol : public Protocol
{
Q_OBJECT
QList<ProtocolSettingInfo> _settingInfos;

public:
Expand Down
1 change: 1 addition & 0 deletions src/protocols/qiniuprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class QiniuUploader: public Uploader

class QiniuProtocol : public Protocol
{
Q_OBJECT
QList<ProtocolSettingInfo> _settingInfos;
public:
QiniuProtocol();
Expand Down
Loading

0 comments on commit 2eca577

Please sign in to comment.