Skip to content

Commit

Permalink
Merge pull request #152 from fxdeniz/issue_151
Browse files Browse the repository at this point in the history
Issue 151
  • Loading branch information
fxdeniz authored Sep 27, 2023
2 parents eee0536 + bb5a4df commit 4268515
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Dependency/efsw
4 changes: 2 additions & 2 deletions Gui/Dialogs/DialogCreateCopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ void DialogCreateCopy::on_buttonCreateCopy_clicked()
QFuture<void> future = QtConcurrent::run([=, &isCopied] {

auto fsm = FileStorageManager::instance();
QJsonObject fileJson = fsm->getFileVersionJson(currentFileSymbolPath, ui->comboBox->currentText().toInt());
QJsonObject versionJson = fsm->getFileVersionJson(currentFileSymbolPath, ui->comboBox->currentText().toInt());

QString internalFilePath = fsm->getStorageFolderPath();
internalFilePath += fileJson[JsonKeys::FileVersion::InternalFileName].toString();
internalFilePath += versionJson[JsonKeys::FileVersion::InternalFileName].toString();

QFile::remove(userFilePath);
isCopied = QFile::copy(internalFilePath, userFilePath);
Expand Down
2 changes: 1 addition & 1 deletion Gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ void MainWindow::on_menuAction_DebugFileMonitor_triggered()
void MainWindow::on_menuAction_AboutApp_triggered()
{
QString title = tr("About NeSync");
QString message = tr("<center><h1>NeSync 1.9.0 [Pre-Alpha]</h1><center/>"
QString message = tr("<center><h1>NeSync 1.10.0 [Pre-Alpha]</h1><center/>"
"<hr>"
"Thanks for using NeSync.<br>"
"This is a <b>pre-alpha version</b>, <b>DO NOT USE</b> for critical things.<br>"
Expand Down
94 changes: 91 additions & 3 deletions Gui/Tabs/TabFileExplorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QtConcurrent>
#include <QStandardPaths>
#include <QProgressDialog>
#include <QDesktopServices>

TabFileExplorer::TabFileExplorer(QWidget *parent) :
QWidget(parent),
Expand Down Expand Up @@ -67,12 +68,14 @@ void TabFileExplorer::buildContextMenuListFileExplorer()
contextMenuListFileExplorer = new QMenu(ui->listView);
QMenu *ptrMenu = contextMenuListFileExplorer;

QAction *actionEditVersion = ui->contextActionListView_EditVersion;
QAction *actionPreivew = ui->contextActionListView_Preview;
QAction *actionEditDescription = ui->contextActionListView_EditDescription;
QAction *actionCreateCopy = ui->contextActionListView_CreateCopy;
QAction *actionSetAsCurrentVerion = ui->contextActionListView_SetAsCurrentVersion;
QAction *actionDelete = ui->contextActionListView_DeleteVersion;

ptrMenu->addAction(actionEditVersion);
ptrMenu->addAction(actionPreivew);
ptrMenu->addAction(actionEditDescription);
ptrMenu->addAction(actionCreateCopy);
ptrMenu->addAction(actionSetAsCurrentVerion);
ptrMenu->addAction(actionDelete);
Expand Down Expand Up @@ -357,7 +360,92 @@ void TabFileExplorer::clearDescriptionDetails()
delete listModel;
}

void TabFileExplorer::on_contextActionListView_EditVersion_triggered()
void TabFileExplorer::on_contextActionListView_Preview_triggered()
{
QItemSelectionModel *tableViewSelectionModel = ui->tableView->selectionModel();
QModelIndexList listSymbolPath = tableViewSelectionModel->selectedRows(TableModelFileExplorer::ColumnIndexSymbolPath);
auto fileSymbolPath = listSymbolPath.first().data().toString();

QModelIndexList listFileName = tableViewSelectionModel->selectedRows(TableModelFileExplorer::ColumnIndexName);
auto fileName = listFileName.first().data().toString();

QString fileExtension = "";
QStringList tokens = fileName.split(".");

if(tokens.size() != 1)
fileExtension = tokens.last();


QItemSelectionModel * listViewSelectionModel = ui->listView->selectionModel();
QModelIndexList listVersionNumber = listViewSelectionModel->selectedRows(ListModelFileExplorer::ColumnIndexVersionNumber);
auto versionNumber = listVersionNumber.first().data().toLongLong();

QFutureWatcher<void> futureWatcher;
QProgressDialog dialog(this);
dialog.setLabelText(tr("Creating preview copy from version <b>%1</b> of file <b>%2</b>...")
.arg(versionNumber)
.arg(fileName)
);

QObject::connect(&futureWatcher, &QFutureWatcher<void>::finished, &dialog, &QProgressDialog::reset);
QObject::connect(&dialog, &QProgressDialog::canceled, &futureWatcher, &QFutureWatcher<void>::cancel);
QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressRangeChanged, &dialog, &QProgressDialog::setRange);
QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressValueChanged, &dialog, &QProgressDialog::setValue);

bool isCopied = false;
QString tempFilePath;

QFuture<void> future = QtConcurrent::run([=, &isCopied, &tempFilePath] {

auto fsm = FileStorageManager::instance();
QJsonObject versionJson = fsm->getFileVersionJson(fileSymbolPath, versionNumber);

QString internalFilePath = fsm->getStorageFolderPath();
internalFilePath += versionJson[JsonKeys::FileVersion::InternalFileName].toString();

QFile actualFile(internalFilePath);
actualFile.open(QFile::OpenModeFlag::ReadOnly);

QTemporaryFile tempFile;
tempFile.open();
tempFilePath = tempFile.fileName().replace(".", "_");
tempFile.remove();

if(!fileExtension.isEmpty())
tempFilePath += "." + fileExtension;

isCopied = QFile::copy(internalFilePath, tempFilePath);
});

futureWatcher.setFuture(future);
dialog.exec();
futureWatcher.waitForFinished();

if(isCopied)
{
bool isOpened = QDesktopServices::openUrl(QUrl(tempFilePath, QUrl::ParsingMode::TolerantMode));

if(!isOpened)
{
QString title = tr("Can't open preview copy of the file !");
QString message = tr("Preview copy of the file <b>%1</b> couldn't opened.<br>"
"Please install program for opening corresponding format and re-try.");
message = message.arg(fileName);
QMessageBox::critical(this, title, message);
return;
}
}
else
{
QString title = tr("Can't create preview copy of the file !");
QString message = tr("Preview copy of the file <b>%1</b> couldn't created in the temp directory.");
message = message.arg(fileName);
QMessageBox::critical(this, title, message);
return;
}
}

void TabFileExplorer::on_contextActionListView_EditDescription_triggered()
{
QItemSelectionModel *tableViewSelectionModel = ui->tableView->selectionModel();
QModelIndexList listSymbolPath = tableViewSelectionModel->selectedRows(TableModelFileExplorer::ColumnIndexSymbolPath);
Expand Down
3 changes: 2 additions & 1 deletion Gui/Tabs/TabFileExplorer.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ private slots:
void on_contextActionTableView_Export_triggered();
void on_contextActionTableView_Delete_triggered();
void on_contextActionTableView_Freeze_triggered();
void on_contextActionListView_EditVersion_triggered();
void on_contextActionListView_Preview_triggered();
void on_contextActionListView_EditDescription_triggered();
void on_contextActionListView_DeleteVersion_triggered();
void on_contextActionListView_CreateCopy_triggered();
void on_contextActionListView_SetAsCurrentVersion_triggered();
Expand Down
14 changes: 11 additions & 3 deletions Gui/Tabs/TabFileExplorer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,20 @@
<string>Delete</string>
</property>
</action>
<action name="contextActionListView_EditVersion">
<action name="contextActionListView_Preview">
<property name="text">
<string>Edit version</string>
<string>Preview</string>
</property>
<property name="toolTip">
<string>Edit version</string>
<string>Preview the selected version</string>
</property>
</action>
<action name="contextActionListView_EditDescription">
<property name="text">
<string>Edit description</string>
</property>
<property name="toolTip">
<string>Edit description of the selected version</string>
</property>
</action>
<action name="contextActionListView_CreateCopy">
Expand Down
2 changes: 1 addition & 1 deletion Installer/nsis_script.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Unicode True
!define APP_NAME "NeSync"
!define COMP_NAME "Deniz Yilmazok (github.com/fxdeniz)"
!define WEB_SITE "github.com/fxdeniz/NeSync"
!define VERSION "1.9.0.0"
!define VERSION "1.10.0.0"
!define COPYRIGHT "2023 - Deniz Yilmazok, GPLv3"
!define DESCRIPTION "NeSync Installer"
!define INSTALLER_NAME "${BIN_SOURCE_DIR}\nesync_${VERSION}_win64_setup.exe"
Expand Down
8 changes: 4 additions & 4 deletions Resources/res_win.rc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
IDI_ICON1 ICON "app_icon.ico"

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,9,0,0
PRODUCTVERSION 1,9,0,0
FILEVERSION 1,10,0,0
PRODUCTVERSION 1,10,0,0
FILEFLAGS 0x0L
FILEFLAGSMASK 0x3fL
FILEOS 0x00040004L
Expand All @@ -17,12 +17,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Deniz Yilmazok (github.com/fxdeniz)"
VALUE "FileDescription", "NeSync - Local file sync & backups"
VALUE "FileVersion", "1.9.0.0"
VALUE "FileVersion", "1.10.0.0"
VALUE "LegalCopyright", "2023 - Deniz Yilmazok, GPLv3"
VALUE "InternalName", "NeSync"
VALUE "OriginalFilename", "NeSync.exe"
VALUE "ProductName", "NeSync"
VALUE "ProductVersion", "1.9.0.0"
VALUE "ProductVersion", "1.10.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 4268515

Please sign in to comment.