From 82c32c05eb4741e98736099c456b3ffc93c755af Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 3 Jul 2009 11:59:24 +0000 Subject: Some tweaking in the new dependency system. Mostly GUI stuff. --- client/client.pro | 2 +- client/client.qrc | 1 + client/icons/padlock.png | Bin 0 -> 1221 bytes client/icons/padlock.svg | 351 +++++++++++++++++++++++++++++++++ client/macro.cc | 38 ++-- client/macro.h | 3 + client/macrodrawer.cc | 49 ++++- client/macrodrawer.h | 9 +- client/macrowindow.cc | 4 +- client/pracro_dk.ts | 48 ++--- server/xml/macros/B.0.1.xml | 50 +++++ server/xml/templates/amd_forunders.xml | 48 ++--- 12 files changed, 533 insertions(+), 70 deletions(-) create mode 100644 client/icons/padlock.png create mode 100644 client/icons/padlock.svg create mode 100644 server/xml/macros/B.0.1.xml diff --git a/client/client.pro b/client/client.pro index 772bbd3..5d86158 100644 --- a/client/client.pro +++ b/client/client.pro @@ -7,7 +7,7 @@ TARGET = pracro DEPENDPATH += . widgets INCLUDEPATH += . widgets RESOURCES += client.qrc -QT += core gui network xml sql +QT += core gui network xml sql svg # For debugging debug { diff --git a/client/client.qrc b/client/client.qrc index 6da90ed..efcd91f 100644 --- a/client/client.qrc +++ b/client/client.qrc @@ -6,5 +6,6 @@ icons/del.png icons/arrows.png icons/compressed.png + icons/padlock.png diff --git a/client/icons/padlock.png b/client/icons/padlock.png new file mode 100644 index 0000000..6e626df Binary files /dev/null and b/client/icons/padlock.png differ diff --git a/client/icons/padlock.svg b/client/icons/padlock.svg new file mode 100644 index 0000000..fb2389b --- /dev/null +++ b/client/icons/padlock.svg @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/client/macro.cc b/client/macro.cc index 650a352..7a4cb89 100644 --- a/client/macro.cc +++ b/client/macro.cc @@ -29,7 +29,7 @@ #include #include - +#include #include "macrodrawer.h" Macro::Macro(QDomNode &n) @@ -89,16 +89,30 @@ void Macro::init(QBoxLayout *layout, Macros ¯os, bool initialising, NetCom & if(window == NULL) { window = new MacroWindow(netcom, node, course, !isstatic, iscompact); - MacroDrawer *g = new MacroDrawer(this, xml_elem.attribute("caption", name)); - g->connect(g, SIGNAL(toggle()), window, SLOT(toggleMacro())); - g->connect(window, SIGNAL(activationChanged(bool)), g, SLOT(activationChange(bool))); + /* + QWidget *edge = new QWidget(); + edge->setContentsMargins(1,1,1,1); + edge->setAutoFillBackground(true); + edge->setAttribute(Qt::WA_WindowPropagation, true); + QHBoxLayout *edgelayout = new QHBoxLayout(); + edgelayout->setContentsMargins(0,0,0,0); + edge->setLayout(edgelayout); + layout->addWidget(edge); + */ + + drawer = new MacroDrawer(this, xml_elem.attribute("caption", name), NULL/*edge*/); + drawer->connect(drawer, SIGNAL(toggle()), window, SLOT(toggleMacro())); + drawer->connect(window, SIGNAL(activationChanged(bool)), drawer, SLOT(activationChange(bool))); + //drawer->setAutoFillBackground(true); + //drawer->setContentsMargins(1,1,1,1); window->setActive(false); - - layout->addWidget(g); + //drawer->setPalette(QApplication::palette()); + //edge->layout()->addWidget(g); + layout->addWidget(drawer); QHBoxLayout *l = new QHBoxLayout(); l->setContentsMargins(10,0,10,0); - g->setLayout(l); + drawer->setLayout(l); l->addWidget(window); { QFont f = window->font(); @@ -116,22 +130,24 @@ void Macro::init(QBoxLayout *layout, Macros ¯os, bool initialising, NetCom & } QStringList::iterator rs = requires.begin(); + QStringList blocking; bool active = true; while(rs != requires.end()) { - printf("Testing if %s is completed...", rs->toStdString().c_str()); + // printf("Testing if %s is completed...", rs->toStdString().c_str()); Macros::iterator ms = macros.begin(); while(ms != macros.end()) { if(ms->name == *rs) { - printf("Found it %d", ms->iscompleted); + // printf("Found it %d", ms->iscompleted); + if(ms->iscompleted == false) blocking.append(ms->name); active = active && ms->iscompleted; } ms++; } - printf("\n"); + // printf("\n"); rs++; } window->setActive(active); - + if(!active) drawer->setToolTip(QObject::tr("Depends on: ") + blocking.join(", ")); } diff --git a/client/macro.h b/client/macro.h index 4adaf09..610d3b2 100644 --- a/client/macro.h +++ b/client/macro.h @@ -39,6 +39,8 @@ class Macro; typedef QMap Macros; +class MacroDrawer; + class Macro { public: Macro() {} @@ -62,6 +64,7 @@ public: bool iscompact; MacroWindow *window; + MacroDrawer *drawer; private: QDomNode node; diff --git a/client/macrodrawer.cc b/client/macrodrawer.cc index f3fcab1..47edc22 100644 --- a/client/macrodrawer.cc +++ b/client/macrodrawer.cc @@ -27,31 +27,37 @@ #include "macrodrawer.h" #include +#include +#include +#include +#include -MacroDrawer::MacroDrawer(Macro *macro, QString title) +MacroDrawer::MacroDrawer(Macro *macro, QString title, QWidget *edge) { + button = NULL; + this->edge = edge; + if(!macro->isstatic) setTitle(" " + title); setFlat(true); { - QFont f = font(); - f.setItalic(true); + QFont f = font(); f.setItalic(true); setFont(f); } if(!macro->isstatic) { - QPushButton *b = new QPushButton("±", this); - b->setFixedSize(16,16); - b->move(0,0); + button = new QPushButton(this); + button->setFixedSize(16,16); + button->move(0,0); { - QFont f = b->font(); + QFont f = button->font(); f.setBold(false); f.setItalic(false); - b->setFont(f); + button->setFont(f); } installEventFilter(this); - connect(b, SIGNAL(clicked()), this, SLOT(toggleMe())); + connect(button, SIGNAL(clicked()), this, SLOT(toggleMe())); } } @@ -73,4 +79,29 @@ void MacroDrawer::activationChange(bool active) { //printf("Active %d\n", (int)active); setEnabled(active); + /* + if(active) { + QPalette palette = edge->palette(); + palette.setBrush(QPalette::Window, QBrush(QColor(150, 150, 255))); + edge->setPalette(palette); + } else { + edge->setPalette(QApplication::palette()); + } + */ + + if(!active) { + // Set padlock icon on button. + if(button) { + button->setIcon(QPixmap(":icons/padlock.png")); + button->setText(""); + } + + } else { + // Clear padlock icon on button + if(button) { + button->setIcon(QPixmap()); + button->setText("±"); + } + } + } diff --git a/client/macrodrawer.h b/client/macrodrawer.h index 0ad09f5..7aaf2ec 100644 --- a/client/macrodrawer.h +++ b/client/macrodrawer.h @@ -29,12 +29,15 @@ #include #include +#include #include "macro.h" +class Macro; + class MacroDrawer : public QGroupBox { Q_OBJECT public: - MacroDrawer(Macro *macro, QString title); + MacroDrawer(Macro *macro, QString title, QWidget *edge); protected: bool eventFilter(QObject *obj, QEvent *event); @@ -45,6 +48,10 @@ public slots: signals: void toggle(); + +private: + QWidget *edge; + QPushButton *button; }; #endif/*__PRACRO_MACRODRAWER_H__*/ diff --git a/client/macrowindow.cc b/client/macrowindow.cc index db6ad53..a96964b 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -400,7 +400,7 @@ void MacroWindow::setActive(bool active) if(this->active == active) return; this->active = active; - if(active == false) setEnabled(false); - else setEnabled(true); + setEnabled(active); + emit activationChanged(active); } diff --git a/client/pracro_dk.ts b/client/pracro_dk.ts index 7097817..30e7b4b 100644 --- a/client/pracro_dk.ts +++ b/client/pracro_dk.ts @@ -1,7 +1,6 @@ - DBWidget @@ -9,7 +8,7 @@ Write something in the searchfield - Skriv noget i søgefeltet + Skriv noget i søgefeltet @@ -17,13 +16,13 @@ Add to list - Tilføj til listen + Tilføj til listen Remove from list Remove form list - Fjern fra listen + Fjern fra listen @@ -31,92 +30,97 @@ Ok - Ok + Ok Open - Ã…bn + Ã…bn Save - Gem + Gem Cancel - Annullér + Annullér Close - Luk + Luk Discard - Kassér + Kassér Apply - Tag i brug + Tag i brug Reset - Nulstil + Nulstil Restore Defaults - Genopret default + Genopret default Help - Hjælp + Hjælp Save All - Gem alle + Gem alle Yes - Ja + Ja Yes To All - Ja til alle + Ja til alle No - Nej + Nej No To All - Nej til alle + Nej til alle Abort - Afbryd + Afbryd Retry - Prøv igen + Prøv igen Ignore - Ignorér + Ignorér + + + + Depends on: + Afhænger af: diff --git a/server/xml/macros/B.0.1.xml b/server/xml/macros/B.0.1.xml new file mode 100644 index 0000000..fcaf010 --- /dev/null +++ b/server/xml/macros/B.0.1.xml @@ -0,0 +1,50 @@ + + + + + Henvist af ${referral.doctor} til forundersøgelse under diagnosen: ${referral.diagnose} + + + + + + + + + + + + + + + +