Some optimizations.

This commit is contained in:
Black Hat 2018-11-11 09:55:41 +08:00
parent 06983a506c
commit bbc4fedd20
3 changed files with 45 additions and 45 deletions

View File

@ -115,58 +115,49 @@ Drawer {
room: roomDrawer.room room: roomDrawer.room
} }
delegate: Column { delegate: SwipeDelegate {
property bool expanded: false width: userListView.width
height: 48
ItemDelegate { RowLayout {
width: userListView.width anchors.fill: parent
height: 48 anchors.margins: 8
spacing: 12
RowLayout { ImageItem {
anchors.fill: parent Layout.preferredWidth: height
anchors.margins: 8 Layout.fillHeight: true
spacing: 12
ImageItem { source: paintable
Layout.preferredWidth: height hint: name
Layout.fillHeight: true
source: paintable
hint: name
}
Label {
Layout.fillWidth: true
text: name
}
} }
onClicked: expanded = !expanded Label {
}
ColumnLayout {
width: parent.width - 32
height: expanded ? implicitHeight : 0
anchors.horizontalCenter: parent.horizontalCenter
spacing: 0
clip: true
Button {
Layout.fillWidth: true Layout.fillWidth: true
text: "Kick" text: name
highlighted: true
onClicked: room.kickMember(userId)
}
Behavior on height {
PropertyAnimation { easing.type: Easing.InOutCubic; duration: 200 }
} }
} }
swipe.right: Rectangle {
width: height
height: parent.height
anchors.right: parent.right
color: Material.accent
MaterialIcon {
anchors.fill: parent
icon: "\ue879"
color: "white"
}
SwipeDelegate.onClicked: {
room.kickMember(userId)
swipe.close()
}
}
onClicked: swipe.open(SwipeDelegate.Right)
} }
ScrollBar.vertical: ScrollBar {} ScrollBar.vertical: ScrollBar {}

View File

@ -40,6 +40,13 @@ Controller::Controller(QObject* parent)
QTimer::singleShot(0, this, SLOT(invokeLogin())); QTimer::singleShot(0, this, SLOT(invokeLogin()));
} }
Controller::~Controller() {
for (Connection* c : m_connections) {
c->saveState();
c->stopSync();
}
}
inline QString accessTokenFileName(const AccountSettings& account) { inline QString accessTokenFileName(const AccountSettings& account) {
QString fileName = account.userId(); QString fileName = account.userId();
fileName.replace(':', '_'); fileName.replace(':', '_');
@ -103,8 +110,10 @@ void Controller::addConnection(Connection* c) {
m_connections.push_back(c); m_connections.push_back(c);
connect(c, &Connection::syncDone, this, [=] { connect(c, &Connection::syncDone, this, [=] {
c->saveState();
c->sync(30000); c->sync(30000);
static int counter = 0;
if (++counter % 17 == 2) c->saveState();
}); });
connect(c, &Connection::loggedOut, this, [=] { dropConnection(c); }); connect(c, &Connection::loggedOut, this, [=] { dropConnection(c); });

View File

@ -23,7 +23,7 @@ class Controller : public QObject {
public: public:
explicit Controller(QObject* parent = nullptr); explicit Controller(QObject* parent = nullptr);
~Controller(){}; ~Controller();
// All the Q_INVOKABLEs. // All the Q_INVOKABLEs.
Q_INVOKABLE void loginWithCredentials(QString, QString, QString); Q_INVOKABLE void loginWithCredentials(QString, QString, QString);