Skip to content

Commit

Permalink
Merge branch 'master' into undo-redo-manager-v2
Browse files Browse the repository at this point in the history
  • Loading branch information
MrStevns committed Aug 24, 2024
2 parents a10d2da + 09ef787 commit bab3f1e
Show file tree
Hide file tree
Showing 66 changed files with 2,265 additions and 1,639 deletions.
4 changes: 3 additions & 1 deletion app/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ RESOURCES += data/app.qrc

MUI_TRANSLATIONS += \
translations/mui_cs.po \
translations/mui_de.po
translations/mui_de.po \
translations/mui_it.po

RC_LANGS.cs = --lang LANG_CZECH --sublang SUBLANG_NEUTRAL
RC_LANGS.de = --lang LANG_GERMAN --sublang SUBLANG_NEUTRAL
RC_LANGS.it = --lang LANG_ITALIAN --sublang SUBLANG_NEUTRAL

EXTRA_TRANSLATIONS += \
$$PWD/../translations/pencil_ar.ts \
Expand Down
26 changes: 0 additions & 26 deletions app/src/basedockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,8 @@ BaseDockWidget::BaseDockWidget(QWidget* pParent)
"border-width: 1px; }");
}
#endif

}

BaseDockWidget::~BaseDockWidget()
{
}

void BaseDockWidget::resizeEvent(QResizeEvent *event)
{
QDockWidget::resizeEvent(event);

// Not sure where the -2 comes from, but the event width is always 2 more than what is passed to FlowLayout::setGeometry
int minHeight = getMinHeightForWidth(event->size().width() - 2);

if (minHeight < 0) return;

#ifdef __APPLE__
// For some reason the behavior of minimumSize and the margin changes on mac when floating, so we need to do this
#else
int top, bottom;
layout()->getContentsMargins(nullptr, &top, nullptr, &bottom);
minHeight += top + bottom;
#endif
setMinimumSize(QSize(layout()->minimumSize().width(), minHeight));
}

int BaseDockWidget::getMinHeightForWidth(int width)
{
Q_UNUSED(width)
return -1;
}
5 changes: 0 additions & 5 deletions app/src/basedockwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,13 @@ class BaseDockWidget : public QDockWidget
explicit BaseDockWidget(QWidget* pParent);
virtual ~BaseDockWidget();

void resizeEvent(QResizeEvent *event) override;

public:
virtual void initUI() = 0;
virtual void updateUI() = 0;

Editor* editor() const { return mEditor; }
void setEditor( Editor* e ) { mEditor = e; }

protected:
virtual int getMinHeightForWidth(int width);

private:
Editor* mEditor = nullptr;
};
Expand Down
2 changes: 1 addition & 1 deletion app/src/colorbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void ColorBox::initUI()
mColorWheel = new ColorWheel(this);

QVBoxLayout* layout = new QVBoxLayout;
layout->setContentsMargins(5, 5, 5, 5);
layout->setContentsMargins(3, 3, 3, 3);
layout->addWidget(mColorWheel);
layout->setStretch(0, 1);
layout->setStretch(1, 0);
Expand Down
6 changes: 6 additions & 0 deletions app/src/mainwindow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ GNU General Public License for more details.
#include "pencilsettings.h"
#include "object.h"
#include "editor.h"
#include "polylinetool.h"

#include "filemanager.h"
#include "colormanager.h"
Expand Down Expand Up @@ -264,6 +265,7 @@ void MainWindow2::createMenus()

//--- Edit Menu ---
replaceUndoRedoActions();
connect(ui->actionRemoveLastPolylineSegment, &QAction::triggered, static_cast<PolylineTool*>(mEditor->tools()->getTool(POLYLINE)), &PolylineTool::removeLastPolylineSegment);
connect(ui->actionCut, &QAction::triggered, mEditor, &Editor::copyAndCut);
connect(ui->actionCopy, &QAction::triggered, mEditor, &Editor::copy);
connect(ui->actionPaste_Previous, &QAction::triggered, mEditor, &Editor::pasteFromPreviousFrame);
Expand Down Expand Up @@ -1205,6 +1207,7 @@ void MainWindow2::setupKeyboardShortcuts()
// edit menu
ui->actionUndo->setShortcut(cmdKeySeq(CMD_UNDO));
ui->actionRedo->setShortcut(cmdKeySeq(CMD_REDO));
ui->actionRemoveLastPolylineSegment->setShortcut(cmdKeySeq(CMD_REMOVE_LAST_POLYLINE_SEGMENT));
ui->actionCut->setShortcut(cmdKeySeq(CMD_CUT));
ui->actionCopy->setShortcut(cmdKeySeq(CMD_COPY));
ui->actionPaste_Previous->setShortcut(cmdKeySeq(CMD_PASTE_FROM_PREVIOUS));
Expand Down Expand Up @@ -1320,6 +1323,9 @@ void MainWindow2::setupKeyboardShortcuts()

ui->actionHelp->setShortcut(cmdKeySeq(CMD_HELP));
ui->actionExit->setShortcut(cmdKeySeq(CMD_EXIT));

// Actions not in a menu won't work unless added to a widget
addAction(ui->actionRemoveLastPolylineSegment);
}

void MainWindow2::clearKeyboardShortcuts()
Expand Down
1 change: 1 addition & 0 deletions app/src/shortcutspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ static QString getHumanReadableShortcutName(const QString& cmdName)
{CMD_CHANGE_LINE_COLOR_LAYER, ShortcutsPage::tr("Change Line Color (All keyframes on layer)", "Shortcut")},
{CMD_CHANGE_LAYER_OPACITY, ShortcutsPage::tr("Change Layer / Keyframe Opacity", "Shortcut")},
{CMD_UNDO, ShortcutsPage::tr("Undo", "Shortcut")},
{CMD_REMOVE_LAST_POLYLINE_SEGMENT, ShortcutsPage::tr("Remove Last Polyline Segment", "Shortcut")},
{CMD_ZOOM_100, ShortcutsPage::tr("Set Zoom to 100%", "Shortcut")},
{CMD_ZOOM_200, ShortcutsPage::tr("Set Zoom to 200%", "Shortcut")},
{CMD_ZOOM_25, ShortcutsPage::tr("Set Zoom to 25%", "Shortcut")},
Expand Down
2 changes: 2 additions & 0 deletions app/src/spinslider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ void SpinSlider::setLabel(QString newText)

void SpinSlider::setValue(qreal v)
{
Q_ASSERT(mMin <= v && v <= mMax);

int value2 = 0;
if (mGrowthType == LINEAR)
{
Expand Down
29 changes: 22 additions & 7 deletions app/src/toolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,18 @@ void ToolBoxWidget::initUI()

connect(editor()->layers(), &LayerManager::currentLayerChanged, this, &ToolBoxWidget::onLayerDidChange);


FlowLayout* flowlayout = new FlowLayout;
connect(this, &QDockWidget::dockLocationChanged, this, [=](Qt::DockWidgetArea area) {
if (area == Qt::DockWidgetArea::TopDockWidgetArea || area == Qt::BottomDockWidgetArea) {
const int minimumHeight = ui->scrollAreaWidgetContents_2->layout()->heightForWidth(width());
ui->scrollArea->setMinimumHeight(minimumHeight);
setMinimumHeight(minimumHeight);
} else {
ui->scrollArea->setMinimumHeight(0); // Default value
// Don't set own minimum height and let Qt come up with a sensible value
}
});

FlowLayout* flowlayout = new FlowLayout(3,3,3);

flowlayout->addWidget(ui->pencilButton);
flowlayout->addWidget(ui->eraserButton);
Expand All @@ -154,6 +164,7 @@ void ToolBoxWidget::initUI()

delete ui->scrollAreaWidgetContents_2->layout();
ui->scrollAreaWidgetContents_2->setLayout(flowlayout);
ui->scrollAreaWidgetContents_2->setContentsMargins(0,0,0,0);

QSettings settings(PENCIL2D, PENCIL2D);
restoreGeometry(settings.value("ToolBoxGeom").toByteArray());
Expand All @@ -163,6 +174,15 @@ void ToolBoxWidget::updateUI()
{
}

void ToolBoxWidget::resizeEvent(QResizeEvent* event)
{
QDockWidget::resizeEvent(event);

const int minimumHeight = ui->scrollArea->minimumHeight();
if (minimumHeight <= 0) { return; }
setMinimumHeight(minimumHeight);
}

void ToolBoxWidget::onToolSetActive(ToolType toolType)
{
deselectAllTools();
Expand Down Expand Up @@ -265,11 +285,6 @@ void ToolBoxWidget::smudgeOn()
toolOn(SMUDGE, ui->smudgeButton);
}

int ToolBoxWidget::getMinHeightForWidth(int width)
{
return ui->toolGroup->layout()->heightForWidth(width);
}

void ToolBoxWidget::deselectAllTools()
{
ui->pencilButton->setChecked(false);
Expand Down
2 changes: 1 addition & 1 deletion app/src/toolbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public slots:
void smudgeOn();

protected:
int getMinHeightForWidth(int width) override;
void resizeEvent(QResizeEvent* event) override;

private:
void deselectAllTools();
Expand Down
10 changes: 8 additions & 2 deletions app/src/tooloptionwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ void ToolOptionWidget::updateUI()

const Properties& p = currentTool->properties;

setPenWidth(p.width);
setPenFeather(p.feather);
if (currentTool->isPropertyEnabled(WIDTH))
{
setPenWidth(p.width);
}
if (currentTool->isPropertyEnabled(FEATHER))
{
setPenFeather(p.feather);
}
setUseFeather(p.useFeather);
setPressure(p.pressure);
setPenInvisibility(p.invisibility);
Expand Down
33 changes: 33 additions & 0 deletions app/translations/mui_it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Translators:
# Mattia Rizzolo <mattia@mapreri.org>, 2024
# albanobattistella <albanobattistella@gmail.com>, 2024
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-09-22 15:26+0200\n"
"PO-Revision-Date: 2024-05-19 14:29+0000\n"
"Last-Translator: albanobattistella <albanobattistella@gmail.com>, 2024\n"
"Language-Team: Italian (https://app.transifex.com/pencil2d/teams/76612/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: it\n"
"Plural-Forms: nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n"
"X-Accelerator-Marker: &\n"
"X-Generator: Translate Toolkit 3.9.0\n"
"X-Merge-On: location\n"

#: STRINGTABLE.0
msgid "Pencil2D"
msgstr "Pencil2D"

#: STRINGTABLE.1
msgid "Pencil2D Animation"
msgstr "Animazione Pencil2D"

#: STRINGTABLE.2
msgid "Pencil2D Animation (Old Format)"
msgstr "Animazione Pencil2D (vecchio formato)"
19 changes: 17 additions & 2 deletions app/ui/bucketoptionswidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<width>140</width>
<height>221</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
Expand Down Expand Up @@ -92,8 +98,17 @@
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>0</number>
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<property name="verticalSpacing">
<number>6</number>
Expand Down
26 changes: 16 additions & 10 deletions app/ui/cameraoptionswidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>254</width>
<width>140</width>
<height>208</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
Expand All @@ -30,16 +36,16 @@
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0">
<property name="leftMargin">
<number>0</number>
<number>3</number>
</property>
<property name="topMargin">
<number>0</number>
<number>3</number>
</property>
<property name="rightMargin">
<number>0</number>
<number>3</number>
</property>
<property name="bottomMargin">
<number>0</number>
<number>3</number>
</property>
<property name="horizontalSpacing">
<number>2</number>
Expand Down Expand Up @@ -122,19 +128,19 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>2</number>
<number>0</number>
</property>
<property name="leftMargin">
<number>4</number>
<number>0</number>
</property>
<property name="topMargin">
<number>4</number>
<number>0</number>
</property>
<property name="rightMargin">
<number>4</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>4</number>
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
Expand Down
Loading

0 comments on commit bab3f1e

Please sign in to comment.