Debian Codegraph @

src/luckybackupwindow.h

raw symbols SCIP
1 /* ------------------ luckybackupwindow.h --------------------------------------------------------------------------------------
2 header file for luckyBackup project
3
4 ===============================================================================================================================
5 ===============================================================================================================================
6 This file is part of "luckyBackup" project
7 Copyright, Loukas Avgeriou
8 luckyBackup is distributed under the terms of the GNU General Public License
9 luckyBackup is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 luckyBackup is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with luckyBackup. If not, see <http://www.gnu.org/licenses/>.
21
22
23 project version : Please see "main.cpp" for project version
24
25 developer : luckyb
26 last modified : 07 Feb 2014
27 ===============================================================================================================================
28 ===============================================================================================================================
29 */
30
31
32 #ifndef LUCKYBACKUPWINDOW_H
33 #define LUCKYBACKUPWINDOW_H
34
35 //include header file that qmake produces from "*.ui" created with qt designer
36 #include "ui_luckybackupwindow.h"
37 #include <QSystemTrayIcon>
38
39 //==============================================================================================================
40 //Declaration of luckyBackupWindow class (this is the main window of the app)
41 class luckyBackupWindow : public QMainWindow
42 {
43 Q_OBJECT
44
45 public:
46 luckyBackupWindow (QMainWindow *parent = 0);
47
48 // general variables
49 bool taskClicked; //these 2 bool vars help to determine when a checkbox state is changed for SLOT taskStateChanged
50 bool taskChanged;
51 bool savedProfile; // Becomes true if a profile is saved and false if it is modified
52
53 bool GoBack; // Becomes true if the user tries to load a profile, but regrets it !!
54 QString InfoData; //String holding the information window text
55 QString createData; //String holding messages from createCurrentProfile
56 QString loadData; //String holding messages from loadCurrentProfile
57 QString saveData; //String holding messages from saveCurrentProfile
58
59 int InfoInt; // this helps to define which message will appear at the info window
60 int count; //simple count variable !!
61
62 private slots:
63 void profileComboChanged(); // SLOT to set the currentProfile when profileCombo index changes
64 void savePressed(); // SLOT to execute when "save" pressed
65 void deleteCurrentProfile();//SLOT: Delete the current profile
66 void NewProfile(); //SLOT: Create a new empty profile
67 void setDefaultProfile(); //SLOT: Set the current profile as default
68 void renameCurrentProfile();//SLOT: rename the current profile
69 void exportProfile(); //SLOT to export a profile
70 void importProfile(); //SLOT to import a profile
71 void duplicateProfile(); //SLOT to duplicate a profile
72 void changeProfileDescription();//SLOT to change the profile description
73
74 void exitApp(); //SLOT: check if a profile is saved and exit application
75
76 void help(); //SLOT: open "help" popup when action selected
77 void about(); //SLOT: open "about" popup when action selected
78 void setToolbarAttrs(); //SLOT: sets the toolbar attributes
79 void setWinPaths(); //SLOT: sets the rsync and ssh paths for windows
80
81 void setLanguage(QAction *);//SLOT: Change the application language
82
83 void checkCurrentItem(QListWidgetItem *); //SLOT: Check the currently selected operation and set an icon
84 void taskStateChanged(); //SLOT: Sets the profile state to unsaved if a task checkbox is changed
85 void refreshList(); //SLOT: Refresh the operations list when refresh button pressed
86 void start(); //SLOT: Open start operations dialog when Button clicked()
87 void modify(); //SLOT: Modify an existing task. Will also save it if bool is true
88 void add(); //SLOT: Add a new task
89 void remove(); //SLOT: remove highlighted task
90 void manage(); //SLOT: Manage existing backups of an existing task
91 void AlsoCreateRestore(); //SLOT: Create another operation for RESTORE
92 void duplicateTask(); //SLOT to duplicate a task
93 void moveUp(); //SLOT: move highlighted operation one position up
94 void moveDown(); //SLOT: move highlighted operation one position down
95 void schedule(); //SLOT: Open schedule dialog when Button clicked()
96 void email(); //SLOT: Open email dialog when Button clicked()
97
98 void hideShowInfoWindow(); // SLOT to hide or show the info window
99
100 //execute.cpp SLOTS
101 void abortPressed(); //SLOT when button pressed( see also notYet)
102 void donePressed(); //SLOT when done button pressed
103 void appendRsyncOutput(); //Display o/p to textbrowser & update logfile
104 /*disable vss until...
105 void appendRsyncVssOutput();
106 void appendRsyncVssOutput(int size);*/
107 void procFinished(); //SLOT executed when syncProcess is finshed (will start a new syncProcess if any left)
108 void procError(); // SLOT for when a process reports an error (eg: failed to start)
109
110 void LBtrayActivated(QSystemTrayIcon::ActivationReason reason);
111 void minimizeTray();
112 void restoreTray();
113
114 void previousErrorJump();
115 void nextErrorJump();
116
117 private:
118 Ui::luckyBackupWindow ui;
119
120 QSystemTrayIcon *LBtray; //this is luckybackup's tray icon
121 QMenu *languageMenu;
122 QMenu *settingsMenu;
123 QMenu *toolbarsMenu;
124 QActionGroup *languageGroup;
125 QActionGroup *toolbarsGroup;
126 QMenu *helpMenu;
127 QAction *action;
128 QAction *actionHelp;
129 QAction *actionAbout;
130 QToolBar *profileToolbar;
131 QToolBar *profileComboToolbar;
132 QToolBar *profileStartToolbar;
133 QToolBar *shutdownToolbar;
134 QToolBar *errorsToolbar;
135 QAction *visibleProfileToolbar;
136 QAction *visibleProfileComboToolbar;
137 QAction *visibleProfileStartToolbar;
138 QAction *actionLockToolbars;
139 QAction *actionVisibleToolbarText;
140 QAction *actionSetWinPaths;
141 QStringList deletedTaskNames;
142 bool saveOrNot;
143
144 //The following functions are inside functions.cpp~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145 void setCurrentProfile(QString);//function to check if a profile is valid and load it by calling loadProfile
146 bool loadCurrentProfile(); //function to load an existing profile
147 bool saveCurrentProfile(); //function to save a profile
148 int createCurrentProfile(); //function to create a profile
149 int isProfileSaved(); //function to check if the current profile is saved and proceed or not
150 void checkDeclared(); //function to check all declared data of included operations
151 bool checkOperationList(); // function to first check the operations list for errors (eg nothing is included)
152 void retranslateUi(); //function to retranslate the ui when user changes the gui language
153 void createMenus(); // create the menu "language" with all available languages & menu "help"
154 void createToolbar(); // create the toolbar
155 void createActions(); // create all actions
156 void createProfileCombo(); // fill the profile combo box with existing profile names
157 bool saveSettings(); //saves various luckybackup settings such as the default profile
158 bool loadSettings(); //loads various luckybackup settings such as the default profile - text mode
159 bool loadSettingsQV(); //loads various luckybackup settings such as the default profile - data mode
160 void InitializeVariables(); //initializes all variables
161 bool arrangeLogSnap(bool,QString,QString);//Rename-delete-copy logs & snaps when a profile/task is renamed, deleted,duplicated
162
163 QString defaultLanguage; // holds the app's default language
164 QString TransDir; // holds the actual translation directory path
165 QUrl helpURL; // holds the actual manual path as a QUrl
166 QString manualChapter; // holds the specific chapter of the manual. changes depending on which window is open
167 QUrl licenseURL; // holds the actual license path as a QUrl
168 int mainWindowWidth; // holds the main window width in pixels
169 int mainWindowHeight; // holds the main window height in pixels
170 bool AreToolbarsLocked; // holds the lock state of the toolbars
171 bool IsVisibleProfileComboToolbar; // holds the visible state of the profile combo toolbar
172 bool IsVisibleProfileToolbar; // holds the visible state of the profile actions toolbar
173 bool IsVisibleProfileStartToolbar; // holds the visible state of the profile start toolbar
174 bool IsVisibleToolbarText; // holds the visible state of the toolbar text
175 bool IsVisibleInfoWindow; // holds the visible state of the info window
176 bool showOnlyErrors; //This becomes true if the user selects to only display errors at the commands output window
177
178 //inside execute.cpp-----------------------------------------------------
179 void executeNOW(); //start the execution of commands (rsync & others)
180 void setNowDoing(); //Display sth in the Now Doing textBrowser
181 void executeRsync(); //execute qprocess "rsync" with Arguments
182 void swapGUI(QString); //swaps the gui mode from normal to execute
183 int errorCount; //used for next/previous error button
184 bool firstScroll; //used for next/previous error button
185 bool NOWexecuting; //becomes true if a profile execution is running
186 bool guiModeNormal; //becomes true when the gui is in normnal mode
187 bool ABORTpressed; //becomes true if the abort button is pressed
188 void finishUp(); // finish up some stuff when all tasks finish either normally or aborted
189 void shutDownSystem(); // shutdown the system if the relevant button is pressed
190 QString convertBytes(QString,bool); // Converts a string of the form of 10GB to bytes and vice versa
191
192 //Progress bar variables
193 int progress_total; //Maximum value of progress
194 int progress_done; //Current value of progress
195
196 //variables used for rsync command
197 QString command; //command to be executed. Normally this is "rsync"
198 QStringList rsyncArguments; // This stringList holds all arguments for the rsync command
199 QString outputString; //all the output of rsync is going to fit in here
200 QString outputError; //all the error output of rsync is going to fit in here
201 QString outputInsert; //this is used to enter application output between outputString/Error
202 QString nowDoingText; //this is the text printed in the NowDoing textBrowser
203
204 bool sync; //becomes true if syncing is to be executed
205 bool syncAB; //becomes true if syncing from dirA to dirB is to be executed
206 QString dirA; //holds the first dir to be synced
207 QString dirB; //holds the second dir to be synced
208
209 bool calculating; //these 3 bools are used to diplay progress of rsync at the info window
210 bool transferring;
211 bool deleting;
212
213 bool ExecuteBefore; //becomes true if a before command is to be executed, not rsync !!
214 bool ExecuteAfter; //becomes true if a after command is to be executed, not rsync !!
215 bool ExecuteBeforeExitedError; // becomes true if a before command exits with an error
216 bool StopTaskExecution; // becomes true if we want to stop task execution
217 bool ProcReportedError; //becomes true if any process reports an error (eg failed to start)
218 bool DestCreateFail; // This will become true if destination does not exist and cannot be created
219 int repeatOnFailMax; // This is equal to the number of times a command will run when it fails
220 int repeatOnFailTry; // This is the current run of a command
221 int currentBefore; //count variable for commands to be executed before task
222 int currentAfter; //count variable for commands to be executed before task
223 void executeBeforeTask(); //function to start execution of pre-task commands
224 void executeAfterTask(); //function to start execution of post-task commands
225
226 //tray icon stuff
227 QString trayMessage; // tray baloon message text
228 QAction *actionAbort;
229 QAction *minimizeToTray;
230 QAction *restoreFromTray;
231 QMenu *LBtrayMenu;
232 void createTrayIcon(); // create the tray icon + relevant actions
233 bool isMinimizedToTray; // becomes true if the gui is minimized to tray
234
235 protected:
236 void closeEvent(QCloseEvent *event);
237 };
238
239 #endif
240
241 // end of luckybackupwindow.h--------------------------------------------------------------