"Fossies" - the Fresh Open Source Software Archive

Member "cb2bib-2.0.1/src/c2bShortcutPushButton.h" (12 Feb 2021, 1371 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "c2bShortcutPushButton.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 2.0.0_vs_2.0.1.

    1 /***************************************************************************
    2  *   Copyright (C) 2004-2021 by Pere Constans
    3  *   constans@molspaces.com
    4  *   cb2Bib version 2.0.1. Licensed under the GNU GPL version 3.
    5  *   See the LICENSE file that comes with this distribution.
    6  ***************************************************************************/
    7 #ifndef C2BSHORTCUTPUSHBUTTON_H
    8 #define C2BSHORTCUTPUSHBUTTON_H
    9 
   10 #include <QPushButton>
   11 
   12 
   13 class c2bShortcutPushButton : public QPushButton
   14 {
   15 
   16     Q_OBJECT
   17 
   18 public:
   19     explicit inline c2bShortcutPushButton(QWidget* parentw = 0) : QPushButton(parentw) {}
   20     inline ~c2bShortcutPushButton() {}
   21 
   22     void setKeysequence(const QKeySequence& ks);
   23     void setDefaultKeysequence(const QKeySequence& ks)
   24     {
   25         _default_keysequence = ks;
   26     }
   27     inline QKeySequence keysequence() const
   28     {
   29         return _keysequence;
   30     }
   31 
   32 
   33 signals:
   34     void shortcutChanged(const QKeySequence& oldks, const QKeySequence& newks);
   35 
   36 
   37 public slots:
   38     void clear();
   39     void reset();
   40 
   41 
   42 protected:
   43     virtual void keyPressEvent(QKeyEvent* qevent);
   44 
   45 
   46 private:
   47     inline void _set_keysequence(const QKeySequence& ks)
   48     {
   49         const QKeySequence oldks(_keysequence);
   50         setKeysequence(ks);
   51         emit shortcutChanged(oldks, ks);
   52     }
   53 
   54     QKeySequence _default_keysequence;
   55     QKeySequence _keysequence;
   56 };
   57 
   58 #endif