-ui_main.h
+ui_*.h
*.o
bat
about-func
m_cursor = new QTextCursor(m_textEdit->document());
mainWin->actionConnect->setIcon(QIcon(QString::fromUtf8("images/disconnected.png")));
- /* ***FIXME*** make this configurable */
- font.setFamily("Courier");
- font.setFixedPitch(true);
- font.setPointSize(10);
- m_textEdit->setFont(font);
/* Just take the first Director */
LockRes();
item->setText(0, "Restore");
item->setText(1, "1");
treeWidget->expandItem(topItem);
+
+ readSettings();
+
}
/*
return;
}
+
+void Console::writeSettings()
+{
+ QFont font = get_font();
+
+ QSettings settings("bacula.org", "bat");
+ settings.beginGroup("Console");
+ settings.setValue("consoleFont", font.family());
+ settings.setValue("consolePointSize", font.pointSize());
+ settings.setValue("consoleFixedPitch", font.fixedPitch());
+ settings.endGroup();
+}
+
+void Console::readSettings()
+{
+ QFont font = get_font();
+
+ QSettings settings("bacula.org", "bat");
+ settings.beginGroup("Console");
+ font.setFamily(settings.value("consoleFont", "Courier").value<QString>());
+ font.setPointSize(settings.value("consolePointSize", 10).toInt());
+ font.setFixedPitch(settings.value("consoleFixedPitch", true).toBool());
+ settings.endGroup();
+ m_textEdit->setFont(font);
+}
+
+void Console::set_font()
+{
+ bool ok;
+ QFont font = QFontDialog::getFont(&ok, QFont(m_textEdit->font()), this);
+ if (ok) {
+ m_textEdit->setFont(font);
+ }
+}
+
+const QFont Console::get_font()
+{
+ return m_textEdit->font();
+}
+
+
void Console::status_dir()
{
write_dir("status dir\n");
void write_dir(const char *buf);
bool authenticate_director(JCR *jcr, DIRRES *director, CONRES *cons);
bool is_connected() { return m_sock != NULL; };
+ const QFont get_font();
+ void writeSettings();
+ void readSettings();
public slots:
void connect(void);
void read_dir(int fd);
void status_dir(void);
+ void set_font(void);
private:
QTextEdit *m_textEdit;
<rect>
<x>0</x>
<y>0</y>
- <width>1038</width>
- <height>802</height>
+ <width>1041</width>
+ <height>801</height>
</rect>
</property>
<property name="windowTitle" >
<rect>
<x>0</x>
<y>0</y>
- <width>1038</width>
+ <width>1041</width>
<height>33</height>
</rect>
</property>
+ <widget class="QMenu" name="menuHelp" >
+ <property name="title" >
+ <string>&Help</string>
+ </property>
+ <addaction name="actionAbout_bat" />
+ </widget>
+ <widget class="QMenu" name="menuSettings" >
+ <property name="title" >
+ <string>Settings</string>
+ </property>
+ <addaction name="actionSelectFont" />
+ </widget>
<widget class="QMenu" name="menuEdit" >
<property name="title" >
<string>&Edit</string>
<addaction name="actionSave" />
<addaction name="actionQuit" />
</widget>
- <widget class="QMenu" name="menuHelp" >
- <property name="title" >
- <string>&Help</string>
- </property>
- <addaction name="actionAbout_bat" />
- </widget>
<addaction name="menuFile" />
<addaction name="menuEdit" />
+ <addaction name="menuSettings" />
<addaction name="menuHelp" />
</widget>
<widget class="QStatusBar" name="statusbar" >
<string>Status of Director</string>
</property>
</action>
+ <action name="actionSelectFont" >
+ <property name="text" >
+ <string>&Select Font ...</string>
+ </property>
+ </action>
</widget>
<resources>
<include location="main.qrc" />
lineEdit->setFocus();
+ createConnections();
+
+ readSettings();
+}
+
+void MainWin::createConnections()
+{
/* Connect signals to slots */
connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(input_line()));
connect(actionAbout_bat, SIGNAL(triggered()), this, SLOT(about()));
connect(actionQuit, SIGNAL(triggered()), app, SLOT(closeAllWindows()));
connect(actionConnect, SIGNAL(triggered()), m_console, SLOT(connect()));
connect(actionStatusDir, SIGNAL(triggered()), m_console, SLOT(status_dir()));
+ connect(actionSelectFont, SIGNAL(triggered()), m_console, SLOT(set_font()));
+}
+
+/*
+ * Reimplementation of QWidget closeEvent virtual function
+ */
+void MainWin::closeEvent(QCloseEvent *event)
+{
+ /* ***FIXME*** close any open sockets */
+ writeSettings();
+ m_console->writeSettings();
+ event->accept();
+}
+
+void MainWin::writeSettings()
+{
+ QSettings settings("bacula.org", "bat");
+
+ settings.beginGroup("MainWin");
+ settings.setValue("winSize", size());
+ settings.setValue("winPos", pos());
+ settings.endGroup();
+}
+
+void MainWin::readSettings()
+{
+ QSettings settings("bacula.org", "bat");
+
+ settings.beginGroup("MainWin");
+ resize(settings.value("winSize", QSize(1041, 801)).toSize());
+ move(settings.value("winPos", QPoint(200, 150)).toPoint());
+ settings.endGroup();
}
void MainWin::treeItemClicked(QTreeWidgetItem *item, int column)
void set_statusf(const char *fmt, ...);
void set_status_ready();
void set_status(const char *buf);
+ void writeSettings();
+ void readSettings();
public slots:
void input_line();
void treeItemClicked(QTreeWidgetItem *item, int column);
void treeItemDoubleClicked(QTreeWidgetItem *item, int column);
+protected:
+ void closeEvent(QCloseEvent *event);
+
+private:
+ void createConnections();
+
private:
QString m_UserInput;
Console *m_console;