From: Dirk H Bartley Date: Fri, 27 Mar 2009 01:42:11 +0000 (+0000) Subject: Changes to put the mouse and the application into a wait state. X-Git-Tag: Release-3.0.0~97 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7055019c46cb0e3d52734da51f91c37396e04712;p=bacula%2Fbacula Changes to put the mouse and the application into a wait state. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8605 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/qt-console/console/console.cpp b/bacula/src/qt-console/console/console.cpp index f1291ca4fd..2d2bab9db2 100644 --- a/bacula/src/qt-console/console/console.cpp +++ b/bacula/src/qt-console/console/console.cpp @@ -191,6 +191,7 @@ bool Console::dir_cmd(const char *cmd, QStringList &results) */ bool Console::dir_cmd(int conn, const char *cmd, QStringList &results) { + mainWin->waitEnter(); DirComm *dircomm = m_dircommHash.value(conn); int stat; @@ -206,6 +207,7 @@ bool Console::dir_cmd(int conn, const char *cmd, QStringList &results) if (stat > 0 && mainWin->m_displayAll) display_text(dircomm->msg()); notify(conn, true); discardToPrompt(conn); + mainWin->waitExit(); return true; /* ***FIXME*** return any command error */ } @@ -251,6 +253,7 @@ bool Console::sql_cmd(int &conn, const char *query, QStringList &results, bool d Pmsg2(000, "sql_cmd conn %i %s\n", conn, query); if (donotify) dircomm->notify(false); + mainWin->waitEnter(); pm_strcpy(cmd, ".sql query=\""); pm_strcat(cmd, query); @@ -275,6 +278,7 @@ bool Console::sql_cmd(int &conn, const char *query, QStringList &results, bool d if (donotify) dircomm->notify(true); discardToPrompt(conn); + mainWin->waitExit(); return true; /* ***FIXME*** return any command error */ } @@ -294,8 +298,9 @@ void Console::write_dir(int conn, const char *msg) if (dircomm->m_sock) { mainWin->set_status(_("Processing command ...")); - QApplication::setOverrideCursor(Qt::WaitCursor); + mainWin->waitEnter(); dircomm->write(msg); + mainWin->waitExit(); } else { mainWin->set_status( tr(" Director not connected. Click on connect button.")); mainWin->actionConnect->setIcon(QIcon(":images/disconnected.png")); @@ -733,13 +738,19 @@ char *Console::msg(int conn) int Console::write(int conn, const QString msg) { DirComm *dircomm = m_dircommHash.value(conn); - return dircomm->write(msg); + mainWin->waitEnter(); + int ret = dircomm->write(msg); + mainWin->waitExit(); + return ret; } int Console::write(int conn, const char *msg) { DirComm *dircomm = m_dircommHash.value(conn); - return dircomm->write(msg); + mainWin->waitEnter(); + int ret = dircomm->write(msg); + mainWin->waitExit(); + return ret; } /* This checks to see if any is connected */ diff --git a/bacula/src/qt-console/mainwin.cpp b/bacula/src/qt-console/mainwin.cpp index 96af3bb2bb..e41793171a 100644 --- a/bacula/src/qt-console/mainwin.cpp +++ b/bacula/src/qt-console/mainwin.cpp @@ -236,13 +236,9 @@ void MainWin::createConnections() connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line())); connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about())); connect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help())); - connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, - SLOT(treeItemClicked(QTreeWidgetItem *, int))); - connect(treeWidget, SIGNAL( - currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), - this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); - connect(stackedWidget, SIGNAL(currentChanged(int)), - this, SLOT(stackItemChanged(int))); + connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int))); + connect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); + connect(stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int))); connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows())); connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked())); connect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked())); @@ -259,6 +255,49 @@ void MainWin::createConnections() connect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences())); } +void MainWin::disconnectConnections() +{ + /* Connect signals to slots */ + disconnect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line())); + disconnect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about())); + disconnect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help())); + disconnect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(treeItemClicked(QTreeWidgetItem *, int))); + disconnect(treeWidget, SIGNAL( currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *))); + disconnect(stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(stackItemChanged(int))); + disconnect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows())); + disconnect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked())); + disconnect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked())); + disconnect(actionEstimate, SIGNAL(triggered()), this, SLOT(estimateButtonClicked())); + disconnect(actionBrowse, SIGNAL(triggered()), this, SLOT(browseButtonClicked())); + disconnect(actionStatusDirPage, SIGNAL(triggered()), this, SLOT(statusPageButtonClicked())); +#ifdef HAVE_QWT + disconnect(actionJobPlot, SIGNAL(triggered()), this, SLOT(jobPlotButtonClicked())); +#endif + disconnect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked())); + disconnect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton())); + disconnect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow())); + disconnect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage())); + disconnect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences())); +} + +/* + * Enter wait state + */ +void MainWin::waitEnter() +{ + app->setOverrideCursor(QCursor(Qt::WaitCursor)); + disconnectConnections(); +} + +/* + * Leave wait state + */ +void MainWin::waitExit() +{ + app->restoreOverrideCursor(); + createConnections(); +} + /* * Reimplementation of QWidget closeEvent virtual function */ diff --git a/bacula/src/qt-console/mainwin.h b/bacula/src/qt-console/mainwin.h index 87b49c4cba..393079283b 100644 --- a/bacula/src/qt-console/mainwin.h +++ b/bacula/src/qt-console/mainwin.h @@ -124,15 +124,18 @@ public slots: void closePage(); void setPreferences(); void readPreferences(); + void waitEnter(); + void waitExit(); protected: void closeEvent(QCloseEvent *event); void keyPressEvent(QKeyEvent *event); private: - void createConnections(); void connectConsole(); void createPages(); + void createConnections(); + void disconnectConnections(); private: Console *m_currentConsole;