1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
|
/***************************************************************************
* C++ Implementation: *
* Copyright (C) 2012-2017 by Eduard Kalinowski *
* Germany, Lower Saxony, Hanover *
* eduard_kalinowski@yahoo.de *
* *
* HTTraQt is free software; may be distributed and/or modified under the *
* terms of the GNU General Public License version 3 as published by the *
* Free Software Foundation and appearing in the file LICENSE_GPLv3 *
* included in the packaging of this file. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with HTTraQt. If not, see http://www.gnu.org/licenses *
***************************************************************************/
using namespace std;
#include "../../version.h"
#include <QMainWindow>
#include <QWidget>
#include <QCloseEvent>
#include <QStringList>
#include <QString>
#if USE_QT_VERSION == 6
#include <QFileSystemModel>
#else
#include <QDirModel>
#endif
#include <QPixmap>
#include <QMessageBox>
#include <QSystemTrayIcon>
#include <QTimer>
#include <QtGui>
#include <QGroupBox>
#include <QtCore/QSharedMemory>
#ifndef HTTRAQ_H
#define HTTRAQ_H
// #include "../../icons/main.h"
#include "translator.h"
#include "options.h"
#include "ui_mainForm.h"
#define PROGRAM_NAME "HTTraQt"
#define PROGRAM_FULL_NAME "HTTraQt Website Copier v.%s (Qt4/Qt5 based)"
#define LAST_ACTION 6
/* Location */
#define WHTT_LOCATION(a) WhttLocation=(a)
#ifndef HTS_DEF_FWSTRUCT_lien_back
#define HTS_DEF_FWSTRUCT_lien_back
#endif
#ifdef __cplusplus
extern "C"
{
#endif
// #include "includes/htinterface.h"
#include <httrack-library.h>
#include <htsglobal.h>
#include <htswrap.h>
#include <htsopt.h>
#include <htsdefines.h>
#ifdef __cplusplus
}
#endif
#define NStatsBuffer 14
#define MAX_LEN_INPROGRESS 40
#include "htinterface.h"
class buttonPanel;
class QAction;
class QMenu;
class QTextEdit;
struct hInfo {
QString name;
QString tInfo;
int num;
};
typedef struct {
QString name;
QString file;
QString strStatus;
QString url_sav; // pour cancel
QString url_adr;
QString url_fil;
qint64 size;
qint64 sizeTotal;
int offset;
int back;
int actived; // pour disabled
} t_StatsBuffer;
class MessageTimerBox: public QMessageBox
{
private:
int timeout;
bool autoClose;
int currentTime;
QString defaultText;
public:
void setTimeout(int t);
void setDefaultText(const QString &t);
void setAutoClose(bool a);
void showEvent ( QShowEvent * event );
private:
void timerEvent(QTimerEvent *event);
// static int exec(const QString &title, const QString &text, int ticon, int timer);
};
class MessageBox: public cTranslator
{
public:
static int exec(void* p, const QString &title, const QString &text, int ticon);
};
#if USE_QT_VERSION == 6
class DirModel : public QFileSystemModel
{
public:
QVariant headerData ( int section, Qt::Orientation orientation, int role ) const;
};
#else
class DirModel : public QDirModel
{
public:
QVariant headerData ( int section, Qt::Orientation orientation, int role ) const;
};
#endif
class MyThread : public QThread
{
public:
void run();
};
class HTTraQt: public QMainWindow, public Ui::MainWindow, public cTranslator, public cOptions
{
Q_OBJECT
public:
HTTraQt(QWidget* parent = 0, Qt::WindowFlags flags = Qt::WindowType::Widget);
~HTTraQt();
bool rebuildWorkDirView();
void activatePage(int pagenum);
void onCancelAll();
void onQuit();
bool getLangTable();
void setLangGUI();
void translateActions();
void translateActions(QAction* act, int id);
void launch();
void getMainOptionsFromGUI();
void setMainOptionsToGUI();
void initSInfo();
void readGUISettings();
void readSettings(bool global);
void writeSettings(bool global);
void writeGUISettings(void);
void clearStatsBuffer(void);
void setFontForWidgets(void);
void getOptions();
void onEndMirror();
bool checkContinue(bool msg);
void afterChangepathlog();
// void resetDefaultOptions();
bool RemoveEmptyDir(QString path);
public slots:
void pauseTransfer();
void onStopAll();
void displayOutputMsg();
void displayProgressMsg();
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
bool treeItemClicked(const QModelIndex &m);
// void resizeTabs(QResizeEvent* re);
void refreshDirModel();
protected:
void closeEvent(QCloseEvent *event);
// void changeEvent(QEvent* re);
private slots:
void threadFinished();
void newProject();
void browseSites();
void setLang(QAction* mnu);
void quit();
void loadDefaultOptions();
void saveDefaultOptions();
void resetToDefault();
void loadOptionsFromFile();
void saveOptionsAs();
void selectFontSize(QAction* mnu);
void modifyOptions();
void setOptions();
void viewLog();
void viewErrorLog();
void viewTransfers();
void hideWindow();
void restoreWindow();
// void createFontSizeMenu();
bool readLangDir();
void checkUpdates();
void contens();
void stepByStep();
void about();
void aboutQt();
void iconActivated(QSystemTrayIcon::ActivationReason reason);
private:
void shutdown();
void hibernate();
void createTrayIcon();
void renameOldToNew();
void convertTranslateFiles();
QString sizeToText(qint64 s);
void gOptions(bool d);
QString getLocaleString();
int removeFolder(QDir &dir);
bool getStrOption(const QString optName, QString &ret);
bool getIntOption(const QString optName, int &ret);
void createActions();
void createToolBars();
void createStatusBar();
// void cmdArgumentsOptions();
QString change(char* chaine, char c);
bool checkInstanceRuns();
void contextMenuEvent(QContextMenuEvent *);
public:
QPixmap *mainpix;
QPixmap *mainicon;
QTimer *timerProgressUpdate;
QTimer *timerDirRefresh;
QWidget *widgets[6];
// QVector<options> prOptions;
// QMap<QString, OptStruct> prOptions;
buttonPanel* buttonsWidget;
int m_todo;
private:
QSharedMemory *_singular;
QString filename;
MyThread* mth;
QString agumentsLine;
QStringList lastDirs;
QVector<QAction*> actLangSelect;
QVector<QAction*> actFSizeSelect;
QMenu *langMenu;
QAction* restAct;
QActionGroup* langGroup;
// int dictFormat; // 0 no file, 1 old, 2 new
// System tray icon
bool verbose;
bool pcShutdown;
bool pcHibernate;
// System tray menu
QMenu* trayIconMenu;
public:
QStringList lst;
char* argv[256];
short argc;
QProcess* process;
QString cmdOpt;
// flag de termination
int termine;
static int arretbrutal;
int termine_requested;
int shell_terminated;
bool use_show;
int soft_term_requested;
httrackp *global_opt;
bool inprogress;
int currentTab;
QFont sysFont;
short fontSize;
QString programStyleSheet;
QSystemTrayIcon* trayIcon;
/*static*/
t_InpInfo SInfo;
t_StatsBuffer StatsBuffer[NStatsBuffer]; // interface to progres tab
QStringList langFiles;
DirModel dModel;
QMutex mutex;
QString currentOptionsFile;
QString defaultOptionsFile;
QString helpDir;
QString langDir;
QString currentLang;
};
#endif
|