Commit 5962853f authored by Tomaz  Canabrava's avatar Tomaz Canabrava
Browse files

Start to store the split sizes globally

parent 9df116c3
......@@ -13,7 +13,6 @@
#include <QDragEnterEvent>
#include <QMimeData>
#include <QApplication>
#include <QDebug>
// C++
#include <memory>
......@@ -25,6 +24,9 @@
using Konsole::ViewSplitter;
using Konsole::TerminalDisplay;
bool ViewSplitter::m_drawTopLevelHandler;
Qt::Orientation ViewSplitter::m_topLevelHandlerDrawnOrientation;
//TODO: Connect the TerminalDisplay destroyed signal here.
namespace {
......@@ -384,3 +386,68 @@ void Konsole::ViewSplitter::showEvent(QShowEvent *)
// Fixes lost focus in background mode.
setFocusProxy(activeSplitter()->activeTerminalDisplay());
}
QPoint Konsole::ViewSplitter::mapToTopLevel(const QPoint p)
{
if (auto parentSplitter = qobject_cast<ViewSplitter*>(parentWidget())) {
auto next_pos = mapToParent(p);
parentSplitter->mapToTopLevel(next_pos);
}
return p;
}
Konsole::ViewSplitterHandle::ViewSplitterHandle(Qt::Orientation orientation, QSplitter* parent)
: QSplitterHandle(orientation, parent)
{
}
QSplitterHandle* ViewSplitter::createHandle()
{
return new ViewSplitterHandle(orientation(), this);
}
namespace {
QList<int> allSplitterSizes;
}
void Konsole::ViewSplitterHandle::mousePressEvent(QMouseEvent *ev)
{
auto parentSplitter = qobject_cast<ViewSplitter*>(parentWidget());
auto topLevelSplitter = parentSplitter->getToplevelSplitter();
QList<ViewSplitter*> splitters = topLevelSplitter->findChildren<ViewSplitter*>();
splitters.append(topLevelSplitter);
for (auto splitter : splitters) {
if (splitter->orientation() != orientation()) {
continue;
}
for (int size : splitter->sizes()) {
QPoint thisPoint = orientation() == Qt::Horizontal
? QPoint(size, 0)
: QPoint(0, size);
QPoint splitterPos = splitter->mapToTopLevel(thisPoint);
const int ourPos = orientation() == Qt::Horizontal
? splitterPos.x()
: splitterPos.y();
allSplitterSizes.push_back(ourPos);
}
}
QSplitterHandle::mousePressEvent(ev);
}
void Konsole::ViewSplitterHandle::mouseReleaseEvent(QMouseEvent *ev)
{
allSplitterSizes.clear();
QSplitterHandle::mouseReleaseEvent(ev);
}
void Konsole::ViewSplitterHandle::mouseMoveEvent(QMouseEvent *ev)
{
QSplitterHandle::mouseMoveEvent(ev);
}
......@@ -9,6 +9,7 @@
// Qt
#include <QSplitter>
#include <QSplitterHandle>
// Konsole
#include "konsoleprivate_export.h"
......@@ -21,6 +22,16 @@ class QDragLeaveEvent;
namespace Konsole {
class TerminalDisplay;
class ViewSplitterHandle : public QSplitterHandle {
Q_OBJECT
public:
ViewSplitterHandle(Qt::Orientation orientation, QSplitter *parent);
protected:
void mousePressEvent(QMouseEvent *ev) override;
void mouseReleaseEvent(QMouseEvent *ev) override;
void mouseMoveEvent(QMouseEvent *ev) override;
};
/**
* A splitter which holds a number of ViewContainer objects and allows
* the user to control the size of each view container by dragging a splitter
......@@ -106,6 +117,10 @@ public:
void childEvent(QChildEvent* event) override;
bool terminalMaximized() const { return m_terminalMaximized; }
QSplitterHandle *createHandle() override;
QPoint mapToTopLevel(const QPoint p);
protected:
void dragEnterEvent(QDragEnterEvent *ev) override;
void dragMoveEvent(QDragMoveEvent *ev) override;
......@@ -129,6 +144,9 @@ private:
void updateSizes();
bool m_terminalMaximized = false;
bool m_blockPropagatedDeletion = false;
static bool m_drawTopLevelHandler;
static Qt::Orientation m_topLevelHandlerDrawnOrientation;
};
}
#endif //VIEWSPLITTER_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment