2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
32 * Main Window control for bat (qt-console)
34 * Kern Sibbald, January MMVII
40 #include "joblist/joblist.h"
41 #include "storage/storage.h"
42 #include "fileset/fileset.h"
43 #include "label/label.h"
46 #include "restore/restore.h"
47 #include "medialist/medialist.h"
48 #include "joblist/joblist.h"
49 #include "clients/clients.h"
50 #include "restore/restoretree.h"
51 #include "help/help.h"
52 #include "jobs/jobs.h"
54 #include "jobgraphs/jobplot.h"
56 #include "status/dirstat.h"
57 #include "util/fmtwidgetitem.h"
60 * Daemon message callback
62 void message_callback(int /* type */, char *msg)
64 QMessageBox::warning(mainWin, "Bat", msg, QMessageBox::Ok);
67 MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
70 m_dtformat = "yyyy-MM-dd HH:mm:ss";
72 setupUi(this); /* Setup UI defined by main.ui (designer) */
73 register_message_callback(message_callback);
76 treeWidget->setColumnCount(1);
77 treeWidget->setHeaderLabel( tr("Select Page") );
78 treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);
87 actionJobPlot->setEnabled(false);
88 actionJobPlot->setVisible(false);
95 foreach(Console *console, m_consoleHash) {
96 console->connect_dir();
98 m_currentConsole = (Console*)getFromHash(m_firstItem);
99 m_currentConsole->setCurrent();
101 QString directoryResourceName;
102 m_currentConsole->getDirResName(directoryResourceName);
103 Pmsg1(100, "Setting initial window to %s\n", directoryResourceName.toUtf8().data());
107 void MainWin::createPages()
110 QTreeWidgetItem *item, *topItem;
114 foreach_res(dir, R_DIRECTOR) {
116 /* Create console tree stacked widget item */
117 m_currentConsole = new Console(stackedWidget);
118 m_currentConsole->setDirRes(dir);
119 m_currentConsole->readSettings();
121 /* The top tree item representing the director */
122 topItem = new QTreeWidgetItem(treeWidget);
123 topItem->setText(0, dir->name());
124 topItem->setIcon(0, QIcon(":images/server.png"));
125 /* Set background to grey for ease of identification of inactive Director */
126 QBrush greyBrush(Qt::lightGray);
127 topItem->setBackground(0, greyBrush);
128 m_currentConsole->setDirectorTreeItem(topItem);
129 m_consoleHash.insert(topItem, m_currentConsole);
131 /* Create Tree Widget Item */
132 item = new QTreeWidgetItem(topItem);
133 item->setText(0, tr("Console"));
134 if (!m_firstItem){ m_firstItem = item; }
135 item->setIcon(0,QIcon(QString::fromUtf8(":images/utilities-terminal.png")));
137 /* insert the cosole and tree widget item into the hashes */
138 hashInsert(item, m_currentConsole);
140 /* Set Color of treeWidgetItem for the console
141 * It will be set to green in the console class if the connection is made.
143 QBrush redBrush(Qt::red);
144 item->setForeground(0, redBrush);
145 m_currentConsole->dockPage();
148 * Create instances in alphabetic order of the rest
149 * of the classes that will by default exist under each Director.
155 createPageJobList("", "", "", "", NULL);
160 new JobPlot(NULL, pass);
169 treeWidget->expandItem(topItem);
170 stackedWidget->setCurrentWidget(m_currentConsole);
176 * create an instance of the the joblist class on the stack
178 void MainWin::createPageJobList(const QString &media, const QString &client,
179 const QString &job, const QString &fileset, QTreeWidgetItem *parentTreeWidgetItem)
181 QTreeWidgetItem *holdItem;
183 /* save current tree widget item in case query produces no results */
184 holdItem = treeWidget->currentItem();
185 JobList* joblist = new JobList(media, client, job, fileset, parentTreeWidgetItem);
186 /* If this is a query of jobs on a specific media */
187 if ((media != "") || (client != "") || (job != "") || (fileset != "")) {
188 joblist->setCurrent();
189 /* did query produce results, if not close window and set back to hold */
190 if (joblist->m_resultCount == 0) {
191 joblist->closeStackPage();
192 treeWidget->setCurrentItem(holdItem);
198 * Handle up and down arrow keys for the command line
201 void MainWin::keyPressEvent(QKeyEvent *event)
203 if (m_cmd_history.size() == 0) {
207 switch (event->key()) {
209 if (m_cmd_last < 0 || m_cmd_last >= (m_cmd_history.size()-1)) {
216 if (m_cmd_last == 0) {
220 if (m_cmd_last < 0 || m_cmd_last > (m_cmd_history.size()-1)) {
221 m_cmd_last = m_cmd_history.size() - 1;
230 lineEdit->setText(m_cmd_history[m_cmd_last]);
233 void MainWin::createConnections()
235 /* Connect signals to slots */
236 connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
237 connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about()));
238 connect(actionBat_Help, SIGNAL(triggered()), this, SLOT(help()));
239 connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this,
240 SLOT(treeItemClicked(QTreeWidgetItem *, int)));
241 connect(treeWidget, SIGNAL(
242 currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
243 this, SLOT(treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)));
244 connect(stackedWidget, SIGNAL(currentChanged(int)),
245 this, SLOT(stackItemChanged(int)));
246 connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
247 connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelButtonClicked()));
248 connect(actionRun, SIGNAL(triggered()), this, SLOT(runButtonClicked()));
249 connect(actionEstimate, SIGNAL(triggered()), this, SLOT(estimateButtonClicked()));
250 connect(actionBrowse, SIGNAL(triggered()), this, SLOT(browseButtonClicked()));
251 connect(actionStatusDirPage, SIGNAL(triggered()), this, SLOT(statusPageButtonClicked()));
253 connect(actionJobPlot, SIGNAL(triggered()), this, SLOT(jobPlotButtonClicked()));
255 connect(actionRestore, SIGNAL(triggered()), this, SLOT(restoreButtonClicked()));
256 connect(actionUndock, SIGNAL(triggered()), this, SLOT(undockWindowButton()));
257 connect(actionToggleDock, SIGNAL(triggered()), this, SLOT(toggleDockContextWindow()));
258 connect(actionClosePage, SIGNAL(triggered()), this, SLOT(closePage()));
259 connect(actionPreferences, SIGNAL(triggered()), this, SLOT(setPreferences()));
263 * Reimplementation of QWidget closeEvent virtual function
265 void MainWin::closeEvent(QCloseEvent *event)
269 /* close all non console pages, this will call settings in destructors */
270 while (m_consoleHash.count() < m_pagehash.count()) {
271 foreach(Pages *page, m_pagehash) {
272 if (page != page->console()) {
273 QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(page);
274 if (pageSelectorTreeWidgetItem->childCount() == 0) {
275 page->console()->setCurrent();
276 page->closeStackPage();
281 foreach(Console *console, m_consoleHash){
282 console->writeSettings();
283 console->terminate();
284 console->closeStackPage();
289 void MainWin::writeSettings()
291 QSettings settings("bacula.org", "bat");
293 settings.beginGroup("MainWin");
294 settings.setValue("winSize", size());
295 settings.setValue("winPos", pos());
296 settings.setValue("state", saveState());
300 void MainWin::readSettings()
302 QSettings settings("bacula.org", "bat");
304 settings.beginGroup("MainWin");
305 resize(settings.value("winSize", QSize(1041, 801)).toSize());
306 move(settings.value("winPos", QPoint(200, 150)).toPoint());
307 restoreState(settings.value("state").toByteArray());
312 * This subroutine is called with an item in the Page Selection window
315 void MainWin::treeItemClicked(QTreeWidgetItem *item, int /*column*/)
317 /* Is this a page that has been inserted into the hash */
318 if (getFromHash(item)) {
319 Pages* page = getFromHash(item);
320 int stackindex=stackedWidget->indexOf(page);
322 if (stackindex >= 0) {
323 stackedWidget->setCurrentWidget(page);
325 /* run the virtual function in case this class overrides it */
326 page->PgSeltreeWidgetClicked();
331 * Called with a change of the highlighed tree widget item in the page selector.
333 void MainWin::treeItemChanged(QTreeWidgetItem *currentitem, QTreeWidgetItem *previousitem)
335 if (m_isClosing) return; /* if closing the application, do nothing here */
337 Pages *previousPage, *nextPage;
338 Console *previousConsole = NULL;
339 Console *nextConsole;
341 /* remove all actions before adding actions appropriate for new page */
342 foreach(QAction* pageAction, treeWidget->actions()) {
343 treeWidget->removeAction(pageAction);
346 /* first determine the next item */
348 /* knowing the treeWidgetItem, get the page from the hash */
349 nextPage = getFromHash(currentitem);
350 nextConsole = m_consoleHash.value(currentitem);
351 /* Is this a page that has been inserted into the hash */
353 nextConsole = nextPage->console();
354 /* then is it a treeWidgetItem representing a director */
355 } else if (nextConsole) {
356 /* let the next page BE the console */
357 nextPage = nextConsole;
359 /* Should never get here */
364 /* The Previous item */
366 /* this condition prevents a segfault. The first time there is no previousitem*/
368 /* knowing the treeWidgetItem, get the page from the hash */
369 previousPage = getFromHash(previousitem);
370 previousConsole = m_consoleHash.value(previousitem);
372 previousConsole = previousPage->console();
373 } else if (previousConsole) {
374 previousPage = previousConsole;
376 if ((previousPage) || (previousConsole)) {
377 if (nextConsole != previousConsole) {
378 /* remove connections to the current console */
379 disconnect(actionConnect, SIGNAL(triggered()), previousConsole, SLOT(connect_dir()));
380 disconnect(actionStatusDir, SIGNAL(triggered()), previousConsole, SLOT(status_dir()));
381 disconnect(actionMessages, SIGNAL(triggered()), previousConsole, SLOT(messages()));
382 disconnect(actionSelectFont, SIGNAL(triggered()), previousConsole, SLOT(set_font()));
383 QTreeWidgetItem *dirItem = previousConsole->directorTreeItem();
384 QBrush greyBrush(Qt::lightGray);
385 dirItem->setBackground(0, greyBrush);
390 /* process the current (next) item */
392 if ((nextPage) || (nextConsole)) {
393 if (nextConsole != previousConsole) {
394 /* make connections to the current console */
395 m_currentConsole = nextConsole;
396 connect(actionConnect, SIGNAL(triggered()), m_currentConsole, SLOT(connect_dir()));
397 connect(actionSelectFont, SIGNAL(triggered()), m_currentConsole, SLOT(set_font()));
398 connect(actionStatusDir, SIGNAL(triggered()), m_currentConsole, SLOT(status_dir()));
399 connect(actionMessages, SIGNAL(triggered()), m_currentConsole, SLOT(messages()));
401 /* Set director's tree widget background to magenta for ease of identification */
402 QTreeWidgetItem *dirItem = m_currentConsole->directorTreeItem();
403 QBrush magentaBrush(Qt::magenta);
404 dirItem->setBackground(0, magentaBrush);
406 /* set the value for the currently active console */
407 int stackindex = stackedWidget->indexOf(nextPage);
409 /* Is this page currently on the stack or is it undocked */
410 if (stackindex >= 0) {
411 /* put this page on the top of the stack */
412 stackedWidget->setCurrentIndex(stackindex);
414 /* it is undocked, raise it to the front */
417 /* for the page selectors menu action to dock or undock, set the text */
418 nextPage->setContextMenuDockText();
420 treeWidget->addAction(actionToggleDock);
421 /* if this page is closeable, and it has no childern, then add that action */
422 if ((nextPage->isCloseable()) && (currentitem->child(0) == NULL))
423 treeWidget->addAction(actionClosePage);
425 /* Add the actions to the Page Selectors tree widget that are part of the
426 * current items list of desired actions regardless of whether on top of stack*/
427 treeWidget->addActions(nextPage->m_contextActions);
431 void MainWin::labelButtonClicked()
436 void MainWin::runButtonClicked()
441 void MainWin::estimateButtonClicked()
446 void MainWin::browseButtonClicked()
451 void MainWin::statusPageButtonClicked()
453 /* if one exists, then just set it current */
455 foreach(Pages *page, m_pagehash) {
456 if (m_currentConsole == page->console()) {
457 if (page->name() == tr("Director Status")) {
467 void MainWin::restoreButtonClicked()
469 new prerestorePage();
472 void MainWin::jobPlotButtonClicked()
477 new JobPlot(NULL, pass);
482 * The user just finished typing a line in the command line edit box
484 void MainWin::input_line()
486 QString cmdStr = lineEdit->text(); /* Get the text */
487 lineEdit->clear(); /* clear the lineEdit box */
488 if (m_currentConsole->is_connected()) {
489 /* Use consoleInput to allow typing anything */
490 m_currentConsole->consoleInput(cmdStr);
492 set_status(tr("Director not connected. Click on connect button."));
494 m_cmd_history.append(cmdStr);
496 if (treeWidget->currentItem() != getFromHash(m_currentConsole))
497 m_currentConsole->setCurrent();
501 void MainWin::about()
503 QMessageBox::about(this, tr("About bat"),
504 tr("<br><h2>bat %1 (%2), by Dirk H Bartley and Kern Sibbald</h2>"
505 "<p>Copyright © 2007-%3 Free Software Foundation Europe e.V."
506 "<p>The <b>bat</b> is an administrative console"
507 " interface to the Director.").arg(VERSION).arg(BDATE).arg(BYEAR));
512 Help::displayFile("index.html");
515 void MainWin::set_statusf(const char *fmt, ...)
520 va_start(arg_ptr, fmt);
521 len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
526 void MainWin::set_status_ready()
528 set_status(tr(" Ready"));
531 void MainWin::set_status(const QString &str)
533 statusBar()->showMessage(str);
536 void MainWin::set_status(const char *buf)
538 statusBar()->showMessage(buf);
542 * Function to respond to the button bar button to undock
544 void MainWin::undockWindowButton()
546 Pages* page = (Pages*)stackedWidget->currentWidget();
547 page->togglePageDocking();
551 * Function to respond to action on page selector context menu to toggle the
552 * dock status of the window associated with the page selectors current
555 void MainWin::toggleDockContextWindow()
557 QTreeWidgetItem *currentitem = treeWidget->currentItem();
559 /* Is this a page that has been inserted into the hash */
560 if (getFromHash(currentitem)) {
561 Pages* page = getFromHash(currentitem);
562 page->togglePageDocking();
567 * This function is called when the stack item is changed. Call
568 * the virtual function here. Avoids a window being undocked leaving
569 * a window at the top of the stack unpopulated.
571 void MainWin::stackItemChanged(int)
573 if (m_isClosing) return; /* if closing the application, do nothing here */
574 Pages* page = (Pages*)stackedWidget->currentWidget();
575 /* run the virtual function in case this class overrides it */
576 page->currentStackItem();
580 * Function to simplify insertion of QTreeWidgetItem <-> Page association
581 * into a double direction hash.
583 void MainWin::hashInsert(QTreeWidgetItem *item, Pages *page)
585 m_pagehash.insert(item, page);
586 m_widgethash.insert(page, item);
590 * Function to simplify removal of QTreeWidgetItem <-> Page association
591 * into a double direction hash.
593 void MainWin::hashRemove(QTreeWidgetItem *item, Pages *page)
595 /* I had all sorts of return status checking code here. Do we have a log
596 * level capability in bat. I would have left it in but it used printf's
597 * and it should really be some kind of log level facility ???
598 * ******FIXME********/
599 m_pagehash.remove(item);
600 m_widgethash.remove(page);
604 * Function to retrieve a Page* when the item in the page selector's tree is
607 Pages* MainWin::getFromHash(QTreeWidgetItem *item)
609 return m_pagehash.value(item);
613 * Function to retrieve the page selectors tree widget item when the page is
616 QTreeWidgetItem* MainWin::getFromHash(Pages *page)
618 return m_widgethash.value(page);
622 * Function to respond to action on page selector context menu to close the
625 void MainWin::closePage()
627 QTreeWidgetItem *currentitem = treeWidget->currentItem();
629 /* Is this a page that has been inserted into the hash */
630 if (getFromHash(currentitem)) {
631 Pages* page = getFromHash(currentitem);
632 if (page->isCloseable()) {
633 page->closeStackPage();
638 /* Quick function to return the current console */
639 Console *MainWin::currentConsole()
641 return m_currentConsole;
643 /* Quick function to return the tree item for the director */
644 QTreeWidgetItem *MainWin::currentTopItem()
646 return m_currentConsole->directorTreeItem();
649 /* Preferences menu item clicked */
650 void MainWin::setPreferences()
653 prefs.commDebug->setCheckState(m_commDebug ? Qt::Checked : Qt::Unchecked);
654 prefs.connDebug->setCheckState(m_connDebug ? Qt::Checked : Qt::Unchecked);
655 prefs.displayAll->setCheckState(m_displayAll ? Qt::Checked : Qt::Unchecked);
656 prefs.sqlDebug->setCheckState(m_sqlDebug ? Qt::Checked : Qt::Unchecked);
657 prefs.commandDebug->setCheckState(m_commandDebug ? Qt::Checked : Qt::Unchecked);
658 prefs.miscDebug->setCheckState(m_miscDebug ? Qt::Checked : Qt::Unchecked);
659 prefs.recordLimit->setCheckState(m_recordLimitCheck ? Qt::Checked : Qt::Unchecked);
660 prefs.recordSpinBox->setValue(m_recordLimitVal);
661 prefs.daysLimit->setCheckState(m_daysLimitCheck ? Qt::Checked : Qt::Unchecked);
662 prefs.daysSpinBox->setValue(m_daysLimitVal);
663 prefs.checkMessages->setCheckState(m_checkMessages ? Qt::Checked : Qt::Unchecked);
664 prefs.checkMessagesSpin->setValue(m_checkMessagesInterval);
665 prefs.refreshStatusDir->setCheckState(m_refreshStatusDir ? Qt::Checked : Qt::Unchecked);
666 prefs.refreshStatusDirSpin->setValue(m_refreshStatusDirInterval);
667 prefs.executeLongCheckBox->setCheckState(m_longList ? Qt::Checked : Qt::Unchecked);
668 prefs.rtPopDirCheckBox->setCheckState(m_rtPopDirDebug ? Qt::Checked : Qt::Unchecked);
669 prefs.rtDirCurICCheckBox->setCheckState(m_rtDirCurICDebug ? Qt::Checked : Qt::Unchecked);
670 prefs.rtDirICCheckBox->setCheckState(m_rtDirICDebug ? Qt::Checked : Qt::Unchecked);
671 prefs.rtFileTabICCheckBox->setCheckState(m_rtFileTabICDebug ? Qt::Checked : Qt::Unchecked);
672 prefs.rtVerTabICCheckBox->setCheckState(m_rtVerTabICDebug ? Qt::Checked : Qt::Unchecked);
673 prefs.rtUpdateFTCheckBox->setCheckState(m_rtUpdateFTDebug ? Qt::Checked : Qt::Unchecked);
674 prefs.rtUpdateVTCheckBox->setCheckState(m_rtUpdateVTDebug ? Qt::Checked : Qt::Unchecked);
675 prefs.rtChecksCheckBox->setCheckState(m_rtChecksDebug ? Qt::Checked : Qt::Unchecked);
676 prefs.rtIconStateCheckBox->setCheckState(m_rtIconStateDebug ? Qt::Checked : Qt::Unchecked);
677 prefs.rtRestore1CheckBox->setCheckState(m_rtRestore1Debug ? Qt::Checked : Qt::Unchecked);
678 prefs.rtRestore2CheckBox->setCheckState(m_rtRestore2Debug ? Qt::Checked : Qt::Unchecked);
679 prefs.rtRestore3CheckBox->setCheckState(m_rtRestore3Debug ? Qt::Checked : Qt::Unchecked);
680 switch (ItemFormatterBase::getBytesConversion()) {
681 case ItemFormatterBase::BYTES_CONVERSION_NONE:
682 prefs.radioConvertOff->setChecked(Qt::Checked);
684 case ItemFormatterBase::BYTES_CONVERSION_IEC:
685 prefs.radioConvertIEC->setChecked(Qt::Checked);
688 prefs.radioConvertStandard->setChecked(Qt::Checked);
691 prefs.openPlotCheckBox->setCheckState(m_openPlot ? Qt::Checked : Qt::Unchecked);
693 prefs.openPlotCheckBox->setVisible(false);
695 prefs.openBrowserCheckBox->setCheckState(m_openBrowser ? Qt::Checked : Qt::Unchecked);
696 prefs.openDirStatCheckBox->setCheckState(m_openDirStat ? Qt::Checked : Qt::Unchecked);
700 /* Preferences dialog */
701 prefsDialog::prefsDialog()
706 void prefsDialog::accept()
709 mainWin->m_commDebug = this->commDebug->checkState() == Qt::Checked;
710 mainWin->m_connDebug = this->connDebug->checkState() == Qt::Checked;
711 mainWin->m_displayAll = this->displayAll->checkState() == Qt::Checked;
712 mainWin->m_sqlDebug = this->sqlDebug->checkState() == Qt::Checked;
713 mainWin->m_commandDebug = this->commandDebug->checkState() == Qt::Checked;
714 mainWin->m_miscDebug = this->miscDebug->checkState() == Qt::Checked;
715 mainWin->m_recordLimitCheck = this->recordLimit->checkState() == Qt::Checked;
716 mainWin->m_recordLimitVal = this->recordSpinBox->value();
717 mainWin->m_daysLimitCheck = this->daysLimit->checkState() == Qt::Checked;
718 mainWin->m_daysLimitVal = this->daysSpinBox->value();
719 mainWin->m_checkMessages = this->checkMessages->checkState() == Qt::Checked;
720 mainWin->m_checkMessagesInterval = this->checkMessagesSpin->value();
721 mainWin->m_refreshStatusDir = this->refreshStatusDir->checkState() == Qt::Checked;
722 mainWin->m_refreshStatusDirInterval = this->refreshStatusDirSpin->value();
723 mainWin->m_longList = this->executeLongCheckBox->checkState() == Qt::Checked;
725 mainWin->m_rtPopDirDebug = this->rtPopDirCheckBox->checkState() == Qt::Checked;
726 mainWin->m_rtDirCurICDebug = this->rtDirCurICCheckBox->checkState() == Qt::Checked;
727 mainWin->m_rtDirICDebug = this->rtDirICCheckBox->checkState() == Qt::Checked;
728 mainWin->m_rtFileTabICDebug = this->rtFileTabICCheckBox->checkState() == Qt::Checked;
729 mainWin->m_rtVerTabICDebug = this->rtVerTabICCheckBox->checkState() == Qt::Checked;
730 mainWin->m_rtUpdateFTDebug = this->rtUpdateFTCheckBox->checkState() == Qt::Checked;
731 mainWin->m_rtUpdateVTDebug = this->rtUpdateVTCheckBox->checkState() == Qt::Checked;
732 mainWin->m_rtChecksDebug = this->rtChecksCheckBox->checkState() == Qt::Checked;
733 mainWin->m_rtIconStateDebug = this->rtIconStateCheckBox->checkState() == Qt::Checked;
734 mainWin->m_rtRestore1Debug = this->rtRestore1CheckBox->checkState() == Qt::Checked;
735 mainWin->m_rtRestore2Debug = this->rtRestore2CheckBox->checkState() == Qt::Checked;
736 mainWin->m_rtRestore3Debug = this->rtRestore3CheckBox->checkState() == Qt::Checked;
737 if (this->radioConvertOff->isChecked()) {
738 ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_NONE);
739 } else if (this->radioConvertIEC->isChecked()){
740 ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_IEC);
742 ItemFormatterBase::setBytesConversion(ItemFormatterBase::BYTES_CONVERSION_SI);
744 mainWin->m_openPlot = this->openPlotCheckBox->checkState() == Qt::Checked;
745 mainWin->m_openBrowser = this->openBrowserCheckBox->checkState() == Qt::Checked;
746 mainWin->m_openDirStat = this->openDirStatCheckBox->checkState() == Qt::Checked;
748 QSettings settings("www.bacula.org", "bat");
749 settings.beginGroup("Debug");
750 settings.setValue("commDebug", mainWin->m_commDebug);
751 settings.setValue("connDebug", mainWin->m_connDebug);
752 settings.setValue("displayAll", mainWin->m_displayAll);
753 settings.setValue("sqlDebug", mainWin->m_sqlDebug);
754 settings.setValue("commandDebug", mainWin->m_commandDebug);
755 settings.setValue("miscDebug", mainWin->m_miscDebug);
757 settings.beginGroup("JobList");
758 settings.setValue("recordLimitCheck", mainWin->m_recordLimitCheck);
759 settings.setValue("recordLimitVal", mainWin->m_recordLimitVal);
760 settings.setValue("daysLimitCheck", mainWin->m_daysLimitCheck);
761 settings.setValue("daysLimitVal", mainWin->m_daysLimitVal);
763 settings.beginGroup("Timers");
764 settings.setValue("checkMessages", mainWin->m_checkMessages);
765 settings.setValue("checkMessagesInterval", mainWin->m_checkMessagesInterval);
766 settings.setValue("refreshStatusDir", mainWin->m_refreshStatusDir);
767 settings.setValue("refreshStatusDirInterval", mainWin->m_refreshStatusDirInterval);
769 settings.beginGroup("Misc");
770 settings.setValue("longList", mainWin->m_longList);
771 settings.setValue("byteConvert", ItemFormatterBase::getBytesConversion());
772 settings.setValue("openplot", mainWin->m_openPlot);
773 settings.setValue("openbrowser", mainWin->m_openBrowser);
774 settings.setValue("opendirstat", mainWin->m_openDirStat);
776 settings.beginGroup("RestoreTree");
777 settings.setValue("rtPopDirDebug", mainWin->m_rtPopDirDebug);
778 settings.setValue("rtDirCurICDebug", mainWin->m_rtDirCurICDebug);
779 settings.setValue("rtDirCurICRetDebug", mainWin->m_rtDirICDebug);
780 settings.setValue("rtFileTabICDebug", mainWin->m_rtFileTabICDebug);
781 settings.setValue("rtVerTabICDebug", mainWin->m_rtVerTabICDebug);
782 settings.setValue("rtUpdateFTDebug", mainWin->m_rtUpdateFTDebug);
783 settings.setValue("rtUpdateVTDebug", mainWin->m_rtUpdateVTDebug);
784 settings.setValue("rtChecksDebug", mainWin->m_rtChecksDebug);
785 settings.setValue("rtIconStateDebug", mainWin->m_rtIconStateDebug);
786 settings.setValue("rtRestore1Debug", mainWin->m_rtRestore1Debug);
787 settings.setValue("rtRestore2Debug", mainWin->m_rtRestore2Debug);
788 settings.setValue("rtRestore3Debug", mainWin->m_rtRestore3Debug);
792 void prefsDialog::reject()
795 mainWin->set_status(tr("Canceled"));
798 /* read preferences for the prefences dialog box */
799 void MainWin::readPreferences()
801 QSettings settings("www.bacula.org", "bat");
802 settings.beginGroup("Debug");
803 m_commDebug = settings.value("commDebug", false).toBool();
804 m_connDebug = settings.value("connDebug", false).toBool();
805 m_displayAll = settings.value("displayAll", false).toBool();
806 m_sqlDebug = settings.value("sqlDebug", false).toBool();
807 m_commandDebug = settings.value("commandDebug", false).toBool();
808 m_miscDebug = settings.value("miscDebug", false).toBool();
810 settings.beginGroup("JobList");
811 m_recordLimitCheck = settings.value("recordLimitCheck", true).toBool();
812 m_recordLimitVal = settings.value("recordLimitVal", 150).toInt();
813 m_daysLimitCheck = settings.value("daysLimitCheck", false).toBool();
814 m_daysLimitVal = settings.value("daysLimitVal", 28).toInt();
816 settings.beginGroup("Timers");
817 m_checkMessages = settings.value("checkMessages", false).toBool();
818 m_checkMessagesInterval = settings.value("checkMessagesInterval", 28).toInt();
819 m_refreshStatusDir = settings.value("refreshStatusDir", false).toBool();
820 m_refreshStatusDirInterval = settings.value("refreshStatusDirInterval", 28).toInt();
822 settings.beginGroup("Misc");
823 m_longList = settings.value("longList", false).toBool();
824 ItemFormatterBase::setBytesConversion(
825 (ItemFormatterBase::BYTES_CONVERSION) settings.value("byteConvert",
826 ItemFormatterBase::BYTES_CONVERSION_IEC).toInt());
827 m_openPlot = settings.value("openplot", false).toBool();
828 m_openBrowser = settings.value("openbrowser", false).toBool();
829 m_openDirStat = settings.value("opendirstat", false).toBool();
831 settings.beginGroup("RestoreTree");
832 m_rtPopDirDebug = settings.value("rtPopDirDebug", false).toBool();
833 m_rtDirCurICDebug = settings.value("rtDirCurICDebug", false).toBool();
834 m_rtDirICDebug = settings.value("rtDirCurICRetDebug", false).toBool();
835 m_rtFileTabICDebug = settings.value("rtFileTabICDebug", false).toBool();
836 m_rtVerTabICDebug = settings.value("rtVerTabICDebug", false).toBool();
837 m_rtUpdateFTDebug = settings.value("rtUpdateFTDebug", false).toBool();
838 m_rtUpdateVTDebug = settings.value("rtUpdateVTDebug", false).toBool();
839 m_rtChecksDebug = settings.value("rtChecksDebug", false).toBool();
840 m_rtIconStateDebug = settings.value("rtIconStateDebug", false).toBool();
841 m_rtRestore1Debug = settings.value("rtRestore1Debug", false).toBool();
842 m_rtRestore2Debug = settings.value("rtRestore2Debug", false).toBool();
843 m_rtRestore3Debug = settings.value("rtRestore3Debug", false).toBool();
847 void MainWin::setMessageIcon()
849 if (m_currentConsole->is_messagesPending())
850 actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-pending.png")));
852 actionMessages->setIcon(QIcon(QString::fromUtf8(":/images/mail-message-new.png")));