Skip to content

Commit 1de5d98

Browse files
committed
Implement test send for checking option
1 parent f47cf25 commit 1de5d98

File tree

11 files changed

+152
-21
lines changed

11 files changed

+152
-21
lines changed

src/cloud

Submodule cloud updated from d848eea to 15d290a

src/core/management_layer/application_manager.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3649,6 +3649,21 @@ void ApplicationManager::initConnections()
36493649
d->cloudServiceManager.data(), &CloudServiceManager::aiGenerateText);
36503650
connect(d->projectManager.data(), &ProjectManager::generateImageRequested,
36513651
d->cloudServiceManager.data(), &CloudServiceManager::aiGenerateImage);
3652+
//
3653+
// Тестовый метод, для отправки документа на проверку
3654+
//
3655+
connect(d->projectManager.data(), &ProjectManager::sendDocumentToReviewRequested,
3656+
d->cloudServiceManager.data(),
3657+
[this](const QUuid& _documentUuid, const QString& _comment) {
3658+
const auto currentProject = d->projectsManager->currentProject();
3659+
if (currentProject == nullptr || currentProject->isLocal()) {
3660+
return;
3661+
}
3662+
3663+
d->cloudServiceManager->sendDocumentToReview(currentProject->id(), _documentUuid,
3664+
_comment);
3665+
});
3666+
//
36523667
connect(d->cloudServiceManager.data(), &CloudServiceManager::textRephrased,
36533668
d->projectManager.data(), &ProjectManager::setRephrasedText);
36543669
connect(d->cloudServiceManager.data(), &CloudServiceManager::textExpanded,

src/core/management_layer/content/project/project_manager.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ class ProjectManager::Implementation
455455
/**
456456
* @brief Находится ли проект в команде
457457
*/
458-
bool isProjectInTeam = false;
458+
int projectTeamId = Domain::kInvalidId;
459459

460460
/**
461461
* @brief Может ли пользователь расшаривать доступ к документам проекта
@@ -3450,7 +3450,7 @@ void ProjectManager::reconfigureNovelNavigator()
34503450

34513451
void ProjectManager::checkAvailabilityToEdit()
34523452
{
3453-
d->pluginsBuilder.checkAvailabilityToEdit(d->isProjectInTeam);
3453+
d->pluginsBuilder.checkAvailabilityToEdit(d->projectTeamId != Domain::kInvalidId);
34543454
d->updateViewsEditingMode();
34553455
}
34563456

@@ -3523,7 +3523,7 @@ void ProjectManager::updateCurrentProject(BusinessLayer::ProjectsModelProjectIte
35233523
d->projectPath = _project->path();
35243524
d->isProjectRemote = _project->isRemote();
35253525
d->isProjectOwner = _project->isOwner();
3526-
d->isProjectInTeam = _project->teamId() != Domain::kInvalidId;
3526+
d->projectTeamId = _project->teamId();
35273527
d->allowGrantAccessToProject
35283528
= d->isProjectOwner || (projectTeam != nullptr && projectTeam->allowGrantAccessToProject());
35293529
d->editingMode = _project->editingMode();
@@ -3541,6 +3541,11 @@ void ProjectManager::updateCurrentProject(BusinessLayer::ProjectsModelProjectIte
35413541
if (projectTeam != nullptr) {
35423542
projectInformationModel->setTeammates(projectTeam->members());
35433543
}
3544+
3545+
//
3546+
// Раз получили обновлённую информацию о проекте, проверим режим редактирования для всех вьюх
3547+
//
3548+
d->updateViewsEditingMode();
35443549
}
35453550

35463551
void ProjectManager::restoreCurrentProjectState(const QString& _path)
@@ -5279,7 +5284,11 @@ void ProjectManager::showView(const QModelIndex& _itemIndex, const QString& _vie
52795284
return;
52805285
}
52815286
Log::trace("Set project info");
5282-
view->setProjectInfo(d->isProjectRemote, d->isProjectOwner, d->allowGrantAccessToProject);
5287+
constexpr int testTeamId = 17;
5288+
const bool canBeSentForChecking
5289+
= d->projectTeamId == testTeamId && d->editingPermissions.contains(itemForShow->uuid());
5290+
view->setProjectInfo(d->isProjectRemote, d->isProjectOwner, d->allowGrantAccessToProject,
5291+
canBeSentForChecking);
52835292
Log::trace("Set editing mode");
52845293
view->setEditingMode(d->documentEditingMode(itemForShow));
52855294
Log::trace("Set view cursors");
@@ -5438,6 +5447,16 @@ void ProjectManager::showView(const QModelIndex& _itemIndex, const QString& _vie
54385447
this, SIGNAL(generateImageRequested(QString, QString, QString)),
54395448
Qt::UniqueConnection);
54405449
}
5450+
5451+
//
5452+
// Добавляем коннект с тестовым методом
5453+
//
5454+
if (documentManager->metaObject()->indexOfSignal(
5455+
"sendDocumentToReviewRequested(QUuid,QString)")
5456+
!= invalidSignalIndex) {
5457+
connect(documentManager, SIGNAL(sendDocumentToReviewRequested(QUuid, QString)), this,
5458+
SIGNAL(sendDocumentToReviewRequested(QUuid, QString)), Qt::UniqueConnection);
5459+
}
54415460
}
54425461

54435462
//

src/core/management_layer/content/project/project_manager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@ class ProjectManager : public QObject
355355
void importFileRequested(const QString& _filePath, const QUuid& _documentUuid,
356356
Domain::DocumentObjectType _type);
357357

358+
359+
/**
360+
* @brief Запрос отправки документа на проверку
361+
*/
362+
void sendDocumentToReviewRequested(const QUuid& _documentUuid, const QString& _comment);
363+
358364
protected:
359365
/**
360366
* @brief Переопределяем для обработки события простоя пользователя

src/core/management_layer/plugins/screenplay_information/screenplay_information_manager.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "screenplay_information_view.h"
44

55
#include <business_layer/model/screenplay/screenplay_information_model.h>
6+
#include <domain/document_object.h>
67

78
#include <QApplication>
89
#include <QFileDialog>
@@ -13,6 +14,8 @@ namespace ManagementLayer {
1314
class ScreenplayInformationManager::Implementation
1415
{
1516
public:
17+
explicit Implementation(ScreenplayInformationManager* _q);
18+
1619
/**
1720
* @brief Создать представление
1821
*/
@@ -25,6 +28,8 @@ class ScreenplayInformationManager::Implementation
2528
Ui::ScreenplayInformationView* _view);
2629

2730

31+
ScreenplayInformationManager* q = nullptr;
32+
2833
/**
2934
* @brief Предаставление для основного окна
3035
*/
@@ -41,6 +46,11 @@ class ScreenplayInformationManager::Implementation
4146
QVector<ViewAndModel> allViews;
4247
};
4348

49+
ScreenplayInformationManager::Implementation::Implementation(ScreenplayInformationManager* _q)
50+
: q(_q)
51+
{
52+
}
53+
4454
Ui::ScreenplayInformationView* ScreenplayInformationManager::Implementation::createView(
4555
BusinessLayer::AbstractModel* _model)
4656
{
@@ -138,6 +148,12 @@ void ScreenplayInformationManager::Implementation::setModelForView(
138148
&BusinessLayer::ScreenplayInformationModel::setScreenplayTextVisible);
139149
connect(_view, &Ui::ScreenplayInformationView::screenplayStatisticsVisibleChanged, model,
140150
&BusinessLayer::ScreenplayInformationModel::setScreenplayStatisticsVisible);
151+
152+
//
153+
connect(_view, &Ui::ScreenplayInformationView::sendDocumentToReviewRequested, q,
154+
[this, model](const QString& _comment) {
155+
emit q->sendDocumentToReviewRequested(model->document()->uuid(), _comment);
156+
});
141157
}
142158
}
143159

@@ -147,12 +163,17 @@ void ScreenplayInformationManager::Implementation::setModelForView(
147163

148164
ScreenplayInformationManager::ScreenplayInformationManager(QObject* _parent)
149165
: QObject(_parent)
150-
, d(new Implementation)
166+
, d(new Implementation(this))
151167
{
152168
}
153169

154170
ScreenplayInformationManager::~ScreenplayInformationManager() = default;
155171

172+
QObject* ScreenplayInformationManager::asQObject()
173+
{
174+
return this;
175+
}
176+
156177
Ui::IDocumentView* ScreenplayInformationManager::view()
157178
{
158179
return d->view;

src/core/management_layer/plugins/screenplay_information/screenplay_information_manager.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class MANAGER_PLUGIN_EXPORT ScreenplayInformationManager : public QObject, publi
2626
* @brief Реализуем интерфейс менеджера документа
2727
*/
2828
/** @{ */
29+
QObject* asQObject() override;
2930
Ui::IDocumentView* view() override;
3031
Ui::IDocumentView* view(BusinessLayer::AbstractModel* _model) override;
3132
Ui::IDocumentView* secondaryView() override;
@@ -35,6 +36,12 @@ class MANAGER_PLUGIN_EXPORT ScreenplayInformationManager : public QObject, publi
3536
void setEditingMode(DocumentEditingMode _mode) override;
3637
/** @} */
3738

39+
signals:
40+
/**
41+
* @brief Запрос отправки документа на проверку
42+
*/
43+
void sendDocumentToReviewRequested(const QUuid& _documentUuid, const QString& _comment);
44+
3845
private:
3946
class Implementation;
4047
QScopedPointer<Implementation> d;

src/core/management_layer/plugins/screenplay_information/screenplay_information_view.cpp

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <interfaces/management_layer/i_document_manager.h>
44
#include <ui/design_system/design_system.h>
55
#include <ui/modules/logline_generator/logline_generator_dialog.h>
6+
#include <ui/widgets/button/button.h>
67
#include <ui/widgets/card/card.h>
78
#include <ui/widgets/check_box/check_box.h>
89
#include <ui/widgets/scroll_bar/scroll_bar.h>
@@ -24,6 +25,10 @@ class ScreenplayInformationView::Implementation
2425

2526
QScrollArea* content = nullptr;
2627

28+
Card* checkingInfo = nullptr;
29+
TextField* checkingComment = nullptr;
30+
Button* sendForChecking = nullptr;
31+
2732
Card* screenplayInfo = nullptr;
2833
QGridLayout* screenplayInfoLayout = nullptr;
2934
TextField* screenplayName = nullptr;
@@ -38,6 +43,9 @@ class ScreenplayInformationView::Implementation
3843

3944
ScreenplayInformationView::Implementation::Implementation(QWidget* _parent)
4045
: content(new QScrollArea(_parent))
46+
, checkingInfo(new Card(_parent))
47+
, checkingComment(new TextField(checkingInfo))
48+
, sendForChecking(new Button(checkingInfo))
4149
, screenplayInfo(new Card(_parent))
4250
, screenplayInfoLayout(new QGridLayout)
4351
, screenplayName(new TextField(screenplayInfo))
@@ -70,6 +78,11 @@ ScreenplayInformationView::Implementation::Implementation(QWidget* _parent)
7078
screenplayLogline,
7179
});
7280

81+
auto checkingLayout = UiHelper::makeHBoxLayout();
82+
checkingLayout->addWidget(checkingComment, 1);
83+
checkingLayout->addWidget(sendForChecking);
84+
checkingInfo->setContentLayout(checkingLayout);
85+
7386
screenplayInfoLayout->setContentsMargins({});
7487
screenplayInfoLayout->setSpacing(0);
7588
int row = 0;
@@ -92,9 +105,12 @@ ScreenplayInformationView::Implementation::Implementation(QWidget* _parent)
92105
QVBoxLayout* layout = new QVBoxLayout;
93106
layout->setContentsMargins({});
94107
layout->setSpacing(0);
108+
layout->addWidget(checkingInfo);
95109
layout->addWidget(screenplayInfo);
96110
layout->addStretch();
97111
contentWidget->setLayout(layout);
112+
113+
checkingInfo->hide();
98114
}
99115

100116

@@ -113,6 +129,9 @@ ScreenplayInformationView::ScreenplayInformationView(QWidget* _parent)
113129
layout->addWidget(d->content);
114130
setLayout(layout);
115131

132+
connect(d->sendForChecking, &Button::clicked, this,
133+
[this] { emit sendDocumentToReviewRequested(d->checkingComment->text()); });
134+
116135
connect(d->screenplayName, &TextField::textChanged, this,
117136
[this] { emit nameChanged(d->screenplayName->text()); });
118137
connect(d->screenplayTagline, &TextField::textChanged, this,
@@ -170,13 +189,26 @@ QWidget* ScreenplayInformationView::asQWidget()
170189
return this;
171190
}
172191

192+
void ScreenplayInformationView::setProjectInfo(bool _isRemote, bool _isOwner,
193+
bool _allowGrantAccessToProject,
194+
bool _canBeSentForChecking)
195+
{
196+
Q_UNUSED(_isRemote)
197+
Q_UNUSED(_isOwner)
198+
Q_UNUSED(_allowGrantAccessToProject)
199+
200+
d->checkingInfo->setVisible(_canBeSentForChecking);
201+
}
202+
173203
void ScreenplayInformationView::setEditingMode(ManagementLayer::DocumentEditingMode _mode)
174204
{
175205
const auto readOnly = _mode != ManagementLayer::DocumentEditingMode::Edit;
206+
d->checkingComment->setReadOnly(readOnly);
176207
d->screenplayName->setReadOnly(readOnly);
177208
d->screenplayTagline->setReadOnly(readOnly);
178209
d->screenplayLogline->setReadOnly(readOnly);
179210
const auto enabled = !readOnly;
211+
d->sendForChecking->setEnabled(enabled);
180212
d->titlePageVisiblity->setEnabled(enabled);
181213
d->synopsisVisiblity->setEnabled(enabled);
182214
d->treatmentVisiblity->setEnabled(enabled);
@@ -238,6 +270,9 @@ void ScreenplayInformationView::setScreenplayStatisticsVisible(bool _visible)
238270

239271
void ScreenplayInformationView::updateTranslations()
240272
{
273+
d->checkingComment->setLabel(tr("Comment"));
274+
d->sendForChecking->setText(tr("Send for checking"));
275+
241276
d->screenplayName->setLabel(tr("Screenplay name"));
242277
d->screenplayTagline->setLabel(tr("Tagline"));
243278
d->screenplayLogline->setLabel(tr("Logline"));
@@ -253,30 +288,40 @@ void ScreenplayInformationView::designSystemChangeEvent(DesignSystemChangeEvent*
253288
{
254289
Widget::designSystemChangeEvent(_event);
255290

256-
setBackgroundColor(Ui::DesignSystem::color().surface());
291+
setBackgroundColor(DesignSystem::color().surface());
257292

258293
d->content->widget()->layout()->setContentsMargins(
259-
QMarginsF(Ui::DesignSystem::layout().px24(),
260-
Ui::DesignSystem::compactLayout().topContentMargin(),
261-
Ui::DesignSystem::layout().px24(), Ui::DesignSystem::compactLayout().px24())
294+
QMarginsF(DesignSystem::layout().px24(), DesignSystem::compactLayout().topContentMargin(),
295+
DesignSystem::layout().px24(), DesignSystem::compactLayout().px24())
262296
.toMargins());
263297

298+
d->checkingInfo->setBackgroundColor(DesignSystem::color().background());
264299
d->screenplayInfo->setBackgroundColor(DesignSystem::color().background());
265-
for (auto textField : { d->screenplayName, d->screenplayTagline, d->screenplayLogline }) {
266-
textField->setBackgroundColor(Ui::DesignSystem::color().onBackground());
267-
textField->setTextColor(Ui::DesignSystem::color().onBackground());
300+
for (auto textField :
301+
{ d->checkingComment, d->screenplayName, d->screenplayTagline, d->screenplayLogline }) {
302+
textField->setBackgroundColor(DesignSystem::color().onBackground());
303+
textField->setTextColor(DesignSystem::color().onBackground());
268304
}
269305
for (auto checkBox : { d->titlePageVisiblity, d->synopsisVisiblity, d->treatmentVisiblity,
270306
d->screenplayTextVisiblity, d->screenplayStatisticsVisiblity }) {
271-
checkBox->setBackgroundColor(Ui::DesignSystem::color().background());
272-
checkBox->setTextColor(Ui::DesignSystem::color().onBackground());
307+
checkBox->setBackgroundColor(DesignSystem::color().background());
308+
checkBox->setTextColor(DesignSystem::color().onBackground());
273309
}
274-
d->screenplayInfoLayout->setVerticalSpacing(Ui::DesignSystem::compactLayout().px16());
275-
d->screenplayInfoLayout->setRowMinimumHeight(
276-
0, static_cast<int>(Ui::DesignSystem::layout().px24()));
310+
d->checkingComment->setCustomMargins(
311+
{ DesignSystem::layout().px24(), DesignSystem::compactLayout().px24(),
312+
DesignSystem::layout().px24(), DesignSystem::compactLayout().px24() });
313+
d->sendForChecking->setBackgroundColor(DesignSystem::color().accent());
314+
d->sendForChecking->setTextColor(DesignSystem::color().accent());
315+
d->sendForChecking->setContentsMargins(0, DesignSystem::compactLayout().px16(),
316+
DesignSystem::compactLayout().px16(),
317+
DesignSystem::layout().px16());
318+
d->checkingInfo->layout()->setSpacing(DesignSystem::layout().px16());
319+
d->screenplayInfoLayout->setVerticalSpacing(DesignSystem::compactLayout().px16());
320+
d->screenplayInfoLayout->setRowMinimumHeight(0,
321+
static_cast<int>(DesignSystem::layout().px24()));
277322
d->screenplayInfoLayout->setRowMinimumHeight(
278323
d->screenplayInfoLayout->rowCount() - 1,
279-
static_cast<int>(Ui::DesignSystem::compactLayout().px24()));
324+
static_cast<int>(DesignSystem::compactLayout().px24()));
280325
}
281326

282327
} // namespace Ui

src/core/management_layer/plugins/screenplay_information/screenplay_information_view.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class ScreenplayInformationView : public Widget, public IDocumentView
1919
*/
2020
/** @{ */
2121
QWidget* asQWidget() override;
22+
virtual void setProjectInfo(bool _isRemote, bool _isOwner, bool _allowGrantAccessToProject,
23+
bool _canBeSentForChecking) override;
2224
void setEditingMode(ManagementLayer::DocumentEditingMode _mode) override;
2325
/** @} */
2426

@@ -46,6 +48,11 @@ class ScreenplayInformationView : public Widget, public IDocumentView
4648
void setScreenplayStatisticsVisible(bool _visible);
4749
Q_SIGNAL void screenplayStatisticsVisibleChanged(bool _visible);
4850

51+
/**
52+
* @brief Запрос отправки документа на проверку
53+
*/
54+
Q_SIGNAL void sendDocumentToReviewRequested(const QString& _comment);
55+
4956
protected:
5057
/**
5158
* @brief Обновить переводы

src/interfaces/management_layer/i_document_manager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,12 @@ class IDocumentManager
147147
// * @brief Запрос на создание документа заданного типа
148148
// */
149149
// void createDocumentRequested(Domain::DocumentObjectType _type);
150+
151+
152+
// /**
153+
// * @brief Запрос отправки документа на проверку
154+
// */
155+
// void sendDocumentToReviewRequested(const QUuid& _documentUuid, const QString& _comment);
150156
};
151157

152158
} // namespace ManagementLayer

0 commit comments

Comments
 (0)