- now saving state of widgets
This commit is contained in:
parent
cb384e1c51
commit
13c5c3788f
@ -33,10 +33,16 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
, ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QCoreApplication::setOrganizationName("RsyncUI");
|
||||
QCoreApplication::setApplicationName("RsyncUI");
|
||||
|
||||
// connectors
|
||||
connect(&downloadO, &downloadFile::progressSignal, ui->progressBar, &QProgressBar::setValue);
|
||||
connect(&downloadO, &downloadFile::finishedSignal, this, &MainWindow::downloadFinished);
|
||||
connect(this, &MainWindow::stopDownloading, &downloadO, &downloadFile::cancelled);
|
||||
|
||||
// init of widgets
|
||||
ui->ktreewidgetsearchline->setTreeWidget(ui->treeWidget);
|
||||
ui->ktreewidgetsearchline->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
ui->treeWidget->setHeaderLabels({tr("Path"), tr("Size")} );
|
||||
@ -86,7 +92,7 @@ void MainWindow::populateTree()
|
||||
path = explode(ui->listWidget->currentItem()->text().toStdString(), '\n', 2);
|
||||
scanDir(this->connexion.server, this->connexion.port, NULL, path[0].append("/") );
|
||||
}
|
||||
QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
|
||||
QGuiApplication::restoreOverrideCursor(); //setOverrideCursor(Qt::ArrowCursor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +138,7 @@ void MainWindow::populateList()
|
||||
}
|
||||
}
|
||||
this->settings.endGroup();
|
||||
QGuiApplication::setOverrideCursor(Qt::ArrowCursor);
|
||||
QGuiApplication::restoreOverrideCursor(); //setOverrideCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void MainWindow::listServices()
|
||||
@ -298,11 +304,7 @@ void MainWindow::on_khistorycombobox_returnPressed()
|
||||
|
||||
void MainWindow::on_khistorycombobox_currentIndexChanged(int i)
|
||||
{
|
||||
/*QString server = ui->khistorycombobox->currentText();
|
||||
this->settings.beginGroup("connexion/server");
|
||||
ui->portEdit->setText(this->settings.value(server).toString());
|
||||
this->settings.endGroup();*/
|
||||
this->populateList();
|
||||
this->populateList();
|
||||
}
|
||||
|
||||
void MainWindow::on_portEdit_returnPressed()
|
||||
@ -370,8 +372,10 @@ void MainWindow::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int colu
|
||||
{
|
||||
this->downloading.dirPath = getenv("HOME");
|
||||
}
|
||||
|
||||
this->downloading.savePath = dialog.getExistingDirectory(this, tr("Choose directory to save file"), this->downloading.dirPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString();
|
||||
if (this->downloading.savePath.empty())
|
||||
{
|
||||
on_DefaultSaveFolder_triggered();
|
||||
}
|
||||
if (!this->downloading.savePath.empty() && this->downloading.pid == 0)
|
||||
{
|
||||
startDownloading();
|
||||
@ -443,11 +447,16 @@ void MainWindow::on_listDownload_itemClicked(QListWidgetItem *item)
|
||||
void MainWindow::loadSettings()
|
||||
{
|
||||
this->restoreGeometry(settings.value("window/geometry").toByteArray());
|
||||
this->restoreState(settings.value("window/state").toByteArray());
|
||||
ui->treeWidget->header()->restoreState(settings.value("treeView/state").toByteArray());
|
||||
ui->splitter->restoreState(settings.value("splitter/state").toByteArray());
|
||||
ui->splitter_2->restoreState(settings.value("splitter2/state").toByteArray());
|
||||
|
||||
this->settings.beginGroup("connexion/server");
|
||||
|
||||
QStringList servers = this->settings.allKeys();
|
||||
this->settings.endGroup();
|
||||
|
||||
this->downloading.dirPath = this->settings.value("Folder").toString();
|
||||
for( const QString &server : servers )
|
||||
{
|
||||
ui->khistorycombobox->addToHistory(server);
|
||||
@ -458,6 +467,12 @@ void MainWindow::loadSettings()
|
||||
void MainWindow::saveSettings()
|
||||
{
|
||||
this->settings.setValue("window/geometry", saveGeometry());
|
||||
this->settings.setValue("window/state", saveState());
|
||||
//ui->treeWidget->header()->saveState();
|
||||
this->settings.setValue("treeView/state", ui->treeWidget->header()->saveState());
|
||||
this->settings.setValue("splitter/state", ui->splitter->saveState());
|
||||
this->settings.setValue("splitter2/state", ui->splitter_2->saveState());
|
||||
|
||||
this->settings.sync();
|
||||
}
|
||||
|
||||
@ -475,3 +490,12 @@ void MainWindow::on_actionAbout_Qt_triggered()
|
||||
{
|
||||
QMessageBox::aboutQt(this);
|
||||
}
|
||||
|
||||
void MainWindow::on_DefaultSaveFolder_triggered()
|
||||
{
|
||||
QFileDialog dialog;
|
||||
|
||||
this->downloading.savePath = dialog.getExistingDirectory(this, tr("Choose directory to save file"), this->downloading.dirPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks).toStdString();
|
||||
this->downloading.dirPath = this->downloading.savePath.c_str();
|
||||
this->settings.setValue("Folder/", this->downloading.dirPath);
|
||||
}
|
||||
|
@ -99,6 +99,8 @@ class MainWindow : public QMainWindow
|
||||
|
||||
void on_khistorycombobox_currentIndexChanged(int i);
|
||||
|
||||
void on_DefaultSaveFolder_triggered();
|
||||
|
||||
signals:
|
||||
void stopDownloading(int);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user