├── ActionWidgetsManager.cpp ├── ActionWidgetsManager.h ├── README.md ├── ScheduledPCTasks_fr.ts ├── ScheduledPasteAndKeys.pro ├── Task.cpp ├── Task.h ├── TaskTabsManager.cpp ├── TaskTabsManager.h ├── TaskThread.cpp ├── TaskThread.h ├── actions ├── AbstractAction.cpp ├── AbstractAction.h ├── ActionParameters.h ├── ActionsTools.cpp ├── ActionsTools.h ├── CursorMovementsAction.cpp ├── CursorMovementsAction.h ├── KeysSequenceAction.cpp ├── KeysSequenceAction.h ├── PasteAction.cpp ├── PasteAction.h ├── SystemCommandsAction.cpp ├── SystemCommandsAction.h ├── WaitAction.cpp └── WaitAction.h ├── globals.h ├── img ├── bottom_arrow_rounded.png ├── browseFolder.png ├── check.png ├── check_light.png ├── check_penombra.png ├── close.png ├── close_light.png ├── close_penombra.png ├── close_red.png ├── crosshair.png ├── cursor-cross.png ├── cursor.png ├── darkTheme.png ├── down_arrow.png ├── down_arrow_light.png ├── down_arrow_penombra.png ├── down_arrow_rounded.png ├── key.png ├── left_arrow.png ├── left_arrow_light.png ├── left_arrow_penombra.png ├── lightTheme.png ├── noscroll.png ├── penombraTheme.png ├── pinned.png ├── play.png ├── plus.png ├── programIcon.ico ├── programIcon.png ├── right_arrow.png ├── right_arrow_light.png ├── right_arrow_penombra.png ├── save.png ├── scroll.png ├── startup.png ├── systemCommand.png ├── text.png ├── top_arrow_rounded.png ├── undock.png ├── undock_light.png ├── undock_penombra.png ├── unpinned.png ├── up_arrow.png ├── up_arrow_light.png ├── up_arrow_penombra.png ├── up_arrow_rounded.png └── wait.png ├── license.txt ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── private_policy.txt ├── readme.txt ├── resources.qrc ├── style ├── dark.qss ├── light.qss └── penombra.qss └── ui ├── CreateLoadTaskDialog.cpp ├── CreateLoadTaskDialog.h ├── CreateLoadTaskDialog.ui ├── CursorMovementsSelectedEditDialog.cpp ├── CursorMovementsSelectedEditDialog.h ├── CursorMovementsSelectedEditDialog.ui ├── CursorMovementsTableWidget.cpp ├── CursorMovementsTableWidget.h ├── DataEditDialog.cpp ├── DataEditDialog.h ├── DataEditDialog.ui ├── KeysSelectorDialog.cpp ├── KeysSelectorDialog.h ├── KeysSelectorDialog.ui ├── KeysSequenceSelectedEditDialog.cpp ├── KeysSequenceSelectedEditDialog.h ├── KeysSequenceSelectedEditDialog.ui ├── KeysSequencesTableWidget.cpp ├── KeysSequencesTableWidget.h ├── SentenceSelectedEditDialog.cpp ├── SentenceSelectedEditDialog.h ├── SentenceSelectedEditDialog.ui ├── SentencesTableWidget.cpp ├── SentencesTableWidget.h ├── StartupTaskEditDialog.cpp ├── StartupTaskEditDialog.h ├── StartupTaskEditDialog.ui ├── StartupTasksDialog.cpp ├── StartupTasksDialog.h ├── StartupTasksDialog.ui ├── StartupTasksTableWidget.cpp ├── StartupTasksTableWidget.h ├── Tasktab.cpp ├── Tasktab.h ├── actionwidgets ├── AbstractActionWidget.cpp ├── AbstractActionWidget.h ├── CursorMovementsWidget.cpp ├── CursorMovementsWidget.h ├── KeysSequenceWidget.cpp ├── KeysSequenceWidget.h ├── PasteWidget.cpp ├── PasteWidget.h ├── SystemCommandWidget.cpp ├── SystemCommandWidget.h ├── WaitWidget.cpp └── WaitWidget.h ├── createactiondialog ├── CreateCursorMovementsActionDialog.cpp ├── CreateCursorMovementsActionDialog.h ├── CreateCursorMovementsActionDialog.ui ├── CreateKeysSequenceActionDialog.cpp ├── CreateKeysSequenceActionDialog.h ├── CreateKeysSequenceActionDialog.ui ├── CreatePasteActionDialog.cpp ├── CreatePasteActionDialog.h ├── CreatePasteActionDialog.ui ├── CreateSystemCommandActionDialog.cpp ├── CreateSystemCommandActionDialog.h ├── CreateSystemCommandActionDialog.ui ├── CreateWaitActionDialog.cpp ├── CreateWaitActionDialog.h └── CreateWaitActionDialog.ui ├── getAutoRenameOptionDialog.cpp ├── getAutoRenameOptionDialog.h ├── getAutoRenameOptionDialog.ui ├── getCursorCoordinatesWidget.cpp ├── getCursorCoordinatesWidget.h ├── getDelayDialog.cpp ├── getDelayDialog.h ├── getDelayDialog.ui ├── getFilePathDialog.cpp ├── getFilePathDialog.h ├── getFilePathDialog.ui ├── getFolderPathDialog.cpp ├── getFolderPathDialog.h ├── getFolderPathDialog.ui ├── getImagePathDialog.cpp ├── getImagePathDialog.h ├── getImagePathDialog.ui ├── getProgramPathDialog.cpp ├── getProgramPathDialog.h └── getProgramPathDialog.ui /ActionWidgetsManager.cpp: -------------------------------------------------------------------------------- 1 | #include "ActionWidgetsManager.h" 2 | 3 | #include 4 | #include 5 | 6 | ActionWidgetsManager::ActionWidgetsManager(QVBoxLayout *parent) 7 | : QObject{parent},m_layout(parent) 8 | { 9 | if(m_layout == nullptr) 10 | { 11 | QMessageBox::critical(nullptr, tr("Internal Error"), 12 | tr("An internal error occured : err02\nlayout is null when affecting to ActionWidgetsManager !")); 13 | qApp->quit(); 14 | return; 15 | } 16 | } 17 | 18 | ActionWidgetsManager::~ActionWidgetsManager() 19 | { 20 | clear(); 21 | } 22 | 23 | int ActionWidgetsManager::appendWidget(AbstractActionWidget *actionWidget) 24 | { 25 | if(actionWidget == nullptr) 26 | return -1; 27 | 28 | m_actionWidgetsMap.insert(actionWidget->getActionID(),actionWidget); 29 | //m_layout->addWidget(actionWidget); 30 | m_actionWidgetsDisplayOrderedList.append(actionWidget); 31 | return m_actionWidgetsMap.count(); 32 | } 33 | 34 | void ActionWidgetsManager::clear() 35 | { 36 | qDeleteAll(m_actionWidgetsMap); 37 | m_actionWidgetsMap.clear(); 38 | m_actionWidgetsDisplayOrderedList.clear(); 39 | } 40 | 41 | void ActionWidgetsManager::fullRefreshActionWidgets() 42 | { 43 | while(m_layout->count() != 0) 44 | m_layout->removeItem(m_layout->itemAt(0)); 45 | 46 | for(auto it = m_actionWidgetsDisplayOrderedList.begin(); it != m_actionWidgetsDisplayOrderedList.end();++it) 47 | { 48 | if((*it) != nullptr) 49 | m_layout->addWidget(*it); 50 | } 51 | 52 | m_layout->update(); 53 | } 54 | 55 | void ActionWidgetsManager::taskStopped() 56 | { 57 | for(auto it = m_actionWidgetsMap.keyValueBegin(); it != m_actionWidgetsMap.keyValueEnd(); ++it) 58 | { 59 | if(it->second == nullptr) 60 | continue; 61 | 62 | it->second->setRunningState(RunningState::NotExecuted); 63 | it->second->setEnabled(true); 64 | } 65 | } 66 | 67 | void ActionWidgetsManager::taskScheduled() 68 | { 69 | for(auto it = m_actionWidgetsMap.keyValueBegin(); it != m_actionWidgetsMap.keyValueEnd(); ++it) 70 | { 71 | if(it->second == nullptr) 72 | continue; 73 | 74 | it->second->setEnabled(false); 75 | } 76 | } 77 | 78 | void ActionWidgetsManager::receivedActionRunningState(unsigned int id) 79 | { 80 | AbstractActionWidget * widg = m_actionWidgetsMap.value(id,nullptr); 81 | if(widg != nullptr) 82 | widg->setRunningState(RunningState::Running); 83 | } 84 | 85 | void ActionWidgetsManager::receivedActionDoneState(unsigned int id) 86 | { 87 | AbstractActionWidget * widg = m_actionWidgetsMap.value(id,nullptr); 88 | if(widg != nullptr) 89 | widg->setRunningState(RunningState::Done); 90 | } 91 | -------------------------------------------------------------------------------- /ActionWidgetsManager.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTIONWIDGETSMANAGER_H 2 | #define ACTIONWIDGETSMANAGER_H 3 | 4 | #include "ui/actionwidgets/AbstractActionWidget.h" 5 | 6 | #include 7 | #include 8 | 9 | class ActionWidgetsManager : public QObject 10 | { 11 | Q_OBJECT 12 | QVBoxLayout *m_layout = nullptr; 13 | QMap m_actionWidgetsMap; 14 | QList m_actionWidgetsDisplayOrderedList; 15 | void fullRefreshActionWidgets(); 16 | public: 17 | explicit ActionWidgetsManager(QVBoxLayout *parent = nullptr); 18 | ~ActionWidgetsManager(); 19 | int appendWidget(AbstractActionWidget* actionWidget); 20 | void clear(); 21 | void taskStopped(); 22 | void taskScheduled(); 23 | public slots: 24 | void receivedActionRunningState(unsigned int id); 25 | void receivedActionDoneState(unsigned int id); 26 | 27 | friend class TaskTab; 28 | }; 29 | 30 | #endif // ACTIONWIDGETSMANAGER_H 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Scheduled PC Tasks 2 | 3 | version 1.3 (January 2025) 4 | 5 | Schedule automated simulations of actions you would perform on your PC. 6 | 7 | 8 | Under GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 9 | Please read license.txt file 10 | 11 | We don't collect any data 12 | Please read private_policy.txt 13 | 14 | ---------- 15 | Details of version 1.3: 16 | 17 | Stable version, fully functional 18 | 19 | Those actions simulations are available : 20 | 21 | - Keys sequence 22 | - Move Cursor 23 | - Paste text 24 | - Open files, folders, executables, url 25 | - Run Windows system specific command (shut down, reboot, kill processes, create files...) 26 | - Wait 27 | 28 | And other features like data management, scheduled tasks at system startup... 29 | 30 | The goal in future versions is to include those actions : 31 | 32 | - Play sounds 33 | - Add more Windows system specific command 34 | 35 | Working on a Linux system version. 36 | 37 | Feedbacks and ideas for further actions are very welcome ! 38 | 39 | ---------- 40 | Available for install on Microsoft Store : 41 | https://apps.microsoft.com/store/detail/XP9CJLHWVXS49P 42 | 43 | Available as a portable version : 44 | https://files.amirhammoutene.dev/ScheduledPCTasks/1.3/Scheduled_PC_Tasks_v1.3.zip 45 | 46 | Needs 30 Mo disk space, available for Windows systems only 47 | 48 | ---------- 49 | Presentation video is available on Youtube : 50 | https://www.youtube.com/watch?v=ue6FPNrjD4c 51 | 52 | ---------- 53 | Has been developed in C++ language, using Qt (6.7.1) framework 54 | 55 | Open Source 56 | 57 | GitHub link for sources : https://github.com/AmirHammouteneEI/ScheduledPasteAndKeys 58 | 59 | ---------- 60 | Conceived and developed by Amir Hammoutene (contact@amirhammoutene.dev). 61 | 62 | Initial work in February 2024. -------------------------------------------------------------------------------- /ScheduledPasteAndKeys.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++17 6 | 7 | TARGET = ScheduledPCTasks 8 | 9 | QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-function -Wno-unused-parameter -Wno-unused-result 10 | 11 | SOURCES += \ 12 | ActionWidgetsManager.cpp \ 13 | Task.cpp \ 14 | TaskTabsManager.cpp \ 15 | TaskThread.cpp \ 16 | actions/AbstractAction.cpp \ 17 | actions/ActionsTools.cpp \ 18 | actions/CursorMovementsAction.cpp \ 19 | actions/KeysSequenceAction.cpp \ 20 | actions/PasteAction.cpp \ 21 | actions/SystemCommandsAction.cpp \ 22 | actions/WaitAction.cpp \ 23 | main.cpp \ 24 | mainwindow.cpp \ 25 | ui/CreateLoadTaskDialog.cpp \ 26 | ui/CursorMovementsSelectedEditDialog.cpp \ 27 | ui/CursorMovementsTableWidget.cpp \ 28 | ui/DataEditDialog.cpp \ 29 | ui/KeysSelectorDialog.cpp \ 30 | ui/KeysSequenceSelectedEditDialog.cpp \ 31 | ui/KeysSequencesTableWidget.cpp \ 32 | ui/SentenceSelectedEditDialog.cpp \ 33 | ui/SentencesTableWidget.cpp \ 34 | ui/StartupTaskEditDialog.cpp \ 35 | ui/StartupTasksDialog.cpp \ 36 | ui/StartupTasksTableWidget.cpp \ 37 | ui/TaskTab.cpp \ 38 | ui/actionwidgets/AbstractActionWidget.cpp \ 39 | ui/actionwidgets/CursorMovementsWidget.cpp \ 40 | ui/actionwidgets/KeysSequenceWidget.cpp \ 41 | ui/actionwidgets/PasteWidget.cpp \ 42 | ui/actionwidgets/SystemCommandWidget.cpp \ 43 | ui/actionwidgets/WaitWidget.cpp \ 44 | ui/createactiondialog/CreateCursorMovementsActionDialog.cpp \ 45 | ui/createactiondialog/CreateKeysSequenceActionDialog.cpp \ 46 | ui/createactiondialog/CreatePasteActionDialog.cpp \ 47 | ui/createactiondialog/CreateSystemCommandActionDialog.cpp \ 48 | ui/createactiondialog/CreateWaitActionDialog.cpp \ 49 | ui/getAutoRenameOptionDialog.cpp \ 50 | ui/getCursorCoordinatesWidget.cpp \ 51 | ui/getDelayDialog.cpp \ 52 | ui/getFilePathDialog.cpp \ 53 | ui/getFolderPathDialog.cpp \ 54 | ui/getImagePathDialog.cpp \ 55 | ui/getProgramPathDialog.cpp 56 | 57 | HEADERS += \ 58 | ActionWidgetsManager.h \ 59 | Task.h \ 60 | TaskTabsManager.h \ 61 | TaskThread.h \ 62 | actions/AbstractAction.h \ 63 | actions/ActionParameters.h \ 64 | actions/ActionsTools.h \ 65 | actions/CursorMovementsAction.h \ 66 | actions/KeysSequenceAction.h \ 67 | actions/PasteAction.h \ 68 | actions/SystemCommandsAction.h \ 69 | actions/WaitAction.h \ 70 | globals.h \ 71 | mainwindow.h \ 72 | ui/CreateLoadTaskDialog.h \ 73 | ui/CursorMovementsSelectedEditDialog.h \ 74 | ui/CursorMovementsTableWidget.h \ 75 | ui/DataEditDialog.h \ 76 | ui/KeysSelectorDialog.h \ 77 | ui/KeysSequenceSelectedEditDialog.h \ 78 | ui/KeysSequencesTableWidget.h \ 79 | ui/SentenceSelectedEditDialog.h \ 80 | ui/SentencesTableWidget.h \ 81 | ui/StartupTaskEditDialog.h \ 82 | ui/StartupTasksDialog.h \ 83 | ui/StartupTasksTableWidget.h \ 84 | ui/TaskTab.h \ 85 | ui/actionwidgets/AbstractActionWidget.h \ 86 | ui/actionwidgets/CursorMovementsWidget.h \ 87 | ui/actionwidgets/KeysSequenceWidget.h \ 88 | ui/actionwidgets/PasteWidget.h \ 89 | ui/actionwidgets/SystemCommandWidget.h \ 90 | ui/actionwidgets/WaitWidget.h \ 91 | ui/createactiondialog/CreateCursorMovementsActionDialog.h \ 92 | ui/createactiondialog/CreateKeysSequenceActionDialog.h \ 93 | ui/createactiondialog/CreatePasteActionDialog.h \ 94 | ui/createactiondialog/CreateSystemCommandActionDialog.h \ 95 | ui/createactiondialog/CreateWaitActionDialog.h \ 96 | ui/getAutoRenameOptionDialog.h \ 97 | ui/getCursorCoordinatesWidget.h \ 98 | ui/getDelayDialog.h \ 99 | ui/getFilePathDialog.h \ 100 | ui/getFolderPathDialog.h \ 101 | ui/getImagePathDialog.h \ 102 | ui/getProgramPathDialog.h 103 | 104 | FORMS += \ 105 | mainwindow.ui \ 106 | ui/CreateLoadTaskDialog.ui \ 107 | ui/CursorMovementsSelectedEditDialog.ui \ 108 | ui/DataEditDialog.ui \ 109 | ui/KeysSelectorDialog.ui \ 110 | ui/KeysSequenceSelectedEditDialog.ui \ 111 | ui/SentenceSelectedEditDialog.ui \ 112 | ui/StartupTaskEditDialog.ui \ 113 | ui/StartupTasksDialog.ui \ 114 | ui/createactiondialog/CreateCursorMovementsActionDialog.ui \ 115 | ui/createactiondialog/CreateKeysSequenceActionDialog.ui \ 116 | ui/createactiondialog/CreatePasteActionDialog.ui \ 117 | ui/createactiondialog/CreateSystemCommandActionDialog.ui \ 118 | ui/createactiondialog/CreateWaitActionDialog.ui \ 119 | ui/getAutoRenameOptionDialog.ui \ 120 | ui/getDelayDialog.ui \ 121 | ui/getFilePathDialog.ui \ 122 | ui/getFolderPathDialog.ui \ 123 | ui/getImagePathDialog.ui \ 124 | ui/getProgramPathDialog.ui 125 | 126 | LIBS += -luser32 -lole32 127 | 128 | TRANSLATIONS = ScheduledPCTasks_fr.ts 129 | 130 | RESOURCES += \ 131 | resources.qrc 132 | 133 | RC_ICONS = img/programIcon.ico 134 | 135 | VERSION = 1.3.0 136 | QMAKE_TARGET_COMPANY = "Amir Hammoutene" 137 | QMAKE_TARGET_COPYRIGHT = "GNU general public license version 3" 138 | 139 | DEFINES += APP_VERSION=\"\\\"$${VERSION}\\\"\" \ 140 | APP_COMPANY=\"\\\"$${QMAKE_TARGET_COMPANY}\\\"\" \ 141 | APP_COPYRIGHT=\"\\\"$${QMAKE_TARGET_COPYRIGHT}\\\"\" 142 | -------------------------------------------------------------------------------- /Task.cpp: -------------------------------------------------------------------------------- 1 | #include "Task.h" 2 | 3 | Task::Task() 4 | {} 5 | 6 | Task::~Task() 7 | { 8 | qDeleteAll(m_actionsMap); 9 | m_actionsMap.clear(); 10 | m_actionsOrderedList.clear(); 11 | } 12 | 13 | int Task::appendAction(AbstractAction *act) 14 | { 15 | if(act != nullptr) 16 | { 17 | m_actionsMap.insert(act->getID(), act); 18 | m_actionsOrderedList.append(act); 19 | } 20 | 21 | return m_actionsMap.size(); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Task.h: -------------------------------------------------------------------------------- 1 | #ifndef TASK_H 2 | #define TASK_H 3 | 4 | #include "actions/AbstractAction.h" 5 | 6 | #include 7 | #include 8 | 9 | class Task 10 | { 11 | QMap m_actionsMap; 12 | QList m_actionsOrderedList; 13 | public: 14 | explicit Task(); 15 | ~Task(); 16 | int appendAction(AbstractAction *act); 17 | 18 | friend class TaskThread; 19 | friend class TaskTab; 20 | friend class TaskTabsManager; 21 | }; 22 | 23 | #endif // TASK_H 24 | -------------------------------------------------------------------------------- /TaskTabsManager.h: -------------------------------------------------------------------------------- 1 | #ifndef TASKTABSMANAGER_H 2 | #define TASKTABSMANAGER_H 3 | 4 | #include "ui/TaskTab.h" 5 | 6 | #include 7 | #include 8 | 9 | class MainWindow; 10 | 11 | class TaskTabsManager : public QObject 12 | { 13 | Q_OBJECT 14 | 15 | MainWindow *m_mainwindow = nullptr; 16 | QMap m_taskTabsMap; 17 | unsigned int m_idCounter = 0; 18 | QMap m_taskFilePathsMap; // may contains old closed tab paths of file, but should be updated with opened tasks 19 | public: 20 | explicit TaskTabsManager(MainWindow *parent = nullptr); 21 | ~TaskTabsManager(); 22 | void forceCloseTask(int id); 23 | void scheduleTaskFromId(int id, qint64 delay); 24 | public slots: 25 | int onOpenNewTabRequest(const QString & path); 26 | void onTabCloseRequest(int index); 27 | void onRefreshTabsRequest(); 28 | void onTaskfilePathChanged(QString oldpath, QString newpath); 29 | void stopAllRunningTasksReceived(); 30 | void saveTaskReceived(int taskTabId, bool verbose = false); 31 | QJsonObject actionToJson(AbstractAction *act); 32 | AbstractAction* jsonToAction(const QJsonObject &jobj); 33 | void saveAllTasks(); 34 | bool isAnyTaskModified(); 35 | protected: 36 | TaskTab* createEmptyTaskAndOpenTab(const QString& name); 37 | int appendTaskInMap(TaskTab* task); 38 | int getIdfromTaskName(const QString &name) const; 39 | int getTabIndexfomId(int id) const; 40 | void createAndLoadTaskObject(int id); 41 | 42 | friend class MainWindow; 43 | }; 44 | 45 | #endif // TASKTABSMANAGER_H 46 | -------------------------------------------------------------------------------- /TaskThread.cpp: -------------------------------------------------------------------------------- 1 | #include "TaskThread.h" 2 | 3 | TaskThread::TaskThread(QObject *parent) 4 | : QThread{parent} 5 | { 6 | 7 | } 8 | 9 | TaskThread::~TaskThread() 10 | { 11 | qDeleteAll(m_actionsList); 12 | quit(); 13 | requestInterruption(); 14 | wait(); 15 | } 16 | 17 | void TaskThread::copyActionsList(Task *task) 18 | { 19 | qDeleteAll(m_actionsList); 20 | m_actionsList.clear(); 21 | 22 | if(task == nullptr) 23 | return; 24 | 25 | for(auto it = task->m_actionsOrderedList.begin(); it != task->m_actionsOrderedList.end(); ++it) 26 | { 27 | if((*it) == nullptr) 28 | continue; 29 | m_actionsList.append((*it)->deepCopy()); 30 | } 31 | } 32 | 33 | void TaskThread::stop() 34 | { 35 | m_haveToStop = true; 36 | //quit(); 37 | terminate(); 38 | } 39 | 40 | void TaskThread::run() 41 | { 42 | begin: 43 | 44 | for(auto it = m_actionsList.begin(); it != m_actionsList.end(); ++it) 45 | { 46 | if(m_haveToStop) 47 | return; 48 | 49 | if((*it) == nullptr) 50 | continue; 51 | emit sendRunningStateAct((*it)->getRefID()); 52 | 53 | (*it)->runAction(); 54 | 55 | if((*it) == nullptr) 56 | continue; 57 | emit sendDoneStateAct((*it)->getRefID()); 58 | } 59 | 60 | --m_timesToRun; 61 | if(m_loop || m_timesToRun > 0) 62 | { 63 | emit sendFinishedOneLoop(); 64 | goto begin; 65 | } 66 | 67 | emit sendFinishedOneLoop(); 68 | } 69 | -------------------------------------------------------------------------------- /TaskThread.h: -------------------------------------------------------------------------------- 1 | #ifndef TASKTHREAD_H 2 | #define TASKTHREAD_H 3 | 4 | #include "Task.h" 5 | 6 | #include 7 | 8 | class TaskThread : public QThread 9 | { 10 | Q_OBJECT 11 | QList m_actionsList; 12 | public: 13 | explicit TaskThread(QObject *parent = nullptr); 14 | ~TaskThread(); 15 | private: 16 | void copyActionsList(Task *task); 17 | bool m_loop = false; 18 | unsigned int m_timesToRun = 1; 19 | bool m_haveToStop = false; 20 | public slots: 21 | void stop(); 22 | protected: 23 | void run() override; 24 | 25 | signals: 26 | void sendRunningStateAct(unsigned int actId); 27 | void sendDoneStateAct(unsigned int actId); 28 | void sendFinishedOneLoop(); 29 | 30 | friend class TaskTab; 31 | }; 32 | 33 | #endif // TASKTHREAD_H 34 | -------------------------------------------------------------------------------- /actions/AbstractAction.cpp: -------------------------------------------------------------------------------- 1 | #include "AbstractAction.h" 2 | 3 | unsigned int AbstractAction::s_idCounter = 0; 4 | 5 | AbstractAction::AbstractAction() 6 | { 7 | e_type = ActionType::Undefined; 8 | m_ID = ++s_idCounter; // No action with id = 0 9 | } 10 | -------------------------------------------------------------------------------- /actions/AbstractAction.h: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACTACTION_H 2 | #define ABSTRACTACTION_H 3 | 4 | #include "actions/ActionParameters.h" 5 | 6 | enum class ActionType { 7 | Undefined, 8 | Paste, 9 | Wait, 10 | KeysSequence, 11 | SystemCommand, 12 | CursorMovements 13 | }; 14 | 15 | class AbstractAction 16 | { 17 | static unsigned int s_idCounter; 18 | protected: 19 | unsigned int m_ID = 0; 20 | unsigned int m_refID = 0; 21 | public: 22 | AbstractAction(); 23 | virtual ~AbstractAction() = default; 24 | AbstractAction(const AbstractAction & other) = delete; 25 | AbstractAction& operator=(const AbstractAction & other) = delete; 26 | 27 | virtual void runAction() const = 0; 28 | virtual void setParameters(const ActionParameters& param) = 0; 29 | virtual AbstractAction* deepCopy() const = 0; 30 | virtual ActionParameters generateParameters() const = 0; 31 | virtual void optionalProcesses() = 0; 32 | 33 | ActionType e_type; 34 | unsigned int getID() const {return m_ID;} 35 | unsigned int getRefID() const {return m_refID;} 36 | }; 37 | 38 | #endif // ABSTRACTACTION_H 39 | -------------------------------------------------------------------------------- /actions/ActionParameters.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTIONPARAMETERS_H 2 | #define ACTIONPARAMETERS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | typedef QPair ReleaseDelayKeysPair;// release delay in milisecond, list of keys as strings 11 | typedef QMap PressedReleaseDelaysKeysMap;// pressed time in milisecond, pair of release delay, list of keys 12 | Q_DECLARE_METATYPE(ReleaseDelayKeysPair); 13 | Q_DECLARE_METATYPE(PressedReleaseDelaysKeysMap); 14 | typedef QList MovementList;// delays (from previous move) in milisecond, moving time in milisecond, screen x,y (4 elements) 15 | typedef QList CursorMovementsList;// delays in milisecond and its movement (time and x,y) 16 | Q_DECLARE_METATYPE(MovementList); 17 | Q_DECLARE_METATYPE(CursorMovementsList); 18 | 19 | class ActionParameters 20 | { 21 | public: 22 | ActionParameters() = default; 23 | ~ActionParameters() = default; 24 | ActionParameters(const ActionParameters &) = default; 25 | ActionParameters &operator=(const ActionParameters &) = default; 26 | 27 | QString m_dataId; 28 | QString m_pasteContent; 29 | long double m_waitDuration; // in seconds 30 | // map with key = delay of key simulated pressed in milisecond, value = pair of release delay (ms) and list of keys label 31 | PressedReleaseDelaysKeysMap m_keysSeqMap; 32 | int m_timesToRun = 1; 33 | QString m_sysCmdTypeStr; 34 | QString m_sysCmdParam1; 35 | QString m_sysCmdParam2; 36 | CursorMovementsList m_cursorMovementsList; 37 | QStringList m_cursorMovementsOptionalKeysStroke; 38 | }; 39 | 40 | Q_DECLARE_METATYPE(ActionParameters); 41 | 42 | #endif // ACTIONPARAMETERS_H 43 | -------------------------------------------------------------------------------- /actions/ActionsTools.h: -------------------------------------------------------------------------------- 1 | #ifndef ACTIONSTOOLS_H 2 | #define ACTIONSTOOLS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "actions/ActionParameters.h" 10 | 11 | class ActionsTools 12 | { 13 | static const int s_cursorFrequency = 20; 14 | public: 15 | ActionsTools(); 16 | ~ActionsTools() = default; 17 | 18 | static void pasteKeystrokeSimulate(); 19 | static void keyStokeSimulate(const QString & keyAsStr, DWORD typeOfPress); 20 | static void mouseStokeSimulate(const QString & keyAsStr, DWORD typeOfPress); 21 | static DWORD mouseFlagPressReleaseConversion(WORD keyInputWord, DWORD typeOfPress); 22 | static void setClipboard(const QString & str); 23 | static PressedReleaseDelaysKeysMap fromStandardQMapToKeysSeqMap(const QMap &standardMap); 24 | static QString fromKeysSeqMapToPrintedString(const PressedReleaseDelaysKeysMap &map); 25 | static QMap m_keysStrToInputWordMap; 26 | static QString fromCursorMovsMapToPrintedString(const CursorMovementsList &map); 27 | static CursorMovementsList fromStandardQMapToCursorMovsMap(const QList &standardList); 28 | static void moveCursorSimulate(int xPos, int yPos, int time); 29 | static QPair getCursorPos(); 30 | }; 31 | 32 | #endif // ACTIONSTOOLS_H 33 | -------------------------------------------------------------------------------- /actions/CursorMovementsAction.cpp: -------------------------------------------------------------------------------- 1 | #include "CursorMovementsAction.h" 2 | #include "actions/ActionsTools.h" 3 | 4 | CursorMovementsAction::CursorMovementsAction() : AbstractAction() 5 | { 6 | e_type = ActionType::CursorMovements; 7 | } 8 | 9 | void CursorMovementsAction::runAction() const 10 | { 11 | int timesToRun = m_timesToRun; 12 | 13 | begin: 14 | 15 | auto it = m_cursorMovementsList.begin(); 16 | while(it != m_cursorMovementsList.end()) 17 | { 18 | if(it->size() < 4) 19 | break; 20 | Sleep(it->at(0)); 21 | ActionsTools::moveCursorSimulate(it->at(2),it->at(3),it->at(1)); 22 | 23 | if(it == m_cursorMovementsList.begin()) 24 | { 25 | for(auto& pressStr : m_cursorMovementsOptionalKeysStroke) 26 | ActionsTools::keyStokeSimulate(pressStr, 0); 27 | } 28 | 29 | ++it; 30 | } 31 | 32 | for(auto& releaseStr : m_cursorMovementsOptionalKeysStroke) 33 | ActionsTools::keyStokeSimulate(releaseStr, KEYEVENTF_KEYUP); 34 | 35 | --timesToRun; 36 | if(timesToRun > 0) 37 | goto begin; 38 | } 39 | 40 | void CursorMovementsAction::setParameters(const ActionParameters ¶m) 41 | { 42 | m_cursorMovementsList = param.m_cursorMovementsList; 43 | m_movementsId = param.m_dataId; 44 | m_timesToRun = param.m_timesToRun; 45 | m_cursorMovementsOptionalKeysStroke = param.m_cursorMovementsOptionalKeysStroke; 46 | } 47 | 48 | CursorMovementsAction *CursorMovementsAction::deepCopy() const 49 | { 50 | CursorMovementsAction *actToReturn = new CursorMovementsAction(); 51 | actToReturn->m_cursorMovementsList = m_cursorMovementsList; 52 | actToReturn->m_movementsId = m_movementsId; 53 | actToReturn->m_timesToRun = m_timesToRun; 54 | actToReturn->m_cursorMovementsOptionalKeysStroke = m_cursorMovementsOptionalKeysStroke; 55 | actToReturn->m_refID = m_ID; 56 | return actToReturn; 57 | } 58 | 59 | ActionParameters CursorMovementsAction::generateParameters() const 60 | { 61 | ActionParameters param; 62 | param.m_cursorMovementsList = m_cursorMovementsList; 63 | param.m_dataId = m_movementsId; 64 | param.m_timesToRun = m_timesToRun; 65 | param.m_cursorMovementsOptionalKeysStroke = m_cursorMovementsOptionalKeysStroke; 66 | return param; 67 | } 68 | 69 | int CursorMovementsAction::computeOneExecutionDuration() 70 | { 71 | int returnedValue = 0; 72 | 73 | for(auto mov : m_cursorMovementsList) 74 | { 75 | if(mov.size() >= 2) 76 | returnedValue += mov[0] + mov[1]; 77 | } 78 | 79 | return returnedValue; 80 | 81 | } 82 | -------------------------------------------------------------------------------- /actions/CursorMovementsAction.h: -------------------------------------------------------------------------------- 1 | #ifndef CURSORMOVEMENTSACTION_H 2 | #define CURSORMOVEMENTSACTION_H 3 | 4 | #include "AbstractAction.h" 5 | 6 | class CursorMovementsAction : public AbstractAction 7 | { 8 | private: 9 | CursorMovementsList m_cursorMovementsList; 10 | QString m_movementsId; 11 | int m_timesToRun = 1; 12 | QStringList m_cursorMovementsOptionalKeysStroke; 13 | public: 14 | CursorMovementsAction(); 15 | ~CursorMovementsAction() = default; 16 | CursorMovementsAction(const CursorMovementsAction & other) = delete; 17 | CursorMovementsAction& operator=(const CursorMovementsAction & other) = delete; 18 | 19 | void runAction() const override; 20 | void setParameters(const ActionParameters& param) override; 21 | CursorMovementsAction *deepCopy() const override; 22 | ActionParameters generateParameters() const override; 23 | 24 | void optionalProcesses() override {} 25 | int computeOneExecutionDuration(); // in miliseconds 26 | 27 | friend class CursorMovementsWidget; 28 | }; 29 | 30 | #endif // CURSORMOVEMENTSACTION_H 31 | -------------------------------------------------------------------------------- /actions/KeysSequenceAction.cpp: -------------------------------------------------------------------------------- 1 | #include "KeysSequenceAction.h" 2 | #include "actions/ActionsTools.h" 3 | 4 | KeysSequenceAction::KeysSequenceAction() : AbstractAction() 5 | { 6 | e_type = ActionType::KeysSequence; 7 | } 8 | 9 | void KeysSequenceAction::runAction() const 10 | { 11 | int timesToRun = m_timesToRun; 12 | 13 | begin: 14 | 15 | auto it = m_keysStrokeTimeline.begin(); 16 | while(it != m_keysStrokeTimeline.end()) 17 | { 18 | int time = it.key(); 19 | auto vecOfStrokes = it.value(); 20 | if(vecOfStrokes.size() < 2) 21 | continue; 22 | 23 | for(auto& pressStr : vecOfStrokes[0]) 24 | ActionsTools::keyStokeSimulate(pressStr, 0); 25 | 26 | for(auto& releaseStr : vecOfStrokes[1]) 27 | ActionsTools::keyStokeSimulate(releaseStr, KEYEVENTF_KEYUP); 28 | ++it; 29 | if(it != m_keysStrokeTimeline.end()) 30 | Sleep(it.key() - time); 31 | } 32 | 33 | Sleep(100); 34 | 35 | --timesToRun; 36 | if(timesToRun > 0) 37 | goto begin; 38 | } 39 | 40 | void KeysSequenceAction::setParameters(const ActionParameters ¶m) 41 | { 42 | m_keysSeqMap = param.m_keysSeqMap; 43 | m_sequenceId = param.m_dataId; 44 | m_timesToRun = param.m_timesToRun; 45 | } 46 | 47 | KeysSequenceAction *KeysSequenceAction::deepCopy() const 48 | { 49 | KeysSequenceAction *actToReturn = new KeysSequenceAction(); 50 | actToReturn->m_keysSeqMap = m_keysSeqMap; 51 | actToReturn->m_sequenceId = m_sequenceId; 52 | actToReturn->m_keysStrokeTimeline = m_keysStrokeTimeline; 53 | actToReturn->m_timesToRun = m_timesToRun; 54 | actToReturn->m_refID = m_ID; 55 | return actToReturn; 56 | } 57 | 58 | ActionParameters KeysSequenceAction::generateParameters() const 59 | { 60 | ActionParameters param; 61 | param.m_keysSeqMap = m_keysSeqMap; 62 | param.m_dataId = m_sequenceId; 63 | param.m_timesToRun = m_timesToRun; 64 | return param; 65 | } 66 | 67 | void KeysSequenceAction::generateTimeline() 68 | { 69 | m_keysStrokeTimeline.clear(); 70 | for(auto [key,val] : m_keysSeqMap.asKeyValueRange()) 71 | { 72 | int releaseKey = key + val.first; // time + release after time 73 | 74 | if(m_keysStrokeTimeline.contains(key)) // in that case, we append keys in the press stroke keys list 75 | { 76 | auto vecOfStrokes = m_keysStrokeTimeline.value(key); 77 | if(vecOfStrokes.size() == 2) 78 | { 79 | vecOfStrokes[0].append(val.second); 80 | m_keysStrokeTimeline.insert(key, vecOfStrokes); 81 | } 82 | } 83 | else // else we create the entry with the pressed keys 84 | { 85 | QVector vecToInsert; 86 | vecToInsert.append(val.second); 87 | vecToInsert.append(QStringList()); 88 | m_keysStrokeTimeline.insert(key,vecToInsert); 89 | } 90 | 91 | if(m_keysStrokeTimeline.contains(releaseKey)) // in that case, we append keys in the release stroke keys list 92 | { 93 | auto vecOfStrokes = m_keysStrokeTimeline.value(releaseKey); 94 | if(vecOfStrokes.size() == 2) 95 | { 96 | vecOfStrokes[1].append(val.second); 97 | m_keysStrokeTimeline.insert(releaseKey, vecOfStrokes); 98 | } 99 | } 100 | else // else we create the entry with the release keys 101 | { 102 | QVector vecToInsert; 103 | vecToInsert.append(QStringList()); 104 | vecToInsert.append(val.second); 105 | m_keysStrokeTimeline.insert(releaseKey,vecToInsert); 106 | } 107 | } 108 | } 109 | 110 | int KeysSequenceAction::computeOneExecutionDuration() 111 | { 112 | int returnedValue = 0; 113 | 114 | for(auto [key,val] : m_keysSeqMap.asKeyValueRange()) 115 | { 116 | int thisKeyStops = key + val.first; 117 | if(thisKeyStops > returnedValue) 118 | returnedValue = thisKeyStops; 119 | } 120 | 121 | return returnedValue+100; // 0.1 second as the minimal time wait for each execution 122 | } 123 | -------------------------------------------------------------------------------- /actions/KeysSequenceAction.h: -------------------------------------------------------------------------------- 1 | #ifndef KEYSSEQUENCEACTION_H 2 | #define KEYSSEQUENCEACTION_H 3 | 4 | #include "AbstractAction.h" 5 | 6 | class KeysSequenceAction : public AbstractAction 7 | { 8 | private: 9 | PressedReleaseDelaysKeysMap m_keysSeqMap; 10 | QString m_sequenceId; 11 | QMap> m_keysStrokeTimeline; // Timeline of keys to stroke, each time contain 2 vectors : [0] press keys list [1] released keys list 12 | int m_timesToRun = 1; 13 | public: 14 | KeysSequenceAction(); 15 | ~KeysSequenceAction() = default; 16 | KeysSequenceAction(const KeysSequenceAction & other) = delete; 17 | KeysSequenceAction& operator=(const KeysSequenceAction & other) = delete; 18 | 19 | void runAction() const override; 20 | void setParameters(const ActionParameters& param) override; 21 | KeysSequenceAction *deepCopy() const override; 22 | ActionParameters generateParameters() const override; 23 | 24 | void generateTimeline(); 25 | void optionalProcesses() override {generateTimeline();} 26 | int computeOneExecutionDuration(); // in miliseconds 27 | 28 | friend class KeysSequenceWidget; 29 | }; 30 | 31 | #endif // KEYSSEQUENCEACTION_H 32 | -------------------------------------------------------------------------------- /actions/PasteAction.cpp: -------------------------------------------------------------------------------- 1 | #include "PasteAction.h" 2 | #include "ActionsTools.h" 3 | 4 | #include 5 | 6 | PasteAction::PasteAction() : AbstractAction() 7 | { 8 | e_type = ActionType::Paste; 9 | } 10 | 11 | void PasteAction::runAction() const 12 | { 13 | int timesToRun = m_timesToRun; 14 | 15 | begin: 16 | 17 | ActionsTools::setClipboard(m_content); 18 | ActionsTools::pasteKeystrokeSimulate(); 19 | 20 | --timesToRun; 21 | if(timesToRun > 0) 22 | goto begin; 23 | } 24 | 25 | void PasteAction::setParameters(const ActionParameters ¶m) 26 | { 27 | m_content = param.m_pasteContent; 28 | m_contentId = param.m_dataId; 29 | m_timesToRun = param.m_timesToRun; 30 | } 31 | 32 | PasteAction *PasteAction::deepCopy() const 33 | { 34 | PasteAction *actToReturn = new PasteAction(); 35 | actToReturn->m_content = m_content; 36 | actToReturn->m_contentId = m_contentId; 37 | actToReturn->m_timesToRun = m_timesToRun; 38 | actToReturn->m_refID = m_ID; 39 | return actToReturn; 40 | } 41 | 42 | ActionParameters PasteAction::generateParameters() const 43 | { 44 | ActionParameters param; 45 | param.m_pasteContent = m_content; 46 | param.m_dataId = m_contentId; 47 | param.m_timesToRun = m_timesToRun; 48 | return param; 49 | } 50 | 51 | int PasteAction::computeOneExecutionDuration() 52 | { 53 | return 200;// 0.2 second as the minimal time wait for each execution 54 | } 55 | -------------------------------------------------------------------------------- /actions/PasteAction.h: -------------------------------------------------------------------------------- 1 | #ifndef PASTEACTION_H 2 | #define PASTEACTION_H 3 | 4 | #include "AbstractAction.h" 5 | 6 | class PasteAction : public AbstractAction 7 | { 8 | private: 9 | QString m_content; 10 | QString m_contentId; 11 | int m_timesToRun = 1; 12 | public: 13 | PasteAction(); 14 | ~PasteAction() = default; 15 | PasteAction(const PasteAction & other) = delete; 16 | PasteAction& operator=(const PasteAction & other) = delete; 17 | 18 | void runAction() const override; 19 | void setParameters(const ActionParameters& param) override; 20 | PasteAction* deepCopy() const override; 21 | ActionParameters generateParameters() const override; 22 | void optionalProcesses() override {} 23 | int computeOneExecutionDuration(); // in miliseconds 24 | 25 | friend class PasteWidget; 26 | }; 27 | 28 | #endif // PASTEACTION_H 29 | -------------------------------------------------------------------------------- /actions/SystemCommandsAction.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEMCOMMANDSACTION_H 2 | #define SYSTEMCOMMANDSACTION_H 3 | 4 | #include "AbstractAction.h" 5 | 6 | enum class SystemCommandType { 7 | Undefined, 8 | ShutDown, 9 | Restart, 10 | LogOff, 11 | ChangeAudioVolume, 12 | ChangeDefaultAudioDevice, 13 | KillProcess, 14 | QuitSelfProgram, 15 | CreateFolder, 16 | DeleteFolder, 17 | CreateOneFile, 18 | DeleteOneFile, 19 | TakeScreenshot, 20 | PrintActualScreen, 21 | OpenFile, 22 | CopyOneFile, 23 | ExecuteProgram, 24 | OpenUrl, 25 | OpenFolder 26 | }; 27 | 28 | class SystemCommandAction : public AbstractAction 29 | { 30 | public: 31 | SystemCommandAction(); 32 | ~SystemCommandAction() = default; 33 | SystemCommandAction(const SystemCommandAction & other) = delete; 34 | SystemCommandAction& operator=(const SystemCommandAction & other) = delete; 35 | 36 | void runAction() const override; 37 | void setParameters(const ActionParameters& param) override; 38 | SystemCommandAction *deepCopy() const override; 39 | ActionParameters generateParameters() const override; 40 | void optionalProcesses() override {} 41 | 42 | void executeCommand(const QString & cmd,const QString & option) const; 43 | 44 | SystemCommandType e_sysCommandType; 45 | QString m_param1; 46 | QString m_param2; 47 | 48 | QString incrementFilenameIfExists(const QString & path) const; 49 | QString incrementFilenameIfExists(const QString & path, unsigned char ndigits) const; 50 | }; 51 | 52 | #endif // SYSTEMCOMMANDSACTION_H 53 | -------------------------------------------------------------------------------- /actions/WaitAction.cpp: -------------------------------------------------------------------------------- 1 | #include "WaitAction.h" 2 | #include 3 | 4 | #include 5 | 6 | WaitAction::WaitAction() : AbstractAction() 7 | { 8 | e_type = ActionType::Wait; 9 | } 10 | 11 | void WaitAction::runAction() const 12 | { 13 | Sleep(m_duration*1000); 14 | //QThread::msleep((int)(m_duration*1000)); 15 | } 16 | 17 | void WaitAction::setParameters(const ActionParameters ¶m) 18 | { 19 | m_duration = param.m_waitDuration; 20 | } 21 | 22 | WaitAction *WaitAction::deepCopy() const 23 | { 24 | WaitAction *actToReturn = new WaitAction(); 25 | actToReturn->m_duration = m_duration; 26 | actToReturn->m_refID = m_ID; 27 | return actToReturn; 28 | } 29 | 30 | ActionParameters WaitAction::generateParameters() const 31 | { 32 | ActionParameters param; 33 | param.m_waitDuration = m_duration; 34 | return param; 35 | } 36 | -------------------------------------------------------------------------------- /actions/WaitAction.h: -------------------------------------------------------------------------------- 1 | #ifndef WAITACTION_H 2 | #define WAITACTION_H 3 | 4 | #include "AbstractAction.h" 5 | 6 | class WaitAction : public AbstractAction 7 | { 8 | private: 9 | long double m_duration; // in seconds 10 | public: 11 | WaitAction(); 12 | ~WaitAction() = default; 13 | WaitAction(const WaitAction & other) = delete; 14 | WaitAction& operator=(const WaitAction & other) = delete; 15 | 16 | void runAction() const override; 17 | void setParameters(const ActionParameters& param) override; 18 | WaitAction* deepCopy() const override; 19 | ActionParameters generateParameters() const override; 20 | void optionalProcesses() override {} 21 | 22 | friend class WaitWidget; 23 | }; 24 | 25 | #endif // WAITACTION_H 26 | -------------------------------------------------------------------------------- /globals.h: -------------------------------------------------------------------------------- 1 | #ifndef GLOBALS_H 2 | #define GLOBALS_H 3 | #include 4 | #include 5 | 6 | namespace G_Files { 7 | inline QString SettingsFilePath = "programSettings.ini"; 8 | inline QString DataFilePath = "programData.ini"; 9 | inline QString SentencesDataCategory = "sentences/"; 10 | inline QString KeysSequencesDataCategory = "keyssequences/"; 11 | inline QString CursorMovementsDataCategory = "cursormovements/"; 12 | inline QString DocumentIdentification_KeyWord = "docType"; 13 | inline QString DocumentIdentification_Value = "ScheduleTask File"; 14 | inline QString DocumentTaskDescription_KeyWord = "description"; 15 | inline QString DocumentActionsArray_KeyWord = "actions"; 16 | inline QString ActionType_KeyWord = "type"; 17 | inline QString ActionPasteType_Value = "paste"; 18 | inline QString ActionWaitType_Value = "wait"; 19 | inline QString ActionSystemCommandeType_Value = "systemcommand"; 20 | inline QString ActionKeysSequenceType_Value = "keyssequence"; 21 | inline QString ActionCursorMovementsType_Value = "cursormovements"; 22 | inline QString ActionContent_KeyWord = "content"; 23 | inline QString ActionContentId_KeyWord = "contentId"; 24 | inline QString ActionPasteTextLoop_KeyWord = "loop"; 25 | inline QString ActionDuration_KeyWord = "duration"; 26 | inline QString ActionKeysSeqMap_KeyWord = "keysmap"; 27 | inline QString ActionKeysSeqId_KeyWord = "keysSeqId"; 28 | inline QString ActionKeysSeqLoop_KeyWord = "loop"; 29 | inline QString ActionSysCommandType_KeyWord = "sysCommandType"; 30 | inline QString ActionSysCommandParam1_KeyWord = "sysCommandParam1"; 31 | inline QString ActionSysCommandParam2_KeyWord = "sysCommandParam2"; 32 | inline QString ActionCursorMovsMap_KeyWord = "cursormovsmap"; 33 | inline QString ActionCursorMovsId_KeyWord = "cursorMovsId"; 34 | inline QString ActionCursorMovsLoop_KeyWord = "loop"; 35 | inline QString ActionCursorMovsOptKeysStroke_KeyWord = "optionalkeysstroke"; 36 | inline QString TasksFolder = "saved_tasks/"; 37 | inline QString TasksFileExtension = ".scht"; 38 | inline QString StartupTasksParams_KeyWord = "startupTasksParams"; 39 | inline QString SystemStartupRegistry_Path = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; 40 | inline QString ProgramNameInRegistry_KeyWord = "ScheduledPCTask"; 41 | } 42 | 43 | namespace G_Sentences { 44 | static QString AlreadyExists() {return QObject::tr("A task file with the chosen name already exists, do you confirm that you would like to overwrite this one ?");} 45 | static QString NoFileSelected() {return QObject::tr("No file has been selected from the table of saved files above. Please select one.");} 46 | static QString OperationInterference() {return QObject::tr("Some system or user action interferes with this operation, sorry for the inconvenience.");} 47 | static QString ForbiddenCharacter() {return QObject::tr("The filename contains some forbidden characters (<>:/\"|?*\\), please change it.");} 48 | static QString FileParsingError() {return QObject::tr("The file is not in the correct format for this software : parse error.");} 49 | static QString NoSetenceSelected() {return QObject::tr("No sentence has been selected. Please select one.");} 50 | static QString NoKeysSequenceSelected() {return QObject::tr("No keys sequence has been selected. Please select one.");} 51 | static QString NoCursorMovementsSelected() {return QObject::tr("No cursor movements set has been selected. Please select one.");} 52 | static QString NoStartupTaskSelected() {return QObject::tr("No startup task has been selected. Please select one.");} 53 | } 54 | 55 | namespace G_SystemCommands { 56 | inline QString UndefinedType = "undefined"; 57 | inline QString ShutDownType = "shutdown"; 58 | inline QString RestartType = "restart"; 59 | inline QString LogOffType = "logoff"; 60 | inline QString ChangeAudioVolumeType = "changevolume"; 61 | inline QString ChangeDefaultAudioDeviceType = "changeaudiodevice"; 62 | inline QString KillProcessType = "killprocess"; 63 | inline QString QuitSelfProgramType = "quitselfprogram"; 64 | inline QString CreateFolderType = "createfolder"; 65 | inline QString DeleteFolderType = "deletefolder"; 66 | inline QString CreateFileType = "createfile"; 67 | inline QString DeleteFileType = "deletefile"; 68 | inline QString TakeScreenshotType = "screenshot"; 69 | inline QString PrintActualScreenType = "printscreen"; 70 | inline QString OpenFileType = "openfile"; 71 | inline QString ExecuteProgramType = "executeprogram"; 72 | inline QString OpenUrlType = "openurl"; 73 | inline QString OpenFolderType = "openfolder"; 74 | inline QString CopyFileType = "copyfile"; 75 | } 76 | 77 | struct G_Parameters { 78 | static bool AutoScrollTask; 79 | }; 80 | 81 | #endif // GLOBALS_H 82 | -------------------------------------------------------------------------------- /img/bottom_arrow_rounded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/bottom_arrow_rounded.png -------------------------------------------------------------------------------- /img/browseFolder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/browseFolder.png -------------------------------------------------------------------------------- /img/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/check.png -------------------------------------------------------------------------------- /img/check_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/check_light.png -------------------------------------------------------------------------------- /img/check_penombra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/check_penombra.png -------------------------------------------------------------------------------- /img/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/close.png -------------------------------------------------------------------------------- /img/close_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/close_light.png -------------------------------------------------------------------------------- /img/close_penombra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/close_penombra.png -------------------------------------------------------------------------------- /img/close_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/close_red.png -------------------------------------------------------------------------------- /img/crosshair.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/crosshair.png -------------------------------------------------------------------------------- /img/cursor-cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/cursor-cross.png -------------------------------------------------------------------------------- /img/cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/cursor.png -------------------------------------------------------------------------------- /img/darkTheme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/darkTheme.png -------------------------------------------------------------------------------- /img/down_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/down_arrow.png -------------------------------------------------------------------------------- /img/down_arrow_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/down_arrow_light.png -------------------------------------------------------------------------------- /img/down_arrow_penombra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/down_arrow_penombra.png -------------------------------------------------------------------------------- /img/down_arrow_rounded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/down_arrow_rounded.png -------------------------------------------------------------------------------- /img/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/key.png -------------------------------------------------------------------------------- /img/left_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/left_arrow.png -------------------------------------------------------------------------------- /img/left_arrow_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/left_arrow_light.png -------------------------------------------------------------------------------- /img/left_arrow_penombra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/left_arrow_penombra.png -------------------------------------------------------------------------------- /img/lightTheme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/lightTheme.png -------------------------------------------------------------------------------- /img/noscroll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/noscroll.png -------------------------------------------------------------------------------- /img/penombraTheme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/penombraTheme.png -------------------------------------------------------------------------------- /img/pinned.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/pinned.png -------------------------------------------------------------------------------- /img/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/play.png -------------------------------------------------------------------------------- /img/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/plus.png -------------------------------------------------------------------------------- /img/programIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/programIcon.ico -------------------------------------------------------------------------------- /img/programIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/programIcon.png -------------------------------------------------------------------------------- /img/right_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/right_arrow.png -------------------------------------------------------------------------------- /img/right_arrow_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/right_arrow_light.png -------------------------------------------------------------------------------- /img/right_arrow_penombra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/right_arrow_penombra.png -------------------------------------------------------------------------------- /img/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/save.png -------------------------------------------------------------------------------- /img/scroll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/scroll.png -------------------------------------------------------------------------------- /img/startup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/startup.png -------------------------------------------------------------------------------- /img/systemCommand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/systemCommand.png -------------------------------------------------------------------------------- /img/text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/text.png -------------------------------------------------------------------------------- /img/top_arrow_rounded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/top_arrow_rounded.png -------------------------------------------------------------------------------- /img/undock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/undock.png -------------------------------------------------------------------------------- /img/undock_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/undock_light.png -------------------------------------------------------------------------------- /img/undock_penombra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/undock_penombra.png -------------------------------------------------------------------------------- /img/unpinned.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/unpinned.png -------------------------------------------------------------------------------- /img/up_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/up_arrow.png -------------------------------------------------------------------------------- /img/up_arrow_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/up_arrow_light.png -------------------------------------------------------------------------------- /img/up_arrow_penombra.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/up_arrow_penombra.png -------------------------------------------------------------------------------- /img/up_arrow_rounded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/up_arrow_rounded.png -------------------------------------------------------------------------------- /img/wait.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmirHammouteneEI/ScheduledPasteAndKeys/f5b5eb5179428f2a93cf6ef0d14d6f5bd5c58b9a/img/wait.png -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /*** 2 | * Amir Hammmoutene (contact@amirhammoutene.dev) 3 | * March 2024 4 | * This program, made for Windows systems, can be used to schedule some action on users computer automatically. 5 | * Code is in C++ language, using Qt framework (version 6.7.1) 6 | * Open-source, under GNU general public license version 3 7 | ***/ 8 | 9 | #include "mainwindow.h" 10 | #include "actions/ActionParameters.h" 11 | 12 | #include 13 | #include 14 | 15 | int main(int argc, char *argv[]) 16 | { 17 | QApplication a(argc, argv); // Application as a Qt ui-framework object 18 | // Registering metatype to be used in signals/slots of Qt mecanism 19 | qRegisterMetaType(); 20 | qRegisterMetaType(); 21 | qRegisterMetaType(); 22 | qRegisterMetaType(); 23 | qRegisterMetaType(); 24 | 25 | a.setWindowIcon(QIcon(":/img/programIcon.png")); 26 | 27 | // Get local system language to apply translations is exists 28 | QString locale = QLocale::system().name().section('_', 0, 0); 29 | QTranslator translator; 30 | translator.load(QString("ScheduledPCTasks_") + locale); 31 | QTranslator baseTranslator; 32 | baseTranslator.load(QString("qtbase_") + locale); 33 | a.installTranslator(&translator); 34 | a.installTranslator(&baseTranslator); 35 | 36 | // Main ui window 37 | MainWindow w; 38 | 39 | // In case of program used with correct arguments, automatically run the task (usage : ScheduledPCTasks.exe "TaskFileName" ) 40 | if(argc == 3) 41 | { 42 | int delay = atoi(argv[2]); 43 | if(delay > 0) 44 | w.autoRun(QString(argv[1]), delay); 45 | else 46 | w.showWindow(); 47 | } 48 | else 49 | w.showWindow(); 50 | 51 | return a.exec(); 52 | } 53 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "ui/CreateLoadTaskDialog.h" 9 | #include "TaskTabsManager.h" 10 | #include "ui/DataEditDialog.h" 11 | #include "ui/StartupTasksDialog.h" 12 | 13 | QT_BEGIN_NAMESPACE 14 | namespace Ui { 15 | class MainWindow; 16 | } 17 | QT_END_NAMESPACE 18 | 19 | class MainWindow : public QMainWindow 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | MainWindow(QWidget *parent = nullptr); 25 | ~MainWindow(); 26 | QTabWidget * getTabWidget(); // ui container of TaskTabs 27 | void autoRun(const QString & filename, int delay); // automatically run a task in silent mode (no window appears) 28 | QShortcut *m_stopAllTasksShortcut; 29 | public slots: 30 | void showWindow(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Trigger); // show mainwindow or systemtray icon menu (if right click on icon) 31 | void quitApp(); // stops all running tasks (forced), asks to saved modified tasks and quit the program 32 | private slots: 33 | void swapStayOnTop(bool state); 34 | void swapAutoscrollMode(bool state); // autoscroll force the action widget visible when running the action 35 | void switchTheme(); // set stylesheet 36 | void taskTabPageClicked(int newIndex); 37 | void taskTabContextMenuRequest(QPoint point); 38 | protected : 39 | QSystemTrayIcon* m_sticon; 40 | void setTheme(); // simulate trigger on the appropriate theme button 41 | void buildToolBar(); 42 | void buildSystemTrayMenu(); 43 | void closeEvent(QCloseEvent *event) override; 44 | int m_windowWidth = 510; 45 | int m_windowHeight = 800; 46 | void geometrySet(); 47 | void loadSettings(); 48 | void saveSettings(); 49 | QAction *m_stayOnTopAction; 50 | QAction * m_lightThemeAction; 51 | QAction * m_penombraThemeAction; 52 | QAction * m_darkThemeAction; 53 | QAction * m_scrollAction; 54 | QString m_currentThemeName; 55 | CreateLoadTaskDialog *m_createLoadTaskDialog; 56 | DataEditDialog *m_dataEditDialog; 57 | StartupTasksDialog *m_startupTasksDialog; 58 | TaskTabsManager* m_tasktabsManager; 59 | QMenu *m_stmenu; 60 | QToolBar *m_toolBar; 61 | bool m_stMessageShown = false; 62 | private: 63 | Ui::MainWindow *ui; 64 | }; 65 | #endif // MAINWINDOW_H 66 | -------------------------------------------------------------------------------- /private_policy.txt: -------------------------------------------------------------------------------- 1 | ___Privacy Policy___ 2 | Last updated: March 18, 2024 3 | 4 | This Privacy Policy describes Our policies and procedures on the collection, use and disclosure of your information 5 | 6 | By using the application "Scheduled PC Tasks" you are consenting to our policies regarding the collection, use and disclosure of personal information set out in this privacy policy. 7 | 8 | __Definition__ 9 | 10 | - Application : refers to Scheduled PC Tasks, the software program provided by the Us. 11 | - You : means the individual accessing or using the Application, or the company, or other legal entity on behalf of which such individual is accessing or using the Application, as applicable. 12 | - Us : means the conceptor and developer of the software, in the person of Amir Hammoutene 13 | 14 | __Collection of Personal Information__ 15 | 16 | We do not collect, store, use or share any information, personal or otherwise. 17 | 18 | __Email__ 19 | 20 | If you email the developer for support or other feedback, the emails with email addresses will be retained for quality assurance purposes. The email addresses will be used only to reply to the concerns or suggestions raised and will never be used for any marketing purpose. 21 | 22 | __Disclosure of Personal Information__ 23 | 24 | We will not disclose your information to any third party except if you expressly consent or where required by law. 25 | 26 | __Contact Us__ 27 | 28 | If you have any questions regarding this privacy policy, you can email : contact@amirhammoutene.dev -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | # Scheduled PC Tasks 2 | 3 | version 1.3 (January 2025) 4 | 5 | Schedule automated simulations of actions you would perform on your PC. 6 | 7 | 8 | Under GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 9 | Please read license.txt file 10 | 11 | We don't collect any data 12 | Please read private_policy.txt 13 | 14 | ---------- 15 | Details of version 1.3: 16 | 17 | Stable version, fully functional 18 | 19 | Those actions simulations are available : 20 | 21 | - Keys sequence 22 | - Move Cursor 23 | - Paste text 24 | - Open files, folders, executables, url 25 | - Run Windows system specific command (shut down, reboot, kill processes, create files...) 26 | - Wait 27 | 28 | And other features like data management, scheduled tasks at system startup... 29 | 30 | The goal in future versions is to include those actions : 31 | 32 | - Play sounds 33 | - Add more Windows system specific command 34 | 35 | Working on a Linux system version. 36 | 37 | Feedbacks and ideas for further actions are very welcome ! 38 | 39 | ---------- 40 | Available for install on Microsoft Store : 41 | https://apps.microsoft.com/store/detail/XP9CJLHWVXS49P 42 | 43 | Available as a portable version : 44 | https://files.amirhammoutene.dev/ScheduledPCTasks/1.3/Scheduled_PC_Tasks_v1.3.zip 45 | 46 | Needs 30 Mo disk space, available for Windows systems only 47 | 48 | ---------- 49 | Presentation video is available on Youtube : 50 | https://www.youtube.com/watch?v=ue6FPNrjD4c 51 | 52 | ---------- 53 | Has been developed in C++ language, using Qt (6.7.1) framework 54 | 55 | Open Source 56 | 57 | GitHub link for sources : https://github.com/AmirHammouteneEI/ScheduledPasteAndKeys 58 | 59 | ---------- 60 | Conceived and developed by Amir Hammoutene (contact@amirhammoutene.dev). 61 | 62 | Initial work in February 2024. -------------------------------------------------------------------------------- /resources.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | img/programIcon.png 4 | img/pinned.png 5 | img/unpinned.png 6 | img/darkTheme.png 7 | img/lightTheme.png 8 | img/penombraTheme.png 9 | style/dark.qss 10 | style/light.qss 11 | style/penombra.qss 12 | img/check.png 13 | img/check_light.png 14 | img/check_penombra.png 15 | img/close.png 16 | img/close_light.png 17 | img/close_penombra.png 18 | img/down_arrow_light.png 19 | img/down_arrow_penombra.png 20 | img/left_arrow.png 21 | img/left_arrow_light.png 22 | img/left_arrow_penombra.png 23 | img/right_arrow.png 24 | img/right_arrow_light.png 25 | img/right_arrow_penombra.png 26 | img/undock.png 27 | img/undock_light.png 28 | img/undock_penombra.png 29 | img/up_arrow.png 30 | img/up_arrow_light.png 31 | img/up_arrow_penombra.png 32 | img/plus.png 33 | img/close_red.png 34 | img/bottom_arrow_rounded.png 35 | img/down_arrow_rounded.png 36 | img/top_arrow_rounded.png 37 | img/up_arrow_rounded.png 38 | img/text.png 39 | img/wait.png 40 | img/save.png 41 | img/noscroll.png 42 | img/scroll.png 43 | img/down_arrow.png 44 | img/key.png 45 | img/systemCommand.png 46 | img/browseFolder.png 47 | img/cursor.png 48 | img/play.png 49 | img/cursor-cross.png 50 | img/crosshair.png 51 | img/startup.png 52 | 53 | 54 | -------------------------------------------------------------------------------- /ui/CreateLoadTaskDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATELOADTASKDIALOG_H 2 | #define CREATELOADTASKDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class CreateLoadTaskDialog; 8 | } 9 | 10 | class CreateLoadTaskDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit CreateLoadTaskDialog(QWidget *parent = nullptr); 16 | ~CreateLoadTaskDialog(); 17 | void showDialog(); 18 | 19 | public: 20 | void renameFilename(const QString &oldFileName, const QString &oldFilePath, bool duplicate = false); 21 | private slots: 22 | void accept() override; 23 | void onOpenFilename(); 24 | void onDeleteFilename(); 25 | void onRenameFilename(); 26 | void onDuplicateFilename(); 27 | signals: 28 | void requestOpenNewTab(QString); 29 | void requestRefreshTabs(); 30 | void taskfilePathChanged(QString,QString); 31 | 32 | private: 33 | Ui::CreateLoadTaskDialog *ui; 34 | void fillExistingTasksTable(); 35 | void createTasksFolderIfNotExist(); 36 | bool doesFilenameContainForbiddenChar(const QString & filename); 37 | }; 38 | 39 | #endif // CREATELOADTASKDIALOG_H 40 | -------------------------------------------------------------------------------- /ui/CursorMovementsSelectedEditDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "CursorMovementsSelectedEditDialog.h" 2 | #include "ui_CursorMovementsSelectedEditDialog.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | CursorMovementsSelectedEditDialog::CursorMovementsSelectedEditDialog(QWidget *parent) 10 | : QDialog(parent) 11 | , ui(new Ui::CursorMovementsSelectedEditDialog) 12 | { 13 | ui->setupUi(this); 14 | ui->tableWidget->horizontalHeader()->resizeSection(0,220); 15 | ui->tableWidget->horizontalHeader()->resizeSection(4,40); 16 | ui->lineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("\\w+"), this)); 17 | m_getCursorCoordinatesWidget = new getCursorCoordinatesWidget(this); 18 | m_keySelectorDialog = new KeysSelectorDialog(ui->keysStrokeButton); 19 | 20 | connect(ui->addMovsButton, &QPushButton::released, this,&CursorMovementsSelectedEditDialog::addMovsRow); 21 | connect(ui->removeMovsButton, &QPushButton::released, this,&CursorMovementsSelectedEditDialog::removeLastMovsRow); 22 | connect(ui->keysStrokeButton, &QPushButton::released, m_keySelectorDialog, &KeysSelectorDialog::showDialog); 23 | connect(m_keySelectorDialog, &KeysSelectorDialog::sendKeysList, this,[=](QStringList keysList) 24 | { 25 | ui->keysStrokeButton->setProperty("keys", keysList); 26 | ui->keysStrokeButton->setText(keysList.join("+")); 27 | }); 28 | } 29 | 30 | CursorMovementsSelectedEditDialog::~CursorMovementsSelectedEditDialog() 31 | { 32 | delete ui; 33 | } 34 | 35 | void CursorMovementsSelectedEditDialog::setEditable(bool id) 36 | { 37 | ui->lineEdit->setReadOnly(!id); 38 | } 39 | 40 | void CursorMovementsSelectedEditDialog::setIdentity(const QString &id) 41 | { 42 | ui->lineEdit->setText(id); 43 | } 44 | 45 | QString CursorMovementsSelectedEditDialog::identity() 46 | { 47 | return ui->lineEdit->text(); 48 | } 49 | 50 | void CursorMovementsSelectedEditDialog::setTableCursorMovements(const CursorMovementsList &tableContent) 51 | { 52 | 53 | ui->tableWidget->clearContents(); 54 | ui->tableWidget->setRowCount(0); 55 | for(auto el : tableContent) 56 | { 57 | if(el.size() < 4) 58 | continue; 59 | 60 | QList widgetsList = addMovsRow(); 61 | if(widgetsList.size() < 4) 62 | break; 63 | 64 | auto delaySpin = qobject_cast(widgetsList.at(0)); 65 | if(delaySpin == nullptr) 66 | break; 67 | delaySpin->setValue(el[0]/1000.); 68 | 69 | auto movingTimeSpin = qobject_cast(widgetsList.at(1)); 70 | if(movingTimeSpin == nullptr) 71 | break; 72 | movingTimeSpin->setValue(el[1]/1000.); 73 | 74 | auto xCoordSpin = qobject_cast(widgetsList.at(2)); 75 | if(xCoordSpin == nullptr) 76 | break; 77 | xCoordSpin->setValue(el[2]); 78 | 79 | auto yCoordSpin = qobject_cast(widgetsList.at(3)); 80 | if(yCoordSpin == nullptr) 81 | break; 82 | yCoordSpin->setValue(el[3]); 83 | } 84 | } 85 | 86 | CursorMovementsList CursorMovementsSelectedEditDialog::tableCursorMovements() 87 | { 88 | CursorMovementsList returnedList; 89 | 90 | for(int row = 0; row < ui->tableWidget->rowCount(); ++row) 91 | { 92 | auto delaySpin = qobject_cast(ui->tableWidget->cellWidget(row, 0)); 93 | auto movingTimeSpin = qobject_cast(ui->tableWidget->cellWidget(row, 1)); 94 | auto xCoordSpin = qobject_cast(ui->tableWidget->cellWidget(row, 2)); 95 | auto yCoordSpin = qobject_cast(ui->tableWidget->cellWidget(row, 3)); 96 | if(delaySpin == nullptr || movingTimeSpin == nullptr || xCoordSpin == nullptr || yCoordSpin == nullptr) 97 | break; 98 | MovementList movlist; 99 | movlist << delaySpin->value()*1000 << movingTimeSpin->value()*1000 << xCoordSpin->value() << yCoordSpin->value(); 100 | returnedList.append(movlist); 101 | } 102 | return returnedList; 103 | } 104 | 105 | void CursorMovementsSelectedEditDialog::setOptionalKeysStroke(const QStringList &keysStroke) 106 | { 107 | ui->keysStrokeButton->setProperty("keys", keysStroke); 108 | ui->keysStrokeButton->setText(keysStroke.join("+")); 109 | } 110 | 111 | QStringList CursorMovementsSelectedEditDialog::optionalKeysStroke() 112 | { 113 | return ui->keysStrokeButton->property("keys").toStringList(); 114 | } 115 | 116 | QList CursorMovementsSelectedEditDialog::addMovsRow() 117 | { 118 | int index = ui->tableWidget->rowCount(); 119 | QDoubleSpinBox *delaySpin = new QDoubleSpinBox(this); 120 | delaySpin->setDecimals(2); 121 | delaySpin->setMinimum(0.); 122 | delaySpin->setMaximum(999999999999.); 123 | delaySpin->setSingleStep(0.1); 124 | delaySpin->setAlignment(Qt::AlignCenter); 125 | delaySpin->setLocale(QLocale::English); 126 | delaySpin->setValue(0.); 127 | if(index == 0) 128 | delaySpin->setEnabled(false); 129 | 130 | QDoubleSpinBox *movingTimeSpin = new QDoubleSpinBox(this); 131 | movingTimeSpin->setDecimals(2); 132 | movingTimeSpin->setMinimum(0.1); 133 | movingTimeSpin->setMaximum(999999999999.); 134 | movingTimeSpin->setSingleStep(0.1); 135 | movingTimeSpin->setAlignment(Qt::AlignCenter); 136 | movingTimeSpin->setLocale(QLocale::English); 137 | movingTimeSpin->setValue(1.); 138 | 139 | QSpinBox *xCoordSpin = new QSpinBox(this); 140 | xCoordSpin->setMinimum(0); 141 | xCoordSpin->setMaximum(9999);//TODO check screens max width 142 | xCoordSpin->setSingleStep(1); 143 | xCoordSpin->setAlignment(Qt::AlignCenter); 144 | xCoordSpin->setLocale(QLocale::English); 145 | xCoordSpin->setValue(0); 146 | 147 | QSpinBox *yCoordSpin = new QSpinBox(this); 148 | yCoordSpin->setMinimum(0); 149 | yCoordSpin->setMaximum(9999);//TODO check screens max height 150 | yCoordSpin->setSingleStep(1); 151 | yCoordSpin->setAlignment(Qt::AlignCenter); 152 | yCoordSpin->setLocale(QLocale::English); 153 | yCoordSpin->setValue(0); 154 | 155 | QPushButton *captureCoordsButton = new QPushButton(this); 156 | captureCoordsButton->setFlat(true); 157 | captureCoordsButton->setIcon(QIcon(":/img/cursor-cross.png")); 158 | captureCoordsButton->setProperty("index",index); 159 | connect(captureCoordsButton,&QPushButton::released, m_getCursorCoordinatesWidget,&getCursorCoordinatesWidget::showWidget); 160 | connect(m_getCursorCoordinatesWidget,&getCursorCoordinatesWidget::sendCoordinates, this,&CursorMovementsSelectedEditDialog::coordinatesReceived); 161 | 162 | ui->tableWidget->insertRow(index); 163 | ui->tableWidget->setCellWidget(index,0,delaySpin); 164 | ui->tableWidget->setCellWidget(index,1,movingTimeSpin); 165 | ui->tableWidget->setCellWidget(index,2,xCoordSpin); 166 | ui->tableWidget->setCellWidget(index,3,yCoordSpin); 167 | ui->tableWidget->setCellWidget(index,4,captureCoordsButton); 168 | 169 | QList returnedList; 170 | returnedList << delaySpin << movingTimeSpin << xCoordSpin << yCoordSpin << captureCoordsButton; 171 | 172 | return returnedList; 173 | } 174 | 175 | void CursorMovementsSelectedEditDialog::removeLastMovsRow() 176 | { 177 | if(ui->tableWidget->rowCount() > 0) 178 | ui->tableWidget->removeRow(ui->tableWidget->rowCount()-1); 179 | } 180 | 181 | void CursorMovementsSelectedEditDialog::coordinatesReceived(int index, int x, int y) 182 | { 183 | auto xCoordSpin = qobject_cast(ui->tableWidget->cellWidget(index, 2)); 184 | auto yCoordSpin = qobject_cast(ui->tableWidget->cellWidget(index, 3)); 185 | if(xCoordSpin == nullptr || yCoordSpin == nullptr) 186 | return; 187 | xCoordSpin->setValue(x); 188 | yCoordSpin->setValue(y); 189 | } 190 | 191 | void CursorMovementsSelectedEditDialog::accept() 192 | { 193 | if(ui->lineEdit->text().isEmpty()) 194 | { 195 | QMessageBox::warning(this, tr("Cursor movements set has no identity"), 196 | tr("The cursor movement set you tried to add has no identity, please define one.")); 197 | return; 198 | } 199 | QDialog::accept(); 200 | } 201 | -------------------------------------------------------------------------------- /ui/CursorMovementsSelectedEditDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CURSORMOVEMENTSSELECTEDEDITDIALOG_H 2 | #define CURSORMOVEMENTSSELECTEDEDITDIALOG_H 3 | 4 | #include "actions/ActionParameters.h" 5 | #include 6 | #include "ui/getCursorCoordinatesWidget.h" 7 | #include "KeysSelectorDialog.h" 8 | 9 | namespace Ui { 10 | class CursorMovementsSelectedEditDialog; 11 | } 12 | 13 | class CursorMovementsSelectedEditDialog : public QDialog 14 | { 15 | Q_OBJECT 16 | getCursorCoordinatesWidget *m_getCursorCoordinatesWidget; 17 | KeysSelectorDialog *m_keySelectorDialog; 18 | public: 19 | explicit CursorMovementsSelectedEditDialog(QWidget *parent = nullptr); 20 | ~CursorMovementsSelectedEditDialog(); 21 | void setEditable(bool id); 22 | void setIdentity(const QString & id); 23 | QString identity(); 24 | void setTableCursorMovements(const CursorMovementsList &tableContent); 25 | CursorMovementsList tableCursorMovements(); 26 | void setOptionalKeysStroke(const QStringList &keysStroke); 27 | QStringList optionalKeysStroke(); 28 | public slots: 29 | QList addMovsRow(); 30 | void removeLastMovsRow(); 31 | void coordinatesReceived(int index, int x, int y); 32 | private slots: 33 | void accept() override; 34 | private: 35 | Ui::CursorMovementsSelectedEditDialog *ui; 36 | }; 37 | 38 | #endif // CURSORMOVEMENTSSELECTEDEDITDIALOG_H 39 | -------------------------------------------------------------------------------- /ui/CursorMovementsTableWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "CursorMovementsTableWidget.h" 2 | #include "globals.h" 3 | #include "actions/ActionsTools.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | CursorMovementsTableWidget::CursorMovementsTableWidget(QWidget *parent) 10 | { 11 | m_cursorMovementsEditDialog = new CursorMovementsSelectedEditDialog(this); 12 | connect(m_cursorMovementsEditDialog, &QDialog::accepted, this, &CursorMovementsTableWidget::editFromDialogReceived); 13 | connect(this, &QTableWidget::cellDoubleClicked, this, &CursorMovementsTableWidget::editCursorMovementsSelected); 14 | } 15 | 16 | void CursorMovementsTableWidget::createCursorMovementsReceived() 17 | { 18 | m_cursorMovementsEditDialog->setEditable(true); 19 | m_cursorMovementsEditDialog->setIdentity(""); 20 | m_cursorMovementsEditDialog->setTableCursorMovements(CursorMovementsList()); 21 | m_cursorMovementsEditDialog->setOptionalKeysStroke(QStringList()); 22 | m_cursorMovementsEditDialog->exec(); 23 | } 24 | 25 | void CursorMovementsTableWidget::editFromDialogReceived() 26 | { 27 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 28 | auto receivedList = m_cursorMovementsEditDialog->tableCursorMovements(); 29 | QList writtenList; 30 | for(auto &el : receivedList) 31 | { 32 | QVariant variant = QVariant::fromValue(el); 33 | writtenList.append(variant); 34 | } 35 | writtenList.append(m_cursorMovementsEditDialog->optionalKeysStroke()); 36 | settings.setValue(G_Files::CursorMovementsDataCategory+m_cursorMovementsEditDialog->identity(),writtenList); 37 | refresh(); 38 | 39 | selectCursorMovementsFromIdentity(m_cursorMovementsEditDialog->identity()); 40 | } 41 | 42 | void CursorMovementsTableWidget::editCursorMovementsSelected(int row, int) 43 | { 44 | QTableWidgetItem *idItem = item(row,0); 45 | if(idItem == nullptr) 46 | return; 47 | 48 | QString trueId = idItem->text().remove(0,1); 49 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 50 | 51 | m_cursorMovementsEditDialog->setEditable(m_belongsToDataEditDialog); 52 | m_cursorMovementsEditDialog->setIdentity(trueId); 53 | auto readList = settings.value(G_Files::CursorMovementsDataCategory + trueId).toList(); 54 | m_cursorMovementsEditDialog->setTableCursorMovements(ActionsTools::fromStandardQMapToCursorMovsMap(readList)); 55 | m_cursorMovementsEditDialog->setOptionalKeysStroke(readList.last().toStringList()); 56 | m_cursorMovementsEditDialog->show(); 57 | } 58 | 59 | void CursorMovementsTableWidget::removeCursorMovementsReceived() 60 | { 61 | QItemSelectionModel *selection = selectionModel(); 62 | if(!selection->hasSelection()) 63 | { 64 | QMessageBox::warning(this, tr("No cursor movements set selected"),G_Sentences::NoCursorMovementsSelected()); 65 | return; 66 | } 67 | 68 | if(QMessageBox::question(this, tr("Confirm removing cursor movements set"), tr("You are about to remove this cursor movements set from data stored, are you sure ?"), 69 | QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::Cancel), QMessageBox::StandardButton(QMessageBox::Cancel)) == QMessageBox::Cancel) 70 | return; 71 | 72 | int row = selection->selectedRows().at(0).row(); 73 | QTableWidgetItem *idItem = item(row,0); 74 | if(idItem == nullptr) 75 | return; 76 | QString trueId = idItem->text().remove(0,1); 77 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 78 | settings.remove(G_Files::CursorMovementsDataCategory + trueId); 79 | 80 | refresh(); 81 | } 82 | 83 | void CursorMovementsTableWidget::refresh() 84 | { 85 | clearContents(); 86 | setRowCount(0); 87 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 88 | QStringList keys = settings.allKeys(); 89 | for(const auto &key : keys) 90 | { 91 | if(key.startsWith(G_Files::CursorMovementsDataCategory)) 92 | { 93 | insertRow(rowCount()); 94 | 95 | QString id = key; 96 | id.remove(G_Files::CursorMovementsDataCategory); 97 | setItem(rowCount()-1,0,new QTableWidgetItem("~"+id)); 98 | 99 | QTableWidgetItem *contentItem = new QTableWidgetItem(); 100 | auto readList = settings.value(G_Files::CursorMovementsDataCategory + id).toList(); 101 | QStringList contentList; 102 | for(auto &el : readList) 103 | { 104 | if(el==readList.last()) 105 | break; 106 | MovementList movelist = el.value(); 107 | if(movelist.size() >= 4) 108 | contentList.append("["+QString::number(movelist[2])+","+QString::number(movelist[3])+"]"); 109 | } 110 | QString fullContent = contentList.join(" ; ") + " (Keys stroke : "+readList.last().toStringList().join("+")+")"; 111 | contentItem->setText(fullContent); 112 | contentItem->setToolTip(ActionsTools::fromCursorMovsMapToPrintedString(ActionsTools::fromStandardQMapToCursorMovsMap(readList))+ 113 | "\nKeys stroke : "+readList.last().toStringList().join("+")); 114 | setItem(rowCount()-1,1,contentItem); 115 | } 116 | } 117 | } 118 | 119 | void CursorMovementsTableWidget::selectCursorMovementsFromIdentity(const QString &id) 120 | { 121 | QTableWidgetItem *idItem = nullptr; 122 | int rowFound = -1; 123 | for(int k=0; k< rowCount(); ++k) 124 | { 125 | idItem = item(k,0); 126 | if(idItem != nullptr && idItem->text() == "~"+id) 127 | { 128 | rowFound = k; 129 | break; 130 | } 131 | } 132 | 133 | if(rowFound >= 0) 134 | { 135 | selectRow(rowFound); 136 | scrollToItem(idItem,QAbstractItemView::PositionAtCenter); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /ui/CursorMovementsTableWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef CURSORMOVEMENTSTABLEWIDGET_H 2 | #define CURSORMOVEMENTSTABLEWIDGET_H 3 | 4 | #include 5 | #include "ui/CursorMovementsSelectedEditDialog.h" 6 | 7 | class CursorMovementsTableWidget : public QTableWidget 8 | { 9 | Q_OBJECT 10 | CursorMovementsSelectedEditDialog *m_cursorMovementsEditDialog; 11 | public: 12 | explicit CursorMovementsTableWidget(QWidget *parent = nullptr); 13 | ~CursorMovementsTableWidget() = default; 14 | void refresh(); 15 | void selectCursorMovementsFromIdentity(const QString & id); 16 | bool m_belongsToDataEditDialog = false; 17 | public slots: 18 | void createCursorMovementsReceived(); 19 | void removeCursorMovementsReceived(); 20 | void editFromDialogReceived(); 21 | private slots: 22 | void editCursorMovementsSelected(int row, int); 23 | }; 24 | 25 | #endif // CURSORMOVEMENTSTABLEWIDGET_H 26 | -------------------------------------------------------------------------------- /ui/DataEditDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "DataEditDialog.h" 2 | #include "ui_DataEditDialog.h" 3 | 4 | DataEditDialog::DataEditDialog(QWidget *parent) 5 | : QDialog(parent) 6 | , ui(new Ui::DataEditDialog) 7 | { 8 | ui->setupUi(this); 9 | 10 | QFont font = ui->tabWidget->tabBar()->font(); 11 | font.setPointSize(14); 12 | ui->tabWidget->tabBar()->setFont(font); 13 | ui->sentencesTableWidget->m_belongsToDataEditDialog = true; 14 | ui->keysSequencesTableWidget->m_belongsToDataEditDialog = true; 15 | ui->cursorMovementsTableWidget->m_belongsToDataEditDialog = true; 16 | 17 | connect(ui->addSentenceButton, &QPushButton::released, ui->sentencesTableWidget, &SentencesTableWidget::createSentenceReceived); 18 | connect(ui->removeSentenceButton, &QPushButton::released, ui->sentencesTableWidget, &SentencesTableWidget::removeSentenceReceived); 19 | connect(ui->addKeysSequenceButton, &QPushButton::released, ui->keysSequencesTableWidget, &KeysSequencesTableWidget::createKeysSequenceReceived); 20 | connect(ui->removeKeysSequenceButton, &QPushButton::released, ui->keysSequencesTableWidget, &KeysSequencesTableWidget::removeKeysSequenceReceived); 21 | connect(ui->addCursorMovementsButton, &QPushButton::released, ui->cursorMovementsTableWidget, &CursorMovementsTableWidget::createCursorMovementsReceived); 22 | connect(ui->removeCursorMovementsButton, &QPushButton::released, ui->cursorMovementsTableWidget, &CursorMovementsTableWidget::removeCursorMovementsReceived); 23 | } 24 | 25 | DataEditDialog::~DataEditDialog() 26 | { 27 | delete ui; 28 | } 29 | 30 | void DataEditDialog::showDialog() 31 | { 32 | ui->sentencesTableWidget->refresh(); 33 | ui->keysSequencesTableWidget->refresh(); 34 | ui->cursorMovementsTableWidget->refresh(); 35 | show(); 36 | } 37 | -------------------------------------------------------------------------------- /ui/DataEditDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef DATAEDITDIALOG_H 2 | #define DATAEDITDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class DataEditDialog; 8 | } 9 | 10 | class DataEditDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit DataEditDialog(QWidget *parent = nullptr); 16 | ~DataEditDialog(); 17 | public slots: 18 | void showDialog(); 19 | 20 | private: 21 | Ui::DataEditDialog *ui; 22 | }; 23 | 24 | #endif // DATAEDITDIALOG_H 25 | -------------------------------------------------------------------------------- /ui/KeysSelectorDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "KeysSelectorDialog.h" 2 | #include "ui_KeysSelectorDialog.h" 3 | 4 | KeysSelectorDialog::KeysSelectorDialog(QWidget *parent) 5 | : QDialog(parent) 6 | , ui(new Ui::KeysSelectorDialog) 7 | { 8 | ui->setupUi(this); 9 | connect(ui->treeWidget, &QTreeWidget::itemDoubleClicked, this, &KeysSelectorDialog::appendToList); 10 | connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &KeysSelectorDialog::removeFromList); 11 | } 12 | 13 | KeysSelectorDialog::~KeysSelectorDialog() 14 | { 15 | delete ui; 16 | } 17 | 18 | void KeysSelectorDialog::appendToList(QTreeWidgetItem *item, int) 19 | { 20 | if(item==nullptr || item->parent() == nullptr) 21 | return; 22 | ui->listWidget->addItem(item->text(0)); 23 | } 24 | 25 | void KeysSelectorDialog::removeFromList(QListWidgetItem *item) 26 | { 27 | if(item == nullptr) 28 | return; 29 | delete ui->listWidget->takeItem(ui->listWidget->row(item)); 30 | } 31 | 32 | void KeysSelectorDialog::accept() 33 | { 34 | QStringList sentList; 35 | for(int k = 0; k < ui->listWidget->count(); ++k) 36 | { 37 | sentList.append(ui->listWidget->item(k)->text()); 38 | } 39 | 40 | emit sendKeysList(sentList); 41 | QDialog::accept(); 42 | } 43 | 44 | void KeysSelectorDialog::showDialog() 45 | { 46 | QObject* sender = QObject::sender(); 47 | if(sender == nullptr) 48 | return; 49 | 50 | ui->listWidget->clear(); 51 | ui->listWidget->addItems(sender->property("keys").toStringList()); 52 | show(); 53 | } 54 | -------------------------------------------------------------------------------- /ui/KeysSelectorDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef KEYSSELECTORDIALOG_H 2 | #define KEYSSELECTORDIALOG_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Ui { 9 | class KeysSelectorDialog; 10 | } 11 | 12 | class KeysSelectorDialog : public QDialog 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit KeysSelectorDialog(QWidget *parent = nullptr); 18 | ~KeysSelectorDialog(); 19 | private slots: 20 | void appendToList(QTreeWidgetItem *item, int); 21 | void removeFromList(QListWidgetItem* item); 22 | void accept() override; 23 | public slots: 24 | void showDialog(); 25 | signals: 26 | void sendKeysList(QStringList keysList); 27 | private: 28 | Ui::KeysSelectorDialog *ui; 29 | }; 30 | 31 | #endif // KEYSSELECTORDIALOG_H 32 | -------------------------------------------------------------------------------- /ui/KeysSequenceSelectedEditDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "KeysSequenceSelectedEditDialog.h" 2 | #include "ui_KeysSequenceSelectedEditDialog.h" 3 | #include "KeysSelectorDialog.h" 4 | #include 5 | #include 6 | #include 7 | 8 | KeysSequenceSelectedEditDialog::KeysSequenceSelectedEditDialog(QWidget *parent) 9 | : QDialog(parent) 10 | , ui(new Ui::KeysSequenceSelectedEditDialog) 11 | { 12 | ui->setupUi(this); 13 | ui->lineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("\\w+"), this)); 14 | connect(ui->addKeysButton, &QPushButton::released, this,&KeysSequenceSelectedEditDialog::addKeysRow); 15 | connect(ui->removeKeysButton, &QPushButton::released, this,&KeysSequenceSelectedEditDialog::removeLastKeysRow); 16 | } 17 | 18 | KeysSequenceSelectedEditDialog::~KeysSequenceSelectedEditDialog() 19 | { 20 | delete ui; 21 | } 22 | 23 | void KeysSequenceSelectedEditDialog::setEditable(bool id) 24 | { 25 | ui->lineEdit->setReadOnly(!id); 26 | } 27 | 28 | void KeysSequenceSelectedEditDialog::setIdentity(const QString &id) 29 | { 30 | ui->lineEdit->setText(id); 31 | } 32 | 33 | QString KeysSequenceSelectedEditDialog::identity() 34 | { 35 | return ui->lineEdit->text(); 36 | } 37 | 38 | void KeysSequenceSelectedEditDialog::setTableKeysSequence(const PressedReleaseDelaysKeysMap &tableContent) 39 | { 40 | ui->tableWidget->clearContents(); 41 | ui->tableWidget->setRowCount(0); 42 | for(auto [key,val] : tableContent.asKeyValueRange()) 43 | { 44 | QList widgetsList = addKeysRow(); 45 | if(widgetsList.size() != 3) 46 | break; 47 | 48 | auto pressedDelaySpin = qobject_cast(widgetsList.at(0)); 49 | if(pressedDelaySpin == nullptr) 50 | break; 51 | pressedDelaySpin->setValue(key/1000.); 52 | 53 | auto releasedDelaySpin = qobject_cast(widgetsList.at(1)); 54 | if(releasedDelaySpin == nullptr) 55 | break; 56 | releasedDelaySpin->setValue(val.first/1000.); 57 | 58 | auto keysListButton = qobject_cast(widgetsList.at(2)); 59 | if(keysListButton == nullptr) 60 | break; 61 | keysListButton->setProperty("keys",val.second); 62 | keysListButton->setText(val.second.join("+")); 63 | } 64 | } 65 | 66 | PressedReleaseDelaysKeysMap KeysSequenceSelectedEditDialog::tableKeysSequence() 67 | { 68 | PressedReleaseDelaysKeysMap returnedMap; 69 | 70 | for(int row = 0; row < ui->tableWidget->rowCount(); ++row) 71 | { 72 | auto pressedDelaySpin = qobject_cast(ui->tableWidget->cellWidget(row, 0)); 73 | auto releasedDelaySpin = qobject_cast(ui->tableWidget->cellWidget(row, 1)); 74 | auto keysListButton = qobject_cast(ui->tableWidget->cellWidget(row, 2)); 75 | if(pressedDelaySpin == nullptr || releasedDelaySpin == nullptr || keysListButton == nullptr ) 76 | break; 77 | returnedMap.insert(pressedDelaySpin->value()*1000, 78 | QPair(releasedDelaySpin->value()*1000,keysListButton->property("keys").toStringList())); 79 | } 80 | return returnedMap; 81 | } 82 | 83 | QList KeysSequenceSelectedEditDialog::addKeysRow() 84 | { 85 | int index = ui->tableWidget->rowCount(); 86 | QDoubleSpinBox *pressedDelaySpin = new QDoubleSpinBox(this); 87 | pressedDelaySpin->setDecimals(2); 88 | pressedDelaySpin->setMaximum(0.); 89 | pressedDelaySpin->setMaximum(999999999999.); 90 | pressedDelaySpin->setSingleStep(0.1); 91 | pressedDelaySpin->setAlignment(Qt::AlignCenter); 92 | pressedDelaySpin->setLocale(QLocale::English); 93 | if(index == 0) 94 | { 95 | pressedDelaySpin->setValue(0.); 96 | pressedDelaySpin->setEnabled(false); 97 | } 98 | else 99 | { 100 | auto previousSpin = qobject_cast(ui->tableWidget->cellWidget(index-1,0)); 101 | if(previousSpin!= nullptr) 102 | pressedDelaySpin->setValue(previousSpin->value()+0.1); 103 | } 104 | 105 | QDoubleSpinBox *releasedDelaySpin = new QDoubleSpinBox(this); 106 | releasedDelaySpin->setDecimals(2); 107 | releasedDelaySpin->setMinimum(0.1); 108 | releasedDelaySpin->setMaximum(999999999999.); 109 | releasedDelaySpin->setSingleStep(0.1); 110 | releasedDelaySpin->setAlignment(Qt::AlignCenter); 111 | releasedDelaySpin->setLocale(QLocale::English); 112 | 113 | QPushButton *keysListButton = new QPushButton(this); 114 | 115 | KeysSelectorDialog *keysSelector = new KeysSelectorDialog(keysListButton); 116 | connect(keysListButton, &QPushButton::released, keysSelector, &KeysSelectorDialog::showDialog); 117 | connect(keysSelector, &KeysSelectorDialog::sendKeysList, this,[=](QStringList keysList) 118 | { 119 | keysListButton->setProperty("keys", keysList); 120 | keysListButton->setText(keysList.join("+")); 121 | }); 122 | 123 | ui->tableWidget->insertRow(index); 124 | ui->tableWidget->setCellWidget(index,0,pressedDelaySpin); 125 | ui->tableWidget->setCellWidget(index,1,releasedDelaySpin); 126 | ui->tableWidget->setCellWidget(index,2,keysListButton); 127 | 128 | QList returnedList; 129 | returnedList << pressedDelaySpin << releasedDelaySpin << keysListButton; 130 | 131 | return returnedList; 132 | } 133 | 134 | void KeysSequenceSelectedEditDialog::removeLastKeysRow() 135 | { 136 | if(ui->tableWidget->rowCount() > 0) 137 | ui->tableWidget->removeRow(ui->tableWidget->rowCount()-1); 138 | } 139 | 140 | void KeysSequenceSelectedEditDialog::accept() 141 | { 142 | if(ui->lineEdit->text().isEmpty()) 143 | { 144 | QMessageBox::warning(this, tr("Keys sequence has no identity"), 145 | tr("The keys sequence you tried to add has no identity, please define one.")); 146 | return; 147 | } 148 | 149 | QList delaysList; 150 | for(int row = 0; row < ui->tableWidget->rowCount(); ++row) 151 | { 152 | auto pressedDelaySpin = qobject_cast(ui->tableWidget->cellWidget(row, 0)); 153 | if(pressedDelaySpin == nullptr) 154 | continue; 155 | int delay = pressedDelaySpin->value()*1000; 156 | if(delaysList.contains(delay)) 157 | { 158 | QMessageBox::warning(this, tr("Delay rehearsal"), 159 | tr("Delays before press must be unique, but some of them have the same value, please modify the entries.")); 160 | return; 161 | } 162 | delaysList.append(delay); 163 | } 164 | 165 | QDialog::accept(); 166 | } 167 | -------------------------------------------------------------------------------- /ui/KeysSequenceSelectedEditDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef KEYSSEQUENCESELECTEDEDITDIALOG_H 2 | #define KEYSSEQUENCESELECTEDEDITDIALOG_H 3 | 4 | #include "actions/ActionParameters.h" 5 | #include 6 | 7 | namespace Ui { 8 | class KeysSequenceSelectedEditDialog; 9 | } 10 | 11 | class KeysSequenceSelectedEditDialog : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit KeysSequenceSelectedEditDialog(QWidget *parent = nullptr); 17 | ~KeysSequenceSelectedEditDialog(); 18 | void setEditable(bool id); 19 | void setIdentity(const QString & id); 20 | QString identity(); 21 | void setTableKeysSequence(const PressedReleaseDelaysKeysMap &tableContent); 22 | PressedReleaseDelaysKeysMap tableKeysSequence(); 23 | public slots: 24 | QList addKeysRow(); 25 | void removeLastKeysRow(); 26 | private slots: 27 | void accept() override; 28 | 29 | private: 30 | Ui::KeysSequenceSelectedEditDialog *ui; 31 | }; 32 | 33 | #endif // KEYSSEQUENCESELECTEDEDITDIALOG_H 34 | -------------------------------------------------------------------------------- /ui/KeysSequencesTableWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "KeysSequencesTableWidget.h" 2 | #include "globals.h" 3 | #include "actions/ActionsTools.h" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | KeysSequencesTableWidget::KeysSequencesTableWidget(QWidget *parent) 10 | : QTableWidget{parent} 11 | { 12 | m_keysSequenceEditDialog = new KeysSequenceSelectedEditDialog(this); 13 | connect(m_keysSequenceEditDialog, &QDialog::accepted, this, &KeysSequencesTableWidget::editFromDialogReceived); 14 | connect(this, &QTableWidget::cellDoubleClicked, this, &KeysSequencesTableWidget::editKeysSequenceSelected); 15 | } 16 | 17 | void KeysSequencesTableWidget::createKeysSequenceReceived() 18 | { 19 | m_keysSequenceEditDialog->setEditable(true); 20 | m_keysSequenceEditDialog->setIdentity(""); 21 | m_keysSequenceEditDialog->setTableKeysSequence(PressedReleaseDelaysKeysMap()); 22 | m_keysSequenceEditDialog->exec(); 23 | } 24 | 25 | void KeysSequencesTableWidget::editKeysSequenceSelected(int row, int) 26 | { 27 | QTableWidgetItem *idItem = item(row,0); 28 | if(idItem == nullptr) 29 | return; 30 | 31 | QString trueId = idItem->text().remove(0,1); 32 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 33 | m_keysSequenceEditDialog->setEditable(m_belongsToDataEditDialog); 34 | m_keysSequenceEditDialog->setIdentity(trueId); 35 | auto readMap = settings.value(G_Files::KeysSequencesDataCategory + trueId).toMap(); 36 | m_keysSequenceEditDialog->setTableKeysSequence(ActionsTools::fromStandardQMapToKeysSeqMap(readMap)); 37 | m_keysSequenceEditDialog->show(); 38 | } 39 | 40 | void KeysSequencesTableWidget::editFromDialogReceived() 41 | { 42 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 43 | auto receivedMap = m_keysSequenceEditDialog->tableKeysSequence(); 44 | QMap writtenMap; 45 | for(auto [key,val] : receivedMap.asKeyValueRange()) 46 | { 47 | QVariant variant = QVariant::fromValue(val); 48 | writtenMap.insert(QString::number(key),variant); 49 | } 50 | settings.setValue(G_Files::KeysSequencesDataCategory+m_keysSequenceEditDialog->identity(), writtenMap); 51 | refresh(); 52 | 53 | selectKeysSequenceFromIdentity(m_keysSequenceEditDialog->identity()); 54 | } 55 | 56 | void KeysSequencesTableWidget::removeKeysSequenceReceived() 57 | { 58 | QItemSelectionModel *selection = selectionModel(); 59 | if(!selection->hasSelection()) 60 | { 61 | QMessageBox::warning(this, tr("No keys sequence selected"),G_Sentences::NoKeysSequenceSelected()); 62 | return; 63 | } 64 | 65 | if(QMessageBox::question(this, tr("Confirm removing keys sequence"), tr("You are about to remove this keys sequence from data stored, are you sure ?"), 66 | QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::Cancel), QMessageBox::StandardButton(QMessageBox::Cancel)) == QMessageBox::Cancel) 67 | return; 68 | 69 | int row = selection->selectedRows().at(0).row(); 70 | QTableWidgetItem *idItem = item(row,0); 71 | if(idItem == nullptr) 72 | return; 73 | QString trueId = idItem->text().remove(0,1); 74 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 75 | settings.remove(G_Files::KeysSequencesDataCategory + trueId); 76 | 77 | refresh(); 78 | } 79 | 80 | void KeysSequencesTableWidget::refresh() 81 | { 82 | clearContents(); 83 | setRowCount(0); 84 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 85 | QStringList keys = settings.allKeys(); 86 | for(const auto &key : keys) 87 | { 88 | if(key.startsWith(G_Files::KeysSequencesDataCategory)) 89 | { 90 | insertRow(rowCount()); 91 | 92 | QString id = key; 93 | id.remove(G_Files::KeysSequencesDataCategory); 94 | setItem(rowCount()-1,0,new QTableWidgetItem(">"+id)); 95 | 96 | QTableWidgetItem *contentItem = new QTableWidgetItem(); 97 | auto readMap = settings.value(G_Files::KeysSequencesDataCategory + id).toMap(); 98 | QStringList contentList; 99 | for(auto [key,val] : readMap.asKeyValueRange()) 100 | { 101 | ReleaseDelayKeysPair pair = val.value(); 102 | contentList.append(pair.second.join("+")); 103 | } 104 | QString fullContent = contentList.join(" ; "); 105 | contentItem->setText(fullContent); 106 | contentItem->setToolTip(ActionsTools::fromKeysSeqMapToPrintedString(ActionsTools::fromStandardQMapToKeysSeqMap(readMap))); 107 | setItem(rowCount()-1,1,contentItem); 108 | } 109 | } 110 | } 111 | 112 | void KeysSequencesTableWidget::selectKeysSequenceFromIdentity(const QString &id) 113 | { 114 | QTableWidgetItem *idItem = nullptr; 115 | int rowFound = -1; 116 | for(int k=0; k< rowCount(); ++k) 117 | { 118 | idItem = item(k,0); 119 | if(idItem != nullptr && idItem->text() == ">"+id) 120 | { 121 | rowFound = k; 122 | break; 123 | } 124 | } 125 | 126 | if(rowFound >= 0) 127 | { 128 | selectRow(rowFound); 129 | scrollToItem(idItem,QAbstractItemView::PositionAtCenter); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /ui/KeysSequencesTableWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef KEYSSEQUENCESTABLEWIDGET_H 2 | #define KEYSSEQUENCESTABLEWIDGET_H 3 | 4 | #include 5 | 6 | #include "ui/KeysSequenceSelectedEditDialog.h" 7 | 8 | class KeysSequencesTableWidget : public QTableWidget 9 | { 10 | Q_OBJECT 11 | KeysSequenceSelectedEditDialog *m_keysSequenceEditDialog; 12 | public: 13 | explicit KeysSequencesTableWidget(QWidget *parent = nullptr); 14 | ~KeysSequencesTableWidget() = default; 15 | void refresh(); 16 | void selectKeysSequenceFromIdentity(const QString & id); 17 | bool m_belongsToDataEditDialog = false; 18 | public slots: 19 | void createKeysSequenceReceived(); 20 | void removeKeysSequenceReceived(); 21 | void editFromDialogReceived(); 22 | private slots: 23 | void editKeysSequenceSelected(int row, int); 24 | signals: 25 | }; 26 | 27 | #endif // KEYSSEQUENCESTABLEWIDGET_H 28 | -------------------------------------------------------------------------------- /ui/SentenceSelectedEditDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "SentenceSelectedEditDialog.h" 2 | #include "ui_SentenceSelectedEditDialog.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | SentenceSelectedEditDialog::SentenceSelectedEditDialog(QWidget *parent) 9 | : QDialog(parent) 10 | , ui(new Ui::SentenceSelectedEditDialog) 11 | { 12 | ui->setupUi(this); 13 | ui->lineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression("\\w+"), this)); 14 | } 15 | 16 | SentenceSelectedEditDialog::~SentenceSelectedEditDialog() 17 | { 18 | delete ui; 19 | } 20 | 21 | void SentenceSelectedEditDialog::setEditable(bool id) 22 | { 23 | ui->lineEdit->setReadOnly(!id); 24 | } 25 | 26 | void SentenceSelectedEditDialog::setIdentity(const QString &id) 27 | { 28 | ui->lineEdit->setText(id); 29 | } 30 | 31 | QString SentenceSelectedEditDialog::identity() 32 | { 33 | return ui->lineEdit->text(); 34 | } 35 | 36 | void SentenceSelectedEditDialog::setContent(const QString &content) 37 | { 38 | ui->plainTextEdit->setPlainText(content); 39 | } 40 | 41 | QString SentenceSelectedEditDialog::content() 42 | { 43 | return ui->plainTextEdit->toPlainText(); 44 | } 45 | 46 | void SentenceSelectedEditDialog::accept() 47 | { 48 | if(ui->lineEdit->text().isEmpty()) 49 | { 50 | QMessageBox::warning(this, tr("Sentence has no identity"), 51 | tr("The sentence you tried to add has no identity, please define one.")); 52 | return; 53 | } 54 | QDialog::accept(); 55 | } 56 | -------------------------------------------------------------------------------- /ui/SentenceSelectedEditDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef SENTENCESELECTEDEDITDIALOG_H 2 | #define SENTENCESELECTEDEDITDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class SentenceSelectedEditDialog; 8 | } 9 | 10 | class SentenceSelectedEditDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit SentenceSelectedEditDialog(QWidget *parent = nullptr); 16 | ~SentenceSelectedEditDialog(); 17 | void setEditable(bool id); 18 | void setIdentity(const QString & id); 19 | QString identity(); 20 | void setContent(const QString & content); 21 | QString content(); 22 | private slots: 23 | void accept() override; 24 | private: 25 | Ui::SentenceSelectedEditDialog *ui; 26 | }; 27 | 28 | #endif // SENTENCESELECTEDEDITDIALOG_H 29 | -------------------------------------------------------------------------------- /ui/SentenceSelectedEditDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | SentenceSelectedEditDialog 4 | 5 | 6 | Qt::WindowModality::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 530 13 | 361 14 | 15 | 16 | 17 | Create/Edit/View a sentences 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 1 25 | 26 | 27 | 1 28 | 29 | 30 | 1 31 | 32 | 33 | 1 34 | 35 | 36 | 2 37 | 38 | 39 | 40 | 41 | Qt::Orientation::Vertical 42 | 43 | 44 | QSizePolicy::Policy::Preferred 45 | 46 | 47 | 48 | 10 49 | 10 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Qt::Orientation::Vertical 61 | 62 | 63 | QSizePolicy::Policy::Preferred 64 | 65 | 66 | 67 | 20 68 | 20 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Qt::Orientation::Vertical 77 | 78 | 79 | QSizePolicy::Policy::Preferred 80 | 81 | 82 | 83 | 10 84 | 10 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | Content : 93 | 94 | 95 | 96 | 97 | 98 | 99 | Identity must be alphanumerical. 100 | If already exists in data, it will replace the entry. 101 | If identity is changed (via the Edit Data window), it will make a copy of the entry. 102 | 103 | 104 | Qt::AlignmentFlag::AlignCenter 105 | 106 | 107 | 108 | 109 | 110 | 111 | Qt::Orientation::Horizontal 112 | 113 | 114 | QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Save 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 2 123 | 124 | 125 | 1 126 | 127 | 128 | 1 129 | 130 | 131 | 1 132 | 133 | 134 | 1 135 | 136 | 137 | 138 | 139 | Qt::Orientation::Horizontal 140 | 141 | 142 | 143 | 40 144 | 20 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | Sentence's identity 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | Qt::Orientation::Horizontal 163 | 164 | 165 | 166 | 40 167 | 20 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | buttonBox 181 | accepted() 182 | SentenceSelectedEditDialog 183 | accept() 184 | 185 | 186 | 248 187 | 254 188 | 189 | 190 | 157 191 | 274 192 | 193 | 194 | 195 | 196 | buttonBox 197 | rejected() 198 | SentenceSelectedEditDialog 199 | reject() 200 | 201 | 202 | 316 203 | 260 204 | 205 | 206 | 286 207 | 274 208 | 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /ui/SentencesTableWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "SentencesTableWidget.h" 2 | #include "globals.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | SentencesTableWidget::SentencesTableWidget(QWidget *parent) 9 | : QTableWidget{parent} 10 | { 11 | m_sentenceEditDialog = new SentenceSelectedEditDialog(this); 12 | connect(m_sentenceEditDialog, &QDialog::accepted, this, &SentencesTableWidget::editFromDialogReceived); 13 | connect(this, &QTableWidget::cellDoubleClicked, this, &SentencesTableWidget::editSentenceSelected); 14 | } 15 | 16 | void SentencesTableWidget::createSentenceReceived() 17 | { 18 | m_sentenceEditDialog->setEditable(true); 19 | m_sentenceEditDialog->setIdentity(""); 20 | m_sentenceEditDialog->setContent(""); 21 | m_sentenceEditDialog->show(); 22 | } 23 | 24 | void SentencesTableWidget::editSentenceSelected(int row, int) 25 | { 26 | QTableWidgetItem *idItem = item(row,0); 27 | if(idItem == nullptr) 28 | return; 29 | 30 | QString trueId = idItem->text().remove(0,1); 31 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 32 | m_sentenceEditDialog->setEditable(m_belongsToDataEditDialog); 33 | m_sentenceEditDialog->setIdentity(trueId); 34 | m_sentenceEditDialog->setContent(settings.value(G_Files::SentencesDataCategory + trueId).toString()); 35 | m_sentenceEditDialog->show(); 36 | } 37 | 38 | void SentencesTableWidget::editFromDialogReceived() 39 | { 40 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 41 | settings.setValue(G_Files::SentencesDataCategory+m_sentenceEditDialog->identity(), 42 | m_sentenceEditDialog->content()); 43 | refresh(); 44 | 45 | selectSentenceFromIdentity(m_sentenceEditDialog->identity()); 46 | } 47 | 48 | void SentencesTableWidget::removeSentenceReceived() 49 | { 50 | QItemSelectionModel *selection = selectionModel(); 51 | if(!selection->hasSelection()) 52 | { 53 | QMessageBox::warning(this, tr("No sentence selected"),G_Sentences::NoSetenceSelected()); 54 | return; 55 | } 56 | 57 | if(QMessageBox::question(this, tr("Confirm removing sentence"), tr("You are about to remove this sentence from data stored, are you sure ?"), 58 | QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::Cancel), QMessageBox::StandardButton(QMessageBox::Cancel)) == QMessageBox::Cancel) 59 | return; 60 | 61 | int row = selection->selectedRows().at(0).row(); 62 | QTableWidgetItem *idItem = item(row,0); 63 | if(idItem == nullptr) 64 | return; 65 | QString trueId = idItem->text().remove(0,1); 66 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 67 | settings.remove(G_Files::SentencesDataCategory + trueId); 68 | 69 | refresh(); 70 | } 71 | 72 | void SentencesTableWidget::refresh() 73 | { 74 | clearContents(); 75 | setRowCount(0); 76 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 77 | QStringList keys = settings.allKeys(); 78 | for(const auto &key : keys) 79 | { 80 | if(key.startsWith(G_Files::SentencesDataCategory)) 81 | { 82 | insertRow(rowCount()); 83 | 84 | QString id = key; 85 | id.remove(G_Files::SentencesDataCategory); 86 | setItem(rowCount()-1,0,new QTableWidgetItem("#"+id)); 87 | 88 | QTableWidgetItem *contentItem = new QTableWidgetItem(); 89 | QString content = settings.value(key).toString(); 90 | contentItem->setToolTip(content); 91 | contentItem->setText(content.simplified()); 92 | setItem(rowCount()-1,1,contentItem); 93 | } 94 | } 95 | } 96 | 97 | void SentencesTableWidget::selectSentenceFromIdentity(const QString &id) 98 | { 99 | QTableWidgetItem *idItem = nullptr; 100 | int rowFound = -1; 101 | for(int k=0; k< rowCount(); ++k) 102 | { 103 | idItem = item(k,0); 104 | if(idItem != nullptr && idItem->text() == "#"+id) 105 | { 106 | rowFound = k; 107 | break; 108 | } 109 | } 110 | 111 | if(rowFound >= 0) 112 | { 113 | selectRow(rowFound); 114 | scrollToItem(idItem,QAbstractItemView::PositionAtCenter); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /ui/SentencesTableWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef SENTENCESTABLEWIDGET_H 2 | #define SENTENCESTABLEWIDGET_H 3 | 4 | #include 5 | 6 | #include "ui/SentenceSelectedEditDialog.h" 7 | 8 | class SentencesTableWidget : public QTableWidget 9 | { 10 | Q_OBJECT 11 | SentenceSelectedEditDialog *m_sentenceEditDialog; 12 | public: 13 | explicit SentencesTableWidget(QWidget *parent = nullptr); 14 | ~SentencesTableWidget() = default; 15 | void refresh(); 16 | void selectSentenceFromIdentity(const QString & id); 17 | bool m_belongsToDataEditDialog = false; 18 | public slots: 19 | void createSentenceReceived(); 20 | void removeSentenceReceived(); 21 | void editFromDialogReceived(); 22 | private slots: 23 | void editSentenceSelected(int row, int); 24 | signals: 25 | }; 26 | 27 | #endif // SENTENCESTABLEWIDGET_H 28 | -------------------------------------------------------------------------------- /ui/StartupTaskEditDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "StartupTaskEditDialog.h" 2 | #include "ui_StartupTaskEditDialog.h" 3 | #include "globals.h" 4 | 5 | #include 6 | #include 7 | 8 | StartupTaskEditDialog::StartupTaskEditDialog(QWidget *parent) 9 | : QDialog(parent) 10 | , ui(new Ui::StartupTaskEditDialog) 11 | { 12 | ui->setupUi(this); 13 | } 14 | 15 | StartupTaskEditDialog::~StartupTaskEditDialog() 16 | { 17 | delete ui; 18 | } 19 | 20 | void StartupTaskEditDialog::showDialog() 21 | { 22 | fillExistingTasksTable(); 23 | ui->timeEdit->setTime(QTime(0,1,0)); 24 | ui->spinBox->setValue(0); 25 | exec(); 26 | } 27 | 28 | void StartupTaskEditDialog::accept() 29 | { 30 | if(ui->tableWidget->selectedItems().count() == 0) 31 | { 32 | QMessageBox::warning(this, tr("No file selected"), G_Sentences::NoFileSelected()); 33 | return; 34 | }; 35 | if(ui->timeEdit->time() == QTime(0,0,0)) 36 | { 37 | QMessageBox::warning(this, tr("Delay can't be set to 0"), tr("The delay for the task to run after system startup can't be set to zero.")); 38 | return; 39 | } 40 | 41 | m_filename = ui->tableWidget->selectedItems().at(0)->text().chopped(5); 42 | m_delay = QTime(0,0,0).secsTo(ui->timeEdit->time()); 43 | m_delay+= ui->spinBox->value() * 86400; 44 | 45 | QDialog::accept(); 46 | } 47 | 48 | void StartupTaskEditDialog::fillExistingTasksTable() 49 | { 50 | QDir tasksFolder = QApplication::applicationDirPath()+"/"+G_Files::TasksFolder; 51 | if(!tasksFolder.exists()) 52 | return; 53 | 54 | QStringList tasksNamesList = tasksFolder.entryList(QStringList() << "*"+G_Files::TasksFileExtension, QDir::Files); 55 | 56 | int nextLineNum, nextColumnNum; 57 | 58 | ui->tableWidget->setRowCount(0); 59 | 60 | for(int k = 0; k < tasksNamesList.size(); k++) 61 | { 62 | nextLineNum = k/2; 63 | nextColumnNum = k % 2; 64 | 65 | if(nextColumnNum == 0) 66 | ui->tableWidget->insertRow(ui->tableWidget->rowCount()); 67 | 68 | ui->tableWidget->setItem(nextLineNum, nextColumnNum, new QTableWidgetItem(tasksNamesList.at(k))); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ui/StartupTaskEditDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef STARTUPTASKEDITDIALOG_H 2 | #define STARTUPTASKEDITDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class StartupTaskEditDialog; 8 | } 9 | 10 | class StartupTaskEditDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit StartupTaskEditDialog(QWidget *parent = nullptr); 16 | ~StartupTaskEditDialog(); 17 | QString m_filename; 18 | qint64 m_delay; 19 | void showDialog(); 20 | private slots: 21 | void accept() override; 22 | private: 23 | Ui::StartupTaskEditDialog *ui; 24 | void fillExistingTasksTable(); 25 | }; 26 | 27 | #endif // STARTUPTASKEDITDIALOG_H 28 | -------------------------------------------------------------------------------- /ui/StartupTaskEditDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | StartupTaskEditDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 375 10 | 300 11 | 12 | 13 | 14 | Add a task scheduled on system startup 15 | 16 | 17 | 18 | 19 | 20 | Select the task to be run : 21 | 22 | 23 | 24 | 25 | 26 | 27 | Qt::ScrollBarPolicy::ScrollBarAlwaysOff 28 | 29 | 30 | QAbstractItemView::EditTrigger::NoEditTriggers 31 | 32 | 33 | false 34 | 35 | 36 | false 37 | 38 | 39 | QAbstractItemView::SelectionMode::SingleSelection 40 | 41 | 42 | 0 43 | 44 | 45 | 2 46 | 47 | 48 | false 49 | 50 | 51 | 32 52 | 53 | 54 | 193 55 | 56 | 57 | false 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 0 68 | 0 69 | 70 | 71 | 72 | Set the delay for the task to be executed after system startup : 73 | 74 | 75 | Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter 76 | 77 | 78 | true 79 | 80 | 81 | false 82 | 83 | 84 | false 85 | 86 | 87 | 88 | 2 89 | 90 | 91 | 1 92 | 93 | 94 | 1 95 | 96 | 97 | 1 98 | 99 | 100 | 1 101 | 102 | 103 | 104 | 105 | 106 | 60 107 | 0 108 | 109 | 110 | 111 | Qt::AlignmentFlag::AlignCenter 112 | 113 | 114 | 10000 115 | 116 | 117 | 118 | 119 | 120 | 121 | days and 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 100 130 | 0 131 | 132 | 133 | 134 | Qt::AlignmentFlag::AlignCenter 135 | 136 | 137 | HH:mm:ss 138 | 139 | 140 | 141 | 142 | 143 | 144 | hours,minutes,seconds 145 | 146 | 147 | 148 | 149 | 150 | 151 | Qt::Orientation::Horizontal 152 | 153 | 154 | QSizePolicy::Policy::Expanding 155 | 156 | 157 | 158 | 20 159 | 20 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | Qt::Orientation::Horizontal 171 | 172 | 173 | QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | buttonBox 183 | accepted() 184 | StartupTaskEditDialog 185 | accept() 186 | 187 | 188 | 248 189 | 254 190 | 191 | 192 | 157 193 | 274 194 | 195 | 196 | 197 | 198 | buttonBox 199 | rejected() 200 | StartupTaskEditDialog 201 | reject() 202 | 203 | 204 | 316 205 | 260 206 | 207 | 208 | 286 209 | 274 210 | 211 | 212 | 213 | 214 | 215 | -------------------------------------------------------------------------------- /ui/StartupTasksDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "StartupTasksDialog.h" 2 | #include "ui_StartupTasksDialog.h" 3 | #include "ui/StartupTasksTableWidget.h" 4 | 5 | StartupTasksDialog::StartupTasksDialog(QWidget *parent) 6 | : QDialog(parent) 7 | , ui(new Ui::StartupTasksDialog) 8 | { 9 | ui->setupUi(this); 10 | ui->tableWidget->horizontalHeader()->resizeSection(1,80); 11 | ui->tableWidget->horizontalHeader()->resizeSection(2,50); 12 | connect(ui->addButton, &QPushButton::released, ui->tableWidget, &StartupTasksTableWidget::addStartupTaskReceived); 13 | connect(ui->removeButton, &QPushButton::released, ui->tableWidget, &StartupTasksTableWidget::removeStartupTaskReceived); 14 | } 15 | 16 | StartupTasksDialog::~StartupTasksDialog() 17 | { 18 | delete ui; 19 | } 20 | 21 | void StartupTasksDialog::showDialog() 22 | { 23 | ui->tableWidget->refresh(); 24 | show(); 25 | } 26 | -------------------------------------------------------------------------------- /ui/StartupTasksDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef STARTUPTASKSDIALOG_H 2 | #define STARTUPTASKSDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class StartupTasksDialog; 8 | } 9 | 10 | class StartupTasksDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit StartupTasksDialog(QWidget *parent = nullptr); 16 | ~StartupTasksDialog(); 17 | public slots: 18 | void showDialog(); 19 | private: 20 | Ui::StartupTasksDialog *ui; 21 | }; 22 | 23 | #endif // STARTUPTASKSDIALOG_H 24 | -------------------------------------------------------------------------------- /ui/StartupTasksTableWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "StartupTasksTableWidget.h" 2 | #include "globals.h" 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | StartupTasksTableWidget::StartupTasksTableWidget(QWidget *parent) 11 | : QTableWidget{parent} 12 | { 13 | m_startupTaskEditDialog = new StartupTaskEditDialog(this); 14 | connect(m_startupTaskEditDialog, &QDialog::accepted, this, &StartupTasksTableWidget::editFromDialogReceived); 15 | } 16 | 17 | void StartupTasksTableWidget::refresh() 18 | { 19 | clearContents(); 20 | setRowCount(0); 21 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 22 | auto startupTasksParams = settings.value(G_Files::StartupTasksParams_KeyWord,"").toString(); 23 | 24 | if(startupTasksParams.isEmpty()) 25 | return; 26 | auto tasksParamsList = startupTasksParams.split("?"); 27 | QStringList paramsInTable; 28 | for(auto& taskParam : tasksParamsList) 29 | { 30 | auto paramL = taskParam.split("/"); 31 | if(paramL.size() != 2 || paramsInTable.contains(taskParam)) 32 | continue; 33 | paramsInTable.append(taskParam); 34 | insertRow(rowCount()); 35 | setItem(rowCount()-1,0,new QTableWidgetItem(paramL.at(0))); 36 | setItem(rowCount()-1,1,new QTableWidgetItem(paramL.at(1))); 37 | 38 | auto checkB = new QCheckBox(this); 39 | checkB->setProperty("params", taskParam); 40 | checkB->setChecked(doesEntryExistsInRegistry(taskParam)); 41 | connect(checkB, &QCheckBox::clicked, this, &StartupTasksTableWidget::checkBoxToggled); 42 | setCellWidget(rowCount()-1,2,checkB); 43 | 44 | model()->setData(model()->index(rowCount()-1,1),Qt::AlignCenter,Qt::TextAlignmentRole); 45 | model()->setData(model()->index(rowCount()-1,2),Qt::AlignCenter,Qt::DecorationRole); 46 | } 47 | } 48 | 49 | void StartupTasksTableWidget::saveInSettings() 50 | { 51 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 52 | 53 | if(rowCount() == 0) 54 | { 55 | settings.setValue(G_Files::StartupTasksParams_KeyWord,QString()); 56 | return; 57 | } 58 | QString strToWrite; 59 | for(int row = 0; row < rowCount() ; ++row) 60 | { 61 | strToWrite += item(row,0)->text()+"/"+item(row,1)->text()+"?"; 62 | } 63 | strToWrite.chop(1); 64 | 65 | settings.setValue(G_Files::StartupTasksParams_KeyWord,strToWrite); 66 | } 67 | 68 | void StartupTasksTableWidget::addStartupTaskReceived() 69 | { 70 | m_startupTaskEditDialog->showDialog(); 71 | } 72 | 73 | void StartupTasksTableWidget::removeStartupTaskReceived() 74 | { 75 | QItemSelectionModel *selection = selectionModel(); 76 | if(!selection->hasSelection()) 77 | { 78 | QMessageBox::warning(this, tr("No startup task selected"),G_Sentences::NoStartupTaskSelected()); 79 | return; 80 | } 81 | 82 | auto row = selection->selectedRows().at(0).row(); 83 | deleteEntryFromRegistry(item(row,0)->text()+"/"+item(row,1)->text()); 84 | 85 | removeRow(row); 86 | 87 | saveInSettings(); 88 | refresh(); 89 | } 90 | 91 | void StartupTasksTableWidget::editFromDialogReceived() 92 | { 93 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 94 | auto startupTasksParams = settings.value(G_Files::StartupTasksParams_KeyWord,"").toString(); 95 | auto entryParams = m_startupTaskEditDialog->m_filename +"/" + QString::number(m_startupTaskEditDialog->m_delay); 96 | if(startupTasksParams.contains(entryParams)) 97 | { 98 | QMessageBox::warning(this, tr("Entry already exists"),tr("This entry already exists in tasks to be executed at system startup.")); 99 | return; 100 | } 101 | startupTasksParams += (startupTasksParams.isEmpty() ? "":"?")+entryParams; 102 | settings.setValue(G_Files::StartupTasksParams_KeyWord,startupTasksParams); 103 | 104 | addEntryToRegistry(entryParams); 105 | refresh(); 106 | } 107 | 108 | bool StartupTasksTableWidget::doesEntryExistsInRegistry(const QString &taskParam) 109 | { 110 | QSettings settings(G_Files::SystemStartupRegistry_Path, QSettings::NativeFormat); 111 | auto paramL = taskParam.split("/"); 112 | if(paramL.size() == 2) 113 | { 114 | if(settings.childKeys().contains(G_Files::ProgramNameInRegistry_KeyWord+" "+paramL.at(0)+" "+paramL.at(1))) 115 | return true; 116 | } 117 | return false; 118 | } 119 | 120 | void StartupTasksTableWidget::addEntryToRegistry(const QString &taskParam) 121 | { 122 | auto paramL = taskParam.split("/"); 123 | if(paramL.size() != 2) 124 | return; 125 | 126 | QSettings settings(G_Files::SystemStartupRegistry_Path, QSettings::NativeFormat); 127 | settings.setValue(G_Files::ProgramNameInRegistry_KeyWord+" "+paramL.at(0)+" "+paramL.at(1), 128 | QDir::toNativeSeparators(QApplication::applicationFilePath())+" \""+paramL.at(0)+"\" "+paramL.at(1)); 129 | settings.sync(); 130 | } 131 | 132 | void StartupTasksTableWidget::deleteEntryFromRegistry(const QString &taskParam) 133 | { 134 | if(taskParam.isEmpty()) // have to check otherwise it removes all startup keys 135 | return; 136 | auto paramL = taskParam.split("/"); 137 | if(paramL.size() != 2) 138 | return; 139 | 140 | QSettings settings(G_Files::SystemStartupRegistry_Path, QSettings::NativeFormat); 141 | settings.remove(G_Files::ProgramNameInRegistry_KeyWord+" "+paramL.at(0)+" "+paramL.at(1)); 142 | settings.sync(); 143 | } 144 | 145 | 146 | void StartupTasksTableWidget::checkBoxToggled(bool val) 147 | { 148 | auto checkBSender = qobject_cast(sender()); 149 | if(checkBSender == nullptr) 150 | return; 151 | 152 | auto param = checkBSender->property("params").toString(); 153 | if(val) 154 | { 155 | if(!doesEntryExistsInRegistry(param)) 156 | addEntryToRegistry(param); 157 | } 158 | else 159 | deleteEntryFromRegistry(param); 160 | } 161 | -------------------------------------------------------------------------------- /ui/StartupTasksTableWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef STARTUPTASKSTABLEWIDGET_H 2 | #define STARTUPTASKSTABLEWIDGET_H 3 | 4 | #include 5 | 6 | #include "ui/StartupTaskEditDialog.h" 7 | 8 | class StartupTasksTableWidget : public QTableWidget 9 | { 10 | Q_OBJECT 11 | StartupTaskEditDialog *m_startupTaskEditDialog; 12 | bool doesEntryExistsInRegistry(const QString & taskParam); 13 | void addEntryToRegistry(const QString & taskParam); 14 | void deleteEntryFromRegistry(const QString & taskParam); 15 | public: 16 | explicit StartupTasksTableWidget(QWidget *parent = nullptr); 17 | ~StartupTasksTableWidget() = default; 18 | void refresh(); 19 | void saveInSettings(); 20 | private slots: 21 | void checkBoxToggled(bool val); 22 | public slots: 23 | void addStartupTaskReceived(); 24 | void removeStartupTaskReceived(); 25 | void editFromDialogReceived(); 26 | }; 27 | 28 | #endif // STARTUPTASKSTABLEWIDGET_H 29 | -------------------------------------------------------------------------------- /ui/Tasktab.h: -------------------------------------------------------------------------------- 1 | #ifndef TASKTAB_H 2 | #define TASKTAB_H 3 | 4 | #include "Task.h" 5 | #include "ui/getDelayDialog.h" 6 | #include "ActionWidgetsManager.h" 7 | #include "ui/createactiondialog/CreatePasteActionDialog.h" 8 | #include "ui/createactiondialog/CreateWaitActionDialog.h" 9 | #include "ui/createactiondialog/CreateKeysSequenceActionDialog.h" 10 | #include "ui/createactiondialog/CreateSystemCommandActionDialog.h" 11 | #include "ui/createactiondialog/CreateCursorMovementsActionDialog.h" 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | enum class ScheduleState{ 24 | NotScheduled, 25 | ScheduledInDelay, 26 | Running 27 | }; 28 | 29 | class TaskTab : public QScrollArea 30 | { 31 | Q_OBJECT 32 | protected: 33 | QString m_name; 34 | int m_ID; 35 | QString m_description; 36 | QWidget *m_mainWidget; 37 | QFrame *m_actionsFrame; 38 | QVBoxLayout *m_actionsLayout; 39 | Task *m_task = nullptr; 40 | void buildBasicInterface(); 41 | void setTask(Task *task); 42 | AbstractActionWidget *createActionWidget(AbstractAction *act); 43 | QLabel *m_nameLabel; 44 | QPlainTextEdit *m_descriptionEdit; 45 | QPushButton *m_scheduleButton; 46 | QPushButton *m_stopButton; 47 | QToolButton *m_addActionButton; 48 | QToolButton *m_loopButton; 49 | QLabel *m_delayChrono; 50 | void setName(const QString & newname); 51 | void setDescription(const QString & newdescription); 52 | getDelayDialog *m_getDelayDialog; 53 | QDateTime m_datetimeOfRun; 54 | ActionWidgetsManager *m_actionWidgetsManager; 55 | QTimer *m_scheduleTimer; 56 | CreatePasteActionDialog *m_createPasteActionDialog; 57 | CreateWaitActionDialog *m_createWaitActionDialog; 58 | CreateSystemCommandActionDialog *m_createSystemCommandActionDialog; 59 | CreateKeysSequenceActionDialog *m_createKeysSequenceActionDialog; 60 | CreateCursorMovementsActionDialog *m_createCursorMovementsActionDialog; 61 | void buildAddButtonMenu(); 62 | void appendAction(AbstractAction *act); 63 | unsigned int m_loopedTimes = 0; 64 | QLabel *m_loopedTimesLabel; 65 | QPushButton *m_saveButton; 66 | bool m_taskModifiedFromLastSave = false; 67 | QWidget *m_runOptionsWidget; 68 | QWidget *m_timesToRunWidget; 69 | QSpinBox *m_timesToRunSpinBox; 70 | public: 71 | explicit TaskTab(QWidget *parent = nullptr, const QString & name = "NONAME"); 72 | ~TaskTab(); 73 | void runTaskThread(); 74 | ScheduleState m_scheduleState; 75 | void setTaskModified(bool val); 76 | bool taskIsModified() const {return m_taskModifiedFromLastSave;} 77 | private slots: 78 | void stopPushed(); 79 | void loopToggled(bool state); 80 | void refreshScheduleText(); 81 | void anyActionChangedParam(); 82 | public slots: 83 | void scheduleTaskAfterDelay(qint64 delayInSeconds); 84 | void finishedOneLoop(); 85 | void receivedActionRunningState(unsigned int actId); 86 | void removeActionReceived(unsigned int actId); 87 | void moveToTopActionReceived(unsigned int actId); 88 | void moveToBottomActionReceived(unsigned int actId); 89 | void moveUpActionReceived(unsigned int actId); 90 | void moveDownActionReceived(unsigned int actId); 91 | void createPasteActionRequest(QString sentenceIdentity); // not const & because it's a slot, will make copy evenif 92 | void createWaitActionRequest(long double duration); 93 | void createKeysSequenceActionRequest(QString keysSequenceIdentity); // not const & because it's a slot, will make copy evenif 94 | void createSystemCommandActionRequest(QString sysCmdType, QString param1, QString param2); // not const & because it's a slot, will make copy evenif 95 | void createCursorMovementsActionRequest(QString cursorMovementsIdentity); // not const & because it's a slot, will make copy evenif 96 | signals: 97 | void saveTaskRequest(int taskId, bool verb); 98 | void refreshTabRunIconRequest(); 99 | 100 | friend class TaskTabsManager; 101 | }; 102 | 103 | #endif // TASKTAB_H 104 | -------------------------------------------------------------------------------- /ui/actionwidgets/AbstractActionWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "AbstractActionWidget.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | AbstractActionWidget::AbstractActionWidget(QWidget *parent) 8 | : QFrame{parent} 9 | { 10 | m_runningState = RunningState::NotExecuted; 11 | setProperty("runningState","notExecuted"); 12 | 13 | auto gridLayout = new QGridLayout(this); 14 | m_centralWidget = new QFrame(this); 15 | 16 | //m_centralWidget->setMinimumHeight(90); 17 | 18 | auto centralGridLayout = new QGridLayout(m_centralWidget); 19 | m_mainButton = new QPushButton(m_centralWidget); 20 | m_mainButton->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 21 | m_mainButton->setMinimumWidth(200); 22 | 23 | m_infoLabel = new QLabel("",m_centralWidget); 24 | m_infoLabel->setObjectName("actionSubLabel"); 25 | m_infoLabel->setWordWrap(true); 26 | m_infoLabel->setAlignment(Qt::AlignCenter); 27 | m_infoLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); 28 | m_infoLabel->setMinimumWidth(200); 29 | 30 | centralGridLayout->addWidget(m_mainButton,0,0,Qt::AlignCenter); 31 | centralGridLayout->addWidget(m_infoLabel,1,0,Qt::AlignCenter); 32 | 33 | centralGridLayout->setContentsMargins(1,1,1,1); 34 | centralGridLayout->setSpacing(2); 35 | centralGridLayout->setSizeConstraint(QLayout::SetMinimumSize); 36 | m_centralWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); 37 | 38 | m_removeButton = new QPushButton(QIcon(":/img/close_red.png"),"",this); 39 | m_removeButton->setMaximumSize(QSize(20,20)); 40 | m_removeButton->setFlat(true); 41 | m_removeButton->setToolTip(tr("Remove this action from the task...")); 42 | m_moveToTopButton = new QPushButton(QIcon(":/img/top_arrow_rounded.png"),"",this); 43 | m_moveToTopButton->setMaximumSize(QSize(20,20)); 44 | m_moveToTopButton->setFlat(true); 45 | m_moveToTopButton->setToolTip(tr("Move this action to the top")); 46 | m_moveToBottomButton = new QPushButton(QIcon(":/img/bottom_arrow_rounded.png"),"",this); 47 | m_moveToBottomButton->setMaximumSize(QSize(20,20)); 48 | m_moveToBottomButton->setFlat(true); 49 | m_moveToBottomButton->setToolTip(tr("Move this action to the bottom")); 50 | m_moveUpButton = new QPushButton(QIcon(":/img/up_arrow_rounded.png"),"",this); 51 | m_moveUpButton->setMaximumSize(QSize(20,20)); 52 | m_moveUpButton->setFlat(true); 53 | m_moveUpButton->setToolTip(tr("Move this action up")); 54 | m_moveDownButton = new QPushButton(QIcon(":/img/down_arrow_rounded.png"),"",this); 55 | m_moveDownButton->setMaximumSize(QSize(20,20)); 56 | m_moveDownButton->setFlat(true); 57 | m_moveDownButton->setToolTip(tr("Move this action down")); 58 | 59 | QGridLayout *rightLayout = new QGridLayout(); 60 | rightLayout->addWidget(m_moveUpButton,0,0); 61 | rightLayout->addWidget(m_moveDownButton,1,0); 62 | rightLayout->addWidget(m_moveToTopButton,0,1); 63 | rightLayout->addWidget(m_moveToBottomButton,1,1); 64 | rightLayout->addWidget(m_removeButton,0,2); 65 | rightLayout->setContentsMargins(1,1,1,1); 66 | rightLayout->setSpacing(2); 67 | rightLayout->setSizeConstraint(QLayout::SetMinimumSize); 68 | 69 | gridLayout->addItem(new QSpacerItem(3,3,QSizePolicy::Fixed,QSizePolicy::Fixed),0,0); 70 | gridLayout->addWidget(m_centralWidget,1,1,Qt::AlignCenter); 71 | gridLayout->addItem(new QSpacerItem(5,5,QSizePolicy::Fixed,QSizePolicy::Fixed),1,2); 72 | gridLayout->addLayout(rightLayout,1,3,Qt::AlignRight | Qt::AlignTop); 73 | gridLayout->addItem(new QSpacerItem(3,3,QSizePolicy::Fixed,QSizePolicy::Fixed),2,2); 74 | gridLayout->setContentsMargins(1,1,1,1); 75 | gridLayout->setSpacing(2); 76 | gridLayout->setColumnStretch(1,1); 77 | setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 78 | gridLayout->setSizeConstraint(QLayout::SetMinimumSize); 79 | 80 | connect(m_removeButton,&QPushButton::released, this, &AbstractActionWidget::removeSelf); 81 | connect(m_moveToTopButton,&QPushButton::released, this, &AbstractActionWidget::moveToTopSelf); 82 | connect(m_moveToBottomButton,&QPushButton::released, this, &AbstractActionWidget::moveToBottomSelf); 83 | connect(m_moveUpButton,&QPushButton::released, this, &AbstractActionWidget::moveUpSelf); 84 | connect(m_moveDownButton,&QPushButton::released, this, &AbstractActionWidget::moveDownSelf); 85 | } 86 | 87 | AbstractActionWidget::~AbstractActionWidget() 88 | { 89 | layout()->deleteLater(); 90 | } 91 | 92 | void AbstractActionWidget::setRunningState(RunningState state) 93 | { 94 | m_runningState = state; 95 | 96 | if(m_runningState == RunningState::NotExecuted) 97 | setProperty("runningState","notExecuted"); 98 | else if(m_runningState == RunningState::Running) 99 | setProperty("runningState","running"); 100 | else 101 | setProperty("runningState","done"); 102 | 103 | style()->unpolish(this); 104 | style()->polish(this); 105 | m_centralWidget->style()->unpolish(m_centralWidget); 106 | m_centralWidget->style()->polish(m_centralWidget); 107 | 108 | changedRunningState(); 109 | } 110 | 111 | void AbstractActionWidget::setAction(AbstractAction *action) 112 | { 113 | m_action = action; 114 | if(action != nullptr) 115 | m_actionID = action->getID(); 116 | } 117 | 118 | void AbstractActionWidget::removeSelf() 119 | { 120 | if(QMessageBox::question(this, tr("Confirm removing action"), tr("You are about to remove this action from the task, are you sure ?"), 121 | QMessageBox::StandardButtons(QMessageBox::Yes | QMessageBox::Cancel), QMessageBox::StandardButton(QMessageBox::Cancel)) == QMessageBox::Cancel) 122 | return; 123 | 124 | emit removeActionRequest(m_actionID); 125 | } 126 | 127 | void AbstractActionWidget::moveToTopSelf() 128 | { 129 | emit moveToTopActionRequest(m_actionID); 130 | } 131 | 132 | void AbstractActionWidget::moveToBottomSelf() 133 | { 134 | emit moveToBottomActionRequest(m_actionID); 135 | } 136 | 137 | void AbstractActionWidget::moveUpSelf() 138 | { 139 | emit moveUpActionRequest(m_actionID); 140 | } 141 | 142 | void AbstractActionWidget::moveDownSelf() 143 | { 144 | emit moveDownActionRequest(m_actionID); 145 | } 146 | -------------------------------------------------------------------------------- /ui/actionwidgets/AbstractActionWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef ABSTRACTACTIONWIDGET_H 2 | #define ABSTRACTACTIONWIDGET_H 3 | 4 | #include "actions/AbstractAction.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | enum class RunningState{ 11 | NotExecuted, 12 | Running, 13 | Done 14 | }; 15 | 16 | class AbstractActionWidget : public QFrame 17 | { 18 | Q_OBJECT 19 | protected: 20 | QFrame *m_centralWidget = nullptr; 21 | AbstractAction *m_action = nullptr; 22 | unsigned int m_actionID = 0; 23 | RunningState m_runningState; 24 | virtual void changedRunningState() {} 25 | QPushButton *m_mainButton; 26 | QLabel *m_infoLabel; 27 | QPushButton *m_removeButton; 28 | QPushButton *m_moveToTopButton; 29 | QPushButton *m_moveToBottomButton; 30 | QPushButton *m_moveUpButton; 31 | QPushButton *m_moveDownButton; 32 | public: 33 | explicit AbstractActionWidget(QWidget *parent = nullptr); 34 | virtual ~AbstractActionWidget(); 35 | void setRunningState(RunningState state); 36 | void setAction(AbstractAction *action); 37 | virtual void buildWidget() = 0; 38 | unsigned int getActionID() const {return m_actionID;} 39 | 40 | inline bool operator==(const AbstractActionWidget& otherActWidg) { return m_actionID == otherActWidg.m_actionID; } 41 | 42 | protected slots: 43 | void removeSelf(); 44 | void moveToTopSelf(); 45 | void moveToBottomSelf(); 46 | void moveUpSelf(); 47 | void moveDownSelf(); 48 | signals: 49 | void removeActionRequest(unsigned int id); 50 | void moveToTopActionRequest(unsigned int id); 51 | void moveToBottomActionRequest(unsigned int id); 52 | void moveUpActionRequest(unsigned int id); 53 | void moveDownActionRequest(unsigned int id); 54 | void anyParamChanged(); 55 | }; 56 | 57 | #endif // ABSTRACTACTIONWIDGET_H 58 | -------------------------------------------------------------------------------- /ui/actionwidgets/CursorMovementsWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "CursorMovementsWidget.h" 2 | #include "actions/CursorMovementsAction.h" 3 | #include "globals.h" 4 | #include "actions/ActionsTools.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | CursorMovementsWidget::CursorMovementsWidget(QWidget *parent) 13 | : AbstractActionWidget{parent} 14 | { 15 | 16 | } 17 | 18 | void CursorMovementsWidget::buildWidget() 19 | { 20 | if(m_centralWidget == nullptr) 21 | return; 22 | auto centralGridLayout = qobject_cast(m_centralWidget->layout()); 23 | if(centralGridLayout == nullptr) 24 | return; 25 | 26 | auto loopFrame = new QFrame(m_centralWidget); 27 | auto loopLabel = new QLabel(tr("Loop "),loopFrame); 28 | m_loopSpin = new QSpinBox(loopFrame); 29 | auto looptimesLabel = new QLabel(tr(" times"),loopFrame); 30 | m_loopSpin->setAlignment(Qt::AlignCenter); 31 | m_loopSpin->setMinimum(1); 32 | m_loopSpin->setMaximum(9999); 33 | m_loopSpin->setMinimumWidth(60); 34 | m_loopSpin->setToolTip(tr("Set how many times this cursor movements should be executed")); 35 | 36 | auto loopLayout = new QHBoxLayout(loopFrame); 37 | loopLayout->addWidget(loopLabel,0,Qt::AlignVCenter | Qt::AlignRight); 38 | loopLayout->addWidget(m_loopSpin,0,Qt::AlignCenter); 39 | loopLayout->addWidget(looptimesLabel,0,Qt::AlignVCenter | Qt::AlignLeft); 40 | loopLayout->setContentsMargins(1,1,1,1); 41 | loopLayout->setSpacing(2); 42 | 43 | centralGridLayout->removeWidget(m_infoLabel); 44 | centralGridLayout->addWidget(loopFrame,1,0,Qt::AlignCenter); 45 | centralGridLayout->addWidget(m_infoLabel,2,0,Qt::AlignCenter); 46 | 47 | auto cursormovsaction = dynamic_cast(m_action); 48 | 49 | QString movsStr = tr("ERROR on access to action"); 50 | QString id = tr("ERROR"); 51 | QStringList optKeysStroke; 52 | if(cursormovsaction != nullptr) 53 | { 54 | id = cursormovsaction->m_movementsId; 55 | movsStr = ActionsTools::fromCursorMovsMapToPrintedString(cursormovsaction->m_cursorMovementsList); 56 | optKeysStroke = cursormovsaction->m_cursorMovementsOptionalKeysStroke; 57 | m_loopSpin->setValue(cursormovsaction->m_timesToRun); 58 | } 59 | 60 | m_mainButton->setIcon(QIcon(":/img/cursor.png")); 61 | m_mainButton->setText(tr("Cursor movements ~")+id); 62 | m_mainButton->setToolTip(movsStr+"\nKeys stroke : "+optKeysStroke.join("+")); 63 | m_mainButton->setProperty("cursorMovsId", id); 64 | 65 | m_createCursorMovsActionDialog = new CreateCursorMovementsActionDialog(m_centralWidget); 66 | 67 | connect(m_mainButton, &QPushButton::released, m_createCursorMovsActionDialog, &CreateCursorMovementsActionDialog::showDialog); 68 | connect(m_createCursorMovsActionDialog, &CreateCursorMovementsActionDialog::sendCursorMovements, this, &CursorMovementsWidget::cursorMovsIdentityReceived); 69 | connect(m_loopSpin, &QSpinBox::valueChanged, this, &CursorMovementsWidget::timesToRunChanged); 70 | 71 | } 72 | 73 | void CursorMovementsWidget::cursorMovsIdentityReceived(QString id) 74 | { 75 | auto cursormovsaction = dynamic_cast(m_action); 76 | if(cursormovsaction == nullptr) 77 | { 78 | m_mainButton->setToolTip("ERROR on access to action"); 79 | m_mainButton->setText("Cursor movements ~ERROR"); 80 | return; 81 | } 82 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 83 | auto cursorMovementsFromSettings = settings.value(G_Files::CursorMovementsDataCategory+id).toList(); 84 | CursorMovementsList movsList = ActionsTools::fromStandardQMapToCursorMovsMap(cursorMovementsFromSettings); 85 | cursormovsaction->m_cursorMovementsList = movsList; 86 | cursormovsaction->m_movementsId = id; 87 | cursormovsaction->m_cursorMovementsOptionalKeysStroke = cursorMovementsFromSettings.last().toStringList(); 88 | m_mainButton->setText(tr("Cursor movements ~")+id); 89 | m_mainButton->setToolTip(ActionsTools::fromCursorMovsMapToPrintedString(movsList)+ 90 | "\nKeys stroke : "+cursorMovementsFromSettings.last().toStringList().join("+")); 91 | m_mainButton->setProperty("cursorMovsId", id); 92 | 93 | emit anyParamChanged(); 94 | } 95 | 96 | void CursorMovementsWidget::timesToRunChanged(int times) 97 | { 98 | auto cursormovsaction = dynamic_cast(m_action); 99 | if(cursormovsaction == nullptr) 100 | return; 101 | cursormovsaction->m_timesToRun = times; 102 | emit anyParamChanged(); 103 | } 104 | 105 | void CursorMovementsWidget::changedRunningState() 106 | { 107 | refreshLoopsRemainingText(QDateTime::currentDateTime()); 108 | } 109 | 110 | void CursorMovementsWidget::refreshLoopsRemainingText(const QDateTime &departureDate) 111 | { 112 | m_infoLabel->setText(""); 113 | 114 | if(m_runningState == RunningState::NotExecuted || m_runningState == RunningState::Done) 115 | return; 116 | 117 | auto cursormovsaction = dynamic_cast(m_action); 118 | if(cursormovsaction == nullptr) 119 | return; 120 | 121 | int oneExecutionDuration = cursormovsaction->computeOneExecutionDuration(); 122 | if(oneExecutionDuration == 0) 123 | return; 124 | 125 | qint64 timelaps = departureDate.msecsTo(QDateTime::currentDateTime()); 126 | int timesExecuted = timelaps / oneExecutionDuration; 127 | auto remainningTimes = cursormovsaction->m_timesToRun - timesExecuted; 128 | if(remainningTimes < 1) 129 | return; 130 | 131 | m_infoLabel->setText(tr("Remaining ")+QString::number(remainningTimes)+tr(" executions")); 132 | 133 | QTimer::singleShot(200, this, [=]() {refreshLoopsRemainingText(departureDate);}); 134 | 135 | } 136 | -------------------------------------------------------------------------------- /ui/actionwidgets/CursorMovementsWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef CURSORMOVEMENTSWIDGET_H 2 | #define CURSORMOVEMENTSWIDGET_H 3 | 4 | #include "ui/actionwidgets/AbstractActionWidget.h" 5 | #include "ui/createactiondialog/CreateCursorMovementsActionDialog.h" 6 | #include 7 | #include 8 | 9 | class CursorMovementsWidget : public AbstractActionWidget 10 | { 11 | Q_OBJECT 12 | CreateCursorMovementsActionDialog *m_createCursorMovsActionDialog; 13 | QSpinBox *m_loopSpin; 14 | void changedRunningState() override; 15 | public: 16 | explicit CursorMovementsWidget(QWidget *parent = nullptr); 17 | ~CursorMovementsWidget() = default; 18 | void buildWidget() override; 19 | private slots: 20 | void cursorMovsIdentityReceived(QString id); // not const & because it's a slot, will make copy evenif 21 | void timesToRunChanged(int times); 22 | private: 23 | void refreshLoopsRemainingText(const QDateTime& departureDate); 24 | }; 25 | 26 | #endif // CURSORMOVEMENTSWIDGET_H 27 | -------------------------------------------------------------------------------- /ui/actionwidgets/KeysSequenceWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "KeysSequenceWidget.h" 2 | #include "actions/KeysSequenceAction.h" 3 | #include "globals.h" 4 | #include "actions/ActionsTools.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | KeysSequenceWidget::KeysSequenceWidget(QWidget *parent) 13 | : AbstractActionWidget{parent} 14 | { 15 | 16 | } 17 | 18 | void KeysSequenceWidget::buildWidget() 19 | { 20 | if(m_centralWidget == nullptr) 21 | return; 22 | auto centralGridLayout = qobject_cast(m_centralWidget->layout()); 23 | if(centralGridLayout == nullptr) 24 | return; 25 | 26 | auto loopFrame = new QFrame(m_centralWidget); 27 | auto loopLabel = new QLabel(tr("Loop "),loopFrame); 28 | m_loopSpin = new QSpinBox(loopFrame); 29 | auto looptimesLabel = new QLabel(tr(" times"),loopFrame); 30 | m_loopSpin->setAlignment(Qt::AlignCenter); 31 | m_loopSpin->setMinimum(1); 32 | m_loopSpin->setMaximum(9999); 33 | m_loopSpin->setMinimumWidth(60); 34 | m_loopSpin->setToolTip(tr("Set how many times this keys sequence should be executed")); 35 | 36 | auto loopLayout = new QHBoxLayout(loopFrame); 37 | loopLayout->addWidget(loopLabel,0,Qt::AlignVCenter | Qt::AlignRight); 38 | loopLayout->addWidget(m_loopSpin,0,Qt::AlignCenter); 39 | loopLayout->addWidget(looptimesLabel,0,Qt::AlignVCenter | Qt::AlignLeft); 40 | loopLayout->setContentsMargins(1,1,1,1); 41 | loopLayout->setSpacing(2); 42 | 43 | centralGridLayout->removeWidget(m_infoLabel); 44 | centralGridLayout->addWidget(loopFrame,1,0,Qt::AlignCenter); 45 | centralGridLayout->addWidget(m_infoLabel,2,0,Qt::AlignCenter); 46 | 47 | auto keysseqaction = dynamic_cast(m_action); 48 | 49 | QString seqStr = tr("ERROR on access to action"); 50 | QString id = tr("ERROR"); 51 | if(keysseqaction != nullptr) 52 | { 53 | id = keysseqaction->m_sequenceId; 54 | seqStr = ActionsTools::fromKeysSeqMapToPrintedString(keysseqaction->m_keysSeqMap); 55 | m_loopSpin->setValue(keysseqaction->m_timesToRun); 56 | } 57 | 58 | m_mainButton->setIcon(QIcon(":/img/key.png")); 59 | m_mainButton->setText(tr("Keys sequence >")+id); 60 | m_mainButton->setToolTip(seqStr); 61 | m_mainButton->setProperty("keysSeqId", id); 62 | 63 | m_createKeysSeqActionDialog = new CreateKeysSequenceActionDialog(m_centralWidget); 64 | 65 | connect(m_mainButton, &QPushButton::released, m_createKeysSeqActionDialog, &CreateKeysSequenceActionDialog::showDialog); 66 | connect(m_createKeysSeqActionDialog, &CreateKeysSequenceActionDialog::sendKeysSequence, this, &KeysSequenceWidget::keysSeqIdentityReceived); 67 | connect(m_loopSpin, &QSpinBox::valueChanged, this, &KeysSequenceWidget::timesToRunChanged); 68 | } 69 | 70 | void KeysSequenceWidget::keysSeqIdentityReceived(QString id) 71 | { 72 | auto keysseqaction = dynamic_cast(m_action); 73 | if(keysseqaction == nullptr) 74 | { 75 | m_mainButton->setToolTip("ERROR on access to action"); 76 | m_mainButton->setText("Keys sequence >ERROR"); 77 | return; 78 | } 79 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 80 | auto keysSequenceFromSettings = settings.value(G_Files::KeysSequencesDataCategory+id).toMap(); 81 | PressedReleaseDelaysKeysMap keysMap = ActionsTools::fromStandardQMapToKeysSeqMap(keysSequenceFromSettings); 82 | keysseqaction->m_keysSeqMap = keysMap; 83 | keysseqaction->m_sequenceId = id; 84 | keysseqaction->generateTimeline(); 85 | m_mainButton->setText(tr("Keys sequence >")+id); 86 | m_mainButton->setToolTip(ActionsTools::fromKeysSeqMapToPrintedString(keysMap)); 87 | m_mainButton->setProperty("keysSeqId", id); 88 | 89 | emit anyParamChanged(); 90 | } 91 | 92 | void KeysSequenceWidget::timesToRunChanged(int times) 93 | { 94 | auto keysseqaction = dynamic_cast(m_action); 95 | if(keysseqaction == nullptr) 96 | return; 97 | keysseqaction->m_timesToRun = times; 98 | emit anyParamChanged(); 99 | } 100 | 101 | void KeysSequenceWidget::changedRunningState() 102 | { 103 | refreshLoopsRemainingText(QDateTime::currentDateTime()); 104 | } 105 | 106 | void KeysSequenceWidget::refreshLoopsRemainingText(const QDateTime &departureDate) 107 | { 108 | m_infoLabel->setText(""); 109 | if(m_runningState == RunningState::NotExecuted || m_runningState == RunningState::Done) 110 | return; 111 | 112 | auto keysseqaction = dynamic_cast(m_action); 113 | if(keysseqaction == nullptr) 114 | return; 115 | 116 | int oneExecutionDuration = keysseqaction->computeOneExecutionDuration(); 117 | if(oneExecutionDuration == 0) 118 | return; 119 | 120 | qint64 timelaps = departureDate.msecsTo(QDateTime::currentDateTime()); 121 | int timesExecuted = timelaps / oneExecutionDuration; 122 | auto remainningTimes = keysseqaction->m_timesToRun - timesExecuted; 123 | if(remainningTimes < 1) 124 | return; 125 | 126 | m_infoLabel->setText(tr("Remaining ")+QString::number(remainningTimes)+tr(" executions")); 127 | 128 | QTimer::singleShot(200, this, [=]() {refreshLoopsRemainingText(departureDate);}); 129 | } 130 | -------------------------------------------------------------------------------- /ui/actionwidgets/KeysSequenceWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef KEYSSEQUENCEWIDGET_H 2 | #define KEYSSEQUENCEWIDGET_H 3 | 4 | #include "ui/actionwidgets/AbstractActionWidget.h" 5 | #include "ui/createactiondialog/CreateKeysSequenceActionDialog.h" 6 | #include 7 | #include 8 | 9 | class KeysSequenceWidget : public AbstractActionWidget 10 | { 11 | Q_OBJECT 12 | CreateKeysSequenceActionDialog *m_createKeysSeqActionDialog; 13 | QSpinBox *m_loopSpin; 14 | void changedRunningState() override; 15 | public: 16 | explicit KeysSequenceWidget(QWidget *parent = nullptr); 17 | ~KeysSequenceWidget() = default; 18 | void buildWidget() override; 19 | private slots: 20 | void keysSeqIdentityReceived(QString id); // not const & because it's a slot, will make copy evenif 21 | void timesToRunChanged(int times); 22 | private: 23 | void refreshLoopsRemainingText(const QDateTime& departureDate); 24 | signals: 25 | }; 26 | 27 | #endif // KEYSSEQUENCEWIDGET_H 28 | -------------------------------------------------------------------------------- /ui/actionwidgets/PasteWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "PasteWidget.h" 2 | #include "actions/PasteAction.h" 3 | #include "globals.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | PasteWidget::PasteWidget(QWidget *parent) 12 | : AbstractActionWidget{parent} 13 | { 14 | 15 | } 16 | 17 | void PasteWidget::buildWidget() 18 | { 19 | if(m_centralWidget == nullptr) 20 | return; 21 | auto centralGridLayout = qobject_cast(m_centralWidget->layout()); 22 | if(centralGridLayout == nullptr) 23 | return; 24 | 25 | auto loopFrame = new QFrame(m_centralWidget); 26 | auto loopLabel = new QLabel(tr("Loop "),loopFrame); 27 | m_loopSpin = new QSpinBox(loopFrame); 28 | auto looptimesLabel = new QLabel(tr(" times"),loopFrame); 29 | m_loopSpin->setAlignment(Qt::AlignCenter); 30 | m_loopSpin->setMinimum(1); 31 | m_loopSpin->setMaximum(9999); 32 | m_loopSpin->setMinimumWidth(60); 33 | m_loopSpin->setToolTip(tr("Set how many times this paste text should be executed")); 34 | 35 | auto loopLayout = new QHBoxLayout(loopFrame); 36 | loopLayout->addWidget(loopLabel,0,Qt::AlignVCenter | Qt::AlignRight); 37 | loopLayout->addWidget(m_loopSpin,0,Qt::AlignCenter); 38 | loopLayout->addWidget(looptimesLabel,0,Qt::AlignVCenter | Qt::AlignLeft); 39 | loopLayout->setContentsMargins(1,1,1,1); 40 | loopLayout->setSpacing(2); 41 | 42 | centralGridLayout->removeWidget(m_infoLabel); 43 | centralGridLayout->addWidget(loopFrame,1,0,Qt::AlignCenter); 44 | centralGridLayout->addWidget(m_infoLabel,2,0,Qt::AlignCenter); 45 | 46 | auto pasteaction = dynamic_cast(m_action); 47 | 48 | QString content = tr("ERROR on access to action"); 49 | QString id = tr("ERROR"); 50 | if(pasteaction != nullptr) 51 | { 52 | content = pasteaction->m_content; 53 | id = pasteaction->m_contentId; 54 | m_loopSpin->setValue(pasteaction->m_timesToRun); 55 | } 56 | 57 | m_mainButton->setIcon(QIcon(":/img/text.png")); 58 | m_mainButton->setText(tr("Paste text #")+id); 59 | m_mainButton->setToolTip(content); 60 | m_mainButton->setProperty("contentId", id); 61 | 62 | m_createPasteActionDialog = new CreatePasteActionDialog(m_centralWidget); 63 | 64 | connect(m_mainButton, &QPushButton::released, m_createPasteActionDialog, &CreatePasteActionDialog::showDialog); 65 | connect(m_createPasteActionDialog, &CreatePasteActionDialog::sendSentence, this, &PasteWidget::sentenceIdentityReceived); 66 | connect(m_loopSpin, &QSpinBox::valueChanged, this, &PasteWidget::timesToRunChanged); 67 | } 68 | 69 | void PasteWidget::sentenceIdentityReceived(QString id) 70 | { 71 | QSettings settings(QApplication::applicationDirPath()+"/"+G_Files::DataFilePath, QSettings::IniFormat); 72 | QString content = settings.value(G_Files::SentencesDataCategory+id).toString(); 73 | 74 | auto pasteaction = dynamic_cast(m_action); 75 | if(pasteaction == nullptr) 76 | { 77 | m_mainButton->setToolTip("ERROR on access to action"); 78 | m_mainButton->setText("Paste text #ERROR"); 79 | return; 80 | } 81 | pasteaction->m_content = content; 82 | pasteaction->m_contentId = id; 83 | m_mainButton->setText(tr("Paste text #")+id); 84 | m_mainButton->setToolTip(content); 85 | m_mainButton->setProperty("contentId", id); 86 | 87 | emit anyParamChanged(); 88 | } 89 | 90 | void PasteWidget::timesToRunChanged(int times) 91 | { 92 | auto pasteaction = dynamic_cast(m_action); 93 | if(pasteaction == nullptr) 94 | return; 95 | pasteaction->m_timesToRun = times; 96 | emit anyParamChanged(); 97 | } 98 | 99 | void PasteWidget::changedRunningState() 100 | { 101 | refreshLoopsRemainingText(QDateTime::currentDateTime()); 102 | } 103 | 104 | void PasteWidget::refreshLoopsRemainingText(const QDateTime &departureDate) 105 | { 106 | m_infoLabel->setText(""); 107 | 108 | if(m_runningState == RunningState::NotExecuted || m_runningState == RunningState::Done) 109 | return; 110 | 111 | auto pasteaction = dynamic_cast(m_action); 112 | if(pasteaction == nullptr) 113 | return; 114 | 115 | int oneExecutionDuration = pasteaction->computeOneExecutionDuration(); 116 | if(oneExecutionDuration == 0) 117 | return; 118 | 119 | qint64 timelaps = departureDate.msecsTo(QDateTime::currentDateTime()); 120 | int timesExecuted = timelaps / oneExecutionDuration; 121 | auto remainningTimes = pasteaction->m_timesToRun - timesExecuted; 122 | if(remainningTimes < 1) 123 | return; 124 | 125 | m_infoLabel->setText(tr("Remaining ")+QString::number(remainningTimes)+tr(" executions")); 126 | 127 | QTimer::singleShot(200, this, [=]() {refreshLoopsRemainingText(departureDate);}); 128 | 129 | } 130 | 131 | -------------------------------------------------------------------------------- /ui/actionwidgets/PasteWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef PASTEWIDGET_H 2 | #define PASTEWIDGET_H 3 | 4 | #include "ui/actionwidgets/AbstractActionWidget.h" 5 | #include "ui/createactiondialog/CreatePasteActionDialog.h" 6 | #include 7 | #include 8 | 9 | class PasteWidget : public AbstractActionWidget 10 | { 11 | Q_OBJECT 12 | CreatePasteActionDialog *m_createPasteActionDialog; 13 | QSpinBox *m_loopSpin; 14 | void changedRunningState() override; 15 | public: 16 | explicit PasteWidget(QWidget *parent = nullptr); 17 | ~PasteWidget() = default; 18 | void buildWidget() override; 19 | private slots: 20 | void sentenceIdentityReceived(QString id); // not const & because it's a slot, will make copy evenif 21 | void timesToRunChanged(int times); 22 | private: 23 | void refreshLoopsRemainingText(const QDateTime& departureDate); 24 | signals: 25 | }; 26 | 27 | #endif // PASTEWIDGET_H 28 | -------------------------------------------------------------------------------- /ui/actionwidgets/SystemCommandWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "SystemCommandWidget.h" 2 | 3 | SystemCommandWidget::SystemCommandWidget(QWidget *parent) 4 | : AbstractActionWidget{parent} 5 | { 6 | 7 | } 8 | 9 | void SystemCommandWidget::buildWidget() 10 | { 11 | if(m_centralWidget == nullptr) 12 | return; 13 | 14 | auto sysCmdaction = dynamic_cast(m_action); 15 | 16 | QString sysCmdTypeStr = tr("ERROR"); 17 | if(sysCmdaction != nullptr) 18 | { 19 | sysCmdTypeStr = fromSysCmdTypeToDiplayedStr(sysCmdaction->e_sysCommandType); 20 | 21 | m_mainButton->setToolTip(sysCmdTypeStr + "\nOption 1 : "+sysCmdaction->m_param1+ "\nOption 2 : "+sysCmdaction->m_param2); 22 | 23 | ActionParameters params = sysCmdaction->generateParameters(); 24 | m_mainButton->setProperty("type", params.m_sysCmdTypeStr); 25 | m_mainButton->setProperty("param1", params.m_sysCmdParam1); 26 | m_mainButton->setProperty("param2", params.m_sysCmdParam2); 27 | m_mainButton->setProperty("displayedStr", sysCmdTypeStr); 28 | } 29 | 30 | m_mainButton->setIcon(QIcon(":/img/systemCommand.png")); 31 | m_mainButton->setText(sysCmdTypeStr); 32 | 33 | m_editSysCmdDialog = new CreateSystemCommandActionDialog(this); 34 | 35 | connect(m_mainButton, &QPushButton::released, m_editSysCmdDialog, &CreateSystemCommandActionDialog::showDialog); 36 | connect(m_editSysCmdDialog, &CreateSystemCommandActionDialog::sendSystemCommand, this, &SystemCommandWidget::systemCommandReceived); 37 | } 38 | 39 | void SystemCommandWidget::systemCommandReceived(QString sysCmdType, QString param1, QString param2) 40 | { 41 | auto sysCmdaction = dynamic_cast(m_action); 42 | if(sysCmdaction == nullptr) 43 | { 44 | m_mainButton->setToolTip("ERROR on access to action"); 45 | m_mainButton->setText("ERROR"); 46 | return; 47 | } 48 | 49 | ActionParameters params; 50 | params.m_sysCmdTypeStr = sysCmdType; 51 | params.m_sysCmdParam1 = param1; 52 | params.m_sysCmdParam2 = param2; 53 | 54 | sysCmdaction->setParameters(params); 55 | QString displayedStr = fromSysCmdTypeToDiplayedStr(sysCmdaction->e_sysCommandType); 56 | m_mainButton->setText(displayedStr); 57 | m_mainButton->setToolTip(displayedStr + "\n\nOption 1 : "+param1+ "\nOption 2 : "+param2); 58 | m_mainButton->setProperty("type", params.m_sysCmdTypeStr); 59 | m_mainButton->setProperty("param1", params.m_sysCmdParam1); 60 | m_mainButton->setProperty("param2", params.m_sysCmdParam2); 61 | 62 | emit anyParamChanged(); 63 | } 64 | 65 | QString SystemCommandWidget::fromSysCmdTypeToDiplayedStr(SystemCommandType t) 66 | { 67 | QString sysCmdTypeStr; 68 | if(t == SystemCommandType::ShutDown) 69 | sysCmdTypeStr = tr("Shut down the PC"); 70 | else if(t == SystemCommandType::Restart) 71 | sysCmdTypeStr = tr("Restart the PC"); 72 | else if(t == SystemCommandType::LogOff) 73 | sysCmdTypeStr = tr("Log off user session"); 74 | else if(t == SystemCommandType::ChangeAudioVolume) 75 | sysCmdTypeStr = tr("Change PC audio volume"); 76 | else if(t == SystemCommandType::ChangeDefaultAudioDevice) 77 | sysCmdTypeStr = tr("Change the default audio device"); 78 | else if(t == SystemCommandType::KillProcess) 79 | sysCmdTypeStr = tr("Kill a process"); 80 | else if(t == SystemCommandType::QuitSelfProgram) 81 | sysCmdTypeStr = tr("Quit Scheduled PC Tasks"); 82 | else if(t == SystemCommandType::CreateFolder) 83 | sysCmdTypeStr = tr("Create a folder"); 84 | else if(t == SystemCommandType::DeleteFolder) 85 | sysCmdTypeStr = tr("Delete a folder"); 86 | else if(t == SystemCommandType::CreateOneFile) 87 | sysCmdTypeStr = tr("Create a file"); 88 | else if(t == SystemCommandType::DeleteOneFile) 89 | sysCmdTypeStr = tr("Delete a file"); 90 | else if(t == SystemCommandType::TakeScreenshot) 91 | sysCmdTypeStr = tr("Take a screenshot"); 92 | else if(t == SystemCommandType::PrintActualScreen) 93 | sysCmdTypeStr = tr("Print the actual screen display"); 94 | else if(t == SystemCommandType::OpenFile) 95 | sysCmdTypeStr = tr("Open a file"); 96 | else if(t == SystemCommandType::ExecuteProgram) 97 | sysCmdTypeStr = tr("Execute a program"); 98 | else if(t == SystemCommandType::OpenUrl) 99 | sysCmdTypeStr = tr("Open an URL"); 100 | else if(t == SystemCommandType::OpenFolder) 101 | sysCmdTypeStr = tr("Open a folder"); 102 | else if(t == SystemCommandType::CopyOneFile) 103 | sysCmdTypeStr = tr("Copy a file"); 104 | 105 | return sysCmdTypeStr; 106 | } 107 | 108 | 109 | void SystemCommandWidget::changedRunningState() 110 | { 111 | 112 | } 113 | -------------------------------------------------------------------------------- /ui/actionwidgets/SystemCommandWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEMCOMMANDWIDGET_H 2 | #define SYSTEMCOMMANDWIDGET_H 3 | 4 | #include "ui/actionwidgets/AbstractActionWidget.h" 5 | #include "actions/SystemCommandsAction.h" 6 | #include "ui/createactiondialog/CreateSystemCommandActionDialog.h" 7 | 8 | class SystemCommandWidget : public AbstractActionWidget 9 | { 10 | Q_OBJECT 11 | void changedRunningState() override; 12 | CreateSystemCommandActionDialog *m_editSysCmdDialog; 13 | public: 14 | explicit SystemCommandWidget(QWidget *parent = nullptr); 15 | ~SystemCommandWidget() = default; 16 | void buildWidget() override; 17 | void systemCommandReceived(QString sysCmdType, QString param1, QString param2); // not const & because it's a slot, will make copy evenif 18 | 19 | private: 20 | QString fromSysCmdTypeToDiplayedStr(SystemCommandType t); 21 | }; 22 | 23 | #endif // SYSTEMCOMMANDWIDGET_H 24 | -------------------------------------------------------------------------------- /ui/actionwidgets/WaitWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "WaitWidget.h" 2 | #include "actions/WaitAction.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | WaitWidget::WaitWidget(QWidget *parent) 9 | : AbstractActionWidget{parent} 10 | { 11 | 12 | } 13 | 14 | void WaitWidget::buildWidget() 15 | { 16 | if(m_centralWidget == nullptr) 17 | return; 18 | 19 | auto waitaction = dynamic_cast(m_action); 20 | 21 | QString durationStr = tr("ERROR"); 22 | if(waitaction != nullptr) 23 | durationStr = QString::number((double)waitaction->m_duration); 24 | 25 | m_mainButton->setIcon(QIcon(":/img/wait.png")); 26 | m_mainButton->setText(tr("Wait for ") + durationStr + tr(" secs")); 27 | m_mainButton->setToolTip(durationStr+tr(" seconds")); 28 | m_mainButton->setProperty("duration", durationStr); 29 | 30 | m_editDurationDialog = new CreateWaitActionDialog(this); 31 | 32 | connect(m_mainButton, &QPushButton::released, m_editDurationDialog, &CreateWaitActionDialog::showDialog); 33 | connect(m_editDurationDialog, &CreateWaitActionDialog::sendDuration, this, &WaitWidget::durationReceived); 34 | 35 | } 36 | 37 | void WaitWidget::changedRunningState() 38 | { 39 | refreshTimeRemainingText(QDateTime::currentDateTime()); 40 | } 41 | 42 | void WaitWidget::refreshTimeRemainingText(const QDateTime &departureDate) 43 | { 44 | if(m_runningState == RunningState::NotExecuted || m_runningState == RunningState::Done) 45 | { 46 | m_infoLabel->setText(""); 47 | return; 48 | } 49 | 50 | auto waitaction = dynamic_cast(m_action); 51 | if(waitaction == nullptr) 52 | return; 53 | 54 | QDateTime finishDate = departureDate.addSecs(waitaction->m_duration); 55 | qint64 dateDelay = QDateTime::currentDateTime().secsTo(finishDate); 56 | 57 | if(dateDelay < 5) 58 | { 59 | m_infoLabel->setText(tr("Remaining less than 5 seconds")); 60 | m_infoLabel->setFixedSize(m_infoLabel->sizeHint()); 61 | return; 62 | } 63 | 64 | qint64 secs = dateDelay % 60; 65 | qint64 minNum = (dateDelay-secs)/60; 66 | qint64 mins = minNum % 60; 67 | qint64 hourNum = (minNum-mins)/ 60 ; 68 | qint64 hours = hourNum %24; 69 | qint64 days = (hourNum - hours)/ 24; 70 | m_infoLabel->setText(QString::number(days)+tr(" days ")+QString::number(hours)+tr(" hours ") 71 | +QString::number(mins)+tr(" mins ")+QString::number(secs)+tr(" secs")); 72 | m_infoLabel->setFixedSize(m_infoLabel->sizeHint()); 73 | QTimer::singleShot(200, this, [=]() {refreshTimeRemainingText(departureDate);}); 74 | } 75 | 76 | void WaitWidget::durationReceived(long double dur) 77 | { 78 | auto waitaction = dynamic_cast(m_action); 79 | if(waitaction == nullptr) 80 | { 81 | m_mainButton->setToolTip("ERROR on access to action"); 82 | m_mainButton->setText("Wait for ERROR secs"); 83 | return; 84 | } 85 | 86 | waitaction->m_duration = dur; 87 | QString durationStr = QString::number((double)dur); 88 | m_mainButton->setText(tr("Wait for ") + durationStr + tr(" secs")); 89 | m_mainButton->setToolTip(durationStr + tr(" seconds")); 90 | m_mainButton->setProperty("duration", durationStr); 91 | 92 | emit anyParamChanged(); 93 | } 94 | -------------------------------------------------------------------------------- /ui/actionwidgets/WaitWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef WAITWIDGET_H 2 | #define WAITWIDGET_H 3 | 4 | #include "ui/actionwidgets/AbstractActionWidget.h" 5 | #include "ui/createactiondialog/CreateWaitActionDialog.h" 6 | 7 | #include 8 | #include 9 | 10 | class WaitWidget : public AbstractActionWidget 11 | { 12 | Q_OBJECT 13 | void changedRunningState() override; 14 | CreateWaitActionDialog *m_editDurationDialog; 15 | public: 16 | explicit WaitWidget(QWidget *parent = nullptr); 17 | ~WaitWidget() = default; 18 | void buildWidget() override; 19 | private slots: 20 | void refreshTimeRemainingText(const QDateTime& departureDate); 21 | void durationReceived(long double dur); 22 | signals: 23 | }; 24 | 25 | #endif // WAITWIDGET_H 26 | -------------------------------------------------------------------------------- /ui/createactiondialog/CreateCursorMovementsActionDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "CreateCursorMovementsActionDialog.h" 2 | #include "ui_CreateCursorMovementsActionDialog.h" 3 | #include "globals.h" 4 | 5 | #include 6 | 7 | CreateCursorMovementsActionDialog::CreateCursorMovementsActionDialog(QWidget *parent) 8 | : QDialog(parent) 9 | , ui(new Ui::CreateCursorMovementsActionDialog) 10 | { 11 | ui->setupUi(this); 12 | connect(ui->addCursorMovementsButton, &QPushButton::released, ui->tableWidget, &CursorMovementsTableWidget::createCursorMovementsReceived); 13 | } 14 | 15 | CreateCursorMovementsActionDialog::~CreateCursorMovementsActionDialog() 16 | { 17 | delete ui; 18 | } 19 | 20 | void CreateCursorMovementsActionDialog::showDialog() 21 | { 22 | ui->tableWidget->refresh(); 23 | show(); 24 | 25 | // if shows from an existing Keys Sequence Widget 26 | auto mainButtonSender = qobject_cast(sender()); 27 | if(mainButtonSender == nullptr) 28 | return; 29 | 30 | if(!mainButtonSender->property("cursorMovsId").isValid() || mainButtonSender->property("cursorMovsId").toString() == tr("ERROR")) 31 | return; 32 | 33 | ui->tableWidget->selectCursorMovementsFromIdentity(mainButtonSender->property("cursorMovsId").toString()); 34 | } 35 | 36 | void CreateCursorMovementsActionDialog::accept() 37 | { 38 | QItemSelectionModel *selection = ui->tableWidget->selectionModel(); 39 | if(!selection->hasSelection()) 40 | { 41 | QMessageBox::warning(this, tr("No cursor movements set selected"),G_Sentences::NoCursorMovementsSelected()); 42 | return; 43 | } 44 | 45 | int row = selection->selectedRows().at(0).row(); 46 | QTableWidgetItem *idItem = ui->tableWidget->item(row,0); 47 | if(idItem == nullptr) 48 | { 49 | QMessageBox::warning(nullptr, tr("Internal Error"), 50 | tr("An internal error occured : err06\nitem selected in CreateCursorMovementsActionDialog is null !")); 51 | 52 | return; 53 | } 54 | 55 | QString trueId = idItem->text().remove(0,1); 56 | 57 | emit sendCursorMovements(trueId); 58 | 59 | QDialog::accept(); 60 | } 61 | -------------------------------------------------------------------------------- /ui/createactiondialog/CreateCursorMovementsActionDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATECURSORMOVEMENTSACTIONDIALOG_H 2 | #define CREATECURSORMOVEMENTSACTIONDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class CreateCursorMovementsActionDialog; 8 | } 9 | 10 | class CreateCursorMovementsActionDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit CreateCursorMovementsActionDialog(QWidget *parent = nullptr); 16 | ~CreateCursorMovementsActionDialog(); 17 | public slots: 18 | void showDialog(); 19 | private slots: 20 | void accept() override; 21 | signals: 22 | void sendCursorMovements(QString cursorMovsIdentity); 23 | private: 24 | Ui::CreateCursorMovementsActionDialog *ui; 25 | }; 26 | 27 | #endif // CREATECURSORMOVEMENTSACTIONDIALOG_H 28 | -------------------------------------------------------------------------------- /ui/createactiondialog/CreateKeysSequenceActionDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "CreateKeysSequenceActionDialog.h" 2 | #include "ui_CreateKeysSequenceActionDialog.h" 3 | #include "globals.h" 4 | 5 | #include 6 | 7 | CreateKeysSequenceActionDialog::CreateKeysSequenceActionDialog(QWidget *parent) 8 | : QDialog(parent) 9 | , ui(new Ui::CreateKeysSequenceActionDialog) 10 | { 11 | ui->setupUi(this); 12 | connect(ui->addKeysSequenceButton, &QPushButton::released, ui->tableWidget, &KeysSequencesTableWidget::createKeysSequenceReceived); 13 | } 14 | 15 | CreateKeysSequenceActionDialog::~CreateKeysSequenceActionDialog() 16 | { 17 | delete ui; 18 | } 19 | 20 | void CreateKeysSequenceActionDialog::showDialog() 21 | { 22 | ui->tableWidget->refresh(); 23 | show(); 24 | 25 | // if shows from an existing Keys Sequence Widget 26 | auto mainButtonSender = qobject_cast(sender()); 27 | if(mainButtonSender == nullptr) 28 | return; 29 | 30 | if(!mainButtonSender->property("keysSeqId").isValid() || mainButtonSender->property("keysSeqId").toString() == tr("ERROR")) 31 | return; 32 | 33 | ui->tableWidget->selectKeysSequenceFromIdentity(mainButtonSender->property("keysSeqId").toString()); 34 | } 35 | 36 | void CreateKeysSequenceActionDialog::accept() 37 | { 38 | QItemSelectionModel *selection = ui->tableWidget->selectionModel(); 39 | if(!selection->hasSelection()) 40 | { 41 | QMessageBox::warning(this, tr("No keys sequence selected"),G_Sentences::NoKeysSequenceSelected()); 42 | return; 43 | } 44 | 45 | int row = selection->selectedRows().at(0).row(); 46 | QTableWidgetItem *idItem = ui->tableWidget->item(row,0); 47 | if(idItem == nullptr) 48 | { 49 | QMessageBox::warning(nullptr, tr("Internal Error"), 50 | tr("An internal error occured : err03\nitem selected in CreateKeysSequenceActionDialog is null !")); 51 | 52 | return; 53 | } 54 | 55 | QString trueId = idItem->text().remove(0,1); 56 | 57 | emit sendKeysSequence(trueId); 58 | 59 | QDialog::accept(); 60 | } 61 | -------------------------------------------------------------------------------- /ui/createactiondialog/CreateKeysSequenceActionDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATEKEYSSEQUENCEACTIONDIALOG_H 2 | #define CREATEKEYSSEQUENCEACTIONDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class CreateKeysSequenceActionDialog; 8 | } 9 | 10 | class CreateKeysSequenceActionDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit CreateKeysSequenceActionDialog(QWidget *parent = nullptr); 16 | ~CreateKeysSequenceActionDialog(); 17 | public slots: 18 | void showDialog(); 19 | private slots: 20 | void accept() override; 21 | signals: 22 | void sendKeysSequence(QString keysSeqIdentity); 23 | private: 24 | Ui::CreateKeysSequenceActionDialog *ui; 25 | }; 26 | 27 | #endif // CREATEKEYSSEQUENCEACTIONDIALOG_H 28 | -------------------------------------------------------------------------------- /ui/createactiondialog/CreatePasteActionDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "CreatePasteActionDialog.h" 2 | #include "ui_CreatePasteActionDialog.h" 3 | #include "globals.h" 4 | 5 | #include 6 | 7 | CreatePasteActionDialog::CreatePasteActionDialog(QWidget *parent) 8 | : QDialog(parent) 9 | , ui(new Ui::CreatePasteActionDialog) 10 | { 11 | ui->setupUi(this); 12 | connect(ui->addSentenceButton, &QPushButton::released, ui->tableWidget, &SentencesTableWidget::createSentenceReceived); 13 | } 14 | 15 | CreatePasteActionDialog::~CreatePasteActionDialog() 16 | { 17 | delete ui; 18 | } 19 | 20 | void CreatePasteActionDialog::showDialog() 21 | { 22 | ui->tableWidget->refresh(); 23 | show(); 24 | 25 | // if shows from an existing Paste Widget 26 | auto mainButtonSender = qobject_cast(sender()); 27 | if(mainButtonSender == nullptr) 28 | return; 29 | 30 | if(!mainButtonSender->property("contentId").isValid() || mainButtonSender->property("contentId").toString() == tr("ERROR")) 31 | return; 32 | 33 | ui->tableWidget->selectSentenceFromIdentity(mainButtonSender->property("contentId").toString()); 34 | } 35 | 36 | void CreatePasteActionDialog::accept() 37 | { 38 | QItemSelectionModel *selection = ui->tableWidget->selectionModel(); 39 | if(!selection->hasSelection()) 40 | { 41 | QMessageBox::warning(this, tr("No sentence selected"),G_Sentences::NoSetenceSelected()); 42 | return; 43 | } 44 | 45 | int row = selection->selectedRows().at(0).row(); 46 | QTableWidgetItem *idItem = ui->tableWidget->item(row,0); 47 | if(idItem == nullptr) 48 | { 49 | QMessageBox::warning(nullptr, tr("Internal Error"), 50 | tr("An internal error occured : err04\nitem selected in CreatePasteActionDialog is null !")); 51 | 52 | return; 53 | } 54 | 55 | QString trueId = idItem->text().remove(0,1); 56 | 57 | emit sendSentence(trueId); 58 | 59 | QDialog::accept(); 60 | } 61 | -------------------------------------------------------------------------------- /ui/createactiondialog/CreatePasteActionDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATEPASTEACTIONDIALOG_H 2 | #define CREATEPASTEACTIONDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class CreatePasteActionDialog; 8 | } 9 | 10 | class CreatePasteActionDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit CreatePasteActionDialog(QWidget *parent = nullptr); 16 | ~CreatePasteActionDialog(); 17 | public slots: 18 | void showDialog(); 19 | private slots: 20 | void accept() override; 21 | signals: 22 | void sendSentence(QString sentenceIdentity); 23 | 24 | private: 25 | Ui::CreatePasteActionDialog *ui; 26 | }; 27 | 28 | #endif // CREATEPASTEACTIONDIALOG_H 29 | -------------------------------------------------------------------------------- /ui/createactiondialog/CreateSystemCommandActionDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATESYSTEMCOMMANDACTIONDIALOG_H 2 | #define CREATESYSTEMCOMMANDACTIONDIALOG_H 3 | 4 | #include 5 | #include 6 | #include "ui/getProgramPathDialog.h" 7 | #include "ui/getFilePathDialog.h" 8 | #include "ui/getFolderPathDialog.h" 9 | #include "ui/getImagePathDialog.h" 10 | #include "ui/getAutoRenameOptionDialog.h" 11 | 12 | namespace Ui { 13 | class CreateSystemCommandActionDialog; 14 | } 15 | 16 | class CreateSystemCommandActionDialog : public QDialog 17 | { 18 | Q_OBJECT 19 | 20 | QString m_type; 21 | QPushButton *m_option1Button; 22 | QPushButton *m_option2Button; 23 | getProgramPathDialog *m_programPathDialog; 24 | getFilePathDialog *m_filePathDialog; 25 | getFolderPathDialog *m_folderPathDialog; 26 | getFilePathDialog *m_savedFilePathDialog; 27 | getImagePathDialog *m_imagePathDialog; 28 | getAutoRenameOptionDialog *m_autorenameDialog; 29 | void activateButtons(); 30 | public: 31 | explicit CreateSystemCommandActionDialog(QWidget *parent = nullptr); 32 | ~CreateSystemCommandActionDialog(); 33 | private slots: 34 | void accept() override; 35 | void commandButtonPushed(); 36 | public slots: 37 | void showDialog(); 38 | signals: 39 | void sendSystemCommand(QString sysCmdType, QString param1, QString param2); 40 | private: 41 | Ui::CreateSystemCommandActionDialog *ui; 42 | }; 43 | 44 | #endif // CREATESYSTEMCOMMANDACTIONDIALOG_H 45 | -------------------------------------------------------------------------------- /ui/createactiondialog/CreateWaitActionDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "CreateWaitActionDialog.h" 2 | #include "ui_CreateWaitActionDialog.h" 3 | #include 4 | 5 | CreateWaitActionDialog::CreateWaitActionDialog(QWidget *parent) 6 | : QDialog(parent) 7 | , ui(new Ui::CreateWaitActionDialog) 8 | { 9 | ui->setupUi(this); 10 | ui->doubleSpinBox->setLocale(QLocale::English); 11 | 12 | connect(ui->bySecondsGroup, &QGroupBox::clicked, this, &CreateWaitActionDialog::uncheckByDayBasedGroup); 13 | connect(ui->byDayGroup, &QGroupBox::clicked, this, &CreateWaitActionDialog::uncheckBySecondsGroup); 14 | } 15 | 16 | CreateWaitActionDialog::~CreateWaitActionDialog() 17 | { 18 | delete ui; 19 | } 20 | 21 | void CreateWaitActionDialog::uncheckBySecondsGroup() 22 | { 23 | ui->bySecondsGroup->setChecked(false); 24 | ui->byDayGroup->setChecked(true); 25 | } 26 | 27 | void CreateWaitActionDialog::uncheckByDayBasedGroup() 28 | { 29 | ui->byDayGroup->setChecked(false); 30 | ui->bySecondsGroup->setChecked(true); 31 | } 32 | 33 | void CreateWaitActionDialog::accept() 34 | { 35 | if(ui->bySecondsGroup->isChecked()) 36 | emit sendDuration(ui->doubleSpinBox->value()); 37 | else 38 | { 39 | long double totalDuration = QTime(0,0,0).secsTo(ui->timeEdit->time()); 40 | totalDuration += ui->spinBox->value() * 86400; 41 | emit sendDuration(totalDuration); 42 | } 43 | 44 | QDialog::accept(); 45 | } 46 | 47 | void CreateWaitActionDialog::showDialog() 48 | { 49 | show(); 50 | 51 | // if shows from an existing Wait Widget 52 | auto mainButtonSender = qobject_cast(sender()); 53 | if(mainButtonSender == nullptr) 54 | return; 55 | 56 | if(!mainButtonSender->property("duration").isValid() || mainButtonSender->property("duration").toString() == tr("ERROR")) 57 | return; 58 | 59 | double dur = mainButtonSender->property("duration").toDouble(); 60 | ui->doubleSpinBox->setValue(dur); 61 | 62 | qint64 secs = (int)dur % 60; 63 | qint64 minNum = (dur-secs)/60; 64 | qint64 mins = minNum % 60; 65 | qint64 hourNum = (minNum-mins)/ 60 ; 66 | qint64 hours = hourNum %24; 67 | qint64 days = (hourNum - hours)/ 24; 68 | 69 | ui->timeEdit->setTime(QTime(hours,mins,secs)); 70 | ui->spinBox->setValue(days); 71 | } 72 | -------------------------------------------------------------------------------- /ui/createactiondialog/CreateWaitActionDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef CREATEWAITACTIONDIALOG_H 2 | #define CREATEWAITACTIONDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class CreateWaitActionDialog; 8 | } 9 | 10 | class CreateWaitActionDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit CreateWaitActionDialog(QWidget *parent = nullptr); 16 | ~CreateWaitActionDialog(); 17 | private slots: 18 | void uncheckBySecondsGroup(); 19 | void uncheckByDayBasedGroup(); 20 | void accept() override; 21 | public slots: 22 | void showDialog(); 23 | signals: 24 | void sendDuration(long double durationInSeconds); 25 | private: 26 | Ui::CreateWaitActionDialog *ui; 27 | }; 28 | 29 | #endif // CREATEWAITACTIONDIALOG_H 30 | -------------------------------------------------------------------------------- /ui/getAutoRenameOptionDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "getAutoRenameOptionDialog.h" 2 | #include "ui_getAutoRenameOptionDialog.h" 3 | #include 4 | 5 | getAutoRenameOptionDialog::getAutoRenameOptionDialog(QWidget *parent) 6 | : QDialog(parent) 7 | , ui(new Ui::getAutoRenameOptionDialog) 8 | { 9 | ui->setupUi(this); 10 | } 11 | 12 | getAutoRenameOptionDialog::~getAutoRenameOptionDialog() 13 | { 14 | delete ui; 15 | } 16 | 17 | void getAutoRenameOptionDialog::accept() 18 | { 19 | emit sendAutorename(ui->checkBox->isChecked()); 20 | 21 | QDialog::accept(); 22 | } 23 | 24 | void getAutoRenameOptionDialog::showDialog() 25 | { 26 | QDialog::show(); 27 | auto buttonSender = qobject_cast(sender()); 28 | if(buttonSender == nullptr) 29 | return; 30 | ui->checkBox->setChecked(buttonSender->text() == "Auto-rename if exists"); 31 | } 32 | -------------------------------------------------------------------------------- /ui/getAutoRenameOptionDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef GETAUTORENAMEOPTIONDIALOG_H 2 | #define GETAUTORENAMEOPTIONDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class getAutoRenameOptionDialog; 8 | } 9 | 10 | class getAutoRenameOptionDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit getAutoRenameOptionDialog(QWidget *parent = nullptr); 16 | ~getAutoRenameOptionDialog(); 17 | private slots: 18 | void accept() override; 19 | public slots: 20 | void showDialog(); 21 | signals: 22 | void sendAutorename(bool autorename); 23 | private: 24 | Ui::getAutoRenameOptionDialog *ui; 25 | }; 26 | 27 | #endif // GETAUTORENAMEOPTIONDIALOG_H 28 | -------------------------------------------------------------------------------- /ui/getAutoRenameOptionDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | getAutoRenameOptionDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 512 10 | 51 11 | 12 | 13 | 14 | Set if new file should be created if file already exists 15 | 16 | 17 | 18 | 2 19 | 20 | 21 | 1 22 | 23 | 24 | 1 25 | 26 | 27 | 1 28 | 29 | 30 | 1 31 | 32 | 33 | 34 | 35 | Automatically rename for a new filename if file already exists 36 | 37 | 38 | 39 | 40 | 41 | 42 | Qt::Orientation::Horizontal 43 | 44 | 45 | QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | buttonBox 55 | accepted() 56 | getAutoRenameOptionDialog 57 | accept() 58 | 59 | 60 | 248 61 | 254 62 | 63 | 64 | 157 65 | 274 66 | 67 | 68 | 69 | 70 | buttonBox 71 | rejected() 72 | getAutoRenameOptionDialog 73 | reject() 74 | 75 | 76 | 316 77 | 260 78 | 79 | 80 | 286 81 | 274 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /ui/getCursorCoordinatesWidget.cpp: -------------------------------------------------------------------------------- 1 | #include "getCursorCoordinatesWidget.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "actions/ActionsTools.h" 7 | 8 | getCursorCoordinatesWidget::getCursorCoordinatesWidget(QWidget *parent) 9 | : QDialog(parent) 10 | { 11 | QPixmap cursorPix(":/img/crosshair.png"); 12 | cursorPix = cursorPix.scaled(32,32); 13 | setCursor(QCursor(cursorPix)); 14 | setWindowOpacity(0.4); 15 | setModal(true); 16 | setWindowFlags(windowFlags() | Qt::FramelessWindowHint); 17 | } 18 | 19 | getCursorCoordinatesWidget::~getCursorCoordinatesWidget() 20 | { 21 | } 22 | 23 | void getCursorCoordinatesWidget::showWidget() 24 | { 25 | auto buttonSender = qobject_cast(sender()); 26 | if(buttonSender == nullptr) 27 | return; 28 | 29 | m_refIndex = buttonSender->property("index").toInt(); 30 | 31 | QDialog::show(); 32 | int width = 0; 33 | int height = 0; 34 | for(auto &screen : QApplication::screens()) 35 | { 36 | width+=screen->geometry().width(); 37 | if(height < screen->geometry().height()) 38 | height = screen->geometry().height(); 39 | } 40 | setGeometry(0,0,width,height); 41 | } 42 | 43 | void getCursorCoordinatesWidget::mouseReleaseEvent(QMouseEvent *ev) 44 | { 45 | auto coordsPair = ActionsTools::getCursorPos(); 46 | emit sendCoordinates(m_refIndex,coordsPair.first,coordsPair.second); 47 | QDialog::close(); 48 | } 49 | -------------------------------------------------------------------------------- /ui/getCursorCoordinatesWidget.h: -------------------------------------------------------------------------------- 1 | #ifndef GETCURSORCOORDINATESWIDGET_H 2 | #define GETCURSORCOORDINATESWIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | class getCursorCoordinatesWidget : public QDialog 8 | { 9 | Q_OBJECT 10 | int m_refIndex = 0; 11 | public: 12 | explicit getCursorCoordinatesWidget(QWidget *parent = nullptr); 13 | ~getCursorCoordinatesWidget(); 14 | public slots: 15 | void showWidget(); 16 | protected: 17 | void mouseReleaseEvent(QMouseEvent*ev) override; 18 | signals: 19 | void sendCoordinates(int index, int x, int y); 20 | }; 21 | 22 | #endif // GETCURSORCOORDINATESWIDGET_H 23 | -------------------------------------------------------------------------------- /ui/getDelayDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "getDelayDialog.h" 2 | #include "ui_getDelayDialog.h" 3 | 4 | #include 5 | #include 6 | 7 | getDelayDialog::getDelayDialog(QWidget *parent) 8 | : QDialog(parent) 9 | , ui(new Ui::getDelayDialog) 10 | { 11 | ui->setupUi(this); 12 | ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Schedule task for run")); 13 | 14 | connect(ui->delayGroup, &QGroupBox::clicked, this, &getDelayDialog::uncheckDateGroup); 15 | connect(ui->dateTimeGroup, &QGroupBox::clicked, this, &getDelayDialog::uncheckDelayGroup); 16 | connect(ui->dateTimeEdit, &QDateTimeEdit::dateTimeChanged, this, &getDelayDialog::refreshDateDelayDetails); 17 | } 18 | 19 | getDelayDialog::~getDelayDialog() 20 | { 21 | delete ui; 22 | } 23 | 24 | void getDelayDialog::uncheckDelayGroup() 25 | { 26 | ui->delayGroup->setChecked(false); 27 | ui->dateTimeGroup->setChecked(true); 28 | } 29 | 30 | void getDelayDialog::uncheckDateGroup() 31 | { 32 | ui->dateTimeGroup->setChecked(false); 33 | ui->delayGroup->setChecked(true); 34 | } 35 | 36 | void getDelayDialog::accept() 37 | { 38 | m_savedDelayTimePart = ui->timeEdit->time(); 39 | m_savedDelayDayPart = ui->spinBox->value(); 40 | 41 | if(ui->delayGroup->isChecked()) 42 | { 43 | qint64 totalDelay = QTime(0,0,0).secsTo(m_savedDelayTimePart); 44 | totalDelay+= m_savedDelayDayPart * 86400; 45 | emit sendDelay(totalDelay); 46 | } 47 | else 48 | { 49 | QDateTime cur = QDateTime::currentDateTime(); 50 | qint64 delayInSec = cur.secsTo(ui->dateTimeEdit->dateTime()); 51 | if(delayInSec < 0) 52 | { 53 | QMessageBox::warning(this, tr("Date selected not correct"), tr("Date/time selected is not later than the current date/time, please set a correct date.")); 54 | return; 55 | } 56 | emit sendDelay(delayInSec); 57 | } 58 | 59 | QDialog::accept(); 60 | } 61 | 62 | void getDelayDialog::refreshDateDelayDetails(const QDateTime & datet) 63 | { 64 | qint64 dateDelay = QDateTime::currentDateTime().secsTo(datet); 65 | qint64 secs = dateDelay % 60; 66 | qint64 minNum = (dateDelay-secs)/60; 67 | qint64 mins = minNum % 60; 68 | qint64 hourNum = (minNum-mins)/ 60 ; 69 | qint64 hours = hourNum %24; 70 | qint64 days = (hourNum - hours)/ 24; 71 | ui->delayDetailsLabel->setText(QString::number(days)+tr(" days ")+QString::number(hours)+tr(" hours ") 72 | +QString::number(mins)+tr(" mins ")+QString::number(secs)+tr(" secs ")); 73 | } 74 | 75 | void getDelayDialog::showDialog() 76 | { 77 | ui->timeEdit->setTime(m_savedDelayTimePart); 78 | ui->spinBox->setValue(m_savedDelayDayPart); 79 | ui->dateTimeEdit->setDateTime(QDateTime::currentDateTime().addSecs(60)); 80 | refreshDateDelayDetails(ui->dateTimeEdit->dateTime()); 81 | show(); 82 | } 83 | -------------------------------------------------------------------------------- /ui/getDelayDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef GETDELAYDIALOG_H 2 | #define GETDELAYDIALOG_H 3 | 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class getDelayDialog; 9 | } 10 | 11 | class getDelayDialog : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit getDelayDialog(QWidget *parent = nullptr); 17 | ~getDelayDialog(); 18 | QTime m_savedDelayTimePart = QTime(0,1,0); 19 | int m_savedDelayDayPart = 0; 20 | private slots: 21 | void uncheckDelayGroup(); 22 | void uncheckDateGroup(); 23 | void accept() override; 24 | void refreshDateDelayDetails(const QDateTime &datet); 25 | public slots: 26 | void showDialog(); 27 | signals: 28 | void sendDelay(qint64 delayInSeconds); 29 | private: 30 | Ui::getDelayDialog *ui; 31 | }; 32 | 33 | #endif // GETDELAYDIALOG_H 34 | -------------------------------------------------------------------------------- /ui/getFilePathDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "getFilePathDialog.h" 2 | #include "ui_getFilePathDialog.h" 3 | #include 4 | 5 | getFilePathDialog::getFilePathDialog(QWidget *parent, bool getSaved) 6 | : QDialog(parent), m_getSavedFileName(getSaved) 7 | , ui(new Ui::getFilePathDialog) 8 | { 9 | ui->setupUi(this); 10 | connect(ui->pushButton, &QPushButton::released, this, &getFilePathDialog::showBrowseFilesDialog); 11 | } 12 | 13 | getFilePathDialog::~getFilePathDialog() 14 | { 15 | delete ui; 16 | } 17 | 18 | void getFilePathDialog::showBrowseFilesDialog() 19 | { 20 | QString dir; 21 | if(m_getSavedFileName) 22 | dir = QFileDialog::getSaveFileName(this, tr("Select a file"),ui->lineEdit->text()); 23 | else 24 | dir = QFileDialog::getOpenFileName(this, tr("Select a file"),ui->lineEdit->text()); 25 | 26 | ui->lineEdit->setText(dir); 27 | } 28 | 29 | void getFilePathDialog::accept() 30 | { 31 | emit sendFile(ui->lineEdit->text()); 32 | 33 | QDialog::accept(); 34 | } 35 | 36 | void getFilePathDialog::showDialog() 37 | { 38 | QDialog::show(); 39 | auto buttonSender = qobject_cast(sender()); 40 | if(buttonSender == nullptr) 41 | return; 42 | ui->lineEdit->setText(buttonSender->text()); 43 | } 44 | -------------------------------------------------------------------------------- /ui/getFilePathDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef GETFILEPATHDIALOG_H 2 | #define GETFILEPATHDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class getFilePathDialog; 8 | } 9 | 10 | class getFilePathDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | bool m_getSavedFileName = false; 14 | public: 15 | explicit getFilePathDialog(QWidget *parent = nullptr, bool getSaved = false); 16 | ~getFilePathDialog(); 17 | private slots: 18 | void showBrowseFilesDialog(); 19 | void accept() override; 20 | public slots: 21 | void showDialog(); 22 | signals: 23 | void sendFile(QString dir); 24 | private: 25 | Ui::getFilePathDialog *ui; 26 | }; 27 | 28 | #endif // GETFILEPATHDIALOG_H 29 | -------------------------------------------------------------------------------- /ui/getFilePathDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | getFilePathDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 559 10 | 78 11 | 12 | 13 | 14 | Set the file option 15 | 16 | 17 | 18 | 2 19 | 20 | 21 | 1 22 | 23 | 24 | 1 25 | 26 | 27 | 1 28 | 29 | 30 | 1 31 | 32 | 33 | 34 | 35 | Set the file (existing or not) on which you would like the operation to proceed : 36 | 37 | 38 | 39 | 40 | 41 | 42 | 2 43 | 44 | 45 | 46 | 47 | C:/... 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 0 56 | 0 57 | 58 | 59 | 60 | Browse a directory in order to help to set the path... 61 | 62 | 63 | 64 | :/img/browseFolder.png:/img/browseFolder.png 65 | 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Qt::Orientation::Horizontal 77 | 78 | 79 | QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | buttonBox 91 | accepted() 92 | getFilePathDialog 93 | accept() 94 | 95 | 96 | 230 97 | 74 98 | 99 | 100 | 230 101 | 47 102 | 103 | 104 | 105 | 106 | buttonBox 107 | rejected() 108 | getFilePathDialog 109 | reject() 110 | 111 | 112 | 230 113 | 74 114 | 115 | 116 | 230 117 | 47 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /ui/getFolderPathDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "getFolderPathDialog.h" 2 | #include "ui_getFolderPathDialog.h" 3 | #include 4 | #include 5 | 6 | getFolderPathDialog::getFolderPathDialog(QWidget *parent) 7 | : QDialog(parent) 8 | , ui(new Ui::getFolderPathDialog) 9 | { 10 | ui->setupUi(this); 11 | connect(ui->pushButton, &QPushButton::released, this, &getFolderPathDialog::showBrowseFoldersDialog); 12 | } 13 | 14 | getFolderPathDialog::~getFolderPathDialog() 15 | { 16 | delete ui; 17 | } 18 | 19 | void getFolderPathDialog::showBrowseFoldersDialog() 20 | { 21 | QString dir = QFileDialog::getExistingDirectory(this, tr("Select a directory"),ui->lineEdit->text(),QFileDialog::ShowDirsOnly); 22 | 23 | ui->lineEdit->setText(dir); 24 | } 25 | 26 | void getFolderPathDialog::accept() 27 | { 28 | emit sendDirectory(ui->lineEdit->text()); 29 | 30 | QDialog::accept(); 31 | } 32 | 33 | void getFolderPathDialog::showDialog() 34 | { 35 | QDialog::show(); 36 | auto buttonSender = qobject_cast(sender()); 37 | if(buttonSender == nullptr) 38 | return; 39 | ui->lineEdit->setText(buttonSender->text()); 40 | } 41 | -------------------------------------------------------------------------------- /ui/getFolderPathDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef GETFOLDERPATHDIALOG_H 2 | #define GETFOLDERPATHDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class getFolderPathDialog; 8 | } 9 | 10 | class getFolderPathDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit getFolderPathDialog(QWidget *parent = nullptr); 16 | ~getFolderPathDialog(); 17 | private slots: 18 | void showBrowseFoldersDialog(); 19 | void accept() override; 20 | public slots: 21 | void showDialog(); 22 | signals: 23 | void sendDirectory(QString dir); 24 | private: 25 | Ui::getFolderPathDialog *ui; 26 | }; 27 | 28 | #endif // GETFOLDERPATHDIALOG_H 29 | -------------------------------------------------------------------------------- /ui/getFolderPathDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | getFolderPathDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 640 10 | 80 11 | 12 | 13 | 14 | Set the directory option 15 | 16 | 17 | 18 | 2 19 | 20 | 21 | 1 22 | 23 | 24 | 1 25 | 26 | 27 | 1 28 | 29 | 30 | 1 31 | 32 | 33 | 34 | 35 | Set the directory (existing or not) on which you would like the operation to proceed : 36 | 37 | 38 | 39 | 40 | 41 | 42 | 2 43 | 44 | 45 | 46 | 47 | C:/... 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 0 56 | 0 57 | 58 | 59 | 60 | Browse a directory in order to help to set the path... 61 | 62 | 63 | 64 | :/img/browseFolder.png:/img/browseFolder.png 65 | 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Qt::Orientation::Horizontal 77 | 78 | 79 | QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | buttonBox 91 | accepted() 92 | getFolderPathDialog 93 | accept() 94 | 95 | 96 | 248 97 | 254 98 | 99 | 100 | 157 101 | 274 102 | 103 | 104 | 105 | 106 | buttonBox 107 | rejected() 108 | getFolderPathDialog 109 | reject() 110 | 111 | 112 | 316 113 | 260 114 | 115 | 116 | 286 117 | 274 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /ui/getImagePathDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "getImagePathDialog.h" 2 | #include "ui_getImagePathDialog.h" 3 | #include 4 | #include 5 | 6 | getImagePathDialog::getImagePathDialog(QWidget *parent) 7 | : QDialog(parent) 8 | , ui(new Ui::getImagePathDialog) 9 | { 10 | ui->setupUi(this); 11 | connect(ui->pushButton, &QPushButton::released, this, &getImagePathDialog::showBrowseFilesDialog); 12 | 13 | } 14 | 15 | getImagePathDialog::~getImagePathDialog() 16 | { 17 | delete ui; 18 | } 19 | 20 | void getImagePathDialog::showBrowseFilesDialog() 21 | { 22 | QString dir = QFileDialog::getSaveFileName(this, tr("Define the image file path"),ui->lineEdit->text(),tr("PNG (*.png)")); 23 | 24 | ui->lineEdit->setText(dir); 25 | } 26 | 27 | void getImagePathDialog::accept() 28 | { 29 | emit sendImage(ui->lineEdit->text()); 30 | 31 | QDialog::accept(); 32 | } 33 | 34 | void getImagePathDialog::showDialog() 35 | { 36 | QDialog::show(); 37 | auto buttonSender = qobject_cast(sender()); 38 | if(buttonSender == nullptr) 39 | return; 40 | ui->lineEdit->setText(buttonSender->text()); 41 | } 42 | -------------------------------------------------------------------------------- /ui/getImagePathDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef GETIMAGEPATHDIALOG_H 2 | #define GETIMAGEPATHDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class getImagePathDialog; 8 | } 9 | 10 | class getImagePathDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit getImagePathDialog(QWidget *parent = nullptr); 16 | ~getImagePathDialog(); 17 | private slots: 18 | void showBrowseFilesDialog(); 19 | void accept() override; 20 | public slots: 21 | void showDialog(); 22 | signals: 23 | void sendImage(QString dir); 24 | private: 25 | Ui::getImagePathDialog *ui; 26 | }; 27 | 28 | #endif // GETIMAGEPATHDIALOG_H 29 | -------------------------------------------------------------------------------- /ui/getImagePathDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | getImagePathDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 518 10 | 72 11 | 12 | 13 | 14 | Set the image file option 15 | 16 | 17 | 18 | 2 19 | 20 | 21 | 1 22 | 23 | 24 | 1 25 | 26 | 27 | 1 28 | 29 | 30 | 1 31 | 32 | 33 | 34 | 35 | Set the file where the screenshot image will be saved : 36 | 37 | 38 | 39 | 40 | 41 | 42 | 2 43 | 44 | 45 | 46 | 47 | C:/... 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 0 56 | 0 57 | 58 | 59 | 60 | Browse a directory in order to help to set the path... 61 | 62 | 63 | 64 | :/img/browseFolder.png:/img/browseFolder.png 65 | 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Qt::Orientation::Horizontal 77 | 78 | 79 | QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | buttonBox 91 | accepted() 92 | getImagePathDialog 93 | accept() 94 | 95 | 96 | 248 97 | 254 98 | 99 | 100 | 157 101 | 274 102 | 103 | 104 | 105 | 106 | buttonBox 107 | rejected() 108 | getImagePathDialog 109 | reject() 110 | 111 | 112 | 316 113 | 260 114 | 115 | 116 | 286 117 | 274 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /ui/getProgramPathDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "getProgramPathDialog.h" 2 | #include "ui_getProgramPathDialog.h" 3 | #include 4 | #include 5 | 6 | getProgramPathDialog::getProgramPathDialog(QWidget *parent) 7 | : QDialog(parent) 8 | , ui(new Ui::getProgramPathDialog) 9 | { 10 | ui->setupUi(this); 11 | connect(ui->pushButton, &QPushButton::released, this, &getProgramPathDialog::showBrowseFilesDialog); 12 | } 13 | 14 | getProgramPathDialog::~getProgramPathDialog() 15 | { 16 | delete ui; 17 | } 18 | 19 | void getProgramPathDialog::showBrowseFilesDialog() 20 | { 21 | QString dir; 22 | dir = QFileDialog::getOpenFileName(this, tr("Select a program"),ui->lineEdit->text()); 23 | 24 | ui->lineEdit->setText(dir); 25 | } 26 | 27 | void getProgramPathDialog::accept() 28 | { 29 | emit sendProgram(ui->lineEdit->text()); 30 | 31 | QDialog::accept(); 32 | } 33 | 34 | void getProgramPathDialog::showDialog() 35 | { 36 | QDialog::show(); 37 | auto buttonSender = qobject_cast(sender()); 38 | if(buttonSender == nullptr) 39 | return; 40 | ui->lineEdit->setText(buttonSender->text()); 41 | } 42 | -------------------------------------------------------------------------------- /ui/getProgramPathDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef GETPROGRAMPATHDIALOG_H 2 | #define GETPROGRAMPATHDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class getProgramPathDialog; 8 | } 9 | 10 | class getProgramPathDialog : public QDialog 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit getProgramPathDialog(QWidget *parent = nullptr); 15 | ~getProgramPathDialog(); 16 | private slots: 17 | void showBrowseFilesDialog(); 18 | void accept() override; 19 | public slots: 20 | void showDialog(); 21 | signals: 22 | void sendProgram(QString dir); 23 | private: 24 | Ui::getProgramPathDialog *ui; 25 | }; 26 | 27 | #endif // GETPROGRAMPATHDIALOG_H 28 | -------------------------------------------------------------------------------- /ui/getProgramPathDialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | getProgramPathDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 485 10 | 72 11 | 12 | 13 | 14 | Set the program option 15 | 16 | 17 | 18 | 2 19 | 20 | 21 | 1 22 | 23 | 24 | 1 25 | 26 | 27 | 1 28 | 29 | 30 | 1 31 | 32 | 33 | 34 | 35 | Set the program on which you would like the operation to proceed : 36 | 37 | 38 | 39 | 40 | 41 | 42 | 2 43 | 44 | 45 | 46 | 47 | C:/... 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 0 56 | 0 57 | 58 | 59 | 60 | Browse a directory in order to help to set the path... 61 | 62 | 63 | 64 | :/img/browseFolder.png:/img/browseFolder.png 65 | 66 | 67 | true 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Qt::Orientation::Horizontal 77 | 78 | 79 | QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | buttonBox 91 | accepted() 92 | getProgramPathDialog 93 | accept() 94 | 95 | 96 | 242 97 | 58 98 | 99 | 100 | 242 101 | 35 102 | 103 | 104 | 105 | 106 | buttonBox 107 | rejected() 108 | getProgramPathDialog 109 | reject() 110 | 111 | 112 | 242 113 | 58 114 | 115 | 116 | 242 117 | 35 118 | 119 | 120 | 121 | 122 | 123 | --------------------------------------------------------------------------------