Crossfire Server, Trunk
ChangesDock.cpp
Go to the documentation of this file.
1 #include "ChangesDock.h"
2 #include <QTextEdit>
3 #include <QFile>
4 #include "CRESettings.h"
5 #include <QHelpEngineCore>
6 
7 ChangesDock::ChangesDock(QHelpEngineCore *help, QWidget *parent) : QDockWidget(tr("Changes"), parent) {
8  setAllowedAreas(Qt::RightDockWidgetArea);
9  setFeatures(DockWidgetClosable);
10  setVisible(false);
11 
12  QTextEdit *changes = new QTextEdit(this);
13  changes->setReadOnly(true);
14  setWidget(changes);
15 
16  connect(help, &QHelpEngineCore::setupFinished, [this, help, changes] () { helpReady(help, changes); });
17 }
18 
19 void ChangesDock::helpReady(QHelpEngineCore *help, QTextEdit *edit) {
20  QString content("No content to display");
21  auto links = help->linksForIdentifier("changes");
22  if (!links.empty()) {
23  content = help->fileData(links.begin().value());
24  }
25  edit->setText(content);
26 
28  if (settings.showChanges() && settings.changesLength() != content.length()) {
29  setVisible(true);
30  settings.setChangesLength(content.length());
31  }
32 
33 }
ChangesDock.h
help
static void help(void)
Definition: init.c:1163
settings
struct Settings settings
Definition: init.c:39
ChangesDock::helpReady
void helpReady(QHelpEngineCore *help, QTextEdit *edit)
Definition: ChangesDock.cpp:19
CRESettings.h
ChangesDock::ChangesDock
ChangesDock(QHelpEngineCore *help, QWidget *parent)
Definition: ChangesDock.cpp:7
CRESettings
Definition: CRESettings.h:9
connect
Definition: connect.py:1