-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinfoscreenswin.cpp
More file actions
149 lines (135 loc) · 5.02 KB
/
infoscreenswin.cpp
File metadata and controls
149 lines (135 loc) · 5.02 KB
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
#include "infoscreenswin.h"
#include "ui_infoscreenswin.h"
#include "common.h"
#include "pcloudapp.h"
InfoScreensWin::InfoScreensWin(PCloudApp *a, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::InfoScreensWin)
{
ui->setupUi(this);
app = a;
ui->checkBox_showagain->setChecked(Qt::Checked);
setWindowIcon(QIcon(WINDOW_ICON));
setWindowTitle("pCloud Drive");
this->setWindowFlags(Qt::WindowTitleHint | Qt::CustomizeWindowHint);
this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
this->layout()->setSizeConstraint(QLayout::SetFixedSize);
#ifdef Q_OS_LINUX
ui->label_intro->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeIntro.png"));
ui->label_drive->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeDrive.png"));
ui->label_sync->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeSync.png"));
ui->label_shares->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeShares.png"));
ui->label_crypto->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeCrypto.png"));
ui->label_finish->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeFinish.png"));
#else
ui->label_intro->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeIntroXP.png"));
ui->label_drive->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeDriveXP.png"));
ui->label_sync->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeSyncXP.png"));
ui->label_shares->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeSharesXP.png"));
ui->label_crypto->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeCryptoXP.png"));
ui->label_finish->setPixmap(QPixmap(":/welcomes/images/welcomes/welcomeFinishXP.png"));
#endif
connect(ui->pagesWidget, SIGNAL(currentChanged(int)), this, SLOT(changePageContent(int)));
connect(ui->btnPreviuos, SIGNAL(clicked()), this, SLOT(openPreviousPage()));
connect(ui->btnNext, SIGNAL(clicked()), this, SLOT(openNextPage()));
connect(ui->btnOpenFldr, SIGNAL(clicked()), this, SLOT(finish()));
}
InfoScreensWin::~InfoScreensWin()
{
delete ui;
}
void InfoScreensWin::showEvent(QShowEvent *event)
{
ui->pagesWidget->setCurrentIndex(0);
ui->btnOpenFldr->setVisible(false);
ui->btnPreviuos->setVisible(false);
ui->btnNext->setVisible(true);
if(app->isFirstLaunch)
{
emit this->createDfltSync();
ui->checkBox_showagain->setChecked(Qt::Checked);
}
event->accept();
}
//slots
void InfoScreensWin::changePageContent(int index)
{
switch(index)
{
case WELCOME_INTRO_PAGE_NUM:
qDebug()<<WELCOME_INTRO_PAGE_NUM<<"WELCOME_INTRO_PAGE_NUM";
ui->btnPreviuos->setVisible(false);
break;
case DRIVE_INFO_PAGE_NUM:
qDebug()<<DRIVE_INFO_PAGE_NUM<<"DRIVE_INFO_PAGE_NUM";
ui->btnPreviuos->setVisible(true);
break;
case CRYPTO_INTRO_PAGE_NUM:
qDebug()<<CRYPTO_INTRO_PAGE_NUM<<"CRYPTO_INTRO_PAGE_NUM";
ui->btnOpenFldr->setVisible(false); //if was on last page
ui->btnNext->setVisible(true);
break;
case FINISH_INFO_PAGE_NUM:
qDebug()<<FINISH_INFO_PAGE_NUM<<"FINISH_INFO_PAGE_NUM";
ui->btnNext->setVisible(false);
ui->btnOpenFldr->setVisible(true);
break;
default:
return;
}
}
void InfoScreensWin::openPreviousPage()
{
int currentIndex = ui->pagesWidget->currentIndex();
ui->pagesWidget->setCurrentIndex(currentIndex - 1);
}
void InfoScreensWin::openNextPage()
{
int currentIndex = ui->pagesWidget->currentIndex();
ui->pagesWidget->setCurrentIndex(currentIndex + 1);
}
void InfoScreensWin::finish()
{
if(ui->checkBox_showagain->isChecked())
this->app->settings->setValue("showintrowin",true);
else if(app->settings->contains("showintrowin"))
app->settings->remove("showintrowin");
app->openCloudDir();
this->close();
if(app->settings->contains("autostartcrypto") && app->settings->value("autostartcrypto").toBool())
app->unlockCryptoFldr();
}
void InfoScreensWin::createDfltSync()
{
QString dfltRemotePath = "/pCloud Sync";
pentry_t *pfldr = psync_stat_path(dfltRemotePath.toUtf8());
if(pfldr == NULL)
{
char *err = NULL;
psync_create_remote_folder_by_path(dfltRemotePath.toUtf8(),&err);
if (err)
{
qDebug()<<"create psync default fldr err:"<<err;
return;
}
free(err);
}
QDir *dfltLocalDir;
#ifdef Q_OS_WIN
dfltLocalDir = new QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation));
#else
dfltLocalDir = new QDir(QDir::homePath());
#endif
QString localpath = dfltLocalDir->path().append(OSPathSeparator).append("pCloud Sync");
QDir pcloudDir(localpath);
localpath = dfltLocalDir->toNativeSeparators(localpath);
if(!pcloudDir.exists())
{
dfltLocalDir->mkdir("pCloud Sync");
}
psync_syncid_t id = psync_add_sync_by_path(localpath.toUtf8(),dfltRemotePath.toUtf8(), PSYNC_FULL);
if (id == -1)
app->check_error();
else
app->pCloudWin->get_sync_page()->load();
}