Project tabs drag to reorder; tabs that don't fit gather in a menu (13.14)
This commit is contained in:
1 parent
0616f9b006
commit
3f2b99f045
15 files changed
+957
-138
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QTimer>
|
||||
#include <algorithm>
|
||||
|
||||
const QString ProjectWorkspace::layerType = QStringLiteral("com.compositor.layer-row");
|
||||
|
||||
@@ -96,6 +97,20 @@ void ProjectWorkspace::select(QUuid id)
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ProjectWorkspace::moveTab(QUuid id, int index)
|
||||
{
|
||||
const auto from = std::ranges::find_if(m_tabs, [id](const std::shared_ptr<ProjectTab> &tab) { return tab->id == id; });
|
||||
if (from == m_tabs.end())
|
||||
return;
|
||||
const auto target = std::clamp<std::ptrdiff_t>(index, 0, std::ptrdiff_t(m_tabs.size()) - 1);
|
||||
if (target == from - m_tabs.begin())
|
||||
return;
|
||||
const std::shared_ptr<ProjectTab> tab = *from;
|
||||
m_tabs.erase(from);
|
||||
m_tabs.insert(m_tabs.begin() + target, tab);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void ProjectWorkspace::newCanvas()
|
||||
{
|
||||
if (!canSwitch())
|
||||
|
||||
@@ -36,6 +36,8 @@ public:
|
||||
bool canSwitch() const;
|
||||
ProjectTab &addTab(bool reuseEmpty = true);
|
||||
void select(QUuid id);
|
||||
// A dragged tab lands at `index`, clamped; chrome, never undone.
|
||||
void moveTab(QUuid id, int index);
|
||||
void newCanvas();
|
||||
// Each `done` runs from the event loop, never inline.
|
||||
void open(std::optional<QString> path = std::nullopt, std::function<void(bool)> done = {});
|
||||
|
||||
Reference in new issue
Block a user