forked from MaurycyLiebner/enve
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathdialogsinterfaceimpl.cpp
More file actions
155 lines (133 loc) · 5.44 KB
/
Copy pathdialogsinterfaceimpl.cpp
File metadata and controls
155 lines (133 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
#
# Friction - https://friction.graphics
#
# Copyright (c) Ole-André Rodlie and contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# See 'README.md' for more information.
#
*/
// Fork of enve - Copyright (C) 2016-2020 Maurycy Liebner
#include "dialogsinterfaceimpl.h"
#include <QDialog>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <QLabel>
#include <QStatusBar>
#include "widgets/buttonslist.h"
#include "GUI/global.h"
#include "GUI/mainwindow.h"
#include "GUI/Expressions/expressiondialog.h"
#include "dialogs/durationrectsettingsdialog.h"
//#include "GUI/Dialogs/animationtopaintdialog.h"
#include "dialogs/applyexpressiondialog.h"
#include "dialogs/scenesettingsdialog.h"
DialogsInterfaceImpl DialogsInterfaceImpl::sInstance;
class ShaderChoiceDialog : public QDialog {
public:
ShaderChoiceDialog(const QString& name, const ShaderOptions& options,
QWidget* const parent) : QDialog(parent) {
const auto layout = new QVBoxLayout(this);
const QString labelTxt = "Missing Shader Effect '" + name + "'.\n"
"Select compatible replacement.";
layout->addWidget(new QLabel(labelTxt), 0);
eSizesUI::widget.addSpacing(layout);
const auto homePath = QDir::homePath();
const auto textTriggerGetter = [this, &options, &homePath](const int id) {
const auto& shader = options.at(id);
QString ttPath = shader->fGrePath;
if(ttPath.left(homePath.count()) == homePath) {
ttPath = "~" + ttPath.mid(homePath.count());
}
return ButtonsList::TextTrigger{
ttPath, [this, ttPath, id, &options]() {
mSelected = options.at(id);
accept();
}};
};
const int count = options.count();
const auto recentWidget = new ButtonsList(textTriggerGetter, count, this);
layout->addWidget(recentWidget);
setLayout(layout);
}
stdsptr<ShaderEffectCreator> getSelected() const { return mSelected; }
private:
stdsptr<ShaderEffectCreator> mSelected;
};
stdsptr<ShaderEffectCreator> DialogsInterfaceImpl::execShaderChooser(
const QString& name, const ShaderOptions& options) const {
const auto parent = MainWindow::sGetInstance();
ShaderChoiceDialog dialog(name, options, parent);
const bool accepted = dialog.exec() == QDialog::Accepted;
if(accepted) return dialog.getSelected();
return nullptr;
}
void DialogsInterfaceImpl::showExpressionDialog(QrealAnimator* const target) const {
const auto parent = MainWindow::sGetInstance();
const auto dialog = new ExpressionDialog(target, parent);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
void DialogsInterfaceImpl::showExpressionDialog(QStringAnimator* const target) const {
const auto parent = MainWindow::sGetInstance();
const auto dialog = new ExpressionDialog(target, parent);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
void DialogsInterfaceImpl::showApplyExpressionDialog(QrealAnimator* const target) const {
const auto parent = MainWindow::sGetInstance();
const auto dialog = new ApplyExpressionDialog(target, parent);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
void DialogsInterfaceImpl::showDurationSettingsDialog(
DurationRectangle* const target) const {
const auto parent = MainWindow::sGetInstance();
const auto dialog = new DurationRectSettingsDialog(target, parent);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
/*bool DialogsInterfaceImpl::execAnimationToPaint(
const AnimationBox* const src,
int& firstAbsFrame, int& lastAbsFrame,
int& increment) const {
const auto parent = MainWindow::sGetInstance();
return AnimationToPaintDialog::sExec(src, firstAbsFrame, lastAbsFrame,
increment, parent);
}*/
void DialogsInterfaceImpl::showSceneSettingsDialog(Canvas* const scene) const {
const auto parent = MainWindow::sGetInstance();
const auto dialog = new SceneSettingsDialog(scene, parent);
dialog->setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(dialog, &QDialog::accepted, scene, [scene, dialog]() {
dialog->applySettingsToCanvas(scene);
dialog->close();
});
dialog->show();
}
void DialogsInterfaceImpl::displayMessageToUser(
const QString& message, const int ms) const {
const auto parent = MainWindow::sGetInstance();
const auto widget = new QLabel(message, parent, Qt::SplashScreen);
widget->setObjectName("messageLabel");
widget->show();
QTimer::singleShot(ms, widget, &QWidget::deleteLater);
}
void DialogsInterfaceImpl::showStatusMessage(
const QString& message, const int ms) const {
const auto win = MainWindow::sGetInstance();
win->statusBar()->showMessage(message, ms);
}