Skip to content

Commit

Permalink
MainWindow_renaming_CustomQMdiArea_to_MovableQMdiArea
Browse files Browse the repository at this point in the history
  • Loading branch information
szeli1 committed Nov 23, 2024
1 parent 477600c commit 8480d1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
9 changes: 4 additions & 5 deletions include/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ConfigManager;
namespace gui
{

class CustomQMdiArea;
class PluginView;
class SubWindow;
class ToolButton;
Expand Down Expand Up @@ -202,11 +201,11 @@ private slots:
bool guiSaveProject();
bool guiSaveProjectAs( const QString & filename );

class CustomQMdiArea : public QMdiArea
class MovableQMdiArea : public QMdiArea
{
public:
CustomQMdiArea(QWidget* parent = nullptr);
~CustomQMdiArea() {}
MovableQMdiArea(QWidget* parent = nullptr);
~MovableQMdiArea() {}
protected:
void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
Expand All @@ -217,7 +216,7 @@ private slots:
int m_lastY;
};

CustomQMdiArea * m_workspace;
MovableQMdiArea * m_workspace;

QWidget * m_toolBar;
QGridLayout * m_toolBarLayout;
Expand Down
10 changes: 5 additions & 5 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ MainWindow::MainWindow() :
sideBar->appendTab(new FileBrowser(root_paths.join("*"), FileItem::defaultFilters(), title,
embed::getIconPixmap("computer").transformed(QTransform().rotate(90)), splitter, dirs_as_items));

m_workspace = new CustomQMdiArea(splitter);
m_workspace = new MovableQMdiArea(splitter);

// Load background
emit initProgress(tr("Loading background picture"));
Expand Down Expand Up @@ -1614,21 +1614,21 @@ void MainWindow::onProjectFileNameChanged()
this->resetWindowTitle();
}

MainWindow::CustomQMdiArea::CustomQMdiArea(QWidget* parent) :
MainWindow::MovableQMdiArea::MovableQMdiArea(QWidget* parent) :
QMdiArea(parent),
m_isBeingMoved(false),
m_lastX(0),
m_lastY(0)
{}

void MainWindow::CustomQMdiArea::mousePressEvent(QMouseEvent* event)
void MainWindow::MovableQMdiArea::mousePressEvent(QMouseEvent* event)
{
m_lastX = event->x();
m_lastY = event->y();
m_isBeingMoved = true;
}

void MainWindow::CustomQMdiArea::mouseMoveEvent(QMouseEvent* event)
void MainWindow::MovableQMdiArea::mouseMoveEvent(QMouseEvent* event)
{
if (m_isBeingMoved == false) { return; }

Expand All @@ -1646,7 +1646,7 @@ void MainWindow::CustomQMdiArea::mouseMoveEvent(QMouseEvent* event)
}
}

void MainWindow::CustomQMdiArea::mouseReleaseEvent(QMouseEvent* event)
void MainWindow::MovableQMdiArea::mouseReleaseEvent(QMouseEvent* event)
{
m_isBeingMoved = false;
}
Expand Down

0 comments on commit 8480d1c

Please sign in to comment.