mirror of
https://github.com/Adaptix-Framework/AdaptixC2
synced 2026-06-08 10:20:39 +00:00
Revert "Refactor tab names management: extract TabNamesUtils and optimize QSettings usage"
This reverts commit e1cc716d15.
This commit is contained in:
@@ -153,7 +153,6 @@ SET( HEADERS
|
||||
Headers/Utils/NonBlockingDialogs.h
|
||||
Headers/Utils/FontManager.h
|
||||
Headers/Utils/TitleBarStyle.h
|
||||
Headers/Utils/TabNamesUtils.h
|
||||
Headers/UI/Widgets/DockWidgetRegister.h
|
||||
)
|
||||
|
||||
@@ -234,7 +233,6 @@ add_executable(AdaptixClient
|
||||
Source/Utils/NonBlockingDialogs.cpp
|
||||
Source/Utils/FontManager.cpp
|
||||
Source/Utils/TitleBarStyle.cpp
|
||||
Source/Utils/TabNamesUtils.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <QSet>
|
||||
#include <MainAdaptix.h>
|
||||
#include <Client/Settings.h>
|
||||
#include <Utils/TabNamesUtils.h>
|
||||
#include <typeinfo>
|
||||
#include <cstdlib>
|
||||
#ifdef __GNUC__
|
||||
@@ -88,20 +87,7 @@ protected:
|
||||
public:
|
||||
DockTab(const QString &tabName, const QString &projectName, const QString &icon = "") {
|
||||
dockWidget = new KDDockWidgets::QtWidgets::DockWidget(tabName + ":Dock-" + projectName, KDDockWidgets::DockWidgetOption_None, KDDockWidgets::LayoutSaverOption::None);
|
||||
|
||||
QString displayTitle = tabName;
|
||||
bool isRenameable = tabName.startsWith("Console [") ||
|
||||
tabName.startsWith("Terminal [") ||
|
||||
tabName.startsWith("Files [") ||
|
||||
tabName.startsWith("Processes [");
|
||||
|
||||
if (isRenameable) {
|
||||
QString customTitle = TabNamesUtils::getCustomTabName(tabName, projectName);
|
||||
if (!customTitle.isEmpty())
|
||||
displayTitle = customTitle;
|
||||
}
|
||||
|
||||
dockWidget->setTitle(displayTitle);
|
||||
dockWidget->setTitle(tabName);
|
||||
if (!icon.isEmpty())
|
||||
dockWidget->setIcon(QIcon(icon), KDDockWidgets::IconPlace::TabBar);
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef ADAPTIXCLIENT_TABNAMESUTILS_H
|
||||
#define ADAPTIXCLIENT_TABNAMESUTILS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class TabNamesUtils
|
||||
{
|
||||
public:
|
||||
static void removeAgentTabNames(const QString &agentId, const QString &projectName);
|
||||
static QString getCustomTabName(const QString &tabName, const QString &projectName);
|
||||
static void setCustomTabName(const QString &uniqueName, const QString &customTitle);
|
||||
static void removeCustomTabName(const QString &uniqueName);
|
||||
static bool hasCustomTabName(const QString &uniqueName);
|
||||
static QString buildUniqueName(const QString &tabName, const QString &projectName);
|
||||
};
|
||||
|
||||
#endif // ADAPTIXCLIENT_TABNAMESUTILS_H
|
||||
@@ -33,7 +33,6 @@
|
||||
# define KDDOCKWIDGETS_DEPRECATED_NO_EXPORT KDDOCKWIDGETS_NO_EXPORT KDDOCKWIDGETS_DEPRECATED
|
||||
#endif
|
||||
|
||||
/* NOLINTNEXTLINE(readability-avoid-unconditional-preprocessor-if) */
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef KDDOCKWIDGETS_NO_DEPRECATED
|
||||
# define KDDOCKWIDGETS_NO_DEPRECATED
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <Client/TunnelEndpoint.h>
|
||||
#include <Client/AuthProfile.h>
|
||||
#include <MainAdaptix.h>
|
||||
#include <Utils/TabNamesUtils.h>
|
||||
|
||||
REGISTER_DOCK_WIDGET(SessionsTableWidget, "Sessions", true)
|
||||
|
||||
@@ -168,9 +167,6 @@ void SessionsTableWidget::RemoveAgentItem(const QString &agentId) const
|
||||
Agent* agent = adaptixWidget->AgentsMap[agentId];
|
||||
adaptixWidget->AgentsMap.remove(agentId);
|
||||
|
||||
QString projectName = adaptixWidget->GetProfile()->GetProject();
|
||||
TabNamesUtils::removeAgentTabNames(agentId, projectName);
|
||||
|
||||
if (agent->Console)
|
||||
delete agent->Console;
|
||||
if (agent->FileBrowser)
|
||||
@@ -226,14 +222,9 @@ void SessionsTableWidget::UpdateData() const
|
||||
|
||||
void SessionsTableWidget::Clear() const
|
||||
{
|
||||
QString projectName = adaptixWidget->GetProfile()->GetProject();
|
||||
|
||||
for (auto agentId : adaptixWidget->AgentsMap.keys()) {
|
||||
Agent* agent = adaptixWidget->AgentsMap[agentId];
|
||||
adaptixWidget->AgentsMap.remove(agentId);
|
||||
|
||||
TabNamesUtils::removeAgentTabNames(agentId, projectName);
|
||||
|
||||
delete agent->Console;
|
||||
delete agent->FileBrowser;
|
||||
delete agent->ProcessBrowser;
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#include <Utils/TabNamesUtils.h>
|
||||
#include <QSettings>
|
||||
#include <QStringList>
|
||||
|
||||
namespace {
|
||||
constexpr const char* SETTINGS_ORG = "Adaptix";
|
||||
constexpr const char* SETTINGS_APP = "AdaptixClient";
|
||||
constexpr const char* TAB_NAMES_PREFIX = "TabNames/";
|
||||
const QStringList TAB_TYPES = {"Console [", "Terminal [", "Files [", "Processes ["};
|
||||
|
||||
QSettings& getSettings() {
|
||||
static QSettings settings(SETTINGS_ORG, SETTINGS_APP);
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
||||
void TabNamesUtils::removeAgentTabNames(const QString &agentId, const QString &projectName)
|
||||
{
|
||||
QSettings& settings = getSettings();
|
||||
|
||||
for (const QString& tabType : TAB_TYPES) {
|
||||
QString uniqueName = tabType + agentId + "]:Dock-" + projectName;
|
||||
settings.remove(TAB_NAMES_PREFIX + uniqueName);
|
||||
}
|
||||
}
|
||||
|
||||
QString TabNamesUtils::getCustomTabName(const QString &tabName, const QString &projectName)
|
||||
{
|
||||
QString uniqueName = buildUniqueName(tabName, projectName);
|
||||
QSettings& settings = getSettings();
|
||||
return settings.value(TAB_NAMES_PREFIX + uniqueName).toString();
|
||||
}
|
||||
|
||||
void TabNamesUtils::setCustomTabName(const QString &uniqueName, const QString &customTitle)
|
||||
{
|
||||
QSettings& settings = getSettings();
|
||||
settings.setValue(TAB_NAMES_PREFIX + uniqueName, customTitle);
|
||||
}
|
||||
|
||||
void TabNamesUtils::removeCustomTabName(const QString &uniqueName)
|
||||
{
|
||||
QSettings& settings = getSettings();
|
||||
settings.remove(TAB_NAMES_PREFIX + uniqueName);
|
||||
}
|
||||
|
||||
bool TabNamesUtils::hasCustomTabName(const QString &uniqueName)
|
||||
{
|
||||
QSettings& settings = getSettings();
|
||||
return settings.contains(TAB_NAMES_PREFIX + uniqueName);
|
||||
}
|
||||
|
||||
QString TabNamesUtils::buildUniqueName(const QString &tabName, const QString &projectName)
|
||||
{
|
||||
return tabName + ":Dock-" + projectName;
|
||||
}
|
||||
Reference in New Issue
Block a user