Internal
Public Access
Merge Profiles and Session windows into a single window
ProfilesWindow and SessionWindow were two independent top-level windows, coordinated through a QPointer and manual show/create-or-reuse logic, with duplicated Help menus and a path where Quit didn't actually quit if a SessionWindow happened to be open. ProfilesWindow is now an embedded QWidget shown as a permanent, unclosable "Profiles" tab inside SessionWindow's tab widget; SessionWindow is the app's sole top-level window. Double-clicking a profile opens a session tab in the same window instead of finding-or-creating a second one, and closing all session tabs falls back to the Profiles tab rather than closing the app. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+29
-71
@@ -1,10 +1,8 @@
|
||||
#include "profiles_window.h"
|
||||
|
||||
#include "about_dialog.h"
|
||||
#include "profile_dialog.h"
|
||||
#include "profile_repository.h"
|
||||
#include "profiles_tree_widget.h"
|
||||
#include "session_window.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QAbstractItemView>
|
||||
@@ -15,13 +13,11 @@
|
||||
#include <QLineEdit>
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSet>
|
||||
#include <QSettings>
|
||||
#include <QSignalBlocker>
|
||||
#include <QApplication>
|
||||
#include <QStringList>
|
||||
#include <QStyle>
|
||||
#include <QTreeWidget>
|
||||
@@ -92,7 +88,7 @@ bool profileHasTag(const Profile& profile, const QString& requestedTag)
|
||||
}
|
||||
|
||||
ProfilesWindow::ProfilesWindow(QWidget* parent)
|
||||
: QMainWindow(parent),
|
||||
: QWidget(parent),
|
||||
m_searchBox(nullptr),
|
||||
m_viewModeBox(nullptr),
|
||||
m_sortBox(nullptr),
|
||||
@@ -104,10 +100,6 @@ ProfilesWindow::ProfilesWindow(QWidget* parent)
|
||||
m_deleteButton(nullptr),
|
||||
m_repository(std::make_unique<ProfileRepository>())
|
||||
{
|
||||
setWindowTitle(QStringLiteral("OrbitHub Profiles"));
|
||||
resize(860, 640);
|
||||
setWindowIcon(QApplication::windowIcon());
|
||||
|
||||
setupUi();
|
||||
|
||||
if (!m_repository->initError().isEmpty()) {
|
||||
@@ -131,36 +123,35 @@ ProfilesWindow::~ProfilesWindow() = default;
|
||||
|
||||
void ProfilesWindow::setupUi()
|
||||
{
|
||||
auto* central = new QWidget(this);
|
||||
auto* rootLayout = new QVBoxLayout(central);
|
||||
auto* rootLayout = new QVBoxLayout(this);
|
||||
|
||||
auto* searchLabel = new QLabel(QStringLiteral("Search"), central);
|
||||
m_searchBox = new QLineEdit(central);
|
||||
auto* searchLabel = new QLabel(QStringLiteral("Search"), this);
|
||||
m_searchBox = new QLineEdit(this);
|
||||
m_searchBox->setPlaceholderText(QStringLiteral("Filter by name, host, folder, or tags..."));
|
||||
|
||||
auto* viewModeLabel = new QLabel(QStringLiteral("View"), central);
|
||||
m_viewModeBox = new QComboBox(central);
|
||||
auto* viewModeLabel = new QLabel(QStringLiteral("View"), this);
|
||||
m_viewModeBox = new QComboBox(this);
|
||||
m_viewModeBox->addItem(QStringLiteral("List"));
|
||||
m_viewModeBox->addItem(QStringLiteral("Folders"));
|
||||
|
||||
auto* sortLabel = new QLabel(QStringLiteral("Sort"), central);
|
||||
m_sortBox = new QComboBox(central);
|
||||
auto* sortLabel = new QLabel(QStringLiteral("Sort"), this);
|
||||
m_sortBox = new QComboBox(this);
|
||||
m_sortBox->addItem(QStringLiteral("Name"), static_cast<int>(ProfileSortOrder::NameAsc));
|
||||
m_sortBox->addItem(QStringLiteral("Protocol"), static_cast<int>(ProfileSortOrder::ProtocolAsc));
|
||||
m_sortBox->addItem(QStringLiteral("Host"), static_cast<int>(ProfileSortOrder::HostAsc));
|
||||
|
||||
auto* protocolFilterLabel = new QLabel(QStringLiteral("Protocol"), central);
|
||||
m_protocolFilterBox = new QComboBox(central);
|
||||
auto* protocolFilterLabel = new QLabel(QStringLiteral("Protocol"), this);
|
||||
m_protocolFilterBox = new QComboBox(this);
|
||||
m_protocolFilterBox->addItem(QStringLiteral("All"));
|
||||
m_protocolFilterBox->addItem(QStringLiteral("SSH"));
|
||||
m_protocolFilterBox->addItem(QStringLiteral("RDP"));
|
||||
m_protocolFilterBox->addItem(QStringLiteral("VNC"));
|
||||
|
||||
auto* tagFilterLabel = new QLabel(QStringLiteral("Tag"), central);
|
||||
m_tagFilterBox = new QComboBox(central);
|
||||
auto* tagFilterLabel = new QLabel(QStringLiteral("Tag"), this);
|
||||
m_tagFilterBox = new QComboBox(this);
|
||||
m_tagFilterBox->addItem(QStringLiteral("All"));
|
||||
|
||||
m_profilesTree = new ProfilesTreeWidget(central);
|
||||
m_profilesTree = new ProfilesTreeWidget(this);
|
||||
m_profilesTree->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
m_profilesTree->setColumnCount(4);
|
||||
m_profilesTree->setHeaderLabels(
|
||||
@@ -179,9 +170,9 @@ void ProfilesWindow::setupUi()
|
||||
m_profilesTree->header()->setSectionResizeMode(3, QHeaderView::Stretch);
|
||||
|
||||
auto* buttonRow = new QHBoxLayout();
|
||||
m_newButton = new QPushButton(QStringLiteral("New"), central);
|
||||
m_editButton = new QPushButton(QStringLiteral("Edit"), central);
|
||||
m_deleteButton = new QPushButton(QStringLiteral("Delete"), central);
|
||||
m_newButton = new QPushButton(QStringLiteral("New"), this);
|
||||
m_editButton = new QPushButton(QStringLiteral("Edit"), this);
|
||||
m_deleteButton = new QPushButton(QStringLiteral("Delete"), this);
|
||||
|
||||
buttonRow->addWidget(m_newButton);
|
||||
buttonRow->addWidget(m_editButton);
|
||||
@@ -204,40 +195,6 @@ void ProfilesWindow::setupUi()
|
||||
rootLayout->addWidget(m_profilesTree, 1);
|
||||
rootLayout->addLayout(buttonRow);
|
||||
|
||||
setCentralWidget(central);
|
||||
|
||||
QMenu* fileMenu = menuBar()->addMenu(QStringLiteral("File"));
|
||||
QAction* newProfileAction = fileMenu->addAction(QStringLiteral("New Profile"));
|
||||
QAction* newFolderAction = fileMenu->addAction(QStringLiteral("New Folder"));
|
||||
fileMenu->addSeparator();
|
||||
QAction* quitAction = fileMenu->addAction(QStringLiteral("Quit"));
|
||||
|
||||
connect(newProfileAction,
|
||||
&QAction::triggered,
|
||||
this,
|
||||
[this]() {
|
||||
const QString folderPath = folderPathForItem(m_profilesTree->currentItem());
|
||||
createProfile(folderPath);
|
||||
});
|
||||
connect(newFolderAction,
|
||||
&QAction::triggered,
|
||||
this,
|
||||
[this]() {
|
||||
const QString folderPath = folderPathForItem(m_profilesTree->currentItem());
|
||||
createFolderInContext(folderPath);
|
||||
});
|
||||
connect(quitAction, &QAction::triggered, this, [this]() { close(); });
|
||||
|
||||
QMenu* helpMenu = menuBar()->addMenu(QStringLiteral("Help"));
|
||||
QAction* aboutAction = helpMenu->addAction(QStringLiteral("About OrbitHub"));
|
||||
connect(aboutAction,
|
||||
&QAction::triggered,
|
||||
this,
|
||||
[this]() {
|
||||
AboutDialog dialog(this);
|
||||
dialog.exec();
|
||||
});
|
||||
|
||||
connect(m_searchBox,
|
||||
&QLineEdit::textChanged,
|
||||
this,
|
||||
@@ -959,16 +916,17 @@ void ProfilesWindow::openSessionForItem(QTreeWidgetItem* item)
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_sessionWindow.isNull()) {
|
||||
m_sessionWindow = new SessionWindow(profile.value());
|
||||
m_sessionWindow->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(m_sessionWindow, &QObject::destroyed, this, [this]() { m_sessionWindow = nullptr; });
|
||||
} else {
|
||||
m_sessionWindow->openProfile(profile.value());
|
||||
}
|
||||
|
||||
m_sessionWindow->setWindowState(m_sessionWindow->windowState() & ~Qt::WindowMinimized);
|
||||
m_sessionWindow->show();
|
||||
m_sessionWindow->raise();
|
||||
m_sessionWindow->activateWindow();
|
||||
emit connectRequested(profile.value());
|
||||
}
|
||||
|
||||
void ProfilesWindow::createProfileInCurrentContext()
|
||||
{
|
||||
const QString folderPath = folderPathForItem(m_profilesTree->currentItem());
|
||||
createProfile(folderPath);
|
||||
}
|
||||
|
||||
void ProfilesWindow::createFolderInCurrentContext()
|
||||
{
|
||||
const QString folderPath = folderPathForItem(m_profilesTree->currentItem());
|
||||
createFolderInContext(folderPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user