File indexing completed on 2023-09-24 04:14:57

0001 /*
0002     SPDX-FileCopyrightText: 2005 Aaron Seigo <aseigo@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef PLASMA_DEFS_H
0008 #define PLASMA_DEFS_H
0009 
0010 /** @header plasma/plasma.h <Plasma/Plasma> */
0011 
0012 #include <QObject>
0013 
0014 #include <plasma/plasma_export.h>
0015 
0016 class QAction;
0017 
0018 /**
0019  * Namespace for everything in libplasma
0020  */
0021 namespace Plasma
0022 {
0023 /**
0024  * @class Types plasma/plasma.h <Plasma/Plasma>
0025  * @short Enums and constants used in Plasma
0026  *
0027  */
0028 class PLASMA_EXPORT Types : public QObject
0029 {
0030     Q_OBJECT
0031 
0032 public:
0033     ~Types() override;
0034     /**
0035      * The Constraint enumeration lists the various constraints that Plasma
0036      * objects have managed for them and which they may wish to react to,
0037      * for instance in Applet::constraintsUpdated
0038      */
0039     enum Constraint {
0040         NoConstraint = 0, /**< No constraint; never passed in to Applet::constraintsEvent on its own */
0041         FormFactorConstraint = 1, /**< The FormFactor for an object */
0042         LocationConstraint = 2, /**< The Location of an object */
0043         ScreenConstraint = 4, /**< Which screen an object is on */
0044         ImmutableConstraint = 8, /**< the immutability (locked) nature of the applet changed  */
0045         StartupCompletedConstraint = 16, /**< application startup has completed */
0046         ContextConstraint = 32, /**< the context (e.g. activity) has changed */
0047         UiReadyConstraint = 64,
0048         /**< The ui has been completely loaded */ // (FIXME: merged with StartupCompletedConstraint?)
0049         AllConstraints = FormFactorConstraint | LocationConstraint | ScreenConstraint | ImmutableConstraint,
0050     };
0051     Q_ENUM(Constraint)
0052     Q_DECLARE_FLAGS(Constraints, Constraint)
0053 
0054     /**
0055      * This enumeration lists the various hints that an applet can pass to its
0056      * constraint regarding the way that it is represented
0057      */
0058     enum ConstraintHints { // TODO KF6 ConstraintHints -> ConstraintHint
0059         NoHint = 0,
0060         CanFillArea = 1,
0061         /**< The CompactRepresentation can fill the area and ignore constraint margins*/ // (TODO: KF6 CanFillArea -> CompactRepresentationFillArea)
0062         MarginAreasSeparator = CanFillArea | 2, /**< The applet acts as a separator between the standard and slim panel margin areas*/
0063     };
0064     Q_DECLARE_FLAGS(ConstraintFlags, ConstraintHints)
0065     Q_FLAG(ConstraintFlags)
0066 
0067     /**
0068      * The FormFactor enumeration describes how a Plasma::Applet should arrange
0069      * itself. The value is derived from the container managing the Applet
0070      * (e.g. in Plasma, a Corona on the desktop or on a panel).
0071      **/
0072     enum FormFactor {
0073         Planar = 0, /**< The applet lives in a plane and has two
0074                    degrees of freedom to grow. Optimize for
0075                    desktop, laptop or tablet usage: a high
0076                    resolution screen 1-3 feet distant from the
0077                    viewer. */
0078         MediaCenter, /**< As with Planar, the applet lives in a plane
0079                     but the interface should be optimized for
0080                     medium-to-high resolution screens that are
0081                     5-15 feet distant from the viewer. Sometimes
0082                     referred to as a "ten foot interface".*/
0083         Horizontal, /**< The applet is constrained vertically, but
0084                    can expand horizontally. */
0085         Vertical, /**< The applet is constrained horizontally, but
0086                 can expand vertically. */
0087         Application, /**< The Applet lives in a plane and should be optimized to look as a full application,
0088                      for the desktop or the particular device. */
0089     };
0090     Q_ENUM(FormFactor)
0091 
0092     /**
0093      * Display hints that come from the containment that suggest the applet how to look and behave.
0094      * @since 5.77
0095      */
0096     enum ContainmentDisplayHint {
0097         NoContainmentDisplayHint = 0,
0098         ContainmentDrawsPlasmoidHeading =
0099             1, /**< The containment will draw an titlebar-looking header for the applets, so the applets shouldn't attempt to paint a similar thing **/
0100         ContainmentForcesSquarePlasmoids =
0101             2, /**< The containment will force every plasmoid to be constrained in a square icon (An example is the System Tray)**/
0102         DesktopFullyCovered =
0103             4, /**< The desktop area for the contaiment's screen is not visible at all, for instance a window has been maximized on top of it */
0104     };
0105     Q_ENUM(ContainmentDisplayHint)
0106     Q_DECLARE_FLAGS(ContainmentDisplayHints, ContainmentDisplayHint)
0107     Q_FLAG(ContainmentDisplayHints)
0108 
0109     /**
0110      * This enumeration describes the type of the Containment.
0111      * DesktopContainments represent main containments that will own a screen in a mutually exclusive fashion,
0112      * while PanelContainments are accessories which can be present multiple per screen.
0113      */
0114     enum ContainmentType {
0115         NoContainmentType = -1, /**< @internal */
0116         DesktopContainment = 0, /**< A desktop containment */
0117         PanelContainment, /**< A desktop panel */
0118 
0119         CustomContainment = 127, /**< A containment that is neither a desktop nor a panel
0120                                 but something application specific */
0121         CustomPanelContainment = 128, /**< A customized desktop panel */
0122         CustomEmbeddedContainment = 129, /**< A customized containment embedded in another applet */
0123     };
0124     Q_ENUM(ContainmentType)
0125 
0126     /**
0127      * A descriptive type for QActions, to help categorizing them when presented to the user
0128      */
0129     enum ActionType {
0130         AddAction = 0, /**< The action will cause something new being created*/
0131         ConfigureAction = 100, /**< The Action will make some kind of configuration ui to appear */
0132         ControlAction = 200, /**< Generic control, similar to ConfigureAction TODO: better doc */
0133         MiscAction = 300, /**< A type of action that doesn't fit in the other categories */
0134         DestructiveAction =
0135             400, /**< A dangerous action, such as deletion of objects, plasmoids and files. They are intended to be shown separated from other actions */
0136         UserAction = DestructiveAction + 1000, /**< If new types are needed in a C++ implementation, define them as ids more than  UserAction*/
0137     };
0138     Q_ENUM(ActionType)
0139 
0140     /**
0141      * The Direction enumeration describes in which direction, relative to the
0142      * Applet (and its managing container), popup menus, expanders, balloons,
0143      * message boxes, arrows and other such visually associated widgets should
0144      * appear in. This is usually the opposite of the Location.
0145      **/
0146     enum Direction {
0147         Down = 0, /**< Display downards */
0148         Up, /**< Display upwards */
0149         Left, /**< Display to the left */
0150         Right, /**< Display to the right */
0151     };
0152     Q_ENUM(Direction)
0153 
0154     /**
0155      * The Location enumeration describes where on screen an element, such as an
0156      * Applet or its managing container, is positioned on the screen.
0157      **/
0158     enum Location {
0159         Floating = 0, /**< Free floating. Neither geometry or z-ordering
0160                      is described precisely by this value. */
0161         Desktop, /**< On the planar desktop layer, extending across
0162                 the full screen from edge to edge */
0163         FullScreen, /**< Full screen */
0164         TopEdge, /**< Along the top of the screen*/
0165         BottomEdge, /**< Along the bottom of the screen*/
0166         LeftEdge, /**< Along the left side of the screen */
0167         RightEdge, /**< Along the right side of the screen */
0168     };
0169     Q_ENUM(Location)
0170 
0171     /**
0172      * The position enumeration
0173      *
0174      **/
0175     enum Position {
0176         LeftPositioned, /**< Positioned left */
0177         RightPositioned, /**< Positioned right */
0178         TopPositioned, /**< Positioned top */
0179         BottomPositioned, /**< Positioned bottom */
0180         CenterPositioned, /**< Positioned in the center */
0181     };
0182     Q_ENUM(Position)
0183 
0184     /**
0185      * The popup position enumeration relatively to his attached widget
0186      *
0187      **/
0188     enum PopupPlacement {
0189         FloatingPopup = 0, /**< Free floating, non attached popup */
0190         TopPosedLeftAlignedPopup, /**< Popup positioned on the top, aligned
0191                                  to the left of the widget */
0192         TopPosedRightAlignedPopup, /**< Popup positioned on the top, aligned
0193                                   to the right of the widget */
0194         LeftPosedTopAlignedPopup, /**< Popup positioned on the left, aligned
0195                                  to the top of the widget */
0196         LeftPosedBottomAlignedPopup, /**< Popup positioned on the left, aligned
0197                                     to the bottom of the widget */
0198         BottomPosedLeftAlignedPopup, /**< Popup positioned on the bottom, aligned
0199                                     to the left of the widget */
0200         BottomPosedRightAlignedPopup, /**< Popup positioned on the bottom, aligned
0201                                      to the right of the widget */
0202         RightPosedTopAlignedPopup, /**< Popup positioned on the right, aligned
0203                                   to the top of the widget */
0204         RightPosedBottomAlignedPopup, /**< Popup positioned on the right, aligned
0205                                     to the bottom of the widget */
0206     };
0207     Q_ENUM(PopupPlacement)
0208 
0209     /**
0210      * Flip enumeration
0211      */
0212     enum FlipDirection {
0213         NoFlip = 0, /**< Do not flip */
0214         HorizontalFlip = 1, /**< Flip horizontally */
0215         VerticalFlip = 2, /**< Flip vertically */
0216     };
0217     Q_ENUM(FlipDirection)
0218     Q_DECLARE_FLAGS(Flip, FlipDirection)
0219 
0220     /**
0221      * Possible timing alignments
0222      **/
0223     enum IntervalAlignment {
0224         NoAlignment = 0, /**< No alignment **/
0225         AlignToMinute, /**< Align to the minute **/
0226         AlignToHour, /**< Align to the hour **/
0227     };
0228     Q_ENUM(IntervalAlignment)
0229 
0230     /**
0231      * Defines the immutability of items like applets, corona and containments
0232      * they can be free to modify, locked down by the user or locked down by the
0233      * system (e.g. kiosk setups).
0234      */
0235     enum ImmutabilityType {
0236         Mutable = 1, /**< The item can be modified in any way **/
0237         UserImmutable = 2, /**< The user has requested a lock down, and can undo
0238                           the lock down at any time **/
0239         SystemImmutable = 4, /**<  the item is locked down by the system, the user
0240                            can't unlock it **/
0241     };
0242     Q_ENUM(ImmutabilityType)
0243 
0244     /**
0245      * The ComonentType enumeration refers to the various types of components,
0246      * or plugins, supported by plasma.
0247      */
0248     enum ComponentType {
0249         AppletComponent = 1, /**< Plasma::Applet based plugins **/
0250         DataEngineComponent = 2, /**< Plasma::DataEngine based plugins **/
0251         ContainmentComponent = 4, /**< Plasma::Containment based plugins **/
0252         WallpaperComponent = 8, /**< Plasma::Wallpaper based plugins **/
0253         GenericComponent = 16, /** Generic repositories of files, usually they keep QML files and their assets **/
0254     };
0255     Q_ENUM(ComponentType)
0256     Q_DECLARE_FLAGS(ComponentTypes, ComponentType)
0257 
0258     enum MarginEdge {
0259         TopMargin = 0, /**< The top margin **/
0260         BottomMargin, /**< The bottom margin **/
0261         LeftMargin, /**< The left margin **/
0262         RightMargin, /**< The right margin **/
0263     };
0264     Q_ENUM(MarginEdge)
0265 
0266     /**
0267      * Status of an applet
0268      * @since 4.3
0269      */
0270     enum ItemStatus {
0271         UnknownStatus = 0, /**< The status is unknown **/
0272         PassiveStatus = 1, /**< The Item is passive **/
0273         ActiveStatus = 2, /**< The Item is active **/
0274         NeedsAttentionStatus = 3, /**< The Item needs attention **/
0275         RequiresAttentionStatus = 4, /**< The Item needs persistent attention **/
0276         AcceptingInputStatus = 5, /**< The Item is accepting input **/
0277         // FIXME KF6: this should be the smallest status
0278         HiddenStatus = 6, /**< The Item will be hidden totally  **/
0279     };
0280     Q_ENUM(ItemStatus)
0281 
0282     enum TrustLevel {
0283         UnverifiableTrust = 0, /**< The trust of the object can not be verified, usually because no
0284                                 trust information (e.g. a cryptographic signature) was provided */
0285         CompletelyUntrusted, /**< The signature is broken/expired/false */
0286         UnknownTrusted, /**< The signature is valid, but the key is unknown */
0287         UserTrusted, /**< The signature is valid and made with a key signed by one of the
0288                       user's own keys*/
0289         SelfTrusted, /**< The signature is valid and made with one of the user's own keys*/
0290         FullyTrusted, /**< The signature is valid and made with a key signed by the vendor's key*/
0291         UltimatelyTrusted, /**< The signature is valid and made with the vendor's key*/
0292     };
0293     Q_ENUM(TrustLevel)
0294 
0295     /**
0296      * Description on how draw a background for the applet
0297      */
0298     enum BackgroundHints {
0299         NoBackground = 0, /**< Not drawing a background under the applet, the applet has its own implementation */
0300         StandardBackground = 1, /**< The standard background from the theme is drawn */
0301         TranslucentBackground = 2, /**< An alternate version of the background is drawn, usually more translucent */
0302         ShadowBackground = 4, /**< The applet won't have a svg background but a drop shadow of its content done via a shader */
0303         ConfigurableBackground = 8, /** If the hint has this flag, the user is able to configure this background */
0304         DefaultBackground = StandardBackground, /**< Default settings: both standard background */
0305     };
0306     Q_ENUM(BackgroundHints)
0307     // TODO KF6: BackgroundHint and BackgroundHints
0308     Q_DECLARE_FLAGS(BackgroundFlags, BackgroundHints)
0309 
0310 private:
0311     Types(QObject *parent = nullptr);
0312 };
0313 
0314 /**
0315  * Converts a location to a direction. Handy for figuring out which way to send a popup based on
0316  * location or to point arrows and other directional items.
0317  *
0318  * @param location the location of the container the element will appear in
0319  * @return the visual direction the element should be oriented in
0320  **/
0321 PLASMA_EXPORT Types::Direction locationToDirection(Types::Location location);
0322 
0323 /**
0324  * Converts a location to the direction facing it. Handy for figuring out which way to collapse
0325  * a popup or to point arrows at the item itself.
0326  *
0327  * @param location the location of the container the element will appear in
0328  * @return the visual direction the element should be oriented in
0329  **/
0330 PLASMA_EXPORT Types::Direction locationToInverseDirection(Types::Location location);
0331 
0332 /**
0333  * Mirrors popup placement horizontally in Right-To-Left environments.
0334  *
0335  * Mirroring behavior can be explicitly overridden by passing a specific
0336  * direction with layoutDirection parameter, or left at default value of
0337  * Qt::LayoutDirectionAuto, in which case it will be deduced from shared
0338  * QGuiApplication instance.
0339  **/
0340 PLASMA_EXPORT Types::PopupPlacement visualPopupPlacement(Types::PopupPlacement placement, Qt::LayoutDirection layoutDirection = Qt::LayoutDirectionAuto);
0341 
0342 Q_DECLARE_OPERATORS_FOR_FLAGS(Types::ContainmentDisplayHints)
0343 Q_DECLARE_OPERATORS_FOR_FLAGS(Types::Constraints)
0344 Q_DECLARE_OPERATORS_FOR_FLAGS(Types::ConstraintFlags)
0345 Q_DECLARE_OPERATORS_FOR_FLAGS(Types::Flip)
0346 Q_DECLARE_OPERATORS_FOR_FLAGS(Types::ComponentTypes)
0347 Q_DECLARE_OPERATORS_FOR_FLAGS(Types::BackgroundFlags)
0348 
0349 } // Plasma namespace
0350 
0351 #endif // multiple inclusion guard