mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:46:41 +00:00
UI: MyFort: Add "Uninstall" Portable button
This commit is contained in:
parent
96ff9f5499
commit
43b4ca9adf
@ -21,10 +21,13 @@ HomePage::HomePage(HomeController *ctrl, QWidget *parent) : HomeBasePage(ctrl, p
|
||||
void HomePage::onRetranslateUi()
|
||||
{
|
||||
m_gbDriver->setTitle(tr("Driver"));
|
||||
m_gbPortable->setTitle(tr("Portable"));
|
||||
|
||||
retranslateDriverMessage();
|
||||
m_btInstallDriver->setText(tr("Reinstall"));
|
||||
m_btRemoveDriver->setText(tr("Remove"));
|
||||
|
||||
m_btUninstallPortable->setText(tr("Uninstall"));
|
||||
}
|
||||
|
||||
void HomePage::retranslateDriverMessage()
|
||||
@ -44,6 +47,10 @@ void HomePage::setupUi()
|
||||
setupDriverBox();
|
||||
layout->addWidget(m_gbDriver, 0, Qt::AlignHCenter);
|
||||
|
||||
// Portable Group Box
|
||||
setupPortableBox();
|
||||
layout->addWidget(m_gbPortable, 0, Qt::AlignHCenter);
|
||||
|
||||
layout->addStretch();
|
||||
|
||||
this->setLayout(layout);
|
||||
@ -119,3 +126,38 @@ void HomePage::setupDriverIcon()
|
||||
connect(driverManager(), &DriverManager::errorCodeChanged, this,
|
||||
&HomePage::retranslateDriverMessage);
|
||||
}
|
||||
|
||||
void HomePage::setupPortableBox()
|
||||
{
|
||||
auto colLayout = new QVBoxLayout();
|
||||
colLayout->setSpacing(10);
|
||||
|
||||
// Buttons Row
|
||||
auto buttonsLayout = new QHBoxLayout();
|
||||
buttonsLayout->setSpacing(10);
|
||||
colLayout->addLayout(buttonsLayout);
|
||||
|
||||
m_btUninstallPortable = ControlUtil::createButton(QString(), [&] {
|
||||
windowManager()->showConfirmBox(
|
||||
[&] {
|
||||
FortManager::uninstall();
|
||||
fortManager()->removeDriver();
|
||||
},
|
||||
tr("Are you sure to uninstall the Fort Firewall?"));
|
||||
});
|
||||
|
||||
if (!settings()->isUserAdmin()) {
|
||||
m_btUninstallPortable->setEnabled(false);
|
||||
}
|
||||
|
||||
buttonsLayout->addStretch();
|
||||
buttonsLayout->addWidget(m_btUninstallPortable);
|
||||
buttonsLayout->addStretch();
|
||||
|
||||
m_gbPortable = new QGroupBox();
|
||||
m_gbPortable->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
m_gbPortable->setMinimumWidth(200);
|
||||
m_gbPortable->setLayout(colLayout);
|
||||
|
||||
m_gbPortable->setVisible(settings()->isPortable());
|
||||
}
|
||||
|
@ -19,13 +19,16 @@ private:
|
||||
void setupUi();
|
||||
void setupDriverBox();
|
||||
void setupDriverIcon();
|
||||
void setupPortableBox();
|
||||
|
||||
private:
|
||||
QGroupBox *m_gbDriver = nullptr;
|
||||
QGroupBox *m_gbPortable = nullptr;
|
||||
QLabel *m_iconDriver = nullptr;
|
||||
QLabel *m_labelDriverMessage = nullptr;
|
||||
QPushButton *m_btInstallDriver = nullptr;
|
||||
QPushButton *m_btRemoveDriver = nullptr;
|
||||
QPushButton *m_btUninstallPortable = nullptr;
|
||||
};
|
||||
|
||||
#endif // HOMEPAGE_H
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <appinfo/appinfocache.h>
|
||||
#include <conf/firewallconf.h>
|
||||
#include <control/controlmanager.h>
|
||||
#include <driver/drivercommon.h>
|
||||
#include <form/dialog/passworddialog.h>
|
||||
#include <fortsettings.h>
|
||||
#include <hostinfo/hostinfocache.h>
|
||||
@ -213,6 +214,34 @@ void FortManager::deleteManagers()
|
||||
ioc->autoDeleteAll();
|
||||
}
|
||||
|
||||
void FortManager::install(const char *arg)
|
||||
{
|
||||
switch (arg[0]) {
|
||||
case 'b': { // "boot_filter"
|
||||
DriverCommon::provRegister(/*bootFilter=*/true); // Register booted provider
|
||||
} break;
|
||||
case 'p': { // "portable"
|
||||
FortManager::setupPortableResource();
|
||||
StartupUtil::setPortable(true);
|
||||
} break;
|
||||
case 's': { // "service"
|
||||
StartupUtil::setAutoRunMode(StartupUtil::StartupAllUsers);
|
||||
StartupUtil::setServiceInstalled(true);
|
||||
} break;
|
||||
case 'e': { // "explorer"
|
||||
StartupUtil::setExplorerIntegrated(true);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void FortManager::uninstall()
|
||||
{
|
||||
StartupUtil::setAutoRunMode(StartupUtil::StartupDisabled); // Remove auto-run
|
||||
StartupUtil::setServiceInstalled(false); // Uninstall service
|
||||
StartupUtil::setExplorerIntegrated(false); // Remove Windows Explorer integration
|
||||
DriverCommon::provUnregister(); // Unregister booted provider
|
||||
}
|
||||
|
||||
bool FortManager::installDriver()
|
||||
{
|
||||
closeDriver();
|
||||
|
@ -20,6 +20,9 @@ public:
|
||||
|
||||
void initialize();
|
||||
|
||||
static void install(const char *arg);
|
||||
static void uninstall();
|
||||
|
||||
public slots:
|
||||
bool installDriver();
|
||||
bool removeDriver();
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <fort_version.h>
|
||||
|
||||
#include <control/controlmanager.h>
|
||||
#include <driver/drivercommon.h>
|
||||
#include <fortmanager.h>
|
||||
#include <fortsettings.h>
|
||||
#include <manager/envmanager.h>
|
||||
@ -16,52 +15,23 @@
|
||||
#include <util/fileutil.h>
|
||||
#include <util/ioc/ioccontainer.h>
|
||||
#include <util/service/serviceworker.h>
|
||||
#include <util/startuputil.h>
|
||||
|
||||
namespace {
|
||||
|
||||
#define FORT_ERROR_INSTANCE 1
|
||||
#define FORT_ERROR_CONTROL 2
|
||||
|
||||
void uninstall()
|
||||
{
|
||||
StartupUtil::setAutoRunMode(StartupUtil::StartupDisabled); // Remove auto-run
|
||||
StartupUtil::setServiceInstalled(false); // Uninstall service
|
||||
StartupUtil::setExplorerIntegrated(false); // Remove Windows Explorer integration
|
||||
DriverCommon::provUnregister(); // Unregister booted provider
|
||||
}
|
||||
|
||||
void install(const char *arg)
|
||||
{
|
||||
switch (arg[0]) {
|
||||
case 'b': { // "boot_filter"
|
||||
DriverCommon::provRegister(/*bootFilter=*/true); // Register booted provider
|
||||
} break;
|
||||
case 'p': { // "portable"
|
||||
FortManager::setupPortableResource();
|
||||
StartupUtil::setPortable(true);
|
||||
} break;
|
||||
case 's': { // "service"
|
||||
StartupUtil::setAutoRunMode(StartupUtil::StartupAllUsers);
|
||||
StartupUtil::setServiceInstalled(true);
|
||||
} break;
|
||||
case 'e': { // "explorer"
|
||||
StartupUtil::setExplorerIntegrated(true);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
bool processArgs(int argc, char *argv[])
|
||||
{
|
||||
// Uninstall
|
||||
if (argc > 1 && !strcmp(argv[1], "-u")) {
|
||||
uninstall();
|
||||
FortManager::uninstall();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Install
|
||||
if (argc > 2 && !strcmp(argv[1], "-i")) {
|
||||
install(argv[2]);
|
||||
FortManager::install(argv[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user