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

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

@ -476,7 +476,6 @@ void UBDocumentController::showKeyboard(bool show)
mKeyboardPalette->setVisible(show);
}
// mPaletteManager->showVirtualKeyboard(show);
}
void UBDocumentController::setupPalettes()
@ -640,10 +639,7 @@ void UBDocumentController::deleteSelectedItem()
}
}
if (QMessageBox::question( 0, 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()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
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())))
{
UBPersistenceManager::persistenceManager()->deleteDocumentScenes(proxy, sceneIndexes);
proxy->setMetaData(UBSettings::documentUpdatedAt, UBStringUtils::toUtcIsoDateTime(QDateTime::currentDateTime()));
@ -668,9 +664,7 @@ void UBDocumentController::deleteSelectedItem()
if (proxyTi && proxyTi->proxy() && proxyTi->parent())
{
if (QMessageBox::question( 0, tr("Remove Document"),
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(UBApplication::mainWindow->yesNoQuestion(tr("Remove Document"), tr("Are you sure you want to remove the document '%1'?").arg(proxyTi->proxy()->metaData(UBSettings::documentName).toString())))
{
if (proxyTi->parent() == mTrashTi)
{
@ -737,9 +731,7 @@ void UBDocumentController::deleteSelectedItem()
{
if (groupTi == mTrashTi)
{
if (QMessageBox::question( 0, tr("Empty Trash"),
tr("Are you sure you want to empty trash?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
if(UBApplication::mainWindow->yesNoQuestion(tr("Empty Trash"), tr("Are you sure you want to empty trash?")))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QList<UBDocumentProxyTreeItem*> toBeDeleted;
@ -769,9 +761,7 @@ void UBDocumentController::deleteSelectedItem()
}
else
{
if (QMessageBox::question( 0, tr("Remove Folder"),
tr("Are you sure you want to remove the folder '%1' and all its content?").arg(groupTi->groupName()),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
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())))
{
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@ -1483,11 +1473,10 @@ bool UBDocumentController::isOKToOpenDocument(UBDocumentProxy* proxy)
}
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?")
.arg(proxy->metaData(UBSettings::documentName).toString())
.arg(docVersion),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
.arg(docVersion)))
{
return true;
}

@ -119,11 +119,11 @@ void UBMainWindow::keyPressEvent(QKeyEvent *event)
*/
}
void UBMainWindow::closeEvent(QCloseEvent *event)
{
event->ignore();
emit closeEvent_Signal(event);
}
void UBMainWindow::closeEvent(QCloseEvent *event)
{
event->ignore();
emit closeEvent_Signal(event);
}
void UBMainWindow::onExportDone()
{
@ -138,3 +138,18 @@ void UBMainWindow::onExportDone()
actionOpen->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,8 +41,9 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow
void addDocumentsWidget(QWidget *pWidget);
void switchToDocumentsWidget();
bool yesNoQuestion(QString windowTitle, QString text);
signals:
signals:
void closeEvent_Signal( QCloseEvent *event );
public slots:

Loading…
Cancel
Save