home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kglobalsettings.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  17.0 KB  |  567 lines

  1. /* This file is part of the KDE libraries
  2.    Copyright (C) 2000 David Faure <faure@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License version 2 as published by the Free Software Foundation.
  7.  
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU Library General Public License
  14.    along with this library; see the file COPYING.LIB.  If not, write to
  15.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16.    Boston, MA 02110-1301, USA.
  17. */
  18. #ifndef _KGLOBALSETTINGS_H
  19. #define _KGLOBALSETTINGS_H
  20.  
  21. #include <qstring.h>
  22. #include <qcolor.h>
  23. #include <qfont.h>
  24. #include "kdelibs_export.h"
  25.  
  26. #define KDE_DEFAULT_SINGLECLICK true
  27. #define KDE_DEFAULT_INSERTTEAROFFHANDLES 0
  28. #define KDE_DEFAULT_AUTOSELECTDELAY -1
  29. #define KDE_DEFAULT_CHANGECURSOR true
  30. #define KDE_DEFAULT_LARGE_CURSOR false
  31. #define KDE_DEFAULT_VISUAL_ACTIVATE true
  32. #define KDE_DEFAULT_VISUAL_ACTIVATE_SPEED 50
  33. #define KDE_DEFAULT_WHEEL_ZOOM false
  34. #define KDE_DEFAULT_ICON_ON_PUSHBUTTON false
  35. #define KDE_DEFAULT_OPAQUE_RESIZE true
  36. #define KDE_DEFAULT_BUTTON_LAYOUT 0
  37. #define KDE_DEFAULT_SHADE_SORT_COLUMN true
  38.  
  39. class KURL;
  40.  
  41. /**
  42.  * Access the KDE global configuration.
  43.  *
  44.  * @author David Faure <faure@kde.org>
  45.  */
  46. class KDECORE_EXPORT KGlobalSettings
  47. {
  48.   public:
  49.  
  50.     /**
  51.      * Returns a threshold in pixels for drag & drop operations.
  52.      * As long as the mouse movement has not exceeded this number
  53.      * of pixels in either X or Y direction no drag operation may
  54.      * be started. This prevents spurious drags when the user intended
  55.      * to click on something but moved the mouse a bit while doing so.
  56.      *
  57.      * For this to work you must save the position of the mouse (oldPos)
  58.      * in the QWidget::mousePressEvent().
  59.      * When the position of the mouse (newPos)
  60.      * in a QWidget::mouseMoveEvent() exceeds this threshold
  61.      * you may start a drag
  62.      * which should originate from oldPos.
  63.      *
  64.      * Example code:
  65.      * \code
  66.      * void KColorCells::mousePressEvent( QMouseEvent *e )
  67.      * {
  68.      *    mOldPos = e->pos();
  69.      * }
  70.      *
  71.      * void KColorCells::mouseMoveEvent( QMouseEvent *e )
  72.      * {
  73.      *    if( !(e->state() && LeftButton)) return;
  74.      *
  75.      *    int delay = KGlobalSettings::dndEventDelay();
  76.      *    QPoint newPos = e->pos();
  77.      *    if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay ||
  78.      *       newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay)
  79.      *    {
  80.      *       // Drag color object
  81.      *       int cell = posToCell(mOldPos); // Find color at mOldPos
  82.      *       if ((cell != -1) && colors[cell].isValid())
  83.      *       {
  84.      *          KColorDrag *d = KColorDrag::makeDrag( colors[cell], this);
  85.      *          d->dragCopy();
  86.      *       }
  87.      *    }
  88.      * }
  89.      * \endcode
  90.      * @return the threshold for drag & drop in pixels
  91.      */
  92.  
  93.     static int dndEventDelay();
  94.  
  95.     /**
  96.      * Returns whether KDE runs in single (default) or double click
  97.      * mode.
  98.      * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html
  99.      * @return true if single click mode, or false if double click mode.
  100.      **/
  101.     static bool singleClick();
  102.  
  103.     /**
  104.      * This enum describes the return type for insertTearOffHandle() whether to insert
  105.      * a handle or not. Applications who independently want to use handles in their popup menus
  106.      * should test for Application level before calling the appropriate function in KPopupMenu.
  107.      * @since 3.1
  108.      **/
  109.     enum TearOffHandle {
  110.       Disable = 0, ///< disable tear-off handles
  111.       ApplicationLevel, ///< enable on application level
  112.       Enable ///< enable tear-off handles
  113.     };
  114.  
  115.     /**
  116.      * Returns whether tear-off handles are inserted in KPopupMenus.
  117.      * @return whether tear-off handles are inserted in KPopupMenus.
  118.      * @since 3.1
  119.      **/
  120.     static TearOffHandle insertTearOffHandle();
  121.  
  122.     /**
  123.      * Checks whether the cursor changes over icons.
  124.      * @return the KDE setting for "change cursor over icon"
  125.      */
  126.     static bool changeCursorOverIcon();
  127.  
  128.     /**
  129.      * Checks whether to show feedback when in item (specifically an
  130.      * icon) is activated.
  131.      * @return whether to show some feedback when an item is activated.
  132.      */
  133.     static bool visualActivate();
  134.  
  135.     /**
  136.      * Returns the speed of the visual activation feedback.
  137.      * @return the speed of the visual activation feedback, between
  138.      *         0 for minimum and 100 for maximum speed
  139.      */
  140.     static unsigned int visualActivateSpeed();
  141.  
  142.     /**
  143.      * Returns the KDE setting for the auto-select option.
  144.      *
  145.      * @return the auto-select delay or -1 if auto-select is disabled.
  146.      */
  147.     static int autoSelectDelay();
  148.  
  149.     /**
  150.      * Returns the KDE setting for the shortcut key to open
  151.      * context menus.
  152.      *
  153.      * @return the key that pops up context menus.
  154.      */
  155.     static int contextMenuKey ();
  156.  
  157.     /**
  158.      * Returns the KDE setting for context menus.
  159.      *
  160.      * @return whether context menus should be shown on button press
  161.      * or button release (click).
  162.      */
  163.     static bool showContextMenusOnPress ();
  164.  
  165.     /**
  166.      * This enum describes the completion mode used for by the KCompletion class.
  167.      * See <a href="http://developer.kde.org/documentation/standards/kde/style/keys/completion.html">
  168.      * the styleguide</a>.
  169.      **/
  170.    enum Completion {
  171.        /**
  172.         * No completion is used.
  173.         */
  174.        CompletionNone=1,
  175.        /**
  176.         * Text is automatically filled in whenever possible.
  177.         */
  178.        CompletionAuto,
  179.        /**
  180.         * Same as automatic except shortest match is used for completion.
  181.         */
  182.        CompletionMan,
  183.        /**
  184.         * Complete text much in the same way as a typical *nix shell would.
  185.         */
  186.        CompletionShell,
  187.        /**
  188.         * Lists all possible matches in a popup list-box to choose from.
  189.         */
  190.        CompletionPopup,
  191.        /**
  192.         * Lists all possible matches in a popup list-box to choose from, and automatically
  193.         * fill the result whenever possible.
  194.         */
  195.        CompletionPopupAuto
  196.    };
  197.  
  198.     /**
  199.      * Returns the preferred completion mode setting.
  200.      *
  201.      * @return Completion.  Default is @p CompletionPopup.
  202.      */
  203.     static Completion completionMode();
  204.  
  205.     /**
  206.      * Describes the mouse settings.
  207.      */
  208.     struct KMouseSettings
  209.     {
  210.         enum { RightHanded = 0, LeftHanded = 1 };
  211.         int handed; // left or right
  212.     };
  213.  
  214.     /**
  215.      * This returns the current mouse settings.
  216.      * On Windows, settings are retrieved from the system.
  217.      * @return the current mouse settings
  218.      */
  219.     static KMouseSettings & mouseSettings();
  220.  
  221.     /**
  222.      * The path to the desktop directory of the current user.
  223.      * @return the user's desktop directory
  224.      */
  225.     static QString desktopPath() { initStatic(); return *s_desktopPath; }
  226.  
  227.     /**
  228.      * The path to the autostart directory of the current user.
  229.      * @return the path of the autostart directory
  230.      */
  231.     static QString autostartPath() { initStatic(); return *s_autostartPath; }
  232.  
  233.     /**
  234.      * DEPRECATED (starting from kde-3.4).
  235.      * This isn't where the trash contents is, anymore.
  236.      * Use KIO::trash() to trash files, "trash:/" to list the trash contents.
  237.      */
  238.     static QString trashPath() { initStatic(); return *s_trashPath; }
  239.     // KDE4: if you want to remove the above, move it to kdesktop/init.cc, which needs
  240.     // to know the old location of the trash
  241.  
  242.     /**
  243.      * The path where documents are stored of the current user.
  244.      * @return the path of the document directory
  245.      */
  246.     static QString documentPath() { initStatic(); return *s_documentPath; }
  247.  
  248.  
  249.     /**
  250.      * The default color to use when highlighting toolbar buttons.
  251.      * @return the toolbar highlight color
  252.      */
  253.     static QColor toolBarHighlightColor();
  254.  
  255.     /**
  256.      * The default color to use for inactive titles.
  257.      * @return the inactive title color
  258.      */
  259.     static QColor inactiveTitleColor();
  260.  
  261.     /**
  262.      * The default color to use for inactive texts.
  263.      * @return the inactive text color
  264.      */
  265.     static QColor inactiveTextColor();
  266.  
  267.     /**
  268.      * The default color to use for active titles.
  269.      * @return the active title color
  270.      */
  271.     static QColor activeTitleColor();
  272.  
  273.     /**
  274.      * The default color to use for active texts.
  275.      * @return the active text color
  276.      */
  277.     static QColor activeTextColor();
  278.  
  279.     /**
  280.      * Returns the contrast for borders.
  281.      * @return the contrast (between 0 for minimum and 10 for maximum
  282.      *         contrast)
  283.      */
  284.     static int contrast();
  285.  
  286.     /**
  287.      * Returns the button background color
  288.      * @return the button background color
  289.      * @since 3.4
  290.      */
  291.     static QColor buttonBackground();
  292.  
  293.     /**
  294.      * Returns the button text color
  295.      * @return the button text color
  296.      * @since 3.4
  297.      */
  298.     static QColor buttonTextColor();
  299.  
  300.     /**
  301.      * Returns the default base (background) color.
  302.      * @return the default base (background) color
  303.      * @see QColorGroup::base()
  304.      */
  305.     static QColor baseColor();
  306.  
  307.     /**
  308.      * Returns the default text color.
  309.      * @return the default text color
  310.      * @see QColorGroup::text()
  311.      */
  312.     static QColor textColor();
  313.  
  314.     /**
  315.      * Returns the default link color.
  316.      * @return the default link color
  317.      */
  318.     static QColor linkColor();
  319.  
  320.     /**
  321.      * Returns the default color for visited links.
  322.      * @return the default color for visited links
  323.      */
  324.     static QColor visitedLinkColor();
  325.  
  326.     /**
  327.      * Returns the default color for highlighted text.
  328.      * @return the default color for highlighted text
  329.      * @see QColorGroup::hightlightedText()
  330.      */
  331.     static QColor highlightedTextColor();
  332.  
  333.     /**
  334.      * Returns the default color for text highlights.
  335.      * @return the default color for text highlights
  336.      * @see QColorGroup::hightlight()
  337.      */
  338.     static QColor highlightColor();
  339.  
  340.     /**
  341.      * Returns the alternate background color used by KListView with
  342.      * KListViewItem. Any other list that uses alternating background
  343.      * colors should use this too, to obey to the user's preferences. Returns
  344.      * an invalid color if the user doesn't want alternating backgrounds.
  345.      * @return the alternate background color
  346.      * @see calculateAlternateBackgroundColor
  347.      */
  348.     static QColor alternateBackgroundColor();
  349.  
  350.     /**
  351.      * Calculates a color based on @p base to be used as alternating
  352.      * color for e.g. listviews.
  353.      * @param base the base for the calculation
  354.      * @return the calculated color
  355.      * @see alternateBackgroundColor
  356.      */
  357.     static QColor calculateAlternateBackgroundColor(const QColor& base);
  358.  
  359.     /**
  360.       * Returns if the sorted column in a KListView shall be drawn with a
  361.       * shaded background color.
  362.       * @return true if the sorted column shall be shaded
  363.       * @since 3.4
  364.       */
  365.     static bool shadeSortColumn();
  366.  
  367.     /**
  368.      * Returns the default general font.
  369.      * @return the default general font.
  370.      */
  371.     static QFont generalFont();
  372.  
  373.     /**
  374.      * Returns the default fixed font.
  375.      * @return the default fixed font.
  376.      */
  377.     static QFont fixedFont();
  378.  
  379.     /**
  380.      * Returns the default toolbar font.
  381.      * @return the default toolbar font.
  382.      */
  383.     static QFont toolBarFont();
  384.  
  385.     /**
  386.      * Returns the default menu font.
  387.      * @return the default menu font.
  388.      */
  389.     static QFont menuFont();
  390.  
  391.     /**
  392.      * Returns the default window title font.
  393.      * @return the default window title font.
  394.      */
  395.     static QFont windowTitleFont();
  396.  
  397.     /**
  398.      * Returns the default taskbar font.
  399.      * @return the default taskbar font.
  400.      */
  401.     static QFont taskbarFont();
  402.  
  403.     /**
  404.      * Returns a font of approx. 48 pt. capable of showing @p text.
  405.      * @param text the text to test
  406.      * @return the font that is capable to show the text with 48 pt
  407.      * @since 3.1
  408.      */
  409.     static QFont largeFont(const QString &text = QString::null);
  410.  
  411.     /**
  412.      * Returns if the user specified multihead. In case the display
  413.      * has multiple screens, the return value of this function specifies
  414.      * if the user wants KDE to run on all of them or just on the primary
  415.      * On Windows, settings are retrieved from the system.
  416.      * @return true if the user chose multi head
  417.      */
  418.     static bool isMultiHead();
  419.  
  420.     /**
  421.      * Typically, QScrollView derived classes can be scrolled fast by
  422.      * holding down the Ctrl-button during wheel-scrolling.
  423.      * But QTextEdit and derived classes perform zooming instead of fast
  424.      * scrolling.
  425.      *
  426.      * This value determines whether the user wants to zoom or scroll fast
  427.      * with Ctrl-wheelscroll.
  428.      * @return true if the user wishes to zoom with the mouse wheel,
  429.      *         false for scrolling
  430.      * @since 3.1
  431.      */
  432.     static bool wheelMouseZooms();
  433.  
  434.     /**
  435.      * This function returns the desktop geometry for an application's splash
  436.      * screen.  It takes into account the user's display settings (number of
  437.      * screens, Xinerama, etc), and the user's preferences (if KDE should be
  438.      * Xinerama aware).
  439.      *
  440.      * @return the geometry to use for the desktop.  Note that it might not
  441.      *         start at (0,0).
  442.      * @since 3.2
  443.      */
  444.     static QRect splashScreenDesktopGeometry();
  445.  
  446.     /**
  447.      * This function returns the desktop geometry for an application that needs
  448.      * to set the geometry of a widget on the screen manually.  It takes into
  449.      * account the user's display settings (number of screens, Xinerama, etc),
  450.      * and the user's preferences (if KDE should be Xinerama aware).
  451.      *
  452.      * Note that this can break in multi-head (not Xinerama) mode because this
  453.      * point could be on multiple screens.  Use with care.
  454.      *
  455.      * @param point a reference point for the widget, for instance one that the
  456.      *              widget should be adjacent or on top of.
  457.      *
  458.      * @return the geometry to use for the desktop.  Note that it might not
  459.      *         start at (0,0).
  460.      * @since 3.2
  461.      */
  462.     static QRect desktopGeometry(const QPoint& point);
  463.  
  464.     /**
  465.      * This function returns the desktop geometry for an application that needs
  466.      * to set the geometry of a widget on the screen manually.  It takes into
  467.      * account the user's display settings (number of screens, Xinerama, etc),
  468.      * and the user's preferences (if KDE should be Xinerama aware).
  469.      *
  470.      * @param w the widget in question.  This is used to determine which screen
  471.      *          to use in Xinerama or multi-head mode.
  472.      *
  473.      * @return the geometry to use for the desktop.  Note that it might not
  474.      *         start at (0,0).
  475.      * @since 3.2
  476.      */
  477.     static QRect desktopGeometry(QWidget* w);
  478.  
  479.     /**
  480.      * This function determines if the user wishes to see icons on the
  481.      * push buttons.
  482.      *
  483.      * @return Returns true if user wants to show icons.
  484.      *
  485.      * @since 3.2
  486.      */
  487.     static bool showIconsOnPushButtons();
  488.  
  489.     /**
  490.      * This function determines if the user wishes to see previews
  491.      * for the selected url
  492.      *
  493.      * @return Returns true if user wants to show previews.
  494.      *
  495.      * @since 3.2
  496.      */
  497.     static bool showFilePreview(const KURL &);
  498.  
  499.     /**
  500.      * Whether the user wishes to use opaque resizing. Primarily
  501.      * intended for QSplitter::setOpaqueResize()
  502.      * 
  503.      * @return Returns true if user wants to use opaque resizing.
  504.      *
  505.      * @since 3.2
  506.      */
  507.     static bool opaqueResize();
  508.  
  509.     /**
  510.      * The layout scheme to use for dialog buttons
  511.      * 
  512.      * @return Returns the number of the scheme to use.
  513.      * @see KDialogBase::setButtonStyle()
  514.      * @since 3.3
  515.      */
  516.     static int buttonLayout();
  517.  
  518. private:
  519.     /**
  520.      * reads in all paths from kdeglobals
  521.      */
  522.     static void initStatic();
  523.     /**
  524.      * initialize colors
  525.      */
  526.     static void initColors();
  527.     /**
  528.      * drop cached values for fonts (called by KApplication)
  529.      */
  530.     static void rereadFontSettings();
  531.     /**
  532.      * drop cached values for paths (called by KApplication)
  533.      */
  534.     static void rereadPathSettings();
  535.     /**
  536.      * drop cached values for mouse settings (called by KApplication)
  537.      */
  538.     static void rereadMouseSettings();
  539.  
  540.  
  541.     static QString* s_desktopPath;
  542.     static QString* s_autostartPath;
  543.     static QString* s_trashPath;
  544.     static QString* s_documentPath;
  545.     static QFont *_generalFont;
  546.     static QFont *_fixedFont;
  547.     static QFont *_toolBarFont;
  548.     static QFont *_menuFont;
  549.     static QFont *_windowTitleFont;
  550.     static QFont *_taskbarFont;
  551.     static QFont *_largeFont;
  552.     static QColor * _kde34Blue;
  553.     static QColor * _inactiveBackground;
  554.     static QColor * _inactiveForeground;
  555.     static QColor * _activeBackground;
  556.     static QColor * _buttonBackground;
  557.     static QColor * _selectBackground;
  558.     static QColor * _linkColor;
  559.     static QColor * _visitedLinkColor;
  560.     static QColor * alternateColor;
  561.     static KMouseSettings *s_mouseSettings;
  562.  
  563.     friend class KApplication;
  564. };
  565.  
  566. #endif
  567.