Internal
Public Access
Milestone 8 UX: folder tree workflows, about dialog, and app icon polish
This commit is contained in:
+71
-1
@@ -1,11 +1,15 @@
|
||||
#include "session_window.h"
|
||||
|
||||
#include "about_dialog.h"
|
||||
#include <QApplication>
|
||||
#include "session_tab.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QColor>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QPalette>
|
||||
#include <QSettings>
|
||||
#include <QStringList>
|
||||
#include <QTabBar>
|
||||
#include <QTabWidget>
|
||||
@@ -36,8 +40,11 @@ QStringList terminalThemeNames()
|
||||
SessionWindow::SessionWindow(const Profile& profile, QWidget* parent)
|
||||
: QMainWindow(parent), m_tabs(new QTabWidget(this))
|
||||
{
|
||||
loadUiPreferences();
|
||||
|
||||
setWindowTitle(QStringLiteral("OrbitHub Session - %1").arg(profile.name));
|
||||
resize(1080, 760);
|
||||
setWindowIcon(QApplication::windowIcon());
|
||||
|
||||
m_tabs->setTabsClosable(true);
|
||||
connect(m_tabs,
|
||||
@@ -72,6 +79,12 @@ SessionWindow::SessionWindow(const Profile& profile, QWidget* parent)
|
||||
QMenu menu(this);
|
||||
QAction* disconnectAction = menu.addAction(QStringLiteral("Disconnect"));
|
||||
QAction* reconnectAction = menu.addAction(QStringLiteral("Reconnect"));
|
||||
QAction* toggleEventsAction = menu.addAction(
|
||||
tab->isEventsPanelExpanded() ? QStringLiteral("Hide Events")
|
||||
: QStringLiteral("Show Events"));
|
||||
QAction* copyEventsAction = menu.addAction(QStringLiteral("Copy Events"));
|
||||
QAction* exportEventsAction = menu.addAction(QStringLiteral("Export Events"));
|
||||
QAction* clearEventsAction = menu.addAction(QStringLiteral("Clear Events"));
|
||||
QList<QAction*> themeActions;
|
||||
|
||||
if (tab->supportsThemeSelection()) {
|
||||
@@ -97,6 +110,14 @@ SessionWindow::SessionWindow(const Profile& profile, QWidget* parent)
|
||||
tab->disconnectSession();
|
||||
} else if (chosen == reconnectAction) {
|
||||
tab->reconnectSession();
|
||||
} else if (chosen == toggleEventsAction) {
|
||||
tab->setEventsPanelExpanded(!tab->isEventsPanelExpanded());
|
||||
} else if (chosen == copyEventsAction) {
|
||||
tab->copyEvents();
|
||||
} else if (chosen == exportEventsAction) {
|
||||
tab->exportEventsToFile();
|
||||
} else if (chosen == clearEventsAction) {
|
||||
tab->clearEvents();
|
||||
} else if (clearAction != nullptr && chosen == clearAction) {
|
||||
tab->clearTerminal();
|
||||
} else {
|
||||
@@ -109,6 +130,16 @@ SessionWindow::SessionWindow(const Profile& profile, QWidget* parent)
|
||||
}
|
||||
});
|
||||
|
||||
QMenu* helpMenu = menuBar()->addMenu(QStringLiteral("Help"));
|
||||
QAction* aboutAction = helpMenu->addAction(QStringLiteral("About OrbitHub"));
|
||||
connect(aboutAction,
|
||||
&QAction::triggered,
|
||||
this,
|
||||
[this]() {
|
||||
AboutDialog dialog(this);
|
||||
dialog.exec();
|
||||
});
|
||||
|
||||
setCentralWidget(m_tabs);
|
||||
addSessionTab(profile);
|
||||
}
|
||||
@@ -120,7 +151,7 @@ void SessionWindow::openProfile(const Profile& profile)
|
||||
|
||||
void SessionWindow::addSessionTab(const Profile& profile)
|
||||
{
|
||||
auto* tab = new SessionTab(profile, this);
|
||||
auto* tab = new SessionTab(profile, m_preferences, this);
|
||||
const int index = m_tabs->addTab(tab, tab->tabTitle());
|
||||
m_tabs->setCurrentIndex(index);
|
||||
if (m_tabs->count() > 1) {
|
||||
@@ -145,6 +176,22 @@ void SessionWindow::addSessionTab(const Profile& profile)
|
||||
}
|
||||
}
|
||||
});
|
||||
connect(tab,
|
||||
&SessionTab::terminalThemeChanged,
|
||||
this,
|
||||
[this](const QString& themeName) {
|
||||
m_preferences.terminalThemeName = themeName.trimmed().isEmpty()
|
||||
? QStringLiteral("Dark")
|
||||
: themeName.trimmed();
|
||||
saveUiPreferences();
|
||||
});
|
||||
connect(tab,
|
||||
&SessionTab::eventsPanelVisibilityChanged,
|
||||
this,
|
||||
[this](bool expanded) {
|
||||
m_preferences.eventsPanelExpanded = expanded;
|
||||
saveUiPreferences();
|
||||
});
|
||||
}
|
||||
|
||||
void SessionWindow::updateTabTitle(SessionTab* tab, const QString& title)
|
||||
@@ -156,3 +203,26 @@ void SessionWindow::updateTabTitle(SessionTab* tab, const QString& title)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SessionWindow::loadUiPreferences()
|
||||
{
|
||||
QSettings settings;
|
||||
m_preferences.terminalThemeName =
|
||||
settings.value(QStringLiteral("session/defaultTerminalTheme"), QStringLiteral("Dark"))
|
||||
.toString()
|
||||
.trimmed();
|
||||
if (m_preferences.terminalThemeName.isEmpty()) {
|
||||
m_preferences.terminalThemeName = QStringLiteral("Dark");
|
||||
}
|
||||
m_preferences.eventsPanelExpanded =
|
||||
settings.value(QStringLiteral("session/eventsPanelExpanded"), false).toBool();
|
||||
}
|
||||
|
||||
void SessionWindow::saveUiPreferences() const
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue(QStringLiteral("session/defaultTerminalTheme"),
|
||||
m_preferences.terminalThemeName);
|
||||
settings.setValue(QStringLiteral("session/eventsPanelExpanded"),
|
||||
m_preferences.eventsPanelExpanded);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user