Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ environment:
QTDIR: C:\Qt\6.10.2\msvc2022_64
PYTHONHOME: C:\Python312-x64
DEFAULT_PROFILE: MSVC2022-x64
FILE_SUFFIX: Windows-10+_msvc_x86_64
PUSH_RELEASE: false
ENABLE_ZSTD: false
- QT_VERSION: 5.15.2
Expand All @@ -31,6 +32,7 @@ environment:
MINGW: C:\Qt\Tools\mingw810_32
MINGW_COMPONENT: tools_mingw
MINGW_VARIANT: qt.tools.win32_mingw810
FILE_SUFFIX: Windows-7-8_x86
PUSH_RELEASE: true
ENABLE_ZSTD: true
CC: i686-w64-mingw32-gcc.exe
Expand All @@ -43,6 +45,7 @@ environment:
MINGW: C:\Qt\Tools\mingw1310_64
MINGW_COMPONENT: tools_mingw1310
MINGW_VARIANT: qt.tools.win64_mingw1310
FILE_SUFFIX: Windows-10+_x86_64
PUSH_RELEASE: true
ENABLE_ZSTD: true
CC: x86_64-w64-mingw32-gcc.exe
Expand Down Expand Up @@ -96,15 +99,15 @@ build_script:
after_build:
- cd release
- cd installer*
- move tiled-*.msi %APPVEYOR_BUILD_FOLDER%
- move tiled-*.msi %APPVEYOR_BUILD_FOLDER%\Tiled-%TILED_VERSION%_%FILE_SUFFIX%.msi
- cd ..
- cd archive*
- move tiled-*.7z %APPVEYOR_BUILD_FOLDER%
- cd ..\..

artifacts:
- name: Installer
path: 'tiled-*.msi'
path: 'Tiled-*.msi'
- name: Archive
path: 'tiled-*.7z'

Expand Down
83 changes: 83 additions & 0 deletions src/tiled/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@
#include <QDesktopServices>
#include <QFileDialog>
#include <QLabel>
#include <QLineEdit>
#include <QMessageBox>
#include <QMimeData>
#include <QRegularExpression>
#include <QShortcut>
#include <QSlider>
#include <QStandardPaths>
#include <QStatusBar>
#include <QTextStream>
Expand Down Expand Up @@ -754,6 +756,47 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
myStatusBar->addPermanentWidget(mNewsButton);
myStatusBar->addPermanentWidget(new NewVersionButton(NewVersionButton::AutoVisible, myStatusBar));

// Zoom controls in the status bar (slider + percentage, with +/- buttons)
mZoomOutButton = new QToolButton(myStatusBar);
mZoomOutButton->setText(QStringLiteral("-"));
mZoomOutButton->setAutoRaise(true);

mZoomInButton = new QToolButton(myStatusBar);
mZoomInButton->setText(QStringLiteral("+"));
mZoomInButton->setAutoRaise(true);

mZoomSlider = new QSlider(Qt::Horizontal);
mZoomSlider->setRange(10, 3200); // 10% to 3200% zoom
mZoomSlider->setFixedWidth(Utils::dpiScaled(100));
mZoomSlider->setToolTip(tr("Zoom Level"));

mZoomEdit = new QLineEdit;
mZoomEdit->setFixedWidth(Utils::dpiScaled(50));
mZoomEdit->setAlignment(Qt::AlignCenter);
mZoomEdit->setToolTip(tr("Current Zoom Percentage"));

connect(mZoomSlider, &QSlider::valueChanged, this, [this](int value) {
if (mZoomable)
mZoomable->setScale(value / 100.0);
});

connect(mZoomEdit, &QLineEdit::returnPressed, this, [this]() {
QString text = mZoomEdit->text().remove(QLatin1Char('%')).trimmed();
bool ok;
int value = text.toInt(&ok);
if (ok) {
if (mZoomable)
mZoomable->setScale(value / 100.0);
else if (mZoomSlider)
mZoomSlider->setValue(value);
}
});

statusBar()->addPermanentWidget(mZoomOutButton);
statusBar()->addPermanentWidget(mZoomSlider);
statusBar()->addPermanentWidget(mZoomInButton);
statusBar()->addPermanentWidget(mZoomEdit);

QIcon terminalIcon(QLatin1String("://images/24/terminal.png"));
terminalIcon.addFile(QLatin1String("://images/16/terminal.png"));
terminalIcon.addFile(QLatin1String("://images/32/terminal.png"));
Expand Down Expand Up @@ -788,6 +831,33 @@ MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags)
myStatusBar->addWidget(consoleToggleButton);
myStatusBar->addWidget(issuesCounter);

// Connect zoom controls to existing zoom actions / Zoomable
connect(mZoomOutButton, &QToolButton::clicked,
this, &MainWindow::zoomOut);
connect(mZoomInButton, &QToolButton::clicked,
this, &MainWindow::zoomIn);

connect(mZoomSlider, &QSlider::valueChanged, this, [this](int value) {
if (!mZoomable)
return;
const qreal scale = value / 100.0;
mZoomable->setScale(scale);
});

connect(mZoomEdit, &QLineEdit::returnPressed, this, [this]() {
if (!mZoomable)
return;

QString text = mZoomEdit->text().remove(QLatin1Char('%')).trimmed();
bool ok = false;
int percent = text.toInt(&ok);
if (!ok)
return;

percent = qBound(mZoomSlider->minimum(), percent, mZoomSlider->maximum());
mZoomable->setScale(percent / 100.0);
});

// Add the 'Views and Toolbars' submenu. This needs to happen after all
// the dock widgets and toolbars have been added to the main window.
mViewsAndToolbarsMenu = new QMenu(this);
Expand Down Expand Up @@ -2268,6 +2338,19 @@ void MainWindow::updateZoomActions()
mUi->actionZoomOut->setEnabled(mZoomable && mZoomable->canZoomOut());
mUi->actionZoomNormal->setEnabled(scale != 1);
mUi->actionFitInView->setEnabled(mDocument && mDocument->type() == Document::MapDocumentType);

const int percent = qRound(scale * 100);

if (mZoomSlider) {
mZoomSlider->blockSignals(true);
mZoomSlider->setValue(qBound(mZoomSlider->minimum(),
percent,
mZoomSlider->maximum()));
mZoomSlider->blockSignals(false);
}

if (mZoomEdit)
mZoomEdit->setText(QStringLiteral("%1 %").arg(percent));
}

void MainWindow::openDocumentation()
Expand Down
8 changes: 8 additions & 0 deletions src/tiled/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <QMainWindow>
#include <QPointer>
#include <QSessionManager>
#include <QSlider>
#include <QLineEdit>

class QComboBox;
class QLabel;
Expand Down Expand Up @@ -267,6 +269,12 @@ class TILED_EDITOR_EXPORT MainWindow : public QMainWindow
QList<QWidget*> mEditorStatusBarWidgets;
QToolButton *mNewsButton;

// Zoom controls in the status bar
QToolButton *mZoomOutButton = nullptr;
QToolButton *mZoomInButton = nullptr;
QSlider *mZoomSlider = nullptr;
QLineEdit *mZoomEdit = nullptr;

QPointer<PreferencesDialog> mPreferencesDialog;

QMap<QMainWindow*, QByteArray> mMainWindowStates;
Expand Down
7 changes: 1 addition & 6 deletions src/tiled/mapeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
#include "worldmanager.h"
#include "worldmovemaptool.h"

#include <QComboBox>
#include <QDialogButtonBox>
#include <QHBoxLayout>
#include <QIdentityProxyModel>
Expand Down Expand Up @@ -152,7 +151,6 @@ MapEditor::MapEditor(QObject *parent)
, mComboBoxProxyModel(new ComboBoxProxyModel(this))
, mReversingProxyModel(new ReversingProxyModel(this))
, mZoomable(nullptr)
, mZoomComboBox(new QComboBox)
, mStatusInfoLabel(new QLabel)
, mMainToolBar(new MainToolBar(mMainWindow))
, mToolManager(new ToolManager(this))
Expand Down Expand Up @@ -395,7 +393,6 @@ void MapEditor::setCurrentDocument(Document *document)
mLayerDock->setMapDocument(mapDocument);

if (mZoomable) {
mZoomable->setComboBox(nullptr);
mZoomable = nullptr;
}

Expand All @@ -416,7 +413,6 @@ void MapEditor::setCurrentDocument(Document *document)

if (mapView) {
mZoomable = mapView->zoomable();
mZoomable->setComboBox(mZoomComboBox.get());
}

connect(mCurrentMapDocument, &MapDocument::currentObjectSet,
Expand Down Expand Up @@ -498,8 +494,7 @@ QList<QWidget *> MapEditor::statusBarWidgets() const
QList<QWidget *> MapEditor::permanentStatusBarWidgets() const
{
return {
mLayerComboBox.get(),
mZoomComboBox.get()
mLayerComboBox.get()
};
}

Expand Down
1 change: 0 additions & 1 deletion src/tiled/mapeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ class MapEditor final : public Editor
ReversingProxyModel *mReversingProxyModel;

Zoomable *mZoomable;
std::unique_ptr<QComboBox> mZoomComboBox;
std::unique_ptr<QLabel> mStatusInfoLabel;

StampBrush *mStampBrush;
Expand Down
7 changes: 1 addition & 6 deletions src/tiled/tileseteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@

#include <QAction>
#include <QCheckBox>
#include <QComboBox>
#include <QCoreApplication>
#include <QDropEvent>
#include <QFileDialog>
Expand Down Expand Up @@ -144,7 +143,6 @@ TilesetEditor::TilesetEditor(QObject *parent)
, mTileCollisionDock(new TileCollisionDock(mMainWindow))
, mTemplatesDock(new TemplatesDock(mMainWindow))
, mWangDock(new WangDock(mMainWindow))
, mZoomComboBox(new QComboBox)
, mStatusInfoLabel(new QLabel)
{
mMainWindow->setDockOptions(mMainWindow->dockOptions() | QMainWindow::GroupedDragging);
Expand Down Expand Up @@ -357,7 +355,6 @@ void TilesetEditor::setCurrentDocument(Document *document)

mWidgetStack->setCurrentWidget(tilesetView);
tilesetView->setEditWangSet(mWangDock->isVisible());
tilesetView->zoomable()->setComboBox(mZoomComboBox);
}

mPropertiesDock->setDocument(document);
Expand Down Expand Up @@ -419,9 +416,7 @@ QList<QWidget *> TilesetEditor::statusBarWidgets() const

QList<QWidget *> TilesetEditor::permanentStatusBarWidgets() const
{
return {
mZoomComboBox
};
return {};
}

Editor::StandardActions TilesetEditor::enabledStandardActions() const
Expand Down
1 change: 0 additions & 1 deletion src/tiled/tileseteditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ class TilesetEditor final : public Editor
TileCollisionDock *mTileCollisionDock;
TemplatesDock *mTemplatesDock;
WangDock *mWangDock;
QComboBox *mZoomComboBox;
QLabel *mStatusInfoLabel;
TileAnimationEditor *mTileAnimationEditor = nullptr;

Expand Down
Loading