Skip to content

Commit

Permalink
Remove input dialog to input layer name
Browse files Browse the repository at this point in the history
Because this is not handled by double clicking on the layer label
  • Loading branch information
MrStevns committed Sep 26, 2024
1 parent 83dedd5 commit a407f92
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 56 deletions.
37 changes: 4 additions & 33 deletions app/src/actioncommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,54 +842,25 @@ void ActionCommands::moveFrameBackward()

Status ActionCommands::addNewBitmapLayer()
{
bool ok;
QString text = QInputDialog::getText(nullptr, tr("Layer Properties"),
tr("Layer name:"), QLineEdit::Normal,
mEditor->layers()->nameSuggestLayer(tr("Bitmap Layer")), &ok);
if (ok && !text.isEmpty())
{
mEditor->layers()->createBitmapLayer(text);
}
mEditor->layers()->createBitmapLayer(mEditor->layers()->nameSuggestLayer(tr("Bitmap Layer")));
return Status::OK;
}

Status ActionCommands::addNewVectorLayer()
{
bool ok;
QString text = QInputDialog::getText(nullptr, tr("Layer Properties"),
tr("Layer name:"), QLineEdit::Normal,
mEditor->layers()->nameSuggestLayer(tr("Vector Layer")), &ok);
if (ok && !text.isEmpty())
{
mEditor->layers()->createVectorLayer(text);
}
mEditor->layers()->createVectorLayer(mEditor->layers()->nameSuggestLayer(tr("Vector Layer")));
return Status::OK;
}

Status ActionCommands::addNewCameraLayer()
{
bool ok;
QString text = QInputDialog::getText(nullptr, tr("Layer Properties", "A popup when creating a new layer"),
tr("Layer name:"), QLineEdit::Normal,
mEditor->layers()->nameSuggestLayer(tr("Camera Layer")), &ok);
if (ok && !text.isEmpty())
{
mEditor->layers()->createCameraLayer(text);
}
mEditor->layers()->createCameraLayer(mEditor->layers()->nameSuggestLayer(tr("Camera Layer")));
return Status::OK;
}

Status ActionCommands::addNewSoundLayer()
{
bool ok = false;
QString strLayerName = QInputDialog::getText(nullptr, tr("Layer Properties"),
tr("Layer name:"), QLineEdit::Normal,
mEditor->layers()->nameSuggestLayer(tr("Sound Layer")), &ok);
if (ok && !strLayerName.isEmpty())
{
Layer* layer = mEditor->layers()->createSoundLayer(strLayerName);
mEditor->layers()->setCurrentLayer(layer);
}
mEditor->layers()->createSoundLayer(mEditor->layers()->nameSuggestLayer(tr("Sound Layer")));
return Status::OK;
}

Expand Down
20 changes: 0 additions & 20 deletions app/src/timelinelayercelleditorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ void TimeLineLayerCellEditorWidget::editLayerProperties() const
{
if (mLayer->type() == Layer::CAMERA) {
editLayerProperties(static_cast<LayerCamera*>(mLayer));
} else {
editLayerName(mLayer);
}
}

Expand Down Expand Up @@ -222,24 +220,6 @@ void TimeLineLayerCellEditorWidget::editLayerProperties(LayerCamera* cameraLayer
mEditor->view()->forceUpdateViewTransform();
}

void TimeLineLayerCellEditorWidget::editLayerName(Layer* layer) const
{
QRegularExpression regex("([\\x{FFEF}-\\x{FFFF}])+");

bool ok;
QString name = QInputDialog::getText(nullptr, QObject::tr("Layer Properties"),
QObject::tr("Layer name:"), QLineEdit::Normal,
layer->name(), &ok);
name.replace(regex, "");
if (!ok || name.isEmpty())
{
return;
}

mLayerNameEditWidget->setText(name);
mEditor->layers()->renameLayer(layer, name);
}

void TimeLineLayerCellEditorWidget::onFinishedEditingName()
{
QRegularExpression regex("([\\x{FFEF}-\\x{FFFF}])+");
Expand Down
3 changes: 0 additions & 3 deletions app/src/timelinelayercelleditorwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class TimeLineLayerCellEditorWidget : public QWidget
bool didDetach() const { return mDidDetach; }
const Layer* layer() const { return mLayer; }

void onLayerVisibilityChanged();

signals:
void drag(const DragEvent& dragEvent, TimeLineLayerCellEditorWidget* cell, int x, int y);
void layerVisibilityChanged();
Expand All @@ -77,7 +75,6 @@ class TimeLineLayerCellEditorWidget : public QWidget
void paintBackground(QPainter& painter, const QPalette& palette, bool isSelected) const;

void editLayerProperties(LayerCamera* cameraLayer) const;
void editLayerName(Layer* layer) const;

void onFinishedEditingName();

Expand Down

0 comments on commit a407f92

Please sign in to comment.