_wantReconnect(false),
_progressMinimum(0),
_progressMaximum(-1),
- _progressValue(-1)
+ _progressValue(-1),
+ _wasReconnect(false),
+ _requestedDisconnect(false)
{
qRegisterMetaType<ConnectionState>("CoreConnection::ConnectionState");
}
void CoreConnection::coreSocketDisconnected() {
// qDebug() << Q_FUNC_INFO;
+ _wasReconnect = !_requestedDisconnect;
resetConnection(true);
// FIXME handle disconnects gracefully
}
}
void CoreConnection::disconnectFromCore() {
+ _requestedDisconnect = true;
disconnectFromCore(QString(), false); // requested disconnect, so don't try to reconnect
}
if(!wantReconnect)
_reconnectTimer.stop();
+ _wasReconnect = wantReconnect; // store if disconnect was requested
+
if(errorString.isEmpty())
emit connectionError(tr("Disconnected"));
else
_socket->deleteLater();
_socket = 0;
}
+ _requestedDisconnect = false;
_blockSize = 0;
_coreMsgBuffer.clear();
inline int progressValue() const;
inline QString progressText() const;
+ //! Check if we consider the last connect as reconnect
+ inline bool wasReconnect() const { return _wasReconnect; }
+
#ifdef HAVE_SSL
inline const QSslSocket *sslSocket() const;
#endif
QString _progressText;
QString _coreInfoString(const QVariantMap &);
+ bool _wasReconnect;
+ bool _requestedDisconnect;
inline CoreAccountModel *accountModel() const;
wizard->show();
}
else {
- QtUiSettings s;
- BufferId lastUsedBufferId(s.value("LastUsedBufferId").toInt());
- if(lastUsedBufferId.isValid())
- Client::bufferModel()->switchToBuffer(lastUsedBufferId);
+ // Monolithic always preselects last used buffer - Client only if the connection died
+ if(Client::coreConnection()->wasReconnect() || Quassel::runMode() == Quassel::Monolithic) {
+ QtUiSettings s;
+ BufferId lastUsedBufferId(s.value("LastUsedBufferId").toInt());
+ if(lastUsedBufferId.isValid())
+ Client::bufferModel()->switchToBuffer(lastUsedBufferId);
+ }
}
}
}
}
+ // store last active buffer
QtUiSettings s;
- BufferId lastBufId = Client::bufferModel()->currentBuffer();
+ BufferId lastBufId = _bufferWidget->currentBuffer();
if(lastBufId.isValid()) {
s.setValue("LastUsedBufferId", lastBufId.toInt());
+ // clear the current selection
Client::bufferModel()->standardSelectionModel()->clearSelection();
}
restoreState(s.value("MainWinState").toByteArray());
switch(net->connectionState()) {
case Network::Initialized:
action->setIcon(SmallIcon("network-connect"));
+ // if we have no currently selected buffer, jump to the first connecting statusbuffer
+ if(!bufferWidget()->currentBuffer().isValid()) {
+ QModelIndex idx = Client::networkModel()->networkIndex(net->networkId());
+ if(idx.isValid()) {
+ BufferId statusBufferId = idx.data(NetworkModel::BufferIdRole).value<BufferId>();
+ Client::bufferModel()->switchToBuffer(statusBufferId);
+ }
+ }
break;
case Network::Disconnected:
action->setIcon(SmallIcon("network-disconnect"));
_chatViews.take(bufferId);
}
+/*
+ Switching to first buffer is now handled in MainWin::clientNetworkUpdated()
+
void AbstractBufferContainer::rowsInserted(const QModelIndex &parent, int start, int end) {
Q_UNUSED(end)
setCurrentBuffer(id);
}
}
+*/
void AbstractBufferContainer::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) {
Q_UNUSED(previous)
protected slots:
virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
- virtual void rowsInserted(const QModelIndex &parent, int start, int end);
//! Show the given chat view
/** This method is called when the given chat view should be displayed. Use this e.g. for