1
0
mirror of https://github.com/chylex/Nextcloud-Desktop.git synced 2025-04-29 04:15:44 +02:00

Implemented a file dialog for choosing the Sync Directory.

Disable and enable save button as appropriate.
This commit is contained in:
Juan Carlos Cornejo 2011-11-04 16:50:29 -04:00 committed by Klaas Freitag
parent 41c9e90852
commit add4cf24e3
3 changed files with 63 additions and 8 deletions

View File

@ -12,6 +12,7 @@
#include <QTimer>
#include <QSystemTrayIcon>
#include <QFileSystemWatcher>
#include <QFileDialog>
SyncWindow::SyncWindow(QWidget *parent) :
QMainWindow(parent),
@ -20,6 +21,9 @@ SyncWindow::SyncWindow(QWidget *parent) :
mBusy = false;
ui->setupUi(this);
mSyncTimer = 0; // So we can delete it without worrying :)
mIsFirstRun = true;
// Setup icons
mDefaultIcon = QIcon(":images/owncloud.png");
mSyncIcon = QIcon(":images/owncloud_sync.png");
@ -86,6 +90,7 @@ SyncWindow::SyncWindow(QWidget *parent) :
mDBOpen = true;
loadDBFromFile();
readConfigFromDB();
ui->buttonSave->setDisabled(true);
initialize();
}
}
@ -94,10 +99,6 @@ SyncWindow::SyncWindow(QWidget *parent) :
connect(mSaveDBTimer, SIGNAL(timeout()), this, SLOT(saveDBToFile()));
mSaveDBTimer->start(370000);
// Connect the SaveButton
connect(ui->buttonSave, SIGNAL(clicked()),
this,SLOT(saveButtonClicked()));
updateStatus();
}
@ -659,8 +660,9 @@ void SyncWindow::createDataBase()
}
void SyncWindow::saveButtonClicked()
void SyncWindow::on_buttonSave_clicked()
{
ui->buttonSave->setDisabled(true);
QString host = ui->lineHost->text();
// Add /files/webdav.php but remove what the user may have added
mHost = host.replace("/files/webdav.php","") + "/files/webdav.php";
@ -722,9 +724,15 @@ void SyncWindow::initialize()
mFileWatcher->addPath(mSyncDirectory+"/");
// Synchronize then start the timer
// Synchronize (only if it is not synchronizing right now) then start the timer
if(mIsFirstRun) {
timeToSync();
}
mIsFirstRun = true;
timeToSync();
if(mSyncTimer) {
mSyncTimer->stop();
}
delete mSyncTimer;
mSyncTimer = new QTimer(this);
connect(mSyncTimer, SIGNAL(timeout()), this, SLOT(timeToSync()));
mSyncTimer->start(mUpdateTime*1000);
@ -892,3 +900,37 @@ void SyncWindow::dropFromDB(QString table, QString column, QString condition)
QSqlQuery drop;
drop.exec("DELETE FROM "+table+" WHERE "+column+"='"+condition+"';");
}
void SyncWindow::on_buttonSyncDir_clicked()
{
QString syncDir = QFileDialog::getExistingDirectory(this);
if( syncDir != "" ) {
ui->lineSyncDir->setText(syncDir);
ui->buttonSave->setEnabled(true);
}
}
void SyncWindow::on_linePassword_textEdited(QString text)
{
ui->buttonSave->setEnabled(true);
}
void SyncWindow::on_lineHost_textEdited(QString text)
{
ui->buttonSave->setEnabled(true);
}
void SyncWindow::on_lineSyncDir_textEdited(QString text)
{
ui->buttonSave->setEnabled(true);
}
void SyncWindow::on_lineUser_textEdited(QString text)
{
ui->buttonSave->setEnabled(true);
}
void SyncWindow::on_time_valueChanged(int value)
{
ui->buttonSave->setEnabled(true);
}

View File

@ -103,12 +103,20 @@ public slots:
void updateStatus();
void transferProgress(qint64 current,qint64 total);
void systemTrayActivated(QSystemTrayIcon::ActivationReason reason);
void saveButtonClicked();
void localFileChanged(QString name);
void localDirectoryChanged(QString name);
void closeEvent(QCloseEvent *event);
void saveDBToFile();
void loadDBFromFile();
// GUI related slots
void on_buttonSave_clicked();
void on_buttonSyncDir_clicked();
void on_linePassword_textEdited(QString text);
void on_lineHost_textEdited(QString text);
void on_lineSyncDir_textEdited(QString text);
void on_lineUser_textEdited(QString text);
void on_time_valueChanged(int value);
};
#endif // SYNCWINDOW_H

View File

@ -76,6 +76,9 @@
</item>
<item row="4" column="4">
<widget class="QPushButton" name="buttonSave">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Save</string>
</property>
@ -179,6 +182,8 @@
<tabstop>lineUser</tabstop>
<tabstop>linePassword</tabstop>
<tabstop>lineSyncDir</tabstop>
<tabstop>time</tabstop>
<tabstop>buttonSave</tabstop>
<tabstop>buttonSyncDir</tabstop>
<tabstop>textBrowser</tabstop>
</tabstops>