2017-10-02 16:18:40 +00:00
|
|
|
#include "SectionsDock.h"
|
|
|
|
#include "ui_SectionsDock.h"
|
2017-04-12 10:16:43 +00:00
|
|
|
|
2017-10-01 19:09:42 +00:00
|
|
|
#include "MainWindow.h"
|
2017-10-02 16:18:40 +00:00
|
|
|
#include "widgets/SectionsWidget.h"
|
2017-04-12 10:16:43 +00:00
|
|
|
|
2017-04-13 15:14:02 +00:00
|
|
|
#include <QMenu>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
|
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
SectionsDock::SectionsDock(MainWindow *main, QAction *action) :
|
|
|
|
CutterDockWidget(main, action),
|
|
|
|
ui(new Ui::SectionsDock),
|
|
|
|
main(main)
|
2017-04-12 10:16:43 +00:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
this->sectionsWidget = new SectionsWidget(this->main);
|
|
|
|
this->setWidget(this->sectionsWidget);
|
|
|
|
this->sectionsWidget->setContentsMargins(0, 0, 0, 5);
|
|
|
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
|
|
|
|
this, SLOT(showSectionsContextMenu(const QPoint &)));
|
|
|
|
}
|
|
|
|
|
2017-10-02 09:41:28 +00:00
|
|
|
SectionsDock::~SectionsDock() {}
|
2017-04-12 10:16:43 +00:00
|
|
|
|
|
|
|
void SectionsDock::showSectionsContextMenu(const QPoint &pt)
|
|
|
|
{
|
|
|
|
// Set functions popup menu
|
|
|
|
QMenu *menu = new QMenu(this);
|
|
|
|
menu->clear();
|
|
|
|
menu->addAction(ui->actionHorizontal);
|
|
|
|
menu->addAction(ui->actionVertical);
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
if (this->sectionsWidget->orientation() == 1) {
|
2017-04-12 10:16:43 +00:00
|
|
|
ui->actionHorizontal->setChecked(true);
|
|
|
|
ui->actionVertical->setChecked(false);
|
2018-03-21 20:32:32 +00:00
|
|
|
} else {
|
2017-04-12 10:16:43 +00:00
|
|
|
ui->actionVertical->setChecked(true);
|
|
|
|
ui->actionHorizontal->setChecked(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
this->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
|
|
menu->exec(this->mapToGlobal(pt));
|
|
|
|
delete menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SectionsDock::resizeEvent(QResizeEvent *event)
|
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
if (main->responsive && isVisible()) {
|
|
|
|
if (event->size().width() >= event->size().height()) {
|
2017-04-12 10:16:43 +00:00
|
|
|
// Set horizontal view (list)
|
|
|
|
this->on_actionHorizontal_triggered();
|
2018-03-21 20:32:32 +00:00
|
|
|
} else {
|
2017-04-12 10:16:43 +00:00
|
|
|
// Set vertical view (Tree)
|
|
|
|
this->on_actionVertical_triggered();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QWidget::resizeEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SectionsDock::on_actionVertical_triggered()
|
|
|
|
{
|
|
|
|
this->sectionsWidget->setOrientation(Qt::Vertical);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SectionsDock::on_actionHorizontal_triggered()
|
|
|
|
{
|
|
|
|
this->sectionsWidget->setOrientation(Qt::Horizontal);
|
|
|
|
}
|