Remove first row, modify room list panel.

This commit is contained in:
Black Hat
2018-11-17 00:04:51 +08:00
parent a296fffd91
commit aaae68a5bf
10 changed files with 322 additions and 507 deletions

View File

@@ -75,7 +75,7 @@ void Controller::loginWithCredentials(QString serverAddr, QString user,
});
connect(m_connection, &Connection::networkError,
[=](QString error, QByteArray detail) {
emit errorOccured("Network", error);
emit errorOccured("Network Error", error);
});
connect(m_connection, &Connection::loginError,
[=](QString error, QByteArray detail) {
@@ -110,6 +110,7 @@ void Controller::addConnection(Connection* c) {
m_connections.push_back(c);
connect(c, &Connection::syncDone, this, [=] {
emit syncDone();
c->sync(30000);
static int counter = 0;
@@ -152,11 +153,12 @@ void Controller::invokeLogin() {
});
connect(c, &Connection::networkError,
[=](QString error, QByteArray detail) {
emit errorOccured("Network", error);
emit errorOccured("Network Error", error);
});
c->connectWithToken(account.userId(), accessToken, account.deviceId());
}
}
if (!m_connections.isEmpty()) setConnection(m_connections[0]);
emit initiated();
}
@@ -184,7 +186,7 @@ bool Controller::saveAccessToken(const AccountSettings& account,
auto fileDir = QFileInfo(accountTokenFile).dir();
if (!((fileDir.exists() || fileDir.mkpath(".")) &&
accountTokenFile.open(QFile::WriteOnly))) {
emit errorOccured("Token", "Cannot save access token.");
emit errorOccured("I/O Denied", "Cannot save access token.");
} else {
accountTokenFile.write(accessToken);
return true;
@@ -227,14 +229,6 @@ void Controller::playAudio(QUrl localFile) {
connect(player, &QMediaPlayer::stateChanged, [=] { player->deleteLater(); });
}
QColor Controller::color(QString userId) {
return QColor(SettingsGroup("UI/Color").value(userId, "#498882").toString());
}
void Controller::setColor(QString userId, QColor newColor) {
SettingsGroup("UI/Color").setValue(userId, newColor.name());
}
void Controller::postNotification(const QString& roomId, const QString& eventId,
const QString& roomName,
const QString& senderName,

View File

@@ -20,6 +20,8 @@ class Controller : public QObject {
connectionDropped)
Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE
setQuitOnLastWindowClosed NOTIFY quitOnLastWindowClosedChanged)
Q_PROPERTY(Connection* connection READ connection WRITE setConnection NOTIFY
connectionChanged)
public:
explicit Controller(QObject* parent = nullptr);
@@ -47,13 +49,23 @@ class Controller : public QObject {
}
}
Q_INVOKABLE QColor color(QString userId);
Q_INVOKABLE void setColor(QString userId, QColor newColor);
Connection* connection() {
if (m_connection.isNull()) return nullptr;
return m_connection;
}
void setConnection(Connection* conn) {
if (!conn) return;
if (conn == m_connection) return;
m_connection = conn;
emit connectionChanged();
}
private:
QClipboard* m_clipboard = QApplication::clipboard();
NotificationsManager notificationsManager;
QVector<Connection*> m_connections;
QPointer<Connection> m_connection;
QByteArray loadAccessToken(const AccountSettings& account);
bool saveAccessToken(const AccountSettings& account,
@@ -67,11 +79,13 @@ class Controller : public QObject {
signals:
void busyChanged();
void errorOccured(QString error, QString detail);
void syncDone();
void connectionAdded(Connection* conn);
void connectionDropped(Connection* conn);
void initiated();
void notificationClicked(const QString roomId, const QString eventId);
void quitOnLastWindowClosedChanged();
void connectionChanged();
public slots:
void logout(Connection* conn);