debugged\nadded return key action
This commit is contained in:
+25
-13
@@ -20,9 +20,9 @@
|
||||
#include <QFileDialog>
|
||||
#include <QThread>
|
||||
#include <QProgressDialog>
|
||||
#include <QCheckBox>
|
||||
#include <sys/wait.h>
|
||||
#include <QGuiApplication>
|
||||
#include <QShortcut>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -37,10 +37,16 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
QCoreApplication::setOrganizationName("RsyncUI");
|
||||
QCoreApplication::setApplicationName("RsyncUI");
|
||||
|
||||
// init shortcut
|
||||
|
||||
// QShortcut * shortcut = new QShortcut(QKeySequence("Return"), this);
|
||||
loadSettings();
|
||||
|
||||
// connectors
|
||||
connect(&downloadO, &downloadFile::progressSignal, ui->progressBar, &QProgressBar::setValue);
|
||||
connect(&downloadO, &downloadFile::finishedSignal, this, &MainWindow::downloadFinished);
|
||||
connect(this, &MainWindow::stopDownloading, &downloadO, &downloadFile::cancelled);
|
||||
//connect(shortcut, SIGNAL(activated()), this, SLOT(returnPressed()));
|
||||
|
||||
// init of widgets
|
||||
ui->ktreewidgetsearchline->setTreeWidget(ui->treeWidget);
|
||||
@@ -48,10 +54,12 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
ui->treeWidget->setHeaderLabels({tr("Path"), tr("Size")} );
|
||||
ui->progressBar->hide();
|
||||
|
||||
loadSettings();
|
||||
|
||||
populateList();
|
||||
}
|
||||
|
||||
void MainWindow::returnPressed()
|
||||
{
|
||||
populateList();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -84,6 +92,7 @@ void MainWindow::populateTree()
|
||||
stringstream ss;
|
||||
vector<string> path;
|
||||
|
||||
ui->treeWidget->clear();
|
||||
if (!this->connexion.server.empty() and this->connexion.port > 0 and this->connexion.port < 65536)
|
||||
{
|
||||
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
@@ -103,11 +112,11 @@ void MainWindow::populateList()
|
||||
QString server;
|
||||
QString port;
|
||||
|
||||
ui->listWidget->clear();
|
||||
server = ui->khistorycombobox->currentText();
|
||||
this->connexion.server.assign(server.toStdString());
|
||||
ss << ui->portEdit->text().toStdString();
|
||||
ss >> this->connexion.port;
|
||||
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
this->settings.beginGroup("connexion/server");
|
||||
if (this->settings.contains(server))
|
||||
@@ -134,7 +143,9 @@ void MainWindow::populateList()
|
||||
}
|
||||
// "waiting" cursor
|
||||
// load and display rsync services of the rsync server
|
||||
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
listServices();
|
||||
QGuiApplication::restoreOverrideCursor(); //setOverrideCursor(Qt::ArrowCursor);
|
||||
}
|
||||
}
|
||||
this->settings.endGroup();
|
||||
@@ -149,7 +160,6 @@ void MainWindow::listServices()
|
||||
vector<string> v;
|
||||
char service[4096];
|
||||
|
||||
ui->listWidget->clear();
|
||||
sprintf(cmd, "rsync --contimeout=10 -P \"%s::\" --port %d ", this->connexion.server.c_str(), this->connexion.port );
|
||||
redi::ipstream in(cmd, redi::pstreams::pstdout | redi::pstreams::pstderr);
|
||||
while (getline(in.out(), line))
|
||||
@@ -236,8 +246,11 @@ bool MainWindow::isIpAddress(string server)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::validateServer(string server)
|
||||
@@ -304,17 +317,17 @@ void MainWindow::on_khistorycombobox_returnPressed()
|
||||
|
||||
void MainWindow::on_khistorycombobox_currentIndexChanged(int i)
|
||||
{
|
||||
this->populateList();
|
||||
populateList();
|
||||
}
|
||||
|
||||
void MainWindow::on_portEdit_returnPressed()
|
||||
{
|
||||
populateList();
|
||||
//populateList();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDownload_triggered()
|
||||
void MainWindow::on_connectButton_clicked()
|
||||
{
|
||||
|
||||
populateList();
|
||||
}
|
||||
|
||||
QTreeWidgetItem * MainWindow::addTreeRoot(QString name, QString fileSize)
|
||||
@@ -342,7 +355,7 @@ QTreeWidgetItem * MainWindow::addTreeChild(QTreeWidgetItem *parent, QString name
|
||||
return treeItem;
|
||||
}
|
||||
|
||||
void MainWindow::on_listWidget_clicked(const QModelIndex &index)
|
||||
void MainWindow::on_listWidget_clicked()
|
||||
{
|
||||
vector<string> v;
|
||||
v = explode(ui->listWidget->currentItem()->text().toStdString(), '\n', 2);
|
||||
@@ -350,11 +363,10 @@ void MainWindow::on_listWidget_clicked(const QModelIndex &index)
|
||||
populateTree();
|
||||
}
|
||||
|
||||
void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item)
|
||||
{
|
||||
QFuture<void> future;
|
||||
QFileDialog dialog;
|
||||
QCheckBox *cb = new QCheckBox("Okay I understand");
|
||||
|
||||
item = ui->treeWidget->currentItem();
|
||||
this->downloading.path = item->text(0).toStdString();
|
||||
|
||||
Reference in New Issue
Block a user