bug resolved

This commit is contained in:
2023-05-01 14:27:20 +02:00
parent c811f3db4f
commit f882ca5e42
6 changed files with 67 additions and 115 deletions
+60 -47
View File
@@ -242,36 +242,37 @@ void MainWindow::quitApp()
void MainWindow::closeEvent (QCloseEvent *event)
{
QMessageBox msgBox;
QCheckBox *cb = new QCheckBox("Don't show this again ?");
QCheckBox *cb;
if (!event->spontaneous() || !isVisible())
return;
if (trayIcon->isVisible() and this->settings.value("CloseCheckbox").toBool() == false)
if (trayIcon->isVisible() and this->settings.value("CloseCheckbox").toBool() == false)
{
cb = new QCheckBox("Don't show this again ?");
msgBox.setWindowTitle(a.applicationName());
msgBox.setInformativeText(tr("The program will keep running in the "
"system tray. To terminate the program, "
"choose <b>Quit</b> in the context menu "
"of the system tray entry."));
msgBox.addButton(QMessageBox::Ok);
//msgBox.addButton(QMessageBox::No);
// msgBox.setDefaultButton(QMessageBox::Yes);
msgBox.setCheckBox(cb);
msgBox.exec();
msgBox.clickedButton();
// if response is yes then loading list
if (cb->isChecked())
{
msgBox.setWindowTitle(a.applicationName());
msgBox.setInformativeText(tr("The program will keep running in the "
"system tray. To terminate the program, "
"choose <b>Quit</b> in the context menu "
"of the system tray entry."));
msgBox.addButton(QMessageBox::Ok);
//msgBox.addButton(QMessageBox::No);
// msgBox.setDefaultButton(QMessageBox::Yes);
msgBox.setCheckBox(cb);
msgBox.exec();
msgBox.clickedButton();
// if response is yes then loading list
if (cb->isChecked())
{
this->settings.setValue("CloseCheckbox", true);
}
hide();
this->settings.setValue("CloseCheckbox", true);
}
hide();
//event->accept();
event->ignore();
}
//event->accept();
event->ignore();
}
}
// Populate treeview with list of files
@@ -484,6 +485,7 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
QString filename;
QString fileType;
QString date;
QString dirName = "";
QProcess * myProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
bool isDir = false;
@@ -493,6 +495,7 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
int nChild = 0;
bool r;
static uint looping;
QStringList dirs;
myProcess = new QProcess(this);
myProcess->setProcessChannelMode(QProcess::MergedChannels);
@@ -556,7 +559,7 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
return false;
}
// extracting name, size and if is dir/file
// extracting name, size and is dir/file
line = line.simplified();
filename = line.section(" ", 4);
if (filename != '.')
@@ -569,8 +572,8 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
{
size = sizeA.at(0) + " " + UnitText[0] + " ";
}else
{ myProcess->setProcessEnvironment(env);
{
myProcess->setProcessEnvironment(env);
size = sizeA.at(0) + "," + sizeA.at(1).left(2) + " " + UnitText[sizeA.count()-1] + " ";
}
@@ -581,9 +584,19 @@ bool MainWindow::scanDir(QString server, int portN, QTreeWidgetItem *parent, QSt
{
isDir = false;
}
date = line.section(' ', 2, 2);
fileType = getFileType(filename);
addTreeItem(filename, size, fullsize, fileType, date, isDir, parent);
if (!path.isEmpty())
{
if (path.endsWith('/'))
{
path.chop(1);
}
dirs = path.split('/');
dirName = dirs[dirs.size()-1];
}
addTreeItem(filename, size, fullsize, fileType, date, isDir, dirName, parent);
if (passwdOk == false and !this->connexion.password.isEmpty())
{
this->settings.setValue("Passwords/" + this->connexion.server + "/" + this->connexion.service + "/" + this->connexion.user, true);
@@ -710,9 +723,9 @@ void MainWindow::on_connectButton_clicked()
}
// add parent in treeview
void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, QString type, QString date, bool isDir=false, QTreeWidgetItem *parent=nullptr)
void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, QString type, QString date, bool isDir=false, QString dirName="", QTreeWidgetItem *parent=nullptr)
{
QFont * font = new QFont();
QFont font;
QTreeWidgetItem *treeItem;
if (parent != nullptr)
@@ -722,6 +735,20 @@ void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, Q
{
treeItem = new QTreeWidgetItem(ui->treeWidget);
}
// item is a file
if (QFile::exists(this->downloading.savePath + "/" + name) or QFile::exists(this->downloading.savePath + "/" + dirName + "/" + name))
{
QBrush b (Qt::green);
treeItem->setForeground(0, b);
treeItem->setFont(0, font);
}else if (this->settings.contains(name))
{
QBrush b (Qt::red);
treeItem->setForeground(0, b);
treeItem->setFont(0, font);
}
if (isDir == true)
{
// item is a dir
@@ -729,23 +756,8 @@ void MainWindow::addTreeItem(QString name, QString fileSize, QString fullsize, Q
treeItem->setIcon(0, QIcon::fromTheme("folder"));
}else
{
// item is a file
if (QFile::exists(this->downloading.savePath + "/" + name))
{
QBrush b (Qt::green);
treeItem->setForeground(0, b);
treeItem->setFont(0, *font);
}else
{
this->settings.beginGroup("Downloaded/");
if (this->settings.contains(name))
{
QBrush b (Qt::red);
treeItem->setForeground(0, b);
treeItem->setFont(0, *font);
}
this->settings.endGroup();
}
this->settings.beginGroup("Downloaded/");
this->settings.endGroup();
treeItem->setText(1,type);
}
treeItem->setText(0, name);
@@ -1401,3 +1413,4 @@ void MainWindow::on_actionHiddenService_triggered()
preparePopulateTree();
}
}