diff --git a/CMakeLists.txt b/CMakeLists.txt index 82b0d523d7e67c3909913646f48bb34df70a812f..91213d2627d091860796991f62cfbd8078047803 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -136,7 +136,6 @@ endif() add_subdirectory(ThirdParty/common) add_subdirectory(ThirdParty/Core) if(BORNAGAIN_GUI) - add_subdirectory(ThirdParty/GUI/qt-manhattan-style) add_subdirectory(ThirdParty/GUI/qcustomplot) endif() if(BORNAGAIN_NEWREFL) diff --git a/GUI/coregui/CMakeLists.txt b/GUI/coregui/CMakeLists.txt index 309cbfa5dba10416d66229006dfb668912dec9b6..e7536666da211dfe474d5a699cf45cec3915b1e8 100644 --- a/GUI/coregui/CMakeLists.txt +++ b/GUI/coregui/CMakeLists.txt @@ -93,10 +93,8 @@ set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE) # --- dependencies --------- target_include_directories(${library_name} PUBLIC - ${CMAKE_SOURCE_DIR}/ThirdParty/GUI # for qt-manhattan-style ${CMAKE_SOURCE_DIR}) target_link_libraries(${library_name} - ${ManhattanStyle_LIBRARY} ${BornAgainCore_LIBRARY} ${ba3d_LIBRARY} Qt5::Widgets diff --git a/GUI/coregui/Views/CommonWidgets/DocksController.cpp b/GUI/coregui/Views/CommonWidgets/DocksController.cpp index d12975362d8c9d31439eb1589a6da34d5b04d479..7de08dc9a57e38735fd732e6698232f53f9b2f4c 100644 --- a/GUI/coregui/Views/CommonWidgets/DocksController.cpp +++ b/GUI/coregui/Views/CommonWidgets/DocksController.cpp @@ -18,15 +18,60 @@ #include <QAbstractItemView> #include <QAction> #include <QDockWidget> +#include <QEvent> +#include <QMainWindow> +#include <QMenu> +#include <QSettings> #include <QTimer> -#include <qt-manhattan-style/fancymainwindow.h> -DocksController::DocksController(Manhattan::FancyMainWindow* mainWindow) +namespace { +const char dockWidgetActiveState[] = "DockWidgetActiveState"; +const char StateKey[] = "State"; +const int settingsVersion = 2; + +QString stripAccelerator(const QString& text) { + QString res = text; + for (int index = res.indexOf('&'); index != -1; index = res.indexOf('&', index + 1)) + res.remove(index, 1); + return res; +} + +} // namespace + +DocksController::DocksController(QMainWindow* mainWindow) : QObject(mainWindow), m_mainWindow(mainWindow) { m_mainWindow->setDocumentMode(true); m_mainWindow->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South); m_mainWindow->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); m_mainWindow->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); + m_mainWindow->installEventFilter(this); +} + +QDockWidget* DocksController::addDockForWidget(QWidget* widget) { + auto dockWidget = new QDockWidget(m_mainWindow); + dockWidget->setWidget(widget); + dockWidget->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable + | QDockWidget::DockWidgetFloatable); + dockWidget->setObjectName(widget->objectName() + QLatin1String("DockWidget")); + + QString title = widget->windowTitle(); + dockWidget->toggleViewAction()->setProperty("original_title", title); + title = stripAccelerator(title); + dockWidget->setWindowTitle(title); + + connect(dockWidget->toggleViewAction(), &QAction::triggered, [=]() { + if (dockWidget->isVisible()) + dockWidget->raise(); + }); + + connect(dockWidget, &QDockWidget::visibilityChanged, [this, dockWidget](bool visible) { + if (m_handleDockVisibilityChanges) + dockWidget->setProperty(dockWidgetActiveState, visible); + }); + + dockWidget->setProperty(dockWidgetActiveState, true); + + return dockWidget; } void DocksController::addWidget(int id, QWidget* widget, Qt::DockWidgetArea area) { @@ -34,7 +79,7 @@ void DocksController::addWidget(int id, QWidget* widget, Qt::DockWidgetArea area throw GUIHelpers::Error("DocksController::addWidget() -> Error. " "Attempt to add widget id twice"); - auto dock = m_mainWindow->addDockForWidget(widget); + auto dock = addDockForWidget(widget); m_docks[id] = DockWidgetInfo(dock, widget, area); QList<QAbstractItemView*> frames = widget->findChildren<QAbstractItemView*>(); @@ -42,10 +87,9 @@ void DocksController::addWidget(int id, QWidget* widget, Qt::DockWidgetArea area frames[i]->setFrameStyle(QFrame::NoFrame); } -void DocksController::onResetLayout() { - m_mainWindow->setTrackingEnabled(false); - QList<QDockWidget*> dockWidgetList = m_mainWindow->dockWidgets(); - for (QDockWidget* dockWidget : dockWidgetList) { +void DocksController::resetLayout() { + setTrackingEnabled(false); + for (auto dockWidget : dockWidgets()) { dockWidget->setFloating(false); m_mainWindow->removeDockWidget(dockWidget); } @@ -55,19 +99,24 @@ void DocksController::onResetLayout() { // Fixes issue: https://bugreports.qt.io/browse/QTBUG-65592 #if QT_VERSION >= 0x050600 - dockWidgetList = m_mainWindow->dockWidgets(); - if (dockWidgetList.size() > 0) - m_mainWindow->resizeDocks({dockWidgetList.first()}, {10}, Qt::Horizontal); + if (dockWidgets().size() > 0) + m_mainWindow->resizeDocks({dockWidgets().first()}, {10}, Qt::Horizontal); #endif - for (QDockWidget* dockWidget : dockWidgetList) + for (auto dockWidget : dockWidgets()) dockWidget->show(); - m_mainWindow->setTrackingEnabled(true); + setTrackingEnabled(true); +} + +void DocksController::toggleDock(int id) { + auto dock = findDock(id); + dock->setHidden(!dock->isHidden()); } QDockWidget* DocksController::findDock(int id) { - return get_info(id).dock(); + ASSERT(m_docks.find(id) != m_docks.end()); + return m_docks[id].dock(); } QDockWidget* DocksController::findDock(QWidget* widget) { @@ -78,11 +127,15 @@ QDockWidget* DocksController::findDock(QWidget* widget) { throw GUIHelpers::Error("DocksController::findDock() -> Can't find dock for widget"); } +const QList<QDockWidget*> DocksController::dockWidgets() const { + return m_mainWindow->findChildren<QDockWidget*>(); +} + //! Show docks with id's from the list. Other docks will be hidden. -void DocksController::show_docks(const std::vector<int>& docks_to_show) { +void DocksController::setVisibleDocks(const std::vector<int>& visibleDocks) { for (auto& it : m_docks) { - if (std::find(docks_to_show.begin(), docks_to_show.end(), it.first) != docks_to_show.end()) + if (std::find(visibleDocks.begin(), visibleDocks.end(), it.first) != visibleDocks.end()) it.second.dock()->show(); else it.second.dock()->hide(); @@ -124,22 +177,84 @@ void DocksController::dockToMinMaxSizes() { m_dock_info.m_dock = nullptr; } -void DocksController::onWidgetCloseRequest() { - QWidget* widget = qobject_cast<QWidget*>(sender()); - ASSERT(widget); - QDockWidget* dock = findDock(widget); - ASSERT(dock); +void DocksController::setTrackingEnabled(bool enabled) { + if (enabled) { + m_handleDockVisibilityChanges = true; + for (auto dockWidget : dockWidgets()) + dockWidget->setProperty(dockWidgetActiveState, dockWidget->isVisible()); + } else { + m_handleDockVisibilityChanges = false; + } +} - dock->toggleViewAction()->trigger(); +void DocksController::handleWindowVisibilityChanged(bool visible) { + m_handleDockVisibilityChanges = false; + for (auto dockWidget : dockWidgets()) { + if (dockWidget->isFloating()) { + dockWidget->setVisible(visible && dockWidget->property(dockWidgetActiveState).toBool()); + } + } + if (visible) + m_handleDockVisibilityChanges = true; } -Manhattan::FancyMainWindow* DocksController::mainWindow() { - return m_mainWindow; +bool DocksController::eventFilter(QObject* obj, QEvent* event) { + if (event->type() == QEvent::Show) + handleWindowVisibilityChanged(true); + else if (event->type() == QEvent::Hide) + handleWindowVisibilityChanged(false); + + return QObject::eventFilter(obj, event); } -DockWidgetInfo DocksController::get_info(int id) { - if (m_docks.find(id) == m_docks.end()) - throw GUIHelpers::Error("DocksController::addWidget() -> Error. Non existing id."); +void DocksController::addDockActionsToMenu(QMenu* menu) { + QList<QAction*> actions; + for (auto dockWidget : dockWidgets()) { + if (dockWidget->property("managed_dockwidget").isNull() + && dockWidget->parentWidget() == m_mainWindow) { + QAction* action = dockWidget->toggleViewAction(); + action->setText(action->property("original_title").toString()); + actions.append(action); + } + } + std::sort(actions.begin(), actions.end(), [](const QAction* action1, const QAction* action2) { + return stripAccelerator(action1->text()).toLower() + < stripAccelerator(action2->text()).toLower(); + }); + + foreach (QAction* action, actions) + menu->addAction(action); +} - return m_docks[id]; +void DocksController::saveSettings(QSettings* settings) const { + QHash<QString, QVariant> hash = saveSettings(); + QHashIterator<QString, QVariant> it(hash); + while (it.hasNext()) { + it.next(); + settings->setValue(it.key(), it.value()); + } +} + +void DocksController::restoreSettings(const QSettings* settings) { + QHash<QString, QVariant> hash; + foreach (const QString& key, settings->childKeys()) { hash.insert(key, settings->value(key)); } + restoreSettings(hash); +} + +QHash<QString, QVariant> DocksController::saveSettings() const { + QHash<QString, QVariant> settings; + settings.insert(QLatin1String(StateKey), m_mainWindow->saveState(settingsVersion)); + for (auto dockWidget : dockWidgets()) { + settings.insert(dockWidget->objectName(), dockWidget->property(dockWidgetActiveState)); + } + return settings; +} + +void DocksController::restoreSettings(const QHash<QString, QVariant>& settings) { + QByteArray ba = settings.value(QLatin1String(StateKey), QByteArray()).toByteArray(); + if (!ba.isEmpty()) + m_mainWindow->restoreState(ba, settingsVersion); + for (auto widget : dockWidgets()) { + widget->setProperty(dockWidgetActiveState, settings.value(widget->objectName(), false)); + } } diff --git a/GUI/coregui/Views/CommonWidgets/DocksController.h b/GUI/coregui/Views/CommonWidgets/DocksController.h index 154c11cf5c8392052f4fdb3ab523c1c90e730010..cc2bf3f75780d3f3de2bbd626ae78b2594c292f6 100644 --- a/GUI/coregui/Views/CommonWidgets/DocksController.h +++ b/GUI/coregui/Views/CommonWidgets/DocksController.h @@ -20,49 +20,56 @@ #include <QSize> #include <map> -namespace Manhattan { -class FancyMainWindow; -} +class QMainWindow; +class QMenu; +class QSettings; -//! Handles appearance of docked widgets in the context of FancyMainWindow. +//! Handles creation and appearance of docked widgets in the context of QMainWindow. It is used for +//! SampleView and JobView which are based on QMainWindow. class DocksController : public QObject { Q_OBJECT public: - DocksController(Manhattan::FancyMainWindow* mainWindow); + DocksController(QMainWindow* mainWindow); void addWidget(int id, QWidget* widget, Qt::DockWidgetArea area); - virtual void onResetLayout(); + void resetLayout(); + void toggleDock(int id); + void setVisibleDocks(const std::vector<int>& visibleDocks); QDockWidget* findDock(int id); - QDockWidget* findDock(QWidget* widget); + const QList<QDockWidget*> dockWidgets() const; + + void addDockActionsToMenu(QMenu* menu); - void show_docks(const std::vector<int>& docks_to_show); + QHash<QString, QVariant> saveSettings() const; + void saveSettings(QSettings* settings) const; + void restoreSettings(const QHash<QString, QVariant>& settings); + void restoreSettings(const QSettings* settings); public slots: void setDockHeightForWidget(int height); void dockToMinMaxSizes(); - void onWidgetCloseRequest(); - -protected: - Manhattan::FancyMainWindow* mainWindow(); private: struct DockSizeInfo { - DockSizeInfo() : m_dock(nullptr) {} - QDockWidget* m_dock; + QDockWidget* m_dock = nullptr; QSize m_min_size; QSize m_max_size; }; - DockWidgetInfo get_info(int id); + QDockWidget* addDockForWidget(QWidget* widget); + void setTrackingEnabled(bool enabled); + void handleWindowVisibilityChanged(bool visible); + virtual bool eventFilter(QObject*, QEvent* event); - Manhattan::FancyMainWindow* m_mainWindow; + QMainWindow* m_mainWindow; std::map<int, DockWidgetInfo> m_docks; DockSizeInfo m_dock_info; + bool m_handleDockVisibilityChanges = true; }; #endif // BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_DOCKSCONTROLLER_H diff --git a/GUI/coregui/Views/CommonWidgets/InfoPanel.cpp b/GUI/coregui/Views/CommonWidgets/InfoPanel.cpp index 265737ffa4e1bf67eaa55b33f010d3aed8af015a..e0ffaea7d186dc9da818af772e8938669148ca25 100644 --- a/GUI/coregui/Views/CommonWidgets/InfoPanel.cpp +++ b/GUI/coregui/Views/CommonWidgets/InfoPanel.cpp @@ -41,8 +41,6 @@ InfoPanel::InfoPanel(QWidget* parent) connect(m_toolBar, &InfoPanelToolBar::expandButtonClicked, this, &InfoPanel::onExpandButtonClicked); - connect(m_toolBar, &InfoPanelToolBar::closeButtonClicked, this, - &InfoPanel::onCloseButtonClicked); } QSize InfoPanel::sizeHint() const { @@ -66,10 +64,6 @@ void InfoPanel::onExpandButtonClicked() { setContentVisible(!isContentVisible(), true); } -void InfoPanel::onCloseButtonClicked() { - emit widgetCloseRequest(); -} - void InfoPanel::setContentVisible(bool editor_status, bool dock_notify) { m_toolBar->setExpandStatus(editor_status); if (editor_status) { diff --git a/GUI/coregui/Views/CommonWidgets/InfoPanel.h b/GUI/coregui/Views/CommonWidgets/InfoPanel.h index 805027e4a2ccebe34f4158fac093a9c52efffd04..c7fc16d4df07ed1627b688af6ff14523435de3cb 100644 --- a/GUI/coregui/Views/CommonWidgets/InfoPanel.h +++ b/GUI/coregui/Views/CommonWidgets/InfoPanel.h @@ -36,11 +36,9 @@ public: signals: void widgetHeightRequest(int); - void widgetCloseRequest(); protected slots: void onExpandButtonClicked(); - void onCloseButtonClicked(); void setContentVisible(bool editor_status, bool dock_notify = false); protected: diff --git a/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.cpp b/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.cpp index f2178707ad970a426832c8030046f878c82fa7cb..d26618e4c8ee8e12bd5878de8a3ae5dd80317a79 100644 --- a/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.cpp +++ b/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.cpp @@ -21,16 +21,11 @@ namespace { const int minimum_size = 25; const QString icon_up = ":/images/dark-angle-up.svg"; const QString icon_down = ":/images/dark-angle-down.svg"; -const QString icon_close = ":/images/dark-close.svg"; const QString expand_text = "Collapse/expand view"; -const QString close_text = "Close view"; } // namespace InfoPanelToolBar::InfoPanelToolBar(QWidget* parent) - : QToolBar(parent) - , m_expandAction(new QAction(expand_text, this)) - , m_closeAction(new QAction(close_text, this)) - , m_expanded(false) { + : QToolBar(parent), m_expandAction(new QAction(expand_text, this)), m_expanded(false) { setMinimumSize(minimum_size, minimum_size); setProperty("_q_custom_style_disabled", QVariant(true)); @@ -38,16 +33,11 @@ InfoPanelToolBar::InfoPanelToolBar(QWidget* parent) m_expandAction->setToolTip(expand_text); connect(m_expandAction, &QAction::triggered, this, &InfoPanelToolBar::onExpandButtonClicked); - m_closeAction->setIcon(QIcon(icon_close)); - m_closeAction->setToolTip(close_text); - connect(m_closeAction, &QAction::triggered, this, &InfoPanelToolBar::closeButtonClicked); - auto empty = new QWidget(); empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); addWidget(empty); addAction(m_expandAction); - addAction(m_closeAction); } void InfoPanelToolBar::setExpandStatus(bool status) { diff --git a/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.h b/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.h index 2067fd7052f3639bf7f0a115f3d2c1b0e575bdfe..c51d217c56648c88cfcb9a551c4dcd9f213e6322 100644 --- a/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.h +++ b/GUI/coregui/Views/CommonWidgets/InfoPanelToolBar.h @@ -29,7 +29,6 @@ public: signals: void expandButtonClicked(); - void closeButtonClicked(); public slots: void setExpandStatus(bool status); @@ -39,7 +38,6 @@ protected slots: private: QAction* m_expandAction; - QAction* m_closeAction; bool m_expanded; }; diff --git a/GUI/coregui/Views/JobView.cpp b/GUI/coregui/Views/JobView.cpp index 2069de1e47fc77e5c8061cb00f62f1698d69c399..7a041e8d9e35905c99fab13910e7174cb465848c 100644 --- a/GUI/coregui/Views/JobView.cpp +++ b/GUI/coregui/Views/JobView.cpp @@ -15,33 +15,52 @@ #include "GUI/coregui/Views/JobView.h" #include "GUI/coregui/Models/JobItem.h" #include "GUI/coregui/Models/JobModel.h" +#include "GUI/coregui/Views/CommonWidgets/DocksController.h" +#include "GUI/coregui/Views/FitWidgets/FitActivityPanel.h" +#include "GUI/coregui/Views/JobView.h" +#include "GUI/coregui/Views/JobWidgets/JobMessagePanel.h" #include "GUI/coregui/Views/JobWidgets/JobOutputDataWidget.h" #include "GUI/coregui/Views/JobWidgets/JobProgressAssistant.h" +#include "GUI/coregui/Views/JobWidgets/JobRealTimeWidget.h" #include "GUI/coregui/Views/JobWidgets/JobSelectorWidget.h" -#include "GUI/coregui/Views/JobWidgets/JobViewDocks.h" +#include "GUI/coregui/Views/JobWidgets/JobViewActivities.h" #include "GUI/coregui/Views/JobWidgets/JobViewFlags.h" -#include "GUI/coregui/Views/JobWidgets/JobViewStatusBar.h" #include "GUI/coregui/mainwindow/mainwindow.h" #include <QMenu> JobView::JobView(MainWindow* mainWindow) - : m_docks(new JobViewDocks(this)) - , m_statusBar(new JobViewStatusBar(mainWindow)) + : m_docks(new DocksController(this)) , m_progressAssistant(new JobProgressAssistant(mainWindow)) , m_currentItem(nullptr) - , m_mainWindow(mainWindow) { - setObjectName("JobView"); - m_docks->initViews(mainWindow->jobModel()); + , m_mainWindow(mainWindow) + , m_activityActions(this) { + setObjectName("JobView"); + createActions(); + createSubWindows(); connectSignals(); } +void JobView::fillViewMenu(QMenu* menu) { + menu->addActions(m_activityActions.actions()); + menu->addSeparator(); + + m_docks->addDockActionsToMenu(menu); + + menu->addSeparator(); + + QAction* action = new QAction(menu); + action->setText("Reset to default layout"); + connect(action, &QAction::triggered, this, &JobView::resetLayout); + menu->addAction(action); +} + void JobView::onFocusRequest(JobItem* jobItem) { if (jobItem->runInBackground()) return; - if (jobItem != m_docks->jobSelector()->currentJobItem()) { - m_docks->jobSelector()->makeJobItemSelected(jobItem); + if (jobItem != m_jobSelector->currentJobItem()) { + m_jobSelector->makeJobItemSelected(jobItem); setAppropriateActivityForJob(jobItem); } @@ -51,70 +70,74 @@ void JobView::onFocusRequest(JobItem* jobItem) { //! Sets docks visibility in accordance with required activity. void JobView::setActivity(int activity) { - m_docks->setActivity(activity); - emit activityChanged(activity); -} + QVector<JobViewFlags::Dock> docksToShow = + JobViewActivities::activeDocks(JobViewFlags::Activity(activity)); -//! Creates global dock menu at cursor position. + std::vector<int> docks_id; + for (auto x : docksToShow) + docks_id.push_back(static_cast<int>(x)); -void JobView::onDockMenuRequest() { - std::unique_ptr<QMenu> menu(createPopupMenu()); - menu->exec(QCursor::pos()); + m_docks->setVisibleDocks(docks_id); + m_activityActions.actions()[activity]->setChecked(true); + emit activityChanged(activity); } //! Propagates change in JobItem's selection down into main widgets. void JobView::onSelectionChanged(JobItem* jobItem) { - m_docks->setItem(jobItem); + m_jobOutputDataWidget->setItem(jobItem); + m_jobRealTimeWidget->setItem(jobItem); + m_fitActivityPanel->setItem(jobItem); } -void JobView::showEvent(QShowEvent* event) { - if (isVisible()) - m_statusBar->show(); +void JobView::createSubWindows() { + m_jobOutputDataWidget = new JobOutputDataWidget(m_mainWindow->jobModel(), this); + m_jobSelector = new JobSelectorWidget(m_mainWindow->jobModel(), this); + m_jobRealTimeWidget = new JobRealTimeWidget(m_mainWindow->jobModel(), this); + m_fitActivityPanel = new FitActivityPanel(m_mainWindow->jobModel(), this); + m_jobMessagePanel = new JobMessagePanel(this); - Manhattan::FancyMainWindow::showEvent(event); -} + m_docks->addWidget(JobViewFlags::JOB_LIST_DOCK, m_jobSelector, Qt::LeftDockWidgetArea); + m_docks->addWidget(JobViewFlags::REAL_TIME_DOCK, m_jobRealTimeWidget, Qt::RightDockWidgetArea); + m_docks->addWidget(JobViewFlags::FIT_PANEL_DOCK, m_fitActivityPanel, Qt::RightDockWidgetArea); + m_docks->addWidget(JobViewFlags::JOB_MESSAGE_DOCK, m_jobMessagePanel, Qt::BottomDockWidgetArea); + + connect(m_jobMessagePanel, &JobMessagePanel::widgetHeightRequest, m_docks, + &DocksController::setDockHeightForWidget); -void JobView::hideEvent(QHideEvent* event) { - if (isHidden()) - m_statusBar->hide(); + m_fitActivityPanel->setRealTimeWidget(m_jobRealTimeWidget); + m_fitActivityPanel->setJobMessagePanel(m_jobMessagePanel); - Manhattan::FancyMainWindow::hideEvent(event); + setCentralWidget(m_jobOutputDataWidget); + + resetLayout(); +} + +void JobView::createActions() { + int activity = 0; + for (auto activityName : JobViewActivities::activityList()) { + QAction* action = new QAction(this); + action->setText(activityName); + action->setCheckable(true); + connect(action, &QAction::triggered, [=]() { setActivity(activity); }); + m_activityActions.addAction(action); + activity++; + } } void JobView::connectSignals() { connectActivityRelated(); - connectLayoutRelated(); connectJobRelated(); } //! Connects signal related to activity change. void JobView::connectActivityRelated() { - // Change activity requests: JobViewStatusBar -> this - connect(m_statusBar, &JobViewStatusBar::changeActivityRequest, this, &JobView::setActivity); - - // Activity was changed: this -> JobViewStatusBar - connect(this, &JobView::activityChanged, m_statusBar, &JobViewStatusBar::onActivityChanged); - // Activity was changed: this -> JobOutputDataWidget - connect(this, &JobView::activityChanged, m_docks->jobOutputDataWidget(), + connect(this, &JobView::activityChanged, m_jobOutputDataWidget, &JobOutputDataWidget::onActivityChanged); } -//! Connects signals related to dock layout. - -void JobView::connectLayoutRelated() { - connect(this, &JobView::resetLayout, m_docks, &JobViewDocks::onResetLayout); - - // Toggling of JobSelector request: JobViewStatusBar -> this - connect(m_statusBar, &JobViewStatusBar::toggleJobSelectorRequest, m_docks, - &JobViewDocks::onToggleJobSelector); - - // Dock menu request: JobViewStatusBar -> this - connect(m_statusBar, &JobViewStatusBar::dockMenuRequest, this, &JobView::onDockMenuRequest); -} - //! Connects signals related to JobItem void JobView::connectJobRelated() { @@ -122,7 +145,7 @@ void JobView::connectJobRelated() { connect(m_mainWindow->jobModel(), &JobModel::focusRequest, this, &JobView::onFocusRequest); // JobItem selection: JobSelectorWidget -> this - connect(m_docks->jobSelector(), &JobSelectorWidget::selectionChanged, this, + connect(m_jobSelector, &JobSelectorWidget::selectionChanged, this, &JobView::onSelectionChanged); } @@ -135,3 +158,8 @@ void JobView::setAppropriateActivityForJob(JobItem* jobItem) { if (jobItem->isValidForFitting()) setActivity(JobViewFlags::FITTING_ACTIVITY); } + +void JobView::resetLayout() { + m_docks->resetLayout(); + setActivity(static_cast<int>(JobViewFlags::JOB_VIEW_ACTIVITY)); +} diff --git a/GUI/coregui/Views/JobView.h b/GUI/coregui/Views/JobView.h index 2d3b2a0d8a97ad7b27bdf99d00d415b867252464..9710c68ef5e6bbfb509e0aa1fd527c651e57a5bb 100644 --- a/GUI/coregui/Views/JobView.h +++ b/GUI/coregui/Views/JobView.h @@ -15,23 +15,31 @@ #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_JOBVIEW_H #define BORNAGAIN_GUI_COREGUI_VIEWS_JOBVIEW_H -#include <qt-manhattan-style/fancymainwindow.h> +#include <QActionGroup> +#include <QMainWindow> class MainWindow; -class JobViewDocks; -class JobViewStatusBar; +class JobView; +class JobSelectorWidget; +class JobOutputDataWidget; +class JobRealTimeWidget; +class FitActivityPanel; +class JobMessagePanel; class JobProgressAssistant; class JobItem; +class DocksController; //! The JobView class is a main view to show list of jobs, job results and widgets for real time //! and fitting activities. -class JobView : public Manhattan::FancyMainWindow { +class JobView : public QMainWindow { Q_OBJECT public: JobView(MainWindow* mainWindow); + void fillViewMenu(QMenu* menu); + signals: void focusRequest(int); void activityChanged(int activity); @@ -39,26 +47,30 @@ signals: public slots: void onFocusRequest(JobItem* jobItem); void setActivity(int activity); - void onDockMenuRequest(); void onSelectionChanged(JobItem* jobItem); -protected: - virtual void showEvent(QShowEvent* event); - virtual void hideEvent(QHideEvent* event); - private: + void createSubWindows(); + void createActions(); void connectSignals(); void connectActivityRelated(); - void connectLayoutRelated(); void connectJobRelated(); void setAppropriateActivityForJob(JobItem* jobItem); + void resetLayout(); - JobViewDocks* m_docks; - JobViewStatusBar* m_statusBar; + DocksController* m_docks; JobProgressAssistant* m_progressAssistant; JobItem* m_currentItem; MainWindow* m_mainWindow; + + JobSelectorWidget* m_jobSelector = nullptr; + JobOutputDataWidget* m_jobOutputDataWidget = nullptr; + JobRealTimeWidget* m_jobRealTimeWidget = nullptr; + FitActivityPanel* m_fitActivityPanel = nullptr; + JobMessagePanel* m_jobMessagePanel = nullptr; + + QActionGroup m_activityActions; }; #endif // BORNAGAIN_GUI_COREGUI_VIEWS_JOBVIEW_H diff --git a/GUI/coregui/Views/JobWidgets/JobListViewDelegate.cpp b/GUI/coregui/Views/JobWidgets/JobListViewDelegate.cpp index 0caf37ee485d64b04a4566d7aa3d1c8f78920c6e..85135d7b1c1452e092d83f6cba6cb61c30227409 100644 --- a/GUI/coregui/Views/JobWidgets/JobListViewDelegate.cpp +++ b/GUI/coregui/Views/JobWidgets/JobListViewDelegate.cpp @@ -22,7 +22,6 @@ #include <QPainter> #include <QStyleOptionProgressBarV2> #include <QWidget> -#include <qt-manhattan-style/progressbar.h> JobListViewDelegate::JobListViewDelegate(QWidget* parent) : QItemDelegate(parent) { m_buttonState = QStyle::State_Enabled; diff --git a/GUI/coregui/Views/JobWidgets/JobViewDocks.cpp b/GUI/coregui/Views/JobWidgets/JobViewDocks.cpp deleted file mode 100644 index 956cf794047a7c66eba298ea3ac52ff84feeb65d..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/JobWidgets/JobViewDocks.cpp +++ /dev/null @@ -1,118 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/JobWidgets/JobViewDocks.cpp -//! @brief Implements class JobViewDocks -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/coregui/Views/JobWidgets/JobViewDocks.h" -#include "GUI/coregui/Models/JobModel.h" -#include "GUI/coregui/Views/FitWidgets/FitActivityPanel.h" -#include "GUI/coregui/Views/JobView.h" -#include "GUI/coregui/Views/JobWidgets/JobMessagePanel.h" -#include "GUI/coregui/Views/JobWidgets/JobOutputDataWidget.h" -#include "GUI/coregui/Views/JobWidgets/JobRealTimeWidget.h" -#include "GUI/coregui/Views/JobWidgets/JobSelectorWidget.h" -#include "GUI/coregui/Views/JobWidgets/JobViewActivities.h" -#include <QDockWidget> - -namespace { -const JobViewFlags::Activity default_activity = JobViewFlags::JOB_VIEW_ACTIVITY; -} - -JobViewDocks::JobViewDocks(JobView* parent) - : DocksController(parent) - , m_jobSelector(nullptr) - , m_jobOutputDataWidget(nullptr) - , m_jobRealTimeWidget(nullptr) - , m_fitActivityPanel(nullptr) - , m_jobMessagePanel(nullptr) - , m_jobView(parent) {} - -void JobViewDocks::initViews(JobModel* jobModel) { - m_jobOutputDataWidget = new JobOutputDataWidget(jobModel, m_jobView); - - m_jobSelector = new JobSelectorWidget(jobModel, m_jobView); - addWidget(JobViewFlags::JOB_LIST_DOCK, m_jobSelector, Qt::LeftDockWidgetArea); - - m_jobRealTimeWidget = new JobRealTimeWidget(jobModel, m_jobView); - addWidget(JobViewFlags::REAL_TIME_DOCK, m_jobRealTimeWidget, Qt::RightDockWidgetArea); - - m_fitActivityPanel = new FitActivityPanel(jobModel, m_jobView); - addWidget(JobViewFlags::FIT_PANEL_DOCK, m_fitActivityPanel, Qt::RightDockWidgetArea); - - m_jobMessagePanel = new JobMessagePanel(m_jobView); - connect(m_jobMessagePanel, &JobMessagePanel::widgetHeightRequest, this, - &DocksController::setDockHeightForWidget); - connect(m_jobMessagePanel, &JobMessagePanel::widgetCloseRequest, this, - &JobViewDocks::onWidgetCloseRequest); - - addWidget(JobViewFlags::JOB_MESSAGE_DOCK, m_jobMessagePanel, Qt::BottomDockWidgetArea); - - m_fitActivityPanel->setRealTimeWidget(m_jobRealTimeWidget); - m_fitActivityPanel->setJobMessagePanel(m_jobMessagePanel); - - m_jobView->setCentralWidget(m_jobOutputDataWidget); - - onResetLayout(); -} - -JobRealTimeWidget* JobViewDocks::jobRealTimeWidget() { - return m_jobRealTimeWidget; -} - -FitActivityPanel* JobViewDocks::fitActivityPanel() { - return m_fitActivityPanel; -} - -JobSelectorWidget* JobViewDocks::jobSelector() { - return m_jobSelector; -} - -JobOutputDataWidget* JobViewDocks::jobOutputDataWidget() { - return m_jobOutputDataWidget; -} - -JobMessagePanel* JobViewDocks::jobMessagePanel() { - return m_jobMessagePanel; -} - -//! Sets docks visibility so they match the activity flag. - -void JobViewDocks::setActivity(int activity) { - QVector<JobViewFlags::Dock> docksToShow = - JobViewActivities::activeDocks(JobViewFlags::Activity(activity)); - - std::vector<int> docks_id; - for (auto x : docksToShow) - docks_id.push_back(static_cast<int>(x)); - - show_docks(docks_id); -} - -void JobViewDocks::setItem(JobItem* jobItem) { - jobOutputDataWidget()->setItem(jobItem); - jobRealTimeWidget()->setItem(jobItem); - fitActivityPanel()->setItem(jobItem); -} - -//! Sets the state of JobView to the default. - -void JobViewDocks::onResetLayout() { - DocksController::onResetLayout(); - setActivity(static_cast<int>(default_activity)); -} - -//! Shows/hides JobSelectorWidget. - -void JobViewDocks::onToggleJobSelector() { - auto selectorDock = findDock(JobViewFlags::JOB_LIST_DOCK); - selectorDock->setHidden(!selectorDock->isHidden()); -} diff --git a/GUI/coregui/Views/JobWidgets/JobViewDocks.h b/GUI/coregui/Views/JobWidgets/JobViewDocks.h deleted file mode 100644 index 74663bc9056394a7660968d91d86228012898f71..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/JobWidgets/JobViewDocks.h +++ /dev/null @@ -1,65 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/JobWidgets/JobViewDocks.h -//! @brief Defines class JobViewDocks -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_JOBVIEWDOCKS_H -#define BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_JOBVIEWDOCKS_H - -#include "GUI/coregui/Views/CommonWidgets/DocksController.h" - -class JobView; -class JobSelectorWidget; -class JobOutputDataWidget; -class JobRealTimeWidget; -class FitActivityPanel; -class JobMessagePanel; -class JobModel; -class JobItem; - -//! The JobViewDocks class assists JobView in holding all main job widgets and corresponding -//! dock containers. - -//! It's main method setActivity handles visibility logic for all of (JobSelectorWidget, -//! JobOutputDataWidget, JobRealTimeWidget and FitPanelWidget). - -class JobViewDocks : public DocksController { - Q_OBJECT - -public: - JobViewDocks(JobView* parent = nullptr); - - void initViews(JobModel* jobModel); - - JobRealTimeWidget* jobRealTimeWidget(); - FitActivityPanel* fitActivityPanel(); - JobSelectorWidget* jobSelector(); - JobOutputDataWidget* jobOutputDataWidget(); - JobMessagePanel* jobMessagePanel(); - - void setActivity(int activity); - void setItem(JobItem* jobItem); - -public slots: - void onResetLayout() override; - void onToggleJobSelector(); - -private: - JobSelectorWidget* m_jobSelector; - JobOutputDataWidget* m_jobOutputDataWidget; - JobRealTimeWidget* m_jobRealTimeWidget; - FitActivityPanel* m_fitActivityPanel; - JobMessagePanel* m_jobMessagePanel; - JobView* m_jobView; -}; - -#endif // BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_JOBVIEWDOCKS_H diff --git a/GUI/coregui/Views/JobWidgets/JobViewStatusBar.cpp b/GUI/coregui/Views/JobWidgets/JobViewStatusBar.cpp deleted file mode 100644 index 1102f0ad1cde0340acf928a5893fb9f8984cec32..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/JobWidgets/JobViewStatusBar.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/JobWidgets/JobViewStatusBar.cpp -//! @brief Implements class JobViewStatusBar -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/coregui/Views/JobWidgets/JobViewStatusBar.h" -#include "Base/Utils/Assert.h" -#include "GUI/coregui/Views/JobWidgets/JobViewActivities.h" -#include "GUI/coregui/mainwindow/mainwindow.h" -#include <QComboBox> -#include <QHBoxLayout> -#include <QStatusBar> -#include <QToolButton> - -JobViewStatusBar::JobViewStatusBar(MainWindow* mainWindow) - : QWidget(mainWindow) - , m_toggleJobListButton(nullptr) - , m_activityCombo(nullptr) - , m_dockMenuButton(nullptr) - , m_mainWindow(mainWindow) { - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - auto layout = new QHBoxLayout; - layout->setContentsMargins(5, 2, 5, 2); - - m_toggleJobListButton = new QToolButton; - m_toggleJobListButton->setText("Job List"); - m_toggleJobListButton->setIcon(QIcon(":/images/statusbar_joblist.svg")); - m_toggleJobListButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - m_toggleJobListButton->setToolTip("Toggle job list view"); - connect(m_toggleJobListButton, &QToolButton::clicked, this, - &JobViewStatusBar::toggleJobSelectorRequest); - - m_activityCombo = new QComboBox(); - m_activityCombo->setToolTip("Main Activity Selector"); - m_activityCombo->addItems(JobViewActivities::activityList()); - connect(m_activityCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - this, &JobViewStatusBar::changeActivityRequest); - - m_dockMenuButton = new QToolButton; - m_dockMenuButton->setIcon(QIcon(":/images/menu-open.svg")); - m_dockMenuButton->setToolTip("Docks layout menu"); - connect(m_dockMenuButton, &QToolButton::clicked, this, &JobViewStatusBar::dockMenuRequest); - - layout->addWidget(m_toggleJobListButton); - layout->addStretch(); - layout->addWidget(m_activityCombo); - layout->addWidget(m_dockMenuButton); - - setLayout(layout); - initAppearance(); -} - -void JobViewStatusBar::onActivityChanged(int activity) { - disconnect(m_activityCombo, - static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, - &JobViewStatusBar::changeActivityRequest); - - m_activityCombo->setCurrentIndex(activity); - - connect(m_activityCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - this, &JobViewStatusBar::changeActivityRequest); -} - -//! Init appearance of MainWindow's statusBar. - -void JobViewStatusBar::initAppearance() { - ASSERT(m_mainWindow); - m_mainWindow->statusBar()->addWidget(this, 1); - m_mainWindow->statusBar()->setSizeGripEnabled(false); - this->hide(); -} diff --git a/GUI/coregui/Views/JobWidgets/JobViewStatusBar.h b/GUI/coregui/Views/JobWidgets/JobViewStatusBar.h deleted file mode 100644 index 5c9db029faaeeb5a422bfa4ba9fa10b661ff5bbd..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/JobWidgets/JobViewStatusBar.h +++ /dev/null @@ -1,49 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/JobWidgets/JobViewStatusBar.h -//! @brief Defines class JobViewStatusBar -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_JOBVIEWSTATUSBAR_H -#define BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_JOBVIEWSTATUSBAR_H - -#include <QWidget> - -class MainWindow; -class QToolButton; -class QComboBox; - -//! Narrow status bar at very bottom of JobView to switch between activities. -//! Added to the status bar of MainWindow when JobView is shown. - -class JobViewStatusBar : public QWidget { - Q_OBJECT -public: - JobViewStatusBar(MainWindow* mainWindow); - -signals: - void toggleJobSelectorRequest(); - void changeActivityRequest(int); - void dockMenuRequest(); - -public slots: - void onActivityChanged(int activity); - -private: - void initAppearance(); - - QToolButton* m_toggleJobListButton; - QComboBox* m_activityCombo; - QToolButton* m_dockMenuButton; - MainWindow* m_mainWindow; -}; - -#endif // BORNAGAIN_GUI_COREGUI_VIEWS_JOBWIDGETS_JOBVIEWSTATUSBAR_H diff --git a/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp b/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp index c529e94d7062fc98ac9f21237069da188a5b74de..417b683e0fc0f5f1bef82c56949716f54c320002 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp +++ b/GUI/coregui/Views/SampleDesigner/SampleToolBar.cpp @@ -15,7 +15,7 @@ #include "GUI/coregui/Views/SampleDesigner/SampleToolBar.h" #include "GUI/coregui/Views/MaterialEditor/MaterialItemUtils.h" #include "GUI/coregui/Views/SampleDesigner/DesignerView.h" -#include "GUI/coregui/Views/SampleDesigner/SampleViewActions.h" +#include "GUI/coregui/Views/SampleView.h" #include <QAction> #include <QButtonGroup> #include <QComboBox> @@ -26,8 +26,7 @@ #include <QToolButton> //! main tool bar on top of SampleView window -SampleToolBar::SampleToolBar(SampleViewActions* sampleActions, QWidget* parent) - : StyledToolBar(parent), m_sampleViewActions(sampleActions) { +SampleToolBar::SampleToolBar(SampleView* parent) : StyledToolBar(parent), m_sampleView(parent) { // Select & Pan auto selectionPointerButton = new QToolButton; selectionPointerButton->setCheckable(true); @@ -118,8 +117,8 @@ SampleToolBar::SampleToolBar(SampleViewActions* sampleActions, QWidget* parent) m_RealSpaceViewerButton->setText("3D Viewer"); m_RealSpaceViewerButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); m_RealSpaceViewerButton->setToolTip("Open real space 3D viewer."); - connect(m_RealSpaceViewerButton, &QToolButton::clicked, m_sampleViewActions, - &SampleViewActions::onToggleRealSpaceView); + connect(m_RealSpaceViewerButton, &QToolButton::clicked, m_sampleView, + &SampleView::toggleRealSpaceView); addWidget(m_RealSpaceViewerButton); } diff --git a/GUI/coregui/Views/SampleDesigner/SampleToolBar.h b/GUI/coregui/Views/SampleDesigner/SampleToolBar.h index f88d884e4a01debcf15d765a3731c81ddcd388dc..bc4e43510befde72baf45cdf352be76a809f678b 100644 --- a/GUI/coregui/Views/SampleDesigner/SampleToolBar.h +++ b/GUI/coregui/Views/SampleDesigner/SampleToolBar.h @@ -25,7 +25,7 @@ class QComboBox; class QString; class QButtonGroup; class SampleModel; -class SampleViewActions; +class SampleView; //! The SampleToolBar class represents a main toolbar on top of SampleView window @@ -33,7 +33,7 @@ class SampleToolBar : public StyledToolBar { Q_OBJECT public: - explicit SampleToolBar(SampleViewActions* sampleActions = nullptr, QWidget* parent = nullptr); + explicit SampleToolBar(SampleView* parent); signals: void deleteItems(); @@ -54,7 +54,7 @@ private: QComboBox* m_scaleCombo; QToolButton* m_materialEditorButton; QToolButton* m_RealSpaceViewerButton; - SampleViewActions* m_sampleViewActions; + SampleView* m_sampleView; }; #endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLETOOLBAR_H diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewActions.cpp b/GUI/coregui/Views/SampleDesigner/SampleViewActions.cpp deleted file mode 100644 index cb0eb5bd35e1fcf89f9550448816dfa18514a054..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/SampleDesigner/SampleViewActions.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/SampleDesigner/SampleViewActions.cpp -//! @brief Implements class SampleViewActions -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/coregui/Views/SampleDesigner/SampleViewActions.h" -#include "GUI/coregui/Views/SampleDesigner/SampleViewDocks.h" -#include "GUI/coregui/Views/SampleView.h" -#include <QAction> -#include <QDockWidget> - -SampleViewActions::SampleViewActions(SampleModel* model, SampleView* parent) - : QObject(parent), m_model(model), m_sampleView(parent), m_selection_model(nullptr) {} - -void SampleViewActions::setSelectionModel(QItemSelectionModel* selection_model) { - m_selection_model = selection_model; -} - -SampleModel* SampleViewActions::sampleModel() { - return m_model; -} - -QItemSelectionModel* SampleViewActions::selectionModel() { - return m_selection_model; -} - -void SampleViewActions::onToggleRealSpaceView() { - m_sampleView->docks()->toggleDock(SampleViewDocks::REALSPACEPANEL); -} diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewActions.h b/GUI/coregui/Views/SampleDesigner/SampleViewActions.h deleted file mode 100644 index e3ab38c8c593b5488271182a40a0a84376cbbae3..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/SampleDesigner/SampleViewActions.h +++ /dev/null @@ -1,46 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/SampleDesigner/SampleViewActions.h -//! @brief Defines class SampleViewActions -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWACTIONS_H -#define BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWACTIONS_H - -#include <QObject> - -class SampleModel; -class QItemSelectionModel; -class SampleView; - -//! Holds all actions of SampleView. - -class SampleViewActions : public QObject { - Q_OBJECT -public: - SampleViewActions(SampleModel* model, SampleView* parent); - - void setSelectionModel(QItemSelectionModel* selection_model); - - SampleModel* sampleModel(); - - QItemSelectionModel* selectionModel(); - -public slots: - void onToggleRealSpaceView(); - -private: - SampleModel* m_model; - SampleView* m_sampleView; - QItemSelectionModel* m_selection_model; -}; - -#endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWACTIONS_H diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewDocks.cpp b/GUI/coregui/Views/SampleDesigner/SampleViewDocks.cpp deleted file mode 100644 index 97240d4b04e7d707ce642f6ce86ca21a28c96ad8..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/SampleDesigner/SampleViewDocks.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/SampleDesigner/SampleViewDocks.cpp -//! @brief Defines class SampleViewDocks -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/coregui/Views/SampleDesigner/SampleViewDocks.h" -#include "GUI/coregui/Models/ApplicationModels.h" -#include "GUI/coregui/Models/FilterPropertyProxy.h" -#include "GUI/coregui/Views/SampleDesigner/RealSpacePanel.h" -#include "GUI/coregui/Views/SampleDesigner/SampleDesigner.h" -#include "GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.h" -#include "GUI/coregui/Views/SampleDesigner/SampleTreeWidget.h" -#include "GUI/coregui/Views/SampleDesigner/SampleWidgetBox.h" -#include "GUI/coregui/Views/SampleDesigner/ScriptPanel.h" -#include "GUI/coregui/Views/SampleView.h" -#include <QAction> -#include <QDockWidget> -#include <QTreeView> - -SampleViewDocks::SampleViewDocks(SampleView* parent) - : DocksController(parent) - , m_sampleDesigner(new SampleDesigner(parent)) - , m_widgetBox(new SampleWidgetBox(sampleDesigner(), parent)) - , m_treeWidget(new SampleTreeWidget(parent, parent->models()->sampleModel())) - , m_propertyWidget(new SamplePropertyWidget(m_treeWidget->treeView()->selectionModel(), parent)) - , m_scriptPanel(new ScriptPanel(parent)) - , m_realSpacePanel(new RealSpacePanel(parent->models()->sampleModel(), - m_treeWidget->treeView()->selectionModel(), parent)) { - addWidget(WIDGET_BOX, m_widgetBox, Qt::LeftDockWidgetArea); - addWidget(SAMPLE_TREE, m_treeWidget, Qt::RightDockWidgetArea); - addWidget(PROPERTY_EDITOR, m_propertyWidget, Qt::RightDockWidgetArea); - addWidget(INFO, m_scriptPanel, Qt::BottomDockWidgetArea); - addWidget(REALSPACEPANEL, m_realSpacePanel, Qt::BottomDockWidgetArea); - - connect(m_scriptPanel, &ScriptPanel::widgetHeightRequest, this, - &DocksController::setDockHeightForWidget); - connect(m_scriptPanel, &ScriptPanel::widgetCloseRequest, this, - &SampleViewDocks::onWidgetCloseRequest); - - m_scriptPanel->setSampleModel(parent->models()->sampleModel()); - m_scriptPanel->setInstrumentModel(parent->models()->instrumentModel()); - - m_sampleDesigner->setModels(parent->models()); - m_sampleDesigner->setSelectionModel( - m_treeWidget->treeView()->selectionModel(), - dynamic_cast<FilterPropertyProxy*>( - const_cast<QAbstractItemModel*>(m_treeWidget->treeView()->model()))); - - parent->setCentralWidget(m_sampleDesigner->getCentralWidget()); - onResetLayout(); -} - -SampleWidgetBox* SampleViewDocks::widgetBox() { - return m_widgetBox; -} - -SampleTreeWidget* SampleViewDocks::treeWidget() { - return m_treeWidget; -} - -SamplePropertyWidget* SampleViewDocks::propertyWidget() { - return m_propertyWidget; -} - -void SampleViewDocks::onResetLayout() { - DocksController::onResetLayout(); - mainWindow()->tabifyDockWidget(findDock(REALSPACEPANEL), findDock(INFO)); - findDock(REALSPACEPANEL)->raise(); // makes first tab active - - findDock(REALSPACEPANEL)->hide(); - findDock(INFO)->hide(); -} - -void SampleViewDocks::toggleDock(int id) { - auto dock = findDock(id); - dock->setHidden(!dock->isHidden()); -} - -SampleDesigner* SampleViewDocks::sampleDesigner() { - return m_sampleDesigner; -} diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewDocks.h b/GUI/coregui/Views/SampleDesigner/SampleViewDocks.h deleted file mode 100644 index fe2d0d615c1453927c3cba9738f3eb98fd5426bf..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/SampleDesigner/SampleViewDocks.h +++ /dev/null @@ -1,64 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/SampleDesigner/SampleViewDocks.h -//! @brief Defines class SampleViewDocks -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWDOCKS_H -#define BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWDOCKS_H - -#include "GUI/coregui/Views/CommonWidgets/DocksController.h" - -class SampleView; -class SampleWidgetBox; -class SampleTreeWidget; -class SamplePropertyWidget; -class SampleDesigner; -class ScriptPanel; -class RealSpacePanel; -class QAction; - -//! Holds all docked widgets for SampleView. - -class SampleViewDocks : public DocksController { - Q_OBJECT - -public: - enum ESubWindows { - WIDGET_BOX, - SAMPLE_TREE, - PROPERTY_EDITOR, - INFO, - REALSPACEPANEL, - NUMBER_OF_SUB_WINDOWS - }; - - SampleViewDocks(SampleView* parent = nullptr); - - SampleDesigner* sampleDesigner(); - SampleWidgetBox* widgetBox(); - SampleTreeWidget* treeWidget(); - SamplePropertyWidget* propertyWidget(); - - void onResetLayout() override; - - void toggleDock(int id); - -private: - SampleDesigner* m_sampleDesigner; - SampleWidgetBox* m_widgetBox; - SampleTreeWidget* m_treeWidget; - SamplePropertyWidget* m_propertyWidget; - ScriptPanel* m_scriptPanel; - RealSpacePanel* m_realSpacePanel; -}; - -#endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWDOCKS_H diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.cpp b/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.cpp deleted file mode 100644 index c837a822be03025f56a4631286a1dd555da75e83..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.cpp -//! @brief Implements class SampleViewActivityStatusBar -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h" -#include "Base/Utils/Assert.h" -#include "GUI/coregui/mainwindow/mainwindow.h" -#include <QHBoxLayout> -#include <QStatusBar> -#include <QToolButton> - -SampleViewStatusBar::SampleViewStatusBar(MainWindow* mainWindow) - : QWidget(mainWindow), m_dockMenuButton(nullptr), m_mainWindow(mainWindow) { - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - auto layout = new QHBoxLayout; - layout->setContentsMargins(0, 1, 5, 1); - - m_dockMenuButton = new QToolButton; - m_dockMenuButton->setIcon(QIcon(":/images/menu-open.svg")); - m_dockMenuButton->setToolTip("Docks layout menu"); - connect(m_dockMenuButton, &QToolButton::clicked, this, &SampleViewStatusBar::dockMenuRequest); - - layout->addStretch(); - layout->addWidget(m_dockMenuButton); - - setLayout(layout); - initAppearance(); -} - -//! Init appearance of MainWindow's statusBar. - -void SampleViewStatusBar::initAppearance() { - ASSERT(m_mainWindow); - m_mainWindow->statusBar()->addWidget(this, 1); - m_mainWindow->statusBar()->setSizeGripEnabled(false); - this->hide(); -} diff --git a/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h b/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h deleted file mode 100644 index b54ef00c91a6a0801ab52befaf8723bfea47bda5..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h +++ /dev/null @@ -1,41 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h -//! @brief Defines class SampleViewStatusBar -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2018 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#ifndef BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWSTATUSBAR_H -#define BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWSTATUSBAR_H - -#include <QWidget> - -class MainWindow; -class QToolButton; -class QComboBox; - -//! Narrow status bar at very bottom of SampleView to access dock menu. - -class SampleViewStatusBar : public QWidget { - Q_OBJECT -public: - SampleViewStatusBar(MainWindow* mainWindow); - -signals: - void dockMenuRequest(); - -private: - void initAppearance(); - - QToolButton* m_dockMenuButton; - MainWindow* m_mainWindow; -}; - -#endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEDESIGNER_SAMPLEVIEWSTATUSBAR_H diff --git a/GUI/coregui/Views/SampleView.cpp b/GUI/coregui/Views/SampleView.cpp index 07e9941409c37d857da18630fcc271cfde7e0d3c..3a0b9ef5746f699c2b6869df16a42453bda6968b 100644 --- a/GUI/coregui/Views/SampleView.cpp +++ b/GUI/coregui/Views/SampleView.cpp @@ -13,82 +13,104 @@ // ************************************************************************************************ #include "GUI/coregui/Views/SampleView.h" +#include "Base/Utils/Assert.h" #include "GUI/coregui/Models/ApplicationModels.h" +#include "GUI/coregui/Models/FilterPropertyProxy.h" +#include "GUI/coregui/Views/CommonWidgets/DocksController.h" +#include "GUI/coregui/Views/SampleDesigner/RealSpacePanel.h" #include "GUI/coregui/Views/SampleDesigner/SampleDesigner.h" +#include "GUI/coregui/Views/SampleDesigner/SamplePropertyWidget.h" #include "GUI/coregui/Views/SampleDesigner/SampleToolBar.h" #include "GUI/coregui/Views/SampleDesigner/SampleTreeWidget.h" -#include "GUI/coregui/Views/SampleDesigner/SampleViewActions.h" -#include "GUI/coregui/Views/SampleDesigner/SampleViewDocks.h" -#include "GUI/coregui/Views/SampleDesigner/SampleViewStatusBar.h" +#include "GUI/coregui/Views/SampleDesigner/SampleWidgetBox.h" +#include "GUI/coregui/Views/SampleDesigner/ScriptPanel.h" #include "GUI/coregui/mainwindow/mainwindow.h" +#include <QDockWidget> #include <QMenu> #include <memory> SampleView::SampleView(MainWindow* mainWindow) - : Manhattan::FancyMainWindow(mainWindow) - , m_models(mainWindow->models()) - , m_docks(new SampleViewDocks(this)) - , m_actions(new SampleViewActions(mainWindow->models()->sampleModel(), this)) - , m_toolBar(nullptr) - , m_statusBar(new SampleViewStatusBar(mainWindow)) { - setObjectName("SampleView"); - m_actions->setSelectionModel(selectionModel()); + : QMainWindow(mainWindow), m_docks(new DocksController(this)) { + setObjectName("SampleView"); + createSubWindows(); connectSignals(); } ApplicationModels* SampleView::models() { - return m_models; + return MainWindow::instance()->models(); } -SampleViewDocks* SampleView::docks() { - return m_docks; +void SampleView::toggleRealSpaceView() { + m_docks->toggleDock(REALSPACEPANEL); } -void SampleView::onDockMenuRequest() { - std::unique_ptr<QMenu> menu(createPopupMenu()); - menu->exec(QCursor::pos()); -} +void SampleView::fillViewMenu(QMenu* menu) { + m_docks->addDockActionsToMenu(menu); -void SampleView::showEvent(QShowEvent* event) { - if (isVisible()) - m_statusBar->show(); - Manhattan::FancyMainWindow::showEvent(event); + menu->addSeparator(); + + QAction* action = new QAction(menu); + action->setText("Reset to default layout"); + connect(action, &QAction::triggered, this, &SampleView::resetLayout); + menu->addAction(action); } -void SampleView::hideEvent(QHideEvent* event) { - if (isHidden()) - m_statusBar->hide(); - Manhattan::FancyMainWindow::hideEvent(event); +void SampleView::createSubWindows() { + m_sampleDesigner = new SampleDesigner(this); + m_widgetBox = new SampleWidgetBox(m_sampleDesigner, this); + m_treeWidget = new SampleTreeWidget(this, models()->sampleModel()); + m_propertyWidget = new SamplePropertyWidget(m_treeWidget->treeView()->selectionModel(), this); + m_scriptPanel = new ScriptPanel(this); + m_realSpacePanel = new RealSpacePanel(models()->sampleModel(), + m_treeWidget->treeView()->selectionModel(), this); + + m_docks->addWidget(WIDGET_BOX, m_widgetBox, Qt::LeftDockWidgetArea); + m_docks->addWidget(SAMPLE_TREE, m_treeWidget, Qt::RightDockWidgetArea); + m_docks->addWidget(PROPERTY_EDITOR, m_propertyWidget, Qt::RightDockWidgetArea); + m_docks->addWidget(INFO, m_scriptPanel, Qt::BottomDockWidgetArea); + m_docks->addWidget(REALSPACEPANEL, m_realSpacePanel, Qt::BottomDockWidgetArea); + + connect(m_scriptPanel, &ScriptPanel::widgetHeightRequest, m_docks, + &DocksController::setDockHeightForWidget); + + m_scriptPanel->setSampleModel(models()->sampleModel()); + m_scriptPanel->setInstrumentModel(models()->instrumentModel()); + + m_sampleDesigner->setModels(models()); + m_sampleDesigner->setSelectionModel( + m_treeWidget->treeView()->selectionModel(), + dynamic_cast<FilterPropertyProxy*>( + const_cast<QAbstractItemModel*>(m_treeWidget->treeView()->model()))); + + setCentralWidget(m_sampleDesigner->getCentralWidget()); + resetLayout(); } void SampleView::connectSignals() { - connect(this, &SampleView::resetLayout, m_docks, &SampleViewDocks::onResetLayout); - connect(m_statusBar, &SampleViewStatusBar::dockMenuRequest, this, - &SampleView::onDockMenuRequest); - // toolBar should be initialized after MaterialBrowser - m_toolBar = new SampleToolBar(m_actions, this); - connect(m_toolBar, SIGNAL(deleteItems()), sampleDesigner()->getView(), - SLOT(deleteSelectedItems())); - connect(m_toolBar, SIGNAL(selectionMode(int)), sampleDesigner()->getView(), - SLOT(onSelectionMode(int))); - connect(sampleDesigner()->getView(), SIGNAL(selectionModeChanged(int)), m_toolBar, - SLOT(onViewSelectionMode(int))); - connect(m_toolBar, SIGNAL(centerView()), sampleDesigner()->getView(), SLOT(onCenterView())); - connect(m_toolBar, SIGNAL(changeScale(double)), sampleDesigner()->getView(), - SLOT(onChangeScale(double))); - - connect(sampleDesigner()->getScene(), SIGNAL(selectionModeChangeRequest(int)), - sampleDesigner()->getView(), SLOT(onSelectionMode(int))); + m_toolBar = new SampleToolBar(this); + connect(m_toolBar, &SampleToolBar::deleteItems, m_sampleDesigner->getView(), + &DesignerView::deleteSelectedItems); + connect(m_toolBar, &SampleToolBar::selectionMode, m_sampleDesigner->getView(), + &DesignerView::onSelectionMode); + connect(m_sampleDesigner->getView(), &DesignerView::selectionModeChanged, m_toolBar, + &SampleToolBar::onViewSelectionMode); + connect(m_toolBar, &SampleToolBar::centerView, m_sampleDesigner->getView(), + &DesignerView::onCenterView); + connect(m_toolBar, &SampleToolBar::changeScale, m_sampleDesigner->getView(), + &DesignerView::onChangeScale); + connect(m_sampleDesigner->getScene(), &DesignerScene::selectionModeChangeRequest, + m_sampleDesigner->getView(), &DesignerView::onSelectionMode); addToolBar(m_toolBar); } -QItemSelectionModel* SampleView::selectionModel() { - return m_docks->treeWidget()->treeView()->selectionModel(); -} +void SampleView::resetLayout() { + m_docks->resetLayout(); + tabifyDockWidget(m_docks->findDock(REALSPACEPANEL), m_docks->findDock(INFO)); + m_docks->findDock(REALSPACEPANEL)->raise(); // makes first tab active -SampleDesigner* SampleView::sampleDesigner() { - return m_docks->sampleDesigner(); + m_docks->findDock(REALSPACEPANEL)->hide(); + m_docks->findDock(INFO)->hide(); } diff --git a/GUI/coregui/Views/SampleView.h b/GUI/coregui/Views/SampleView.h index d8e19bcd5b0fb74a7235bbbe180f13c2dc0ca0a3..e118a5ea35d8ff01c8a804389f8598f4d79cf5cd 100644 --- a/GUI/coregui/Views/SampleView.h +++ b/GUI/coregui/Views/SampleView.h @@ -15,52 +15,45 @@ #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEVIEW_H #define BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEVIEW_H -#include <qt-manhattan-style/fancymainwindow.h> +#include <QMainWindow> class MainWindow; -class SampleViewDocks; +class DocksController; class SampleDesigner; class SampleToolBar; class ApplicationModels; class QItemSelectionModel; -class SampleViewStatusBar; -class QShowEvent; -class QHideEvent; -class SampleViewActions; +class SampleWidgetBox; +class SampleTreeWidget; +class SamplePropertyWidget; +class ScriptPanel; +class RealSpacePanel; -class SampleView : public Manhattan::FancyMainWindow { +class SampleView : public QMainWindow { Q_OBJECT - public: + enum ESubWindows { WIDGET_BOX, SAMPLE_TREE, PROPERTY_EDITOR, INFO, REALSPACEPANEL }; + SampleView(MainWindow* mainWindow); ApplicationModels* models(); - - SampleViewDocks* docks(); - -public slots: - void onDockMenuRequest(); - -protected: - virtual void showEvent(QShowEvent* event); - virtual void hideEvent(QHideEvent* event); + void toggleRealSpaceView(); + void fillViewMenu(QMenu* menu); private: + void createSubWindows(); void connectSignals(); + void resetLayout(); - QItemSelectionModel* selectionModel(); - - ApplicationModels* m_models; - - SampleViewDocks* m_docks; - - SampleDesigner* sampleDesigner(); - - SampleViewActions* m_actions; - - SampleToolBar* m_toolBar; + DocksController* m_docks = nullptr; + SampleToolBar* m_toolBar = nullptr; - SampleViewStatusBar* m_statusBar; + SampleDesigner* m_sampleDesigner = nullptr; + SampleWidgetBox* m_widgetBox = nullptr; + SampleTreeWidget* m_treeWidget = nullptr; + SamplePropertyWidget* m_propertyWidget = nullptr; + ScriptPanel* m_scriptPanel = nullptr; + RealSpacePanel* m_realSpacePanel = nullptr; }; #endif // BORNAGAIN_GUI_COREGUI_VIEWS_SAMPLEVIEW_H diff --git a/GUI/coregui/mainwindow/actionmanager.cpp b/GUI/coregui/mainwindow/actionmanager.cpp index dd36a2cf764d6658a99885640d757240a0cd4749..3edb9924444b8f6b3bc18e86030b7d9521998b82 100644 --- a/GUI/coregui/mainwindow/actionmanager.cpp +++ b/GUI/coregui/mainwindow/actionmanager.cpp @@ -15,6 +15,7 @@ #include "GUI/coregui/mainwindow/actionmanager.h" #include "Base/Utils/Assert.h" #include "Base/Utils/SysUtils.h" +#include "GUI/coregui/Views/CommonWidgets/DocksController.h" #include "GUI/coregui/mainwindow/PyImportAssistant.h" #include "GUI/coregui/mainwindow/UpdateNotifier.h" #include "GUI/coregui/mainwindow/aboutapplicationdialog.h" @@ -23,6 +24,8 @@ #include "GUI/coregui/mainwindow/projectmanager.h" #include "GUI/coregui/utils/hostosinfo.h" #include "GUI/coregui/utils/qstringutils.h" +#include "Views/JobView.h" +#include "Views/SampleView.h" #include <QDir> #include <QMenuBar> #include <QSettings> @@ -40,6 +43,7 @@ ActionManager::ActionManager(MainWindow* parent) , m_menuBar(nullptr) , m_fileMenu(nullptr) , m_settingsMenu(nullptr) + , m_viewMenu(nullptr) , m_recentProjectsMenu(nullptr) , m_helpMenu(nullptr) , m_importMenu(nullptr) @@ -47,6 +51,9 @@ ActionManager::ActionManager(MainWindow* parent) createActions(); createMenus(); createGlobalShortcuts(); + + connect(m_mainWindow, &MainWindow::currentViewChanged, this, + &ActionManager::onCurrentViewChanged); } void ActionManager::createActions() { @@ -102,7 +109,7 @@ void ActionManager::createMenus() { m_fileMenu = m_menuBar->addMenu("&File"); m_fileMenu->addAction(m_newAction); m_fileMenu->addAction(m_openAction); - connect(m_fileMenu, &QMenu::aboutToShow, this, &ActionManager::aboutToShowFileMenu); + connect(m_fileMenu, &QMenu::aboutToShow, this, &ActionManager::onAboutToShowFileMenu); m_recentProjectsMenu = m_fileMenu->addMenu("&Recent Projects"); @@ -130,14 +137,23 @@ void ActionManager::createMenus() { // Settings Menu m_settingsMenu = new QMenu("&Settings", m_mainWindow); - aboutToShowSettings(); // MacOS feature: action should exist already, otherwise menuBar will not - // add menu - connect(m_settingsMenu, &QMenu::aboutToShow, this, &ActionManager::aboutToShowSettings); + onAboutToShowSettingsMenu(); // MacOS feature: action should exist already, otherwise menuBar + // will not add menu + connect(m_settingsMenu, &QMenu::aboutToShow, this, &ActionManager::onAboutToShowSettingsMenu); m_menuBar->addMenu(m_settingsMenu); + // View menu + m_viewMenu = new QMenu("&View", m_mainWindow); + onAboutToShowViewMenu(); // MacOS feature: action should exist already, otherwise menuBar will + // not add menu + connect(m_viewMenu, &QMenu::aboutToShow, this, &ActionManager::onAboutToShowViewMenu); + m_menuBar->addMenu(m_viewMenu); + // Help Menu m_helpMenu = m_menuBar->addMenu("&Help"); m_helpMenu->addAction(m_aboutAction); + + onCurrentViewChanged(); } void ActionManager::createGlobalShortcuts() { @@ -147,7 +163,7 @@ void ActionManager::createGlobalShortcuts() { &MainWindow::onRunSimulationShortcut); } -void ActionManager::aboutToShowFileMenu() { +void ActionManager::onAboutToShowFileMenu() { m_recentProjectsMenu->clear(); bool hasRecentProjects = false; @@ -172,7 +188,7 @@ void ActionManager::aboutToShowFileMenu() { } } -void ActionManager::aboutToShowSettings() { +void ActionManager::onAboutToShowSettingsMenu() { m_settingsMenu->clear(); QSettings settings; @@ -203,6 +219,16 @@ void ActionManager::aboutToShowSettings() { m_settingsMenu->setToolTipsVisible(true); } +void ActionManager::onAboutToShowViewMenu() { + m_viewMenu->clear(); + + auto view = m_mainWindow->currentView(); + if (auto sampleView = dynamic_cast<SampleView*>(view); sampleView != nullptr) + sampleView->fillViewMenu(m_viewMenu); + if (auto jobView = dynamic_cast<JobView*>(view); jobView != nullptr) + jobView->fillViewMenu(m_viewMenu); +} + void ActionManager::toggleCheckForUpdates(bool status) { m_mainWindow->updateNotifier()->setCheckUpdatesFlag(status); m_mainWindow->updateNotifier()->checkForUpdates(); @@ -221,6 +247,13 @@ void ActionManager::onAboutApplication() { dialog.exec(); } +void ActionManager::onCurrentViewChanged() { + // not every view support view menu entries -> hide it, if empty + onAboutToShowViewMenu(); + const bool isEmpty = m_viewMenu->actions().isEmpty(); + m_viewMenu->menuAction()->setVisible(!m_viewMenu->actions().isEmpty()); +} + #ifdef BORNAGAIN_PYTHON void ActionManager::onImportFromPythonScript() { PyImportAssistant assistant(m_mainWindow); diff --git a/GUI/coregui/mainwindow/actionmanager.h b/GUI/coregui/mainwindow/actionmanager.h index 3bce60d22d4804e5131b989f5268118296f5b8dc..424df4255b410766d40f1e1adc399844de0bab9c 100644 --- a/GUI/coregui/mainwindow/actionmanager.h +++ b/GUI/coregui/mainwindow/actionmanager.h @@ -31,11 +31,13 @@ public: ActionManager(MainWindow* parent); private slots: - void aboutToShowFileMenu(); - void aboutToShowSettings(); + void onAboutToShowFileMenu(); + void onAboutToShowSettingsMenu(); + void onAboutToShowViewMenu(); void toggleCheckForUpdates(bool status); void setSessionModelViewActive(bool status); void onAboutApplication(); + void onCurrentViewChanged(); #ifdef BORNAGAIN_PYTHON void onImportFromPythonScript(); #endif // BORNAGAIN_PYTHON @@ -53,6 +55,7 @@ private: QMenuBar* m_menuBar; QMenu* m_fileMenu; QMenu* m_settingsMenu; + QMenu* m_viewMenu; QMenu* m_recentProjectsMenu; QMenu* m_helpMenu; QMenu* m_importMenu; diff --git a/GUI/coregui/mainwindow/mainwindow.cpp b/GUI/coregui/mainwindow/mainwindow.cpp index 1743063167942ceec2d1143d03605f4c1a18e1ad..e2eadcd3ffe5236277a8cc0c98de36e18d9aaf9a 100644 --- a/GUI/coregui/mainwindow/mainwindow.cpp +++ b/GUI/coregui/mainwindow/mainwindow.cpp @@ -41,12 +41,11 @@ #include <QMessageBox> #include <QProgressBar> #include <QSettings> -#include <qt-manhattan-style/stylehelper.h> MainWindow* MainWindow::s_instance = nullptr; MainWindow::MainWindow() - : Manhattan::FancyMainWindow(nullptr) + : QMainWindow(nullptr) , m_progressBar(new QProgressBar) , m_viewSelectionButtons(new QButtonGroup(this)) , m_viewSelectionButtonsLayout(new QVBoxLayout) @@ -81,8 +80,8 @@ MainWindow::MainWindow() fillerButton->setEnabled(false); m_viewSelectionButtonsLayout->insertWidget(-1, fillerButton); - connect(m_viewSelectionButtons, QOverload<int>::of(&QButtonGroup::buttonClicked), - [&](int index) { m_viewsStack->setCurrentIndex(index); }); + connect(m_viewSelectionButtons, QOverload<int>::of(&QButtonGroup::buttonClicked), this, + &MainWindow::setCurrentView); m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); @@ -97,6 +96,8 @@ MainWindow::MainWindow() setCentralWidget(centralWidget); + m_statusBar->hide(); + initApplication(); readSettings(); initProgressBar(); @@ -159,6 +160,17 @@ UpdateNotifier* MainWindow::updateNotifier() { return m_updateNotifier; } +QWidget* MainWindow::currentView() const { + return m_viewsStack->currentWidget(); +} + +void MainWindow::setCurrentView(int viewId) { + if (m_viewsStack->currentIndex() != viewId) { + m_viewsStack->setCurrentIndex(viewId); + emit currentViewChanged(ViewId(viewId)); + } +} + void MainWindow::onFocusRequest(int index) { m_viewSelectionButtons->button(index)->click(); } @@ -216,8 +228,6 @@ void MainWindow::initApplication() { if (!GUI_OS_Utils::HostOsInfo::isMacHost()) QApplication::setWindowIcon(QIcon(":/images/BornAgain.ico")); - Manhattan::Utils::StyleHelper::setBaseColor(QColor(Constants::MAIN_THEME_COLOR)); - setDockNestingEnabled(true); setAcceptDrops(true); @@ -338,6 +348,13 @@ void MainWindow::updateViewSelectionButtonsGeometry() const { b->setFixedSize(buttonExtent, buttonExtent); b->setIconSize({iconExtent, iconExtent}); } + // set fixed width in filler and progress bar + auto filler = m_viewSelectionButtonsLayout->itemAt(m_viewSelectionButtons->buttons().size()); + if (filler) + if (auto fillerBtn = dynamic_cast<QToolButton*>(filler->widget()); fillerBtn) + fillerBtn->setFixedWidth(buttonExtent); + + m_progressBar->setFixedWidth(buttonExtent); } QToolButton* MainWindow::createViewSelectionButton() const { diff --git a/GUI/coregui/mainwindow/mainwindow.h b/GUI/coregui/mainwindow/mainwindow.h index 21f6dcaa5f4940a42c47035a545a922e8c435180..024c7e276837bc4c6637bdf009175bf10367ee75 100644 --- a/GUI/coregui/mainwindow/mainwindow.h +++ b/GUI/coregui/mainwindow/mainwindow.h @@ -15,7 +15,7 @@ #ifndef BORNAGAIN_GUI_COREGUI_MAINWINDOW_MAINWINDOW_H #define BORNAGAIN_GUI_COREGUI_MAINWINDOW_MAINWINDOW_H -#include <qt-manhattan-style/fancymainwindow.h> +#include <QMainWindow> class WelcomeView; class InstrumentView; @@ -43,7 +43,7 @@ class QStatusBar; class QToolButton; class QVBoxLayout; -class MainWindow : public Manhattan::FancyMainWindow { +class MainWindow : public QMainWindow { Q_OBJECT public: @@ -68,12 +68,18 @@ public: ProjectManager* projectManager(); UpdateNotifier* updateNotifier(); + QWidget* currentView() const; + void setCurrentView(int viewId); + public slots: void onFocusRequest(int index); void openRecentProject(); void onRunSimulationShortcut(); void onSessionModelViewActive(bool isActive); +signals: + void currentViewChanged(ViewId newView); + protected: void closeEvent(QCloseEvent* event); diff --git a/GUI/coregui/mainwindow/mainwindow_constants.h b/GUI/coregui/mainwindow/mainwindow_constants.h index 2e71547bc63c67917fa3309099f74a79e8f4bc5d..938c2b3bdf6d77312ecc99b10831544e2a36622e 100644 --- a/GUI/coregui/mainwindow/mainwindow_constants.h +++ b/GUI/coregui/mainwindow/mainwindow_constants.h @@ -45,11 +45,6 @@ const int MAX_RECENT_PROJECTS = 10; const char MIME_JOBQUEUE[] = "application/org.bornagainproject.jobqueue"; -// Colors -const unsigned int MAIN_THEME_COLOR = 0x086FA1; -const unsigned int BUTTON_COLOR = 0x044362; -const unsigned int BUTTON_TEXT_COLOR = 0xFFFFFF; - // Hints const unsigned int REALTIME_WIDGET_WIDTH_HINT = 480; diff --git a/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt b/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt deleted file mode 100644 index 24fdaa55cc42db28d661d829f9951025b73c0a8e..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################ -# CMakeLists.txt file for building libManhattanStyle -############################################################################ -set(library_name ManhattanStyle) - -set(SRCS - stylehelper.cpp - styledbar.cpp - styleanimator.cpp - settingsutils.cpp - qtcolorbutton.cpp - qtcassert.cpp - progressbar.cpp - minisplitter.cpp - manhattanstyle.cpp - historycompleter.cpp - fancytabwidget.cpp - fancymainwindow.cpp - fancylineedit.cpp - fancyactionbar.cpp - doubletabwidget.cpp - extensions/simpleprogressbar.cpp - stylehelper.h - styledbar.h - styleanimator.h - settingsutils.h - qtcolorbutton.h - qtcolorbutton_p.h - qtcassert.h - progressbar.h - minisplitter.h - manhattanstyle.h - historycompleter.h - fancytabwidget.h - fancymainwindow.h - fancylineedit.h - fancyactionbar.h - doubletabwidget.h - coreconstants.h - qt-manhattan-style_global.hpp - extensions/simpleprogressbar.h - extensions/tabwidget.h - extensions/tabwidget.cpp - extensions/threelevelsitempicker.h - extensions/threelevelsitempicker.cpp -) - -set(include_dirs ${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${include_dirs}) - -set(RCS - resources/resources.qrc -) - -set(UI_FILES - doubletabwidget.ui -) - -# --- Qt5 --------- -set(CMAKE_INCLUDE_CURRENT_DIR ON) -set(CMAKE_AUTOMOC ON) - -qt5_wrap_ui(UI_HDRS ${UI_FILES}) - -# --- definitions --------- -add_definitions(-DQTMANHATTANSTYLE_LIBRARY) - - -# --- library --------- -add_library(${library_name} STATIC ${SRCS} ${UI_HDRS} ${RCS}) -set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE) -set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE) - - -# --- dependencies --------- -target_link_libraries(${library_name} ${Qt5Widgets_LIBRARIES}) -target_link_libraries(${library_name} Qt5::Widgets) - - diff --git a/ThirdParty/GUI/qt-manhattan-style/README.md b/ThirdParty/GUI/qt-manhattan-style/README.md deleted file mode 100644 index 9fc32a112b1a0d5a9f7a9fca358c0eaf9de98583..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/README.md +++ /dev/null @@ -1,5 +0,0 @@ -qt-manhattan-style -================== - -Extraction into a standalone library of the style and of some widgets used in -QtCreator 2.6.2 application. diff --git a/ThirdParty/GUI/qt-manhattan-style/coreconstants.h b/ThirdParty/GUI/qt-manhattan-style/coreconstants.h deleted file mode 100644 index 6f10ad99bbb5041b5af7559fa5252b85ea6b623c..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/coreconstants.h +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CORECONSTANTS_H -#define CORECONSTANTS_H - -#include <QtGlobal> - -namespace Manhattan { -namespace Constants { - -// Modes -const char MODE_WELCOME[] = "Welcome"; -const char MODE_WELCOME_TYPE[] = "Type.Welcome"; -const char MODE_EDIT[] = "Edit"; -const char MODE_EDIT_TYPE[] = "Type.Edit"; -const char MODE_DESIGN[] = "Design"; -const char MODE_DESIGN_TYPE[] = "Type.Design"; -const int P_MODE_WELCOME = 100; -const int P_MODE_EDIT = 90; -const int P_MODE_DESIGN = 89; - -// Menubar -const char MENU_BAR[] = "QtCreator.MenuBar"; - -// Menus -const char M_FILE[] = "QtCreator.Menu.File"; -const char M_FILE_RECENTFILES[] = "QtCreator.Menu.File.RecentFiles"; -const char M_EDIT[] = "QtCreator.Menu.Edit"; -const char M_EDIT_ADVANCED[] = "QtCreator.Menu.Edit.Advanced"; -const char M_TOOLS[] = "QtCreator.Menu.Tools"; -const char M_TOOLS_EXTERNAL[] = "QtCreator.Menu.Tools.External"; -const char M_WINDOW[] = "QtCreator.Menu.Window"; -const char M_WINDOW_PANES[] = "QtCreator.Menu.Window.Panes"; -const char M_WINDOW_VIEWS[] = "QtCreator.Menu.Window.Views"; -const char M_HELP[] = "QtCreator.Menu.Help"; - -// Contexts -const char C_GLOBAL[] = "Global Context"; -const char C_WELCOME_MODE[] = "Core.WelcomeMode"; -const char C_EDIT_MODE[] = "Core.EditMode"; -const char C_DESIGN_MODE[] = "Core.DesignMode"; -const char C_EDITORMANAGER[] = "Core.EditorManager"; -const char C_NAVIGATION_PANE[] = "Core.NavigationPane"; -const char C_PROBLEM_PANE[] = "Core.ProblemPane"; -const char C_GENERAL_OUTPUT_PANE[] = "Core.GeneralOutputPane"; - -// Default editor kind -const char K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "Plain Text Editor"); -const char K_DEFAULT_TEXT_EDITOR_ID[] = "Core.PlainTextEditor"; -const char K_DEFAULT_BINARY_EDITOR_ID[] = "Core.BinaryEditor"; - -//actions -const char UNDO[] = "QtCreator.Undo"; -const char REDO[] = "QtCreator.Redo"; -const char COPY[] = "QtCreator.Copy"; -const char PASTE[] = "QtCreator.Paste"; -const char CUT[] = "QtCreator.Cut"; -const char SELECTALL[] = "QtCreator.SelectAll"; - -const char GOTO[] = "QtCreator.Goto"; - -const char NEW[] = "QtCreator.New"; -const char OPEN[] = "QtCreator.Open"; -const char OPEN_WITH[] = "QtCreator.OpenWith"; -const char REVERTTOSAVED[] = "QtCreator.RevertToSaved"; -const char SAVE[] = "QtCreator.Save"; -const char SAVEAS[] = "QtCreator.SaveAs"; -const char SAVEALL[] = "QtCreator.SaveAll"; -const char PRINT[] = "QtCreator.Print"; -const char EXIT[] = "QtCreator.Exit"; - -const char OPTIONS[] = "QtCreator.Options"; -const char TOGGLE_SIDEBAR[] = "QtCreator.ToggleSidebar"; -const char TOGGLE_FULLSCREEN[] = "QtCreator.ToggleFullScreen"; - -const char MINIMIZE_WINDOW[] = "QtCreator.MinimizeWindow"; -const char ZOOM_WINDOW[] = "QtCreator.ZoomWindow"; - -const char SPLIT[] = "QtCreator.Split"; -const char SPLIT_SIDE_BY_SIDE[] = "QtCreator.SplitSideBySide"; -const char REMOVE_CURRENT_SPLIT[] = "QtCreator.RemoveCurrentSplit"; -const char REMOVE_ALL_SPLITS[] = "QtCreator.RemoveAllSplits"; -const char GOTO_OTHER_SPLIT[] = "QtCreator.GotoOtherSplit"; -const char CLOSE[] = "QtCreator.Close"; -#ifdef Q_OS_WIN -const char CLOSE_ALTERNATIVE[] = "QtCreator.Close_Alternative"; // temporary, see QTCREATORBUG-72 -#endif -const char CLOSEALL[] = "QtCreator.CloseAll"; -const char CLOSEOTHERS[] = "QtCreator.CloseOthers"; -const char GOTONEXT[] = "QtCreator.GotoNext"; -const char GOTOPREV[] = "QtCreator.GotoPrevious"; -const char GOTONEXTINHISTORY[] = "QtCreator.GotoNextInHistory"; -const char GOTOPREVINHISTORY[] = "QtCreator.GotoPreviousInHistory"; -const char GO_BACK[] = "QtCreator.GoBack"; -const char GO_FORWARD[] = "QtCreator.GoForward"; -const char ABOUT_QTCREATOR[] = "QtCreator.AboutQtCreator"; -const char ABOUT_PLUGINS[] = "QtCreator.AboutPlugins"; -const char S_RETURNTOEDITOR[] = "QtCreator.ReturnToEditor"; - -// Default groups -const char G_DEFAULT_ONE[] = "QtCreator.Group.Default.One"; -const char G_DEFAULT_TWO[] = "QtCreator.Group.Default.Two"; -const char G_DEFAULT_THREE[] = "QtCreator.Group.Default.Three"; - -// Main menu bar groups -const char G_FILE[] = "QtCreator.Group.File"; -const char G_EDIT[] = "QtCreator.Group.Edit"; -const char G_VIEW[] = "QtCreator.Group.View"; -const char G_TOOLS[] = "QtCreator.Group.Tools"; -const char G_WINDOW[] = "QtCreator.Group.Window"; -const char G_HELP[] = "QtCreator.Group.Help"; - -// File menu groups -const char G_FILE_NEW[] = "QtCreator.Group.File.New"; -const char G_FILE_OPEN[] = "QtCreator.Group.File.Open"; -const char G_FILE_PROJECT[] = "QtCreator.Group.File.Project"; -const char G_FILE_SAVE[] = "QtCreator.Group.File.Save"; -const char G_FILE_CLOSE[] = "QtCreator.Group.File.Close"; -const char G_FILE_PRINT[] = "QtCreator.Group.File.Print"; -const char G_FILE_OTHER[] = "QtCreator.Group.File.Other"; - -// Edit menu groups -const char G_EDIT_UNDOREDO[] = "QtCreator.Group.Edit.UndoRedo"; -const char G_EDIT_COPYPASTE[] = "QtCreator.Group.Edit.CopyPaste"; -const char G_EDIT_SELECTALL[] = "QtCreator.Group.Edit.SelectAll"; -const char G_EDIT_ADVANCED[] = "QtCreator.Group.Edit.Advanced"; - -const char G_EDIT_FIND[] = "QtCreator.Group.Edit.Find"; -const char G_EDIT_OTHER[] = "QtCreator.Group.Edit.Other"; - -// Advanced edit menu groups -const char G_EDIT_FORMAT[] = "QtCreator.Group.Edit.Format"; -const char G_EDIT_COLLAPSING[] = "QtCreator.Group.Edit.Collapsing"; -const char G_EDIT_BLOCKS[] = "QtCreator.Group.Edit.Blocks"; -const char G_EDIT_FONT[] = "QtCreator.Group.Edit.Font"; -const char G_EDIT_EDITOR[] = "QtCreator.Group.Edit.Editor"; - -const char G_TOOLS_OPTIONS[] = "QtCreator.Group.Tools.Options"; - -// Window menu groups -const char G_WINDOW_SIZE[] = "QtCreator.Group.Window.Size"; -const char G_WINDOW_PANES[] = "QtCreator.Group.Window.Panes"; -const char G_WINDOW_VIEWS[] = "QtCreator.Group.Window.Views"; -const char G_WINDOW_SPLIT[] = "QtCreator.Group.Window.Split"; -const char G_WINDOW_NAVIGATE[] = "QtCreator.Group.Window.Navigate"; -const char G_WINDOW_OTHER[] = "QtCreator.Group.Window.Other"; - -// Help groups (global) -const char G_HELP_HELP[] = "QtCreator.Group.Help.Help"; -const char G_HELP_ABOUT[] = "QtCreator.Group.Help.About"; - -const char ICON_MINUS[] = ":/core/images/minus.png"; -const char ICON_PLUS[] = ":/core/images/plus.png"; -const char ICON_NEWFILE[] = ":/core/images/filenew.png"; -const char ICON_OPENFILE[] = ":/core/images/fileopen.png"; -const char ICON_SAVEFILE[] = ":/core/images/filesave.png"; -const char ICON_UNDO[] = ":/core/images/undo.png"; -const char ICON_REDO[] = ":/core/images/redo.png"; -const char ICON_COPY[] = ":/core/images/editcopy.png"; -const char ICON_PASTE[] = ":/core/images/editpaste.png"; -const char ICON_CUT[] = ":/core/images/editcut.png"; -const char ICON_NEXT[] = ":/core/images/next.png"; -const char ICON_PREV[] = ":/core/images/prev.png"; -const char ICON_DIR[] = ":/core/images/dir.png"; -const char ICON_CLEAN_PANE[] = ":/core/images/clean_pane_small.png"; -const char ICON_CLEAR[] = ":/core/images/clear.png"; -const char ICON_RESET[] = ":/core/images/reset.png"; -const char ICON_MAGNIFIER[] = ":/core/images/magnifier.png"; -const char ICON_TOGGLE_SIDEBAR[] = ":/core/images/sidebaricon.png"; -const char ICON_CLOSE_DOCUMENT[] = ":/core/images/button_close.png"; -const char ICON_CLOSE[] = ":/core/images/closebutton.png"; -const char ICON_CLOSE_DARK[] = ":/core/images/darkclosebutton.png"; -const char ICON_SPLIT_HORIZONTAL[] = ":/core/images/splitbutton_horizontal.png"; -const char ICON_SPLIT_VERTICAL[] = ":/core/images/splitbutton_vertical.png"; -const char ICON_CLOSE_SPLIT_TOP[] = ":/core/images/splitbutton_closetop.png"; -const char ICON_CLOSE_SPLIT_BOTTOM[] = ":/core/images/splitbutton_closebottom.png"; -const char ICON_CLOSE_SPLIT_LEFT[] = ":/core/images/splitbutton_closeleft.png"; -const char ICON_CLOSE_SPLIT_RIGHT[] = ":/core/images/splitbutton_closeright.png"; -const char ICON_FILTER[] = ":/core/images/filtericon.png"; -const char ICON_LINK[] = ":/core/images/linkicon.png"; -const char ICON_QTLOGO_32[] = ":/core/images/logo/32/QtProject-qtcreator.png"; -const char ICON_QTLOGO_128[] = ":/core/images/logo/128/QtProject-qtcreator.png"; - -const char WIZARD_CATEGORY_QT[] = "R.Qt"; -const char WIZARD_TR_CATEGORY_QT[] = QT_TRANSLATE_NOOP("Core", "Qt"); - -const char SETTINGS_CATEGORY_CORE[] = "A.Core"; -const char SETTINGS_CATEGORY_CORE_ICON[] = ":/core/images/category_core.png"; -const char SETTINGS_TR_CATEGORY_CORE[] = QT_TRANSLATE_NOOP("Core", "Environment"); -const char SETTINGS_ID_ENVIRONMENT[] = "A.General"; -const char SETTINGS_ID_SHORTCUTS[] = "B.Keyboard"; -const char SETTINGS_ID_TOOLS[] = "C.ExternalTools"; -const char SETTINGS_ID_MIMETYPES[] = "D.MimeTypes"; - -const char SETTINGS_DEFAULTTEXTENCODING[] = "General/DefaultFileEncoding"; - -const char ALL_FILES_FILTER[] = QT_TRANSLATE_NOOP("Core", "All Files (*)"); - -const char VARIABLE_SUPPORT_PROPERTY[] = "QtCreator.VariableSupport"; - -const char TR_CLEAR_MENU[] = QT_TRANSLATE_NOOP("Core", "Clear Menu"); - -const int TARGET_ICON_SIZE = 32; - -} // namespace Manhattan -} // namespace Core - -#endif // CORECONSTANTS_H diff --git a/ThirdParty/GUI/qt-manhattan-style/doubletabwidget.cpp b/ThirdParty/GUI/qt-manhattan-style/doubletabwidget.cpp deleted file mode 100644 index 91187fa22b5bcb31c9e6d551bc0f4734745f63b9..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/doubletabwidget.cpp +++ /dev/null @@ -1,542 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "doubletabwidget.h" -#include "ui_doubletabwidget.h" - -#include "stylehelper.h" - -#include <QRect> -#include <QPainter> -#include <QFont> -#include <QMouseEvent> -#include <QMenu> -#include <QStyleOption> -#include <QToolTip> - -#include <QDebug> - -using namespace Manhattan; - -static const int MIN_LEFT_MARGIN = 50; -static const int MARGIN = 12; -static const int OTHER_HEIGHT = 38; -static const int SELECTION_IMAGE_WIDTH = 10; -static const int SELECTION_IMAGE_HEIGHT = 20; -static const int OVERFLOW_DROPDOWN_WIDTH = Utils::StyleHelper::navigationWidgetHeight(); - -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) -#define WIDTH_METHOD horizontalAdvance -#else -#define WIDTH_METHOD width -#endif - -static void drawFirstLevelSeparator(QPainter *painter, QPoint top, QPoint bottom) -{ - QLinearGradient grad(top, bottom); - grad.setColorAt(0, QColor(255, 255, 255, 20)); - grad.setColorAt(0.4, QColor(255, 255, 255, 60)); - grad.setColorAt(0.7, QColor(255, 255, 255, 50)); - grad.setColorAt(1, QColor(255, 255, 255, 40)); - painter->setPen(QPen(grad, 0)); - painter->drawLine(top, bottom); - grad.setColorAt(0, QColor(0, 0, 0, 30)); - grad.setColorAt(0.4, QColor(0, 0, 0, 70)); - grad.setColorAt(0.7, QColor(0, 0, 0, 70)); - grad.setColorAt(1, QColor(0, 0, 0, 40)); - painter->setPen(QPen(grad, 0)); - painter->drawLine(top - QPoint(1,0), bottom - QPoint(1,0)); -} - -static void drawSecondLevelSeparator(QPainter *painter, QPoint top, QPoint bottom) -{ - QLinearGradient grad(top, bottom); - grad.setColorAt(0, QColor(255, 255, 255, 0)); - grad.setColorAt(0.4, QColor(255, 255, 255, 100)); - grad.setColorAt(0.7, QColor(255, 255, 255, 100)); - grad.setColorAt(1, QColor(255, 255, 255, 0)); - painter->setPen(QPen(grad, 0)); - painter->drawLine(top, bottom); - grad.setColorAt(0, QColor(0, 0, 0, 0)); - grad.setColorAt(0.4, QColor(0, 0, 0, 100)); - grad.setColorAt(0.7, QColor(0, 0, 0, 100)); - grad.setColorAt(1, QColor(0, 0, 0, 0)); - painter->setPen(QPen(grad, 0)); - painter->drawLine(top - QPoint(1,0), bottom - QPoint(1,0)); -} - -DoubleTabWidget::DoubleTabWidget(QWidget *parent) : - QWidget(parent), - m_left(QLatin1String(":/projectexplorer/images/leftselection.png")), - m_mid(QLatin1String(":/projectexplorer/images/midselection.png")), - m_right(QLatin1String(":/projectexplorer/images/rightselection.png")), - ui(new Ui::DoubleTabWidget), - m_currentIndex(-1), - m_lastVisibleIndex(-1) -{ - ui->setupUi(this); -} - -DoubleTabWidget::~DoubleTabWidget() -{ - delete ui; -} - -int DoubleTabWidget::currentIndex() const -{ - return m_currentIndex; -} - -void DoubleTabWidget::setCurrentIndex(int index) -{ - Q_ASSERT(index < m_tabs.size()); - if (index == m_currentIndex) - return; - m_currentIndex = index; - emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab); - update(); -} - -int DoubleTabWidget::currentSubIndex() const -{ - if (m_currentIndex >= 0 && m_currentIndex < m_tabs.size()) - return m_tabs.at(m_currentIndex).currentSubTab; - return -1; -} - -void DoubleTabWidget::setTitle(const QString &title) -{ - m_title = title; - update(); -} - -QSize DoubleTabWidget::minimumSizeHint() const -{ - return QSize(0, Utils::StyleHelper::navigationWidgetHeight() + OTHER_HEIGHT + 1); -} - -void DoubleTabWidget::updateNameIsUniqueAdd(Tab *tab) -{ - tab->nameIsUnique = true; - for (int i=0; i < m_tabs.size(); ++i) { - if (m_tabs.at(i).name == tab->name) { - m_tabs[i].nameIsUnique = false; - tab->nameIsUnique = false; - break; - } - } -} - -void DoubleTabWidget::updateNameIsUniqueRemove(const Tab &tab) -{ - if (tab.nameIsUnique) - return; - int index(0); - int count = 0; - for (int i=0; i < m_tabs.size(); ++i) { - if (m_tabs.at(i).name == tab.name) { - ++count; - index = i; - } - } - - if (count == 1) - m_tabs[index].nameIsUnique = true; -} - -void DoubleTabWidget::addTab(const QString &name, const QString &fullName, const QStringList &subTabs) -{ - Tab tab; - tab.name = name; - tab.fullName = fullName; - tab.subTabs = subTabs; - tab.currentSubTab = tab.subTabs.isEmpty() ? -1 : 0; - updateNameIsUniqueAdd(&tab); - - m_tabs.append(tab); - update(); -} - -void DoubleTabWidget::insertTab(int index, const QString &name, const QString &fullName, const QStringList &subTabs) -{ - Tab tab; - tab.name = name; - tab.fullName = fullName; - tab.subTabs = subTabs; - tab.currentSubTab = tab.subTabs.isEmpty() ? -1 : 0; - updateNameIsUniqueAdd(&tab); - - m_tabs.insert(index, tab); - if (m_currentIndex >= index) { - ++m_currentIndex; - emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab); - } - update(); -} - -void DoubleTabWidget::removeTab(int index) -{ - Tab t = m_tabs.takeAt(index); - updateNameIsUniqueRemove(t); - if (index <= m_currentIndex) { - --m_currentIndex; - if (m_currentIndex < 0 && m_tabs.size() > 0) - m_currentIndex = 0; - if (m_currentIndex < 0) { - emit currentIndexChanged(-1, -1); - } else { - emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab); - } - } - update(); -} - -int DoubleTabWidget::tabCount() const -{ - return m_tabs.size(); -} - -/// Converts a position to the tab/subtab that is undeneath -/// If HitArea is tab or subtab, then the second part of the pair -/// is the tab or subtab number -QPair<DoubleTabWidget::HitArea, int> DoubleTabWidget::convertPosToTab(QPoint pos) -{ - if (pos.y() < Utils::StyleHelper::navigationWidgetHeight()) { - // on the top level part of the bar - int eventX = pos.x(); - QFontMetrics fm(font()); - int x = m_title.isEmpty() ? 0 : - 2 * MARGIN + qMax(fm.WIDTH_METHOD(m_title), MIN_LEFT_MARGIN); - - if (eventX <= x) - return qMakePair(HITNOTHING, -1); - int i; - for (i = 0; i <= m_lastVisibleIndex; ++i) { - int otherX = x + 2 * MARGIN + fm.WIDTH_METHOD(m_tabs.at( - m_currentTabIndices.at(i)).displayName()); - if (eventX > x && eventX < otherX) { - break; - } - x = otherX; - } - if (i <= m_lastVisibleIndex) { - return qMakePair(HITTAB, i); - } else if (m_lastVisibleIndex < m_tabs.size() - 1) { - // handle overflow menu - if (eventX > x && eventX < x + OVERFLOW_DROPDOWN_WIDTH) { - return qMakePair(HITOVERFLOW, -1); - } - } - } else if (pos.y() < Utils::StyleHelper::navigationWidgetHeight() + OTHER_HEIGHT) { - int diff = (OTHER_HEIGHT - SELECTION_IMAGE_HEIGHT) / 2; - if (pos.y() < Utils::StyleHelper::navigationWidgetHeight() + diff - || pos.y() > Utils::StyleHelper::navigationWidgetHeight() + OTHER_HEIGHT - diff) - return qMakePair(HITNOTHING, -1); - // on the lower level part of the bar - if (m_currentIndex == -1) - return qMakePair(HITNOTHING, -1); - Tab currentTab = m_tabs.at(m_currentIndex); - QStringList subTabs = currentTab.subTabs; - if (subTabs.isEmpty()) - return qMakePair(HITNOTHING, -1); - int eventX = pos.x(); - QFontMetrics fm(font()); - int x = MARGIN; - int i; - for (i = 0; i < subTabs.size(); ++i) { - int otherX = x + 2 * SELECTION_IMAGE_WIDTH + fm.WIDTH_METHOD(subTabs.at(i)); - if (eventX > x && eventX < otherX) { - break; - } - x = otherX + 2 * MARGIN; - } - if (i < subTabs.size()) { - return qMakePair(HITSUBTAB, i); - } - } - return qMakePair(HITNOTHING, -1); -} - -void DoubleTabWidget::mousePressEvent(QMouseEvent *event) -{ - // todo: - // the even wasn't accepted/ignored in a consistent way - // now the event is accepted everywhere were it hitted something interesting - // and otherwise ignored - // should not make any difference - QPair<HitArea, int> hit = convertPosToTab(event->pos()); - if (hit.first == HITTAB) { - if (m_currentIndex != m_currentTabIndices.at(hit.second)) { - m_currentIndex = m_currentTabIndices.at(hit.second); - update(); - event->accept(); - emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab); - return; - } - } else if (hit.first == HITOVERFLOW) { - QMenu overflowMenu; - QList<QAction *> actions; - for (int i = m_lastVisibleIndex + 1; i < m_tabs.size(); ++i) { - actions << overflowMenu.addAction(m_tabs.at(m_currentTabIndices.at(i)).displayName()); - } - if (QAction *action = overflowMenu.exec(event->globalPos())) { // todo used different position before - int index = m_currentTabIndices.at(actions.indexOf(action) + m_lastVisibleIndex + 1); - if (m_currentIndex != index) { - m_currentIndex = index; - update(); - event->accept(); - emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab); - return; - } - } - } else if (hit.first == HITSUBTAB) { - if (m_tabs[m_currentIndex].currentSubTab != hit.second) { - m_tabs[m_currentIndex].currentSubTab = hit.second; - update(); - // todo next two lines were outside the if leading to - // unnecessary (?) signal emissions? - event->accept(); - emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab); - return; - } - } - event->ignore(); -} - -void DoubleTabWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event) - QPainter painter(this); - QRect r = rect(); - - // draw top level tab bar - r.setHeight(Utils::StyleHelper::navigationWidgetHeight()); - - QPoint offset = window()->mapToGlobal(QPoint(0, 0)) - mapToGlobal(r.topLeft()); - QRect gradientSpan = QRect(offset, window()->size()); - Utils::StyleHelper::horizontalGradient(&painter, gradientSpan, r); - - painter.setPen(Utils::StyleHelper::borderColor()); - - QColor lighter(255, 255, 255, 40); - painter.drawLine(r.bottomLeft(), r.bottomRight()); - painter.setPen(lighter); - painter.drawLine(r.topLeft(), r.topRight()); - - QFontMetrics fm(font()); - int baseline = (r.height() + fm.ascent()) / 2 - 1; - - // top level title - if (!m_title.isEmpty()) { - painter.setPen(Utils::StyleHelper::panelTextColor()); - painter.drawText(MARGIN, baseline, m_title); - } - - QLinearGradient grad(QPoint(0, 0), QPoint(0, r.height() + OTHER_HEIGHT - 1)); - grad.setColorAt(0, QColor(247, 247, 247)); - grad.setColorAt(1, QColor(205, 205, 205)); - - // draw background of second bar - painter.fillRect(QRect(0, r.height(), r.width(), OTHER_HEIGHT), grad); - painter.setPen(QColor(0x505050)); - painter.drawLine(0, r.height() + OTHER_HEIGHT, - r.width(), r.height() + OTHER_HEIGHT); - painter.setPen(Qt::white); - painter.drawLine(0, r.height(), - r.width(), r.height()); - - // top level tabs - int x = m_title.isEmpty() ? 0 : - 2 * MARGIN + qMax(fm.WIDTH_METHOD(m_title), MIN_LEFT_MARGIN); - - // calculate sizes - QList<int> nameWidth; - int width = x; - int indexSmallerThanOverflow = -1; - int indexSmallerThanWidth = -1; - for (int i = 0; i < m_tabs.size(); ++i) { - const Tab &tab = m_tabs.at(i); - int w = fm.WIDTH_METHOD(tab.displayName()); - nameWidth << w; - width += 2 * MARGIN + w; - if (width < r.width()) - indexSmallerThanWidth = i; - if (width < r.width() - OVERFLOW_DROPDOWN_WIDTH) - indexSmallerThanOverflow = i; - } - m_lastVisibleIndex = -1; - m_currentTabIndices.resize(m_tabs.size()); - if (indexSmallerThanWidth == m_tabs.size() - 1) { - // => everything fits - for (int i = 0; i < m_tabs.size(); ++i) - m_currentTabIndices[i] = i; - m_lastVisibleIndex = m_tabs.size()-1; - } else { - // => we need the overflow thingy - if (m_currentIndex <= indexSmallerThanOverflow) { - // easy going, simply draw everything that fits - for (int i = 0; i < m_tabs.size(); ++i) - m_currentTabIndices[i] = i; - m_lastVisibleIndex = indexSmallerThanOverflow; - } else { - // now we need to put the current tab into - // visible range. for that we need to find the place - // to put it, so it fits - width = x; - int index = 0; - bool handledCurrentIndex = false; - for (int i = 0; i < m_tabs.size(); ++i) { - if (index != m_currentIndex) { - if (!handledCurrentIndex) { - // check if enough room for current tab after this one - if (width + 2 * MARGIN + nameWidth.at(index) - + 2 * MARGIN + nameWidth.at(m_currentIndex) - < r.width() - OVERFLOW_DROPDOWN_WIDTH) { - m_currentTabIndices[i] = index; - ++index; - width += 2 * MARGIN + nameWidth.at(index); - } else { - m_currentTabIndices[i] = m_currentIndex; - handledCurrentIndex = true; - m_lastVisibleIndex = i; - } - } else { - m_currentTabIndices[i] = index; - ++index; - } - } else { - ++index; - --i; - } - } - } - } - - // actually draw top level tabs - for (int i = 0; i <= m_lastVisibleIndex; ++i) { - int actualIndex = m_currentTabIndices.at(i); - Tab tab = m_tabs.at(actualIndex); - if (actualIndex == m_currentIndex) { - painter.setPen(Utils::StyleHelper::borderColor()); - painter.drawLine(x - 1, 0, x - 1, r.height() - 1); - painter.fillRect(QRect(x, 0, - 2 * MARGIN + fm.WIDTH_METHOD(tab.displayName()), - r.height() + 1), - grad); - - if (actualIndex != 0) { - painter.setPen(QColor(255, 255, 255, 170)); - painter.drawLine(x, 0, x, r.height()); - } - x += MARGIN; - painter.setPen(Qt::black); - painter.drawText(x, baseline, tab.displayName()); - x += nameWidth.at(actualIndex); - x += MARGIN; - painter.setPen(Utils::StyleHelper::borderColor()); - painter.drawLine(x, 0, x, r.height() - 1); - painter.setPen(QColor(0, 0, 0, 20)); - painter.drawLine(x + 1, 0, x + 1, r.height() - 1); - painter.setPen(QColor(255, 255, 255, 170)); - painter.drawLine(x - 1, 0, x - 1, r.height()); - } else { - if (i == 0) - drawFirstLevelSeparator(&painter, QPoint(x, 0), QPoint(x, r.height()-1)); - x += MARGIN; - painter.setPen(Utils::StyleHelper::panelTextColor()); - painter.drawText(x + 1, baseline, tab.displayName()); - x += nameWidth.at(actualIndex); - x += MARGIN; - drawFirstLevelSeparator(&painter, QPoint(x, 0), QPoint(x, r.height()-1)); - } - } - - // draw overflow button - if (m_lastVisibleIndex < m_tabs.size() - 1) { - QStyleOption opt; - opt.rect = QRect(x, 0, OVERFLOW_DROPDOWN_WIDTH - 1, r.height() - 1); - style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, - &opt, &painter, this); - drawFirstLevelSeparator(&painter, QPoint(x + OVERFLOW_DROPDOWN_WIDTH, 0), - QPoint(x + OVERFLOW_DROPDOWN_WIDTH, r.height()-1)); - } - - // second level tabs - if (m_currentIndex != -1) { - int y = static_cast<int>(r.height() + (OTHER_HEIGHT - m_left.height()) / 2.); - int imageHeight = m_left.height(); - Tab currentTab = m_tabs.at(m_currentIndex); - QStringList subTabs = currentTab.subTabs; - x = 0; - for (int i = 0; i < subTabs.size(); ++i) { - x += MARGIN; - int textWidth = fm.WIDTH_METHOD(subTabs.at(i)); - if (currentTab.currentSubTab == i) { - painter.setPen(Qt::white); - painter.drawPixmap(x, y, m_left); - painter.drawPixmap(QRect(x + SELECTION_IMAGE_WIDTH, y, - textWidth, imageHeight), - m_mid, QRect(0, 0, m_mid.width(), m_mid.height())); - painter.drawPixmap(x + SELECTION_IMAGE_WIDTH + textWidth, y, m_right); - } else { - painter.setPen(Qt::black); - } - x += SELECTION_IMAGE_WIDTH; - painter.drawText(x, static_cast<int>(y + (imageHeight + fm.ascent()) / 2. - 1), - subTabs.at(i)); - x += textWidth + SELECTION_IMAGE_WIDTH + MARGIN; - drawSecondLevelSeparator(&painter, QPoint(x, y), QPoint(x, y + imageHeight)); - } - } -} - -void DoubleTabWidget::changeEvent(QEvent *e) -{ - QWidget::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} - -bool DoubleTabWidget::event(QEvent *event) -{ - if (event->type() == QEvent::ToolTip) { - QHelpEvent *helpevent = static_cast<QHelpEvent*>(event); - QPair<HitArea, int> hit = convertPosToTab(helpevent->pos()); - if (hit.first == HITTAB && m_tabs.at(m_currentTabIndices.at(hit.second)).nameIsUnique) - QToolTip::showText(helpevent->globalPos(), m_tabs.at(m_currentTabIndices.at(hit.second)).fullName, this); - else - QToolTip::showText(helpevent->globalPos(), QString(), this); - } - return QWidget::event(event); -} diff --git a/ThirdParty/GUI/qt-manhattan-style/doubletabwidget.h b/ThirdParty/GUI/qt-manhattan-style/doubletabwidget.h deleted file mode 100644 index e176b04e625cc52d266a6e6d11f12b3d22de04d1..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/doubletabwidget.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef DOUBLETABWIDGET_H -#define DOUBLETABWIDGET_H - -#include <QVector> -#include <QWidget> -#include <QPixmap> - -namespace Manhattan { - -namespace Ui { - class DoubleTabWidget; -} - -class DoubleTabWidget : public QWidget -{ - Q_OBJECT -public: - DoubleTabWidget(QWidget *parent = 0); - virtual ~DoubleTabWidget(); - - void setTitle(const QString &title); - QString title() const { return m_title; } - - void addTab(const QString &name, const QString &fullName, const QStringList &subTabs); - void insertTab(int index, const QString &name, const QString &fullName, const QStringList &subTabs); - void removeTab(int index); - int tabCount() const; - - int currentIndex() const; - void setCurrentIndex(int index); - - int currentSubIndex() const; - -signals: - void currentIndexChanged(int index, int subIndex); - -protected: - virtual void paintEvent(QPaintEvent *event); - virtual void mousePressEvent(QMouseEvent *event); - virtual void changeEvent(QEvent *e); - virtual bool event(QEvent *event); - virtual QSize minimumSizeHint() const; - -private: - struct Tab { - QString name; - QString fullName; - bool nameIsUnique; - QStringList subTabs; - int currentSubTab; - QString displayName() const { - return nameIsUnique ? name : fullName; - } - }; - void updateNameIsUniqueAdd(Tab *tab); - void updateNameIsUniqueRemove(const Tab &tab); - - enum HitArea { HITNOTHING, HITOVERFLOW, HITTAB, HITSUBTAB }; - QPair<DoubleTabWidget::HitArea, int> convertPosToTab(QPoint pos); - - const QPixmap m_left; - const QPixmap m_mid; - const QPixmap m_right; - - Ui::DoubleTabWidget *ui; - - - QString m_title; - QList<Tab> m_tabs; - int m_currentIndex; - QVector<int> m_currentTabIndices; - int m_lastVisibleIndex; -}; - -} // namespace Manhattan - -#endif // DOUBLETABWIDGET_H diff --git a/ThirdParty/GUI/qt-manhattan-style/doubletabwidget.ui b/ThirdParty/GUI/qt-manhattan-style/doubletabwidget.ui deleted file mode 100644 index f39747448d7c7f8320cc8bbb1666bde54ceb7e77..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/doubletabwidget.ui +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Manhattan::DoubleTabWidget</class> - <widget class="QWidget" name="Manhattan::DoubleTabWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>600</width> - <height>400</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="windowTitle"> - <string>DoubleTabWidget</string> - </property> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/ThirdParty/GUI/qt-manhattan-style/extensions/simpleprogressbar.cpp b/ThirdParty/GUI/qt-manhattan-style/extensions/simpleprogressbar.cpp deleted file mode 100644 index 158121d57278db3fc6e36f793ef99f60094ca46f..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/extensions/simpleprogressbar.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "simpleprogressbar.h" -#include "../stylehelper.h" - -#include <QPainter> -#include <QBrush> -#include <QColor> - -using namespace Manhattan; - -SimpleProgressBar::SimpleProgressBar(int width, int height, QWidget *parent) - : QWidget(parent) - , m_error(false) - , m_progressHeight(height + ((height % 2) + 1) % 2) // make odd - , m_progressWidth(width) - , m_minimum(1) - , m_maximum(100) - , m_value(1) - , m_finished(false) -{ - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); -} - -SimpleProgressBar::~SimpleProgressBar() -{ -} - -void SimpleProgressBar::reset() -{ - m_value = m_minimum; - m_finished = false; - m_error = false; - update(); -} - -void SimpleProgressBar::setRange(int minimum, int maximum) -{ - m_minimum = minimum; - m_maximum = maximum; - if (m_value < m_minimum || m_value > m_maximum) - m_value = m_minimum; - update(); -} - -void SimpleProgressBar::setValue(int value) -{ - if (m_value == value - || m_value < m_minimum - || m_value > m_maximum) { - return; - } - m_value = value; - update(); -} - -void SimpleProgressBar::setFinished(bool b) -{ - if (b == m_finished) - return; - m_finished = b; - update(); -} - -bool SimpleProgressBar::hasError() const -{ - return m_error; -} - -void SimpleProgressBar::setError(bool on) -{ - m_error = on; - update(); -} - -QSize SimpleProgressBar::sizeHint() const -{ - QSize s; - s.setWidth(m_progressWidth + 6); - s.setHeight(m_progressHeight + 6); - return s; -} - -void SimpleProgressBar::paintEvent(QPaintEvent *) -{ - if (bar.isNull()) - bar.load(QLatin1String(":/core/images/progressbar.png")); - - double range = maximum() - minimum(); - double percent = 0.; - if (range != 0) - percent = (value() - minimum()) / range; - if (percent > 1) - percent = 1; - else if (percent < 0) - percent = 0; - - if (finished()) - percent = 1; - - QPainter p(this); - - // draw outer rect - QRect rect((size().width() - m_progressWidth) / 2, (size().height() - m_progressHeight) / 2, m_progressWidth, m_progressHeight-1); - p.setPen(Utils::StyleHelper::panelTextColor()); - Utils::StyleHelper::drawCornerImage(bar, &p, rect, 2, 2, 2, 2); - - // draw inner rect - QColor c = Utils::StyleHelper::panelTextColor(); - c.setAlpha(180); - p.setPen(Qt::NoPen); - - QRect inner = rect.adjusted(3, 2, -2, -2); - inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0); - if (m_error) { - QColor red(255, 60, 0, 210); - c = red; - // avoid too small red bar - if (inner.width() < 10) - inner.adjust(0, 0, 10 - inner.width(), 0); - } else if (m_finished) { - c = QColor(90, 170, 60); - } - - // Draw line and shadow after the gradient fill - if (value() > 0 && value() < maximum()) { - p.fillRect(QRect(inner.right() + 1, inner.top(), 2, inner.height()), QColor(0, 0, 0, 20)); - p.fillRect(QRect(inner.right() + 1, inner.top(), 1, inner.height()), QColor(0, 0, 0, 60)); - } - QLinearGradient grad(inner.topLeft(), inner.bottomLeft()); - grad.setColorAt(0, c.lighter(130)); - grad.setColorAt(0.5, c.lighter(106)); - grad.setColorAt(0.51, c.darker(106)); - grad.setColorAt(1, c.darker(130)); - p.setPen(Qt::NoPen); - p.setBrush(grad); - p.drawRect(inner); - p.setBrush(Qt::NoBrush); - p.setPen(QPen(QColor(0, 0, 0, 30), 1)); - p.drawLine(inner.topLeft(), inner.topRight()); - p.drawLine(inner.topLeft(), inner.bottomLeft()); - p.drawLine(inner.topRight(), inner.bottomRight()); - p.drawLine(inner.bottomLeft(), inner.bottomRight()); - p.drawPoint(inner.bottomLeft()); - p.drawPoint(inner.bottomRight()); -} diff --git a/ThirdParty/GUI/qt-manhattan-style/extensions/simpleprogressbar.h b/ThirdParty/GUI/qt-manhattan-style/extensions/simpleprogressbar.h deleted file mode 100644 index 064ddfa95b5db0c95cf113d9c058c7c4512b2383..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/extensions/simpleprogressbar.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef SIMPLEPROGRESSBAR_H -#define SIMPLEPROGRESSBAR_H - -#include "../qt-manhattan-style_global.hpp" -#include <QWidget> - -namespace Manhattan { - -class QTMANHATTANSTYLESHARED_EXPORT SimpleProgressBar : public QWidget -{ - Q_OBJECT - -public: - explicit SimpleProgressBar(int width = 50, int height = 12, QWidget *parent = 0); - virtual ~SimpleProgressBar(); - - void setError(bool on); - bool hasError() const; - virtual QSize sizeHint() const; - virtual void paintEvent(QPaintEvent *); - int minimum() const { return m_minimum; } - int maximum() const { return m_maximum; } - int value() const { return m_value; } - bool finished() const { return m_finished; } - void setRange(int minimum, int maximum); - void setValue(int value); - void setFinished(bool b); - -public slots: - void reset(); - -private: - QImage bar; - QString m_text; - bool m_error; - int m_progressHeight; - int m_progressWidth; - int m_minimum; - int m_maximum; - int m_value; - bool m_finished; -}; - -} // namespace Manhattan - -#endif // SIMPLEPROGRESSBAR_H diff --git a/ThirdParty/GUI/qt-manhattan-style/extensions/tabwidget.cpp b/ThirdParty/GUI/qt-manhattan-style/extensions/tabwidget.cpp deleted file mode 100644 index 0280578f27acfec6fb1ebf79fa2da2bbced4659f..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/extensions/tabwidget.cpp +++ /dev/null @@ -1,418 +0,0 @@ -#include "tabwidget.h" -#include "../stylehelper.h" -#include <QRect> -#include <QPainter> -#include <QFont> -#include <QMouseEvent> -#include <QMenu> -#include <QToolTip> -#include <QStyleOption> -#include <QVBoxLayout> -#include <QStackedWidget> - -using namespace Manhattan; - -static const int MIN_LEFT_MARGIN = 50; -static const int MARGIN = 12; -static const int TAB_HEIGHT = 24; -static const int CONTENT_HEIGHT_MARGIN = 10; -//static const int SELECTION_IMAGE_WIDTH = 10; -//static const int SELECTION_IMAGE_HEIGHT = 20; -static const int OVERFLOW_DROPDOWN_WIDTH = TAB_HEIGHT; - -#include <QtGlobal> -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) -#define WIDTH_METHOD horizontalAdvance -#else -#define WIDTH_METHOD width -#endif - - -static void drawFirstLevelSeparator(QPainter *painter, QPoint top, QPoint bottom) -{ - painter->setPen(QPen(QColor(Qt::white).darker(110), 0)); - painter->drawLine(top, bottom); - painter->setPen(QPen(Qt::gray, 0)); - painter->drawLine(top - QPoint(1,0), bottom - QPoint(1,0)); -} - -TabWidget::TabWidget(QWidget *parent) : - QWidget(parent), - m_currentIndex(-1), - m_lastVisibleIndex(-1), - m_stack(nullptr), - m_drawFrame(false) -{ - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, TAB_HEIGHT + CONTENT_HEIGHT_MARGIN + 1, 0, 0); - m_stack = new QStackedWidget; - layout->addWidget(m_stack); - setLayout(layout); - - connect(this, SIGNAL(currentIndexChanged(int)), m_stack, SLOT(setCurrentIndex(int))); -} - -TabWidget::~TabWidget() -{ -} - -int TabWidget::currentIndex() const -{ - return m_currentIndex; -} - -void TabWidget::setCurrentIndex(int index) -{ - Q_ASSERT(index < m_tabs.size()); - if (index == m_currentIndex) - return; - m_currentIndex = index; - emit currentIndexChanged(m_currentIndex); - update(); -} - -void TabWidget::setTitle(const QString &title) -{ - m_title = title; - update(); -} - -void TabWidget::setFrameVisible(bool visible) -{ - if (visible != m_drawFrame) { - m_drawFrame = visible; - update(); - } -} - -void TabWidget::addTab(const QString &name, QWidget *widget, const QColor &color) -{ - Q_ASSERT(widget); - Tab tab; - tab.name = name; - tab.color = color; - tab.widget = widget; - m_tabs.append(tab); - m_stack->addWidget(widget); - if (m_currentIndex == -1) { - m_currentIndex = 0; - emit currentIndexChanged(m_currentIndex); - } - update(); -} - -void TabWidget::insertTab(int index, const QString &name, QWidget *widget, const QColor &color) -{ - Q_ASSERT(widget); - Tab tab; - tab.name = name; - tab.color = color; - tab.widget = widget; - m_tabs.insert(index, tab); - m_stack->insertWidget(index, widget); - if (m_currentIndex >= index) { - ++m_currentIndex; - emit currentIndexChanged(m_currentIndex); - } - update(); -} - -QWidget* TabWidget::removeTab(int index) -{ - Tab tab = m_tabs.takeAt(index); - if (index <= m_currentIndex) { - --m_currentIndex; - if (m_currentIndex < 0 && m_tabs.size() > 0) - m_currentIndex = 0; - if (m_currentIndex < 0) { - emit currentIndexChanged(-1); - } else { - emit currentIndexChanged(m_currentIndex); - } - } - update(); - return tab.widget; -} - -int TabWidget::tabCount() const -{ - return m_tabs.size(); -} - -QString TabWidget::tabText(int index) const -{ - return m_tabs.value(index).name; -} - -/// Converts a position to the tab that is undeneath -/// If HitArea is tab, then the second part of the pair -/// is the tab number -QPair<TabWidget::HitArea, int> TabWidget::convertPosToTab(QPoint pos) -{ - if (pos.y() < TAB_HEIGHT) { - // on the top level part of the bar - int eventX = pos.x(); - QFontMetrics fm(font()); - int x = m_title.isEmpty() ? 0 : - 2 * MARGIN + qMax(fm.WIDTH_METHOD(m_title), MIN_LEFT_MARGIN); - - if (eventX <= x) - return qMakePair(HITNOTHING, -1); - int i; - for (i = 0; i <= m_lastVisibleIndex; ++i) { - int otherX = x + 2 * MARGIN + fm.WIDTH_METHOD(m_tabs.at( - m_currentTabIndices.at(i)).name); - if (eventX > x && eventX < otherX) { - break; - } - x = otherX; - } - if (i <= m_lastVisibleIndex) { - return qMakePair(HITTAB, i); - } else if (m_lastVisibleIndex < m_tabs.size() - 1) { - // handle overflow menu - if (eventX > x && eventX < x + OVERFLOW_DROPDOWN_WIDTH) { - return qMakePair(HITOVERFLOW, -1); - } - } - } - - return qMakePair(HITNOTHING, -1); -} - -void TabWidget::mousePressEvent(QMouseEvent *event) -{ - // todo: - // the even wasn't accepted/ignored in a consistent way - // now the event is accepted everywhere were it hitted something interesting - // and otherwise ignored - // should not make any difference - QPair<HitArea, int> hit = convertPosToTab(event->pos()); - if (hit.first == HITTAB) { - if (m_currentIndex != m_currentTabIndices.at(hit.second)) { - m_currentIndex = m_currentTabIndices.at(hit.second); - update(); - event->accept(); - emit currentIndexChanged(m_currentIndex); - return; - } - } else if (hit.first == HITOVERFLOW) { - QMenu overflowMenu; - QList<QAction *> actions; - for (int i = m_lastVisibleIndex + 1; i < m_tabs.size(); ++i) { - actions << overflowMenu.addAction(m_tabs.at(m_currentTabIndices.at(i)).name); - } - if (QAction *action = overflowMenu.exec(event->globalPos())) { // todo used different position before - int index = m_currentTabIndices.at(actions.indexOf(action) + m_lastVisibleIndex + 1); - if (m_currentIndex != index) { - m_currentIndex = index; - update(); - event->accept(); - emit currentIndexChanged(m_currentIndex); - return; - } - } - } - - event->ignore(); -} - -void TabWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event) - QPainter painter(this); - QRect r = rect(); - - QColor baseColor = palette().window().color(); - QColor backgroundColor = baseColor.darker(110); - QColor lineColor = backgroundColor.darker(); - - // draw top level tab bar - r.setHeight(TAB_HEIGHT); - - // Fill top bar background - if (!m_drawFrame) - painter.fillRect(r, backgroundColor); - - QFontMetrics fm(font()); - int baseline = (r.height() + fm.ascent()) / 2 - 1; - - // top level title - if (!m_title.isEmpty()) { - painter.setPen(Utils::StyleHelper::panelTextColor()); - painter.drawText(MARGIN, baseline, m_title); - } - // draw content background - QRect content(r); - content.setTop(r.height()); - content.setHeight(height() - r.height()); - painter.fillRect(content, baseColor); - - // frames - if (m_drawFrame) { - painter.setPen(lineColor); - painter.drawRect(content.adjusted(0, 0, -1, -1)); - } - else { - painter.setPen(lineColor); - painter.drawLine(r.left(), r.height(), r.right(), r.height()); - } - - // top level tabs - int x = m_title.isEmpty() ? 0 : 2 * MARGIN + qMax(fm.WIDTH_METHOD(m_title), MIN_LEFT_MARGIN); - // calculate sizes - QList<int> nameWidth; - int width = x; - int indexSmallerThanOverflow = -1; - int indexSmallerThanWidth = -1; - for (int i = 0; i < m_tabs.size(); ++i) { - const Tab& tab = m_tabs.at(i); - int w = fm.WIDTH_METHOD(tab.name); - nameWidth << w; - width += 2 * MARGIN + w; - if (width < r.width()) - indexSmallerThanWidth = i; - if (width < r.width() - OVERFLOW_DROPDOWN_WIDTH) - indexSmallerThanOverflow = i; - } - m_lastVisibleIndex = -1; - m_currentTabIndices.resize(m_tabs.size()); - if (indexSmallerThanWidth == m_tabs.size() - 1) { - // => everything fits - for (int i = 0; i < m_tabs.size(); ++i) - m_currentTabIndices[i] = i; - m_lastVisibleIndex = m_tabs.size()-1; - } else { - // => we need the overflow thingy - if (m_currentIndex <= indexSmallerThanOverflow) { - // easy going, simply draw everything that fits - for (int i = 0; i < m_tabs.size(); ++i) - m_currentTabIndices[i] = i; - m_lastVisibleIndex = indexSmallerThanOverflow; - } else { - // now we need to put the current tab into - // visible range. for that we need to find the place - // to put it, so it fits - width = x; - int index = 0; - bool handledCurrentIndex = false; - for (int i = 0; i < m_tabs.size(); ++i) { - if (index != m_currentIndex) { - if (!handledCurrentIndex) { - // check if enough room for current tab after this one - if (width + 2 * MARGIN + nameWidth.at(index) - + 2 * MARGIN + nameWidth.at(m_currentIndex) - < r.width() - OVERFLOW_DROPDOWN_WIDTH) { - m_currentTabIndices[i] = index; - ++index; - width += 2 * MARGIN + nameWidth.at(index); - } else { - m_currentTabIndices[i] = m_currentIndex; - handledCurrentIndex = true; - m_lastVisibleIndex = i; - } - } else { - m_currentTabIndices[i] = index; - ++index; - } - } else { - ++index; - --i; - } - } - } - } - - // actually draw top level tabs - for (int i = 0; i <= m_lastVisibleIndex; ++i) { - int actualIndex = m_currentTabIndices.at(i); - const Tab& tab = m_tabs.at(actualIndex); - - painter.setPen(lineColor); - - // top - if (m_drawFrame) { - painter.drawLine(x, 0, x + 2 * MARGIN + fm.WIDTH_METHOD(tab.name), 0); - } - - if (actualIndex == m_currentIndex) { - // tab background - painter.fillRect(QRect(x, 1, - 2 * MARGIN + fm.WIDTH_METHOD(tab.name), - r.height() + 1), - baseColor); - - // Left - if (actualIndex == 0) { - if (m_drawFrame) - painter.drawLine(x, 0, x, r.height()+1); - } - else { - painter.drawLine(x - 1, 0, x - 1, r.height() - 1); - painter.setPen(QColor(255, 255, 255, 170)); - painter.drawLine(x, 1, x, r.height()); - } - - x += MARGIN; - painter.setPen(tab.color); - painter.drawText(x, baseline, tab.name); - x += nameWidth.at(actualIndex); - x += MARGIN; - painter.setPen(lineColor); - painter.drawLine(x, 0, x, r.height() - 1); - painter.setPen(QColor(0, 0, 0, 20)); - painter.drawLine(x + 1, 0, x + 1, r.height() - 1); - painter.setPen(QColor(255, 255, 255, 170)); - painter.drawLine(x - 1, 1, x - 1, r.height()); - } else { - // tab background - painter.fillRect(QRect(x + 1, 1, - 2 * MARGIN + fm.WIDTH_METHOD(tab.name), - r.height()-1), - backgroundColor); - - // left - if (m_drawFrame && (actualIndex == 0)) - painter.drawLine(x, 0, x, r.height()); - - x += MARGIN; - QColor penColor(tab.color); - penColor.setAlpha(190); - painter.setPen(penColor); - painter.drawText(x + 1, baseline, tab.name); - x += nameWidth.at(actualIndex); - x += MARGIN; - if (!m_drawFrame || (actualIndex != m_lastVisibleIndex)) - drawFirstLevelSeparator(&painter, QPoint(x, 1), QPoint(x, r.height()-1)); - } - - // end of tabs right vertical line - if (m_drawFrame && (actualIndex == m_lastVisibleIndex)) { - painter.setPen(lineColor); - painter.drawLine(x, 0, x, r.height() - 1); - } - } - - // draw overflow button - if (m_lastVisibleIndex < m_tabs.size() - 1) { - QStyleOption opt; - opt.rect = QRect(x, 0, OVERFLOW_DROPDOWN_WIDTH - 1, r.height() - 1); - style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, - &opt, &painter, this); - drawFirstLevelSeparator(&painter, QPoint(x + OVERFLOW_DROPDOWN_WIDTH, 0), - QPoint(x + OVERFLOW_DROPDOWN_WIDTH, r.height()-1)); - } -} - -bool TabWidget::event(QEvent *event) -{ - if (event->type() == QEvent::ToolTip) { - QHelpEvent *helpevent = static_cast<QHelpEvent*>(event); - QPair<HitArea, int> hit = convertPosToTab(helpevent->pos()); - if (hit.first == HITTAB) - QToolTip::showText(helpevent->globalPos(), m_tabs.at(m_currentTabIndices.at(hit.second)).name, this); - else - QToolTip::showText(helpevent->globalPos(), QString(), this); - } - return QWidget::event(event); -} diff --git a/ThirdParty/GUI/qt-manhattan-style/extensions/tabwidget.h b/ThirdParty/GUI/qt-manhattan-style/extensions/tabwidget.h deleted file mode 100644 index 94c12439fef01632048ba9ee2cf24758c384a9b9..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/extensions/tabwidget.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef TABWIDGET_H -#define TABWIDGET_H - -#include "../qt-manhattan-style_global.hpp" -#include <QVector> -#include <QWidget> - -class QStackedWidget; - -namespace Manhattan { - -class QTMANHATTANSTYLESHARED_EXPORT TabWidget : public QWidget -{ - Q_OBJECT -public: - TabWidget(QWidget *parent = 0); - virtual ~TabWidget(); - - void setTitle(const QString &title); - QString title() const { return m_title; } - - void setFrameVisible(bool visible); - - void addTab(const QString &name, QWidget *widget, const QColor &color = Qt::black); - void insertTab(int index, const QString &name, QWidget *widget, const QColor &color = Qt::black); - QWidget* removeTab(int index); - int tabCount() const; - QString tabText(int index) const; - - int currentIndex() const; - void setCurrentIndex(int index); - -signals: - void currentIndexChanged(int index); - -protected: - virtual void paintEvent(QPaintEvent *event); - virtual void mousePressEvent(QMouseEvent *event); - virtual bool event(QEvent *event); - -private: - struct Tab { - QString name; - QColor color; - QWidget* widget; - }; - enum HitArea { HITNOTHING, HITOVERFLOW, HITTAB }; - QPair<TabWidget::HitArea, int> convertPosToTab(QPoint pos); - - QString m_title; - QList<Tab> m_tabs; - int m_currentIndex; - QVector<int> m_currentTabIndices; - int m_lastVisibleIndex; - QStackedWidget *m_stack; - bool m_drawFrame; -}; - -} // namespace Manhattan - -#endif // TABWIDGET_H diff --git a/ThirdParty/GUI/qt-manhattan-style/extensions/threelevelsitempicker.cpp b/ThirdParty/GUI/qt-manhattan-style/extensions/threelevelsitempicker.cpp deleted file mode 100644 index ca0b4403f222a375903de6ee3489ba10e7ad4fe5..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/extensions/threelevelsitempicker.cpp +++ /dev/null @@ -1,383 +0,0 @@ -#include "threelevelsitempicker.h" -#include "../stylehelper.h" -#include "../styledbar.h" -#include <QAction> -#include <QStyle> -#include <QStatusBar> -#include <QHBoxLayout> -#include <QPainter> -#include <QKeyEvent> -#include <QItemDelegate> -#include <QLabel> -#include <QTimer> - -namespace -{ - -QWidget *createTitleLabel(const QString &text) -{ - Manhattan::StyledBar *bar = new Manhattan::StyledBar; - bar->setSingleRow(true); - QVBoxLayout *toolLayout = new QVBoxLayout(bar); - toolLayout->setMargin(0); - toolLayout->setSpacing(0); - - QLabel *l = new QLabel(text); - l->setIndent(6); - QFont f = l->font(); - f.setBold(true); - l->setFont(f); - toolLayout->addWidget(l); - - int panelHeight = l->fontMetrics().height() + 12; - bar->ensurePolished(); // Required since manhattanstyle overrides height - bar->setFixedHeight(panelHeight); - return bar; -} - -} - -class OnePixelGreyLine : public QWidget -{ -public: - OnePixelGreyLine(QWidget *parent = 0) - : QWidget(parent) - { - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - setMinimumWidth(1); - setMaximumWidth(1); - } - void paintEvent(QPaintEvent *e) - { - Q_UNUSED(e); - QPainter p(this); - p.fillRect(contentsRect(), QColor(160, 160, 160, 255)); - } -}; - -using namespace Manhattan; - -ThreeLevelsItemPicker::ThreeLevelsItemPicker(const QString& level1Title, - const QString& level2Title, - const QString& level3Title, - QMap<QString, QStringList> level2ItemsFromlevel1, - QMap<QString, QStringList> level3ItemsFromLevel2, - QIcon icon, - QWidget* anchorWidget) - : QWidget() - , m_anchorWidget(anchorWidget) - , m_triggerAction(0) - , m_level2ItemsFromlevel1(level2ItemsFromlevel1) - , m_level3ItemsFromLevel2(level3ItemsFromLevel2) -{ - // Style - QPalette p = palette(); - p.setColor(QPalette::Text, QColor(255, 255, 255, 160)); - setPalette(p); - setProperty("panelwidget", true); - setContentsMargins(QMargins(0, 0, 1, 8)); - setWindowFlags(Qt::Popup); - - // List widgets - m_level1Items = new ListWidget; - m_level1Items->setMaxCount(5); - m_level1Items->addItems(m_level2ItemsFromlevel1.keys()); - connect(m_level1Items, SIGNAL(currentTextChanged(QString)), this, SLOT(setLevel1(QString))); - m_level2Items = new ListWidget; - m_level2Items->setMaxCount(5); - connect(m_level2Items, SIGNAL(currentTextChanged(QString)), this, SLOT(setLevel2(QString))); - m_level3Items = new ListWidget; - m_level3Items->setMaxCount(5); - connect(m_level3Items, SIGNAL(currentTextChanged(QString)), this, SLOT(setLevel3(QString))); - connect(m_level3Items, SIGNAL(itemReselected()), this, SLOT(hide())); - - QGridLayout *grid = new QGridLayout(this); - grid->setMargin(0); - grid->setSpacing(0); - - // Level 1 column - { - QWidget* title = ::createTitleLabel(level1Title); - grid->addWidget(title, 0, 0); - grid->addWidget(new OnePixelGreyLine, 0, 1); - grid->addWidget(m_level1Items, 1, 0); - grid->addWidget(new OnePixelGreyLine, 1, 1); - } - - // Level 2 column - { - QWidget* title = ::createTitleLabel(level2Title); - grid->addWidget(title, 0, 2); - grid->addWidget(new OnePixelGreyLine, 0, 3); - grid->addWidget(m_level2Items, 1, 2); - grid->addWidget(new OnePixelGreyLine, 1, 3); - } - - // Level 3 column - { - QWidget* title = ::createTitleLabel(level3Title); - grid->addWidget(title, 0, 4); - grid->addWidget(m_level3Items, 1, 4); - } - - this->setLayout(grid); - - // Mode selector action - m_triggerAction = new QAction(this); - m_triggerAction->setCheckable(true); - m_triggerAction->setEnabled(true); - m_triggerAction->setIcon(icon); - m_triggerAction->setProperty("titledAction", true); // will add the arrow ! - connect(m_triggerAction, SIGNAL(triggered()), this, SLOT(show())); -} - -void ThreeLevelsItemPicker::setVisible(bool visible) -{ - if (visible) - { - QPoint moveTo = m_anchorWidget->mapToGlobal(QPoint(m_anchorWidget->width() + 1,0)); - move(moveTo); - } - - QWidget::setVisible(visible); - m_triggerAction->setChecked(visible); -} - -void ThreeLevelsItemPicker::setMaxVisibleItemCount(int count) -{ - m_level1Items->setMaxCount(count); - m_level2Items->setMaxCount(count); - m_level3Items->setMaxCount(count); -} - -QString ThreeLevelsItemPicker::level1() const -{ - QListWidgetItem* item = m_level1Items->currentItem(); - return item ? item->text() : QString(); -} - -QString ThreeLevelsItemPicker::level2() const -{ - QListWidgetItem* item = m_level2Items->currentItem(); - return item ? item->text() : QString(); -} - -QString ThreeLevelsItemPicker::level3() const -{ - QListWidgetItem* item = m_level3Items->currentItem(); - return item ? item->text() : QString(); -} - -namespace helper_namespace -{ - -QListWidgetItem* find(const ListWidget* list, const QString& name) -{ - for (int row = 0; row < list->count(); ++row) - { - QListWidgetItem* item = list->item(row); - if (item->text() == name) - return item; - } - - return 0; -} - -} // Anonymous namespace - -void ThreeLevelsItemPicker::setLevel1Item(const QString& name) -{ - QListWidgetItem* item = helper_namespace::find(m_level1Items, name); - if (item) - m_level1Items->setCurrentItem(item); -} - -void ThreeLevelsItemPicker::setLevel2Item(const QString& name) -{ - QListWidgetItem* item = helper_namespace::find(m_level2Items, name); - if (item) - m_level2Items->setCurrentItem(item); -} - -void ThreeLevelsItemPicker::setLevel3Item(const QString& name) -{ - QListWidgetItem* item = helper_namespace::find(m_level3Items, name); - if (item) - m_level3Items->setCurrentItem(item); -} - -void ThreeLevelsItemPicker::setLevel1(const QString& name) -{ - m_level2Items->clear(); - m_level2Items->addItems(m_level2ItemsFromlevel1.value(name)); -} - -void ThreeLevelsItemPicker::setLevel2(const QString& name) -{ - m_level3Items->clear(); - m_level3Items->addItems(m_level3ItemsFromLevel2.value(name)); -} - -void ThreeLevelsItemPicker::setLevel3(const QString& name) -{ - if (name.isEmpty()) - return; - - m_triggerAction->setProperty("heading", name); - QListWidgetItem* item = m_level2Items->currentItem(); - m_triggerAction->setProperty("subtitle", item ? item->text() : ""); - smoothHide(); - emit itemChanged(); -} - -void ThreeLevelsItemPicker::smoothHide() -{ - QTimer::singleShot(200, this, SLOT(hide())); -} - -// This is a workaround for the problem that Windows -// will let the mouse events through when you click -// outside a popup to close it. This causes the popup -// to open on mouse release if you hit the button, which -// -// -// A similar case can be found in QComboBox -void ThreeLevelsItemPicker::mousePressEvent(QMouseEvent *e) -{ - setAttribute(Qt::WA_NoMouseReplay); - QWidget::mousePressEvent(e); -} - -void ThreeLevelsItemPicker::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.setPen(Manhattan::Utils::StyleHelper::borderColor()); - painter.drawLine(rect().topRight(), rect().bottomRight()); - - QRect bottomRect(0, rect().height() - 8, rect().width(), 8); - static QImage image(QLatin1String(":/projectexplorer/images/targetpanel_bottom.png")); - Manhattan::Utils::StyleHelper::drawCornerImage(image, &painter, bottomRect, 1, 1, 1, 1); -} - -//////// -// TargetSelectorDelegate -//////// -class TargetSelectorDelegate : public QItemDelegate -{ -public: - TargetSelectorDelegate(QObject *parent) : QItemDelegate(parent) { } -private: - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; - void paint(QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const; - mutable QImage selectionGradient; -}; - -QSize TargetSelectorDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - Q_UNUSED(option) - Q_UNUSED(index) - return QSize(190, 30); -} - -void TargetSelectorDelegate::paint(QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index) const -{ - painter->save(); - painter->setClipping(false); - - if (selectionGradient.isNull()) - selectionGradient.load(QLatin1String(":/projectexplorer/images/targetpanel_gradient.png")); - - if (option.state & QStyle::State_Selected) { - QColor color =(option.state & QStyle::State_HasFocus) ? - option.palette.highlight().color() : - option.palette.dark().color(); - painter->fillRect(option.rect, color.darker(140)); - Manhattan::Utils::StyleHelper::drawCornerImage(selectionGradient, painter, option.rect.adjusted(0, 0, 0, -1), 5, 5, 5, 5); - painter->setPen(QColor(255, 255, 255, 60)); - painter->drawLine(option.rect.topLeft(), option.rect.topRight()); - painter->setPen(QColor(255, 255, 255, 30)); - painter->drawLine(option.rect.bottomLeft() - QPoint(0,1), option.rect.bottomRight() - QPoint(0,1)); - painter->setPen(QColor(0, 0, 0, 80)); - painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight()); - } - - QFontMetrics fm(option.font); - QString text = index.data(Qt::DisplayRole).toString(); - painter->setPen(QColor(255, 255, 255, 160)); - QString elidedText = fm.elidedText(text, Qt::ElideMiddle, option.rect.width() - 12); - if (elidedText != text) - const_cast<QAbstractItemModel *>(index.model())->setData(index, text, Qt::ToolTipRole); - else - const_cast<QAbstractItemModel *>(index.model())->setData(index, QString(), Qt::ToolTipRole); - painter->drawText(option.rect.left() + 6, option.rect.top() + (option.rect.height() - fm.height()) / 2 + fm.ascent(), elidedText); - - painter->restore(); -} - -//////// -// ListWidget -//////// -ListWidget::ListWidget(QWidget *parent) - : QListWidget(parent), m_maxCount(0) -{ - setFocusPolicy(Qt::NoFocus); - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setAlternatingRowColors(false); - setFocusPolicy(Qt::WheelFocus); - setItemDelegate(new TargetSelectorDelegate(this)); - setAttribute(Qt::WA_MacShowFocusRect, false); - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - - // Style - QFile file(":/extensions/qss/threelevelsitempicker-listwidget.qss"); - file.open(QFile::ReadOnly); - QString styleSheet = QLatin1String(file.readAll()); - setStyleSheet(styleSheet); -} - -QSize ListWidget::sizeHint() const -{ - int height = m_maxCount * 30; - int width = 190; - QSize size(width, height); - return size; -} - -void ListWidget::keyPressEvent(QKeyEvent *event) -{ - if (event->key() == Qt::Key_Left) - focusPreviousChild(); - else if (event->key() == Qt::Key_Right) - focusNextChild(); - else - QListWidget::keyPressEvent(event); -} - -void ListWidget::keyReleaseEvent(QKeyEvent *event) -{ - if (event->key() != Qt::LeftArrow && event->key() != Qt::RightArrow) - QListWidget::keyReleaseEvent(event); -} - -void ListWidget::setMaxCount(int maxCount) -{ - // Note: the current assumption is that, this is not called while the listwidget is visible - // Otherwise we would need to add code to MiniProjectTargetSelector reacting to the - // updateGeometry (which then would jump ugly) - m_maxCount = maxCount; - updateGeometry(); -} - -void ListWidget::mouseReleaseEvent(QMouseEvent* event) -{ - QListWidgetItem* item = currentItem(); - QListWidget::mouseReleaseEvent(event); - if (item == currentItem()) - { - emit itemReselected(); - } -} diff --git a/ThirdParty/GUI/qt-manhattan-style/extensions/threelevelsitempicker.h b/ThirdParty/GUI/qt-manhattan-style/extensions/threelevelsitempicker.h deleted file mode 100644 index e51344cda9812e0b4c25bd8f5ab923498b321e95..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/extensions/threelevelsitempicker.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef THREELEVELSITEMPICKER_H -#define THREELEVELSITEMPICKER_H - -#include "../qt-manhattan-style_global.hpp" -#include <QWidget> -#include <QListWidget> -#include <QMap> - -class QStatusBar; - -namespace Manhattan { - -class ListWidget : public QListWidget -{ - Q_OBJECT - -public: - ListWidget(QWidget *parent = 0); - QSize sizeHint() const; - void keyPressEvent(QKeyEvent *event); - void keyReleaseEvent(QKeyEvent *event); - void setMaxCount(int maxCount); - -signals: - void itemReselected(); - -protected: - void mouseReleaseEvent(QMouseEvent* event); - -private: - int m_maxCount; -}; - -class QTMANHATTANSTYLESHARED_EXPORT ThreeLevelsItemPicker : public QWidget -{ - Q_OBJECT - -public: - explicit ThreeLevelsItemPicker(const QString& level1Title, - const QString& level2Title, - const QString& level3Title, - QMap<QString, QStringList> level2ItemsFromlevel1, - QMap<QString, QStringList> level3ItemsFromLevel2, - QIcon icon, - QWidget* anchorWidget); - - inline QAction* triggerAction() const { return m_triggerAction; } - void setVisible(bool visible); - void setMaxVisibleItemCount(int count); - - QString level1() const; - QString level2() const; - QString level3() const; - - void setLevel1Item(const QString& name); - void setLevel2Item(const QString& name); - void setLevel3Item(const QString& name); - -signals: - void itemChanged(); - -private slots: - void setLevel1(const QString& name); - void setLevel2(const QString& name); - void setLevel3(const QString& name); - void smoothHide(); - -private: - void mousePressEvent(QMouseEvent *); - void paintEvent(QPaintEvent *); - -private: - QWidget* m_anchorWidget; - QAction* m_triggerAction; - QMap<QString, QStringList> m_level2ItemsFromlevel1; - QMap<QString, QStringList> m_level3ItemsFromLevel2; - ListWidget* m_level1Items; - ListWidget* m_level2Items; - ListWidget* m_level3Items; -}; - -} // namespace Manhattan - -#endif // THREELEVELSITEMPICKER_H diff --git a/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.cpp b/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.cpp deleted file mode 100644 index bb4ec88ccbd3c214b87ea8030c56fcc87ccc11a9..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.cpp +++ /dev/null @@ -1,376 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "fancyactionbar.h" -#include "coreconstants.h" - -#include "stylehelper.h" -#include "settingsutils.h" - - -#include <QHBoxLayout> -#include <QPainter> -#include <QPicture> -#include <QVBoxLayout> -#include <QAction> -#include <QStatusBar> -#include <QStyle> -#include <QStyleOption> -#include <QMouseEvent> -#include <QApplication> -#include <QEvent> -#include <QAnimationGroup> -#include <QPropertyAnimation> - -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) -#define WIDTH_METHOD horizontalAdvance -#else -#define WIDTH_METHOD width -#endif - -using namespace Manhattan; - -FancyToolButton::FancyToolButton(QWidget *parent) - : QToolButton(parent), m_fader(0) -{ - m_hasForceVisible = false; - setAttribute(Qt::WA_Hover, true); - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); -} - -void FancyToolButton::forceVisible(bool visible) -{ - m_hasForceVisible = true; - setVisible(visible); -} - -bool FancyToolButton::event(QEvent *e) -{ - switch(e->type()) { - case QEvent::Enter: - { - QPropertyAnimation *animation = new QPropertyAnimation(this, "fader"); - animation->setDuration(125); - animation->setEndValue(1.0); - animation->start(QAbstractAnimation::DeleteWhenStopped); - } - break; - case QEvent::Leave: - { - QPropertyAnimation *animation = new QPropertyAnimation(this, "fader"); - animation->setDuration(125); - animation->setEndValue(0.0); - animation->start(QAbstractAnimation::DeleteWhenStopped); - } - break; - default: - return QToolButton::event(e); - } - return false; -} - -static QVector<QString> splitInTwoLines(const QString &text, const QFontMetrics &fontMetrics, - qreal availableWidth) -{ - // split in two lines. - // this looks if full words can be split off at the end of the string, - // to put them in the second line. First line is drawn with ellipsis, - // second line gets ellipsis if it couldn't split off full words. - QVector<QString> splitLines(2); - QRegExp rx(QLatin1String("\\s+")); - int splitPos = -1; - int nextSplitPos = text.length(); - do { - nextSplitPos = rx.lastIndexIn(text, - nextSplitPos - text.length() - 1); - if (nextSplitPos != -1) { - int splitCandidate = nextSplitPos + rx.matchedLength(); - if (fontMetrics.WIDTH_METHOD(text.mid(splitCandidate)) <= availableWidth) { - splitPos = splitCandidate; - } else { - break; - } - } - } while (nextSplitPos > 0 && fontMetrics.WIDTH_METHOD(text.left(nextSplitPos)) > availableWidth); - // check if we could split at white space at all - if (splitPos < 0) { - splitLines[0] = fontMetrics.elidedText(text, Qt::ElideRight, - static_cast<int>(availableWidth)); - QString common = Manhattan::commonPrefix(QStringList() - << splitLines[0] << text); - splitLines[1] = text.mid(common.length()); - // elide the second line even if it fits, since it is cut off in mid-word - while (fontMetrics.WIDTH_METHOD(QChar(0x2026) /*'...'*/ + splitLines[1]) > availableWidth - && splitLines[1].length() > 3 - /*keep at least three original characters (should not happen)*/) { - splitLines[1].remove(0, 1); - } - splitLines[1] = QChar(0x2026) /*'...'*/ + splitLines[1]; - } else { - splitLines[0] = fontMetrics.elidedText(text.left(splitPos).trimmed(), Qt::ElideRight, static_cast<int>(availableWidth)); - splitLines[1] = text.mid(splitPos); - } - return splitLines; -} - -void FancyToolButton::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event) - QPainter painter(this); - - // draw borders - bool isTitledAction = defaultAction()->property("titledAction").toBool(); - -#ifndef Q_OS_MAC // Mac UIs usually don't hover - if (m_fader > 0 && isEnabled() && !isDown() && !isChecked()) { - painter.save(); - int fader = int(40 * m_fader); - QLinearGradient grad(rect().topLeft(), rect().topRight()); - grad.setColorAt(0, Qt::transparent); - grad.setColorAt(0.5, QColor(255, 255, 255, fader)); - grad.setColorAt(1, Qt::transparent); - painter.fillRect(rect(), grad); - painter.setPen(QPen(grad, 1.0)); - painter.drawLine(rect().topLeft(), rect().topRight()); - painter.drawLine(rect().bottomLeft(), rect().bottomRight()); - painter.restore(); - } else -#endif - if (isDown() || isChecked()) { - painter.save(); - QLinearGradient grad(rect().topLeft(), rect().topRight()); - grad.setColorAt(0, Qt::transparent); - grad.setColorAt(0.5, QColor(0, 0, 0, 50)); - grad.setColorAt(1, Qt::transparent); - painter.fillRect(rect(), grad); - painter.setPen(QPen(grad, 1.0)); - painter.drawLine(rect().topLeft(), rect().topRight()); - painter.drawLine(rect().topLeft(), rect().topRight()); - painter.drawLine(rect().topLeft() + QPoint(0,1), rect().topRight() + QPoint(0,1)); - painter.drawLine(rect().bottomLeft(), rect().bottomRight()); - painter.drawLine(rect().bottomLeft(), rect().bottomRight()); - painter.drawLine(rect().topLeft() - QPoint(0,1), rect().topRight() - QPoint(0,1)); - painter.restore(); - } - QPixmap borderPixmap; - - QRect iconRect(0, 0, Manhattan::Constants::TARGET_ICON_SIZE, Manhattan::Constants::TARGET_ICON_SIZE); - // draw popup texts - if (isTitledAction) { - - QFont normalFont(painter.font()); - QRect centerRect = rect(); - normalFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); - QFont boldFont(normalFont); - boldFont.setBold(true); - QFontMetrics fm(normalFont); - QFontMetrics boldFm(boldFont); - int lineHeight = boldFm.height(); - int textFlags = Qt::AlignVCenter|Qt::AlignHCenter; - - const QString projectName = defaultAction()->property("heading").toString(); - if (!projectName.isNull()) - centerRect.adjust(0, lineHeight + 4, 0, 0); - - centerRect.adjust(0, 0, 0, -lineHeight*2 - 4); - - iconRect.moveCenter(centerRect.center()); - Utils::StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, isEnabled() ? QIcon::Normal : QIcon::Disabled); - painter.setFont(normalFont); - - QPoint textOffset = centerRect.center() - QPoint(iconRect.width()/2, iconRect.height()/2); - textOffset = textOffset - QPoint(0, lineHeight + 4); - QRectF r(0, textOffset.y(), rect().width(), lineHeight); - QColor penColor; - if (isEnabled()) - penColor = Qt::white; - else - penColor = Qt::gray; - painter.setPen(penColor); - - // draw project name - const int margin = 6; - const qreal availableWidth = r.width() - margin; - QString ellidedProjectName = fm.elidedText(projectName, Qt::ElideMiddle, static_cast<int>(availableWidth)); - if (isEnabled()) { - const QRectF shadowR = r.translated(0, 1); - painter.setPen(QColor(30, 30, 30, 80)); - painter.drawText(shadowR, textFlags, ellidedProjectName); - painter.setPen(penColor); - } - painter.drawText(r, textFlags, ellidedProjectName); - - // draw build configuration name - textOffset = iconRect.center() + QPoint(iconRect.width()/2, iconRect.height()/2); - QRectF buildConfigRect[2]; - buildConfigRect[0] = QRectF(0, textOffset.y() + 5, rect().width(), lineHeight); - buildConfigRect[1] = QRectF(0, textOffset.y() + 5 + lineHeight, rect().width(), lineHeight); - painter.setFont(boldFont); - QVector<QString> splitBuildConfiguration(2); - const QString buildConfiguration = defaultAction()->property("subtitle").toString(); - if (boldFm.WIDTH_METHOD(buildConfiguration) <= availableWidth) { - // text fits in one line - splitBuildConfiguration[0] = buildConfiguration; - } else { - splitBuildConfiguration = splitInTwoLines(buildConfiguration, boldFm, availableWidth); - } - // draw the two lines for the build configuration - for (int i = 0; i < 2; ++i) { - if (splitBuildConfiguration[i].isEmpty()) - continue; - if (isEnabled()) { - const QRectF shadowR = buildConfigRect[i].translated(0, 1); - painter.setPen(QColor(30, 30, 30, 80)); - painter.drawText(shadowR, textFlags, splitBuildConfiguration[i]); - painter.setPen(penColor); - } - painter.drawText(buildConfigRect[i], textFlags, splitBuildConfiguration[i]); - } - - // pop up arrow next to icon - if (!icon().isNull()) { - QStyleOption opt; - opt.initFrom(this); - opt.rect = rect().adjusted(rect().width() - 16, 0, -8, 0); - Utils::StyleHelper::drawArrow(QStyle::PE_IndicatorArrowRight, &painter, &opt); - } - } else { - iconRect.moveCenter(rect().center()); - Utils::StyleHelper::drawIconWithShadow(icon(), iconRect, &painter, isEnabled() ? QIcon::Normal : QIcon::Disabled); - } -} - -void FancyActionBar::setSeparator(SeparatorType type) -{ - if (type != m_separator) { - m_separator = type; - update(); - } -} - -void FancyActionBar::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event) - - if (m_separator == None) - return; - - QPainter painter(this); - QColor light = Utils::StyleHelper::sidebarHighlight(); - QColor dark = Utils::StyleHelper::sidebarShadow(); - if (m_separator == Top) { - painter.setPen(dark); - painter.drawLine(rect().topLeft(), rect().topRight()); - painter.setPen(light); - painter.drawLine(rect().topLeft() + QPoint(1,1), rect().topRight() + QPoint(0,1)); - } - else { - painter.setPen(dark); - painter.drawLine(rect().bottomLeft() - QPoint(0,2), rect().bottomRight() - QPoint(0,2)); - painter.setPen(light); - painter.drawLine(rect().bottomLeft() - QPoint(1,1), rect().bottomRight() - QPoint(0,1)); - } -} - -QSize FancyToolButton::sizeHint() const -{ - QSizeF buttonSize = iconSize().expandedTo(QSize(64, 38)); - if (defaultAction()->property("titledAction").toBool()) { - QFont boldFont(font()); - boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); - boldFont.setBold(true); - QFontMetrics fm(boldFont); - qreal lineHeight = fm.height(); - const QString projectName = defaultAction()->property("heading").toString(); - buttonSize += QSizeF(0, 10); - if (!projectName.isEmpty()) - buttonSize += QSizeF(0, lineHeight + 2); - - buttonSize += QSizeF(0, lineHeight*2 + 2); - } - return buttonSize.toSize(); -} - -QSize FancyToolButton::minimumSizeHint() const -{ - return QSize(8, 8); -} - -void FancyToolButton::actionChanged() -{ - // the default action changed in some way, e.g. it might got hidden - // since we inherit a tool button we won't get invisible, so do this here - if (!m_hasForceVisible) { - if (QAction* action = defaultAction()) - setVisible(action->isVisible()); - } -} - -FancyActionBar::FancyActionBar(QWidget *parent) - : QWidget(parent) - , m_separator(Top) -{ - setObjectName(QLatin1String("actionbar")); - m_actionsLayout = new QVBoxLayout; - QVBoxLayout *spacerLayout = new QVBoxLayout; - spacerLayout->addLayout(m_actionsLayout); - int sbh = 8; - spacerLayout->addSpacing(sbh); - spacerLayout->setMargin(0); - spacerLayout->setSpacing(0); - setLayout(spacerLayout); - setContentsMargins(0,2,0,0); -} - -void FancyActionBar::addProjectSelector(QAction *action) -{ - FancyToolButton* toolButton = new FancyToolButton(this); - toolButton->setDefaultAction(action); - connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged())); - m_actionsLayout->insertWidget(0, toolButton); - -} -void FancyActionBar::insertAction(int index, QAction *action) -{ - FancyToolButton *toolButton = new FancyToolButton(this); - toolButton->setDefaultAction(action); - connect(action, SIGNAL(changed()), toolButton, SLOT(actionChanged())); - m_actionsLayout->insertWidget(index, toolButton); -} - -QLayout *FancyActionBar::actionsLayout() const -{ - return m_actionsLayout; -} - -QSize FancyActionBar::minimumSizeHint() const -{ - return sizeHint(); -} - diff --git a/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.h b/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.h deleted file mode 100644 index e3e43dcfedd681c0de713c02fc559b273a23e965..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef FANCYACTIONBAR_H -#define FANCYACTIONBAR_H - -#include "qt-manhattan-style_global.hpp" -#include <QToolButton> - -QT_BEGIN_NAMESPACE -class QVBoxLayout; -QT_END_NAMESPACE - -namespace Manhattan { - -class QTMANHATTANSTYLESHARED_EXPORT FancyToolButton : public QToolButton -{ - Q_OBJECT - - Q_PROPERTY(float fader READ fader WRITE setFader) - -public: - FancyToolButton(QWidget *parent = 0); - - void paintEvent(QPaintEvent *event); - bool event(QEvent *e); - QSize sizeHint() const; - QSize minimumSizeHint() const; - - float m_fader; - float fader() { return m_fader; } - void setFader(float value) { m_fader = value; update(); } - - void forceVisible(bool visible); - -private slots: - void actionChanged(); - -private: - bool m_hasForceVisible; -}; - -class QTMANHATTANSTYLESHARED_EXPORT FancyActionBar : public QWidget -{ - Q_OBJECT - -public: - FancyActionBar(QWidget *parent = 0); - - enum SeparatorType { None = 0, Top, Bottom }; - void setSeparator(SeparatorType type); - - void paintEvent(QPaintEvent *event); - void insertAction(int index, QAction *action); - void addProjectSelector(QAction *action); - QLayout *actionsLayout() const; - QSize minimumSizeHint() const; - -private: - QVBoxLayout *m_actionsLayout; - SeparatorType m_separator; -}; - -} // namespace Manhattan - -#endif // FANCYACTIONBAR_H diff --git a/ThirdParty/GUI/qt-manhattan-style/fancylineedit.cpp b/ThirdParty/GUI/qt-manhattan-style/fancylineedit.cpp deleted file mode 100644 index 076981daba93883a9b23766ccfde70caf561df4c..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/fancylineedit.cpp +++ /dev/null @@ -1,371 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "fancylineedit.h" -#include "historycompleter.h" -#include "qtcassert.h" - -#include <QEvent> -#include <QString> -#include <QPropertyAnimation> -#include <QApplication> -#include <QMenu> -#include <QMouseEvent> -#include <QLabel> -#include <QAbstractButton> -#include <QPainter> -#include <QStyle> -#include <QPaintEvent> -#include <QDesktopWidget> - -/*! Opens a menu at the specified widget position. - * This functions computes the position where to show the menu, and opens it with - * QMenu::exec(). - * \param menu The menu to open - * \param widget The widget next to which to open the menu - */ -static void execMenuAtWidget(QMenu *menu, QWidget *widget) -{ - QPoint p; - QRect screen = qApp->desktop()->availableGeometry(widget); - QSize sh = menu->sizeHint(); - QRect rect = widget->rect(); - if (widget->isRightToLeft()) { - if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { - p = widget->mapToGlobal(rect.bottomRight()); - } else { - p = widget->mapToGlobal(rect.topRight() - QPoint(0, sh.height())); - } - p.rx() -= sh.width(); - } else { - if (widget->mapToGlobal(QPoint(0, rect.bottom())).y() + sh.height() <= screen.height()) { - p = widget->mapToGlobal(rect.bottomLeft()); - } else { - p = widget->mapToGlobal(rect.topLeft() - QPoint(0, sh.height())); - } - } - p.rx() = qMax(screen.left(), qMin(p.x(), screen.right() - sh.width())); - p.ry() += 1; - - menu->exec(p); -} - -/*! - \class Utils::FancyLineEdit - - \brief A line edit with an embedded pixmap on one side that is connected to - a menu. - - Additionally, it can display a grayed hintText (like "Type Here to") - when not focused and empty. When connecting to the changed signals and - querying text, one has to be aware that the text is set to that hint - text if isShowingHintText() returns true (that is, does not contain - valid user input). - */ - -enum { margin = 6 }; - -#define ICONBUTTON_HEIGHT 18 -#define FADE_TIME 160 - -namespace Manhattan { - -// --------- FancyLineEditPrivate -class FancyLineEditPrivate : public QObject -{ -public: - explicit FancyLineEditPrivate(FancyLineEdit *parent); - - virtual bool eventFilter(QObject *obj, QEvent *event); - - FancyLineEdit *m_lineEdit; - QPixmap m_pixmap[2]; - QMenu *m_menu[2]; - bool m_menuTabFocusTrigger[2]; - IconButton *m_iconbutton[2]; - bool m_iconEnabled[2]; - - HistoryCompleter *m_historyCompleter; -}; - - -FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) : - QObject(parent), m_lineEdit(parent), m_historyCompleter(0) -{ - for (int i = 0; i < 2; ++i) { - m_menu[i] = 0; - m_menuTabFocusTrigger[i] = false; - m_iconbutton[i] = new IconButton(parent); - m_iconbutton[i]->installEventFilter(this); - m_iconbutton[i]->hide(); - m_iconbutton[i]->setAutoHide(false); - m_iconEnabled[i] = false; - } -} - -bool FancyLineEditPrivate::eventFilter(QObject *obj, QEvent *event) -{ - int buttonIndex = -1; - for (int i = 0; i < 2; ++i) { - if (obj == m_iconbutton[i]) { - buttonIndex = i; - break; - } - } - if (buttonIndex == -1) - return QObject::eventFilter(obj, event); - switch (event->type()) { - case QEvent::FocusIn: - if (m_menuTabFocusTrigger[buttonIndex] && m_menu[buttonIndex]) { - m_lineEdit->setFocus(); - execMenuAtWidget(m_menu[buttonIndex], m_iconbutton[buttonIndex]); - return true; - } - default: - break; - } - return QObject::eventFilter(obj, event); -} - - -// --------- FancyLineEdit -FancyLineEdit::FancyLineEdit(QWidget *parent) : - QLineEdit(parent), - d(new FancyLineEditPrivate(this)) -{ - ensurePolished(); - updateMargins(); - - connect(this, SIGNAL(textChanged(QString)), this, SLOT(checkButtons(QString))); - connect(d->m_iconbutton[Left], SIGNAL(clicked()), this, SLOT(iconClicked())); - connect(d->m_iconbutton[Right], SIGNAL(clicked()), this, SLOT(iconClicked())); -} - -void FancyLineEdit::checkButtons(const QString &text) -{ - if (m_oldText.isEmpty() || text.isEmpty()) { - for (int i = 0; i < 2; ++i) { - if (d->m_iconbutton[i]->hasAutoHide()) - d->m_iconbutton[i]->animateShow(!text.isEmpty()); - } - m_oldText = text; - } -} - -FancyLineEdit::~FancyLineEdit() -{ -} - -void FancyLineEdit::setButtonVisible(Side side, bool visible) -{ - d->m_iconbutton[side]->setVisible(visible); - d->m_iconEnabled[side] = visible; - updateMargins(); -} - -bool FancyLineEdit::isButtonVisible(Side side) const -{ - return d->m_iconEnabled[side]; -} - -void FancyLineEdit::iconClicked() -{ - IconButton *button = qobject_cast<IconButton *>(sender()); - int index = -1; - for (int i = 0; i < 2; ++i) - if (d->m_iconbutton[i] == button) - index = i; - if (index == -1) - return; - if (d->m_menu[index]) { - execMenuAtWidget(d->m_menu[index], button); - } else { - emit buttonClicked((Side)index); - if (index == Left) - emit leftButtonClicked(); - else if (index == Right) - emit rightButtonClicked(); - } -} - -void FancyLineEdit::updateMargins() -{ - bool leftToRight = (layoutDirection() == Qt::LeftToRight); - Side realLeft = (leftToRight ? Left : Right); - Side realRight = (leftToRight ? Right : Left); - - int leftMargin = d->m_iconbutton[realLeft]->pixmap().width() + 8; - int rightMargin = d->m_iconbutton[realRight]->pixmap().width() + 8; - // Note KDE does not reserve space for the highlight color - if (style()->inherits("OxygenStyle")) { - leftMargin = qMax(24, leftMargin); - rightMargin = qMax(24, rightMargin); - } - - QMargins margins((d->m_iconEnabled[realLeft] ? leftMargin : 0), 0, - (d->m_iconEnabled[realRight] ? rightMargin : 0), 0); - - setTextMargins(margins); -} - -void FancyLineEdit::updateButtonPositions() -{ - QRect contentRect = rect(); - for (int i = 0; i < 2; ++i) { - Side iconpos = (Side)i; - if (layoutDirection() == Qt::RightToLeft) - iconpos = (iconpos == Left ? Right : Left); - - if (iconpos == FancyLineEdit::Right) { - const int iconoffset = textMargins().right() + 4; - d->m_iconbutton[i]->setGeometry(contentRect.adjusted(width() - iconoffset, 0, 0, 0)); - } else { - const int iconoffset = textMargins().left() + 4; - d->m_iconbutton[i]->setGeometry(contentRect.adjusted(0, 0, -width() + iconoffset, 0)); - } - } -} - -void FancyLineEdit::resizeEvent(QResizeEvent *) -{ - updateButtonPositions(); -} - -void FancyLineEdit::setButtonPixmap(Side side, const QPixmap &buttonPixmap) -{ - d->m_iconbutton[side]->setPixmap(buttonPixmap); - updateMargins(); - updateButtonPositions(); - update(); -} - -QPixmap FancyLineEdit::buttonPixmap(Side side) const -{ - return d->m_pixmap[side]; -} - -void FancyLineEdit::setButtonMenu(Side side, QMenu *buttonMenu) -{ - d->m_menu[side] = buttonMenu; - d->m_iconbutton[side]->setIconOpacity(1.0); - } - -QMenu *FancyLineEdit::buttonMenu(Side side) const -{ - return d->m_menu[side]; -} - -bool FancyLineEdit::hasMenuTabFocusTrigger(Side side) const -{ - return d->m_menuTabFocusTrigger[side]; -} - -void FancyLineEdit::setMenuTabFocusTrigger(Side side, bool v) -{ - if (d->m_menuTabFocusTrigger[side] == v) - return; - - d->m_menuTabFocusTrigger[side] = v; - d->m_iconbutton[side]->setFocusPolicy(v ? Qt::TabFocus : Qt::NoFocus); -} - -bool FancyLineEdit::hasAutoHideButton(Side side) const -{ - return d->m_iconbutton[side]->hasAutoHide(); -} - -void FancyLineEdit::setHistoryCompleter(const QString &historyKey) -{ - QTC_ASSERT(!d->m_historyCompleter, return); - d->m_historyCompleter = new HistoryCompleter(this, historyKey, this); - QLineEdit::setCompleter(d->m_historyCompleter); -} - -void FancyLineEdit::setSpecialCompleter(QCompleter *completer) -{ - QTC_ASSERT(!d->m_historyCompleter, return); - QLineEdit::setCompleter(completer); -} - -void FancyLineEdit::setAutoHideButton(Side side, bool h) -{ - d->m_iconbutton[side]->setAutoHide(h); - if (h) - d->m_iconbutton[side]->setIconOpacity(text().isEmpty() ? 0.0 : 1.0); - else - d->m_iconbutton[side]->setIconOpacity(1.0); -} - -void FancyLineEdit::setButtonToolTip(Side side, const QString &tip) -{ - d->m_iconbutton[side]->setToolTip(tip); -} - -void FancyLineEdit::setButtonFocusPolicy(Side side, Qt::FocusPolicy policy) -{ - d->m_iconbutton[side]->setFocusPolicy(policy); -} - -// IconButton - helper class to represent a clickable icon - -IconButton::IconButton(QWidget *parent) - : QAbstractButton(parent), m_autoHide(false) -{ - setCursor(Qt::ArrowCursor); - setFocusPolicy(Qt::NoFocus); -} - -void IconButton::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - QRect pixmapRect = QRect(0, 0, m_pixmap.width(), m_pixmap.height()); - pixmapRect.moveCenter(rect().center()); - - if (m_autoHide) - painter.setOpacity(m_iconOpacity); - - painter.drawPixmap(pixmapRect, m_pixmap); -} - -void IconButton::animateShow(bool visible) -{ - if (visible) { - QPropertyAnimation *animation = new QPropertyAnimation(this, "iconOpacity"); - animation->setDuration(FADE_TIME); - animation->setEndValue(1.0); - animation->start(QAbstractAnimation::DeleteWhenStopped); - } else { - QPropertyAnimation *animation = new QPropertyAnimation(this, "iconOpacity"); - animation->setDuration(FADE_TIME); - animation->setEndValue(0.0); - animation->start(QAbstractAnimation::DeleteWhenStopped); - } -} - -} // namespace Manhattan diff --git a/ThirdParty/GUI/qt-manhattan-style/fancylineedit.h b/ThirdParty/GUI/qt-manhattan-style/fancylineedit.h deleted file mode 100644 index 2f14c0f6835c1036a13e589b12f4da9be442246c..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/fancylineedit.h +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef FANCYLINEEDIT_H -#define FANCYLINEEDIT_H - -#include "qt-manhattan-style_global.hpp" - -#include <QLineEdit> -#include <QAbstractButton> - -namespace Manhattan { - -class FancyLineEditPrivate; - -class QTMANHATTANSTYLESHARED_EXPORT IconButton: public QAbstractButton -{ - Q_OBJECT - Q_PROPERTY(float iconOpacity READ iconOpacity WRITE setIconOpacity) - Q_PROPERTY(bool autoHide READ hasAutoHide WRITE setAutoHide) - Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap) -public: - explicit IconButton(QWidget *parent = 0); - void paintEvent(QPaintEvent *event); - void setPixmap(const QPixmap &pixmap) { m_pixmap = pixmap; update(); } - QPixmap pixmap() const { return m_pixmap; } - float iconOpacity() { return m_iconOpacity; } - void setIconOpacity(float value) { m_iconOpacity = value; update(); } - void animateShow(bool visible); - - void setAutoHide(bool hide) { m_autoHide = hide; } - bool hasAutoHide() const { return m_autoHide; } -private: - float m_iconOpacity; - bool m_autoHide; - QPixmap m_pixmap; -}; - -class QTMANHATTANSTYLESHARED_EXPORT FancyLineEdit : public QLineEdit -{ - Q_OBJECT - Q_ENUMS(Side) - -public: - enum Side {Left = 0, Right = 1}; - - explicit FancyLineEdit(QWidget *parent = 0); - virtual ~FancyLineEdit(); - - QPixmap buttonPixmap(Side side) const; - void setButtonPixmap(Side side, const QPixmap &pixmap); - - QMenu *buttonMenu(Side side) const; - void setButtonMenu(Side side, QMenu *menu); - - void setButtonVisible(Side side, bool visible); - bool isButtonVisible(Side side) const; - - void setButtonToolTip(Side side, const QString &); - void setButtonFocusPolicy(Side side, Qt::FocusPolicy policy); - - // Set whether tabbing in will trigger the menu. - void setMenuTabFocusTrigger(Side side, bool v); - bool hasMenuTabFocusTrigger(Side side) const; - - // Set if icon should be hidden when text is empty - void setAutoHideButton(Side side, bool h); - bool hasAutoHideButton(Side side) const; - - // Enable a history completer with a history of entries. - void setHistoryCompleter(const QString &historyKey); - - // Sets a completer that is not a history completer. - void setSpecialCompleter(QCompleter *completer); - -signals: - void buttonClicked(Manhattan::FancyLineEdit::Side side); - void leftButtonClicked(); - void rightButtonClicked(); - -private slots: - void checkButtons(const QString &); - void iconClicked(); - -protected: - virtual void resizeEvent(QResizeEvent *e); - -private: - // Unimplemented, to force the user to make a decision on - // whether to use setHistoryKey() or setSpecialCompleter(). - void setCompleter(QCompleter *); - - void updateMargins(); - void updateButtonPositions(); - friend class Manhattan::FancyLineEditPrivate; - - FancyLineEditPrivate *d; - QString m_oldText; -}; - -} // namespace Manhattan - -#endif // FANCYLINEEDIT_H diff --git a/ThirdParty/GUI/qt-manhattan-style/fancymainwindow.cpp b/ThirdParty/GUI/qt-manhattan-style/fancymainwindow.cpp deleted file mode 100644 index 67e112bbc90479095dda7abe73dec4f4556442f7..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/fancymainwindow.cpp +++ /dev/null @@ -1,607 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "fancymainwindow.h" - -#include "qtcassert.h" - -#include <QAbstractButton> -#include <QApplication> -#include <QContextMenuEvent> -#include <QDockWidget> -#include <QHBoxLayout> -#include <QLabel> -#include <QMenu> -#include <QPainter> -#include <QSettings> -#include <QStyle> -#include <QStyleOption> -#include <QTimer> -#include <QToolButton> -#include <algorithm> - -static const char AutoHideTitleBarsKey[] = "AutoHideTitleBars"; -static const char ShowCentralWidgetKey[] = "ShowCentralWidget"; -static const char StateKey[] = "State"; - -static const int settingsVersion = 2; -static const char dockWidgetActiveState[] = "DockWidgetActiveState"; - -namespace { -QString stripAccelerator(const QString &text) -{ - QString res = text; - for (int index = res.indexOf('&'); index != -1; index = res.indexOf('&', index + 1)) - res.remove(index, 1); - return res; -} -} - -namespace Manhattan { - -class TitleBarWidget; - -struct FancyMainWindowPrivate -{ - FancyMainWindowPrivate(FancyMainWindow *parent); - - FancyMainWindow *q; - - bool m_handleDockVisibilityChanges; - QAction m_showCentralWidget; - QAction m_menuSeparator1; - QAction m_menuSeparator2; - QAction m_resetLayoutAction; - QAction m_autoHideTitleBars; -}; - -class DockWidget : public QDockWidget -{ -public: - DockWidget(QWidget *inner, FancyMainWindow *parent, bool immutable = false); - - bool eventFilter(QObject *, QEvent *event) override; - void enterEvent(QEvent *event) override; - void leaveEvent(QEvent *event) override; - void handleMouseTimeout(); - void handleToplevelChanged(bool floating); - - FancyMainWindow *q; - -private: - QPoint m_startPos; - TitleBarWidget *m_titleBar; - QTimer m_timer; - bool m_immutable = false; -}; - -// Stolen from QDockWidgetTitleButton -class DockWidgetTitleButton : public QAbstractButton -{ -public: - DockWidgetTitleButton(QWidget *parent) - : QAbstractButton(parent) - { - setFocusPolicy(Qt::NoFocus); - } - - QSize sizeHint() const override - { - ensurePolished(); - - int size = 2*style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin, nullptr, this); - if (!icon().isNull()) { - int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this); - QSize sz = icon().actualSize(QSize(iconSize, iconSize)); - size += qMax(sz.width(), sz.height()); - } - - return QSize(size, size); - } - - QSize minimumSizeHint() const override { return sizeHint(); } - - void enterEvent(QEvent *event) override - { - if (isEnabled()) - update(); - QAbstractButton::enterEvent(event); - } - - void leaveEvent(QEvent *event) override - { - if (isEnabled()) - update(); - QAbstractButton::leaveEvent(event); - } - - void paintEvent(QPaintEvent *event) override; -}; - -void DockWidgetTitleButton::paintEvent(QPaintEvent *) -{ - QPainter p(this); - - QStyleOptionToolButton opt; - opt.init(this); - opt.state |= QStyle::State_AutoRaise; - opt.icon = icon(); - opt.subControls = nullptr; - opt.activeSubControls = nullptr; - opt.features = QStyleOptionToolButton::None; - opt.arrowType = Qt::NoArrow; - int size = style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, this); - opt.iconSize = QSize(size, size); - style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &p, this); -} - -class TitleBarWidget : public QWidget -{ -public: - TitleBarWidget(DockWidget *parent, const QStyleOptionDockWidget &opt) - : QWidget(parent), q(parent), m_active(true) - { - m_titleLabel = new QLabel(this); - - m_floatButton = new DockWidgetTitleButton(this); - m_floatButton->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarNormalButton, &opt, q)); - m_floatButton->setToolTip("Undocks and re-attaches the dock widget"); - - m_closeButton = new DockWidgetTitleButton(this); - m_closeButton->setIcon(q->style()->standardIcon(QStyle::SP_TitleBarCloseButton, &opt, q)); - m_closeButton->setToolTip("Closes the dock widget"); - -#ifndef QT_NO_ACCESSIBILITY - m_floatButton->setAccessibleName(QDockWidget::tr("Float")); - m_floatButton->setAccessibleDescription(QDockWidget::tr("Undocks and re-attaches the dock widget")); - m_closeButton->setAccessibleName(QDockWidget::tr("Close")); - m_closeButton->setAccessibleDescription(QDockWidget::tr("Closes the dock widget")); -#endif - - setActive(false); - - const int minWidth = 10; - const int maxWidth = 10000; - const int inactiveHeight = 0; - const int activeHeight = m_closeButton->sizeHint().height() + 2; - - m_minimumInactiveSize = QSize(minWidth, inactiveHeight); - m_maximumInactiveSize = QSize(maxWidth, inactiveHeight); - m_minimumActiveSize = QSize(minWidth, activeHeight); - m_maximumActiveSize = QSize(maxWidth, activeHeight); - - auto layout = new QHBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); - layout->setContentsMargins(4, 0, 0, 0); - layout->addWidget(m_titleLabel); - layout->addStretch(); - layout->addWidget(m_floatButton); - layout->addWidget(m_closeButton); - setLayout(layout); - - setProperty("managed_titlebar", 1); - } - - void enterEvent(QEvent *event) override - { - setActive(true); - QWidget::enterEvent(event); - } - - void setActive(bool on) - { - m_active = on; - updateChildren(); - } - - void updateChildren() - { - bool clickable = isClickable(); - m_titleLabel->setVisible(clickable); - m_floatButton->setVisible(clickable); - m_closeButton->setVisible(clickable); - } - - bool isClickable() const - { - return m_active || !q->q->autoHideTitleBars(); - } - - QSize sizeHint() const override - { - ensurePolished(); - return isClickable() ? m_maximumActiveSize : m_maximumInactiveSize; - } - - QSize minimumSizeHint() const override - { - ensurePolished(); - return isClickable() ? m_minimumActiveSize : m_minimumInactiveSize; - } - -private: - DockWidget *q; - bool m_active; - QSize m_minimumActiveSize; - QSize m_maximumActiveSize; - QSize m_minimumInactiveSize; - QSize m_maximumInactiveSize; - -public: - QLabel *m_titleLabel; - DockWidgetTitleButton *m_floatButton; - DockWidgetTitleButton *m_closeButton; -}; - -DockWidget::DockWidget(QWidget *inner, FancyMainWindow *parent, bool immutable) - : QDockWidget(parent), q(parent), m_immutable(immutable) -{ - setWidget(inner); - setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); - setObjectName(inner->objectName() + QLatin1String("DockWidget")); - setMouseTracking(true); - - QString title = inner->windowTitle(); - toggleViewAction()->setProperty("original_title", title); - title = stripAccelerator(title); - setWindowTitle(title); - - QStyleOptionDockWidget opt; - initStyleOption(&opt); - m_titleBar = new TitleBarWidget(this, opt); - m_titleBar->m_titleLabel->setText(title); - setTitleBarWidget(m_titleBar); - - if (immutable) - return; - - m_timer.setSingleShot(true); - m_timer.setInterval(500); - - connect(&m_timer, &QTimer::timeout, this, &DockWidget::handleMouseTimeout); - - connect(this, &QDockWidget::topLevelChanged, this, &DockWidget::handleToplevelChanged); - - connect(toggleViewAction(), &QAction::triggered, - [this]() { - if (isVisible()) - raise(); - }); - - auto origFloatButton = findChild<QAbstractButton *>(QLatin1String("qt_dockwidget_floatbutton")); - connect(m_titleBar->m_floatButton, &QAbstractButton::clicked, - origFloatButton, &QAbstractButton::clicked); - - auto origCloseButton = findChild<QAbstractButton *>(QLatin1String("qt_dockwidget_closebutton")); - connect(m_titleBar->m_closeButton, &QAbstractButton::clicked, - origCloseButton, &QAbstractButton::clicked); -} - -bool DockWidget::eventFilter(QObject *, QEvent *event) -{ - if (!m_immutable && event->type() == QEvent::MouseMove && q->autoHideTitleBars()) { - auto me = static_cast<QMouseEvent *>(event); - int y = me->pos().y(); - int x = me->pos().x(); - int h = qMin(8, m_titleBar->m_floatButton->height()); - if (!isFloating() && widget() && 0 <= x && x < widget()->width() && 0 <= y && y <= h) { - m_timer.start(); - m_startPos = mapToGlobal(me->pos()); - } - } - return false; -} - -void DockWidget::enterEvent(QEvent *event) -{ - if (!m_immutable) - QApplication::instance()->installEventFilter(this); - QDockWidget::enterEvent(event); -} - -void DockWidget::leaveEvent(QEvent *event) -{ - if (!m_immutable) { - if (!isFloating()) { - m_timer.stop(); - m_titleBar->setActive(false); - } - QApplication::instance()->removeEventFilter(this); - } - QDockWidget::leaveEvent(event); -} - -void DockWidget::handleMouseTimeout() -{ - QPoint dist = m_startPos - QCursor::pos(); - if (!isFloating() && dist.manhattanLength() < 4) - m_titleBar->setActive(true); -} - -void DockWidget::handleToplevelChanged(bool floating) -{ - m_titleBar->setActive(floating); -} - - - -/*! \class Utils::FancyMainWindow - - \brief The FancyMainWindow class is a MainWindow with dock widgets and - additional "lock" functionality - (locking the dock widgets in place) and "reset layout" functionality. - - The dock actions and the additional actions should be accessible - in a Window-menu. -*/ - -FancyMainWindowPrivate::FancyMainWindowPrivate(FancyMainWindow *parent) : - q(parent), - m_handleDockVisibilityChanges(true), - m_showCentralWidget(FancyMainWindow::tr("Central Widget"), nullptr), - m_menuSeparator1(nullptr), - m_menuSeparator2(nullptr), - m_resetLayoutAction(FancyMainWindow::tr("Reset to Default Layout"), nullptr), - m_autoHideTitleBars(FancyMainWindow::tr("Automatically Hide View Title Bars"), nullptr) -{ - m_showCentralWidget.setCheckable(true); - m_showCentralWidget.setChecked(true); - - m_menuSeparator1.setSeparator(true); - m_menuSeparator2.setSeparator(true); - - m_autoHideTitleBars.setCheckable(true); - m_autoHideTitleBars.setChecked(true); - - QObject::connect(&m_autoHideTitleBars, &QAction::toggled, q, [this](bool) { - for (QDockWidget *dock : q->dockWidgets()) { - if (auto titleBar = dynamic_cast<TitleBarWidget *>(dock->titleBarWidget())) - titleBar->updateChildren(); - } - }); - - QObject::connect(&m_showCentralWidget, &QAction::toggled, q, [this](bool visible) { - q->centralWidget()->setVisible(visible); - }); -} - -FancyMainWindow::FancyMainWindow(QWidget *parent) : - QMainWindow(parent), d(new FancyMainWindowPrivate(this)) -{ - connect(&d->m_resetLayoutAction, &QAction::triggered, - this, &FancyMainWindow::resetLayout); -} - -FancyMainWindow::~FancyMainWindow() -{ - delete d; -} - -QDockWidget *FancyMainWindow::addDockForWidget(QWidget *widget, bool immutable) -{ - QTC_ASSERT(widget, return nullptr); - QTC_CHECK(widget->objectName().size()); - QTC_CHECK(widget->windowTitle().size()); - - auto dockWidget = new DockWidget(widget, this, immutable); - - if (!immutable) { - connect(dockWidget, &QDockWidget::visibilityChanged, - [this, dockWidget](bool visible) { - if (d->m_handleDockVisibilityChanges) - dockWidget->setProperty(dockWidgetActiveState, visible); - }); - - connect(dockWidget->toggleViewAction(), &QAction::triggered, - this, &FancyMainWindow::onDockActionTriggered, - Qt::QueuedConnection); - - dockWidget->setProperty(dockWidgetActiveState, true); - } - - return dockWidget; -} - -void FancyMainWindow::onDockActionTriggered() -{ - auto dw = qobject_cast<QDockWidget *>(sender()->parent()); - if (dw) { - if (dw->isVisible()) - dw->raise(); - } -} - -void FancyMainWindow::setTrackingEnabled(bool enabled) -{ - if (enabled) { - d->m_handleDockVisibilityChanges = true; - for (QDockWidget *dockWidget : dockWidgets()) - dockWidget->setProperty(dockWidgetActiveState, dockWidget->isVisible()); - } else { - d->m_handleDockVisibilityChanges = false; - } -} - -void FancyMainWindow::hideEvent(QHideEvent *event) -{ - Q_UNUSED(event) - handleVisibilityChanged(false); -} - -void FancyMainWindow::showEvent(QShowEvent *event) -{ - Q_UNUSED(event) - handleVisibilityChanged(true); -} - -void FancyMainWindow::contextMenuEvent(QContextMenuEvent *event) -{ - QMenu menu; - addDockActionsToMenu(&menu); - menu.exec(event->globalPos()); -} - -void FancyMainWindow::handleVisibilityChanged(bool visible) -{ - d->m_handleDockVisibilityChanges = false; - for (QDockWidget *dockWidget : dockWidgets()) { - if (dockWidget->isFloating()) { - dockWidget->setVisible(visible - && dockWidget->property(dockWidgetActiveState).toBool()); - } - } - if (visible) - d->m_handleDockVisibilityChanges = true; -} - -void FancyMainWindow::saveSettings(QSettings *settings) const -{ - QHash<QString, QVariant> hash = saveSettings(); - QHashIterator<QString, QVariant> it(hash); - while (it.hasNext()) { - it.next(); - settings->setValue(it.key(), it.value()); - } -} - -void FancyMainWindow::restoreSettings(const QSettings *settings) -{ - QHash<QString, QVariant> hash; - foreach (const QString &key, settings->childKeys()) { - hash.insert(key, settings->value(key)); - } - restoreSettings(hash); -} - -QHash<QString, QVariant> FancyMainWindow::saveSettings() const -{ - QHash<QString, QVariant> settings; - settings.insert(QLatin1String(StateKey), saveState(settingsVersion)); - settings.insert(QLatin1String(AutoHideTitleBarsKey), - d->m_autoHideTitleBars.isChecked()); - settings.insert(ShowCentralWidgetKey, d->m_showCentralWidget.isChecked()); - for (QDockWidget *dockWidget : dockWidgets()) { - settings.insert(dockWidget->objectName(), - dockWidget->property(dockWidgetActiveState)); - } - return settings; -} - -void FancyMainWindow::restoreSettings(const QHash<QString, QVariant> &settings) -{ - QByteArray ba = settings.value(QLatin1String(StateKey), QByteArray()).toByteArray(); - if (!ba.isEmpty()) - restoreState(ba, settingsVersion); - bool on = settings.value(QLatin1String(AutoHideTitleBarsKey), true).toBool(); - d->m_autoHideTitleBars.setChecked(on); - d->m_showCentralWidget.setChecked(settings.value(ShowCentralWidgetKey, true).toBool()); - for (QDockWidget *widget : dockWidgets()) { - widget->setProperty(dockWidgetActiveState, - settings.value(widget->objectName(), false)); - } -} - -const QList<QDockWidget *> FancyMainWindow::dockWidgets() const -{ - return findChildren<QDockWidget *>(); -} - -bool FancyMainWindow::autoHideTitleBars() const -{ - return d->m_autoHideTitleBars.isChecked(); -} - -QMenu* FancyMainWindow::createPopupMenu() -{ - QMenu *menu = new QMenu(this); - addDockActionsToMenu(menu); - return menu; -} - -void FancyMainWindow::addDockActionsToMenu(QMenu *menu) -{ - QList<QAction *> actions; - QList<QDockWidget *> dockwidgets = findChildren<QDockWidget *>(); - for (int i = 0; i < dockwidgets.size(); ++i) { - QDockWidget *dockWidget = dockwidgets.at(i); - if (dockWidget->property("managed_dockwidget").isNull() - && dockWidget->parentWidget() == this) { - QAction *action = dockWidget->toggleViewAction(); - action->setText(action->property("original_title").toString()); - actions.append(action); - } - } - std::sort(actions.begin(), actions.end(), [](const QAction *action1, const QAction *action2) { - QTC_ASSERT(action1, return true); - QTC_ASSERT(action2, return false); - return stripAccelerator(action1->text()).toLower() < stripAccelerator(action2->text()).toLower(); - }); - foreach (QAction *action, actions) - menu->addAction(action); - menu->addAction(&d->m_showCentralWidget); - menu->addAction(&d->m_menuSeparator1); - menu->addAction(&d->m_autoHideTitleBars); - menu->addAction(&d->m_menuSeparator2); - menu->addAction(&d->m_resetLayoutAction); -} - -QAction *FancyMainWindow::menuSeparator1() const -{ - return &d->m_menuSeparator1; -} - -QAction *FancyMainWindow::autoHideTitleBarsAction() const -{ - return &d->m_autoHideTitleBars; -} - -QAction *FancyMainWindow::menuSeparator2() const -{ - return &d->m_menuSeparator2; -} - -QAction *FancyMainWindow::resetLayoutAction() const -{ - return &d->m_resetLayoutAction; -} - -QAction *FancyMainWindow::showCentralWidgetAction() const -{ - return &d->m_showCentralWidget; -} - -void FancyMainWindow::setDockActionsVisible(bool v) -{ - for (const QDockWidget *dockWidget : dockWidgets()) - dockWidget->toggleViewAction()->setVisible(v); - d->m_showCentralWidget.setVisible(v); - d->m_autoHideTitleBars.setVisible(v); - d->m_menuSeparator1.setVisible(v); - d->m_menuSeparator2.setVisible(v); - d->m_resetLayoutAction.setVisible(v); -} - -} // namespace Utils diff --git a/ThirdParty/GUI/qt-manhattan-style/fancymainwindow.h b/ThirdParty/GUI/qt-manhattan-style/fancymainwindow.h deleted file mode 100644 index 3d2f3bbffd5623764a2f695865efade501670e86..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/fancymainwindow.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#ifndef FANCYMAINWINDOW_H -#define FANCYMAINWINDOW_H - -#include "qt-manhattan-style_global.hpp" - -#include <QMainWindow> - -QT_BEGIN_NAMESPACE -class QSettings; -QT_END_NAMESPACE - -namespace Manhattan { - -struct FancyMainWindowPrivate; - -class QTMANHATTANSTYLESHARED_EXPORT FancyMainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit FancyMainWindow(QWidget *parent = nullptr); - ~FancyMainWindow() override; - - /* The widget passed in should have an objectname set - * which will then be used as key for QSettings. */ - QDockWidget *addDockForWidget(QWidget *widget, bool immutable = false); - const QList<QDockWidget *> dockWidgets() const; - - void setTrackingEnabled(bool enabled); - - void saveSettings(QSettings *settings) const; - void restoreSettings(const QSettings *settings); - QHash<QString, QVariant> saveSettings() const; - void restoreSettings(const QHash<QString, QVariant> &settings); - - // Additional context menu actions - QAction *menuSeparator1() const; - QAction *autoHideTitleBarsAction() const; - QAction *menuSeparator2() const; - QAction *resetLayoutAction() const; - QAction *showCentralWidgetAction() const; - void addDockActionsToMenu(QMenu *menu); - - bool autoHideTitleBars() const; - - QMenu *createPopupMenu() override; - -signals: - // Emitted by resetLayoutAction(). Connect to a slot - // restoring the default layout. - void resetLayout(); - -public slots: - void setDockActionsVisible(bool v); - -protected: - void hideEvent(QHideEvent *event) override; - void showEvent(QShowEvent *event) override; - void contextMenuEvent(QContextMenuEvent *event) override; - -private: - void onDockActionTriggered(); - - void handleVisibilityChanged(bool visible); - - FancyMainWindowPrivate *d; -}; - -} // namespace Utils - -#endif diff --git a/ThirdParty/GUI/qt-manhattan-style/fancytabwidget.cpp b/ThirdParty/GUI/qt-manhattan-style/fancytabwidget.cpp deleted file mode 100644 index c278f3579312466a49d3d7e325abdbc6821332f2..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/fancytabwidget.cpp +++ /dev/null @@ -1,567 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "fancytabwidget.h" -#include "stylehelper.h" -#include "styledbar.h" -#include <QColorDialog> -#include <QHBoxLayout> -#include <QVBoxLayout> -#include <QMouseEvent> -#include <QStyleFactory> -#include <QPainter> -#include <QSplitter> -#include <QStackedLayout> -#include <QStatusBar> -#include <QToolButton> -#include <QToolTip> -#include <QAnimationGroup> -#include <QPropertyAnimation> - -using namespace Manhattan; - -const int FancyTabBar::m_rounding = 22; -const int FancyTabBar::m_textPadding = 4; - -void FancyTab::fadeIn() -{ - animator.stop(); - animator.setDuration(80); - animator.setEndValue(40); - animator.start(); -} - -void FancyTab::fadeOut() -{ - animator.stop(); - animator.setDuration(160); - animator.setEndValue(0); - animator.start(); -} - -void FancyTab::setFader(float value) -{ - m_fader = value; - tabbar->update(); -} - -FancyTabBar::FancyTabBar(QWidget *parent) - : QWidget(parent) -{ - m_hoverIndex = -1; - m_currentIndex = -1; - setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - setStyle(QStyleFactory::create(QLatin1String("windows"))); - setMinimumWidth(qMax(2 * m_rounding, 40)); - setAttribute(Qt::WA_Hover, true); - setFocusPolicy(Qt::NoFocus); - setMouseTracking(true); // Needed for hover events - m_triggerTimer.setSingleShot(true); - - // We use a zerotimer to keep the sidebar responsive - connect(&m_triggerTimer, SIGNAL(timeout()), this, SLOT(emitCurrentIndex())); -} - -FancyTabBar::~FancyTabBar() -{ - delete style(); -} - -QSize FancyTabBar::tabSizeHint(bool minimum) const -{ - QFont boldFont(font()); - boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); - boldFont.setBold(true); - QFontMetrics fm(boldFont); - int spacing = 8; - int width = 60 + spacing + 2; - int maxLabelwidth = 0; - for (int tab=0 ; tab<count() ;++tab) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) - int width = fm.horizontalAdvance(tabText(tab)); -#else - int width = fm.width(tabText(tab)); -#endif - if (width > maxLabelwidth) - maxLabelwidth = width; - } - int iconHeight = minimum ? 0 : 48; - return QSize(qMax(width, maxLabelwidth + 4), iconHeight + spacing + fm.height()); -} - -void FancyTabBar::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event) - QPainter p(this); - - for (int i = 0; i < count(); ++i) - if (i != currentIndex()) - paintTab(&p, i); - - // paint active tab last, since it overlaps the neighbors - if (currentIndex() != -1) - paintTab(&p, currentIndex()); -} - -// Handle hover events for mouse fade ins -void FancyTabBar::mouseMoveEvent(QMouseEvent *e) -{ - int newHover = -1; - for (int i = 0; i < count(); ++i) { - QRect area = tabRect(i); - if (area.contains(e->pos())) { - newHover = i; - break; - } - } - if (newHover == m_hoverIndex) - return; - - if (validIndex(m_hoverIndex)) - m_tabs[m_hoverIndex]->fadeOut(); - - m_hoverIndex = newHover; - - if (validIndex(m_hoverIndex)) { - m_tabs[m_hoverIndex]->fadeIn(); - m_hoverRect = tabRect(m_hoverIndex); - } -} - -bool FancyTabBar::event(QEvent *event) -{ - if (event->type() == QEvent::ToolTip) { - if (validIndex(m_hoverIndex)) { - QString tt = tabToolTip(m_hoverIndex); - if (!tt.isEmpty()) { - QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tt, this); - return true; - } - } - } - return QWidget::event(event); -} - -// Resets hover animation on mouse enter -void FancyTabBar::enterEvent(QEvent *e) -{ - Q_UNUSED(e) - m_hoverRect = QRect(); - m_hoverIndex = -1; -} - -// Resets hover animation on mouse enter -void FancyTabBar::leaveEvent(QEvent *e) -{ - Q_UNUSED(e) - m_hoverIndex = -1; - m_hoverRect = QRect(); - for (int i = 0 ; i < m_tabs.count() ; ++i) { - m_tabs[i]->fadeOut(); - } -} - -QSize FancyTabBar::sizeHint() const -{ - QSize sh = tabSizeHint(); - return QSize(sh.width(), sh.height() * m_tabs.count()); -} - -QSize FancyTabBar::minimumSizeHint() const -{ - QSize sh = tabSizeHint(true); - return QSize(sh.width(), sh.height() * m_tabs.count()); -} - -QRect FancyTabBar::tabRect(int index) const -{ - QSize sh = tabSizeHint(); - - if (sh.height() * m_tabs.count() > height()) - sh.setHeight(height() / m_tabs.count()); - - return QRect(0, index * sh.height(), sh.width(), sh.height()); - -} - -// This keeps the sidebar responsive since -// we get a repaint before loading the -// mode itself -void FancyTabBar::emitCurrentIndex() -{ - emit currentChanged(m_currentIndex); -} - -void FancyTabBar::mousePressEvent(QMouseEvent *e) -{ - e->accept(); - for (int index = 0; index < m_tabs.count(); ++index) { - if (tabRect(index).contains(e->pos())) { - - if (isTabEnabled(index)) { - m_currentIndex = index; - update(); - m_triggerTimer.start(0); - } - break; - } - } -} - -void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const -{ - if (!validIndex(tabIndex)) { - qWarning("invalid index"); - return; - } - painter->save(); - - QRect rect = tabRect(tabIndex); - bool selected = (tabIndex == m_currentIndex); - bool enabled = isTabEnabled(tabIndex); - - if (selected) { - //background - painter->save(); - QLinearGradient grad(rect.topLeft(), rect.topRight()); - grad.setColorAt(0, QColor(255, 255, 255, 140)); - grad.setColorAt(1, QColor(255, 255, 255, 210)); - painter->fillRect(rect.adjusted(0, 0, 0, -1), grad); - painter->restore(); - - //shadows - painter->setPen(QColor(0, 0, 0, 110)); - painter->drawLine(rect.topLeft() + QPoint(1,-1), rect.topRight() - QPoint(0,1)); - painter->drawLine(rect.bottomLeft(), rect.bottomRight()); - painter->setPen(QColor(0, 0, 0, 40)); - painter->drawLine(rect.topLeft(), rect.bottomLeft()); - - //highlights - painter->setPen(QColor(255, 255, 255, 50)); - painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0,2)); - painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0,1)); - painter->setPen(QColor(255, 255, 255, 40)); - painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight()); - painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1)); - painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1)); - } - - QString tabText(this->tabText(tabIndex)); - QRect tabTextRect(tabRect(tabIndex)); - QRect tabIconRect(tabTextRect); - tabTextRect.translate(0, -2); - QFont boldFont(painter->font()); - boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); - boldFont.setBold(true); - painter->setFont(boldFont); - painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110)); - int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::TextWordWrap; - if (enabled) { - painter->drawText(tabTextRect, textFlags, tabText); - painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor()); - } else { - painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(255, 255, 255, 120)); - } -#ifndef Q_OS_MAC - if (!selected && enabled) { - painter->save(); - int fader = int(m_tabs[tabIndex]->fader()); - QLinearGradient grad(rect.topLeft(), rect.topRight()); - grad.setColorAt(0, Qt::transparent); - grad.setColorAt(0.5, QColor(255, 255, 255, fader)); - grad.setColorAt(1, Qt::transparent); - painter->fillRect(rect, grad); - painter->setPen(QPen(grad, 1.0)); - painter->drawLine(rect.topLeft(), rect.topRight()); - painter->drawLine(rect.bottomLeft(), rect.bottomRight()); - painter->restore(); - } -#endif - - if (!enabled) - painter->setOpacity(0.7); - - int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height(); - tabIconRect.adjust(0, 4, 0, -textHeight); - Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled); - - painter->translate(0, -1); - painter->drawText(tabTextRect, textFlags, tabText); - painter->restore(); -} - -void FancyTabBar::setCurrentIndex(int index) { - if (isTabEnabled(index)) { - m_currentIndex = index; - update(); - emit currentChanged(m_currentIndex); - } -} - -void FancyTabBar::setTabEnabled(int index, bool enable) -{ - Q_ASSERT(index < m_tabs.size()); - Q_ASSERT(index >= 0); - - if (index < m_tabs.size() && index >= 0) { - m_tabs[index]->enabled = enable; - update(tabRect(index)); - } -} - -bool FancyTabBar::isTabEnabled(int index) const -{ - Q_ASSERT(index < m_tabs.size()); - Q_ASSERT(index >= 0); - - if (index < m_tabs.size() && index >= 0) - return m_tabs[index]->enabled; - - return false; -} - - -////// -// FancyColorButton -////// - -class FancyColorButton : public QWidget -{ -public: - FancyColorButton(QWidget *parent) - : m_parent(parent) - { - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); - } - - void mousePressEvent(QMouseEvent *ev) - { - if (ev->modifiers() & Qt::ShiftModifier) { - QColor color = QColorDialog::getColor(Utils::StyleHelper::requestedBaseColor(), m_parent); - if (color.isValid()) - Utils::StyleHelper::setBaseColor(color); - } - } -private: - QWidget *m_parent; -}; - -////// -// FancyTabWidget -////// - -FancyTabWidget::FancyTabWidget(QWidget *parent) - : QWidget(parent) -{ - m_tabBar = new FancyTabBar(this); - - m_selectionWidget = new QWidget(this); - QVBoxLayout *selectionLayout = new QVBoxLayout; - selectionLayout->setSpacing(0); - selectionLayout->setMargin(0); - - // top stub - StyledBar *bar = new StyledBar; - QHBoxLayout *layout = new QHBoxLayout(bar); - layout->setMargin(0); - layout->setSpacing(0); - layout->addWidget(new FancyColorButton(this)); - selectionLayout->addWidget(bar); - - // top corner widget container - m_topCornerWidgetContainer = new QWidget(this); - m_topCornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); - m_topCornerWidgetContainer->setAutoFillBackground(false); - QVBoxLayout *topCornerWidgetLayout = new QVBoxLayout; - topCornerWidgetLayout->setSpacing(0); - topCornerWidgetLayout->setMargin(0); - m_topCornerWidgetContainer->setLayout(topCornerWidgetLayout); - selectionLayout->addWidget(m_topCornerWidgetContainer, 0); - - // Tab bar - selectionLayout->addWidget(m_tabBar, 1); - m_selectionWidget->setLayout(selectionLayout); - m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); - - // bottom corner widget container - m_bottomCornerWidgetContainer = new QWidget(this); - m_bottomCornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); - m_bottomCornerWidgetContainer->setAutoFillBackground(false); - QVBoxLayout *bottomCornerWidgetLayout = new QVBoxLayout; - bottomCornerWidgetLayout->setSpacing(0); - bottomCornerWidgetLayout->setMargin(0); - m_bottomCornerWidgetContainer->setLayout(bottomCornerWidgetLayout); - selectionLayout->addWidget(m_bottomCornerWidgetContainer, 0); - - m_modesStack = new QStackedLayout; - m_statusBar = new QStatusBar; - m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); - - QVBoxLayout *vlayout = new QVBoxLayout; - vlayout->setMargin(0); - vlayout->setSpacing(0); - vlayout->addLayout(m_modesStack); - vlayout->addWidget(m_statusBar); - - QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->setMargin(0); - mainLayout->setSpacing(1); - mainLayout->addWidget(m_selectionWidget); - mainLayout->addLayout(vlayout); - setLayout(mainLayout); - - connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(showWidget(int))); -} - -void FancyTabWidget::setSelectionWidgetHidden(bool hidden) { - m_selectionWidget->setHidden(hidden); -} - -//void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon) -void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label) -{ -// QString label("XXX"); - m_modesStack->insertWidget(index, tab); - m_tabBar->insertTab(index, icon, label); - setTabEnabled(index, true); -} - -void FancyTabWidget::removeTab(int index) -{ - m_modesStack->removeWidget(m_modesStack->widget(index)); - m_tabBar->removeTab(index); -} - -void FancyTabWidget::removeTabs() -{ - while (m_modesStack->count() != 0) - { - m_modesStack->removeWidget(m_modesStack->widget(0)); - m_tabBar->removeTab(0); - } -} - -void FancyTabWidget::setBackgroundBrush(const QBrush &brush) -{ - QPalette pal = m_tabBar->palette(); - pal.setBrush(QPalette::Mid, brush); - m_tabBar->setPalette(pal); - pal = m_topCornerWidgetContainer->palette(); - pal.setBrush(QPalette::Mid, brush); - m_topCornerWidgetContainer->setPalette(pal); - pal = m_bottomCornerWidgetContainer->palette(); - pal.setBrush(QPalette::Mid, brush); - m_bottomCornerWidgetContainer->setPalette(pal); -} - -void FancyTabWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event) - QPainter painter(this); - - QRect rect = m_selectionWidget->rect().adjusted(0, 0, 1, 0); - rect = style()->visualRect(layoutDirection(), geometry(), rect); - Utils::StyleHelper::verticalGradient(&painter, rect, rect); - painter.setPen(Utils::StyleHelper::borderColor()); - painter.drawLine(rect.topRight(), rect.bottomRight()); - - QColor light = Utils::StyleHelper::sidebarHighlight(); - painter.setPen(light); - painter.drawLine(rect.bottomLeft(), rect.bottomRight()); -} - -void FancyTabWidget::insertTopCornerWidget(int pos, QWidget *widget) -{ - QVBoxLayout *layout = static_cast<QVBoxLayout *>(m_topCornerWidgetContainer->layout()); - layout->insertWidget(pos, widget); -} - -int FancyTabWidget::topCornerWidgetCount() const -{ - return m_topCornerWidgetContainer->layout()->count(); -} - -void FancyTabWidget::addTopCornerWidget(QWidget *widget) -{ - m_topCornerWidgetContainer->layout()->addWidget(widget); -} - -void FancyTabWidget::insertBottomCornerWidget(int pos, QWidget *widget) -{ - QVBoxLayout *layout = static_cast<QVBoxLayout *>(m_bottomCornerWidgetContainer->layout()); - layout->insertWidget(pos, widget); -} - -int FancyTabWidget::bottomCornerWidgetCount() const -{ - return m_bottomCornerWidgetContainer->layout()->count(); -} - -void FancyTabWidget::addBottomCornerWidget(QWidget *widget) -{ - m_bottomCornerWidgetContainer->layout()->addWidget(widget); -} - -int FancyTabWidget::currentIndex() const -{ - return m_tabBar->currentIndex(); -} - -QStatusBar *FancyTabWidget::statusBar() const -{ - return m_statusBar; -} - -void FancyTabWidget::setCurrentIndex(int index) -{ - if (m_tabBar->isTabEnabled(index)) - m_tabBar->setCurrentIndex(index); -} - -void FancyTabWidget::showWidget(int index) -{ - emit currentAboutToShow(index); - m_modesStack->setCurrentIndex(index); - emit currentChanged(index); -} - -void FancyTabWidget::setTabToolTip(int index, const QString &toolTip) -{ - m_tabBar->setTabToolTip(index, toolTip); -} - -void FancyTabWidget::setTabEnabled(int index, bool enable) -{ - m_tabBar->setTabEnabled(index, enable); -} - -bool FancyTabWidget::isTabEnabled(int index) const -{ - return m_tabBar->isTabEnabled(index); -} diff --git a/ThirdParty/GUI/qt-manhattan-style/fancytabwidget.h b/ThirdParty/GUI/qt-manhattan-style/fancytabwidget.h deleted file mode 100644 index fab7b31fe409516ad05ecc9f4980a6c2b429185b..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/fancytabwidget.h +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef FANCYTABWIDGET_H -#define FANCYTABWIDGET_H - -#include "qt-manhattan-style_global.hpp" - -#include <QIcon> -#include <QWidget> - -#include <QTimer> -#include <QPropertyAnimation> - -QT_BEGIN_NAMESPACE -class QPainter; -class QStackedLayout; -class QStatusBar; -QT_END_NAMESPACE - -namespace Manhattan { - -class QTMANHATTANSTYLESHARED_EXPORT FancyTab : public QObject -{ - Q_OBJECT - - Q_PROPERTY(float fader READ fader WRITE setFader) -public: - FancyTab(QWidget *tabbar) : QObject(tabbar), enabled(false), tabbar(tabbar), m_fader(0) { - animator.setPropertyName("fader"); - animator.setTargetObject(this); - } - float fader() { return m_fader; } - void setFader(float value); - - void fadeIn(); - void fadeOut(); - - QIcon icon; - QString text; - QString toolTip; - bool enabled; - -private: - QPropertyAnimation animator; - QWidget *tabbar; - float m_fader; -}; - -class FancyTabBar : public QWidget -{ - Q_OBJECT - -public: - FancyTabBar(QWidget *parent = 0); - virtual ~FancyTabBar(); - - bool event(QEvent *event); - - virtual void paintEvent(QPaintEvent *event); - void paintTab(QPainter *painter, int tabIndex) const; - virtual void mousePressEvent(QMouseEvent *); - virtual void mouseMoveEvent(QMouseEvent *); - virtual void enterEvent(QEvent *); - virtual void leaveEvent(QEvent *); - bool validIndex(int index) const { return index >= 0 && index < m_tabs.count(); } - - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; - - void setTabEnabled(int index, bool enable); - bool isTabEnabled(int index) const; - - void insertTab(int index, const QIcon &icon, const QString &label) { - FancyTab *tab = new FancyTab(this); - tab->icon = icon; - tab->text = label; - m_tabs.insert(index, tab); - } - void setEnabled(int index, bool enabled); - void removeTab(int index) { - FancyTab *tab = m_tabs.takeAt(index); - delete tab; - } - void setCurrentIndex(int index); - int currentIndex() const { return m_currentIndex; } - - void setTabToolTip(int index, QString toolTip) { m_tabs[index]->toolTip = toolTip; } - QString tabToolTip(int index) const { return m_tabs.at(index)->toolTip; } - - QIcon tabIcon(int index) const { return m_tabs.at(index)->icon; } - QString tabText(int index) const { return m_tabs.at(index)->text; } - int count() const {return m_tabs.count(); } - QRect tabRect(int index) const; - -signals: - void currentChanged(int); - -public slots: - void emitCurrentIndex(); - -private: - static const int m_rounding; - static const int m_textPadding; - QRect m_hoverRect; - int m_hoverIndex; - int m_currentIndex; - QList<FancyTab*> m_tabs; - QTimer m_triggerTimer; - QSize tabSizeHint(bool minimum = false) const; - -}; - -class QTMANHATTANSTYLESHARED_EXPORT FancyTabWidget : public QWidget -{ - Q_OBJECT - -public: - FancyTabWidget(QWidget *parent = 0); - -// void insertTab(int index, QWidget *tab, const QIcon &icon); - void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label); - void removeTab(int index); - void removeTabs(); - void setBackgroundBrush(const QBrush &brush); - void addTopCornerWidget(QWidget *widget); - void insertTopCornerWidget(int pos, QWidget *widget); - void addBottomCornerWidget(QWidget *widget); - void insertBottomCornerWidget(int pos, QWidget *widget); - int topCornerWidgetCount() const; - int bottomCornerWidgetCount() const; - void setTabToolTip(int index, const QString &toolTip); - - void paintEvent(QPaintEvent *event); - - int currentIndex() const; - QStatusBar *statusBar() const; - - void setTabEnabled(int index, bool enable); - bool isTabEnabled(int index) const; - -signals: - void currentAboutToShow(int index); - void currentChanged(int index); - -public slots: - void setCurrentIndex(int index); - void setSelectionWidgetHidden(bool hidden); - -private slots: - void showWidget(int index); - -private: - FancyTabBar *m_tabBar; - QWidget *m_topCornerWidgetContainer; - QWidget *m_bottomCornerWidgetContainer; - QStackedLayout *m_modesStack; - QWidget *m_selectionWidget; - QStatusBar *m_statusBar; -}; - -} // namespace Manhattan - -#endif // FANCYTABWIDGET_H diff --git a/ThirdParty/GUI/qt-manhattan-style/historycompleter.cpp b/ThirdParty/GUI/qt-manhattan-style/historycompleter.cpp deleted file mode 100644 index 53e283b395e49c75ce276f7b8b719e8e34dd8328..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/historycompleter.cpp +++ /dev/null @@ -1,222 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "historycompleter.h" - -#include "qtcassert.h" - -#include <QAbstractListModel> -#include <QSettings> - -#include <QItemDelegate> -#include <QKeyEvent> -#include <QLineEdit> -#include <QListView> -#include <QPainter> -#include <QStyle> - -namespace Manhattan { - -static QSettings *theSettings = 0; - -class HistoryCompleterPrivate : public QAbstractListModel -{ -public: - HistoryCompleterPrivate() : maxLines(30), lineEdit(0) {} - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); - - void clearHistory(); - void saveEntry(const QString &str); - - QStringList list; - QString historyKey; - int maxLines; - QLineEdit *lineEdit; -}; - -class HistoryLineDelegate : public QItemDelegate -{ -public: - HistoryLineDelegate() - : pixmap(QLatin1String(":/core/images/editclear.png")) - {} - - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const - { - QItemDelegate::paint(painter,option,index); - QRect r = QStyle::alignedRect(option.direction, Qt::AlignRight | Qt::AlignVCenter , pixmap.size(), option.rect); - painter->drawPixmap(r, pixmap); - } - - QPixmap pixmap; -}; - -class HistoryLineView : public QListView -{ -public: - HistoryLineView(HistoryCompleterPrivate *model_) - : model(model_) - { - HistoryLineDelegate *delegate = new HistoryLineDelegate; - pixmapWidth = delegate->pixmap.width(); - setItemDelegate(delegate); - } - -private: - void mousePressEvent(QMouseEvent *event) - { - int rr= event->x(); - if (layoutDirection() == Qt::LeftToRight) - rr = viewport()->width() - event->x(); - if (rr < pixmapWidth) { - model->removeRow(indexAt(event->pos()).row()); - return; - } - QListView::mousePressEvent(event); - } - - HistoryCompleterPrivate *model; - int pixmapWidth; -}; - -int HistoryCompleterPrivate::rowCount(const QModelIndex &parent) const -{ - return parent.isValid() ? 0 : list.count(); -} - -QVariant HistoryCompleterPrivate::data(const QModelIndex &index, int role) const -{ - if (index.row() >= list.count() || index.column() != 0) - return QVariant(); - if (role == Qt::DisplayRole || role == Qt::EditRole) - return list.at(index.row()); - return QVariant(); -} - -bool HistoryCompleterPrivate::removeRows(int row, int count, const QModelIndex &parent) -{ - beginRemoveRows (parent, row, row + count); - list.removeAt(row); - theSettings->setValue(historyKey, list); - endRemoveRows(); - return true; -} - -void HistoryCompleterPrivate::clearHistory() -{ - list.clear(); - beginResetModel(); - endResetModel(); -} - -void HistoryCompleterPrivate::saveEntry(const QString &str) -{ - QTC_ASSERT(theSettings, return); - if (str.isEmpty()) - return; - if (list.contains(str)) - return; - beginInsertRows (QModelIndex(), list.count(), list.count()); - list.prepend(str); - list = list.mid(0, maxLines); - endInsertRows(); - theSettings->setValue(historyKey, list); -} - -HistoryCompleter::HistoryCompleter(QLineEdit *lineEdit, const QString &historyKey, QObject *parent) - : QCompleter(parent), - d(new HistoryCompleterPrivate) -{ - QTC_ASSERT(lineEdit, return); - QTC_ASSERT(!historyKey.isEmpty(), return); - QTC_ASSERT(theSettings, return); - - d->historyKey = QLatin1String("CompleterHistory/") + historyKey; - d->list = theSettings->value(d->historyKey).toStringList(); - d->lineEdit = lineEdit; - if (d->list.count()) - lineEdit->setText(d->list.at(0)); - - setModel(d); - setPopup(new HistoryLineView(d)); - lineEdit->installEventFilter(this); - - connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(saveHistory())); -} - -HistoryCompleter::~HistoryCompleter() -{ - delete d; -} - -bool HistoryCompleter::eventFilter(QObject *obj, QEvent *event) -{ - if (event->type() == QEvent::KeyPress - && static_cast<QKeyEvent *>(event)->key() == Qt::Key_Down - && !popup()->isVisible()) { - setCompletionPrefix(QString()); - complete(); - } - return QCompleter::eventFilter(obj, event); -} - -int HistoryCompleter::historySize() const -{ - return d->rowCount(); -} - -int HistoryCompleter::maximalHistorySize() const -{ - return d->maxLines; -} - -void HistoryCompleter::setMaximalHistorySize(int numberOfEntries) -{ - d->maxLines = numberOfEntries; -} - -void HistoryCompleter::clearHistory() -{ - d->clearHistory(); -} - -void HistoryCompleter::saveHistory() -{ - d->saveEntry(d->lineEdit->text()); -} - -void HistoryCompleter::setSettings(QSettings *settings) -{ - theSettings = settings; -} - -} // namespace Manhattan diff --git a/ThirdParty/GUI/qt-manhattan-style/historycompleter.h b/ThirdParty/GUI/qt-manhattan-style/historycompleter.h deleted file mode 100644 index 141354634eb1a6240b5546498d0423ba550e244b..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/historycompleter.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef HISTORYCOMPLETER_H -#define HISTORYCOMPLETER_H - -#include "qt-manhattan-style_global.hpp" - -#include <QCompleter> - -QT_BEGIN_NAMESPACE -class QLineEdit; -class QSettings; -QT_END_NAMESPACE - -namespace Manhattan { - -class HistoryCompleterPrivate; - -class QTMANHATTANSTYLESHARED_EXPORT HistoryCompleter : public QCompleter -{ - Q_OBJECT - -public: - static void setSettings(QSettings *settings); - HistoryCompleter(QLineEdit *lineEdit, const QString &historyKey, QObject *parent = 0); - -private: - virtual ~HistoryCompleter(); - int historySize() const; - int maximalHistorySize() const; - void setMaximalHistorySize(int numberOfEntries); - virtual bool eventFilter(QObject *obj, QEvent *event); - -public Q_SLOTS: - void clearHistory(); - void saveHistory(); - -private: - HistoryCompleterPrivate *d; -}; - -} // namespace Manhattan - -#endif // HISTORYCOMPLETER_H diff --git a/ThirdParty/GUI/qt-manhattan-style/manhattanstyle.cpp b/ThirdParty/GUI/qt-manhattan-style/manhattanstyle.cpp deleted file mode 100644 index 3a6d3c0e20afa026c1eb443de1ef276c8b90f109..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/manhattanstyle.cpp +++ /dev/null @@ -1,1040 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "manhattanstyle.h" - -#include "styleanimator.h" - -#include <QLibrary> - -#include "coreconstants.h" - -#include "qtcassert.h" -#include "stylehelper.h" - -#include "fancymainwindow.h" - -#include <QApplication> -#include <QComboBox> -#include <QDialogButtonBox> -#include <QDockWidget> -#include <QLabel> -#include <QLineEdit> -#include <QMenuBar> -#include <QPainter> -#include <QPixmap> -#include <QPixmapCache> -#include <QPushButton> -#include <QScrollArea> -#include <QSplitter> -#include <QStatusBar> -#include <QStyleFactory> -#include <QStyleOption> -#include <QToolBar> -#include <QTreeView> -#include <QToolButton> -#include <QAbstractItemView> -#include <QPainterPath> - -using namespace Manhattan; - -// We define a currently unused state for indicating animations -const QStyle::State State_Animating = QStyle::State(0x00000040); - -// Because designer needs to disable this for widget previews -// we have a custom property that is inherited -bool styleEnabled(const QWidget *widget) -{ - const QWidget *p = widget; - while (p) { - if (p->property("_q_custom_style_disabled").toBool()) - return false; - p = p->parentWidget(); - } - return true; -} - -// Consider making this a QStyle state -bool panelWidget(const QWidget *widget) -{ - if (!widget) - return false; - - // Do not style dialogs or explicitly ignored widgets - if ((widget->window()->windowFlags() & Qt::WindowType_Mask) == Qt::Dialog) - return false; - - if (qobject_cast<const Manhattan::FancyMainWindow *>(widget)) - return true; - - if (qobject_cast<const QTabBar *>(widget)) - return styleEnabled(widget); - - const QWidget *p = widget; - while (p) { - if (qobject_cast<const QToolBar *>(p) || - qobject_cast<const QStatusBar *>(p) || - qobject_cast<const QMenuBar *>(p) || - p->property("panelwidget").toBool()) - return styleEnabled(widget); - p = p->parentWidget(); - } - return false; -} - -// Consider making this a QStyle state -bool lightColored(const QWidget *widget) -{ - if (!widget) - return false; - - // Don't style dialogs or explicitly ignored widgets - if ((widget->window()->windowFlags() & Qt::WindowType_Mask) == Qt::Dialog) - return false; - - const QWidget *p = widget; - while (p) { - if (p->property("lightColored").toBool()) - return true; - p = p->parentWidget(); - } - return false; -} - -bool hasProperty(const QWidget *widget, const QByteArray& name) -{ - if (!widget) - return false; - - // Don't style dialogs or explicitly ignored widgets - if ((widget->window()->windowFlags() & Qt::WindowType_Mask) == Qt::Dialog) - return false; - - const QWidget *p = widget; - while (p) { - if (p->property(name).isValid()) - return true; - p = p->parentWidget(); - } - return false; -} - -class ManhattanStylePrivate -{ -public: - explicit ManhattanStylePrivate(); - void init(); - -public: - const QImage lineeditImage; - const QImage lineeditImage_disabled; - const QPixmap extButtonPixmap; - const QPixmap closeButtonPixmap; - StyleAnimator animator; -}; - -ManhattanStylePrivate::ManhattanStylePrivate() : - lineeditImage(QLatin1String(":/core/images/inputfield.png")), - lineeditImage_disabled(QLatin1String(":/core/images/inputfield_disabled.png")), - extButtonPixmap(QLatin1String(":/core/images/extension.png")), - closeButtonPixmap(QLatin1String(Manhattan::Constants::ICON_CLOSE)) -{ -} - -ManhattanStyle::ManhattanStyle(const QString &baseStyleName) - : QProxyStyle(QStyleFactory::create(baseStyleName)), - d(new ManhattanStylePrivate()) -{ -} - -ManhattanStyle::~ManhattanStyle() -{ - delete d; - d = nullptr; -} - -QPixmap ManhattanStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const -{ - return QProxyStyle::generatedIconPixmap(iconMode, pixmap, opt); -} - -QSize ManhattanStyle::sizeFromContents(ContentsType type, const QStyleOption *option, - const QSize &size, const QWidget *widget) const -{ - QSize newSize = QProxyStyle::sizeFromContents(type, option, size, widget); - - if (type == CT_Splitter && widget && widget->property("minisplitter").toBool()) - return QSize(1, 1); - else if (type == CT_ComboBox && panelWidget(widget)) - newSize += QSize(14, 0); - return newSize; -} - -QRect ManhattanStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const -{ - return QProxyStyle::subElementRect(element, option, widget); -} - -QRect ManhattanStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option, - SubControl subControl, const QWidget *widget) const -{ - return QProxyStyle::subControlRect(control, option, subControl, widget); -} - -QStyle::SubControl ManhattanStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, - const QPoint &pos, const QWidget *widget) const -{ - return QProxyStyle::hitTestComplexControl(control, option, pos, widget); -} - -int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const -{ - int retval = 0; - retval = QProxyStyle::pixelMetric(metric, option, widget); - switch (metric) { - case PM_SplitterWidth: - if (widget && widget->property("minisplitter").toBool()) - retval = 1; - break; - case PM_ToolBarIconSize: - if (panelWidget(widget)) - retval = 16; - break; - case PM_DockWidgetHandleExtent: - case PM_DockWidgetSeparatorExtent: - return 1; - case PM_MenuPanelWidth: - case PM_MenuBarHMargin: - case PM_MenuBarVMargin: - case PM_ToolBarFrameWidth: - if (panelWidget(widget)) - retval = 1; - break; - case PM_ButtonShiftVertical: - case PM_ButtonShiftHorizontal: - case PM_MenuBarPanelWidth: - case PM_ToolBarItemMargin: - case PM_ToolBarItemSpacing: - if (panelWidget(widget)) - retval = 0; - break; - case PM_DefaultFrameWidth: - if (qobject_cast<const QLineEdit*>(widget) && panelWidget(widget)) - return 1; - break; - default: - break; - } - return retval; -} - -QPalette ManhattanStyle::standardPalette() const -{ - return QProxyStyle::standardPalette(); -} - -void ManhattanStyle::polish(QApplication *app) -{ - return QProxyStyle::polish(app); -} - -void ManhattanStyle::unpolish(QApplication *app) -{ - return QProxyStyle::unpolish(app); -} - -QPalette panelPalette(const QPalette &oldPalette, bool lightColored = false) -{ - QColor color = Utils::StyleHelper::panelTextColor(lightColored); - QPalette pal = oldPalette; - pal.setBrush(QPalette::All, QPalette::WindowText, color); - pal.setBrush(QPalette::All, QPalette::ButtonText, color); - pal.setBrush(QPalette::All, QPalette::Foreground, color); - color.setAlpha(100); - pal.setBrush(QPalette::Disabled, QPalette::WindowText, color); - pal.setBrush(QPalette::Disabled, QPalette::ButtonText, color); - pal.setBrush(QPalette::Disabled, QPalette::Foreground, color); - return pal; -} - -void ManhattanStyle::polish(QWidget *widget) -{ - QProxyStyle::polish(widget); - - // g.p. added KDE 5 style to avoid one pixel frame - // see styles ./qtbase/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp - - // OxygenStyle forces a rounded widget mask on toolbars and dock widgets - if (baseStyle()->inherits("OxygenStyle") || baseStyle()->inherits("Oxygen::Style") - || baseStyle()->inherits("Breeze::Style")) { - if (qobject_cast<QToolBar*>(widget) || qobject_cast<QDockWidget*>(widget)) { - widget->removeEventFilter(baseStyle()); - widget->setContentsMargins(0, 0, 0, 0); - } - } - if (panelWidget(widget)) { - - // Oxygen and possibly other styles override this - if (qobject_cast<QDockWidget*>(widget)) - widget->setContentsMargins(0, 0, 0, 0); - - widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true); - if (qobject_cast<QToolButton*>(widget)) { - widget->setAttribute(Qt::WA_Hover); - widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2); - } - else if (qobject_cast<QLineEdit*>(widget)) { - widget->setAttribute(Qt::WA_Hover); - widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2); - } - else if (qobject_cast<QLabel*>(widget)) - widget->setPalette(panelPalette(widget->palette(), lightColored(widget))); - else if (widget->property("panelwidget_singlerow").toBool()) - widget->setFixedHeight(Utils::StyleHelper::navigationWidgetHeight()); - else if (qobject_cast<QStatusBar*>(widget)) - widget->setFixedHeight(Utils::StyleHelper::navigationWidgetHeight() + 2); - else if (qobject_cast<QComboBox*>(widget)) { - widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2); - widget->setAttribute(Qt::WA_Hover); - } - } -} - -void ManhattanStyle::unpolish(QWidget *widget) -{ - QProxyStyle::unpolish(widget); - if (panelWidget(widget)) { - widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, false); - if (qobject_cast<QTabBar*>(widget)) - widget->setAttribute(Qt::WA_Hover, false); - else if (qobject_cast<QToolBar*>(widget)) - widget->setAttribute(Qt::WA_Hover, false); - else if (qobject_cast<QComboBox*>(widget)) - widget->setAttribute(Qt::WA_Hover, false); - } -} - -void ManhattanStyle::polish(QPalette &pal) -{ - QProxyStyle::polish(pal); -} - -QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const -{ - QIcon icon; - switch (standardIcon) { - case QStyle::SP_TitleBarCloseButton: - case QStyle::SP_ToolBarHorizontalExtensionButton: - return QIcon(standardPixmap(standardIcon, option, widget)); - default: - icon = baseStyle()->standardIcon(standardIcon, option, widget); - } - return icon; -} - -QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget) const -{ - if (widget && !panelWidget(widget)) - return QProxyStyle::standardPixmap(standardPixmap, opt, widget); - - QPixmap pixmap; - switch (standardPixmap) { - case QStyle::SP_ToolBarHorizontalExtensionButton: - pixmap = d->extButtonPixmap; - break; - case QStyle::SP_TitleBarCloseButton: - pixmap = d->closeButtonPixmap; - break; - default: - pixmap = QProxyStyle::standardPixmap(standardPixmap, opt, widget); - break; - } - return pixmap; -} - -int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, - QStyleHintReturn *returnData) const -{ - int ret = QProxyStyle::styleHint(hint, option, widget, returnData); - switch (hint) { - // Make project explorer alternate rows all the way - case QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea: - if (widget && widget->property("AlternateEmpty").toBool()) - ret = true; - break; - case QStyle::SH_EtchDisabledText: - if (panelWidget(widget)) - ret = false; - break; - case QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren: - ret = true; - break; - default: - break; - } - return ret; -} - -void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const -{ - if (!panelWidget(widget)) - return QProxyStyle::drawPrimitive(element, option, painter, widget); - - bool animating = (option->state & State_Animating); - int state = option->state; - QRect rect = option->rect; - QRect oldRect; - QRect newRect; - if (widget && (element == PE_PanelButtonTool) && !animating) { - QWidget *w = const_cast<QWidget *> (widget); - int oldState = w->property("_q_stylestate").toInt(); - oldRect = w->property("_q_stylerect").toRect(); - newRect = w->rect(); - w->setProperty("_q_stylestate", (int)option->state); - w->setProperty("_q_stylerect", w->rect()); - - // Determine the animated transition - bool doTransition = ((state & State_On) != (oldState & State_On) || - (state & State_MouseOver) != (oldState & State_MouseOver)); - -#ifndef Q_OS_MAC - if (oldRect != newRect) - { - doTransition = false; - d->animator.stopAnimation(widget); - } -#else - doTransition = false; - d->animator.stopAnimation(widget); -#endif - - - if (doTransition) { - QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - Animation *anim = d->animator.widgetAnimation(widget); - QStyleOption opt = *option; - opt.state = (QStyle::State)oldState; - opt.state |= State_Animating; - startImage.fill(0); - Transition *t = new Transition; - t->setWidget(w); - QPainter startPainter(&startImage); - if (!anim) { - drawPrimitive(element, &opt, &startPainter, widget); - } else { - anim->paint(&startPainter, &opt); - d->animator.stopAnimation(widget); - } - QStyleOption endOpt = *option; - endOpt.state |= State_Animating; - t->setStartImage(startImage); - d->animator.startAnimation(t); - endImage.fill(0); - QPainter endPainter(&endImage); - drawPrimitive(element, &endOpt, &endPainter, widget); - t->setEndImage(endImage); - if (oldState & State_MouseOver) - t->setDuration(150); - else - t->setDuration(75); - t->setStartTime(QTime::currentTime()); - } - } - - switch (element) { - case PE_IndicatorDockWidgetResizeHandle: - painter->fillRect(option->rect, Utils::StyleHelper::borderColor()); - break; - case PE_FrameDockWidget: - QCommonStyle::drawPrimitive(element, option, painter, widget); - break; - case PE_PanelLineEdit: - { - painter->save(); - - // Fill the line edit background - QRect filledRect = option->rect.adjusted(1, 1, -1, -1); - painter->setBrushOrigin(filledRect.topLeft()); - painter->fillRect(filledRect, option->palette.base()); - - if (option->state & State_Enabled) - Utils::StyleHelper::drawCornerImage(d->lineeditImage, painter, option->rect, 5, 5, 5, 5); - else - Utils::StyleHelper::drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 5, 5, 5, 5); - - if (option->state & State_HasFocus || option->state & State_MouseOver) { - QColor hover = Utils::StyleHelper::baseColor(); - if (state & State_HasFocus) - hover.setAlpha(100); - else - hover.setAlpha(50); - - painter->setPen(QPen(hover, 1)); - painter->drawRect(option->rect.adjusted(1, 1, -2 ,-2)); - } - painter->restore(); - } - break; - - case PE_FrameStatusBarItem: - break; - - case PE_PanelButtonTool: { - Animation *anim = d->animator.widgetAnimation(widget); - if (!animating && anim) { - anim->paint(painter, option); - } else { - bool pressed = option->state & State_Sunken || option->state & State_On; -#ifndef Q_OS_MAC - QColor shadow(0, 0, 0, 30); - painter->setPen(shadow); -#else - painter->setPen(QColor(255, 255, 255)); -#endif - if (pressed) { - painter->setPen(QColor(0, 0, 0, 30)); // g.p. - QColor shade(0, 0, 0, 40); - painter->fillRect(rect, shade); - painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight() - QPoint(1, 0)); - painter->drawLine(rect.topLeft(), rect.bottomLeft()); - painter->drawLine(rect.topRight(), rect.bottomRight()); - // painter->drawLine(rect.bottomLeft() + QPoint(1, 0), rect.bottomRight() - QPoint(1, 0)); - QColor highlight(255, 255, 255, 30); - painter->setPen(highlight); - } - else if (option->state & State_Enabled && - option->state & State_MouseOver) { - QColor lighter(255, 255, 255, 37); - painter->fillRect(rect, lighter); - } - if (option->state & State_HasFocus && (option->state & State_KeyboardFocusChange)) { - QColor highlight = option->palette.highlight().color(); - highlight.setAlphaF(0.4); - painter->setPen(QPen(highlight.lighter(), 1)); - highlight.setAlphaF(0.3); - painter->setBrush(highlight); - painter->setRenderHint(QPainter::Antialiasing); - QRectF rect = option->rect; - rect.translate(0.5, 0.5); - painter->drawRoundedRect(rect.adjusted(2, 2, -3, -3), 2, 2); - } - } - } - break; - - case PE_PanelStatusBar: - { - painter->save(); - QLinearGradient grad(option->rect.topLeft(), QPoint(rect.center().x(), rect.bottom())); - QColor startColor = Utils::StyleHelper::shadowColor().darker(164); - QColor endColor = Utils::StyleHelper::baseColor().darker(130); - grad.setColorAt(0, startColor); - grad.setColorAt(1, endColor); - painter->fillRect(option->rect, grad); - painter->setPen(QColor(255, 255, 255, 60)); - painter->drawLine(rect.topLeft() + QPoint(0,1), - rect.topRight()+ QPoint(0,1)); - painter->setPen(Utils::StyleHelper::borderColor().darker(110)); - painter->drawLine(rect.topLeft(), rect.topRight()); - painter->restore(); - } - break; - - case PE_IndicatorToolBarSeparator: - { - QColor separatorColor = Utils::StyleHelper::borderColor(); - //separatorColor.setAlpha(100); - painter->setPen(separatorColor); - //const int margin = 6; gp - const int margin = 2; - if (option->state & State_Horizontal) { - const int offset = rect.width()/2; - painter->drawLine(rect.bottomLeft().x() + offset, - rect.bottomLeft().y() - margin, - rect.topLeft().x() + offset, - rect.topLeft().y() + margin); - } else { //Draw vertical separator - const int offset = rect.height()/2; -#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) - painter->setPen(QPen(option->palette.window().color().darker(110))); -#else - painter->setPen(QPen(option->palette.background().color().darker(110))); -#endif - painter->drawLine(rect.topLeft().x() + margin , - rect.topLeft().y() + offset, - rect.topRight().x() - margin, - rect.topRight().y() + offset); - } - } - break; - - case PE_IndicatorToolBarHandle: - { - bool horizontal = option->state & State_Horizontal; - painter->save(); - QPainterPath path; - int x = option->rect.x() + (horizontal ? 2 : 6); - int y = option->rect.y() + (horizontal ? 6 : 2); - static const int RectHeight = 2; - if (horizontal) { - while (y < option->rect.height() - RectHeight - 6) { - path.moveTo(x, y); - path.addRect(x, y, RectHeight, RectHeight); - y += 6; - } - } else { - while (x < option->rect.width() - RectHeight - 6) { - path.moveTo(x, y); - path.addRect(x, y, RectHeight, RectHeight); - x += 6; - } - } - - painter->setPen(Qt::NoPen); - QColor dark = Utils::StyleHelper::borderColor(); - dark.setAlphaF(0.4); - - QColor light = Utils::StyleHelper::baseColor(); - light.setAlphaF(0.4); - - painter->fillPath(path, light); - painter->save(); - painter->translate(1, 1); - painter->fillPath(path, dark); - painter->restore(); - painter->translate(3, 3); - painter->fillPath(path, light); - painter->translate(1, 1); - painter->fillPath(path, dark); - painter->restore(); - } - break; - case PE_IndicatorArrowUp: - case PE_IndicatorArrowDown: - case PE_IndicatorArrowRight: - case PE_IndicatorArrowLeft: - { - Utils::StyleHelper::drawArrow(element, painter, option); - } - break; - - default: - QProxyStyle::drawPrimitive(element, option, painter, widget); - break; - } -} - -void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget) const -{ - if (!panelWidget(widget)) - return QProxyStyle::drawControl(element, option, painter, widget); - - switch (element) { - case CE_Splitter: - painter->fillRect(option->rect, Utils::StyleHelper::borderColor()); - break; - - case CE_TabBarTabShape: - // Most styles draw a single dark outline. This looks rather ugly when combined with our - // single pixel dark separator so we adjust the first tab to compensate for this - - if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) { - QStyleOptionTab adjustedTab = *tab; - if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && ( - tab->position == QStyleOptionTab::Beginning || - tab->position == QStyleOptionTab::OnlyOneTab)) - { - if (option->direction == Qt::LeftToRight) - adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0); - else - adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0); - } - QProxyStyle::drawControl(element, &adjustedTab, painter, widget); - return; - } - break; - - case CE_MenuBarItem: - painter->save(); - if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { - QColor highlightOutline = Utils::StyleHelper::borderColor().lighter(120); - bool act = mbi->state & State_Sunken; - bool dis = !(mbi->state & State_Enabled); - Utils::StyleHelper::menuGradient(painter, option->rect, option->rect); - QStyleOptionMenuItem item = *mbi; - item.rect = mbi->rect; - QPalette pal = mbi->palette; - pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black); - item.palette = pal; - QCommonStyle::drawControl(element, &item, painter, widget); - QRect r = option->rect; - - if (act) { - // Fill| - QColor baseColor = Utils::StyleHelper::baseColor(); - QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft()); - grad.setColorAt(0, baseColor.lighter(120)); - grad.setColorAt(1, baseColor.lighter(130)); - painter->fillRect(option->rect.adjusted(1, 1, -1, 0), grad); - - // Outline - painter->setPen(QPen(highlightOutline, 0)); - painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())); - painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())); - painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); - highlightOutline.setAlpha(60); - painter->setPen(QPen(highlightOutline, 0)); - painter->drawPoint(r.topLeft()); - painter->drawPoint(r.topRight()); - - QPalette pal = mbi->palette; - uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; - if (!styleHint(SH_UnderlineShortcut, mbi, widget)) - alignment |= Qt::TextHideMnemonic; - pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60)); - drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); - pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white); - drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text); - } - } - painter->restore(); - break; - - case CE_ComboBoxLabel: - if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { - if (panelWidget(widget)) { - painter->save(); - QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); - QPalette customPal = cb->palette; - bool drawIcon = !(widget && widget->property("hideicon").toBool()); - - if (!cb->currentIcon.isNull() && drawIcon) { - QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal - : QIcon::Disabled; - QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); - QRect iconRect(editRect); - iconRect.setWidth(cb->iconSize.width() + 4); - iconRect = alignedRect(cb->direction, - Qt::AlignLeft | Qt::AlignVCenter, - iconRect.size(), editRect); - if (cb->editable) - painter->fillRect(iconRect, customPal.brush(QPalette::Base)); - drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap); - - if (cb->direction == Qt::RightToLeft) - editRect.translate(-4 - cb->iconSize.width(), 0); - else - editRect.translate(cb->iconSize.width() + 4, 0); - - // Reserve some space for the down-arrow - editRect.adjust(0, 0, -13, 0); - } - - QString text = option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, editRect.width()); - if ((option->state & State_Enabled)) { - painter->setPen(QColor(0, 0, 0, 70)); - painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); - } else { - painter->setOpacity(0.8); - } - painter->setPen(Utils::StyleHelper::panelTextColor(lightColored(widget))); - painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text); - - painter->restore(); - } else { - QProxyStyle::drawControl(element, option, painter, widget); - } - } - break; - - case CE_SizeGrip: { - painter->save(); - QColor dark = Qt::white; - dark.setAlphaF(0.1); - int x, y, w, h; - option->rect.getRect(&x, &y, &w, &h); - int sw = qMin(h, w); - if (h > w) - painter->translate(0, h - w); - else - painter->translate(w - h, 0); - int sx = x; - int sy = y; - int s = 4; - painter->setPen(dark); - if (option->direction == Qt::RightToLeft) { - sx = x + sw; - for (int i = 0; i < 4; ++i) { - painter->drawLine(x, sy, sx, sw); - sx -= s; - sy += s; - } - } else { - for (int i = 0; i < 4; ++i) { - painter->drawLine(sx, sw, sw, sy); - sx += s; - sy += s; - } - } - painter->restore(); - } - break; - - case CE_MenuBarEmptyArea: { - Utils::StyleHelper::menuGradient(painter, option->rect, option->rect); - painter->save(); - painter->setPen(Utils::StyleHelper::borderColor()); - painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); - painter->restore(); - } - break; - - case CE_ToolBar: - { - QRect rect = option->rect; - bool horizontal = option->state & State_Horizontal; - rect = option->rect; - - // Map offset for global window gradient - QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) - - widget->mapToGlobal(option->rect.topLeft()); - QRect gradientSpan; - if (widget) - gradientSpan = QRect(offset, widget->window()->size()); - - bool drawLightColored = lightColored(widget); - if (horizontal) - Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored); - else - Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored); - - if (!drawLightColored) - painter->setPen(Utils::StyleHelper::borderColor()); - else - painter->setPen(QColor(0x888888)); - - if (horizontal) { - // Note: This is a hack to determine if the - // toolbar should draw the top or bottom outline - // (needed for the find toolbar for instance) - QColor lighter(Utils::StyleHelper::sidebarHighlight()); - if (drawLightColored) - lighter = QColor(255, 255, 255, 180); - if (widget && widget->property("topBorder").toBool()) { - painter->drawLine(rect.topLeft(), rect.topRight()); - painter->setPen(lighter); - painter->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1)); - } else { - painter->drawLine(rect.bottomLeft(), rect.bottomRight()); - painter->setPen(lighter); - painter->drawLine(rect.topLeft(), rect.topRight()); - } - } else { - painter->drawLine(rect.topLeft(), rect.bottomLeft()); - painter->drawLine(rect.topRight(), rect.bottomRight()); - } - } - break; - - default: - QProxyStyle::drawControl(element, option, painter, widget); - break; - } -} - -void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget) const -{ - if (!panelWidget(widget)) - return QProxyStyle::drawComplexControl(control, option, painter, widget); - - QRect rect = option->rect; - switch (control) { - case CC_ToolButton: - if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { - bool reverse = option->direction == Qt::RightToLeft; - bool drawborder = (widget && widget->property("showborder").toBool()); - - if (drawborder) - drawButtonSeparator(painter, rect, reverse); - - QRect button, menuarea; - button = subControlRect(control, toolbutton, SC_ToolButton, widget); - menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget); - - State bflags = toolbutton->state; - if (bflags & State_AutoRaise) { - if (!(bflags & State_MouseOver)) { - bflags &= ~State_Raised; - } - } - - State mflags = bflags; - if (toolbutton->state & State_Sunken) { - if (toolbutton->activeSubControls & SC_ToolButton) - bflags |= State_Sunken; - if (toolbutton->activeSubControls & SC_ToolButtonMenu) - mflags |= State_Sunken; - } - - QStyleOption tool(0); - tool.palette = toolbutton->palette; - if (toolbutton->subControls & SC_ToolButton) { - tool.rect = button; - tool.state = bflags; - drawPrimitive(PE_PanelButtonTool, &tool, painter, widget); - } - - QStyleOptionToolButton label = *toolbutton; - - label.palette = panelPalette(option->palette, lightColored(widget)); - int fw = pixelMetric(PM_DefaultFrameWidth, option, widget); - label.rect = button.adjusted(fw, fw, -fw, -fw); - - drawControl(CE_ToolButtonLabel, &label, painter, widget); - - if (toolbutton->subControls & SC_ToolButtonMenu) { - tool.state = mflags; - tool.rect = menuarea.adjusted(1, 1, -1, -1); - if (mflags & (State_Sunken | State_On | State_Raised)) { - painter->setPen(Qt::gray); - painter->drawLine(tool.rect.topLeft(), tool.rect.bottomLeft()); - if (mflags & (State_Sunken)) { - QColor shade(0, 0, 0, 50); - painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade); - } -#ifndef Q_OS_MAC - else if (mflags & (State_MouseOver)) { - QColor shade(255, 255, 255, 50); - painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade); - } -#endif - } - tool.rect = tool.rect.adjusted(2, 2, -2, -2); - drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget); - } else if (toolbutton->features & QStyleOptionToolButton::HasMenu - && !widget->property("noArrow").toBool()) { - int arrowSize = 6; - QRect ir = toolbutton->rect.adjusted(1, 1, -1, -1); - QStyleOptionToolButton newBtn = *toolbutton; - newBtn.palette = panelPalette(option->palette); - newBtn.rect = QRect(ir.right() - arrowSize - 1, - ir.height() - arrowSize - 2, arrowSize, arrowSize); - drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget); - } - } - break; - - case CC_ComboBox: - if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) { - painter->save(); - bool isEmpty = cb->currentText.isEmpty() && cb->currentIcon.isNull(); - bool reverse = option->direction == Qt::RightToLeft; - bool drawborder = !(widget && widget->property("hideborder").toBool()); - bool alignarrow = !(widget && widget->property("alignarrow").toBool()); - - if (drawborder) - drawButtonSeparator(painter, rect, reverse); - - QStyleOption toolbutton = *option; - if (isEmpty) - toolbutton.state &= ~(State_Enabled | State_Sunken); - painter->save(); - if (drawborder) - painter->setClipRect(toolbutton.rect.adjusted(0, 0, -2, 0)); - drawPrimitive(PE_PanelButtonTool, &toolbutton, painter, widget); - painter->restore(); - // Draw arrow - int menuButtonWidth = 12; - int left = !reverse ? rect.right() - menuButtonWidth : rect.left(); - int right = !reverse ? rect.right() : rect.left() + menuButtonWidth; - QRect arrowRect((left + right) / 2 + (reverse ? 6 : -6), rect.center().y() - 3, 9, 9); - - if (!alignarrow) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) - int labelwidth = option->fontMetrics.horizontalAdvance(cb->currentText); -#else - int labelwidth = option->fontMetrics.width(cb->currentText); -#endif - if (reverse) - arrowRect.moveLeft(qMax(rect.width() - labelwidth - menuButtonWidth - 2, 4)); - else - arrowRect.moveLeft(qMin(labelwidth + menuButtonWidth - 2, rect.width() - menuButtonWidth - 4)); - } - if (option->state & State_On) - arrowRect.translate(QProxyStyle::pixelMetric(PM_ButtonShiftHorizontal, option, widget), - QProxyStyle::pixelMetric(PM_ButtonShiftVertical, option, widget)); - - QStyleOption arrowOpt = *option; - arrowOpt.rect = arrowRect; - if (isEmpty) - arrowOpt.state &= ~(State_Enabled | State_Sunken); - - if (styleHint(SH_ComboBox_Popup, option, widget)) { - arrowOpt.rect.translate(0, -3); - drawPrimitive(PE_IndicatorArrowUp, &arrowOpt, painter, widget); - arrowOpt.rect.translate(0, 6); - drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget); - } else { - drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget); - } - - painter->restore(); - } - break; - - default: - QProxyStyle::drawComplexControl(control, option, painter, widget); - break; - } -} - -void ManhattanStyle::drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const -{ - QLinearGradient grad(rect.topRight(), rect.bottomRight()); - grad.setColorAt(0, QColor(255, 255, 255, 20)); - grad.setColorAt(0.4, QColor(255, 255, 255, 60)); - grad.setColorAt(0.7, QColor(255, 255, 255, 50)); - grad.setColorAt(1, QColor(255, 255, 255, 40)); - painter->setPen(QPen(grad, 0)); - painter->drawLine(rect.topRight(), rect.bottomRight()); - grad.setColorAt(0, QColor(0, 0, 0, 30)); - grad.setColorAt(0.4, QColor(0, 0, 0, 70)); - grad.setColorAt(0.7, QColor(0, 0, 0, 70)); - grad.setColorAt(1, QColor(0, 0, 0, 40)); - painter->setPen(QPen(grad, 0)); - if (!reverse) - painter->drawLine(rect.topRight() - QPoint(1,0), rect.bottomRight() - QPoint(1,0)); - else - painter->drawLine(rect.topLeft(), rect.bottomLeft()); - } diff --git a/ThirdParty/GUI/qt-manhattan-style/manhattanstyle.h b/ThirdParty/GUI/qt-manhattan-style/manhattanstyle.h deleted file mode 100644 index fe761a3f7e0fab16ed055b5c3d52fdbb1e4c028e..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/manhattanstyle.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef MANHATTANSTYLE_H -#define MANHATTANSTYLE_H - -#include "qt-manhattan-style_global.hpp" - -#include <QProxyStyle> - -class ManhattanStylePrivate; - -class QTMANHATTANSTYLESHARED_EXPORT ManhattanStyle : public QProxyStyle -{ - Q_OBJECT - -public: - explicit ManhattanStyle(const QString &baseStyleName); - - virtual ~ManhattanStyle(); - - virtual void drawPrimitive(PrimitiveElement element, const QStyleOption *option, - QPainter *painter, const QWidget *widget = 0) const; - virtual void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, - const QWidget *widget = 0) const; - virtual void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, - QPainter *painter, const QWidget *widget = 0) const; - - virtual QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, - const QWidget *widget) const; - virtual QRect subElementRect(SubElement element, const QStyleOption *option, - const QWidget *widget) const; - virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, - const QWidget *widget) const; - - virtual SubControl hitTestComplexControl(ComplexControl control, - const QStyleOptionComplex *option, const QPoint &pos, - const QWidget *widget = 0) const; - virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, - const QWidget *widget = 0) const; - virtual int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, - QStyleHintReturn *returnData = 0) const; - QRect itemRect(QPainter *p, const QRect &r, int flags, bool enabled, const QPixmap *pixmap, - const QString &text, int len = -1) const; - virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, - const QStyleOption *opt) const; - - virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, - const QWidget *widget = 0) const; - - virtual QPalette standardPalette() const; - - virtual void polish(QWidget *widget); - virtual void polish(QPalette &pal); - virtual void polish(QApplication *app); - - virtual void unpolish(QWidget *widget); - virtual void unpolish(QApplication *app); - -protected slots: - QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const; - -private: - void drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const; - - ManhattanStylePrivate *d; -}; - -#endif // MANHATTANSTYLE_H diff --git a/ThirdParty/GUI/qt-manhattan-style/minisplitter.cpp b/ThirdParty/GUI/qt-manhattan-style/minisplitter.cpp deleted file mode 100644 index bf18d53389463a703592240cf7adf75a3edb2f38..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/minisplitter.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "minisplitter.h" - -#include "stylehelper.h" - -#include <QPaintEvent> -#include <QPainter> -#include <QSplitterHandle> - -using namespace Manhattan; - -class MiniSplitterHandle : public QSplitterHandle -{ -public: - MiniSplitterHandle(Qt::Orientation orientation, QSplitter *parent) - : QSplitterHandle(orientation, parent) - { - setMask(QRegion(contentsRect())); - setAttribute(Qt::WA_MouseNoMask, true); - } -protected: - void resizeEvent(QResizeEvent *event); - void paintEvent(QPaintEvent *event); -}; - -void MiniSplitterHandle::resizeEvent(QResizeEvent *event) -{ - if (orientation() == Qt::Horizontal) - setContentsMargins(2, 0, 2, 0); - else - setContentsMargins(0, 2, 0, 2); - setMask(QRegion(contentsRect())); - QSplitterHandle::resizeEvent(event); -} - -void MiniSplitterHandle::paintEvent(QPaintEvent *event) -{ - QPainter painter(this); - painter.fillRect(event->rect(), Utils::StyleHelper::borderColor()); -} - -QSplitterHandle *MiniSplitter::createHandle() -{ - return new MiniSplitterHandle(orientation(), this); -} - -MiniSplitter::MiniSplitter(QWidget *parent) - : QSplitter(parent) -{ - setHandleWidth(1); - setChildrenCollapsible(false); - setProperty("minisplitter", true); -} - -MiniSplitter::MiniSplitter(Qt::Orientation orientation) - : QSplitter(orientation) -{ - setHandleWidth(1); - setChildrenCollapsible(false); - setProperty("minisplitter", true); -} diff --git a/ThirdParty/GUI/qt-manhattan-style/minisplitter.h b/ThirdParty/GUI/qt-manhattan-style/minisplitter.h deleted file mode 100644 index ef9caa9453527d6643c86ffcf81e0e4d24c7c4e1..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/minisplitter.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef MINISPLITTER_H -#define MINISPLITTER_H - -#include "qt-manhattan-style_global.hpp" - -#include <QSplitter> - -QT_BEGIN_NAMESPACE -class QSplitterHandle; -QT_END_NAMESPACE - -namespace Manhattan { - -/*! This is a simple helper-class to obtain mac-style 1-pixel wide splitters */ -class QTMANHATTANSTYLESHARED_EXPORT MiniSplitter : public QSplitter -{ -public: - MiniSplitter(QWidget *parent = 0); - MiniSplitter(Qt::Orientation orientation); - -protected: - QSplitterHandle *createHandle(); -}; - -} // namespace Manhattan - -#endif // MINISPLITTER_H diff --git a/ThirdParty/GUI/qt-manhattan-style/progressbar.cpp b/ThirdParty/GUI/qt-manhattan-style/progressbar.cpp deleted file mode 100644 index 67301e086a4e4ccecbc795eb663e304e35edb03b..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/progressbar.cpp +++ /dev/null @@ -1,298 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "progressbar.h" - -#include "stylehelper.h" - -#include <QPropertyAnimation> -#include <QPainter> -#include <QFont> -#include <QBrush> -#include <QColor> -#include <QMouseEvent> - -using namespace Manhattan; - -#define PROGRESSBAR_HEIGHT 12 -#define CANCELBUTTON_SIZE 15 - -ProgressBar::ProgressBar(QWidget *parent) - : QWidget(parent), m_error(false), m_progressHeight(0), m_minimum(1), m_maximum(100), m_value(1), m_cancelButtonFader(0), m_finished(false) -{ - setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); - setMouseTracking(true); -} - -ProgressBar::~ProgressBar() -{ -} - -bool ProgressBar::event(QEvent *e) -{ - switch(e->type()) { - case QEvent::Enter: - { - QPropertyAnimation *animation = new QPropertyAnimation(this, "cancelButtonFader"); - animation->setDuration(125); - animation->setEndValue(1.0); - animation->start(QAbstractAnimation::DeleteWhenStopped); - } - break; - case QEvent::Leave: - { - QPropertyAnimation *animation = new QPropertyAnimation(this, "cancelButtonFader"); - animation->setDuration(225); - animation->setEndValue(0.0); - animation->start(QAbstractAnimation::DeleteWhenStopped); - } - break; - default: - return QWidget::event(e); - } - return false; -} - - -void ProgressBar::reset() -{ - m_value = m_minimum; - update(); -} - -void ProgressBar::setRange(int minimum, int maximum) -{ - m_minimum = minimum; - m_maximum = maximum; - if (m_value < m_minimum || m_value > m_maximum) - m_value = m_minimum; - update(); -} - -void ProgressBar::setValue(int value) -{ - if (m_value == value - || m_value < m_minimum - || m_value > m_maximum) { - return; - } - m_value = value; - update(); -} - -void ProgressBar::setFinished(bool b) -{ - if (b == m_finished) - return; - m_finished = b; - update(); -} - -QString ProgressBar::title() const -{ - return m_title; -} - -bool ProgressBar::hasError() const -{ - return m_error; -} - -void ProgressBar::setTitle(const QString &title) -{ - m_title = title; - update(); -} - -void ProgressBar::setError(bool on) -{ - m_error = on; - update(); -} - -QSize ProgressBar::sizeHint() const -{ - QSize s; - s.setWidth(50); - s.setHeight(fontMetrics().height() + PROGRESSBAR_HEIGHT + 6); - return s; -} - -namespace { const int INDENT = 6; } - -void ProgressBar::mousePressEvent(QMouseEvent *event) -{ - QFont boldFont(font()); - boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); - boldFont.setBold(true); - QFontMetrics fm(boldFont); - int h = fm.height(); - QRect rect(INDENT - 1, h+8, size().width()-2*INDENT + 1, m_progressHeight-1); - QRect cancelRect(rect.adjusted(rect.width() - CANCELBUTTON_SIZE, 1, -1, 0)); - - if (event->modifiers() == Qt::NoModifier - && cancelRect.contains(event->pos())) { - event->accept(); - emit clicked(); - return; - } - QWidget::mousePressEvent(event); -} - -void ProgressBar::mouseMoveEvent(QMouseEvent *) -{ - update(); -} - -void ProgressBar::paintEvent(QPaintEvent *) -{ - if (bar.isNull()) - bar.load(QLatin1String(":/core/images/progressbar.png")); - - double range = maximum() - minimum(); - double percent = 0.; - if (range != 0) - percent = (value() - minimum()) / range; - if (percent > 1) - percent = 1; - else if (percent < 0) - percent = 0; - - if (finished()) - percent = 1; - - QPainter p(this); - QFont boldFont(p.font()); - boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize()); - boldFont.setBold(true); - p.setFont(boldFont); - QFontMetrics fm(boldFont); - - // Draw separator - int h = fm.height(); - p.setPen(Utils::StyleHelper::sidebarShadow()); - p.drawLine(0,0, size().width(), 0); - - p.setPen(Utils::StyleHelper::sidebarHighlight()); - p.drawLine(1, 1, size().width(), 1); - - QRect textBounds = fm.boundingRect(m_title); - textBounds.moveCenter(rect().center()); - int alignment = Qt::AlignHCenter; - - int textSpace = rect().width() - 8; - // If there is not enough room when centered, we left align and - // elide the text - QString elidedtitle = fm.elidedText(m_title, Qt::ElideRight, textSpace); - - QRect textRect = rect().adjusted(3, 1, -3, 0); - textRect.setHeight(h+5); - - p.setPen(QColor(0, 0, 0, 120)); - p.drawText(textRect, alignment | Qt::AlignBottom, elidedtitle); - p.translate(0, -1); - p.setPen(Utils::StyleHelper::panelTextColor()); - p.drawText(textRect, alignment | Qt::AlignBottom, elidedtitle); - p.translate(0, 1); - - m_progressHeight = PROGRESSBAR_HEIGHT; - m_progressHeight += ((m_progressHeight % 2) + 1) % 2; // make odd - // draw outer rect - QRect rect(INDENT - 1, h+6, size().width()-2*INDENT + 1, m_progressHeight-1); - p.setPen(Utils::StyleHelper::panelTextColor()); - Utils::StyleHelper::drawCornerImage(bar, &p, rect, 2, 2, 2, 2); - - // draw inner rect - QColor c = Utils::StyleHelper::panelTextColor(); - c.setAlpha(180); - p.setPen(Qt::NoPen); - - - QRect inner = rect.adjusted(3, 2, -2, -2); - inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0); - if (m_error) { - QColor red(255, 60, 0, 210); - c = red; - // avoid too small red bar - if (inner.width() < 10) - inner.adjust(0, 0, 10 - inner.width(), 0); - } else if (m_finished) { - c = QColor(90, 170, 60); - } - - // Draw line and shadow after the gradient fill - if (value() > 0 && value() < maximum()) { - p.fillRect(QRect(inner.right() + 1, inner.top(), 2, inner.height()), QColor(0, 0, 0, 20)); - p.fillRect(QRect(inner.right() + 1, inner.top(), 1, inner.height()), QColor(0, 0, 0, 60)); - } - QLinearGradient grad(inner.topLeft(), inner.bottomLeft()); - grad.setColorAt(0, c.lighter(130)); - grad.setColorAt(0.5, c.lighter(106)); - grad.setColorAt(0.51, c.darker(106)); - grad.setColorAt(1, c.darker(130)); - p.setPen(Qt::NoPen); - p.setBrush(grad); - p.drawRect(inner); - p.setBrush(Qt::NoBrush); - p.setPen(QPen(QColor(0, 0, 0, 30), 1)); - p.drawLine(inner.topLeft(), inner.topRight()); - p.drawLine(inner.topLeft(), inner.bottomLeft()); - p.drawLine(inner.topRight(), inner.bottomRight()); - p.drawLine(inner.bottomLeft(), inner.bottomRight()); - p.drawPoint(inner.bottomLeft()); - p.drawPoint(inner.bottomRight()); - - // Draw cancel button - p.setOpacity(m_cancelButtonFader); - - if (value() < maximum() && !m_error) { - QRect cancelRect(rect.adjusted(rect.width() - CANCELBUTTON_SIZE, 1, -1, 0)); - bool hover = cancelRect.contains(mapFromGlobal(QCursor::pos())); - QLinearGradient grad(cancelRect.topLeft(), cancelRect.bottomLeft()); - int intensity = hover ? 90 : 70; - QColor buttonColor(intensity, intensity, intensity, 255); - grad.setColorAt(0, buttonColor.lighter(130)); - grad.setColorAt(1, buttonColor.darker(130)); - p.setPen(Qt::NoPen); - p.setBrush(grad); - p.drawRect(cancelRect.adjusted(1, 1, -1, -1)); - - p.setPen(QPen(QColor(0, 0, 0, 30))); - p.drawLine(cancelRect.topLeft() + QPoint(0,1), cancelRect.bottomLeft() + QPoint(0,-1)); - p.setPen(QPen(QColor(0, 0, 0, 120))); - p.drawLine(cancelRect.topLeft() + QPoint(1,1), cancelRect.bottomLeft() + QPoint(1,-1)); - p.setPen(QPen(QColor(255, 255, 255, 30))); - p.drawLine(cancelRect.topLeft() + QPoint(2,1), cancelRect.bottomLeft() + QPoint(2,-1)); - p.setPen(QPen(hover ? Utils::StyleHelper::panelTextColor() : QColor(180, 180, 180), 1)); - p.setRenderHint(QPainter::Antialiasing); - p.translate(0.5, 0.5); - p.drawLine(cancelRect.center()+QPoint(-1,-2), cancelRect.center()+QPoint(+3,+2)); - p.drawLine(cancelRect.center()+QPoint(+3,-2), cancelRect.center()+QPoint(-1,+2)); - } -} diff --git a/ThirdParty/GUI/qt-manhattan-style/progressbar.h b/ThirdParty/GUI/qt-manhattan-style/progressbar.h deleted file mode 100644 index 13b45f94366485a35d4b98480af2c41f1be7952f..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/progressbar.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef PROGRESSPIE_H -#define PROGRESSPIE_H - -#include "qt-manhattan-style_global.hpp" -#include <QString> -#include <QWidget> - -namespace Manhattan { - -class QTMANHATTANSTYLESHARED_EXPORT ProgressBar : public QWidget -{ - Q_OBJECT - - Q_PROPERTY(float cancelButtonFader READ cancelButtonFader WRITE setCancelButtonFader) - -public: - explicit ProgressBar(QWidget *parent = 0); - virtual ~ProgressBar(); - - QString title() const; - void setTitle(const QString &title); - void setError(bool on); - bool hasError() const; - virtual QSize sizeHint() const; - virtual void paintEvent(QPaintEvent *); - virtual void mouseMoveEvent(QMouseEvent *); - int minimum() const { return m_minimum; } - int maximum() const { return m_maximum; } - int value() const { return m_value; } - bool finished() const { return m_finished; } - void reset(); - void setRange(int minimum, int maximum); - void setValue(int value); - void setFinished(bool b); - float cancelButtonFader() { return m_cancelButtonFader; } - void setCancelButtonFader(float value) { update(); m_cancelButtonFader= value;} - virtual bool event(QEvent *); - -signals: - void clicked(); - -protected: - virtual void mousePressEvent(QMouseEvent *event); - -private: - QImage bar; - QString m_text; - QString m_title; - bool m_error; - int m_progressHeight; - int m_minimum; - int m_maximum; - int m_value; - float m_cancelButtonFader; - bool m_finished; -}; - -} // namespace Manhattan - -#endif // PROGRESSPIE_H diff --git a/ThirdParty/GUI/qt-manhattan-style/qt-manhattan-style_global.hpp b/ThirdParty/GUI/qt-manhattan-style/qt-manhattan-style_global.hpp deleted file mode 100644 index 19a954df76ad006e8606fab84d37f35ba543dda3..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/qt-manhattan-style_global.hpp +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef QTMANHATTANSTYLE_GLOBAL_HPP -#define QTMANHATTANSTYLE_GLOBAL_HPP - -#include <qglobal.h> - -# define QTMANHATTANSTYLESHARED_EXPORT - -#endif // QTMANHATTANSTYLE_GLOBAL_HPP diff --git a/ThirdParty/GUI/qt-manhattan-style/qtcassert.cpp b/ThirdParty/GUI/qt-manhattan-style/qtcassert.cpp deleted file mode 100644 index 256190f984d9ea70abb1203d079577dd18f35521..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/qtcassert.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qtcassert.h" - -namespace Manhattan { - -void writeAssertLocation(const char *msg) -{ - qDebug("SOFT ASSERT: %s", msg); -} - -} // namespace Utils diff --git a/ThirdParty/GUI/qt-manhattan-style/qtcassert.h b/ThirdParty/GUI/qt-manhattan-style/qtcassert.h deleted file mode 100644 index eb49fa815b49ea29d9dfbfc6aa7d051f3ef62739..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/qtcassert.h +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QTC_ASSERT_H -#define QTC_ASSERT_H - -#include "qt-manhattan-style_global.hpp" - -namespace Manhattan { QTMANHATTANSTYLESHARED_EXPORT void writeAssertLocation(const char *msg); } - -#define QTC_ASSERT_STRINGIFY_HELPER(x) #x -#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x) -#define QTC_ASSERT_STRING(cond) ::Manhattan::writeAssertLocation(\ - "\"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__)) - -// The 'do {...} while (0)' idiom is not used for the main block here to be -// able to use 'break' and 'continue' as 'actions'. - -#define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0) -#define QTC_CHECK(cond) if (cond) {} else { QTC_ASSERT_STRING(#cond); } do {} while (0) - -#endif // QTC_ASSERT_H - diff --git a/ThirdParty/GUI/qt-manhattan-style/qtcolorbutton.cpp b/ThirdParty/GUI/qt-manhattan-style/qtcolorbutton.cpp deleted file mode 100644 index e46ef6bb7588f48dad034553ab80c803030e96cf..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/qtcolorbutton.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qtcolorbutton.h" -#include "qtcolorbutton_p.h" - -#include <QMimeData> -#include <QApplication> -#include <QColorDialog> -#include <QDragEnterEvent> -#include <QPainter> -#include <QDrag> - -namespace Manhattan { - -void QtColorButtonPrivate::slotEditColor() -{ - QColor newColor; - if (m_alphaAllowed) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) - newColor = QColorDialog::getColor(m_color.rgba(), q_ptr); -#else - bool ok; - const QRgb rgba = QColorDialog::getRgba(m_color.rgba(), &ok, q_ptr); - if (!ok) - return; - newColor = QColor::fromRgba(rgba); -#endif - } else { - newColor = QColorDialog::getColor(m_color, q_ptr); - if (!newColor.isValid()) - return; - } - if (newColor == q_ptr->color()) - return; - q_ptr->setColor(newColor); - emit q_ptr->colorChanged(m_color); -} - -QColor QtColorButtonPrivate::shownColor() const -{ -#ifndef QT_NO_DRAGANDDROP - if (m_dragging) - return m_dragColor; -#endif - return m_color; -} - -QPixmap QtColorButtonPrivate::generatePixmap() const -{ - QPixmap pix(24, 24); - - int pixSize = 20; - QBrush br(shownColor()); - - QPixmap pm(2 * pixSize, 2 * pixSize); - QPainter pmp(&pm); - pmp.fillRect(0, 0, pixSize, pixSize, Qt::lightGray); - pmp.fillRect(pixSize, pixSize, pixSize, pixSize, Qt::lightGray); - pmp.fillRect(0, pixSize, pixSize, pixSize, Qt::darkGray); - pmp.fillRect(pixSize, 0, pixSize, pixSize, Qt::darkGray); - pmp.fillRect(0, 0, 2 * pixSize, 2 * pixSize, shownColor()); - br = QBrush(pm); - - QPainter p(&pix); - int corr = 1; - QRect r = pix.rect().adjusted(corr, corr, -corr, -corr); - p.setBrushOrigin((r.width() % pixSize + pixSize) / 2 + corr, (r.height() % pixSize + pixSize) / 2 + corr); - p.fillRect(r, br); - - p.fillRect(r.width() / 4 + corr, r.height() / 4 + corr, - r.width() / 2, r.height() / 2, - QColor(shownColor().rgb())); - p.drawRect(pix.rect().adjusted(0, 0, -1, -1)); - - return pix; -} - -/////////////// - -QtColorButton::QtColorButton(QWidget *parent) - : QToolButton(parent) -{ - d_ptr = new QtColorButtonPrivate; - d_ptr->q_ptr = this; - d_ptr->m_dragging = false; - d_ptr->m_backgroundCheckered = true; - d_ptr->m_alphaAllowed = true; - - setAcceptDrops(true); - - connect(this, SIGNAL(clicked()), d_ptr, SLOT(slotEditColor())); - setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); -} - -QtColorButton::~QtColorButton() -{ - delete d_ptr; -} - -void QtColorButton::setColor(const QColor &color) -{ - if (d_ptr->m_color == color) - return; - d_ptr->m_color = color; - update(); -} - -QColor QtColorButton::color() const -{ - return d_ptr->m_color; -} - -void QtColorButton::setBackgroundCheckered(bool checkered) -{ - if (d_ptr->m_backgroundCheckered == checkered) - return; - d_ptr->m_backgroundCheckered = checkered; - update(); -} - -bool QtColorButton::isBackgroundCheckered() const -{ - return d_ptr->m_backgroundCheckered; -} - -void QtColorButton::setAlphaAllowed(bool allowed) -{ - d_ptr->m_alphaAllowed = allowed; -} - -bool QtColorButton::isAlphaAllowed() const -{ - return d_ptr->m_alphaAllowed; -} - -void QtColorButton::paintEvent(QPaintEvent *event) -{ - QToolButton::paintEvent(event); - if (!isEnabled()) - return; - - const int pixSize = 10; - QBrush br(d_ptr->shownColor()); - if (d_ptr->m_backgroundCheckered) { - QPixmap pm(2 * pixSize, 2 * pixSize); - QPainter pmp(&pm); - pmp.fillRect(0, 0, pixSize, pixSize, Qt::white); - pmp.fillRect(pixSize, pixSize, pixSize, pixSize, Qt::white); - pmp.fillRect(0, pixSize, pixSize, pixSize, Qt::black); - pmp.fillRect(pixSize, 0, pixSize, pixSize, Qt::black); - pmp.fillRect(0, 0, 2 * pixSize, 2 * pixSize, d_ptr->shownColor()); - br = QBrush(pm); - } - - QPainter p(this); - const int corr = 5; - QRect r = rect().adjusted(corr, corr, -corr, -corr); - p.setBrushOrigin((r.width() % pixSize + pixSize) / 2 + corr, (r.height() % pixSize + pixSize) / 2 + corr); - p.fillRect(r, br); - - //const int adjX = qRound(r.width() / 4.0); - //const int adjY = qRound(r.height() / 4.0); - //p.fillRect(r.adjusted(adjX, adjY, -adjX, -adjY), - // QColor(d_ptr->shownColor().rgb())); - /* - p.fillRect(r.adjusted(0, r.height() * 3 / 4, 0, 0), - QColor(d_ptr->shownColor().rgb())); - p.fillRect(r.adjusted(0, 0, 0, -r.height() * 3 / 4), - QColor(d_ptr->shownColor().rgb())); - */ - /* - const QColor frameColor0(0, 0, 0, qRound(0.2 * (0xFF - d_ptr->shownColor().alpha()))); - p.setPen(frameColor0); - p.drawRect(r.adjusted(adjX, adjY, -adjX - 1, -adjY - 1)); - */ - - const QColor frameColor1(0, 0, 0, 26); - p.setPen(frameColor1); - p.drawRect(r.adjusted(1, 1, -2, -2)); - const QColor frameColor2(0, 0, 0, 51); - p.setPen(frameColor2); - p.drawRect(r.adjusted(0, 0, -1, -1)); -} - -void QtColorButton::mousePressEvent(QMouseEvent *event) -{ -#ifndef QT_NO_DRAGANDDROP - if (event->button() == Qt::LeftButton) - d_ptr->m_dragStart = event->pos(); -#endif - QToolButton::mousePressEvent(event); -} - -void QtColorButton::mouseMoveEvent(QMouseEvent *event) -{ -#ifndef QT_NO_DRAGANDDROP - if (event->buttons() & Qt::LeftButton && - (d_ptr->m_dragStart - event->pos()).manhattanLength() > QApplication::startDragDistance()) { - QMimeData *mime = new QMimeData; - mime->setColorData(color()); - QDrag *drg = new QDrag(this); - drg->setMimeData(mime); - drg->setPixmap(d_ptr->generatePixmap()); - setDown(false); - event->accept(); - -#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) - drg->exec(); -#else - drg->start(); -#endif - return; - } -#endif - QToolButton::mouseMoveEvent(event); -} - -#ifndef QT_NO_DRAGANDDROP -void QtColorButton::dragEnterEvent(QDragEnterEvent *event) -{ - const QMimeData *mime = event->mimeData(); - if (!mime->hasColor()) - return; - - event->accept(); - d_ptr->m_dragColor = qvariant_cast<QColor>(mime->colorData()); - d_ptr->m_dragging = true; - update(); -} - -void QtColorButton::dragLeaveEvent(QDragLeaveEvent *event) -{ - event->accept(); - d_ptr->m_dragging = false; - update(); -} - -void QtColorButton::dropEvent(QDropEvent *event) -{ - event->accept(); - d_ptr->m_dragging = false; - if (d_ptr->m_dragColor == color()) - return; - setColor(d_ptr->m_dragColor); - emit colorChanged(color()); -} -#endif - -} // namespace Manhattan - diff --git a/ThirdParty/GUI/qt-manhattan-style/qtcolorbutton.h b/ThirdParty/GUI/qt-manhattan-style/qtcolorbutton.h deleted file mode 100644 index 8c3a7b837d3388166fb962091f243e8bc358c583..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/qtcolorbutton.h +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QTCOLORBUTTON_H -#define QTCOLORBUTTON_H - -#include "qt-manhattan-style_global.hpp" - -#include <QToolButton> - -namespace Manhattan { - -class QTMANHATTANSTYLESHARED_EXPORT QtColorButton : public QToolButton -{ - Q_OBJECT - Q_PROPERTY(bool backgroundCheckered READ isBackgroundCheckered WRITE setBackgroundCheckered) - Q_PROPERTY(bool alphaAllowed READ isAlphaAllowed WRITE setAlphaAllowed) - Q_PROPERTY(QColor color READ color WRITE setColor) -public: - QtColorButton(QWidget *parent = 0); - virtual ~QtColorButton(); - - bool isBackgroundCheckered() const; - void setBackgroundCheckered(bool checkered); - - bool isAlphaAllowed() const; - void setAlphaAllowed(bool allowed); - - QColor color() const; - -public slots: - void setColor(const QColor &color); - -signals: - void colorChanged(const QColor &color); -protected: - virtual void paintEvent(QPaintEvent *event); - virtual void mousePressEvent(QMouseEvent *event); - virtual void mouseMoveEvent(QMouseEvent *event); -#ifndef QT_NO_DRAGANDDROP - virtual void dragEnterEvent(QDragEnterEvent *event); - virtual void dragLeaveEvent(QDragLeaveEvent *event); - virtual void dropEvent(QDropEvent *event); -#endif -private: - class QtColorButtonPrivate *d_ptr; - friend class QtColorButtonPrivate; -}; - -} // namespace Manhattan - -#endif // QTCOLORBUTTON_H diff --git a/ThirdParty/GUI/qt-manhattan-style/qtcolorbutton_p.h b/ThirdParty/GUI/qt-manhattan-style/qtcolorbutton_p.h deleted file mode 100644 index c1102cfd2e2e29ea143b0b0053b557912022b8f6..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/qtcolorbutton_p.h +++ /dev/null @@ -1,27 +0,0 @@ -#include "qtcolorbutton.h" - -namespace Manhattan { - -class QtColorButtonPrivate: public QObject -{ - Q_OBJECT - QtColorButton *q_ptr; - Q_DECLARE_PUBLIC(QtColorButton) -public slots: - void slotEditColor(); - -public: - QColor shownColor() const; - QPixmap generatePixmap() const; - - QColor m_color; -#ifndef QT_NO_DRAGANDDROP - QColor m_dragColor; - QPoint m_dragStart; - bool m_dragging; -#endif - bool m_backgroundCheckered; - bool m_alphaAllowed; -}; - -} // namespace Utils diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/leftselection.png b/ThirdParty/GUI/qt-manhattan-style/resources/leftselection.png deleted file mode 100644 index 8b787ca4e6e54f7b80d9abfabc925ad0466c79eb..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/leftselection.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/midselection.png b/ThirdParty/GUI/qt-manhattan-style/resources/midselection.png deleted file mode 100644 index d6db82e1680701be6287e1e3f1f114189be9c697..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/midselection.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/progressbar.png b/ThirdParty/GUI/qt-manhattan-style/resources/progressbar.png deleted file mode 100644 index 806ed87020fceea7d27f88aa35c35ace939db843..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/progressbar.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/resources.qrc b/ThirdParty/GUI/qt-manhattan-style/resources/resources.qrc deleted file mode 100644 index 1c216e94513c0843d721660de008657afc34ea16..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/resources/resources.qrc +++ /dev/null @@ -1,24 +0,0 @@ -<RCC> - <qresource prefix="/core/images"> - <file>progressbar.png</file> - </qresource> - <qresource prefix="/projectexplorer/images"> - <file>targetpanel_gradient.png</file> - <file>leftselection.png</file> - <file>midselection.png</file> - <file>rightselection.png</file> - <file>targetpanel_bottom.png</file> - </qresource> - <qresource prefix="/extensions/images"> - <file>scrollbar-vertical-up-highlight.png</file> - <file>scrollbar-vertical-background.png</file> - <file>scrollbar-vertical-down.png</file> - <file>scrollbar-vertical-down-highlight.png</file> - <file>scrollbar-vertical-slider.png</file> - <file>scrollbar-vertical-slider-highlight.png</file> - <file>scrollbar-vertical-up.png</file> - </qresource> - <qresource prefix="/extensions/qss"> - <file>threelevelsitempicker-listwidget.qss</file> - </qresource> -</RCC> diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/rightselection.png b/ThirdParty/GUI/qt-manhattan-style/resources/rightselection.png deleted file mode 100644 index 26b181cf342a7ee7c4a771bcc75625ac2f2f59b3..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/rightselection.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-background.png b/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-background.png deleted file mode 100644 index 42a9b86c7b446bfeaef151440086f8d223a27ced..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-background.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-down-highlight.png b/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-down-highlight.png deleted file mode 100644 index e4bf7b40251fb16c28d73af51abe4b7538388159..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-down-highlight.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-down.png b/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-down.png deleted file mode 100644 index 5f91b598bbbb837a159893833fb2c992fe9870a5..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-down.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-slider-highlight.png b/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-slider-highlight.png deleted file mode 100644 index 96cba68f5d92eb162e8b7222016148153e4f1a60..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-slider-highlight.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-slider.png b/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-slider.png deleted file mode 100644 index e3b100f2645132b129bb411b2c84be16498b2d9b..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-slider.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-up-highlight.png b/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-up-highlight.png deleted file mode 100644 index 73851f6002960a014023d63943b51eb1e2b664a8..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-up-highlight.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-up.png b/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-up.png deleted file mode 100644 index 3638898f2fe8fb4f05e263b96dc25e718efc0a0e..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/scrollbar-vertical-up.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/targetpanel_bottom.png b/ThirdParty/GUI/qt-manhattan-style/resources/targetpanel_bottom.png deleted file mode 100644 index 28bddc01e71fafd3524c11c21cfb24a28a35cce3..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/targetpanel_bottom.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/targetpanel_gradient.png b/ThirdParty/GUI/qt-manhattan-style/resources/targetpanel_gradient.png deleted file mode 100644 index c2d8b5896602869d1a4153a2ba5f5aa513bad62b..0000000000000000000000000000000000000000 Binary files a/ThirdParty/GUI/qt-manhattan-style/resources/targetpanel_gradient.png and /dev/null differ diff --git a/ThirdParty/GUI/qt-manhattan-style/resources/threelevelsitempicker-listwidget.qss b/ThirdParty/GUI/qt-manhattan-style/resources/threelevelsitempicker-listwidget.qss deleted file mode 100644 index 52a99b447a9ffb7481252eaae5979a1fdd5d2327..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/resources/threelevelsitempicker-listwidget.qss +++ /dev/null @@ -1,48 +0,0 @@ -QListWidget { - background: #464646; - border-style: none; -} - -QScrollBar:vertical { - margin: 17px 0 17px 0; - border-image: url(:extensions/images/scrollbar-vertical-background.png) 10 0 10 0 stretch stretch; -} - -QScrollBar::handle:vertical { - border-width: 1px; - border-image: url(:extensions/images/scrollbar-vertical-slider.png) 2 1 2 1 stretch stretch; - min-height: 20px; -} - -QScrollBar::handle:vertical:hover { - border-image: url(:extensions/images/scrollbar-vertical-slider-highlight.png) 2 1 2 1 stretch stretch; - min-height: 20px; -} - -QScrollBar::add-line:vertical { - border-image: url(:extensions/images/scrollbar-vertical-down.png); - height: 16px; - subcontrol-origin: margin; -} - -QScrollBar::add-line:vertical:hover { - border-image: url(:extensions/images/scrollbar-vertical-down-highlight.png); - height: 16px; - subcontrol-origin: margin; -} - -QScrollBar::sub-line:vertical { - border-image: url(:extensions/images/scrollbar-vertical-up.png); - height: 16px; - subcontrol-origin: margin; -} - -QScrollBar::sub-line:vertical:hover { - border-image: url(:extensions/images/scrollbar-vertical-up-highlight.png); - height: 16px; - subcontrol-origin: margin; -} - -QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { - background: none; -} diff --git a/ThirdParty/GUI/qt-manhattan-style/settingsutils.cpp b/ThirdParty/GUI/qt-manhattan-style/settingsutils.cpp deleted file mode 100644 index bfbeb751e127658ad5383b0f954d42890627271f..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/settingsutils.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "settingsutils.h" - -#include <QString> -#include <QStringList> -#include <QFileInfo> -#include <QDir> - -#include <limits.h> - -namespace Manhattan { - -QTMANHATTANSTYLESHARED_EXPORT QString settingsKey(const QString &category) -{ - QString rc(category); - const QChar underscore = QLatin1Char('_'); - // Remove the sort category "X.Category" -> "Category" - if (rc.size() > 2 && rc.at(0).isLetter() && rc.at(1) == QLatin1Char('.')) - rc.remove(0, 2); - // Replace special characters - const int size = rc.size(); - for (int i = 0; i < size; i++) { - const QChar c = rc.at(i); - if (!c.isLetterOrNumber() && c != underscore) - rc[i] = underscore; - } - return rc; -} - -// Figure out length of common start of string ("C:\a", "c:\b" -> "c:\" -static inline int commonPartSize(const QString &s1, const QString &s2) -{ - const int size = qMin(s1.size(), s2.size()); - for (int i = 0; i < size; i++) - if (s1.at(i) != s2.at(i)) - return i; - return size; -} - -QTMANHATTANSTYLESHARED_EXPORT QString commonPrefix(const QStringList &strings) -{ - switch (strings.size()) { - case 0: - return QString(); - case 1: - return strings.front(); - default: - break; - } - // Figure out common string part: "C:\foo\bar1" "C:\foo\bar2" -> "C:\foo\bar" - int commonLength = INT_MAX; - const int last = strings.size() - 1; - for (int i = 0; i < last; i++) - commonLength = qMin(commonLength, commonPartSize(strings.at(i), strings.at(i + 1))); - if (!commonLength) - return QString(); - return strings.at(0).left(commonLength); -} - -QTMANHATTANSTYLESHARED_EXPORT QString commonPath(const QStringList &files) -{ - QString common = commonPrefix(files); - // Find common directory part: "C:\foo\bar" -> "C:\foo" - int lastSeparatorPos = common.lastIndexOf(QLatin1Char('/')); - if (lastSeparatorPos == -1) - lastSeparatorPos = common.lastIndexOf(QLatin1Char('\\')); - if (lastSeparatorPos == -1) - return QString(); -#ifdef Q_OS_UNIX - if (lastSeparatorPos == 0) // Unix: "/a", "/b" -> '/' - lastSeparatorPos = 1; -#endif - common.truncate(lastSeparatorPos); - return common; -} - -QTMANHATTANSTYLESHARED_EXPORT QString withTildeHomePath(const QString &path) -{ -#ifdef Q_OS_WIN - QString outPath = path; -#else - static const QString homePath = QDir::homePath(); - - QFileInfo fi(QDir::cleanPath(path)); - QString outPath = fi.absoluteFilePath(); - if (outPath.startsWith(homePath)) - outPath = QLatin1Char('~') + outPath.mid(homePath.size()); - else - outPath = path; -#endif - return outPath; -} - -int AbstractQtcMacroExpander::findMacro(const QString &str, int *pos, QString *ret) -{ - forever { - int openPos = str.indexOf(QLatin1String("%{"), *pos); - if (openPos < 0) - return 0; - int varPos = openPos + 2; - int closePos = str.indexOf(QLatin1Char('}'), varPos); - if (closePos < 0) - return 0; - int varLen = closePos - varPos; - if (resolveMacro(str.mid(varPos, varLen), ret)) { - *pos = openPos; - return varLen + 3; - } - // An actual expansion may be nested into a "false" one, - // so we continue right after the last %{. - *pos = varPos; - } -} - -QTMANHATTANSTYLESHARED_EXPORT void expandMacros(QString *str, AbstractMacroExpander *mx) -{ - QString rsts; - - for (int pos = 0; int len = mx->findMacro(*str, &pos, &rsts); ) { - str->replace(pos, len, rsts); - pos += rsts.length(); - } -} - -QTMANHATTANSTYLESHARED_EXPORT QString expandMacros(const QString &str, AbstractMacroExpander *mx) -{ - QString ret = str; - expandMacros(&ret, mx); - return ret; -} - -} // namespace Manhattan diff --git a/ThirdParty/GUI/qt-manhattan-style/settingsutils.h b/ThirdParty/GUI/qt-manhattan-style/settingsutils.h deleted file mode 100644 index 29c658badd79480d323dbf3e7bbe985c51be106a..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/settingsutils.h +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef SETTINGSTUTILS_H -#define SETTINGSTUTILS_H - -#include "qt-manhattan-style_global.hpp" - -QT_BEGIN_NAMESPACE -class QStringList; -QT_END_NAMESPACE - -namespace Manhattan { - -// Create a usable settings key from a category, -// for example Editor|C++ -> Editor_C__ -QTMANHATTANSTYLESHARED_EXPORT QString settingsKey(const QString &category); - -// Return the common prefix part of a string list: -// "C:\foo\bar1" "C:\foo\bar2" -> "C:\foo\bar" -QTMANHATTANSTYLESHARED_EXPORT QString commonPrefix(const QStringList &strings); - -// Return the common path of a list of files: -// "C:\foo\bar1" "C:\foo\bar2" -> "C:\foo" -QTMANHATTANSTYLESHARED_EXPORT QString commonPath(const QStringList &files); - -// On Linux/Mac replace user's home path with ~ -// Uses cleaned path and tries to use absolute path of "path" if possible -// If path is not sub of home path, or when running on Windows, returns the input -QTMANHATTANSTYLESHARED_EXPORT QString withTildeHomePath(const QString &path); - -class QTMANHATTANSTYLESHARED_EXPORT AbstractMacroExpander { -public: - virtual ~AbstractMacroExpander() {} - // Not const, as it may change the state of the expander. - //! Find an expando to replace and provide a replacement string. - //! \param str The string to scan - //! \param pos Position to start scan on input, found position on output - //! \param ret Replacement string on output - //! \return Length of string part to replace, zero if no (further) matches found - virtual int findMacro(const QString &str, int *pos, QString *ret) = 0; -}; - -class QTMANHATTANSTYLESHARED_EXPORT AbstractQtcMacroExpander : public AbstractMacroExpander { -public: - virtual int findMacro(const QString &str, int *pos, QString *ret); - //! Provide a replacement string for an expando - //! \param name The name of the expando - //! \param ret Replacement string on output - //! \return True if the expando was found - virtual bool resolveMacro(const QString &name, QString *ret) = 0; -}; - -QTMANHATTANSTYLESHARED_EXPORT void expandMacros(QString *str, AbstractMacroExpander *mx); -QTMANHATTANSTYLESHARED_EXPORT QString expandMacros(const QString &str, AbstractMacroExpander *mx); - -} // namespace Manhattan - -#endif // SETTINGSTUTILS_H diff --git a/ThirdParty/GUI/qt-manhattan-style/styleanimator.cpp b/ThirdParty/GUI/qt-manhattan-style/styleanimator.cpp deleted file mode 100644 index 8ad1a783f547c523527d29ade4c5d51779fa018c..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/styleanimator.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "styleanimator.h" - -#include <QStyleOption> - -Animation * StyleAnimator::widgetAnimation(const QWidget *widget) const -{ - if (!widget) - return 0; - foreach (Animation *a, animations) { - if (a->widget() == widget) - return a; - } - return 0; -} - -void Animation::paint(QPainter *painter, const QStyleOption *option) -{ - Q_UNUSED(option) - Q_UNUSED(painter) -} - -void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) -{ - if (m_secondaryImage.isNull() || m_primaryImage.isNull()) - return; - - if (m_tempImage.isNull()) - m_tempImage = m_secondaryImage; - - const int a = qRound(alpha*256); - const int ia = 256 - a; - const int sw = m_primaryImage.width(); - const int sh = m_primaryImage.height(); - const int bpl = m_primaryImage.bytesPerLine(); - switch (m_primaryImage.depth()) { - case 32: - { - uchar *mixed_data = m_tempImage.bits(); - const uchar *back_data = m_primaryImage.bits(); - const uchar *front_data = m_secondaryImage.bits(); - for (int sy = 0; sy < sh; sy++) { - quint32 *mixed = (quint32*)mixed_data; - const quint32* back = (const quint32*)back_data; - const quint32* front = (const quint32*)front_data; - for (int sx = 0; sx < sw; sx++) { - quint32 bp = back[sx]; - quint32 fp = front[sx]; - mixed[sx] = qRgba ((qRed(bp)*ia + qRed(fp)*a)>>8, - (qGreen(bp)*ia + qGreen(fp)*a)>>8, - (qBlue(bp)*ia + qBlue(fp)*a)>>8, - (qAlpha(bp)*ia + qAlpha(fp)*a)>>8); - } - mixed_data += bpl; - back_data += bpl; - front_data += bpl; - } - } - default: - break; - } - painter->drawImage(rect, m_tempImage); -} - -void Transition::paint(QPainter *painter, const QStyleOption *option) -{ - float alpha = 1.0; - if (m_duration > 0) { - QTime current = QTime::currentTime(); - - if (m_startTime > current) - m_startTime = current; - - int timeDiff = m_startTime.msecsTo(current); - alpha = timeDiff/(float)m_duration; - if (timeDiff > m_duration) { - m_running = false; - alpha = 1.0; - } - } - else { - m_running = false; - } - drawBlendedImage(painter, option->rect, alpha); -} - -void StyleAnimator::timerEvent(QTimerEvent *) -{ - for (int i = animations.size() - 1 ; i >= 0 ; --i) { - if (animations[i]->widget()) - animations[i]->widget()->update(); - - if (!animations[i]->widget() || - !animations[i]->widget()->isEnabled() || - !animations[i]->widget()->isVisible() || - animations[i]->widget()->window()->isMinimized() || - !animations[i]->running()) - { - Animation *a = animations.takeAt(i); - delete a; - } - } - if (animations.size() == 0 && animationTimer.isActive()) { - animationTimer.stop(); - } -} - -void StyleAnimator::stopAnimation(const QWidget *w) -{ - for (int i = animations.size() - 1 ; i >= 0 ; --i) { - if (animations[i]->widget() == w) { - Animation *a = animations.takeAt(i); - delete a; - break; - } - } -} - -void StyleAnimator::startAnimation(Animation *t) -{ - stopAnimation(t->widget()); - animations.append(t); - if (animations.size() > 0 && !animationTimer.isActive()) { - animationTimer.start(35, this); - } -} diff --git a/ThirdParty/GUI/qt-manhattan-style/styleanimator.h b/ThirdParty/GUI/qt-manhattan-style/styleanimator.h deleted file mode 100644 index 08452c6f52109d2738276f2bff943a2e2d6e952f..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/styleanimator.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef ANIMATION_H -#define ANIMATION_H - -#include <QPointer> -#include <QTime> -#include <QBasicTimer> -#include <QStyle> -#include <QPainter> -#include <QWidget> - -/* - * This is a set of helper classes to allow for widget animations in - * the style. Its mostly taken from Vista style so it should be fully documented - * there. - * - */ - -class Animation -{ -public : - Animation() : m_running(true) { } - virtual ~Animation() { } - QWidget * widget() const { return m_widget; } - bool running() const { return m_running; } - const QTime &startTime() const { return m_startTime; } - void setRunning(bool val) { m_running = val; } - void setWidget(QWidget *widget) { m_widget = widget; } - void setStartTime(const QTime &startTime) { m_startTime = startTime; } - virtual void paint(QPainter *painter, const QStyleOption *option); - -protected: - void drawBlendedImage(QPainter *painter, QRect rect, float value); - QTime m_startTime; - QPointer<QWidget> m_widget; - QImage m_primaryImage; - QImage m_secondaryImage; - QImage m_tempImage; - bool m_running; -}; - -// Handles state transition animations -class Transition : public Animation -{ -public : - Transition() : Animation() {} - virtual ~Transition() {} - void setDuration(int duration) { m_duration = duration; } - void setStartImage(const QImage &image) { m_primaryImage = image; } - void setEndImage(const QImage &image) { m_secondaryImage = image; } - virtual void paint(QPainter *painter, const QStyleOption *option); - int duration() const { return m_duration; } - int m_duration; //set time in ms to complete a state transition -}; - -class StyleAnimator : public QObject -{ - Q_OBJECT - -public: - StyleAnimator(QObject *parent = 0) : QObject(parent) {} - - void timerEvent(QTimerEvent *); - void startAnimation(Animation *); - void stopAnimation(const QWidget *); - Animation* widgetAnimation(const QWidget *) const; - -private: - QBasicTimer animationTimer; - QList <Animation*> animations; -}; - -#endif // ANIMATION_H diff --git a/ThirdParty/GUI/qt-manhattan-style/styledbar.cpp b/ThirdParty/GUI/qt-manhattan-style/styledbar.cpp deleted file mode 100644 index de2e220667efc43b6b6b312af418aa7bfc72ce79..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/styledbar.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "styledbar.h" - -#include "stylehelper.h" - -#include <QVariant> -#include <QPainter> -#include <QPixmapCache> -#include <QStyle> -#include <QStyleOption> - -using namespace Manhattan; - -StyledBar::StyledBar(QWidget *parent) - : QWidget(parent) -{ - setProperty("panelwidget", true); - setProperty("panelwidget_singlerow", true); - setProperty("lightColored", false); -} - -void StyledBar::setSingleRow(bool singleRow) -{ - setProperty("panelwidget_singlerow", singleRow); -} - -bool StyledBar::isSingleRow() const -{ - return property("panelwidget_singlerow").toBool(); -} - -void StyledBar::setLightColored(bool lightColored) -{ - setProperty("lightColored", lightColored); -} - -bool StyledBar::isLightColored() const -{ - return property("lightColored").toBool(); -} - -void StyledBar::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event) - QPainter painter(this); - QStyleOption option; - option.rect = rect(); - option.state = QStyle::State_Horizontal; - style()->drawControl(QStyle::CE_ToolBar, &option, &painter, this); -} - -StyledSeparator::StyledSeparator(QWidget *parent) - : QWidget(parent) -{ - setFixedWidth(10); -} - -void StyledSeparator::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event) - QPainter painter(this); - QStyleOption option; - option.rect = rect(); - option.state = QStyle::State_Horizontal; - option.palette = palette(); - style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &option, &painter, this); -} diff --git a/ThirdParty/GUI/qt-manhattan-style/styledbar.h b/ThirdParty/GUI/qt-manhattan-style/styledbar.h deleted file mode 100644 index b273da77efc34ccfd9e056b57d6b16f844a266a1..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/styledbar.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef STYLEDBAR_H -#define STYLEDBAR_H - -#include "qt-manhattan-style_global.hpp" - -#include <QWidget> - -namespace Manhattan { - -class QTMANHATTANSTYLESHARED_EXPORT StyledBar : public QWidget -{ - Q_OBJECT -public: - StyledBar(QWidget *parent = 0); - void setSingleRow(bool singleRow); - bool isSingleRow() const; - - void setLightColored(bool lightColored); - bool isLightColored() const; - -protected: - void paintEvent(QPaintEvent *event); -}; - -class QTMANHATTANSTYLESHARED_EXPORT StyledSeparator : public QWidget -{ - Q_OBJECT -public: - StyledSeparator(QWidget *parent = 0); -protected: - void paintEvent(QPaintEvent *event); -}; - -} // Manhattan - -#endif // STYLEDBAR_H diff --git a/ThirdParty/GUI/qt-manhattan-style/stylehelper.cpp b/ThirdParty/GUI/qt-manhattan-style/stylehelper.cpp deleted file mode 100644 index 9f58355c96ad2917e3ca4367c0b06dbcfefe3b4d..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/stylehelper.cpp +++ /dev/null @@ -1,573 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "stylehelper.h" - -#include <QApplication> -#include <QObject> -#include <QPainter> -#include <QPalette> -#include <QPixmapCache> -#include <QRect> -#include <QStyleOption> -#include <QWidget> - -// Clamps float color values within (0, 255) -static int clamp(float x) -{ - const int val = x > 255 ? 255 : static_cast<int>(x); - return val < 0 ? 0 : val; -} - -// Clamps float color values within (0, 255) -/* -static int range(float x, int min, int max) -{ - int val = x > max ? max : x; - return val < min ? min : val; -} -*/ - -namespace Manhattan -{ -namespace Utils -{ - -QColor StyleHelper::mergedColors(const QColor& colorA, const QColor& colorB, int factor) -{ - const int maxFactor = 100; - QColor tmp = colorA; - tmp.setRed((tmp.red() * factor) / maxFactor - + (colorB.red() * (maxFactor - factor)) / maxFactor); - tmp.setGreen((tmp.green() * factor) / maxFactor - + (colorB.green() * (maxFactor - factor)) / maxFactor); - tmp.setBlue((tmp.blue() * factor) / maxFactor - + (colorB.blue() * (maxFactor - factor)) / maxFactor); - return tmp; -} - -qreal StyleHelper::sidebarFontSize() -{ -#if defined(Q_OS_MAC) - return 10; -#else - return 7.5; -#endif -} - -QPalette StyleHelper::sidebarFontPalette(const QPalette& original) -{ - QPalette palette = original; - palette.setColor(QPalette::Active, QPalette::Text, panelTextColor()); - palette.setColor(QPalette::Active, QPalette::WindowText, panelTextColor()); - palette.setColor(QPalette::Inactive, QPalette::Text, panelTextColor().darker()); - palette.setColor(QPalette::Inactive, QPalette::WindowText, panelTextColor().darker()); - return palette; -} - -QColor StyleHelper::panelTextColor(bool lightColored) -{ - // qApp->palette().highlightedText().color(); - if (!lightColored) - return Qt::white; - else - return Qt::black; -} - -// Invalid by default, setBaseColor needs to be called at least once -QColor StyleHelper::m_baseColor; -QColor StyleHelper::m_requestedBaseColor; -int StyleHelper::m_navigationWidgetHeight = 24; - -QColor StyleHelper::baseColor(bool lightColored) -{ - if (!lightColored) - return m_baseColor; - else - return m_baseColor.lighter(230); -} - -QColor StyleHelper::highlightColor(bool lightColored) -{ - QColor result = baseColor(lightColored); - if (!lightColored) - result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.16)); - else - result.setHsv(result.hue(), clamp(result.saturation()), clamp(result.value() * 1.06)); - return result; -} - -QColor StyleHelper::shadowColor(bool lightColored) -{ - QColor result = baseColor(lightColored); - result.setHsv(result.hue(), clamp(result.saturation() * 1.1), clamp(result.value() * 0.70)); - return result; -} - -QColor StyleHelper::borderColor(bool lightColored) -{ - QColor result = baseColor(lightColored); - result.setHsv(result.hue(), result.saturation(), result.value() / 2); - return result; -} - -// We try to ensure that the actual color used are within -// reasonalbe bounds while generating the actual baseColor -// from the users request. -void StyleHelper::setBaseColor(const QColor& newcolor) -{ - m_requestedBaseColor = newcolor; - - QColor color; - color.setHsv(newcolor.hue(), newcolor.saturation() * 0.7, 64 + newcolor.value() / 3); - - if (color.isValid() && color != m_baseColor) { - m_baseColor = color; - foreach (QWidget* w, QApplication::topLevelWidgets()) - w->update(); - } -} - -static void verticalGradientHelper(QPainter* p, const QRect& spanRect, const QRect& rect, - bool lightColored) -{ - QColor highlight = StyleHelper::highlightColor(lightColored); - QColor shadow = StyleHelper::shadowColor(lightColored); - QLinearGradient grad(spanRect.topRight(), spanRect.topLeft()); - grad.setColorAt(0, highlight.lighter(117)); - grad.setColorAt(1, shadow.darker(109)); - p->fillRect(rect, grad); - - QColor light(255, 255, 255, 80); - p->setPen(light); - p->drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0)); - QColor dark(0, 0, 0, 90); - p->setPen(dark); - p->drawLine(rect.topLeft(), rect.bottomLeft()); -} - -void StyleHelper::verticalGradient(QPainter* painter, const QRect& spanRect, const QRect& clipRect, - bool lightColored) -{ - if (StyleHelper::usePixmapCache()) { - QString key; - QColor keyColor = baseColor(lightColored); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - key = QString("mh_vertical %1 %2 %3 %4 %5") - .arg(spanRect.width(), spanRect.height(), clipRect.width(), clipRect.height(), - keyColor.rgb()); -#else - key.sprintf("mh_vertical %d %d %d %d %d", spanRect.width(), spanRect.height(), - clipRect.width(), clipRect.height(), keyColor.rgb()); -#endif - - QPixmap pixmap; -#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) - if (!QPixmapCache::find(key, &pixmap)) { -#else - if (!QPixmapCache::find(key, pixmap)) { -#endif - pixmap = QPixmap(clipRect.size()); - QPainter p(&pixmap); - QRect rect(0, 0, clipRect.width(), clipRect.height()); - verticalGradientHelper(&p, spanRect, rect, lightColored); - p.end(); - QPixmapCache::insert(key, pixmap); - } - - painter->drawPixmap(clipRect.topLeft(), pixmap); - } else { - verticalGradientHelper(painter, spanRect, clipRect, lightColored); - } -} - -static void horizontalGradientHelper(QPainter* p, const QRect& spanRect, const QRect& rect, - bool lightColored) -{ - if (lightColored) { - QLinearGradient shadowGradient(rect.topLeft(), rect.bottomLeft()); - shadowGradient.setColorAt(0, 0xf0f0f0); - shadowGradient.setColorAt(1, 0xcfcfcf); - p->fillRect(rect, shadowGradient); - return; - } - - QColor base = StyleHelper::baseColor(lightColored); - QColor highlight = StyleHelper::highlightColor(lightColored); - QColor shadow = StyleHelper::shadowColor(lightColored); - QLinearGradient grad(rect.topLeft(), rect.bottomLeft()); - grad.setColorAt(0, highlight.lighter(120)); - if (rect.height() == StyleHelper::navigationWidgetHeight()) { - grad.setColorAt(0.4, highlight); - grad.setColorAt(0.401, base); - } - grad.setColorAt(1, shadow); - p->fillRect(rect, grad); - - QLinearGradient shadowGradient(spanRect.topLeft(), spanRect.topRight()); - shadowGradient.setColorAt(0, QColor(0, 0, 0, 30)); - QColor lighterHighlight; - lighterHighlight = highlight.lighter(130); - lighterHighlight.setAlpha(100); - shadowGradient.setColorAt(0.7, lighterHighlight); - shadowGradient.setColorAt(1, QColor(0, 0, 0, 40)); - p->fillRect(rect, shadowGradient); -} - -void StyleHelper::horizontalGradient(QPainter* painter, const QRect& spanRect, - const QRect& clipRect, bool lightColored) -{ - if (StyleHelper::usePixmapCache()) { - QString key; - QColor keyColor = baseColor(lightColored); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - key.asprintf("mh_horizontal %d %d %d %d %d %d", spanRect.width(), spanRect.height(), - clipRect.width(), clipRect.height(), keyColor.rgb(), spanRect.x()); -#else - key.sprintf("mh_horizontal %d %d %d %d %d %d", spanRect.width(), spanRect.height(), - clipRect.width(), clipRect.height(), keyColor.rgb(), spanRect.x()); -#endif - - QPixmap pixmap; -#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) - if (!QPixmapCache::find(key, &pixmap)) { -#else - if (!QPixmapCache::find(key, pixmap)) { -#endif - pixmap = QPixmap(clipRect.size()); - QPainter p(&pixmap); - QRect rect = QRect(0, 0, clipRect.width(), clipRect.height()); - horizontalGradientHelper(&p, spanRect, rect, lightColored); - p.end(); - QPixmapCache::insert(key, pixmap); - } - - painter->drawPixmap(clipRect.topLeft(), pixmap); - - } else { - horizontalGradientHelper(painter, spanRect, clipRect, lightColored); - } -} - -static void menuGradientHelper(QPainter* p, const QRect& spanRect, const QRect& rect) -{ - QLinearGradient grad(spanRect.topLeft(), spanRect.bottomLeft()); - QColor menuColor = - StyleHelper::mergedColors(StyleHelper::baseColor(), QColor(244, 244, 244), 25); - grad.setColorAt(0, menuColor.lighter(112)); - grad.setColorAt(1, menuColor); - p->fillRect(rect, grad); -} - -void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter* painter, - const QStyleOption* option) -{ - // From windowsstyle but modified to enable AA - if (option->rect.width() <= 1 || option->rect.height() <= 1) - return; - - QRect r = option->rect; - int size = qMin(r.height(), r.width()); - QPixmap pixmap; - QString pixmapName; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - pixmapName.asprintf("arrow-%s-%d-%d-%d-%lld", "$qt_ia", uint(option->state), element, size, - option->palette.cacheKey()); -#else - pixmapName.sprintf("arrow-%s-%d-%d-%d-%lld", "$qt_ia", uint(option->state), element, size, - option->palette.cacheKey()); -#endif - -#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) - if (!QPixmapCache::find(pixmapName, &pixmap)) { -#else - if (!QPixmapCache::find(pixmapName, pixmap)) { -#endif - int border = size / 5; - int sqsize = 2 * (size / 2); - QImage image(sqsize, sqsize, QImage::Format_ARGB32); - image.fill(Qt::transparent); - QPainter imagePainter(&image); - imagePainter.setRenderHint(QPainter::Antialiasing, true); - imagePainter.translate(0.5, 0.5); - QPolygon a; - switch (element) { - case QStyle::PE_IndicatorArrowUp: - a.setPoints(3, border, sqsize / 2, sqsize / 2, border, sqsize - border, sqsize / 2); - break; - case QStyle::PE_IndicatorArrowDown: - a.setPoints(3, border, sqsize / 2, sqsize / 2, sqsize - border, sqsize - border, - sqsize / 2); - break; - case QStyle::PE_IndicatorArrowRight: - a.setPoints(3, sqsize - border, sqsize / 2, sqsize / 2, border, sqsize / 2, - sqsize - border); - break; - case QStyle::PE_IndicatorArrowLeft: - a.setPoints(3, border, sqsize / 2, sqsize / 2, border, sqsize / 2, sqsize - border); - break; - default: - break; - } - - int bsx = 0; - int bsy = 0; - - if (option->state & QStyle::State_Sunken) { - bsx = qApp->style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal); - bsy = qApp->style()->pixelMetric(QStyle::PM_ButtonShiftVertical); - } - - QRect bounds = a.boundingRect(); - int sx = sqsize / 2 - bounds.center().x() - 1; - int sy = sqsize / 2 - bounds.center().y() - 1; - imagePainter.translate(sx + bsx, sy + bsy); - - if (!(option->state & QStyle::State_Enabled)) { - imagePainter.setBrush(option->palette.mid().color()); - imagePainter.setPen(option->palette.mid().color()); - } else { - QColor shadow(0, 0, 0, 100); - imagePainter.translate(0, 1); - imagePainter.setPen(shadow); - imagePainter.setBrush(shadow); - QColor foreGround(255, 255, 255, 210); - imagePainter.drawPolygon(a); - imagePainter.translate(0, -1); - imagePainter.setPen(foreGround); - imagePainter.setBrush(foreGround); - } - imagePainter.drawPolygon(a); - imagePainter.end(); - pixmap = QPixmap::fromImage(image); - QPixmapCache::insert(pixmapName, pixmap); - } - int xOffset = r.x() + (r.width() - size) / 2; - int yOffset = r.y() + (r.height() - size) / 2; - painter->drawPixmap(xOffset, yOffset, pixmap); -} - -void StyleHelper::menuGradient(QPainter* painter, const QRect& spanRect, const QRect& clipRect) -{ - if (StyleHelper::usePixmapCache()) { - QString key; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - key.asprintf("mh_menu %d %d %d %d %d", spanRect.width(), spanRect.height(), - clipRect.width(), clipRect.height(), StyleHelper::baseColor().rgb()); -#else - key.sprintf("mh_menu %d %d %d %d %d", spanRect.width(), spanRect.height(), clipRect.width(), - clipRect.height(), StyleHelper::baseColor().rgb()); -#endif - - QPixmap pixmap; -#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) - if (!QPixmapCache::find(key, &pixmap)) { -#else - if (!QPixmapCache::find(key, pixmap)) { -#endif - pixmap = QPixmap(clipRect.size()); - QPainter p(&pixmap); - QRect rect = QRect(0, 0, clipRect.width(), clipRect.height()); - menuGradientHelper(&p, spanRect, rect); - p.end(); - QPixmapCache::insert(key, pixmap); - } - - painter->drawPixmap(clipRect.topLeft(), pixmap); - } else { - menuGradientHelper(painter, spanRect, clipRect); - } -} - -// Draws a cached pixmap with shadow -// Draws a cached pixmap with shadow -void StyleHelper::drawIconWithShadow(const QIcon& icon, const QRect& rect, QPainter* p, - QIcon::Mode iconMode, int dipRadius, const QColor& color, - const QPoint& dipOffset) -{ - QPixmap cache; - const int devicePixelRatio = p->device()->devicePixelRatio(); - QString pixmapName = QString::fromLatin1("icon %0 %1 %2 %3") - .arg(icon.cacheKey()) - .arg(iconMode) - .arg(rect.height()) - .arg(devicePixelRatio); - - if (!QPixmapCache::find(pixmapName, &cache)) { - // High-dpi support: The in parameters (rect, radius, offset) are in - // device-independent pixels. The call to QIcon::pixmap() below might - // return a high-dpi pixmap, which will in that case have a devicePixelRatio - // different than 1. The shadow drawing caluculations are done in device - // pixels. - QWindow* window = dynamic_cast<QWidget*>(p->device())->window()->windowHandle(); - QPixmap px = icon.pixmap(window, rect.size(), iconMode); - int radius = dipRadius * devicePixelRatio; - QPoint offset = dipOffset * devicePixelRatio; - cache = QPixmap(px.size() + QSize(radius * 2, radius * 2)); - cache.fill(Qt::transparent); - - QPainter cachePainter(&cache); - // Draw shadow - QImage tmp(px.size() + QSize(radius * 2, radius * 2 + 1), - QImage::Format_ARGB32_Premultiplied); - tmp.fill(Qt::transparent); - - QPainter tmpPainter(&tmp); - tmpPainter.setCompositionMode(QPainter::CompositionMode_Source); - tmpPainter.drawPixmap(QRect(radius, radius, px.width(), px.height()), px); - tmpPainter.end(); - - // blur the alpha channel - QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied); - blurred.fill(Qt::transparent); - QPainter blurPainter(&blurred); - qt_blurImage(&blurPainter, tmp, radius, false, true); - blurPainter.end(); - - tmp = blurred; - - // blacken the image... - tmpPainter.begin(&tmp); - tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); - tmpPainter.fillRect(tmp.rect(), color); - tmpPainter.end(); - - tmpPainter.begin(&tmp); - tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn); - tmpPainter.fillRect(tmp.rect(), color); - tmpPainter.end(); - - // draw the blurred drop shadow... - // cachePainter.drawImage(QRect(0, 0, cache.rect().width(), cache.rect().height()), - // tmp); - - // Draw the actual pixmap... -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) - int space = p->fontMetrics().horizontalAdvance('M') * 0.05; -#else - int space = p->fontMetrics().width('M') * 0.05; -#endif - - cachePainter.drawPixmap( - QRect(QPoint(radius, radius) + offset, QSize(px.width(), px.height())) - .marginsRemoved(QMargins(space, space, space, space)), - px); - cachePainter.end(); - cache.setDevicePixelRatio(devicePixelRatio); - QPixmapCache::insert(pixmapName, cache); - } - - QRect targetRect = cache.rect(); - targetRect.setSize(targetRect.size() / cache.devicePixelRatio()); - targetRect.moveCenter(rect.center() - dipOffset); - p->drawPixmap(targetRect, cache); -} - -// Draws a CSS-like border image where the defined borders are not stretched -void StyleHelper::drawCornerImage(const QImage& img, QPainter* painter, QRect rect, int left, - int top, int right, int bottom) -{ - QSize size = img.size(); - if (top > 0) { // top - painter->drawImage(QRect(rect.left() + left, rect.top(), rect.width() - right - left, top), - img, QRect(left, 0, size.width() - right - left, top)); - if (left > 0) // top-left - painter->drawImage(QRect(rect.left(), rect.top(), left, top), img, - QRect(0, 0, left, top)); - if (right > 0) // top-right - painter->drawImage(QRect(rect.left() + rect.width() - right, rect.top(), right, top), - img, QRect(size.width() - right, 0, right, top)); - } - // left - if (left > 0) - painter->drawImage(QRect(rect.left(), rect.top() + top, left, rect.height() - top - bottom), - img, QRect(0, top, left, size.height() - bottom - top)); - // center - painter->drawImage(QRect(rect.left() + left, rect.top() + top, rect.width() - right - left, - rect.height() - bottom - top), - img, - QRect(left, top, size.width() - right - left, size.height() - bottom - top)); - if (right > 0) // right - painter->drawImage(QRect(rect.left() + rect.width() - right, rect.top() + top, right, - rect.height() - top - bottom), - img, - QRect(size.width() - right, top, right, size.height() - bottom - top)); - if (bottom > 0) { // bottom - painter->drawImage( - QRect(rect.left() + left, rect.top() + rect.height() - bottom, - rect.width() - right - left, bottom), - img, QRect(left, size.height() - bottom, size.width() - right - left, bottom)); - if (left > 0) // bottom-left - painter->drawImage( - QRect(rect.left(), rect.top() + rect.height() - bottom, left, bottom), img, - QRect(0, size.height() - bottom, left, bottom)); - if (right > 0) // bottom-right - painter->drawImage(QRect(rect.left() + rect.width() - right, - rect.top() + rect.height() - bottom, right, bottom), - img, - QRect(size.width() - right, size.height() - bottom, right, bottom)); - } -} - -// Tints an image with tintColor, while preserving alpha and lightness -void StyleHelper::tintImage(QImage& img, const QColor& tintColor) -{ - QPainter p(&img); - p.setCompositionMode(QPainter::CompositionMode_Screen); - - for (int x = 0; x < img.width(); ++x) { - for (int y = 0; y < img.height(); ++y) { - QRgb rgbColor = img.pixel(x, y); - int alpha = qAlpha(rgbColor); - QColor c = QColor(rgbColor); - - if (alpha > 0) { - c.toHsl(); - qreal l = c.lightnessF(); - QColor newColor = - QColor::fromHslF(tintColor.hslHueF(), tintColor.hslSaturationF(), l); - newColor.setAlpha(alpha); - img.setPixel(x, y, newColor.rgba()); - } - } - } -} - -int StyleHelper::navigationWidgetHeight() -{ - return m_navigationWidgetHeight; -} - -void StyleHelper::setNavigationWidgetHeight(int height) -{ - m_navigationWidgetHeight = height; -} - -} // namespace Utils -} // namespace Manhattan diff --git a/ThirdParty/GUI/qt-manhattan-style/stylehelper.h b/ThirdParty/GUI/qt-manhattan-style/stylehelper.h deleted file mode 100644 index 19745dd7f5e69742daa53722cf6c71693f1a6977..0000000000000000000000000000000000000000 --- a/ThirdParty/GUI/qt-manhattan-style/stylehelper.h +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef STYLEHELPER_H -#define STYLEHELPER_H - -#include "qt-manhattan-style_global.hpp" - -#include <QColor> -#include <QStyle> - -QT_BEGIN_NAMESPACE -class QPalette; -class QPainter; -class QRect; -// Note, this is exported but in a private header as qtopengl depends on it. -// We should consider adding this as a public helper function. -void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); -QT_END_NAMESPACE - -// Helper class holding all custom color values - -namespace Manhattan { -namespace Utils { -class QTMANHATTANSTYLESHARED_EXPORT StyleHelper -{ -public: - static const unsigned int DEFAULT_BASE_COLOR = 0x666666; - - // Height of the project explorer navigation bar - static int navigationWidgetHeight(); - static void setNavigationWidgetHeight(int height); - static qreal sidebarFontSize(); - static QPalette sidebarFontPalette(const QPalette &original); - - // This is our color table, all colors derive from baseColor - static QColor requestedBaseColor() { return m_requestedBaseColor; } - static QColor baseColor(bool lightColored = false); - static QColor panelTextColor(bool lightColored = false); - static QColor highlightColor(bool lightColored = false); - static QColor shadowColor(bool lightColored = false); - static QColor borderColor(bool lightColored = false); - static QColor buttonTextColor() { return QColor(0x4c4c4c); } - static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50); - - static QColor sidebarHighlight() { return QColor(255, 255, 255, 40); } - static QColor sidebarShadow() { return QColor(0, 0, 0, 40); } - - // Sets the base color and makes sure all top level widgets are updated - static void setBaseColor(const QColor &color); - - // Draws a shaded anti-aliased arrow - static void drawArrow(QStyle::PrimitiveElement element, QPainter *painter, const QStyleOption *option); - - // Gradients used for panels - static void horizontalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false); - static void verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored = false); - static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect); - static bool usePixmapCache() { return true; } - - static void drawIconWithShadow(const QIcon &icon, const QRect &rect, QPainter *p, QIcon::Mode iconMode, - int radius = 3, const QColor &color = QColor(0, 0, 0, 130), - const QPoint &offset = QPoint(1, -2)); - static void drawCornerImage(const QImage &img, QPainter *painter, QRect rect, - int left = 0, int top = 0, int right = 0, int bottom = 0); - - static void tintImage(QImage &img, const QColor &tintColor); - -private: - static QColor m_baseColor; - static QColor m_requestedBaseColor; - static int m_navigationWidgetHeight; -}; - -} // namespace Utils -} // namespace Manhattan -#endif // STYLEHELPER_H