/** * @RDE_HEADER@ * ComboBox, optimized for tablets (bigger dropdown/popup and more comfortable completer) * $Id$ * $HeadURL$ * $Author$ * * Created by Mike Wille, SLSE, 2016-03-09 */ #pragma once #include "lts_widgets_export.h" #include namespace LtsWidgets { /** * @brief The LtsComboBox class provides an almost identically version of the QComboBox, with the main difference that this version is more touch friendly. * The LtsComboBox's Popup (LtsComboBoxPopup) is a LtsFramelessDialog (screen-centered) with bigger selection-items. * For debug purpose: press CTRL while clicking on the popup-button to open the original QComboBox-Popup */ class LTSWIDGETS_EXPORT LtsComboBox : public QComboBox // TODO: change title of selection window { Q_OBJECT using BaseClass = QComboBox; public: explicit LtsComboBox(QWidget *parent = nullptr); ~LtsComboBox() = default; /** * @brief Set the default widget to use - either the default QComboBox or the selection widget * @param bUseSelectionDialog true if the selection widget should be used, false for the normal combobox */ static void setUseSelectionDialog(bool bUseSelectionDialog); /** * @brief hasValueChanged tells if the value set by default (initialization) or by the user to another value, * different by the default value. If the user sets the value back to the default value, 'hasValueChanged' will return false again. * Use this in your UiRequirement to see if value differs from the default value to determine a change. * @return true if value differs from default value and v.v. */ bool hasValueChanged() const; void setExternalContentType(int ect) { m_externalContentType = ect; } int externalContentType() const { return m_externalContentType; } protected: /** * @brief showPopup is emited by the native widget when the popup should be triggered (e.g. by clicking a non-writeable LtsComboBox or by clicking the popup-button) and shows an touch-friendly, screen-centered LtsComboBoxPopup */ void showPopup() override; void showEvent(QShowEvent *e) override; void enterEvent(QEvent *e) override; void leaveEvent(QEvent *) override; protected slots: void userChangedIndex(int index); // user change - for 'hasValueChanged' signals: void signalExternallyChanged(); // e.g. PPM's parties changed, ComboBox should report to PpmComboBox for a refill void signalRefill(); // outgoing void signalEnterEvent(); void signalLeaveEvent(); private: int m_currentIndex; int m_externalContentType; static bool s_useSelectionDialog; }; }