Crossfire Server, Trunk
ChangesDock.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include "ChangesDock.h"
14 #include <QTextEdit>
15 #include <QFile>
16 #include "CRESettings.h"
17 #include <QHelpEngineCore>
18 
19 ChangesDock::ChangesDock(QHelpEngineCore *help, QWidget *parent) : QDockWidget(tr("Changes"), parent) {
20  setAllowedAreas(Qt::RightDockWidgetArea);
21  setFeatures(DockWidgetClosable);
22  setVisible(false);
23 
24  QTextEdit *changes = new QTextEdit(this);
25  changes->setReadOnly(true);
26  setWidget(changes);
27 
28  connect(help, &QHelpEngineCore::setupFinished, [this, help, changes] () { helpReady(help, changes); });
29 }
30 
31 void ChangesDock::helpReady(QHelpEngineCore *help, QTextEdit *edit) {
32  QString content("No content to display");
33  auto links = help->linksForIdentifier("changes");
34  if (!links.empty()) {
35  content = help->fileData(links.begin().value());
36  }
37  edit->setText(content);
38 
40  if (settings.showChanges() && settings.changesLength() != content.length()) {
41  setVisible(true);
42  settings.setChangesLength(content.length());
43  }
44 
45 }
settings
struct Settings settings
Definition: init.cpp:139
ChangesDock.h
ChangesDock::helpReady
void helpReady(QHelpEngineCore *help, QTextEdit *edit)
Definition: ChangesDock.cpp:31
CRESettings.h
ChangesDock::ChangesDock
ChangesDock(QHelpEngineCore *help, QWidget *parent)
Definition: ChangesDock.cpp:19
CRESettings
Definition: CRESettings.h:21
help
static void help(void)
Definition: init.cpp:1163
connect
Definition: connect.py:1