summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/Controllers/SettingConstants.cpp5
-rw-r--r--Swift/Controllers/SettingConstants.h22
-rw-r--r--Swift/QtUI/QtChatTabs.cpp11
-rw-r--r--Swift/QtUI/QtSpellCheckerWindow.cpp11
-rw-r--r--Swift/QtUI/QtSwift.cpp3
-rw-r--r--Swift/QtUI/QtTextEdit.cpp13
-rw-r--r--Swift/QtUI/QtUISettingConstants.cpp7
-rw-r--r--Swift/QtUI/QtUISettingConstants.h24
8 files changed, 46 insertions, 50 deletions
diff --git a/Swift/Controllers/SettingConstants.cpp b/Swift/Controllers/SettingConstants.cpp
index c3de90f..dedf56b 100644
--- a/Swift/Controllers/SettingConstants.cpp
+++ b/Swift/Controllers/SettingConstants.cpp
@@ -1,32 +1,27 @@
/*
* Copyright (c) 2012-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/Controllers/SettingConstants.h>
namespace Swift {
const SettingsProvider::Setting<bool> SettingConstants::IDLE_GOES_OFFLINE = SettingsProvider::Setting<bool>("idleGoesOffline", false);
const SettingsProvider::Setting<int> SettingConstants::IDLE_TIMEOUT = SettingsProvider::Setting<int>("idleTimeout", 600);
const SettingsProvider::Setting<bool> SettingConstants::SHOW_NOTIFICATIONS = SettingsProvider::Setting<bool>("showNotifications", true);
const SettingsProvider::Setting<bool> SettingConstants::REQUEST_DELIVERYRECEIPTS = SettingsProvider::Setting<bool>("requestDeliveryReceipts", false);
const SettingsProvider::Setting<bool> SettingConstants::FORGET_PASSWORDS = SettingsProvider::Setting<bool>("forgetPasswords", false);
const SettingsProvider::Setting<bool> SettingConstants::REMEMBER_RECENT_CHATS = SettingsProvider::Setting<bool>("rememberRecentChats", true);
const SettingsProvider::Setting<std::string> SettingConstants::LAST_LOGIN_JID = SettingsProvider::Setting<std::string>("lastLoginJID", "");
const SettingsProvider::Setting<bool> SettingConstants::LOGIN_AUTOMATICALLY = SettingsProvider::Setting<bool>("loginAutomatically", false);
const SettingsProvider::Setting<bool> SettingConstants::SHOW_OFFLINE("showOffline", false);
const SettingsProvider::Setting<std::string> SettingConstants::EXPANDED_ROSTER_GROUPS("GroupExpandiness", "");
const SettingsProvider::Setting<bool> SettingConstants::PLAY_SOUNDS("playSounds", true);
const SettingsProvider::Setting<std::string> SettingConstants::HIGHLIGHT_RULES("highlightRules", "@");
-const SettingsProvider::Setting<bool> SettingConstants::SPELL_CHECKER("spellChecker", false);
-const SettingsProvider::Setting<std::string> SettingConstants::SPELL_CHECKER_LANGUAGE("spellCheckerLanguage", "en_US");
const SettingsProvider::Setting<std::string> SettingConstants::INVITE_AUTO_ACCEPT_MODE("inviteAutoAcceptMode", "presence");
-const SettingsProvider::Setting<std::string> SettingConstants::TRELLIS_GRID_SIZE("trellisGridSize", "");
-const SettingsProvider::Setting<std::string> SettingConstants::TRELLIS_GRID_POSITIONS("trellisGridPositions", "");
const SettingsProvider::Setting<bool> SettingConstants::DISCONNECT_ON_CARD_REMOVAL("disconnectOnCardRemoval", true);
const SettingsProvider::Setting<bool> SettingConstants::SINGLE_SIGN_ON("singleSignOn", false);
-const SettingsProvider::Setting<bool> SettingConstants::ENABLE_SOFTWARE_UPDATES("enableSoftwareUpdates", true);
}
diff --git a/Swift/Controllers/SettingConstants.h b/Swift/Controllers/SettingConstants.h
index 95d0527..3f15c44 100644
--- a/Swift/Controllers/SettingConstants.h
+++ b/Swift/Controllers/SettingConstants.h
@@ -30,83 +30,61 @@ namespace Swift {
/**
* The #REQUEST_DELIVERYRECEIPTS settings specifies whether to request delivery receipts
* for messages to contacts that support message receipts.
*/
static const SettingsProvider::Setting<bool> REQUEST_DELIVERYRECEIPTS;
static const SettingsProvider::Setting<bool> FORGET_PASSWORDS;
static const SettingsProvider::Setting<bool> REMEMBER_RECENT_CHATS;
static const SettingsProvider::Setting<std::string> LAST_LOGIN_JID;
static const SettingsProvider::Setting<bool> LOGIN_AUTOMATICALLY;
/**
* The #SHOW_OFFLINE setting specifies whether or not to show offline contacts in the
* roster.
*
* If set true Swift will show offline contacts; else not.
*/
static const SettingsProvider::Setting<bool> SHOW_OFFLINE;
/**
* The #EXPANDED_ROSTER_GROUPS setting specifies the list of groups that are expanded
* in the roster UI.
*
* Its value is a string with group names seperated by newlines.
*/
static const SettingsProvider::Setting<std::string> EXPANDED_ROSTER_GROUPS;
static const SettingsProvider::Setting<bool> PLAY_SOUNDS;
/**
* The #HIGHLIGHT_RULES setting specifies the highlight rules and the associated actions.
*
* Its value is a Boost serialized representation.
*/
static const SettingsProvider::Setting<std::string> HIGHLIGHT_RULES;
- static const SettingsProvider::Setting<bool> SPELL_CHECKER;
- static const SettingsProvider::Setting<std::string> SPELL_CHECKER_LANGUAGE;
/**
* The #INVITE_AUTO_ACCEPT_MODE setting specifies how to handle invites to chat rooms.
*
* Supported values are:
* - "no" : It is up to the user whether to accept the invitation and enter a room or not.
* - "presence" : The invitation is automatically accepted if it is from a contact that is
* already allowed to see the user's presence status.
* - "domain" : The invitation is automatically accepted if it is from a contact that is
* already allowed to see the user's presence status or from a contact of user's domain.
*/
static const SettingsProvider::Setting<std::string> INVITE_AUTO_ACCEPT_MODE;
/**
- * The #TRELLIS_GRID_SIZE setting specifies the dimensions of the grid used for the trellis
- * layout.
- *
- * Its value is a Qt serialized representation.
- */
- static const SettingsProvider::Setting<std::string> TRELLIS_GRID_SIZE;
- /**
- * The #TRELLIS_GRID_POSITIONS setting specifies where conversations to contacts or rooms go
- * in the trellis grid.
- *
- * Its value is a Qt serialized representation.
- */
- static const SettingsProvider::Setting<std::string> TRELLIS_GRID_POSITIONS;
- /**
* The #DISCONNECT_ON_CARD_REMOVAL setting
* specifies whether or not to sign out the user when
* the smartcard is removed.
*
* If set true Swift will sign out the user when the
* smart card is removed; else not.
*/
static const SettingsProvider::Setting<bool> DISCONNECT_ON_CARD_REMOVAL;
/**
* The #SINGLE_SIGN_ON setting
* specifies whether to log in using Single Sign On.
* This is currently supported on Windows.
*
* If set true Swift will use GSSAPI authentication to
* log in the user; else not.
*/
static const SettingsProvider::Setting<bool> SINGLE_SIGN_ON;
- /**
- * The #ENABLE_SOFTWARE_UPDATES settings specifies, whether Swift
- * should automatically check for software updates in regular
- * intervals and install them automatically.
- */
- static const SettingsProvider::Setting<bool> ENABLE_SOFTWARE_UPDATES;
};
}
diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index 650d807..bb9c005 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -1,94 +1,93 @@
/*
* Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/QtUI/QtChatTabs.h>
#include <algorithm>
#include <vector>
#include <QAction>
#include <QApplication>
#include <QCloseEvent>
#include <QCursor>
#include <QDesktopWidget>
#include <QLayout>
#include <QMenu>
#include <QTabBar>
#include <QTabWidget>
#include <QtGlobal>
#include <Swiften/Base/Log.h>
#include <Swift/Controllers/ChatMessageSummarizer.h>
-#include <Swift/Controllers/SettingConstants.h>
-#include <Swift/Controllers/Settings/SettingsProvider.h>
#include <Swift/QtUI/QtSwiftUtil.h>
#include <Swift/QtUI/QtTabWidget.h>
#include <Swift/QtUI/QtTabbable.h>
+#include <Swift/QtUI/QtUISettingConstants.h>
#include <Swift/QtUI/Trellis/QtDynamicGridLayout.h>
#include <Swift/QtUI/Trellis/QtGridSelectionDialog.h>
namespace Swift {
QtChatTabs::QtChatTabs(bool singleWindow, SettingsProvider* settingsProvider, bool trellisMode) : QWidget(), singleWindow_(singleWindow), settingsProvider_(settingsProvider), trellisMode_(trellisMode), dynamicGrid_(nullptr), gridSelectionDialog_(nullptr) {
#ifndef Q_OS_MAC
setWindowIcon(QIcon(":/logo-chat-16.png"));
#else
setAttribute(Qt::WA_ShowWithoutActivating);
#endif
dynamicGrid_ = new QtDynamicGridLayout(this, trellisMode);
connect(dynamicGrid_, SIGNAL(tabCloseRequested(int)), this, SLOT(handleTabCloseRequested(int)));
connect(dynamicGrid_, SIGNAL(onCurrentIndexChanged(int)), this, SLOT(handleCurrentTabIndexChanged(int)));
QVBoxLayout *layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(dynamicGrid_);
setLayout(layout);
if (trellisMode) {
// restore size
- std::string gridSizeString = settingsProvider->getSetting(SettingConstants::TRELLIS_GRID_SIZE);
+ std::string gridSizeString = settingsProvider->getSetting(QtUISettingConstants::TRELLIS_GRID_SIZE);
if (!gridSizeString.empty()) {
QByteArray gridSizeData = QByteArray::fromBase64(P2QSTRING(gridSizeString).toUtf8());
QDataStream dataStreamGridSize(&gridSizeData, QIODevice::ReadWrite);
QSize gridSize(1,1);
dataStreamGridSize >> gridSize;
dynamicGrid_->setDimensions(gridSize);
}
// restore positions
- std::string tabPositionsString = settingsProvider->getSetting(SettingConstants::TRELLIS_GRID_POSITIONS);
+ std::string tabPositionsString = settingsProvider->getSetting(QtUISettingConstants::TRELLIS_GRID_POSITIONS);
if (!tabPositionsString.empty()) {
QByteArray tabPositionsData = QByteArray::fromBase64(P2QSTRING(tabPositionsString).toUtf8());
QDataStream inTabPositions(&tabPositionsData, QIODevice::ReadWrite);
QHash<QString, QPoint> tabPositions;
inTabPositions >> tabPositions;
dynamicGrid_->setTabPositions(tabPositions);
}
}
gridSelectionDialog_ = new QtGridSelectionDialog();
// setup shortcuts
shortcuts_ << new QShortcut(QKeySequence(tr("CTRL+W", "Close chat tab.")), window(), SLOT(handleCloseTabShortcut()));
shortcuts_ << new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageUp), window(), SLOT(handleRequestedPreviousTab()));
shortcuts_ << new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_PageDown), window(), SLOT(handleRequestedNextTab()));
shortcuts_ << new QShortcut(QKeySequence(Qt::ALT + Qt::Key_A), window(), SLOT(handleRequestedActiveTab()));
}
QtChatTabs::~QtChatTabs() {
foreach (QShortcut* shortcut, shortcuts_) {
delete shortcut;
}
if (trellisMode_) {
storeTabPositions();
}
delete gridSelectionDialog_;
}
void QtChatTabs::closeEvent(QCloseEvent* event) {
@@ -356,68 +355,68 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
unreads.push_back(std::pair<std::string, int>(Q2PSTRING(tab->windowTitle()), tab->getCount()));
}
}
std::string current(Q2PSTRING(qobject_cast<QtTabbable*>(dynamicGrid_->currentWidget())->windowTitle()));
ChatMessageSummarizer summary;
QString title = summary.getSummary(current, unreads).c_str();
setWindowTitle(title);
emit onTitleChanged(title);
}
void QtChatTabs::flash() {
#ifndef SWIFTEN_PLATFORM_MACOSX
QApplication::alert(this, 0);
#endif
}
void QtChatTabs::handleOpenLayoutChangeDialog() {
disconnect(gridSelectionDialog_, SIGNAL(currentGridSizeChanged(QSize)), dynamicGrid_, SLOT(setDimensions(QSize)));
gridSelectionDialog_->setCurrentGridSize(dynamicGrid_->getDimension());
gridSelectionDialog_->move(QCursor::pos());
connect(gridSelectionDialog_, SIGNAL(currentGridSizeChanged(QSize)), dynamicGrid_, SLOT(setDimensions(QSize)));
gridSelectionDialog_->show();
}
void QtChatTabs::storeTabPositions() {
// save size
QByteArray gridSizeData;
QDataStream dataStreamGridSize(&gridSizeData, QIODevice::ReadWrite);
dataStreamGridSize << dynamicGrid_->getDimension();
- settingsProvider_->storeSetting(SettingConstants::TRELLIS_GRID_SIZE, Q2PSTRING(QString(gridSizeData.toBase64())));
+ settingsProvider_->storeSetting(QtUISettingConstants::TRELLIS_GRID_SIZE, Q2PSTRING(QString(gridSizeData.toBase64())));
// save positions
QByteArray tabPositionsData;
QDataStream dataStreamTabPositions(&tabPositionsData, QIODevice::ReadWrite);
dynamicGrid_->updateTabPositions();
dataStreamTabPositions << dynamicGrid_->getTabPositions();
- settingsProvider_->storeSetting(SettingConstants::TRELLIS_GRID_POSITIONS, Q2PSTRING(QString(tabPositionsData.toBase64())));
+ settingsProvider_->storeSetting(QtUISettingConstants::TRELLIS_GRID_POSITIONS, Q2PSTRING(QString(tabPositionsData.toBase64())));
}
void QtChatTabs::resizeEvent(QResizeEvent*) {
emit geometryChanged();
}
void QtChatTabs::moveEvent(QMoveEvent*) {
emit geometryChanged();
}
void QtChatTabs::checkForFirstShow() {
if (!isVisible()) {
#ifndef Q_OS_MAC
showMinimized();
#else
/* https://bugreports.qt-project.org/browse/QTBUG-19194
* ^ When the above is fixed we can swap the below for just show();
* WA_ShowWithoutActivating seems to helpfully not work, so... */
QWidget* currentWindow = QApplication::activeWindow(); /* Remember who had focus if we're the current application*/
show();
QCoreApplication::processEvents(); /* Run through the eventloop to clear the show() */
if (currentWindow) {
currentWindow->activateWindow(); /* Set focus back */
}
#endif
}
}
}
diff --git a/Swift/QtUI/QtSpellCheckerWindow.cpp b/Swift/QtUI/QtSpellCheckerWindow.cpp
index ed7e7e8..a8178c4 100644
--- a/Swift/QtUI/QtSpellCheckerWindow.cpp
+++ b/Swift/QtUI/QtSpellCheckerWindow.cpp
@@ -1,101 +1,98 @@
/*
* Copyright (c) 2011 Vlad Voicu
* Licensed under the Simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
/*
* Copyright (c) 2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/QtUI/QtSpellCheckerWindow.h>
#include <QCoreApplication>
#include <QDir>
#include <QFileDialog>
#include <QStringList>
#include <QTimer>
#include <Swiften/Base/Log.h>
-#include <Swift/Controllers/SettingConstants.h>
-#include <Swift/Controllers/Settings/SettingsProvider.h>
-
#include <Swift/QtUI/QtSwiftUtil.h>
#include <Swift/QtUI/QtUISettingConstants.h>
namespace Swift {
QtSpellCheckerWindow::QtSpellCheckerWindow(SettingsProvider* settings, QWidget* parent) : QDialog(parent) {
settings_ = settings;
ui_.setupUi(this);
#ifdef HAVE_HUNSPELL
ui_.hunspellOptions->show();
#else
ui_.hunspellOptions->hide();
QTimer::singleShot(0, this, SLOT(shrinkWindow()));
#endif
connect(ui_.spellChecker, SIGNAL(toggled(bool)), this, SLOT(handleChecker(bool)));
connect(ui_.cancel, SIGNAL(clicked()), this, SLOT(handleCancel()));
connect(ui_.apply, SIGNAL(clicked()), this, SLOT(handleApply()));
setFromSettings();
}
void QtSpellCheckerWindow::shrinkWindow() {
resize(0,0);
}
void QtSpellCheckerWindow::setFromSettings() {
- ui_.spellChecker->setChecked(settings_->getSetting(SettingConstants::SPELL_CHECKER));
- setEnabled(settings_->getSetting(SettingConstants::SPELL_CHECKER));
+ ui_.spellChecker->setChecked(settings_->getSetting(QtUISettingConstants::SPELL_CHECKER));
+ setEnabled(settings_->getSetting(QtUISettingConstants::SPELL_CHECKER));
}
void QtSpellCheckerWindow::setSupportedLanguages(const std::vector<std::string>& languages) {
languageItems_.clear();
ui_.languageView->clear();
for (const auto& shortLang : languages) {
auto locale = QLocale(P2QSTRING(shortLang));
auto label = QString("%1 ( %2 )").arg(locale.nativeLanguageName(), locale.nativeCountryName());
QListWidgetItem* item = new QListWidgetItem(label);
item->setData(Qt::UserRole, P2QSTRING(shortLang));
languageItems_[shortLang] = item;
ui_.languageView->addItem(item);
}
}
void QtSpellCheckerWindow::setActiveLanguage(const std::string& language) {
SWIFT_LOG_ASSERT(languageItems_.find(language) != languageItems_.end(), warning) << "Language '" << language << "' is not available." << std::endl;
if (languageItems_.find(language) != languageItems_.end()) {
languageItems_[language]->setSelected(true);
}
}
void QtSpellCheckerWindow::setAutomaticallyIdentifiesLanguage(bool isAutomaticallyIdentifying) {
ui_.languageView->setHidden(isAutomaticallyIdentifying);
}
void QtSpellCheckerWindow::handleChecker(bool state) {
setEnabled(state);
}
void QtSpellCheckerWindow::setEnabled(bool state) {
ui_.language->setEnabled(state);
}
void QtSpellCheckerWindow::handleApply() {
- settings_->storeSetting(SettingConstants::SPELL_CHECKER, ui_.spellChecker->isChecked());
+ settings_->storeSetting(QtUISettingConstants::SPELL_CHECKER, ui_.spellChecker->isChecked());
QList<QListWidgetItem* > selectedLanguage = ui_.languageView->selectedItems();
if (!selectedLanguage.empty()) {
- settings_->storeSetting(SettingConstants::SPELL_CHECKER_LANGUAGE, Q2PSTRING(selectedLanguage.first()->data(Qt::UserRole).toString()));
+ settings_->storeSetting(QtUISettingConstants::SPELL_CHECKER_LANGUAGE, Q2PSTRING(selectedLanguage.first()->data(Qt::UserRole).toString()));
}
this->done(0);
}
void QtSpellCheckerWindow::handleCancel() {
this->done(0);
}
}
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index 16d8955..3aff999 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -23,60 +23,61 @@
#include <Swiften/Base/Paths.h>
#include <Swiften/Base/Platform.h>
#include <Swiften/Client/Client.h>
#include <Swiften/Elements/Presence.h>
#include <Swiften/TLS/TLSContextFactory.h>
#include <SwifTools/Application/PlatformApplicationPathProvider.h>
#include <SwifTools/AutoUpdater/AutoUpdater.h>
#include <SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h>
#include <Swift/Controllers/ApplicationInfo.h>
#include <Swift/Controllers/BuildVersion.h>
#include <Swift/Controllers/MainController.h>
#include <Swift/Controllers/SettingConstants.h>
#include <Swift/Controllers/Settings/SettingsProviderHierachy.h>
#include <Swift/Controllers/Settings/XMLSettingsProvider.h>
#include <Swift/Controllers/StatusCache.h>
#include <Swift/Controllers/Storages/CertificateFileStorageFactory.h>
#include <Swift/Controllers/Storages/FileStoragesFactory.h>
#include <Swift/QtUI/QtChatTabs.h>
#include <Swift/QtUI/QtChatTabsBase.h>
#include <Swift/QtUI/QtChatTabsShortcutOnlySubstitute.h>
#include <Swift/QtUI/QtChatWindowFactory.h>
#include <Swift/QtUI/QtLoginWindow.h>
#include <Swift/QtUI/QtSingleWindow.h>
#include <Swift/QtUI/QtSoundPlayer.h>
#include <Swift/QtUI/QtSwiftUtil.h>
#include <Swift/QtUI/QtSystemTray.h>
#include <Swift/QtUI/QtUIFactory.h>
+#include <Swift/QtUI/QtUISettingConstants.h>
#if defined(SWIFTEN_PLATFORM_WINDOWS)
#include <Swift/QtUI/WindowsNotifier.h>
#elif defined(HAVE_GROWL)
#include <SwifTools/Notifier/GrowlNotifier.h>
#elif defined(SWIFTEN_PLATFORM_LINUX)
#include <Swift/QtUI/FreeDesktopNotifier.h>
#elif defined(SWIFTEN_PLATFORM_MACOSX)
#include <SwifTools/Notifier/NotificationCenterNotifier.h>
#else
#include <SwifTools/Notifier/NullNotifier.h>
#endif
#if defined(SWIFTEN_PLATFORM_MACOSX)
#include <SwifTools/Dock/MacOSXDock.h>
#else
#include <SwifTools/Dock/NullDock.h>
#endif
#if defined(SWIFTEN_PLATFORM_MACOSX)
#include <Swift/QtUI/QtURIHandler.h>
#elif defined(SWIFTEN_PLATFORM_WIN32)
#include <SwifTools/URIHandler/NullURIHandler.h>
#else
#include <Swift/QtUI/QtDBUSURIHandler.h>
#endif
#if defined(SWIFTEN_PLATFORM_MACOSX)
#include <Swift/QtUI/CocoaUIHelpers.h>
#endif
@@ -257,61 +258,61 @@ QtSwift::QtSwift(const po::variables_map& options) : networkFactories_(&clientMa
}
for (int i = 0; i < numberOfAccounts; i++) {
if (i > 0) {
// Don't add the first tray (see note above)
systemTrays_.push_back(new QtSystemTray());
}
QtUIFactory* uiFactory = new QtUIFactory(settingsHierachy_, qtSettings_, tabs_, splitter_, systemTrays_[i], chatWindowFactory_, networkFactories_.getTimerFactory(), statusCache_, startMinimized, !emoticons.empty(), enableAdHocCommandOnJID);
uiFactories_.push_back(uiFactory);
MainController* mainController = new MainController(
&clientMainThreadCaller_,
&networkFactories_,
uiFactory,
settingsHierachy_,
systemTrays_[i],
soundPlayer_,
storagesFactory_,
certificateStorageFactory_,
dock_,
notifier_,
uriHandler_,
&idleDetector_,
emoticons,
options.count("latency-debug") > 0);
mainControllers_.push_back(mainController);
}
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(handleAboutToQuit()));
PlatformAutoUpdaterFactory autoUpdaterFactory;
- if (autoUpdaterFactory.isSupported() && settingsHierachy_->getSetting(SettingConstants::ENABLE_SOFTWARE_UPDATES)) {
+ if (autoUpdaterFactory.isSupported() && settingsHierachy_->getSetting(QtUISettingConstants::ENABLE_SOFTWARE_UPDATES)) {
autoUpdater_ = autoUpdaterFactory.createAutoUpdater(SWIFT_APPCAST_URL);
autoUpdater_->checkForUpdates();
autoUpdater_->onSuggestRestartToUserToUpdate.connect(boost::bind(&QtSwift::handleRecommendRestartToInstallUpdate, this));
}
}
QtSwift::~QtSwift() {
delete autoUpdater_;
for (auto* factory : uiFactories_) {
delete factory;
}
for (auto* controller : mainControllers_) {
delete controller;
}
delete notifier_;
for (auto* tray : systemTrays_) {
delete tray;
}
delete tabs_;
delete splitter_;
delete settingsHierachy_;
delete qtSettings_;
delete xmlSettings_;
delete statusCache_;
delete uriHandler_;
delete dock_;
delete soundPlayer_;
delete chatWindowFactory_;
delete certificateStorageFactory_;
delete storagesFactory_;
diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index d9ee2f4..e9708bf 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -1,57 +1,56 @@
/*
* Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/QtUI/QtTextEdit.h>
#include <boost/algorithm/string.hpp>
#include <boost/bind.hpp>
#include <boost/tuple/tuple.hpp>
#include <QApplication>
#include <QKeyEvent>
#include <QKeySequence>
#include <QMenu>
#include <QTextDocument>
#include <Swiften/Base/Log.h>
-#include <Swift/Controllers/SettingConstants.h>
-
#include <SwifTools/SpellChecker.h>
#include <SwifTools/SpellCheckerFactory.h>
#include <Swift/QtUI/QtSpellCheckerWindow.h>
#include <Swift/QtUI/QtSwiftUtil.h>
+#include <Swift/QtUI/QtUISettingConstants.h>
#include <Swift/QtUI/QtUtilities.h>
namespace Swift {
QtTextEdit::QtTextEdit(SettingsProvider* settings, QWidget* parent) : QTextEdit(parent), checker_(nullptr), highlighter_(nullptr) {
connect(this, SIGNAL(textChanged()), this, SLOT(handleTextChanged()));
settings_ = settings;
#ifdef HAVE_SPELLCHECKER
setUpSpellChecker();
#endif
handleTextChanged();
QTextOption textOption = document()->defaultTextOption();
textOption.setWrapMode(QTextOption::WordWrap);
document()->setDefaultTextOption(textOption);
}
QtTextEdit::~QtTextEdit() {
delete checker_;
}
void QtTextEdit::keyPressEvent(QKeyEvent* event) {
int key = event->key();
Qt::KeyboardModifiers modifiers = event->modifiers();
if ((key == Qt::Key_Enter || key == Qt::Key_Return)
&& (modifiers == Qt::NoModifier || modifiers == Qt::KeypadModifier)) {
emit returnPressed();
}
else if (((key == Qt::Key_PageUp || key == Qt::Key_PageDown) && modifiers == Qt::ShiftModifier)
|| (key == Qt::Key_C && modifiers == Qt::ControlModifier && textCursor().selectedText().isEmpty())
|| (key == Qt::Key_W && modifiers == Qt::ControlModifier)
@@ -188,81 +187,81 @@ void QtTextEdit::addSuggestions(QMenu* menu, QContextMenuEvent* event)
// suggestions are necessary
return;
}
cursor.setPosition(boost::get<0>(wordPosition), QTextCursor::MoveAnchor);
cursor.setPosition(boost::get<1>(wordPosition), QTextCursor::KeepAnchor);
std::vector<std::string> wordList;
checker_->getSuggestions(Q2PSTRING(cursor.selectedText()), wordList);
if (wordList.size() == 0) {
QAction* noSuggestions = new QAction(tr("No Suggestions"), menu);
noSuggestions->setDisabled(true);
menu->insertAction(insertPoint, noSuggestions);
}
else {
for (auto& word : wordList) {
QAction* wordAction = new QAction(word.c_str(), menu);
menu->insertAction(insertPoint, wordAction);
replaceWordActions_.push_back(wordAction);
}
}
menu->insertAction(insertPoint, menu->addSeparator());
}
}
#ifdef HAVE_SPELLCHECKER
void QtTextEdit::setUpSpellChecker() {
delete highlighter_;
highlighter_ = nullptr;
delete checker_;
checker_ = nullptr;
- if (settings_->getSetting(SettingConstants::SPELL_CHECKER)) {
+ if (settings_->getSetting(QtUISettingConstants::SPELL_CHECKER)) {
checker_ = SpellCheckerFactory().createSpellChecker();
if (checker_) {
if (!checker_->isAutomaticallyDetectingLanguage()) {
- checker_->setActiveLanguage(settings_->getSetting(SettingConstants::SPELL_CHECKER_LANGUAGE));
+ checker_->setActiveLanguage(settings_->getSetting(QtUISettingConstants::SPELL_CHECKER_LANGUAGE));
}
highlighter_ = new QtSpellCheckHighlighter(document(), checker_);
}
else {
// Spellchecking is not working, as we did not get a valid checker from the factory. Disable spellchecking.
SWIFT_LOG(warning) << "Spellchecking is currently misconfigured in Swift (e.g. missing dictionary or broken dictionary file). Disable spellchecking." << std::endl;
- settings_->storeSetting(SettingConstants::SPELL_CHECKER, false);
+ settings_->storeSetting(QtUISettingConstants::SPELL_CHECKER, false);
}
}
}
#endif
void QtTextEdit::spellCheckerSettingsWindow() {
if (!spellCheckerWindow_) {
spellCheckerWindow_ = new QtSpellCheckerWindow(settings_);
settings_->onSettingChanged.connect(boost::bind(&QtTextEdit::handleSettingChanged, this, _1));
spellCheckerWindow_->show();
}
else {
spellCheckerWindow_->show();
spellCheckerWindow_->raise();
spellCheckerWindow_->activateWindow();
}
if (checker_) {
spellCheckerWindow_->setAutomaticallyIdentifiesLanguage(checker_->isAutomaticallyDetectingLanguage());
if (!checker_->isAutomaticallyDetectingLanguage()) {
spellCheckerWindow_->setSupportedLanguages(checker_->supportedLanguages());
spellCheckerWindow_->setActiveLanguage(checker_->activeLanguage());
}
}
}
void QtTextEdit::handleSettingChanged(const std::string& settings) {
- if (settings == SettingConstants::SPELL_CHECKER.getKey() ||
- settings == SettingConstants::SPELL_CHECKER_LANGUAGE.getKey()) {
+ if (settings == QtUISettingConstants::SPELL_CHECKER.getKey() ||
+ settings == QtUISettingConstants::SPELL_CHECKER_LANGUAGE.getKey()) {
#ifdef HAVE_SPELLCHECKER
setUpSpellChecker();
if (highlighter_) {
highlighter_->rehighlight();
}
#endif
}
}
}
diff --git a/Swift/QtUI/QtUISettingConstants.cpp b/Swift/QtUI/QtUISettingConstants.cpp
index 812e3eb..c81a234 100644
--- a/Swift/QtUI/QtUISettingConstants.cpp
+++ b/Swift/QtUI/QtUISettingConstants.cpp
@@ -1,20 +1,25 @@
/*
- * Copyright (c) 2012-2013 Isode Limited.
+ * Copyright (c) 2012-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swift/QtUI/QtUISettingConstants.h>
namespace Swift {
const SettingsProvider::Setting<bool> QtUISettingConstants::COMPACT_ROSTER("compactRoster", false);
const SettingsProvider::Setting<std::string> QtUISettingConstants::CLICKTHROUGH_BANNER("clickthroughBanner", "");
const SettingsProvider::Setting<int> QtUISettingConstants::CURRENT_ROSTER_TAB("currentRosterTab", 0);
const SettingsProvider::Setting<bool> QtUISettingConstants::SHOW_NICK_IN_ROSTER_HEADER("showNickInRosterHeader", true);
const SettingsProvider::Setting<int> QtUISettingConstants::CHATWINDOW_FONT_SIZE("chatWindowFontSize", 0);
const SettingsProvider::Setting<int> QtUISettingConstants::HISTORYWINDOW_FONT_SIZE("historyWindowFontSize", 0);
const SettingsProvider::Setting<bool> QtUISettingConstants::SHOW_EMOTICONS("showEmoticons", true);
const SettingsProvider::Setting<bool> QtUISettingConstants::USE_PLAIN_CHATS("plainChats", false);
const SettingsProvider::Setting<bool> QtUISettingConstants::USE_SCREENREADER("screenreader", false);
+const SettingsProvider::Setting<bool> QtUISettingConstants::SPELL_CHECKER("spellChecker", false);
+const SettingsProvider::Setting<std::string> QtUISettingConstants::SPELL_CHECKER_LANGUAGE("spellCheckerLanguage", "en_US");
+const SettingsProvider::Setting<std::string> QtUISettingConstants::TRELLIS_GRID_SIZE("trellisGridSize", "");
+const SettingsProvider::Setting<std::string> QtUISettingConstants::TRELLIS_GRID_POSITIONS("trellisGridPositions", "");
+const SettingsProvider::Setting<bool> QtUISettingConstants::ENABLE_SOFTWARE_UPDATES("enableSoftwareUpdates", true);
}
diff --git a/Swift/QtUI/QtUISettingConstants.h b/Swift/QtUI/QtUISettingConstants.h
index 3e7291f..4616656 100644
--- a/Swift/QtUI/QtUISettingConstants.h
+++ b/Swift/QtUI/QtUISettingConstants.h
@@ -1,24 +1,46 @@
/*
- * Copyright (c) 2012-2013 Isode Limited.
+ * Copyright (c) 2012-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
#include <Swift/Controllers/Settings/SettingsProvider.h>
namespace Swift {
class QtUISettingConstants {
public:
static const SettingsProvider::Setting<bool> COMPACT_ROSTER;
static const SettingsProvider::Setting<std::string> CLICKTHROUGH_BANNER;
static const SettingsProvider::Setting<int> CURRENT_ROSTER_TAB;
static const SettingsProvider::Setting<bool> SHOW_NICK_IN_ROSTER_HEADER;
static const SettingsProvider::Setting<int> CHATWINDOW_FONT_SIZE;
static const SettingsProvider::Setting<int> HISTORYWINDOW_FONT_SIZE;
static const SettingsProvider::Setting<bool> SHOW_EMOTICONS;
static const SettingsProvider::Setting<bool> USE_PLAIN_CHATS;
static const SettingsProvider::Setting<bool> USE_SCREENREADER;
+ static const SettingsProvider::Setting<bool> SPELL_CHECKER;
+ static const SettingsProvider::Setting<std::string> SPELL_CHECKER_LANGUAGE;
+ /**
+ * The #TRELLIS_GRID_SIZE setting specifies the dimensions of the grid used for the trellis
+ * layout.
+ *
+ * Its value is a Qt serialized representation.
+ */
+ static const SettingsProvider::Setting<std::string> TRELLIS_GRID_SIZE;
+ /**
+ * The #TRELLIS_GRID_POSITIONS setting specifies where conversations to contacts or rooms go
+ * in the trellis grid.
+ *
+ * Its value is a Qt serialized representation.
+ */
+ static const SettingsProvider::Setting<std::string> TRELLIS_GRID_POSITIONS;
+ /**
+ * The #ENABLE_SOFTWARE_UPDATES settings specifies, whether Swift
+ * should automatically check for software updates in regular
+ * intervals and install them automatically.
+ */
+ static const SettingsProvider::Setting<bool> ENABLE_SOFTWARE_UPDATES;
};
}