smsapp: add main contextual actions

Includes an about page and a refresh button for the conversations.
This commit is contained in:
Aleix Pol 2019-07-21 12:55:25 +02:00
parent ed9e3028be
commit f256e32fb2
4 changed files with 39 additions and 3 deletions

View file

@ -89,8 +89,18 @@ void ConversationListModel::setDeviceId(const QString& deviceId)
m_conversationsInterface = new DeviceConversationsDbusInterface(deviceId, this);
connect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleCreatedConversation(QDBusVariant)));
connect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdated(QDBusVariant)));
prepareConversationsList();
refresh();
}
void ConversationListModel::refresh()
{
if (m_deviceId.isEmpty()) {
qWarning() << "refreshing null device";
return;
}
prepareConversationsList();
m_conversationsInterface->requestAllConversationThreads();
}

View file

@ -90,6 +90,8 @@ public:
QString deviceId() const { return m_deviceId; }
void setDeviceId(const QString &/*deviceId*/);
Q_SCRIPTABLE void refresh();
public Q_SLOTS:
void handleCreatedConversation(const QDBusVariant& msg);
void handleConversationUpdated(const QDBusVariant& msg);

View file

@ -36,9 +36,9 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
KAboutData aboutData(QStringLiteral("org.kde.kdeconnect.sms"), i18n("SMS Instant Messaging"), QStringLiteral(KDECONNECT_VERSION_STRING), i18n("KDE Connect SMS"), KAboutLicense::GPL, i18n("(c) 2018, Aleix Pol Gonzalez"));
aboutData.addAuthor(i18n("Simon Redman"), {}, QStringLiteral("simon@ergotech.com"));
aboutData.addAuthor(i18n("Aleix Pol Gonzalez"), {}, QStringLiteral("aleixpol@kde.org"));
aboutData.addAuthor(i18n("Nicolas Fella"), {}, QStringLiteral("nicolas.fella@gmx.de"));
aboutData.addAuthor(i18n("Simon Redman"), {}, QStringLiteral("simon@ergotech.com"));
KAboutData::setApplicationData(aboutData);
QString initialMessage;
@ -67,6 +67,7 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
engine.rootContext()->setContextObject(new KLocalizedContext(&engine));
engine.rootContext()->setContextProperty(QStringLiteral("_initialMessage"), QVariant(initialMessage));
engine.rootContext()->setContextProperty(QStringLiteral("aboutData"), QVariant::fromValue(KAboutData::applicationData()));
engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
return app.exec();

View file

@ -24,7 +24,7 @@ import QtQuick 2.5
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.1
import org.kde.people 1.0
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kirigami 2.6 as Kirigami
import org.kde.kdeconnect 1.0
import org.kde.kdeconnect.sms 1.0
@ -49,6 +49,29 @@ Kirigami.ScrollablePage
}
}
contextualActions: [
Kirigami.Action {
text: i18n("Refresh")
icon.name: "view-refresh"
enabled: devicesCombo.count > 0
onTriggered: {
conversationListModel.refresh()
}
},
Kirigami.Action {
text: i18n("About...")
icon.name: "help-about"
onTriggered: {
applicationWindow().pageStack.push(aboutPageComponent, { aboutData: aboutData });
}
}
]
Component {
id: aboutPageComponent
Kirigami.AboutPage {}
}
property string initialMessage
header: Kirigami.InlineMessage {