mirror of https://github.com/KDE/kasts.git
add timestamp, aboutpage, settingspage
This commit is contained in:
parent
4802a4db04
commit
195b6d63ee
|
@ -1,8 +1,6 @@
|
|||
project(Alligator)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
set(KF5_MIN_VERSION "5.18.0")
|
||||
set(QT_MIN_VERSION "5.5.0")
|
||||
|
||||
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
|
||||
message(FATAL_ERROR "This application requires an out of source build. Please create a separate build directory.")
|
||||
|
@ -21,9 +19,8 @@ include(KDECMakeSettings)
|
|||
include(ECMPoQmTools)
|
||||
include(KDECompilerSettings NO_POLICY_SCOPE)
|
||||
|
||||
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2 Sql)
|
||||
find_package(KF5Kirigami2 ${KF5_MIN_VERSION} REQUIRED)
|
||||
find_package(KF5Syndication ${KF5_MIN_VERSION} REQUIRED)
|
||||
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui Svg QuickControls2 Sql)
|
||||
find_package(KF5 REQUIRED COMPONENTS CoreAddons Syndication Config)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@ set(alligator_SRCS
|
|||
resources.qrc
|
||||
)
|
||||
|
||||
kconfig_add_kcfg_files(alligator_SRCS alligatorsettings.kcfgc GENERATE_MOC)
|
||||
|
||||
add_executable(alligator ${alligator_SRCS})
|
||||
target_link_libraries(alligator Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg Qt5::Sql KF5::Syndication)
|
||||
target_link_libraries(alligator Qt5::Core Qt5::Qml Qt5::Quick Qt5::Svg Qt5::Sql KF5::Syndication KF5::CoreAddons KF5::ConfigGui)
|
||||
|
||||
install(TARGETS alligator ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
|
||||
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
|
||||
<kcfgfile name="alligatorrc" />
|
||||
<group name="General">
|
||||
</group>
|
||||
</kcfg>
|
|
@ -0,0 +1,7 @@
|
|||
File=alligatorsettings.kcfg
|
||||
ClassName=AlligatorSettings
|
||||
Mutators=true
|
||||
DefaultValueGetters=true
|
||||
GenerateProperties=true
|
||||
ParentInConstructor=true
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Controls 2.10 as Controls
|
||||
|
||||
import org.kde.kirigami 2.4 as Kirigami
|
||||
import org.kde.kirigami 2.8 as Kirigami
|
||||
|
||||
import org.kde.alligator 1.0
|
||||
|
||||
|
@ -57,7 +57,7 @@ Kirigami.ScrollablePage {
|
|||
delegate: Kirigami.SwipeListItem {
|
||||
Controls.Label {
|
||||
width: parent.width
|
||||
text: model.title
|
||||
text: model.title + " - " + model.updated
|
||||
textFormat: Text.RichText
|
||||
color: model.read ? Kirigami.Theme.disabledTextColor : Kirigami.Theme.textColor
|
||||
}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import QtQuick 2.0
|
||||
import org.kde.kirigami 2.8 as Kirigami
|
||||
import QtQuick.Controls 2.10 as Controls
|
||||
|
||||
Kirigami.ScrollablePage {
|
||||
title: "Settings"
|
||||
|
||||
property QtObject settings
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
import QtQuick 2.1
|
||||
import QtQuick.Controls 2.0 as Controls
|
||||
|
||||
import org.kde.kirigami 2.4 as Kirigami
|
||||
import org.kde.kirigami 2.8 as Kirigami
|
||||
|
||||
Kirigami.ApplicationWindow {
|
||||
id: root
|
||||
|
@ -30,6 +30,27 @@ Kirigami.ApplicationWindow {
|
|||
|
||||
pageStack.initialPage: feedList
|
||||
|
||||
globalDrawer: Kirigami.GlobalDrawer {
|
||||
isMenu: true
|
||||
actions: [
|
||||
Kirigami.Action {
|
||||
text: "Settings"
|
||||
onTriggered: pageStack.push("qrc:/SettingsPage.qml", {"settings": _settings})
|
||||
},
|
||||
Kirigami.Action {
|
||||
text: "About"
|
||||
onTriggered: root.pageStack.push(aboutPage)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Component {
|
||||
id: aboutPage
|
||||
Kirigami.AboutPage {
|
||||
aboutData: _aboutData
|
||||
}
|
||||
}
|
||||
|
||||
contextDrawer: Kirigami.ContextDrawer {
|
||||
id: contextDrawer
|
||||
}
|
||||
|
|
|
@ -20,9 +20,10 @@
|
|||
|
||||
#include "entry.h"
|
||||
|
||||
Entry::Entry(const QString title, const QString content, const bool bookmark, const bool read)
|
||||
Entry::Entry(const QString title, const QString content, const int updated, const bool bookmark, const bool read)
|
||||
: m_title(title)
|
||||
, m_content(content)
|
||||
, m_updated(updated)
|
||||
, m_bookmark(bookmark)
|
||||
, m_read(read)
|
||||
{
|
||||
|
@ -31,6 +32,7 @@ Entry::Entry(const QString title, const QString content, const bool bookmark, co
|
|||
Entry::Entry(const Entry &other)
|
||||
: m_title(other.title())
|
||||
, m_content(other.content())
|
||||
, m_updated(other.updated())
|
||||
, m_bookmark(other.isBookmark())
|
||||
, m_read(other.isRead())
|
||||
{
|
||||
|
@ -56,6 +58,11 @@ QString Entry::content() const
|
|||
return m_content;
|
||||
}
|
||||
|
||||
int Entry::updated() const
|
||||
{
|
||||
return m_updated;
|
||||
}
|
||||
|
||||
void Entry::setRead(bool read)
|
||||
{
|
||||
m_read = read;
|
||||
|
|
|
@ -26,10 +26,11 @@ class Entry
|
|||
{
|
||||
public:
|
||||
Entry(const Entry &);
|
||||
Entry(const QString title, const QString content, const bool bookmark, const bool read);
|
||||
Entry(const QString title, const QString content, const int updated, const bool bookmark, const bool read);
|
||||
|
||||
QString title() const;
|
||||
QString content() const;
|
||||
int updated() const;
|
||||
bool isBookmark() const;
|
||||
bool isRead() const;
|
||||
|
||||
|
@ -39,6 +40,7 @@ public:
|
|||
private:
|
||||
QString m_title;
|
||||
QString m_content;
|
||||
int m_updated;
|
||||
bool m_bookmark;
|
||||
bool m_read;
|
||||
};
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <QVector>
|
||||
#include <QDateTime>
|
||||
|
||||
#include "entryListModel.h"
|
||||
#include "fetcher.h"
|
||||
|
@ -33,14 +34,20 @@ EntryListModel::EntryListModel(QObject *parent)
|
|||
|
||||
QVariant EntryListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Title)
|
||||
return m_entries[index.row()].title();
|
||||
if (role == Content)
|
||||
return m_entries[index.row()].content();
|
||||
if (role == Updated) {
|
||||
QDateTime updated;
|
||||
updated.setSecsSinceEpoch(m_entries[index.row()].updated());
|
||||
return updated;
|
||||
}
|
||||
if (role == Bookmark)
|
||||
return m_entries[index.row()].isBookmark();
|
||||
if (role == Read)
|
||||
return m_entries[index.row()].isRead();
|
||||
if (role == Content)
|
||||
return m_entries[index.row()].content();
|
||||
if (role == Title)
|
||||
return m_entries[index.row()].title();
|
||||
|
||||
return QStringLiteral("DEADBEEF");
|
||||
}
|
||||
int EntryListModel::rowCount(const QModelIndex &index) const
|
||||
|
@ -51,9 +58,11 @@ QHash<int, QByteArray> EntryListModel::roleNames() const
|
|||
{
|
||||
QHash<int, QByteArray> roleNames;
|
||||
roleNames[Title] = "title";
|
||||
roleNames[Content] = "content";
|
||||
roleNames[Updated] = "updated";
|
||||
roleNames[Bookmark] = "bookmark";
|
||||
roleNames[Read] = "read";
|
||||
roleNames[Content] = "content";
|
||||
|
||||
return roleNames;
|
||||
}
|
||||
bool EntryListModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
|
@ -80,15 +89,15 @@ void EntryListModel::update() {
|
|||
beginResetModel();
|
||||
QSqlQuery query;
|
||||
if(m_feed.compare("all") == 0) {
|
||||
query.prepare(QStringLiteral("SELECT id, title, content FROM Entries ORDER BY updated DESC;"));
|
||||
query.prepare(QStringLiteral("SELECT id, title, content, updated FROM Entries ORDER BY updated DESC;"));
|
||||
}
|
||||
else {
|
||||
query.prepare(QStringLiteral("SELECT id, title, content FROM Entries WHERE feed=:feed ORDER BY updated DESC;"));
|
||||
query.prepare(QStringLiteral("SELECT id, title, content, updated FROM Entries WHERE feed=:feed ORDER BY updated DESC;"));
|
||||
query.bindValue(QStringLiteral(":feed"), m_feed);
|
||||
}
|
||||
Database::instance().execute(query);
|
||||
while (query.next()) {
|
||||
m_entries.append(Entry(query.value(1).toString(), query.value(2).toString(), false, false));
|
||||
m_entries.append(Entry(query.value(1).toString(), query.value(2).toString(), query.value(3).toInt(), false, false));
|
||||
}
|
||||
endResetModel();
|
||||
}
|
||||
|
|
|
@ -34,9 +34,10 @@ class EntryListModel : public QAbstractListModel
|
|||
public:
|
||||
enum DataRole {
|
||||
Title = Qt::UserRole + 1,
|
||||
Content,
|
||||
Updated,
|
||||
Bookmark,
|
||||
Read,
|
||||
Content,
|
||||
};
|
||||
explicit EntryListModel(QObject *parent = nullptr);
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -21,10 +21,14 @@
|
|||
#include <QApplication>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickView>
|
||||
#include <QQmlContext>
|
||||
|
||||
#include <KAboutData>
|
||||
|
||||
#include "entryListModel.h"
|
||||
#include "feedListModel.h"
|
||||
#include "database.h"
|
||||
#include "alligatorsettings.h"
|
||||
|
||||
#include "alligator-debug.h"
|
||||
|
||||
|
@ -44,6 +48,17 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
|
|||
|
||||
QQmlApplicationEngine engine;
|
||||
|
||||
KAboutData about(QStringLiteral("alligator"), QStringLiteral("Alligator"), QStringLiteral("0.1"), QStringLiteral("Feed Reader"),
|
||||
KAboutLicense::GPL, QStringLiteral("© 2020 KDE Community"));
|
||||
about.addAuthor(QStringLiteral("Tobias Fella"), QString(), QStringLiteral("fella@posteo.de"));
|
||||
KAboutData::setApplicationData(about);
|
||||
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("_aboutData"), QVariant::fromValue(about));
|
||||
|
||||
AlligatorSettings settings;
|
||||
|
||||
engine.rootContext()->setContextProperty(QStringLiteral("_settings"), &settings);
|
||||
|
||||
Database::instance();
|
||||
|
||||
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));
|
||||
|
|
|
@ -4,5 +4,6 @@
|
|||
<file alias="EntryListPage.qml">contents/ui/EntryListPage.qml</file>
|
||||
<file alias="FeedListPage.qml">contents/ui/FeedListPage.qml</file>
|
||||
<file alias="EntryPage.qml">contents/ui/EntryPage.qml</file>
|
||||
<file alias="SettingsPage.qml">contents/ui/SettingsPage.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Loading…
Reference in New Issue