diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/collapser.cc | 15 | ||||
-rw-r--r-- | client/collapser.h | 4 | ||||
-rw-r--r-- | client/macrowindow.cc | 8 | ||||
-rw-r--r-- | client/pracro.ini | 2 | ||||
-rw-r--r-- | client/viewer.cc | 12 | ||||
-rw-r--r-- | client/viewer.h | 5 | ||||
-rw-r--r-- | client/widgets/checkgroupbox.cc | 89 | ||||
-rw-r--r-- | client/widgets/checkgroupbox.h | 11 |
8 files changed, 107 insertions, 39 deletions
diff --git a/client/collapser.cc b/client/collapser.cc index caf3117..599397f 100644 --- a/client/collapser.cc +++ b/client/collapser.cc @@ -47,6 +47,9 @@ Collapser::Collapser(QWidget *current, QScrollArea *scroll) setLayout(new QHBoxLayout()); layout()->setContentsMargins(0,0,0,0); + + connect(this, SIGNAL(scrollToViewSignal()), + this, SLOT(scrollToView()), Qt::QueuedConnection); } void Collapser::updateHeight() @@ -90,6 +93,13 @@ void Collapser::animateToWidget(QWidget *widget, bool stv) timer->start(); } +void Collapser::scrollToView() +{ + if(scroll_to_view && scrollarea && current_widget) { + scrollarea->ensureWidgetVisible(current_widget); + } +} + void Collapser::anim() { double x = (double)(t_anim.elapsed()) / (double)ANIM_TIME; @@ -120,10 +130,7 @@ void Collapser::anim() setFixedHeight(placeholder.toHeight()); emit doneAnimating(current_widget); - - if(scroll_to_view && scrollarea && current_widget) { - scrollarea->ensureWidgetVisible(current_widget); - } + emit scrollToViewSignal(); } } diff --git a/client/collapser.h b/client/collapser.h index 8eea84a..a8ff604 100644 --- a/client/collapser.h +++ b/client/collapser.h @@ -41,16 +41,18 @@ public: void updateHeight(); - void animateToWidget(QWidget *widget, bool scroll_to_view = false); + void animateToWidget(QWidget *widget, bool scroll_to_view); QWidget *currentWidget(); public slots: void anim(); + void scrollToView(); signals: void animating(QWidget *); void doneAnimating(QWidget *); + void scrollToViewSignal(); protected: // void timerEvent(QTimerEvent *); diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 3776a6b..00eb1ed 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -50,7 +50,7 @@ MacroWindow::MacroWindow(NetCom &n, QString templ, bool is_static, bool compact, QScrollArea *scrollarea, MacroDrawer *d) - : Collapser(NULL, compact?NULL:scrollarea), netcom(n) + : Collapser(NULL, is_static?NULL:scrollarea), netcom(n) { drawer = d; this->is_static = is_static; @@ -95,7 +95,7 @@ void MacroWindow::update(QDomNode &node) // No content reveals resumewidget with 'dummy' text. if(children.count() == 0) { - animateToWidget(resumewidget); + animateToWidget(resumewidget, false); return; } @@ -124,7 +124,7 @@ void MacroWindow::updateResume(QDomNode &node) } resumewidget->setText(resume, state); - animateToWidget(resumewidget); + animateToWidget(resumewidget, false); } void MacroWindow::initMacro(QDomNode &node) @@ -150,7 +150,7 @@ void MacroWindow::initMacro(QDomNode &node) if(waschanged == true) macroChanged(); WARN(macrowindow, "New window.\n"); - animateToWidget(mainwidget->qwidget()); + animateToWidget(mainwidget->qwidget(), true); return; // No further recursion here. } diff --git a/client/pracro.ini b/client/pracro.ini index 55c97f7..c3d0dce 100644 --- a/client/pracro.ini +++ b/client/pracro.ini @@ -2,4 +2,4 @@ #host=pracserv.j.auh.dk host=localhost port=12345 -journalpath="/home/samba/praxis/J1" +journalpath="/home/deva/docs/uploadserver/data/"
\ No newline at end of file diff --git a/client/viewer.cc b/client/viewer.cc index eabcf16..4a194b4 100644 --- a/client/viewer.cc +++ b/client/viewer.cc @@ -112,7 +112,7 @@ Viewer::Viewer(QString cpr, QString templs, QString host, quint16 port, } #endif - journal = new QTextEdit(); + journal = new QPlainTextEdit(); journal->setReadOnly(true); journal->setFont(*fixedfont); l->addWidget(journal); @@ -199,7 +199,6 @@ void Viewer::update() } QString filename = journalpath + "/" + cpr.mid(2,2) + "/" + crypt + "/JOURNAL.TXT"; - // filename = "/home/senator/JOURNAL.TXT"; QTextCodec *cp850 = QTextCodec::codecForName("cp850"); if(!cp850) { @@ -213,12 +212,17 @@ void Viewer::update() QString jstrip; for(int i = 0; i < j.length(); i++) { - if(j[i] != '·') jstrip += j[i]; // Remove end of line symbols. + if(j[i] != '·' && j[i] != '') + jstrip += j[i]; // Remove end of line and file symbols. } - if(journal->toPlainText() != jstrip) { + if(jlast != jstrip) { + int max = journal->verticalScrollBar()->maximum(); int pos = journal->verticalScrollBar()->value(); journal->setPlainText(jstrip); + // Scroll to bottom if we were there already or on first update. + if(pos == max || jlast == "") pos = journal->verticalScrollBar()->maximum(); journal->verticalScrollBar()->setValue(pos); + jlast = jstrip; } } diff --git a/client/viewer.h b/client/viewer.h index c9f1b41..799bb3d 100644 --- a/client/viewer.h +++ b/client/viewer.h @@ -29,7 +29,7 @@ #define __PRACRO_VIEWER_H__ #include <QApplication> -#include <QTextEdit> +#include <QPlainTextEdit> #include <QTimer> #include <QLabel> #include <QStringList> @@ -76,7 +76,8 @@ private: QString journalpath; QStringList templs; - QTextEdit *journal; + QPlainTextEdit *journal; + QString jlast; #ifdef WITH_FROGS NetCom *netcom; diff --git a/client/widgets/checkgroupbox.cc b/client/widgets/checkgroupbox.cc index 7204418..07b7632 100644 --- a/client/widgets/checkgroupbox.cc +++ b/client/widgets/checkgroupbox.cc @@ -28,29 +28,59 @@ #include "checkgroupbox.h" #include <QGroupBox> +#include <QCheckBox> + +#include <QHBoxLayout> #include "common.h" +#include "debug.h" CheckGroupBox::CheckGroupBox(QDomNode &node, MacroWindow *macrowindow) : Widget(node, macrowindow) { - // - // From GroupBox - // - groupbox = new QGroupBox(); - groupbox->setCheckable(true); - widget = groupbox; + QDomElement elem = node.toElement(); - setCommonAttributes(groupbox, node); - setCommonLayout(groupbox, node); + type = elem.attribute("type", "framed"); + + checkbox = NULL; + groupbox = NULL; - QDomElement elem = node.toElement(); + if(type == "framed") { + groupbox = new QGroupBox(); + groupbox->setCheckable(true); + connect(groupbox, SIGNAL(toggled(bool)), this, SLOT(state_change(bool))); + widget = groupbox; - if(elem.hasAttribute("caption")) { - groupbox->setTitle(elem.attribute("caption")); - } + if(elem.hasAttribute("caption")) { + groupbox->setTitle(elem.attribute("caption")); + } + + setCommonAttributes(widget, node); + setCommonLayout(widget, node); - addChildren(node, groupbox->layout()); + addChildren(node, widget->layout()); + + } else if(type == "simple") { + widget = new QWidget(); + QHBoxLayout *l = new QHBoxLayout(); + widget->setLayout(l); + checkbox = new QCheckBox(); + connect(checkbox, SIGNAL(toggled(bool)), this, SLOT(state_change(bool))); + if(elem.hasAttribute("caption")) { + checkbox->setText(elem.attribute("caption")); + } + l->addWidget(checkbox); + container = new QWidget(); + l->addWidget(container); + + setCommonAttributes(widget, node); + setCommonLayout(container, node); + + addChildren(node, container->layout()); + + } else { + ERROR(checkgroupbox, "Illigal value of attribute 'type'\n"); + } // // From CheckBox @@ -68,8 +98,6 @@ CheckGroupBox::CheckGroupBox(QDomNode &node, MacroWindow *macrowindow) } else { falsevalue = "false"; } - - connect(groupbox, SIGNAL(toggled(bool)), this, SLOT(state_change(bool))); } CheckGroupBox::~CheckGroupBox() @@ -79,7 +107,8 @@ CheckGroupBox::~CheckGroupBox() QString CheckGroupBox::value() { - if(groupbox->isChecked()) return truevalue; + if(groupbox && groupbox->isChecked()) return truevalue; + if(checkbox && checkbox->isChecked()) return truevalue; return falsevalue; } @@ -89,28 +118,43 @@ void CheckGroupBox::setValue(QString value, QString source) changedByUser = false; - bool old = groupbox->isChecked(); + bool old = false; + if(groupbox) old = groupbox->isChecked(); + if(checkbox) old = checkbox->isChecked(); if(value == truevalue) { - groupbox->setChecked(true); + if(groupbox) groupbox->setChecked(true); + if(checkbox) { + checkbox->setChecked(true); + container->setEnabled(true); + } } else if(value == falsevalue) { - groupbox->setChecked(false); + if(groupbox) groupbox->setChecked(false); + if(checkbox) { + checkbox->setChecked(false); + container->setEnabled(false); + } } else { printf("Unknown checkbox value: %s\n", value.toStdString().c_str()); } // If set operation did not change the value we must invocate the code manually. - if(old == groupbox->isChecked()) state_change(0); + if(groupbox && old == groupbox->isChecked()) state_change(old); + if(checkbox && old == checkbox->isChecked()) state_change(old); // setInitialValue(value); changedByUser = true; } -void CheckGroupBox::state_change(bool) +void CheckGroupBox::state_change(bool state) { emit eventOnChange(); if(changedByUser) emit wasChanged(); + + if(checkbox) { + container->setEnabled(state); + } } bool CheckGroupBox::checked() @@ -135,7 +179,8 @@ void CheckGroupBox::setWdgValid(bool valid) palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); } - groupbox->setPalette(palette); + if(groupbox) groupbox->setPalette(palette); + if(checkbox) checkbox->setPalette(palette); } bool CheckGroupBox::setKeyboardFocus() diff --git a/client/widgets/checkgroupbox.h b/client/widgets/checkgroupbox.h index eac85f9..9b6dcdc 100644 --- a/client/widgets/checkgroupbox.h +++ b/client/widgets/checkgroupbox.h @@ -37,10 +37,15 @@ * @extends checkbox * @screenshot * @container - * @att layout the layout used in the groupbox. Can be one of 'vbox' or 'hbox'. + * @att layout The layout used in the groupbox. Can be one of 'vbox' or 'hbox'. + * @att type Defines the type of the checkbox. It can be one of 'framed' or + * 'simple'. Framed will draw a frame with the checkbox contained in the + * caption. 'simple' will draw the checkbox without the frame and put the inner + * to the right of it. Default is 'framed'. */ class QGroupBox; +class QCheckBox; class CheckGroupBox : public Widget { Q_OBJECT @@ -65,9 +70,13 @@ private: QString truevalue; QString falsevalue; + QString type; + bool changedByUser; QGroupBox *groupbox; + QCheckBox *checkbox; + QWidget *container; }; #endif/*__PRACRO_CHECKGROUPBOX_H__*/ |