File indexing completed on 2024-05-12 05:14:58

0001 /*
0002  *  specialactions.h  -  widget to specify special alarm actions
0003  *  Program:  kalarm
0004  *  SPDX-FileCopyrightText: 2004-2022 David Jarvie <djarvie@kde.org>
0005  *
0006  *  SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #pragma once
0010 
0011 #include "kalarmcalendar/kaevent.h"
0012 
0013 #include <QDialog>
0014 #include <QWidget>
0015 #include <QPushButton>
0016 
0017 using namespace KAlarmCal;
0018 
0019 class QResizeEvent;
0020 class QLineEdit;
0021 class CheckBox;
0022 
0023 
0024 class SpecialActionsButton : public QPushButton
0025 {
0026     Q_OBJECT
0027 public:
0028     explicit SpecialActionsButton(bool enableCheckboxes, QWidget* parent = nullptr);
0029     void           setActions(const QString& pre, const QString& post, KAEvent::ExtraActionOptions);
0030     const QString& preAction() const      { return mPreAction; }
0031     const QString& postAction() const     { return mPostAction; }
0032     KAEvent::ExtraActionOptions options() const  { return mOptions; }
0033     virtual void   setReadOnly(bool ro)   { mReadOnly = ro; }
0034     virtual bool   isReadOnly() const     { return mReadOnly; }
0035 
0036 Q_SIGNALS:
0037     /** Signal emitted whenever the widget has been changed. */
0038     void           selected();
0039 
0040 protected Q_SLOTS:
0041     void           slotButtonPressed();
0042 
0043 private:
0044     QString  mPreAction;
0045     QString  mPostAction;
0046     KAEvent::ExtraActionOptions mOptions;
0047     bool     mEnableCheckboxes;
0048     bool     mReadOnly {false};
0049 };
0050 
0051 
0052 // Pre- and post-alarm actions widget
0053 class SpecialActions : public QWidget
0054 {
0055     Q_OBJECT
0056 public:
0057     explicit SpecialActions(bool enableCheckboxes, QWidget* parent = nullptr);
0058     void         setActions(const QString& pre, const QString& post, KAEvent::ExtraActionOptions);
0059     QString      preAction() const;
0060     QString      postAction() const;
0061     KAEvent::ExtraActionOptions options() const;
0062     void         setReadOnly(bool);
0063     bool         isReadOnly() const    { return mReadOnly; }
0064 
0065 private Q_SLOTS:
0066     void         slotPreActionChanged(const QString& text);
0067 
0068 private:
0069     QLineEdit*   mPreAction;
0070     QLineEdit*   mPostAction;
0071     CheckBox*    mCancelOnError;
0072     CheckBox*    mDontShowError;
0073     CheckBox*    mExecOnDeferral;
0074     bool         mEnableCheckboxes;   // enable checkboxes even if mPreAction is blank
0075     bool         mReadOnly {false};
0076 };
0077 
0078 
0079 // Pre- and post-alarm actions dialog displayed by the push button
0080 class SpecialActionsDlg : public QDialog
0081 {
0082     Q_OBJECT
0083 public:
0084     SpecialActionsDlg(const QString& preAction, const QString& postAction,
0085                       KAEvent::ExtraActionOptions, bool enableCheckboxes,
0086                       QWidget* parent = nullptr);
0087     QString        preAction() const     { return mActions->preAction(); }
0088     QString        postAction() const    { return mActions->postAction(); }
0089     KAEvent::ExtraActionOptions options() const  { return mActions->options(); }
0090     void           setReadOnly(bool ro)  { mActions->setReadOnly(ro); }
0091     bool           isReadOnly() const    { return mActions->isReadOnly(); }
0092 
0093 protected:
0094     void           resizeEvent(QResizeEvent*) override;
0095 
0096 protected Q_SLOTS:
0097     virtual void slotOk();
0098 
0099 private:
0100     SpecialActions* mActions;
0101 };
0102 
0103 // vim: et sw=4: