RSS Guard now remembers its size and position, including all nested widgets.

This commit is contained in:
Martin Rotter 2013-12-21 09:14:03 +01:00
parent a881513f7d
commit 9fb4ebff68
8 changed files with 129 additions and 55 deletions

View File

@ -177,7 +177,7 @@
</message>
<message>
<source>&lt;body&gt;RSS Guard is a (very) tiny feed reader.&lt;br&gt;&lt;br&gt;This software is distributed under the terms of GNU General Public License, version 3.&lt;br&gt;&lt;br&gt;Contacts:&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;mailto://%1&quot;&gt;%1&lt;/a&gt; ~email&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;%2&quot;&gt;%2&lt;/a&gt; ~website&lt;/li&gt;&lt;/ul&gt;You can obtain source code for RSS Guard from its website.&lt;br&gt;&lt;br&gt;&lt;br&gt;Copyrigh (C) 2011-%3 %4&lt;/body&gt;</source>
<translation type="unfinished"></translation>
<translation>&lt;body&gt;RSS Guard is een (zeer) makelijk om te gebruiken feed lezer.&lt;br&gt;&lt;br&gt;Dit programma is beschikbaar onder te termenvan de GNU General Public License versie 3.&lt;br&gt;&lt;br&gt;Contacts:&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;mailto://%1&quot;&gt;%1&lt;/a&gt; ~email&lt;/li&gt;&lt;li&gt;&lt;a ref=&quot;%2&quot;&gt;%2&lt;/a&gt; ~website &lt;/li&gt;&lt;ul&gt;U kunt de broncode voor RSS Guard verkrijgen op de website.&lt;br&gt;&lt;br&gt;&lt;br&gt;Auteursrecht(C)2011-%3 %4&lt;/body&gt;</translation>
</message>
</context>
<context>
@ -416,15 +416,15 @@
</message>
<message>
<source>Mark all messages from selected feeds read. This does NOT take message filters into account.</source>
<translation type="unfinished"></translation>
<translation>Markeer alle berichten van geselekteerde feeds als gelezen. Dit zal GEEN bericht filters meenemen in account.</translation>
</message>
<message>
<source>Mark all messages from selected feeds unread. This does NOT take message filters into account.</source>
<translation type="unfinished"></translation>
<translation>Markeer alle berichten van geselekteerde feeds als ongelezen. Dit zal GEEN bericht filters meenemen in account.</translation>
</message>
<message>
<source>Delete all messages from selected feeds. This does NOT take message filters into account.</source>
<translation type="unfinished"></translation>
<translation>Verwijder alle berichten van geselekteerde feeds. Dit zal GEEN bericht filters meenemen in account.</translation>
</message>
</context>
<context>
@ -747,15 +747,15 @@
</message>
<message>
<source>Current color</source>
<translation type="unfinished"></translation>
<translation>Huidige kleur</translation>
</message>
<message>
<source>Executable file of web browser</source>
<translation type="unfinished"></translation>
<translation>Uitvoerbaar bestand van webbrowser</translation>
</message>
<message>
<source>Parameters to executable</source>
<translation type="unfinished"></translation>
<translation>Parameter voor exe</translation>
</message>
<message>
<source>some keyboard shortcuts are not unique</source>
@ -858,47 +858,47 @@
</message>
<message>
<source>Id of the message.</source>
<translation type="unfinished"></translation>
<translation>Id van het bericht.</translation>
</message>
<message>
<source>Is message read?</source>
<translation type="unfinished"></translation>
<translation>Is bericht gelezen?</translation>
</message>
<message>
<source>Is message deleted?</source>
<translation type="unfinished"></translation>
<translation>Is bericht verwijderd?</translation>
</message>
<message>
<source>Is message important?</source>
<translation type="unfinished"></translation>
<translation>IS bericht belangrijk?</translation>
</message>
<message>
<source>Id of feed which this message belongs to.</source>
<translation type="unfinished"></translation>
<translation>Id van feed waar dit bericht bijhoort.</translation>
</message>
<message>
<source>Title of the message.</source>
<translation type="unfinished"></translation>
<translation>Titel van het bericht.</translation>
</message>
<message>
<source>Url of the message.</source>
<translation type="unfinished"></translation>
<translation>Url van het bericht.</translation>
</message>
<message>
<source>Author of the message.</source>
<translation type="unfinished"></translation>
<translation>De schrijver van het bericht.</translation>
</message>
<message>
<source>Creation date of the message.</source>
<translation type="unfinished"></translation>
<translation>Aanmaakdatum van het bericht.</translation>
</message>
<message>
<source>Date of the most recent update of the message.</source>
<translation type="unfinished"></translation>
<translation>Datum van het meest recente update van het bericht.</translation>
</message>
<message>
<source>Contents of the message.</source>
<translation type="unfinished"></translation>
<translation>Inhoud van het bericht.</translation>
</message>
</context>
<context>
@ -945,39 +945,44 @@
</message>
<message numerus="yes">
<source>%n unread message(s).</source>
<translation type="unfinished">
<numerusform></numerusform>
<numerusform></numerusform>
<translation>
<numerusform>%n ongelezen bericht.</numerusform>
<numerusform>%n ongelezen berichten.</numerusform>
</translation>
</message>
<message>
<source>ATOM 1.0</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<source>RDF 1.0</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<source>RSS 0.90/0.91/0.92</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<source>RSS 2.0/2.0.1</source>
<translation type="unfinished"></translation>
<translation></translation>
</message>
<message>
<source>%1
Category type: standard
Creation date: %2%3</source>
<translation type="unfinished"></translation>
<translation>%1
Categorie type: standaard
aanmaakdatum: %2%3</translation>
</message>
<message>
<source>
This category does not contain any nested items.</source>
<translation type="unfinished"></translation>
<translation>
Deze categorie bevat geen nested items.</translation>
</message>
<message>
<source>%1
@ -986,7 +991,12 @@ Feed type: %2
URL: %3
Encoding: %4
Language: %5</source>
<translation type="unfinished"></translation>
<translation>%1
Feed type: %2
URL: %3
Encodering: %4
Taal: %5</translation>
</message>
</context>
<context>

View File

@ -22,12 +22,12 @@
#define APP_VERSION "@APP_VERSION@"
#define APP_USERAGENT QString("@APP_NAME@/@APP_VERSION@ (@APP_URL@) on @CMAKE_SYSTEM@; Webkit/") + qWebKitVersion()
#define TEXT_TITLE_LIMIT 30
#define MAX_ZOOM_FACTOR 10.0
#define ICON_SIZE_SETTINGS 16
#define DATABASE_DRIVER "QSQLITE"
#define NO_PARENT_FEED -1
#define NO_PARENT_CATEGORY -1
#define TEXT_TITLE_LIMIT 30
#define MAX_ZOOM_FACTOR 10.0
#define ICON_SIZE_SETTINGS 16
#define DATABASE_DRIVER "QSQLITE"
#define NO_PARENT_CATEGORY -1
#define TRAY_ICON_BUBBLE_TIMEOUT 15000
#define APP_DB_INIT_FILE "db_init.sql"
#define APP_DB_INIT_SPLIT "-- !\n"

View File

@ -348,7 +348,7 @@ void FeedsModel::assembleFeeds(FeedAssignment feeds) {
void FeedsModel::assembleCategories(CategoryAssignment categories) {
QHash<int, FeedsModelRootItem*> assignments;
assignments.insert(-1, m_rootItem);
assignments.insert(NO_PARENT_CATEGORY, m_rootItem);
// Add top-level categories.
while (!categories.isEmpty()) {

View File

@ -15,6 +15,7 @@
#include "gui/messagesview.h"
#include "gui/feedsview.h"
#include "core/messagesproxymodel.h"
#include "core/settings.h"
FeedMessageViewer::FeedMessageViewer(QWidget *parent)
@ -26,6 +27,28 @@ FeedMessageViewer::FeedMessageViewer(QWidget *parent)
initialize();
initializeViews();
createConnections();
loadSize();
}
FeedMessageViewer::~FeedMessageViewer() {
qDebug("Destroying FeedMessageViewer instance.");
saveSize();
}
void FeedMessageViewer::saveSize() {
Settings::getInstance()->setValue(APP_CFG_GUI,
"splitter_feeds",
m_feedSplitter->saveState());
Settings::getInstance()->setValue(APP_CFG_GUI,
"splitter_messages",
m_messageSplitter->saveState());
}
void FeedMessageViewer::loadSize() {
m_feedSplitter->restoreState(Settings::getInstance()->value(APP_CFG_GUI, "splitter_feeds").toByteArray());
m_messageSplitter->restoreState(Settings::getInstance()->value(APP_CFG_GUI, "splitter_messages").toByteArray());
}
void FeedMessageViewer::createConnections() {
@ -93,8 +116,8 @@ void FeedMessageViewer::initialize() {
void FeedMessageViewer::initializeViews() {
// Instantiate needed components.
QVBoxLayout *central_layout = new QVBoxLayout(this);
QSplitter *feed_splitter = new QSplitter(Qt::Horizontal, this);
QSplitter *message_splitter = new QSplitter(Qt::Vertical, this);
m_feedSplitter = new QSplitter(Qt::Horizontal, this);
m_messageSplitter = new QSplitter(Qt::Vertical, this);
// Set layout properties.
central_layout->setMargin(0);
@ -105,30 +128,26 @@ void FeedMessageViewer::initializeViews() {
m_messagesView->setFrameStyle(QFrame::NoFrame);
// Setup splitters.
message_splitter->setHandleWidth(1);
message_splitter->setChildrenCollapsible(false);
message_splitter->setStretchFactor(0, 1);
message_splitter->addWidget(m_messagesView);
message_splitter->addWidget(m_messagesBrowser);
m_messageSplitter->setHandleWidth(1);
m_messageSplitter->setChildrenCollapsible(false);
m_messageSplitter->setStretchFactor(0, 1);
m_messageSplitter->addWidget(m_messagesView);
m_messageSplitter->addWidget(m_messagesBrowser);
feed_splitter->setHandleWidth(1);
feed_splitter->setChildrenCollapsible(false);
feed_splitter->setStretchFactor(0, 1);
feed_splitter->addWidget(m_feedsView);
feed_splitter->addWidget(message_splitter);
m_feedSplitter->setHandleWidth(1);
m_feedSplitter->setChildrenCollapsible(false);
m_feedSplitter->setStretchFactor(0, 1);
m_feedSplitter->addWidget(m_feedsView);
m_feedSplitter->addWidget(m_messageSplitter);
// Add toolbar and main feeds/messages widget to main layout.
central_layout->addWidget(m_toolBar);
central_layout->addWidget(feed_splitter);
central_layout->addWidget(m_feedSplitter);
// Set layout as active.
setLayout(central_layout);
}
FeedMessageViewer::~FeedMessageViewer() {
qDebug("Destroying FeedMessageViewer instance.");
}
WebBrowser *FeedMessageViewer::webBrowser() {
return m_messagesBrowser;
}

View File

@ -8,6 +8,7 @@ class WebBrowser;
class FeedsView;
class MessagesView;
class QToolBar;
class QSplitter;
class FeedMessageViewer : public TabContent {
Q_OBJECT
@ -20,6 +21,12 @@ class FeedMessageViewer : public TabContent {
// WebBrowser getter from TabContent interface.
WebBrowser *webBrowser();
// Loads/saves sizes and states of ALL
// underlying widgets, this contains primarily
// splitters, toolbar and views.
void saveSize();
void loadSize();
protected:
// Initializes some properties of the widget.
void initialize();
@ -33,6 +40,9 @@ class FeedMessageViewer : public TabContent {
private:
QToolBar *m_toolBar;
QSplitter *m_feedSplitter;
QSplitter *m_messageSplitter;
MessagesView *m_messagesView;
FeedsView *m_feedsView;
WebBrowser *m_messagesBrowser;

View File

@ -66,8 +66,8 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout)
APP_REVISION,
TextFactory::parseDateTime(QString("%1 %2").arg(__DATE__,
__TIME__)).toString(Qt::DefaultLocaleShortDate),
QT_VERSION_STR,
qVersion(),
QT_VERSION_STR,
APP_NAME));
m_ui->m_txtInfo->setText(tr("<body>RSS Guard is a (very) tiny feed reader."

View File

@ -1,6 +1,8 @@
#include <QCloseEvent>
#include <QMessageBox>
#include <QSessionManager>
#include <QRect>
#include <QDesktopWidget>
#include "gui/formmain.h"
#include "gui/formabout.h"
@ -35,6 +37,7 @@ FormMain::FormMain(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::FormMain
m_ui->m_tabWidget->initializeTabs();
setupIcons();
setupSize();
}
FormMain::~FormMain() {
@ -86,7 +89,7 @@ QList<QAction*> FormMain::getActions() {
m_ui->m_actionEditSelectedFeed <<
m_ui->m_actionDeleteSelectedFeeds;
return actions;
return actions;
}
void FormMain::prepareMenus() {
@ -109,7 +112,17 @@ void FormMain::prepareMenus() {
void FormMain::processExecutionMessage(const QString &message) {
qDebug("Received '%s' execution message from another application instance.",
qPrintable(message));
display();
if (message == APP_IS_RUNNING) {
if (SystemTrayIcon::isSystemTrayActivated()) {
SystemTrayIcon::getInstance()->showMessage(APP_NAME,
tr("Application is already running."),
QSystemTrayIcon::Information,
TRAY_ICON_BUBBLE_TIMEOUT);
}
display();
}
}
void FormMain::quit() {
@ -155,6 +168,8 @@ void FormMain::onCommitData(QSessionManager &manager) {
void FormMain::onAboutToQuit() {
qDebug("Cleaning up resources and saving application state before it exits.");
saveSize();
}
bool FormMain::event(QEvent *event) {
@ -206,6 +221,22 @@ void FormMain::setupIcons() {
m_ui->m_tabWidget->setupIcons();
}
void FormMain::setupSize() {
QRect screen = qApp->desktop()->screenGeometry();
resize(Settings::getInstance()->value(APP_CFG_GUI,
"window_size",
size()).toSize());
move(Settings::getInstance()->value(APP_CFG_GUI,
"window_position",
screen.center() - rect().center()).toPoint());
}
void FormMain::saveSize() {
Settings::getInstance()->setValue(APP_CFG_GUI, "window_position", pos());
Settings::getInstance()->setValue(APP_CFG_GUI, "window_size", size());
}
void FormMain::createConnections() {
// Core connections.
connect(qApp, SIGNAL(commitDataRequest(QSessionManager&)),

View File

@ -48,6 +48,10 @@ class FormMain : public QMainWindow {
// kind of method and catch ThemeFactoryEvent::type() in its event handler.
void setupIcons();
// Loads saves visual state of the application.
void setupSize();
void saveSize();
public slots:
// Processes incoming message from another RSS Guard instance.
void processExecutionMessage(const QString &message);