File indexing completed on 2024-05-12 05:14:39
0001 /* 0002 * commandoptions.h - extract command line options 0003 * Program: kalarm 0004 * SPDX-FileCopyrightText: 2001-2022 David Jarvie <djarvie@kde.org> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 0009 #pragma once 0010 0011 #include "editdlg.h" 0012 #include "kalarmcalendar/kaevent.h" 0013 #include "kalarmcalendar/karecurrence.h" 0014 #include "kalarmcalendar/kadatetime.h" 0015 0016 #include <QColor> 0017 #include <QStringList> 0018 class QCommandLineParser; 0019 class QCommandLineOption; 0020 0021 using namespace KAlarmCal; 0022 0023 class CommandOptions 0024 { 0025 public: 0026 enum Command 0027 { 0028 CMD_ERROR, // error in command line options 0029 NONE, // no command 0030 TRAY, // --tray 0031 TRIGGER_EVENT, // --triggerEvent 0032 CANCEL_EVENT, // --cancelEvent 0033 EDIT, // --edit 0034 EDIT_NEW_PRESET, // --edit-new-preset 0035 EDIT_NEW, // --edit-new-display, --edit-new-command, --edit-new-email 0036 NEW, // --file, --exec-display, --exec, --mail, message 0037 LIST // --list 0038 }; 0039 QStringList setOptions(QCommandLineParser*, const QStringList& args); 0040 static CommandOptions* firstInstance() { return mFirstInstance; } 0041 CommandOptions(); 0042 CommandOptions(CommandOptions&) = delete; 0043 CommandOptions& operator=(CommandOptions&) = delete; 0044 void parse(); 0045 void process(); 0046 Command command() const { return mCommand; } 0047 QString commandName() const; 0048 QString eventId() const { return mEventId; } 0049 QString resourceId() const { return mResourceId; } 0050 QString name() const { return mName; } 0051 EditAlarmDlg::Type editType() const { return mEditType; } 0052 KAEvent::SubAction editAction() const { return mEditAction; } 0053 QString text() const { return mText; } 0054 KADateTime alarmTime() const { return mAlarmTime; } 0055 KARecurrence* recurrence() const { return mRecurrence; } 0056 int subRepeatCount() const { return mRepeatCount; } 0057 KCalendarCore::Duration subRepeatInterval() const { return mRepeatInterval; } 0058 int lateCancel() const { return mLateCancel; } 0059 QColor bgColour() const { return mBgColour; } 0060 QColor fgColour() const { return mFgColour; } 0061 int reminderMinutes() const { return mReminderMinutes; } 0062 QString audioFile() const { return mAudioFile; } 0063 float audioVolume() const { return mAudioVolume; } 0064 KCalendarCore::Person::List addressees() const { return mAddressees; } 0065 QStringList attachments() const { return mAttachments; } 0066 QString subject() const { return mSubject; } 0067 uint fromID() const { return mFromID; } 0068 KAEvent::Flags flags() const { return mFlags; } 0069 bool disableAll() const { return mDisableAll; } 0070 QString outputText() const { return mError; } 0071 #ifndef NDEBUG 0072 KADateTime simulationTime() const { return mSimulationTime; } 0073 #endif 0074 static void printError(const QString& errmsg); 0075 0076 private: 0077 class Private; 0078 friend class Private; 0079 Private* const d; 0080 QString arg(int n); 0081 0082 static CommandOptions* mFirstInstance; // the first instance 0083 QCommandLineParser* mParser {nullptr}; 0084 QList<QCommandLineOption*> mOptions; // all possible command line options 0085 QStringList mNonExecArguments; // arguments except for --exec or --exec-display parameters 0086 QStringList mExecArguments; // arguments for --exec or --exec-display 0087 QString mError; // error message 0088 Command mCommand {NONE}; // the selected command 0089 QString mEventId; // TRIGGER_EVENT, CANCEL_EVENT, EDIT: event ID 0090 QString mResourceId; // TRIGGER_EVENT, CANCEL_EVENT, EDIT: optional resource ID 0091 QString mName; // NEW, EDIT_NEW_PRESET: alarm/template name 0092 EditAlarmDlg::Type mEditType; // NEW, EDIT_NEW_*: alarm edit type 0093 KAEvent::SubAction mEditAction; // NEW: alarm edit sub-type 0094 bool mEditActionSet {false}; // NEW: mEditAction is valid 0095 QString mText; // NEW: alarm text 0096 KADateTime mAlarmTime; // NEW: alarm time 0097 KARecurrence* mRecurrence {nullptr}; // NEW: recurrence 0098 int mRepeatCount {0}; // NEW: sub-repetition count 0099 KCalendarCore::Duration mRepeatInterval {0}; // NEW: sub-repetition interval 0100 int mLateCancel {0}; // NEW: late-cancellation interval 0101 QColor mBgColour; // NEW: background colour 0102 QColor mFgColour; // NEW: foreground colour 0103 int mReminderMinutes {0}; // NEW: reminder period 0104 QString mAudioFile; // NEW: audio file path 0105 float mAudioVolume {-1.0f}; // NEW: audio file volume 0106 KCalendarCore::Person::List mAddressees; // NEW: email addressees 0107 QStringList mAttachments; // NEW: email attachment file names 0108 QString mSubject; // NEW: email subject 0109 uint mFromID {0}; // NEW: email sender ID 0110 KAEvent::Flags mFlags; // NEW: event flags 0111 bool mDisableAll {false}; // disable all alarm monitoring 0112 #ifndef NDEBUG 0113 KADateTime mSimulationTime; // system time to be simulated, or invalid if none 0114 #endif 0115 }; 0116 0117 // vim: et sw=4: