diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index dfdbe236..8a180ea2 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -1,147 +1,148 @@ set(Ruqola_widgets_SRCS ruqolamainwindow.cpp ruqolacentralwidget.cpp ruqolaloginwidget.cpp ruqolamainwidget.cpp ) set(Ruqola_widgets_dialog_SRCS dialogs/serverinfowidget.cpp dialogs/serverinfodialog.cpp dialogs/uploadfiledialog.cpp dialogs/uploadfilewidget.cpp dialogs/channelinfowidget.cpp dialogs/channelinfodialog.cpp dialogs/searchchanneldialog.cpp dialogs/searchchannelwidget.cpp dialogs/modifystatusdialog.cpp dialogs/modifystatuswidget.cpp dialogs/createnewchanneldialog.cpp dialogs/createnewchannelwidget.cpp dialogs/showlistmessagebasedialog.cpp dialogs/showlistmessagebasewidget.cpp dialogs/createnewaccountdialog.cpp dialogs/createnewaccountwidget.cpp dialogs/showpinnedmessagesdialog.cpp dialogs/showstarredmessagesdialog.cpp dialogs/showmentionsmessagesdialog.cpp dialogs/showsnipperedmessagesdialog.cpp dialogs/configurenotificationdialog.cpp dialogs/configurenotificationwidget.cpp dialogs/searchmessagedialog.cpp dialogs/searchmessagewidget.cpp dialogs/reportmessagedialog.cpp dialogs/reportmessagewidget.cpp dialogs/showimagedialog.cpp dialogs/showimagewidget.cpp dialogs/showattachmentdialog.cpp dialogs/showattachmentwidget.cpp dialogs/directchannelinfodialog.cpp dialogs/directchannelinfowidget.cpp dialogs/listattachmentdelegate.cpp dialogs/showdiscussionsdialog.cpp dialogs/showdiscussionswidget.cpp dialogs/listdiscussiondelegate.cpp dialogs/createnewdiscussiondialog.cpp dialogs/createnewdiscussionwidget.cpp dialogs/channelpassworddialog.cpp dialogs/channelpasswordwidget.cpp dialogs/addusersinroomdialog.cpp dialogs/addusersinroomwidget.cpp dialogs/adduserscompletionlineedit.cpp dialogs/showthreadswidget.cpp dialogs/showthreadsdialog.cpp dialogs/listthreadsdelegate.cpp ) set(Ruqola_configure_SRCS configuredialog/configuresettingsdialog.cpp configuredialog/configureaccountwidget.cpp configuredialog/accountserverlistwidget.cpp configuredialog/configureaccountserverwidget.cpp ) ki18n_wrap_ui(Ruqola_configure_SRCS configuredialog/configureaccountserverwidget.ui ) set(Ruqola_channellist_SRCS channellist/channellistwidget.cpp channellist/statuscombobox.cpp channellist/channellistview.cpp channellist/channellistdelegate.cpp ) set(Ruqola_roomwidget_SRCS room/roomwidget.cpp room/roomheaderwidget.cpp room/messagelistview.cpp room/messagelineedit.cpp room/messagelistdelegate.cpp room/messagedelegatehelperbase.cpp room/messagedelegatehelpertext.cpp room/messagedelegatehelperimage.cpp room/messagedelegatehelperfile.cpp room/messagelinewidget.cpp room/readonlylineeditwidget.cpp ) set(Ruqola_misc_widget_SRCS misc/accountmenu.cpp + misc/accountsoverviewwidget.cpp misc/emoticonmenuwidget.cpp misc/emoticonselectorwidget.cpp ) set(Ruqola_common_SRCS common/completionlineedit.cpp ) ecm_qt_declare_logging_category(Ruqola_widgets_SRCS HEADER ruqolawidgets_debug.h IDENTIFIER RUQOLAWIDGETS_LOG CATEGORY_NAME org.kde.ruqola.widgets) qt5_add_resources(Ruqola_widgets_SRCS ruqolawidget.qrc) add_library(libruqolawidgets ${Ruqola_common_SRCS} ${Ruqola_widgets_SRCS} ${Ruqola_widgets_dialog_SRCS} ${Ruqola_channellist_SRCS} ${Ruqola_roomwidget_SRCS} ${Ruqola_configure_SRCS} ${Ruqola_misc_widget_SRCS} ) generate_export_header(libruqolawidgets BASE_NAME libruqolawidgets) target_link_libraries(libruqolawidgets Qt5::Gui Qt5::Widgets KF5::I18n KF5::ConfigCore KF5::XmlGui KF5::KIOWidgets KF5::WidgetsAddons librocketchatrestapi-qt5 libruqolacore ) if (NOT WIN32) target_link_libraries(libruqolawidgets Qt5::DBus) endif() set_target_properties(libruqolawidgets PROPERTIES OUTPUT_NAME ruqolawidgets VERSION ${RUQOLA_LIB_VERSION} SOVERSION ${RUQOLA_LIB_SOVERSION} ) if (BUILD_TESTING) add_subdirectory(autotests) add_subdirectory(tests) add_subdirectory(channellist/autotests) add_subdirectory(room/autotests) add_subdirectory(dialogs/autotests) add_subdirectory(misc/autotests) endif() install(TARGETS libruqolawidgets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP) diff --git a/src/widgets/misc/accountsoverviewwidget.cpp b/src/widgets/misc/accountsoverviewwidget.cpp new file mode 100644 index 00000000..3eea131d --- /dev/null +++ b/src/widgets/misc/accountsoverviewwidget.cpp @@ -0,0 +1,222 @@ +/* + * Copyright 2020 Olivier de Gaalon + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "accountsoverviewwidget.h" + +#include "accountmanager.h" +#include "model/rocketchataccountmodel.h" +#include "rocketchataccount.h" +#include "ruqola.h" + +#include + +#include +#include +#include +#include +#include +#include + +constexpr const double PAD = 0.2; + +class AccountButton : public QAbstractButton +{ + struct UnreadAlert + { + int unread; + bool alert; + }; + +public: + AccountButton(QWidget *parent = nullptr) + : QAbstractButton(parent) + , mAccount(nullptr) + { + connect(Ruqola::self()->accountManager(), &AccountManager::currentAccountChanged, + this, QOverload<>::of(&AccountButton::update)); + + setMouseTracking(true); + setFocusPolicy(Qt::NoFocus); + setAttribute(Qt::WA_Hover); + } + + void setAccount(RocketChatAccount *acct) + { + if (mAccount) + { + mAccount->disconnect(this); + mAccount->roomModel()->disconnect(this); + this->disconnect(acct); + } + + mAccount = acct; + + if (mAccount) + { + auto updateFont = [this]{ + QFont f = font(); + f.setBold(currentUnreadAlert().alert); + setFont(f); + updateGeometry(); + }; + connect(acct, &RocketChatAccount::accountNameChanged, this, &AccountButton::updateGeometry); + connect(acct, &RocketChatAccount::loginStatusChanged, this, &AccountButton::updateGeometry); + connect(acct, &RocketChatAccount::loginStatusChanged, this, &AccountButton::updateTooltip); + connect(acct->roomModel(), &RoomModel::needToUpdateNotification, this, updateFont); + connect(this, &AccountButton::clicked, acct, [acct]{ + Ruqola::self()->accountManager()->setCurrentAccount(acct->accountName()); + }); + + updateFont(); + } + update(); + } + + QSize sizeHint() const override + { + const double height = fontMetrics().height(); + const double padding = height * PAD; + const QSize text = fontMetrics().boundingRect(currentText()).size(); + return QSize(text.width() + padding * 2, height + padding * 2); + } + +protected: + void enterEvent(QEvent *event) override + { + if (isEnabled()) + update(); + QAbstractButton::enterEvent(event); + } + + void leaveEvent(QEvent *event) override + { + if (isEnabled()) + update(); + QAbstractButton::leaveEvent(event); + } + + void paintEvent(QPaintEvent *) override + { + if (!mAccount) + return; + + QPainter p(this); + + { + const bool isCurrent = Ruqola::self()->accountManager()->currentAccount() == mAccount->accountName(); + + QStyleOption opt; + opt.init(this); + if (isDown() || isCurrent) + opt.state |= QStyle::State_Sunken; + style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this); + } + + p.setPen(palette().color(QPalette::WindowText)); + p.setFont(font()); + p.drawText(rect(), Qt::AlignCenter, currentText()); + } + +private: + QString currentText() const + { + QString text = mAccount->accountName(); + if (text.isEmpty()) + text = i18n("(Unnamed)"); + + if (mAccount->loginStatus() != DDPClient::LoggedIn) + text += QStringLiteral(": %1").arg(currentLoginStatusText()); + else if (int unread = currentUnreadAlert().unread) + text += QStringLiteral(" (%1)").arg(unread); + + return text; + } + + UnreadAlert currentUnreadAlert() const + { + UnreadAlert ua = {0, false}; + mAccount->roomModel()->getUnreadAlertFromAccount(ua.alert, ua.unread); + return ua; + } + + QString currentLoginStatusText() const + { + if (mAccount) + { + switch (mAccount->loginStatus()) + { + case DDPClient::NotConnected: + return i18n("Not connected"); + case DDPClient::LoginCodeRequired: + return i18n("Login code required"); + case DDPClient::LoginFailed: + return i18n("Login failed"); + case DDPClient::LoggingIn: + return i18n("Logging in"); + case DDPClient::LoggedIn: + return i18n("Logged in"); + case DDPClient::LoggedOut: + return i18n("Logged out"); + case DDPClient::FailedToLoginPluginProblem: + return i18n("Failed to login due to plugin problem"); + } + } + return i18n("Unknown state"); + } + + void updateTooltip() + { + setToolTip(currentLoginStatusText()); + } + + QPointer mAccount; +}; + +AccountsOverviewWidget::AccountsOverviewWidget(QWidget *parent) + : QWidget(parent) +{ + setLayout(new QHBoxLayout); + const auto model = Ruqola::self()->accountManager()->rocketChatAccountModel(); + connect(model, &RocketChatAccountModel::rowsInserted, this, &AccountsOverviewWidget::updateButtons); + connect(model, &RocketChatAccountModel::rowsRemoved, this, &AccountsOverviewWidget::updateButtons); + connect(model, &RocketChatAccountModel::modelReset, this, &AccountsOverviewWidget::updateButtons); + updateButtons(); +} + +void AccountsOverviewWidget::updateButtons() +{ + const auto model = Ruqola::self()->accountManager()->rocketChatAccountModel(); + const auto count = model->rowCount(); + for (int i = 0; i < count; ++i) + { + if (i >= mAccounts.size()) + { + mAccounts.append(new AccountButton(this)); + layout()->addWidget(mAccounts.last()); + } + mAccounts[i]->setAccount(model->account(i)); + } + for (int i = count; i < mAccounts.size(); ++i) + { + mAccounts[i]->deleteLater(); + } + mAccounts.resize(count); +} diff --git a/src/widgets/misc/accountsoverviewwidget.h b/src/widgets/misc/accountsoverviewwidget.h new file mode 100644 index 00000000..c2fce0d8 --- /dev/null +++ b/src/widgets/misc/accountsoverviewwidget.h @@ -0,0 +1,40 @@ +/* + * Copyright 2020 Olivier de Gaalon + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#pragma once + +#include +#include + +class AccountButton; + +class AccountsOverviewWidget : public QWidget +{ + Q_OBJECT +public: + explicit AccountsOverviewWidget(QWidget *parent = nullptr); + +private: + void updateButtons(); + +private: + QVector mAccounts; +}; diff --git a/src/widgets/ruqolamainwindow.cpp b/src/widgets/ruqolamainwindow.cpp index e7d08bc7..473c698d 100644 --- a/src/widgets/ruqolamainwindow.cpp +++ b/src/widgets/ruqolamainwindow.cpp @@ -1,400 +1,402 @@ /* Copyright (c) 2020 Laurent Montel This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "ruqola.h" #include "rocketchataccount.h" #include "accountmanager.h" #include "roomwrapper.h" #include "receivetypingnotificationmanager.h" #include "ruqolamainwindow.h" #include "ruqolacentralwidget.h" #include "misc/accountmenu.h" +#include "misc/accountsoverviewwidget.h" #include "dialogs/serverinfodialog.h" #include "dialogs/searchchanneldialog.h" #include "dialogs/createnewchanneldialog.h" #include "dialogs/createnewaccountdialog.h" #include "dialogs/showpinnedmessagesdialog.h" #include "dialogs/showstarredmessagesdialog.h" #include "dialogs/showmentionsmessagesdialog.h" #include "dialogs/showsnipperedmessagesdialog.h" #include "dialogs/searchmessagedialog.h" #include "dialogs/configurenotificationdialog.h" #include "dialogs/showattachmentdialog.h" #include "dialogs/showdiscussionsdialog.h" #include "dialogs/showthreadsdialog.h" #include "dialogs/channelpassworddialog.h" #include "dialogs/channelinfodialog.h" #include "dialogs/directchannelinfodialog.h" #include "dialogs/addusersinroomdialog.h" #include "configuredialog/configuresettingsdialog.h" #include #include #include #include #include #include #include #include namespace { static const char myConfigGroupName[] = "RuqolaMainWindow"; } RuqolaMainWindow::RuqolaMainWindow(QWidget *parent) : KXmlGuiWindow(parent) { mMainWidget = new RuqolaCentralWidget(this); mMainWidget->setObjectName(QStringLiteral("mMainWidget")); setCentralWidget(mMainWidget); setupActions(); setupStatusBar(); setupGUI(KXmlGuiWindow::Default, QStringLiteral(":/kxmlgui5/ruqola/ruqolaui.rc")); readConfig(); connect(Ruqola::self()->accountManager(), &AccountManager::currentAccountChanged, this, &RuqolaMainWindow::slotAccountChanged); slotAccountChanged(); } RuqolaMainWindow::~RuqolaMainWindow() { KSharedConfig::Ptr config = KSharedConfig::openConfig(); KConfigGroup group = config->group(myConfigGroupName); group.writeEntry("Size", size()); Ruqola::destroy(); } void RuqolaMainWindow::setupStatusBar() { mStatusBarTypingMessage = new QLabel(this); mStatusBarTypingMessage->setTextFormat(Qt::RichText); mStatusBarTypingMessage->setObjectName(QStringLiteral("mStatusBarTypingMessage")); statusBar()->addPermanentWidget(mStatusBarTypingMessage); + statusBar()->addPermanentWidget(new AccountsOverviewWidget(this)); } void RuqolaMainWindow::slotAccountChanged() { if (mCurrentRocketChatAccount) { disconnect(mCurrentRocketChatAccount, nullptr, this, nullptr); } mCurrentRocketChatAccount = Ruqola::self()->rocketChatAccount(); connect(mCurrentRocketChatAccount->receiveTypingNotificationManager(), &ReceiveTypingNotificationManager::notificationChanged, this, &RuqolaMainWindow::slotTypingNotificationChanged); connect(mCurrentRocketChatAccount->receiveTypingNotificationManager(), &ReceiveTypingNotificationManager::clearNotification, this, &RuqolaMainWindow::slotClearNotification); connect(mCurrentRocketChatAccount, &RocketChatAccount::missingChannelPassword, this, &RuqolaMainWindow::slotMissingChannelPassword); connect(mCurrentRocketChatAccount, &RocketChatAccount::publicSettingChanged, this, &RuqolaMainWindow::updateActions); connect(mCurrentRocketChatAccount, &RocketChatAccount::serverVersionChanged, this, &RuqolaMainWindow::updateActions); mMainWidget->setCurrentRocketChatAccount(mCurrentRocketChatAccount); updateActions(); } void RuqolaMainWindow::updateActions() { mUnreadOnTop->setChecked(mCurrentRocketChatAccount->sortUnreadOnTop()); mShowPinnedMessages->setVisible(mCurrentRocketChatAccount->hasPinnedMessagesSupport() && mCurrentRocketChatAccount->allowMessagePinningEnabled()); mShowStarredMessages->setVisible(mCurrentRocketChatAccount->hasStarredMessagesSupport() && mCurrentRocketChatAccount->allowMessageStarringEnabled()); mShowSnipperedMessages->setVisible(mCurrentRocketChatAccount->hasSnippetedMessagesSupport() && mCurrentRocketChatAccount->allowMessageSnippetingEnabled()); } void RuqolaMainWindow::readConfig() { KSharedConfig::Ptr config = KSharedConfig::openConfig(); KConfigGroup group = KConfigGroup(config, myConfigGroupName); const QSize sizeDialog = group.readEntry("Size", QSize(800, 600)); if (sizeDialog.isValid()) { resize(sizeDialog); } } void RuqolaMainWindow::slotClearNotification() { mStatusBarTypingMessage->clear(); } void RuqolaMainWindow::slotTypingNotificationChanged(const QString &roomId, const QString ¬ificationStr) { if (mMainWidget->roomId() == roomId) { mStatusBarTypingMessage->setText(notificationStr); } } void RuqolaMainWindow::setupActions() { KActionCollection *ac = actionCollection(); KStandardAction::quit(this, &RuqolaMainWindow::close, ac); KStandardAction::preferences(this, &RuqolaMainWindow::slotConfigure, ac); QAction *act = new QAction(i18n("Add Account..."), this); connect(act, &QAction::triggered, this, &RuqolaMainWindow::slotAddAccount); ac->addAction(QStringLiteral("add_account"), act); //Move in specific server widget mServerInfo = new QAction(i18n("Server Info..."), this); connect(mServerInfo, &QAction::triggered, this, &RuqolaMainWindow::slotServerInfo); ac->addAction(QStringLiteral("server_info"), mServerInfo); mLogout = new QAction(i18n("Logout"), this); connect(mLogout, &QAction::triggered, this, &RuqolaMainWindow::slotLogout); ac->addAction(QStringLiteral("logout"), mLogout); mSearchChannel = new QAction(i18n("Search Channel..."), this); connect(mSearchChannel, &QAction::triggered, this, &RuqolaMainWindow::slotSearchChannel); ac->addAction(QStringLiteral("search_channel"), mSearchChannel); mCreateNewChannel = new QAction(i18n("Create New Channel..."), this); connect(mCreateNewChannel, &QAction::triggered, this, &RuqolaMainWindow::slotCreateNewChannel); ac->addAction(QStringLiteral("create_new_channel"), mCreateNewChannel); mShowMentions = new QAction(i18n("Show Mentions..."), this); connect(mShowMentions, &QAction::triggered, this, &RuqolaMainWindow::slotShowMentions); ac->addAction(QStringLiteral("show_mentions"), mShowMentions); mShowPinnedMessages = new QAction(i18n("Show Pinned Messages..."), this); connect(mShowPinnedMessages, &QAction::triggered, this, &RuqolaMainWindow::slotPinnedMessages); ac->addAction(QStringLiteral("show_pinned_messages"), mShowPinnedMessages); mShowStarredMessages = new QAction(i18n("Show Starred Messages..."), this); connect(mShowStarredMessages, &QAction::triggered, this, &RuqolaMainWindow::slotStarredMessages); ac->addAction(QStringLiteral("show_starred_messages"), mShowStarredMessages); mShowSnipperedMessages = new QAction(i18n("Show Snippered Messages..."), this); connect(mShowSnipperedMessages, &QAction::triggered, this, &RuqolaMainWindow::slotSnipperedMessages); ac->addAction(QStringLiteral("show_snippered_messages"), mShowSnipperedMessages); mSearchMessages = new QAction(QIcon::fromTheme(QStringLiteral("edit-find")), i18n("Search Messages..."), this); connect(mSearchMessages, &QAction::triggered, this, &RuqolaMainWindow::slotSearchMessages); ac->addAction(QStringLiteral("search_messages"), mSearchMessages); mConfigureNotification = new QAction(QIcon::fromTheme(QStringLiteral("preferences-desktop-notification")), i18n("Configure Notification..."), this); connect(mConfigureNotification, &QAction::triggered, this, &RuqolaMainWindow::slotConfigureNotification); ac->addAction(QStringLiteral("configure_notification"), mConfigureNotification); mLoadChannelHistory = new QAction(i18n("Load Recent History"), this); connect(mLoadChannelHistory, &QAction::triggered, this, &RuqolaMainWindow::slotLoadRecentHistory); ac->addAction(QStringLiteral("load_recent_history"), mLoadChannelHistory); mShowFileAttachments = new QAction(i18n("Show File Attachment..."), this); connect(mShowFileAttachments, &QAction::triggered, this, &RuqolaMainWindow::slotShowFileAttachments); ac->addAction(QStringLiteral("show_file_attachments"), mShowFileAttachments); mAccountMenu = new AccountMenu(this); ac->addAction(QStringLiteral("account_menu"), mAccountMenu); mShowDiscussions = new QAction(i18n("Show Discussions..."), this); connect(mShowDiscussions, &QAction::triggered, this, &RuqolaMainWindow::slotShowDiscussions); ac->addAction(QStringLiteral("show_discussions"), mShowDiscussions); mShowThreads = new QAction(i18n("Show Threads..."), this); connect(mShowThreads, &QAction::triggered, this, &RuqolaMainWindow::slotShowThreads); ac->addAction(QStringLiteral("show_threads"), mShowThreads); mUnreadOnTop = new QAction(i18n("Unread on Top"), this); mUnreadOnTop->setCheckable(true); connect(mUnreadOnTop, &QAction::triggered, this, &RuqolaMainWindow::slotUnreadOnTop); ac->addAction(QStringLiteral("unread_on_top"), mUnreadOnTop); mChannelInfo = new QAction(i18n("Channel Info..."), this); connect(mChannelInfo, &QAction::triggered, this, &RuqolaMainWindow::slotShowChannelInfo); ac->addAction(QStringLiteral("channel_info"), mChannelInfo); mAddUserInRooms = new QAction(i18n("Add Users in Channel..."), this); connect(mAddUserInRooms, &QAction::triggered, this, &RuqolaMainWindow::slotAddUsersInRoom); ac->addAction(QStringLiteral("add_user_in_room"), mAddUserInRooms); } void RuqolaMainWindow::slotAddUsersInRoom() { QPointer dlg = new AddUsersInRoomDialog(this); if (dlg->exec()) { //TODO } delete dlg; } void RuqolaMainWindow::slotShowThreads() { QPointer dlg = new ShowThreadsDialog(this); //TODO dlg->setModel(mCurrentRocketChatAccount->filesForRoomFilterProxyModel()); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotShowDiscussions() { QPointer dlg = new ShowDiscussionsDialog(this); //TODO dlg->setModel(mCurrentRocketChatAccount->filesForRoomFilterProxyModel()); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotShowChannelInfo() { RoomWrapper *roomWrapper = mMainWidget->roomWrapper(); if (roomWrapper) { const QString roomType = mMainWidget->roomType(); if (roomType == QLatin1String("d")) { QPointer dlg = new DirectChannelInfoDialog(this); dlg->exec(); delete dlg; } else { QPointer dlg = new ChannelInfoDialog(this); dlg->setRoomWrapper(roomWrapper); dlg->exec(); delete dlg; } } } void RuqolaMainWindow::slotShowFileAttachments() { QPointer dlg = new ShowAttachmentDialog(this); const QString roomId = mMainWidget->roomId(); const QString roomType = mMainWidget->roomType(); mCurrentRocketChatAccount->roomFiles(roomId, roomType); dlg->setModel(mCurrentRocketChatAccount->filesForRoomFilterProxyModel()); dlg->setRoomId(roomId); dlg->setRoomType(roomType); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotLoadRecentHistory() { mCurrentRocketChatAccount->loadHistory(mMainWidget->roomId()); } void RuqolaMainWindow::slotConfigureNotification() { QPointer dlg = new ConfigureNotificationDialog(this); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotSearchMessages() { QPointer dlg = new SearchMessageDialog(this); dlg->setRoomId(mMainWidget->roomId()); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotStarredMessages() { QPointer dlg = new ShowStarredMessagesDialog(this); dlg->setRoomId(mMainWidget->roomId()); dlg->setModel(mCurrentRocketChatAccount->listMessagesFilterProxyModel()); mCurrentRocketChatAccount->getListMessages(mMainWidget->roomId(), ListMessagesModel::StarredMessages); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotPinnedMessages() { QPointer dlg = new ShowPinnedMessagesDialog(this); dlg->setRoomId(mMainWidget->roomId()); dlg->setModel(mCurrentRocketChatAccount->listMessagesFilterProxyModel()); mCurrentRocketChatAccount->getListMessages(mMainWidget->roomId(), ListMessagesModel::PinnedMessages); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotShowMentions() { QPointer dlg = new ShowMentionsMessagesDialog(this); dlg->setRoomId(mMainWidget->roomId()); dlg->setModel(Ruqola::self()->rocketChatAccount()->listMessagesFilterProxyModel()); Ruqola::self()->rocketChatAccount()->getListMessages(mMainWidget->roomId(), ListMessagesModel::MentionsMessages); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotSnipperedMessages() { QPointer dlg = new ShowSnipperedMessagesDialog(this); dlg->setRoomId(mMainWidget->roomId()); dlg->setModel(mCurrentRocketChatAccount->listMessagesFilterProxyModel()); mCurrentRocketChatAccount->getListMessages(mMainWidget->roomId(), ListMessagesModel::SnipperedMessages); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotCreateNewChannel() { QPointer dlg = new CreateNewChannelDialog(this); if (dlg->exec()) { const CreateNewChannelDialog::NewChannelInfo info = dlg->channelInfo(); mCurrentRocketChatAccount->createNewChannel(info.channelName, info.readOnly, info.privateChannel, info.usersName, info.encryptedRoom, info.password, info.broadCast); } delete dlg; } void RuqolaMainWindow::slotConfigure() { QPointer dlg = new ConfigureSettingsDialog(this); if (dlg->exec()) { //TODO } delete dlg; } void RuqolaMainWindow::slotAddAccount() { QPointer dlg = new CreateNewAccountDialog(this); if (dlg->exec()) { const CreateNewAccountDialog::AccountInfo info = dlg->accountInfo(); Ruqola::self()->accountManager()->addAccount(info.accountName, info.userName, info.serverName); } delete dlg; } void RuqolaMainWindow::slotServerInfo() { QPointer dlg = new ServerInfoDialog(this); dlg->setServerConfigInfo(mCurrentRocketChatAccount->serverConfigInfo()); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotLogout() { mCurrentRocketChatAccount->logOut(); } void RuqolaMainWindow::slotSearchChannel() { QPointer dlg = new SearchChannelDialog(this); dlg->exec(); delete dlg; } void RuqolaMainWindow::slotUnreadOnTop(bool checked) { mCurrentRocketChatAccount->setSortUnreadOnTop(checked); } void RuqolaMainWindow::slotMissingChannelPassword(const QString &roomId) { //TODO move in room page ? QPointer dlg = new ChannelPasswordDialog(this); //TODO add channel name! if (dlg->exec()) { mCurrentRocketChatAccount->joinRoom(roomId, dlg->password()); } delete dlg; }