Claudio Valerio 13 years ago
parent 490b1be9fc
commit c7c4bca705
  1. 18
      src/core/UBApplicationController.cpp
  2. 23
      src/document/UBDocumentController.cpp
  3. 15
      src/gui/UBMainWindow.cpp
  4. 1
      src/gui/UBMainWindow.h

@ -520,7 +520,7 @@ void UBApplicationController::ftpCommandFinished(int id, bool error)
} }
else{ else{
QString responseString = QString(mFtp->readAll()); QString responseString = QString(mFtp->readAll());
if (!responseString.isEmpty() && responseString.contains("version:") && responseString.contains("url:")){ if (!responseString.isEmpty() && responseString.contains("version") && responseString.contains("url")){
mFtp->close(); mFtp->close();
downloadJsonFinished(responseString); downloadJsonFinished(responseString);
} }
@ -539,23 +539,9 @@ void UBApplicationController::downloadJsonFinished(QString currentJson)
UBVersion jsonVersion (scriptValue.property("version").toString().left(4)); UBVersion jsonVersion (scriptValue.property("version").toString().left(4));
if (installedVersion.isValid() && jsonVersion.isValid() && jsonVersion > installedVersion) { if (installedVersion.isValid() && jsonVersion.isValid() && jsonVersion > installedVersion) {
QMessageBox msgBox; if (UBApplication::mainWindow->yesNoQuestion(tr("Update available"), tr ("New update available, would you go to the web page ?"))){
msgBox.setText (tr ("New update available, would you go to the web page ?"));
msgBox.setStandardButtons (QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton (QMessageBox::Ok);
int ret = msgBox.exec();
switch (ret) {
case QMessageBox::Ok: {
QUrl url(scriptValue.property ("url").toString()); QUrl url(scriptValue.property ("url").toString());
QDesktopServices::openUrl (url); QDesktopServices::openUrl (url);
break;
}
case QMessageBox::Cancel:
// do nothing
break;
default:
// should never be reached
break;
} }
} }
else { else {

@ -476,7 +476,6 @@ void UBDocumentController::showKeyboard(bool show)
mKeyboardPalette->setVisible(show); mKeyboardPalette->setVisible(show);
} }
// mPaletteManager->showVirtualKeyboard(show);
} }
void UBDocumentController::setupPalettes() void UBDocumentController::setupPalettes()
@ -640,10 +639,7 @@ void UBDocumentController::deleteSelectedItem()
} }
} }
if (QMessageBox::question( 0, tr("Remove Page"), if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Page"), tr("Are you sure you want to remove %n page(s) from the selected document '%1'?", "", sceneIndexes.count()).arg(proxy->metaData(UBSettings::documentName).toString())))
tr("Are you sure you want to remove %n page(s) from the selected document '%1'?", "", sceneIndexes.count())
.arg(proxy->metaData(UBSettings::documentName).toString()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
{ {
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes); UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime())); proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
@ -668,9 +664,7 @@ void UBDocumentController::deleteSelectedItem()
if (proxyTi && proxyTi->proxy() && proxyTi->parent()) if (proxyTi && proxyTi->proxy() && proxyTi->parent())
{ {
if (QMessageBox::question( 0, tr("Remove Document"), if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Document"), tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString())))
tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
{ {
if (proxyTi->parent() == mTrashTi) if (proxyTi->parent() == mTrashTi)
{ {
@ -737,9 +731,7 @@ void UBDocumentController::deleteSelectedItem()
{ {
if (groupTi == mTrashTi) if (groupTi == mTrashTi)
{ {
if (QMessageBox::question( 0, tr("Empty Trash"), if(UBApplication::mainWindow->yesNoQuestion(tr("Empty Trash"), tr("Are you sure you want to empty trash?")))
tr("Are you sure you want to empty trash?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QList<UBDocumentProxyTreeItem*> toBeDeleted; QList<UBDocumentProxyTreeItem*> toBeDeleted;
@ -769,9 +761,7 @@ void UBDocumentController::deleteSelectedItem()
} }
else else
{ {
if (QMessageBox::question( 0, tr("Remove Folder"), if(UBApplication::mainWindow->yesNoQuestion(tr("Remove Folder"), tr("Are you sure you want to remove the folder '%1' and all its content?").arg(groupTi->groupName())))
tr("Are you sure you want to remove the folder '%1' and all its content?").arg(groupTi->groupName()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@ -1483,11 +1473,10 @@ bool UBDocumentController::isOKToOpenDocument(UBDocumentProxy* proxy)
} }
else else
{ {
if (QMessageBox::question( 0, tr("Open Document"), if (UBApplication::mainWindow->yesNoQuestion(tr("Open Document"),
tr("The document '%1' has been generated with a newer version of Sankore (%2). By opening it, you may lose some information. Do you want to proceed?") tr("The document '%1' has been generated with a newer version of Sankore (%2). By opening it, you may lose some information. Do you want to proceed?")
.arg(proxy->metaData(UBSettings::documentName).toString()) .arg(proxy->metaData(UBSettings::documentName).toString())
.arg(docVersion), .arg(docVersion)))
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
{ {
return true; return true;
} }

@ -138,3 +138,18 @@ void UBMainWindow::onExportDone()
actionOpen->setEnabled(true); actionOpen->setEnabled(true);
actionDocumentAdd->setEnabled(true); actionDocumentAdd->setEnabled(true);
} }
bool UBMainWindow::yesNoQuestion(QString windowTitle, QString text)
{
QMessageBox messageBox;
messageBox.setParent(this);
messageBox.setWindowFlags(Qt::Dialog);
messageBox.setWindowTitle(windowTitle);
messageBox.setText(text);
QPushButton* yesButton = messageBox.addButton(tr("Yes"),QMessageBox::YesRole);
messageBox.addButton(tr("No"),QMessageBox::NoRole);
messageBox.setIcon(QMessageBox::Question);
messageBox.exec();
return messageBox.clickedButton() == yesButton;
}

@ -41,6 +41,7 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow
void addDocumentsWidget(QWidget *pWidget); void addDocumentsWidget(QWidget *pWidget);
void switchToDocumentsWidget(); void switchToDocumentsWidget();
bool yesNoQuestion(QString windowTitle, QString text);
signals: signals:
void closeEvent_Signal( QCloseEvent *event ); void closeEvent_Signal( QCloseEvent *event );

Loading…
Cancel
Save