-
Notifications
You must be signed in to change notification settings - Fork 0
/
installedform.cpp
119 lines (93 loc) · 3.01 KB
/
installedform.cpp
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
#include "installedform.h"
#include "ui_installedform.h"
InstalledForm::InstalledForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::InstalledForm)
{
InitComponents();
QTextCodec::setCodecForTr(QTextCodec::codecForName("Windows-1251"));
QMenu* Menu = new QMenu(this);
Menu->addAction(tr("Óäàëèòü"), this, SLOT(on_DeleteAction_triggered()));
Menu->addAction(tr("Ñâîéñòâà"), this, SLOT(on_PropAction_triggered()));
QAction *RightOption = new QAction("Exit", this);
RightOption->setMenu(Menu);
RightOption->setSoftKeyRole(QAction::NegativeSoftKey);
QObject::connect(RightOption, SIGNAL(triggered()), this, SLOT(close()));
this->addAction(RightOption);
QAction *LeftOption = new QAction("Options", this);
LeftOption->setMenu(Menu);
LeftOption->setSoftKeyRole(QAction::PositiveSoftKey);
this->addAction(LeftOption);
ui->MemLabel->setText(tr("Äîñòóïíî ïàìÿòè: ") + QString::number(ParamsHelper::BytesToMegs(SystemHelper::GetStorageSpace(ParamsHelper::InstallPath))) + tr(" ÌÁ"));
this->InstalledMap = SystemHelper::GetInstalledApps();
if (!this->InstalledMap.isEmpty())
{
int i = 0;
foreach (QString app_name, InstalledMap.keys())
{
ui->InstalledListWidget->insertItem(i, app_name);
i++;
}
}
}
InstalledForm::~InstalledForm()
{
delete ui;
}
void InstalledForm::on_DeleteAction_triggered()
{
SystemHelper *UninstallHelper = new SystemHelper();
uint AppUid = 0;
QString AppName = ui->InstalledListWidget->currentItem()->text();
if (!AppName.isNull() && !AppName.isEmpty())
{
connect(UninstallHelper, SIGNAL(done(bool)), this, SLOT(on_Uninstalling_Complete(bool)));
AppUid = this->InstalledMap.value(AppName);
UninstallHelper->AppUninstall(AppUid);
}
else
{
QMessageBox::warning(this, tr("Ïðåäóïðåæäåíèå"), tr("Ïðèëîæåíèå íå âûáðàíî"), QMessageBox::Ok);
}
}
void InstalledForm::on_PropAction_triggered()
{
}
void InstalledForm::InitLayout(QRect *FormRect)
{
this->setGeometry(*FormRect);
ui->ContentLayout->setGeometry(*FormRect);
ui->gridLayoutWidget->setGeometry(*FormRect);
}
void InstalledForm::resizeEvent(QResizeEvent *event)
{
QRect *FormRect = SystemHelper::GetScreenRect();
InitLayout(FormRect);
}
void InstalledForm::InitComponents()
{
QRect *FormRect = SystemHelper::GetScreenRect();
ui->setupUi(this);
InitLayout(FormRect);
}
void InstalledForm::on_Uninstalling_Complete(bool IsError)
{
if (IsError)
{
QMessageBox::critical(this, tr("Îøèáêà"), tr("Íå óäàëîñü óäàëèòü ïðèëîæåíèå"), QMessageBox::Ok);
}
else
{
this->InstalledMap = SystemHelper::GetInstalledApps();
if (!this->InstalledMap.isEmpty())
{
int i = 0;
ui->InstalledListWidget->clear();
foreach (QString app_name, InstalledMap.keys())
{
ui->InstalledListWidget->insertItem(i, app_name);
i++;
}
}
}
}