Show warning on wrong remote folder

This commit is contained in:
Klaas Freitag 2011-10-12 15:14:39 +02:00
parent 91b12c7eb3
commit c4b24ab952
4 changed files with 110 additions and 10 deletions

View file

@ -55,8 +55,7 @@ bool FolderWizardSourcePage::isComplete() const
bool isOk = selFile.isDir();
if( !isOk ) {
_ui.warnLabel->show();
_ui.warnLabel->setText(tr("HEHHHAH"));
warnString = tr("No local directory selected!");
}
// check if the local directory isn't used yet in another ownCloud sync
Folder::Map *map = _folderMap;
@ -69,7 +68,7 @@ bool FolderWizardSourcePage::isComplete() const
qDebug() << "Checking local path: " << f->path() << " <-> " << selFile.absoluteFilePath();
if( QFileInfo( f->path() ) == selFile ) {
isOk = false;
warnString = tr("The local path %1 is already a upload folder.<br/>Please pick another one!").arg(selFile.absoluteFilePath());
warnString.append( tr("The local path %1 is already a upload folder.<br/>Please pick another one!").arg(selFile.absoluteFilePath()) );
}
i++;
}
@ -127,6 +126,7 @@ void FolderWizardSourcePage::on_localFolderLineEdit_textChanged()
FolderWizardTargetPage::FolderWizardTargetPage()
{
_ui.setupUi(this);
_ui.warnLabel->hide();
registerField("local?", _ui.localFolderRadioBtn);
registerField("remote?", _ui.urlFolderRadioBtn);
@ -145,7 +145,7 @@ FolderWizardTargetPage::FolderWizardTargetPage()
_ownCloudDirCheck = new ownCloudDirCheck( this );
connect( _ownCloudDirCheck, SIGNAL(directoryExists(QString,bool)),
SLOT(slotInfoReply(QString,bool)));
SLOT(slotDirCheckReply(QString,bool)));
}
void FolderWizardTargetPage::slotFolderTextChanged( const QString& t)
@ -155,6 +155,7 @@ void FolderWizardTargetPage::slotFolderTextChanged( const QString& t)
if( t.isEmpty() ) {
_timer->stop();
_ui.warnLabel->hide();
return;
}
@ -168,10 +169,16 @@ void FolderWizardTargetPage::slotTimerFires()
_ownCloudDirCheck->checkDirectory( folder );
}
void FolderWizardTargetPage::slotInfoReply(const QString &url, bool exists )
void FolderWizardTargetPage::slotDirCheckReply(const QString &url, bool exists )
{
qDebug() << "Got reply from ownCloudInfo: " << url << " :" << exists;
_dirChecked = exists;
if( _dirChecked ) {
_ui.warnLabel->hide();
} else {
showWarn( tr("The folder is not available on your ownCloud. Please create it.") );
}
emit completeChanged();
}
@ -230,6 +237,12 @@ void FolderWizardTargetPage::slotNoOwnCloudFound()
_ui.OCFolderLineEdit->setEnabled( false );
}
void FolderWizardTargetPage::showWarn( const QString& msg )
{
_ui.warnLabel->show();
_ui.warnLabel->setText( msg );
}
void FolderWizardTargetPage::on_localFolderRadioBtn_toggled()
{
slotToggleItems();

View file

@ -84,8 +84,8 @@ protected slots:
void slotFolderTextChanged( const QString& );
void slotTimerFires();
void slotInfoReply( const QString&, bool );
void slotDirCheckReply( const QString&, bool );
void showWarn( const QString& );
private:
Ui_FolderWizardTargetPage _ui;
QTimer *_timer;

View file

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>431</width>
<height>292</height>
<height>296</height>
</rect>
</property>
<property name="windowTitle">
@ -186,6 +186,92 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="warnLabel">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>192</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>192</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>192</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>192</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="margin">
<number>3</number>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>

View file

@ -122,8 +122,9 @@ void ownCloudInfo::slotReadyRead()
_readBuffer.append(_reply->readAll());
}
void ownCloudInfo::slotError( QNetworkReply::NetworkError )
void ownCloudInfo::slotError( QNetworkReply::NetworkError err)
{
qDebug() << "Network Error: " << err;
emit noOwncloudFound();
}