This commit is contained in:
Martin Rotter 2013-12-07 20:33:41 +01:00
parent 8bff38b66c
commit 832190edbd
11 changed files with 197 additions and 78 deletions

View File

@ -15,13 +15,13 @@
#
# "-DUSE_QT_5=ON"
# Specifies which major Qt version to use. Qt 4 and Qt 5 are supported.
# If "OFF" is passed as an argument, then Qt 4 is used.
# If "OFF" is passed as an argument, then Qt 4 is used. Default is "OFF".
#
# Other information:
# - supports Windows, Linux, OS/2 (eComStation),
# - Qt 4.7.3 and higher is required,
# - resource compiler (windres.exe) is needed on MinGW,
# - resource compiler (rc.exe) is needed on OS/2,
# - supports Windows, Linux, OS/2 (eComStation).
# - resource compiler (rc.exe) is needed on OS/2.
#
# Authors and contributors:
# - Martin Rotter (project leader)
@ -34,12 +34,14 @@ cmake_minimum_required(VERSION 2.8.11)
# Setup basic variables.
project(rssguard)
set(APP_NAME "RSS Guard")
set(APP_UP_NAME "RSSGuard")
set(APP_LOW_NAME "rssguard")
set(APP_VERSION "2.0.0-prealpha-3")
set(FILE_VERSION "2,0,0,0")
set(APP_AUTHOR "Martin Rotter")
set(APP_URL "http://rssguard.sf.net")
set(MINIMUM_QT_VERSION 4.7.3)
set(SOURCE_PACKAGE_SUFFIX "Source")
set(EXE_NAME ${APP_LOW_NAME})
option(USE_QT_5 "Use Qt 5 for building" ON)
@ -51,13 +53,6 @@ set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/resources/cmake ${CMAKE_MODULE_PATH})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Setup name for executable file.
if(APPLE)
set(EXE_NAME ${APP_UP_NAME})
else(APPLE)
set(EXE_NAME ${APP_LOW_NAME})
endif(APPLE)
# Select which Qt version to use.
if(${USE_QT_5})
message(STATUS "[${APP_LOW_NAME}] Using Qt 5 library for building.")
@ -159,14 +154,6 @@ endif(${USE_QT_5})
# Setup libraries.
if(${USE_QT_5})
#find_package(Qt5Sql)
#find_package(Qt5WebKit)
#find_package(Qt5WebKitWidgets)
#find_package(Qt5Widgets)
#find_package(Qt5Xml)
#find_package(Qt5XmlPatterns)
#find_package(Qt5Network)
#find_package(Qt5LinguistTools)
find_package(Qt5 REQUIRED Sql WebKit WebKitWidgets Widgets Xml XmlPatterns Network LinguistTools)
else(${USE_QT_5})
set(QT_MIN_VERSION ${MINIMUM_QT_VERSION})
@ -490,7 +477,7 @@ set(CPACK_PACKAGE_NAME ${APP_LOW_NAME})
set(CPACK_PACKAGE_VERSION ${APP_VERSION})
set(CPACK_IGNORE_FILES "/resources/aur/;\\\\.psd$;/resources/deployment;/CVS/;/\\\\.svn/;/\\\\.git/;\\\\.swp$;/CMakeLists.txt.user;\\\\.#;/#;\\\\.tar.gz$;/CMakeFiles/;CMakeCache.txt;\\\\.qm$;/build/;\\\\.diff$;.DS_Store'")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-src")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SOURCE_PACKAGE_SUFFIX}")
set(CPACK_SOURCE_IGNORE_FILES ${CPACK_IGNORE_FILES})
# Load packaging facilities.

View File

@ -1,10 +1,13 @@
// This is resource file for MS Windows platform.
IDI_ICON1 ICON DISCARDABLE "@PROJECT_SOURCE_DIR@/resources/graphics/rssguard.ico"
#include <windows.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION 1,0,0,0
FILEVERSION @FILE_VERSION@
PRODUCTVERSION @FILE_VERSION@
BEGIN
BLOCK "StringFileInfo"
BEGIN

View File

@ -51,8 +51,8 @@ void FeedMessageViewer::initialize() {
QToolButton *update_button = new QToolButton(m_toolBar);
update_button->setPopupMode(QToolButton::InstantPopup);
update_button->setIcon(IconThemeFactory::getInstance()->fromTheme("view-refresh"));
update_button->setText(FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds->text());
update_button->setToolTip(FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds->toolTip());
update_button->setText(tr("Update selected/all feeds"));
update_button->setToolTip(tr("Select which feeds you want to update."));
QMenu *update_menu = new QMenu(tr("Feed update menu"), update_button);
update_menu->addAction(FormMain::getInstance()->m_ui->m_actionUpdateAllFeeds);

View File

@ -58,12 +58,32 @@ TabWidget *FormMain::getTabWidget() {
QList<QAction*> FormMain::getActions() {
QList<QAction*> actions;
// Add basic actions.
actions << m_ui->m_actionImport << m_ui->m_actionExport <<
m_ui->m_actionSettings << m_ui->m_actionQuit <<
m_ui->m_actionFullscreen << m_ui->m_actionAboutGuard <<
m_ui->m_actionAddBrowser << m_ui->m_actionCloseCurrentTab <<
m_ui->m_actionFullscreen;
// Add web browser actions
actions << m_ui->m_actionAddBrowser << m_ui->m_actionCloseCurrentTab <<
m_ui->m_actionCloseAllTabs;
// Add feeds/messages actions.
actions << m_ui->m_actionOpenSelectedSourceArticlesExternally <<
m_ui->m_actionOpenSelectedMessagesExternally <<
m_ui->m_actionOpenSelectedMessagesInternally <<
m_ui->m_actionMarkAllMessagesAsRead <<
m_ui->m_actionMarkAllMessagesAsUnread <<
m_ui->m_actionDeleteAllMessages <<
m_ui->m_actionMarkSelectedMessagesAsRead <<
m_ui->m_actionMarkSelectedMessagesAsUnread <<
m_ui->m_actionSwitchImportanceOfSelectedMessages <<
m_ui->m_actionDeleteSelectedMessages <<
m_ui->m_actionUpdateAllFeeds <<
m_ui->m_actionUpdateSelectedFeeds <<
m_ui->m_actionEditSelectedFeed <<
m_ui->m_actionDeleteSelectedFeeds;
return actions;
}
@ -166,7 +186,9 @@ void FormMain::setupIcons() {
m_ui->m_actionMarkSelectedMessagesAsRead->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-read"));
m_ui->m_actionMarkSelectedMessagesAsUnread->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-unread"));
m_ui->m_actionSwitchImportanceOfSelectedMessages->setIcon(IconThemeFactory::getInstance()->fromTheme("mail-mark-important"));
m_ui->m_actionOpenSelectedMessagesExternally->setIcon(IconThemeFactory::getInstance()->fromTheme("document-open"));
m_ui->m_actionOpenSelectedSourceArticlesExternally->setIcon(IconThemeFactory::getInstance()->fromTheme("document-open"));
m_ui->m_actionOpenSelectedMessagesInternally->setIcon(IconThemeFactory::getInstance()->fromTheme("document-open"));
// Setup icons for underlying components: opened web browsers...
foreach (WebBrowser *browser, WebBrowser::runningWebBrowsers()) {

View File

@ -12,6 +12,7 @@ class FormMain : public QMainWindow {
friend class TabWidget;
friend class FeedMessageViewer;
friend class MessagesView;
public:
// Constructors and destructors.

View File

@ -48,7 +48,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>19</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="m_menuFile">
@ -357,6 +357,36 @@
<string>Add new feed.</string>
</property>
</action>
<action name="m_actionOpenSelectedMessagesExternally">
<property name="text">
<string>Open selected messages in external browser</string>
</property>
<property name="toolTip">
<string>Open selected messages in external browser.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionOpenSelectedMessagesInternally">
<property name="text">
<string>Open selected messages in internal browser</string>
</property>
<property name="toolTip">
<string>Open selected messages in internal browser.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionOpenSelectedSourceArticlesExternally">
<property name="text">
<string>Open selected source articles in external browser</string>
</property>
<property name="toolTip">
<string>Open selected source messages in external browser.</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -125,18 +125,30 @@ void FormSettings::displayProxyPassword(int state) {
bool FormSettings::doSaveCheck() {
bool everything_ok = true;
QString resulting_information;
QStringList resulting_information;
QMessageBox msg_error(this);
// Setup indication of settings consistence.
everything_ok &= m_ui->m_shortcuts->areShortcutsUnique();
if (!m_ui->m_shortcuts->areShortcutsUnique()) {
resulting_information = resulting_information.append(tr("Some keyboard shortcuts are not unique.\n"));
#if QT_VERSION >= 0x050000
resulting_information.append(tr(" • some keyboard shortcuts are not unique"));
#else
resulting_information.append(trUtf8(" • some keyboard shortcuts are not unique"));
#endif
}
// Setup dialog.
msg_error.setText(tr("Some critical settings are not set. You must fix these settings in order confirm new settings."));
msg_error.setWindowTitle(tr("Cannot save settings"));
msg_error.setDetailedText(tr("List of errors:\n %1.").arg(resulting_information.join(",\n")));
msg_error.setIcon(QMessageBox::Critical);
msg_error.setStandardButtons(QMessageBox::Ok);
msg_error.setDefaultButton(QMessageBox::Ok);
if (!everything_ok) {
QMessageBox::warning(this,
tr("Cannot save settings"),
resulting_information);
msg_error.exec();
}
return everything_ok;
@ -494,6 +506,7 @@ void FormSettings::saveInterface() {
QString original_icon_theme = IconThemeFactory::getInstance()->getCurrentIconTheme();
IconThemeFactory::getInstance()->setCurrentIconTheme(selected_icon_theme);
// Check if icon theme was changed.
if (selected_icon_theme != original_icon_theme) {
#if QT_VERSION >= 0x050000
m_changedDataTexts.append(tr(" • icon theme changed"));

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>910</width>
<width>966</width>
<height>445</height>
</rect>
</property>
@ -17,7 +17,7 @@
<item row="0" column="1">
<widget class="QStackedWidget" name="m_stackedSettings">
<property name="currentIndex">
<number>2</number>
<number>5</number>
</property>
<widget class="QWidget" name="m_pageGeneral">
<layout class="QFormLayout" name="formLayout_5">
@ -69,8 +69,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>666</width>
<height>399</height>
<width>100</width>
<height>30</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
@ -147,8 +147,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>662</width>
<height>371</height>
<width>167</width>
<height>219</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
@ -634,6 +634,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="m_pageFeedsMessages"/>
</widget>
</item>
<item row="0" column="0">
@ -663,7 +664,7 @@
<bool>false</bool>
</property>
<property name="currentRow">
<number>0</number>
<number>-1</number>
</property>
<item>
<property name="text">
@ -690,6 +691,11 @@
<string>Web browser &amp; proxy</string>
</property>
</item>
<item>
<property name="text">
<string>Feeds &amp; messages</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">

View File

@ -1,13 +1,16 @@
#include <QHeaderView>
#include <QKeyEvent>
#include <QScrollBar>
#include <QMenu>
#include "gui/messagesview.h"
#include "core/messagesproxymodel.h"
#include "core/messagesmodel.h"
#include "gui/formmain.h"
MessagesView::MessagesView(QWidget *parent) : QTreeView(parent) {
MessagesView::MessagesView(QWidget *parent)
: QTreeView(parent), m_contextMenu(NULL) {
m_proxyModel = new MessagesProxyModel(this);
m_sourceModel = m_proxyModel->sourceModel();
@ -98,6 +101,39 @@ void MessagesView::keyPressEvent(QKeyEvent *event) {
QTreeView::keyPressEvent(event);
}
void MessagesView::contextMenuEvent(QContextMenuEvent *event) {
QModelIndex clicked_index = indexAt(event->pos());
if (!clicked_index.isValid()) {
qDebug("Context menu for MessagesView will not be shown because "
"user clicked on invalid item.");
return;
}
if (m_contextMenu == NULL) {
// Context menu is not initialized, initialize.
initializeContextMenu();
}
m_contextMenu->exec(event->globalPos());
}
void MessagesView::initializeContextMenu() {
m_contextMenu = new QMenu(tr("Context menu for messages"), this);
connect(FormMain::getInstance()->m_ui->m_actionOpenSelectedMessagesExternally,
SIGNAL(triggered()), this, SLOT(openSelectedMessagesExternally()));
m_contextMenu->addActions(QList<QAction*>() <<
FormMain::getInstance()->m_ui->m_actionOpenSelectedSourceArticlesExternally <<
FormMain::getInstance()->m_ui->m_actionOpenSelectedMessagesExternally <<
FormMain::getInstance()->m_ui->m_actionOpenSelectedMessagesInternally <<
FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsRead <<
FormMain::getInstance()->m_ui->m_actionMarkSelectedMessagesAsUnread <<
FormMain::getInstance()->m_ui->m_actionSwitchImportanceOfSelectedMessages <<
FormMain::getInstance()->m_ui->m_actionDeleteSelectedMessages);
}
void MessagesView::mousePressEvent(QMouseEvent *event) {
QTreeView::mousePressEvent(event);
@ -140,36 +176,49 @@ void MessagesView::currentChanged(const QModelIndex &current,
QTreeView::currentChanged(current, previous);
}
void MessagesView::openSelectedMessagesExternally() {
// TODO: otevře vybrane zpravy v externim prohlizeci
}
void MessagesView::openSelectedSourceMessagesInternally() {
// TODO: otevre vybrane nactene zpravy v internch tabech
}
void MessagesView::openSelectedTargetMessagesInternally() {
// TODO: otevre vybrane zpravy ze zdrojovych webz v internich tabech
}
void MessagesView::switchSelectedMessagesImportance() {
QModelIndex current_idx = selectionModel()->currentIndex();
QModelIndex mapped_current_idx = m_proxyModel->mapToSource(current_idx);
QModelIndexList selected_idxs = selectionModel()->selectedRows();
QModelIndexList mapped_idxs = m_proxyModel->mapListToSource(selected_idxs);
QModelIndex current_index = selectionModel()->currentIndex();
QModelIndex mapped_current_index = m_proxyModel->mapToSource(current_index);
QModelIndexList selected_indexes = selectionModel()->selectedRows();
QModelIndexList mapped_indexes = m_proxyModel->mapListToSource(selected_indexes);
m_sourceModel->switchBatchMessageImportance(mapped_idxs);
m_sourceModel->switchBatchMessageImportance(mapped_indexes);
selected_idxs.clear();
selected_indexes.clear();
sortByColumn(header()->sortIndicatorSection(), header()->sortIndicatorOrder());
foreach (const QModelIndex &index, mapped_idxs) {
selected_idxs << m_proxyModel->mapFromSource(m_sourceModel->index(index.row(),
foreach (const QModelIndex &index, mapped_indexes) {
selected_indexes << m_proxyModel->mapFromSource(m_sourceModel->index(index.row(),
index.column()));
}
current_idx = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_idx.row(),
mapped_current_idx.column()));
current_index = m_proxyModel->mapFromSource(m_sourceModel->index(mapped_current_index.row(),
mapped_current_index.column()));
setCurrentIndex(current_idx);
scrollTo(current_idx);
reselectIndexes(selected_idxs);
setCurrentIndex(current_index);
scrollTo(current_index);
reselectIndexes(selected_indexes);
}
void MessagesView::reselectIndexes(const QModelIndexList &indexes) {
selectionModel()->clearSelection();
foreach (const QModelIndex &idx, indexes) {
selectionModel()->select(idx,
QItemSelectionModel::Select | QItemSelectionModel::Rows);
foreach (const QModelIndex &index, indexes) {
selectionModel()->select(index,
QItemSelectionModel::Select |
QItemSelectionModel::Rows);
}
}

View File

@ -24,6 +24,9 @@ class MessagesView : public QTreeView {
public slots:
// Message manipulators.
void openSelectedMessagesExternally();
void openSelectedSourceMessagesInternally();
void openSelectedTargetMessagesInternally();
void switchSelectedMessagesImportance();
void setAllMessagesRead();
@ -31,7 +34,10 @@ class MessagesView : public QTreeView {
void reselectIndexes(const QModelIndexList &indexes);
protected:
void initializeContextMenu();
void setupAppearance();
void contextMenuEvent(QContextMenuEvent *event);
void mousePressEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
void currentChanged(const QModelIndex &current,
@ -44,6 +50,8 @@ class MessagesView : public QTreeView {
void currentMessageRemoved();
private:
QMenu *m_contextMenu;
MessagesProxyModel *m_proxyModel;
MessagesModel *m_sourceModel;
};

View File

@ -176,7 +176,7 @@ void WebBrowser::navigateToMessage(const Message &message) {
tr("Written by ") + message.m_author,
message.m_url,
message.m_contents,
message.m_updated.toString(Qt::ISODate)));
message.m_updated.toString(Qt::DefaultLocaleLongDate)));
}
void WebBrowser::updateZoomGui() {