2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2007 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 plus additions
11 that are listed in the file LICENSE.
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 John Walker.
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.
30 * Main Window control for bat (qt-console)
32 * Kern Sibbald, January MMVI
38 MainWin::MainWin(QWidget *parent) : QMainWindow(parent)
41 setupUi(this); /* Setup UI defined by main.ui (designer) */
43 m_console = new Console(stackedWidget);
44 stackedWidget->setCurrentIndex(0);
58 void MainWin::createConnections()
60 /* Connect signals to slots */
61 connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
62 connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about()));
64 connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem *, int)), this,
65 SLOT(treeItemClicked(QTreeWidgetItem *, int)));
66 connect(treeWidget, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this,
67 SLOT(treeItemClicked(QTreeWidgetItem *, int)));
68 connect(treeWidget, SIGNAL(itemPressed(QTreeWidgetItem *, int)), this,
69 SLOT(treeItemClicked(QTreeWidgetItem *, int)));
70 connect(treeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this,
71 SLOT(treeItemDoubleClicked(QTreeWidgetItem *, int)));
73 connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
74 connect(actionConnect, SIGNAL(triggered()), m_console, SLOT(connect()));
75 connect(actionStatusDir, SIGNAL(triggered()), m_console, SLOT(status_dir()));
76 connect(actionSelectFont, SIGNAL(triggered()), m_console, SLOT(set_font()));
77 connect(actionLabel, SIGNAL(triggered()), this, SLOT(labelDialogClicked()));
81 * Reimplementation of QWidget closeEvent virtual function
83 void MainWin::closeEvent(QCloseEvent *event)
85 /* ***FIXME*** close any open sockets */
87 m_console->writeSettings();
91 void MainWin::writeSettings()
93 QSettings settings("bacula.org", "bat");
95 settings.beginGroup("MainWin");
96 settings.setValue("winSize", size());
97 settings.setValue("winPos", pos());
101 void MainWin::readSettings()
103 QSettings settings("bacula.org", "bat");
105 settings.beginGroup("MainWin");
106 resize(settings.value("winSize", QSize(1041, 801)).toSize());
107 move(settings.value("winPos", QPoint(200, 150)).toPoint());
111 void MainWin::treeItemClicked(QTreeWidgetItem *item, int column)
114 int index = item->text(1).toInt();
115 if (index >= 0 && index < 2) {
116 stackedWidget->setCurrentIndex(index);
122 void MainWin::treeItemDoubleClicked(QTreeWidgetItem *item, int column)
125 int index = item->text(1).toInt();
126 /* ***FIXME**** make this automatic */
127 if (index >= 0 && index < 2) {
128 stackedWidget->setCurrentIndex(index);
132 void MainWin::labelDialogClicked()
134 new labelDialog(m_console);
139 * The user just finished typing a line in the command line edit box
141 void MainWin::input_line()
143 QString cmdStr = lineEdit->text(); /* Get the text */
144 lineEdit->clear(); /* clear the lineEdit box */
145 if (m_console->is_connected()) {
146 m_console->set_text(cmdStr + "\n");
147 m_console->write_dir(cmdStr.toUtf8().data()); /* send to dir */
149 set_status("Director not connected. Click on connect button.");
154 void MainWin::about()
156 QMessageBox::about(this, tr("About bat"),
157 tr("<br><h2>bat 0.1</h2>"
158 "<p>Copyright © " BYEAR " Free Software Foundation Europe e.V."
159 "<p>The <b>bat</b> is an administrative console"
160 " interface to the Director."));
163 void MainWin::set_statusf(const char *fmt, ...)
168 va_start(arg_ptr, fmt);
169 len = bvsnprintf(buf, sizeof(buf), fmt, arg_ptr);
172 // set_scroll_bar_to_end();
175 void MainWin::set_status_ready()
178 // set_scroll_bar_to_end();
181 void MainWin::set_status(const char *buf)
183 statusBar()->showMessage(buf);