fixed effect context menu linking

This commit is contained in:
itsmattkc
2019-03-17 08:48:07 +11:00
parent 918ab6132d
commit 789b751935
3 changed files with 91 additions and 65 deletions
+12 -2
View File
@@ -415,9 +415,14 @@ void Effect::delete_self() {
}
void Effect::move_up() {
int index_of_effect = parent_clip->IndexOfEffect(this);
if (index_of_effect == 0) {
return;
}
MoveEffectCommand* command = new MoveEffectCommand();
command->clip = parent_clip;
command->from = parent_clip->IndexOfEffect(this);
command->from = index_of_effect;
command->to = command->from - 1;
olive::UndoStack.push(command);
panel_effect_controls->Reload();
@@ -425,9 +430,14 @@ void Effect::move_up() {
}
void Effect::move_down() {
int index_of_effect = parent_clip->IndexOfEffect(this);
if (index_of_effect == parent_clip->effects.size()-1) {
return;
}
MoveEffectCommand* command = new MoveEffectCommand();
command->clip = parent_clip;
command->from = parent_clip->IndexOfEffect(this);
command->from = index_of_effect;
command->to = command->from + 1;
olive::UndoStack.push(command);
panel_effect_controls->Reload();
+58 -58
View File
@@ -34,79 +34,79 @@ QFile debug_file;
QTextStream debug_stream;
void open_debug_file() {
QDir debug_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
debug_dir.mkpath(".");
if (debug_dir.exists()) {
debug_file.setFileName(debug_dir.path() + "/debug_log");
if (debug_file.open(QFile::WriteOnly)) {
debug_stream.setDevice(&debug_file);
} else {
qWarning() << "Couldn't open debug log file, debug log will not be saved";
}
QDir debug_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
debug_dir.mkpath(".");
if (debug_dir.exists()) {
debug_file.setFileName(debug_dir.path() + "/debug_log");
if (debug_file.open(QFile::WriteOnly)) {
debug_stream.setDevice(&debug_file);
} else {
qWarning() << "Couldn't open debug log file, debug log will not be saved";
}
}
}
void close_debug_file()
{
if (debug_file.isOpen()) {
debug_file.close();
}
if (debug_file.isOpen()) {
debug_file.close();
}
}
void debug_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
debug_mutex.lock();
const QByteArray localMsg = msg.toLocal8Bit();
const QDateTime now = QDateTime::currentDateTime();
const QByteArray timeRepr(now.toString(Qt::ISODate).toLocal8Bit());
QString msgTag;
QString fontColor;
switch (type) {
case QtDebugMsg:
msgTag = "DEBUG";
fontColor = "grey";
break;
case QtInfoMsg:
msgTag = "INFO";
fontColor = "blue";
break;
case QtWarningMsg:
msgTag = "WARNING";
fontColor = "yellow";
break;
case QtCriticalMsg:
msgTag = "ERROR";
fontColor = "red";
break;
case QtFatalMsg:
msgTag = "FATAL";
fontColor = "red";
break;
default:
fprintf(stderr, "Unknown debug msg type");
fflush(stderr);
break;
}//switch
debug_mutex.lock();
const QByteArray localMsg = msg.toLocal8Bit();
const QDateTime now = QDateTime::currentDateTime();
const QByteArray timeRepr(now.toString(Qt::ISODate).toLocal8Bit());
QString msgTag;
QString fontColor;
switch (type) {
case QtDebugMsg:
msgTag = "DEBUG";
fontColor = "grey";
break;
case QtInfoMsg:
msgTag = "INFO";
fontColor = "blue";
break;
case QtWarningMsg:
msgTag = "WARNING";
fontColor = "yellow";
break;
case QtCriticalMsg:
msgTag = "ERROR";
fontColor = "red";
break;
case QtFatalMsg:
msgTag = "FATAL";
fontColor = "red";
break;
default:
fprintf(stderr, "Unknown debug msg type");
fflush(stderr);
break;
}//switch
/*fprintf(stderr, "%s [%s] %s (%s:%u, %s)\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data(),
/*fprintf(stderr, "%s [%s] %s (%s:%u, %s)\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data(),
context.file, context.line, context.function);*/
fprintf(stderr, "%s [%s] %s\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data());
fprintf(stderr, "%s [%s] %s\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data());
if (debug_file.isOpen()) {
debug_stream << QString("[%1] %2 (%3:%4, %5)\n")
.arg(msgTag, localMsg, context.file, QString::number(context.line), context.function);
}
debug_info.prepend(QString("<font color='%1'><b>[%2]</b> %3 (%4:%5, %6)</font><br>")
.arg(fontColor, msgTag, localMsg, context.file, QString::number(context.line), context.function));
fflush(stderr);
if (olive::DebugDialog != nullptr && olive::DebugDialog->isVisible()) {
QMetaObject::invokeMethod(olive::DebugDialog, "update_log", Qt::QueuedConnection);
}
debug_mutex.unlock();
if (debug_file.isOpen()) {
debug_stream << QString("[%1] %2 (%3:%4, %5)\n")
.arg(msgTag, localMsg, context.file, QString::number(context.line), context.function);
}
debug_info.prepend(QString("<font color='%1'><b>[%2]</b> %3 (%4:%5, %6)</font><br>")
.arg(fontColor, msgTag, localMsg, context.file, QString::number(context.line), context.function));
fflush(stderr);
if (olive::DebugDialog != nullptr && olive::DebugDialog->isVisible()) {
QMetaObject::invokeMethod(olive::DebugDialog, "update_log", Qt::QueuedConnection);
}
debug_mutex.unlock();
}
const QString &get_debug_str()
{
return debug_info;
return debug_info;
}
+21 -5
View File
@@ -289,23 +289,39 @@ void EffectUI::show_context_menu(const QPoint& pos) {
menu.addSeparator();
QAction* move_up_action = nullptr;
QAction* move_down_action = nullptr;
if (index > 0) {
menu.addAction(tr("Move &Up"), this, SLOT(move_up()));
move_up_action = menu.addAction(tr("Move &Up"), GetEffect(), SLOT(move_up()));
}
if (index < c->effects.size() - 1) {
menu.addAction(tr("Move &Down"), this, SLOT(move_down()));
move_down_action = menu.addAction(tr("Move &Down"), GetEffect(), SLOT(move_down()));
}
menu.addSeparator();
menu.addAction(tr("D&elete"), this, SLOT(delete_self()));
QAction* delete_action = menu.addAction(tr("D&elete"), GetEffect(), SLOT(delete_self()));
// Loop through additional effects and link these too
for (int i=0;i<additional_effects_.size();i++) {
if (move_up_action != nullptr) {
connect(move_up_action, SIGNAL(triggered(bool)), additional_effects_.at(i), SLOT(move_up()));
}
if (move_down_action != nullptr) {
connect(move_down_action, SIGNAL(triggered(bool)), additional_effects_.at(i), SLOT(move_down()));
}
connect(delete_action, SIGNAL(triggered(bool)), additional_effects_.at(i), SLOT(delete_self()));
}
menu.addSeparator();
menu.addAction(tr("Load Settings From File"), this, SLOT(load_from_file()));
menu.addAction(tr("Load Settings From File"), GetEffect(), SLOT(load_from_file()));
menu.addAction(tr("Save Settings to File"), this, SLOT(save_to_file()));
menu.addAction(tr("Save Settings to File"), GetEffect(), SLOT(save_to_file()));
menu.exec(title_bar->mapToGlobal(pos));
}