From 66c20669d3a7470917873ed304058c100ec1b173 2019-05-22 16:54:48 From: Alexis Jeandet Date: 2019-05-22 16:54:48 Subject: [PATCH] Refactored main toolbar to make it suck less :) Signed-off-by: Alexis Jeandet --- diff --git a/app/include/toolbar.h b/app/include/toolbar.h new file mode 100644 index 0000000..3ef4693 --- /dev/null +++ b/app/include/toolbar.h @@ -0,0 +1,37 @@ +#ifndef TOOLBAR_H +#define TOOLBAR_H + +#include +#include +#include +#include +#include +#include +#include + +// @TODO remove this, shouldn't need to include SqpApplication to get PlotsInteractionMode +#include + +class ToolBar : public QToolBar +{ + Q_OBJECT +public: + explicit ToolBar(QWidget* parent = nullptr); + + QAction* timeRange; + QAction* pointerMode; + QAction* zoomMode; + QAction* organizationMode; + QAction* zonesMode; + QAction* cursorsActn; + QAction* cataloguesActn; + + TimeWidgetAction* timeWidget; +signals: + void setPlotsInteractionMode(SqpApplication::PlotsInteractionMode); + void setPlotsCursorMode(SqpApplication::PlotsCursorMode); + void timeUpdated(DateTimeRange time); + void showCataloguesBrowser(); +}; + +#endif // TOOLBAR_H diff --git a/app/meson.build b/app/meson.build index 5244c3a..406df30 100644 --- a/app/meson.build +++ b/app/meson.build @@ -1,6 +1,7 @@ app_moc_headers = [ 'include/MainWindow.h' + 'include/toolbar.h' ] app_ui_files = [ @@ -16,6 +17,7 @@ app_moc_files = qt5.preprocess(moc_headers : app_moc_headers, app_sources = [ 'src/Main.cpp', 'src/MainWindow.cpp' + 'src/toolbar.cpp' ] app_inc = include_directories(['include']) diff --git a/app/src/MainWindow.cpp b/app/src/MainWindow.cpp index f0d4cfc..9772cc8 100644 --- a/app/src/MainWindow.cpp +++ b/app/src/MainWindow.cpp @@ -34,6 +34,8 @@ #include #include +#include "toolbar.h" + #include #include #include @@ -164,115 +166,12 @@ MainWindow::MainWindow(QWidget* parent) impl->m_SettingsDialog->saveSettings(); } }); - - auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); - - auto timeWidget = new TimeWidget {}; - mainToolBar->addWidget(timeWidget); - - // Interaction modes - auto actionPointerMode = new QAction { QIcon(":/icones/pointer.png"), "Move", this }; - actionPointerMode->setCheckable(true); - actionPointerMode->setChecked( - sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::None); - connect(actionPointerMode, &QAction::triggered, - []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::None); }); - - auto actionZoomMode = new QAction { QIcon(":/icones/zoom.png"), "Zoom", this }; - actionZoomMode->setCheckable(true); - actionZoomMode->setChecked( - sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::ZoomBox); - connect(actionZoomMode, &QAction::triggered, - []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::ZoomBox); }); - - auto actionOrganisationMode = new QAction { QIcon(":/icones/drag.png"), "Organize", this }; - actionOrganisationMode->setCheckable(true); - actionOrganisationMode->setChecked( - sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::DragAndDrop); - connect(actionOrganisationMode, &QAction::triggered, []() { - sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::DragAndDrop); - }); - - auto actionZonesMode = new QAction { QIcon(":/icones/rectangle.png"), "Zones", this }; - actionZonesMode->setCheckable(true); - actionZonesMode->setChecked( - sqpApp->plotsInteractionMode() == SqpApplication::PlotsInteractionMode::SelectionZones); - connect(actionZonesMode, &QAction::triggered, []() { - sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::SelectionZones); - }); - - auto modeActionGroup = new QActionGroup { this }; - modeActionGroup->addAction(actionZoomMode); - modeActionGroup->addAction(actionZonesMode); - modeActionGroup->addAction(actionOrganisationMode); - modeActionGroup->addAction(actionPointerMode); - modeActionGroup->setExclusive(true); - - mainToolBar->addSeparator(); - mainToolBar->addAction(actionPointerMode); - mainToolBar->addAction(actionZoomMode); - mainToolBar->addAction(actionOrganisationMode); - mainToolBar->addAction(actionZonesMode); - mainToolBar->addSeparator(); - - // Cursors - auto btnCursor = new QToolButton { this }; - btnCursor->setIcon(QIcon(":/icones/cursor.png")); - btnCursor->setText("Cursor"); - btnCursor->setToolTip("Cursor"); - btnCursor->setPopupMode(QToolButton::InstantPopup); - auto cursorMenu = new QMenu("CursorMenu", this); - btnCursor->setMenu(cursorMenu); - - auto noCursorAction = cursorMenu->addAction("No Cursor"); - noCursorAction->setCheckable(true); - noCursorAction->setChecked( - sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::NoCursor); - connect(noCursorAction, &QAction::triggered, - []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::NoCursor); }); - - cursorMenu->addSeparator(); - auto verticalCursorAction = cursorMenu->addAction("Vertical Cursor"); - verticalCursorAction->setCheckable(true); - verticalCursorAction->setChecked( - sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::Vertical); - connect(verticalCursorAction, &QAction::triggered, - []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Vertical); }); - - auto temporalCursorAction = cursorMenu->addAction("Temporal Cursor"); - temporalCursorAction->setCheckable(true); - temporalCursorAction->setChecked( - sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::Temporal); - connect(temporalCursorAction, &QAction::triggered, - []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Temporal); }); - - auto horizontalCursorAction = cursorMenu->addAction("Horizontal Cursor"); - horizontalCursorAction->setCheckable(true); - horizontalCursorAction->setChecked( - sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::Horizontal); - connect(horizontalCursorAction, &QAction::triggered, - []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Horizontal); }); - - auto crossCursorAction = cursorMenu->addAction("Cross Cursor"); - crossCursorAction->setCheckable(true); - crossCursorAction->setChecked( - sqpApp->plotsCursorMode() == SqpApplication::PlotsCursorMode::Cross); - connect(crossCursorAction, &QAction::triggered, - []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Cross); }); - - mainToolBar->addWidget(btnCursor); - - auto cursorModeActionGroup = new QActionGroup { this }; - cursorModeActionGroup->setExclusive(true); - cursorModeActionGroup->addAction(noCursorAction); - cursorModeActionGroup->addAction(verticalCursorAction); - cursorModeActionGroup->addAction(temporalCursorAction); - cursorModeActionGroup->addAction(horizontalCursorAction); - cursorModeActionGroup->addAction(crossCursorAction); - - // Catalog - mainToolBar->addSeparator(); - mainToolBar->addAction(QIcon(":/icones/catalogue.png"), "Catalogues", + auto mainToolBar = new ToolBar(this); + this->addToolBar(mainToolBar); + connect(mainToolBar, &ToolBar::setPlotsInteractionMode, sqpApp, + &SqpApplication::setPlotsInteractionMode); + connect(mainToolBar, &ToolBar::setPlotsCursorMode, sqpApp, &SqpApplication::setPlotsCursorMode); + connect(mainToolBar, &ToolBar::showCataloguesBrowser, [this]() { impl->m_CatalogExplorer->show(); }); // //////// // @@ -287,11 +186,6 @@ MainWindow::MainWindow(QWidget* parent) // Connections // // /////////// // - // Controllers / controllers connections - // connect(&sqpApp->timeController(), SIGNAL(timeUpdated(DateTimeRange)), - // &sqpApp->variableController(), - // SLOT(onDateTimeOnSelection(DateTimeRange))); - // Widgets / controllers connections // DataSource @@ -299,8 +193,10 @@ MainWindow::MainWindow(QWidget* parent) m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem*))); // Time - connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(), - SLOT(onTimeToUpdate(DateTimeRange))); + // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(), + // SLOT(onTimeToUpdate(DateTimeRange))); + connect(mainToolBar, &ToolBar::timeUpdated, &sqpApp->timeController(), + &TimeController::setDateTimeRange); // Visualization connect(&sqpApp->visualizationController(), diff --git a/app/src/toolbar.cpp b/app/src/toolbar.cpp new file mode 100644 index 0000000..2c3a417 --- /dev/null +++ b/app/src/toolbar.cpp @@ -0,0 +1,68 @@ +#include "toolbar.h" +#include +#include +#include +#include + +using InteractionMode = SqpApplication::PlotsInteractionMode; +using CursorMode = SqpApplication::PlotsCursorMode; + +ToolBar::ToolBar(QWidget* parent) +{ +#define mk_tuple std::make_tuple + + for (auto [action, icon, text, checkable] : + { mk_tuple(&this->timeRange, ":/icones/Simple_icon_time.svg", "Set time range", false), + mk_tuple(&this->pointerMode, ":/icones/pointer.png", "Move", true), + mk_tuple(&this->zoomMode, ":/icones/zoom.png", "Zoom", true), + mk_tuple(&this->organizationMode, ":/icones/drag.png", "Organize", true), + mk_tuple(&this->zonesMode, ":/icones/rectangle.png", "Zones", true), + mk_tuple(&this->cursorsActn, ":/icones/cursor.png", "Cursors", false), + mk_tuple(&this->cataloguesActn, ":/icones/catalogue.png", "Catalogues", false) }) + { + *action = new QAction(QIcon(icon), text, this); + (*action)->setCheckable(checkable); + this->addAction(*action); + } + connect(this->cataloguesActn, &QAction::triggered, this, &ToolBar::showCataloguesBrowser); + this->pointerMode->setChecked(true); + { + this->cursorsActn->setMenu(new QMenu()); + auto menu = this->cursorsActn->menu(); + auto group = new QActionGroup { this }; + group->setExclusive(true); + for (auto [icon, text, mode, checked] : + { mk_tuple("", "No Cursor", CursorMode::NoCursor, true), + mk_tuple("", "Vertical Cursor", CursorMode::Vertical, false), + mk_tuple("", "Horizontal Cursor", CursorMode::Horizontal, false), + mk_tuple("", "Cross Cursor", CursorMode::Cross, false) }) + { + auto action = menu->addAction(text); + group->addAction(action); + action->setCheckable(true); + action->setChecked(checked); + connect(action, &QAction::triggered, + [this, mode = mode]() { emit this->setPlotsCursorMode(mode); }); + } + } + + for (auto [actn, mode] : { mk_tuple(this->pointerMode, InteractionMode::None), + mk_tuple(this->zoomMode, InteractionMode::ZoomBox), + mk_tuple(this->organizationMode, InteractionMode::DragAndDrop), + mk_tuple(this->zonesMode, InteractionMode::SelectionZones) }) + { + connect(actn, &QAction::triggered, + [this, mode = mode]() { emit this->setPlotsInteractionMode(mode); }); + } + + auto cursorModeActionGroup = new QActionGroup { this }; + cursorModeActionGroup->setExclusive(true); + for (auto actn : { this->pointerMode, this->organizationMode, this->zoomMode, this->zonesMode }) + { + cursorModeActionGroup->addAction(actn); + } + + this->timeWidget = new TimeWidgetAction(); + this->timeRange->setMenu(new QMenu()); + this->timeRange->menu()->addAction(this->timeWidget); +} diff --git a/app/ui/MainWindow.ui b/app/ui/MainWindow.ui index 12fe480..899a94f 100644 --- a/app/ui/MainWindow.ui +++ b/app/ui/MainWindow.ui @@ -130,9 +130,24 @@ 0 0 800 - 24 + 27 + + + 0 + 0 + + + + + 0 + 0 + + + + true + diff --git a/gui/include/SqpApplication.h b/gui/include/SqpApplication.h index 4984fa0..4e2e9c6 100644 --- a/gui/include/SqpApplication.h +++ b/gui/include/SqpApplication.h @@ -3,8 +3,14 @@ #include "SqpApplication.h" +#include #include #include +#include +#include +#include +#include +#include #include @@ -13,7 +19,7 @@ Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication) #if defined(sqpApp) #undef sqpApp #endif -#define sqpApp (static_cast(QCoreApplication::instance())) +#define sqpApp (static_cast(QCoreApplication::instance())) class DataSourceController; class NetworkController; @@ -26,6 +32,27 @@ class DragDropGuiController; class ActionsGuiController; class CatalogueController; +/* stolen from here https://forum.qt.io/topic/90403/show-tooltip-immediatly/6 */ +class MyProxyStyle : public QProxyStyle +{ +public: + using QProxyStyle::QProxyStyle; + + int styleHint(StyleHint hint, const QStyleOption* option = nullptr, + const QWidget* widget = nullptr, QStyleHintReturn* returnData = nullptr) const override + { + if (widget) + auto cname = widget->metaObject()->className(); + if (hint == QStyle::SH_ToolButton_PopupDelay && widget + /*&& widget->inherits(QWidgetAction::staticMetaObject.className())*/) + { + return 0; + } + + return QProxyStyle::styleHint(hint, option, widget, returnData); + } +}; + /** * @brief The SqpApplication class aims to make the link between SciQlop * and its plugins. This is the intermediate class that SciQlop has to use @@ -35,32 +62,46 @@ class CatalogueController; * You can load a data source driver plugin then create a data source. */ -class SqpApplication : public QApplication { +class SqpApplication : public QApplication +{ Q_OBJECT public: - explicit SqpApplication(int &argc, char **argv); - ~SqpApplication() override; + explicit SqpApplication(int& argc, char** argv); + ~SqpApplication() override; void initialize(); /// Accessors for the differents sciqlop controllers - DataSourceController &dataSourceController() noexcept; - NetworkController &networkController() noexcept; - TimeController &timeController() noexcept; - VariableController2 &variableController() noexcept; + DataSourceController& dataSourceController() noexcept; + NetworkController& networkController() noexcept; + TimeController& timeController() noexcept; + VariableController2& variableController() noexcept; std::shared_ptr variableControllerOwner() noexcept; //@TODO there should not be any global model it's just GUI impl detail -// VariableModel2 &variableModel() noexcept; - VisualizationController &visualizationController() noexcept; - CatalogueController &catalogueController() noexcept; + // VariableModel2 &variableModel() noexcept; + VisualizationController& visualizationController() noexcept; + CatalogueController& catalogueController() noexcept; /// Accessors for the differents sciqlop helpers, these helpers classes are like controllers but /// doesn't live in a thread and access gui - DragDropGuiController &dragDropGuiController() noexcept; - ActionsGuiController &actionsGuiController() noexcept; - - enum class PlotsInteractionMode { None, ZoomBox, DragAndDrop, SelectionZones }; - - enum class PlotsCursorMode { NoCursor, Vertical, Temporal, Horizontal, Cross }; + DragDropGuiController& dragDropGuiController() noexcept; + ActionsGuiController& actionsGuiController() noexcept; + + enum class PlotsInteractionMode + { + None, + ZoomBox, + DragAndDrop, + SelectionZones + }; + + enum class PlotsCursorMode + { + NoCursor, + Vertical, + Temporal, + Horizontal, + Cross + }; PlotsInteractionMode plotsInteractionMode() const; void setPlotsInteractionMode(PlotsInteractionMode mode); diff --git a/gui/include/TimeWidget/TimeWidget.h b/gui/include/TimeWidget/TimeWidget.h index 3b22bfa..69f46b8 100644 --- a/gui/include/TimeWidget/TimeWidget.h +++ b/gui/include/TimeWidget/TimeWidget.h @@ -2,20 +2,24 @@ #define SCIQLOP_TIMEWIDGET_H #include +#include #include #include -namespace Ui { +namespace Ui +{ class TimeWidget; } // Ui -class TimeWidget : public QWidget { + +class TimeWidget : public QWidget +{ Q_OBJECT public: - explicit TimeWidget(QWidget *parent = 0); + explicit TimeWidget(QWidget* parent = 0); virtual ~TimeWidget(); void setTimeRange(DateTimeRange time); @@ -30,18 +34,31 @@ public slots: void onTimeUpdateRequested(); protected: - void dragEnterEvent(QDragEnterEvent *event) override; - void dragLeaveEvent(QDragLeaveEvent *event) override; - void dropEvent(QDropEvent *event) override; + void dragEnterEvent(QDragEnterEvent* event) override; + void dragLeaveEvent(QDragLeaveEvent* event) override; + void dropEvent(QDropEvent* event) override; - void mousePressEvent(QMouseEvent *event) override; - void mouseMoveEvent(QMouseEvent *event) override; + void mousePressEvent(QMouseEvent* event) override; + void mouseMoveEvent(QMouseEvent* event) override; private: - Ui::TimeWidget *ui; + Ui::TimeWidget* ui; class TimeWidgetPrivate; spimpl::unique_impl_ptr impl; }; +class TimeWidgetAction : public QWidgetAction +{ + Q_OBJECT + TimeWidget* timeWidget; + +public: + explicit TimeWidgetAction(QWidget* parent = 0) : QWidgetAction(parent) + { + timeWidget = new TimeWidget(); + this->setDefaultWidget(timeWidget); + } +}; + #endif // SCIQLOP_ SQPSIDEPANE_H diff --git a/gui/resources/icones/Simple_icon_time.svg b/gui/resources/icones/Simple_icon_time.svg new file mode 100644 index 0000000..9068711 --- /dev/null +++ b/gui/resources/icones/Simple_icon_time.svg @@ -0,0 +1,20 @@ + + + + + + + + + image/svg+xml + + + + + + + + + + + \ No newline at end of file diff --git a/gui/resources/sqpguiresources.qrc b/gui/resources/sqpguiresources.qrc index 60a79a6..6844376 100644 --- a/gui/resources/sqpguiresources.qrc +++ b/gui/resources/sqpguiresources.qrc @@ -1,10 +1,10 @@ - icones/dataSourceComponent.png - icones/dataSourceNode.png - icones/dataSourceProduct.png - icones/dataSourceRoot.png - icones/delete.png + icones/dataSourceComponent.png + icones/dataSourceNode.png + icones/dataSourceProduct.png + icones/dataSourceRoot.png + icones/delete.png icones/down.png icones/openInspector.png icones/next.png @@ -12,20 +12,21 @@ icones/previous.png icones/unplot.png icones/up.png - icones/time.png - icones/zoom.png - icones/rectangle.png - icones/drag.png - icones/cursor.png - icones/pointer.png - icones/catalogue.png - icones/add.png - icones/remove.png - icones/chart.png - icones/allEvents.png - icones/trash.png - icones/database.png - icones/save.png - icones/discard.png + icones/time.png + icones/zoom.png + icones/rectangle.png + icones/drag.png + icones/cursor.png + icones/pointer.png + icones/catalogue.png + icones/add.png + icones/remove.png + icones/chart.png + icones/allEvents.png + icones/trash.png + icones/database.png + icones/save.png + icones/discard.png + icones/Simple_icon_time.svg diff --git a/gui/src/SqpApplication.cpp b/gui/src/SqpApplication.cpp index 6d15918..e3288ba 100644 --- a/gui/src/SqpApplication.cpp +++ b/gui/src/SqpApplication.cpp @@ -92,6 +92,7 @@ public: SqpApplication::SqpApplication(int& argc, char** argv) : QApplication { argc, argv }, impl { spimpl::make_unique_impl() } { + this->setStyle(new MyProxyStyle(this->style())); qCDebug(LOG_SqpApplication()) << tr("SqpApplication construction") << QThread::currentThread(); QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); diff --git a/gui/src/TimeWidget/TimeWidget.cpp b/gui/src/TimeWidget/TimeWidget.cpp index abf961e..08fd810 100644 --- a/gui/src/TimeWidget/TimeWidget.cpp +++ b/gui/src/TimeWidget/TimeWidget.cpp @@ -15,32 +15,27 @@ #include -struct TimeWidget::TimeWidgetPrivate { +struct TimeWidget::TimeWidgetPrivate +{ explicit TimeWidgetPrivate() {} QPoint m_DragStartPosition; }; -TimeWidget::TimeWidget(QWidget *parent) - : QWidget{parent}, - ui{new Ui::TimeWidget}, - impl{spimpl::make_unique_impl()} +TimeWidget::TimeWidget(QWidget* parent) + : QWidget { parent } + , ui { new Ui::TimeWidget } + , impl { spimpl::make_unique_impl() } { ui->setupUi(this); - ui->applyToolButton->setIcon(sqpApp->style()->standardIcon(QStyle::SP_DialogApplyButton)); - // Connection connect(ui->startDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, - &TimeWidget::onTimeUpdateRequested); + &TimeWidget::onTimeUpdateRequested); connect(ui->endDateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, - &TimeWidget::onTimeUpdateRequested); - - - connect(ui->applyToolButton, &QToolButton::clicked, &sqpApp->timeController(), - &TimeController::onTimeNotify); + &TimeWidget::onTimeUpdateRequested); // Initialisation auto endDateTime = QDateTime::currentDateTimeUtc(); @@ -49,8 +44,8 @@ TimeWidget::TimeWidget(QWidget *parent) ui->startDateTimeEdit->setDateTime(startDateTime); ui->endDateTimeEdit->setDateTime(endDateTime); - auto dateTime = DateTimeRange{DateUtils::secondsSinceEpoch(startDateTime), - DateUtils::secondsSinceEpoch(endDateTime)}; + auto dateTime = DateTimeRange { DateUtils::secondsSinceEpoch(startDateTime), + DateUtils::secondsSinceEpoch(endDateTime) }; sqpApp->timeController().setDateTimeRange(dateTime); } @@ -72,8 +67,8 @@ void TimeWidget::setTimeRange(DateTimeRange time) DateTimeRange TimeWidget::timeRange() const { - return DateTimeRange{DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), - DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime())}; + return DateTimeRange { DateUtils::secondsSinceEpoch(ui->startDateTimeEdit->dateTime()), + DateUtils::secondsSinceEpoch(ui->endDateTimeEdit->dateTime()) }; } void TimeWidget::onTimeUpdateRequested() @@ -83,60 +78,67 @@ void TimeWidget::onTimeUpdateRequested() sqpApp->timeController().setDateTimeRange(dateTime); } -void TimeWidget::dragEnterEvent(QDragEnterEvent *event) +void TimeWidget::dragEnterEvent(QDragEnterEvent* event) { - if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) { + if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) + { event->acceptProposedAction(); setStyleSheet("QDateTimeEdit{background-color: #BBD5EE; border:2px solid #2A7FD4}"); } - else { + else + { event->ignore(); } } -void TimeWidget::dragLeaveEvent(QDragLeaveEvent *event) +void TimeWidget::dragLeaveEvent(QDragLeaveEvent* event) { - setStyleSheet(QString{}); + setStyleSheet(QString {}); } -void TimeWidget::dropEvent(QDropEvent *event) +void TimeWidget::dropEvent(QDropEvent* event) { - if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) { + if (event->mimeData()->hasFormat(MIME_TYPE_TIME_RANGE)) + { auto mimeData = event->mimeData()->data(MIME_TYPE_TIME_RANGE); auto timeRange = TimeController::timeRangeForMimeData(mimeData); setTimeRange(timeRange); } - else { + else + { event->ignore(); } - setStyleSheet(QString{}); + setStyleSheet(QString {}); } -void TimeWidget::mousePressEvent(QMouseEvent *event) +void TimeWidget::mousePressEvent(QMouseEvent* event) { - if (event->button() == Qt::LeftButton) { + if (event->button() == Qt::LeftButton) + { impl->m_DragStartPosition = event->pos(); } QWidget::mousePressEvent(event); } -void TimeWidget::mouseMoveEvent(QMouseEvent *event) +void TimeWidget::mouseMoveEvent(QMouseEvent* event) { - if (!(event->buttons() & Qt::LeftButton)) { + if (!(event->buttons() & Qt::LeftButton)) + { return; } if ((event->pos() - impl->m_DragStartPosition).manhattanLength() - < QApplication::startDragDistance()) { + < QApplication::startDragDistance()) + { return; } // Note: The management of the drag object is done by Qt - auto drag = new QDrag{this}; + auto drag = new QDrag { this }; auto mimeData = new QMimeData; auto timeData = TimeController::mimeDataForTimeRange(timeRange()); @@ -144,7 +146,7 @@ void TimeWidget::mouseMoveEvent(QMouseEvent *event) drag->setMimeData(mimeData); - auto pixmap = QPixmap{":/icones/time.png"}; + auto pixmap = QPixmap { ":/icones/time.png" }; drag->setPixmap(pixmap.scaledToWidth(22)); sqpApp->dragDropGuiController().resetDragAndDrop(); diff --git a/gui/ui/TimeWidget/TimeWidget.ui b/gui/ui/TimeWidget/TimeWidget.ui index 9f074ba..57deed9 100644 --- a/gui/ui/TimeWidget/TimeWidget.ui +++ b/gui/ui/TimeWidget/TimeWidget.ui @@ -90,13 +90,6 @@ - - - - ... - - -