Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
vadi2 committed Aug 9, 2019
1 parent bc5ea65 commit 083927b
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 28 deletions.
2 changes: 2 additions & 0 deletions src/HostManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ bool HostManager::addHost(const QString& hostname, const QString& port, const QS

mHostPool.insert(hostname, pNewHost);
mPoolReadWriteLock.unlock();

mudlet::self()->attachDebugArea(hostname);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/HostManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class HostManager
HostManager() = default; /* : mpActiveHost() - Not needed */

Host* getHost(const QString& hostname);
bool addHost(const QString& name, const QString& port, const QString& login, const QString& pass);
int getHostCount();
QStringList getHostList();
bool addHost(const QString& name, const QString& port, const QString& login, const QString& pass);
bool deleteHost(const QString&);
void postIrcMessage(const QString&, const QString&, const QString&);
void postInterHostEvent(const Host*, const TEvent&, const bool = false);
Expand Down
6 changes: 3 additions & 3 deletions src/dlgConnectionProfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2020,11 +2020,11 @@ void dlgConnectionProfiles::loadProfile(bool alsoConnect)
return;
}
// load an old profile if there is any
// PLACEMARKER: Host creation (3) - normal case
if (mudlet::self()->addHost(profile_name, port_entry->text().trimmed(), QString(), QString())) {
// PLACEMARKER: Host creation (1) - normal case
if (hostManager.addHost(profile_name, port_entry->text().trimmed(), QString(), QString())) {
pHost = hostManager.getHost(profile_name);
if (!pHost) {
return;
return ;
}
} else {
return;
Expand Down
64 changes: 41 additions & 23 deletions src/mudlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,30 @@ void mudlet::slot_close_profile_requested(int tab)
mpIrcClientMap[pH]->deleteLater();
}

// auto success = mHostManager.addHost(hostname, port, login, pass);
// if (mpDebugArea) {
// return success;
// }

// if (success && !mpDebugArea) {
// mpDebugArea = new QMainWindow(nullptr);
// mpDefaultHost = mHostManager.getHost(hostname);
// mpDebugConsole = new TConsole(mpDefaultHost, TConsole::CentralDebugConsole);
// mpDebugConsole->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// mpDebugConsole->setWrapAt(100);
// mpDebugArea->setCentralWidget(mpDebugConsole);
// mpDebugArea->setWindowTitle(tr("Central Debug Console"));
// mpDebugArea->setWindowIcon(QIcon(QStringLiteral(":/icons/mudlet_debug.png")));

// auto consoleCloser = new TConsoleMonitor(mpDebugArea);
// mpDebugArea->installEventFilter(consoleCloser);

// QSize generalRule(qApp->desktop()->size());
// generalRule -= QSize(30, 30);
// mpDebugArea->resize(QSize(800, 600).boundedTo(generalRule));
// mpDebugArea->hide();
// }

// Wait for disconnection to complete
while (pH->mTelnet.getConnectionState() != QAbstractSocket::UnconnectedState) {
QApplication::processEvents();
Expand Down Expand Up @@ -3636,36 +3660,30 @@ void mudlet::startAutoLogin()
}
}

bool mudlet::addHost(const QString& hostname, const QString& port, const QString& login, const QString& pass)
void mudlet::attachDebugArea(const QString& hostname)
{
auto success = mHostManager.addHost(hostname, port, login, pass);
if (mpDebugArea) {
return success;
return;
}

if (success && !mpDebugArea) {
mpDebugArea = new QMainWindow(nullptr);
mpDefaultHost = mHostManager.getHost(hostname);
mpDebugConsole = new TConsole(mpDefaultHost, TConsole::CentralDebugConsole);
mpDebugConsole->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
mpDebugConsole->setWrapAt(100);
mpDebugArea->setCentralWidget(mpDebugConsole);
mpDebugArea->setWindowTitle(tr("Central Debug Console"));
mpDebugArea->setWindowIcon(QIcon(QStringLiteral(":/icons/mudlet_debug.png")));
mpDebugArea = new QMainWindow(nullptr);
mpDefaultHost = mHostManager.getHost(hostname);
mpDebugConsole = new TConsole(mpDefaultHost, TConsole::CentralDebugConsole);
mpDebugConsole->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
mpDebugConsole->setWrapAt(100);
mpDebugArea->setCentralWidget(mpDebugConsole);
mpDebugArea->setWindowTitle(tr("Central Debug Console"));
mpDebugArea->setWindowIcon(QIcon(QStringLiteral(":/icons/mudlet_debug.png")));

auto consoleCloser = new TConsoleMonitor(mpDebugArea);
mpDebugArea->installEventFilter(consoleCloser);
auto consoleCloser = new TConsoleMonitor(mpDebugArea);
mpDebugArea->installEventFilter(consoleCloser);

QSize generalRule(qApp->desktop()->size());
generalRule -= QSize(30, 30);
mpDebugArea->resize(QSize(800, 600).boundedTo(generalRule));
mpDebugArea->hide();
}

return success;
QSize generalRule(qApp->desktop()->size());
generalRule -= QSize(30, 30);
mpDebugArea->resize(QSize(800, 600).boundedTo(generalRule));
mpDebugArea->hide();
}


void mudlet::doAutoLogin(const QString& profile_name)
{
if (profile_name.size() < 1) {
Expand All @@ -3680,7 +3698,7 @@ void mudlet::doAutoLogin(const QString& profile_name)

// load an old profile if there is any
// PLACEMARKER: Host creation (2) - autoload case
if (mudlet::self()->addHost(profile_name, QString(), QString(), QString())) {
if (mHostManager.addHost(profile_name, QString(), QString(), QString())) {
pHost = mHostManager.getHost(profile_name);
if (!pHost) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/mudlet.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class mudlet : public QMainWindow, public Ui::main_window
// This method allows better debugging when mudlet::self() is called inappropriately.
static void start();
HostManager& getHostManager() { return mHostManager; }
bool addHost(const QString& hostname, const QString& port, const QString& login, const QString& pass);
void attachDebugArea(const QString& hostname);
FontManager mFontManager;
Discord mDiscord;
QPointer<QSettings> mpSettings;
Expand Down

0 comments on commit 083927b

Please sign in to comment.