Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/ruqolamainwindow.cpp
Show All 23 Lines | |||||
24 | #include "ruqola.h" | 24 | #include "ruqola.h" | ||
25 | #include "rocketchataccount.h" | 25 | #include "rocketchataccount.h" | ||
26 | #include "accountmanager.h" | 26 | #include "accountmanager.h" | ||
27 | #include "roomwrapper.h" | 27 | #include "roomwrapper.h" | ||
28 | #include "ruqolaserverconfig.h" | 28 | #include "ruqolaserverconfig.h" | ||
29 | #include "receivetypingnotificationmanager.h" | 29 | #include "receivetypingnotificationmanager.h" | ||
30 | #include "ruqolacentralwidget.h" | 30 | #include "ruqolacentralwidget.h" | ||
31 | #include "misc/accountmenu.h" | 31 | #include "misc/accountmenu.h" | ||
32 | #include "misc/accountsoverviewwidget.h" | | |||
33 | #include "dialogs/serverinfodialog.h" | 32 | #include "dialogs/serverinfodialog.h" | ||
34 | #include "dialogs/searchchanneldialog.h" | 33 | #include "dialogs/searchchanneldialog.h" | ||
35 | #include "dialogs/createnewchanneldialog.h" | 34 | #include "dialogs/createnewchanneldialog.h" | ||
36 | #include "dialogs/createnewaccountdialog.h" | 35 | #include "dialogs/createnewaccountdialog.h" | ||
37 | #include "dialogs/channelpassworddialog.h" | 36 | #include "dialogs/channelpassworddialog.h" | ||
38 | #include "configuredialog/configuresettingsdialog.h" | 37 | #include "configuredialog/configuresettingsdialog.h" | ||
39 | #include <KActionCollection> | 38 | #include <KActionCollection> | ||
40 | #include <KConfigGroup> | 39 | #include <KConfigGroup> | ||
Show All 25 Lines | 60 | { | |||
66 | }); | 65 | }); | ||
67 | connect(mMainWidget, &RuqolaCentralWidget::loginPageActivated, this, &RuqolaMainWindow::slotLoginPageActivated); | 66 | connect(mMainWidget, &RuqolaCentralWidget::loginPageActivated, this, &RuqolaMainWindow::slotLoginPageActivated); | ||
68 | setCentralWidget(mMainWidget); | 67 | setCentralWidget(mMainWidget); | ||
69 | setupActions(); | 68 | setupActions(); | ||
70 | setupStatusBar(); | 69 | setupStatusBar(); | ||
71 | setupGUI(/*QStringLiteral(":/kxmlgui5/ruqola/ruqolaui.rc")*/); | 70 | setupGUI(/*QStringLiteral(":/kxmlgui5/ruqola/ruqolaui.rc")*/); | ||
72 | readConfig(); | 71 | readConfig(); | ||
73 | connect(Ruqola::self()->accountManager(), &AccountManager::currentAccountChanged, this, &RuqolaMainWindow::slotAccountChanged); | 72 | connect(Ruqola::self()->accountManager(), &AccountManager::currentAccountChanged, this, &RuqolaMainWindow::slotAccountChanged); | ||
74 | slotAccountChanged(); | 73 | slotAccountChanged(false /*showLastRoom*/); | ||
75 | #if HAVE_KUSERFEEDBACK | 74 | #if HAVE_KUSERFEEDBACK | ||
76 | KUserFeedback::NotificationPopup *userFeedBackNotificationPopup = new KUserFeedback::NotificationPopup(this); | 75 | KUserFeedback::NotificationPopup *userFeedBackNotificationPopup = new KUserFeedback::NotificationPopup(this); | ||
77 | userFeedBackNotificationPopup->setFeedbackProvider(UserFeedBackManager::self()->userFeedbackProvider()); | 76 | userFeedBackNotificationPopup->setFeedbackProvider(UserFeedBackManager::self()->userFeedbackProvider()); | ||
78 | #endif | 77 | #endif | ||
79 | } | 78 | } | ||
80 | 79 | | |||
81 | RuqolaMainWindow::~RuqolaMainWindow() | 80 | RuqolaMainWindow::~RuqolaMainWindow() | ||
82 | { | 81 | { | ||
83 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | 82 | KSharedConfig::Ptr config = KSharedConfig::openConfig(); | ||
84 | KConfigGroup group = config->group(myConfigGroupName); | 83 | KConfigGroup group = config->group(myConfigGroupName); | ||
85 | group.writeEntry("Size", size()); | 84 | group.writeEntry("Size", size()); | ||
86 | 85 | | |||
87 | delete mMainWidget; // before Ruqola::destroy() | 86 | delete mMainWidget; // before Ruqola::destroy() | ||
88 | 87 | | |||
89 | Ruqola::destroy(); | 88 | Ruqola::destroy(); | ||
90 | } | 89 | } | ||
91 | 90 | | |||
92 | void RuqolaMainWindow::setupStatusBar() | 91 | void RuqolaMainWindow::setupStatusBar() | ||
93 | { | 92 | { | ||
94 | mStatusBarTypingMessage = new QLabel(this); | 93 | mStatusBarTypingMessage = new QLabel(this); | ||
95 | mStatusBarTypingMessage->setTextFormat(Qt::RichText); | 94 | mStatusBarTypingMessage->setTextFormat(Qt::RichText); | ||
96 | mStatusBarTypingMessage->setObjectName(QStringLiteral("mStatusBarTypingMessage")); | 95 | mStatusBarTypingMessage->setObjectName(QStringLiteral("mStatusBarTypingMessage")); | ||
97 | statusBar()->addPermanentWidget(mStatusBarTypingMessage); | 96 | statusBar()->addPermanentWidget(mStatusBarTypingMessage); | ||
98 | mAccountOverviewWidget = new AccountsOverviewWidget(this); | | |||
99 | statusBar()->addPermanentWidget(mAccountOverviewWidget); | | |||
100 | } | 97 | } | ||
101 | 98 | | |||
102 | void RuqolaMainWindow::slotAccountChanged() | 99 | void RuqolaMainWindow::slotAccountChanged(bool showLastRoom) | ||
103 | { | 100 | { | ||
104 | if (mCurrentRocketChatAccount) { | 101 | if (mCurrentRocketChatAccount) { | ||
105 | disconnect(mCurrentRocketChatAccount, nullptr, this, nullptr); | 102 | disconnect(mCurrentRocketChatAccount, nullptr, this, nullptr); | ||
106 | } | 103 | } | ||
107 | mCurrentRocketChatAccount = Ruqola::self()->rocketChatAccount(); | 104 | mCurrentRocketChatAccount = Ruqola::self()->rocketChatAccount(); | ||
108 | connect(mCurrentRocketChatAccount->receiveTypingNotificationManager(), &ReceiveTypingNotificationManager::notificationChanged, this, &RuqolaMainWindow::slotTypingNotificationChanged); | 105 | connect(mCurrentRocketChatAccount->receiveTypingNotificationManager(), &ReceiveTypingNotificationManager::notificationChanged, this, &RuqolaMainWindow::slotTypingNotificationChanged); | ||
109 | connect(mCurrentRocketChatAccount->receiveTypingNotificationManager(), &ReceiveTypingNotificationManager::clearNotification, this, &RuqolaMainWindow::slotClearNotification); | 106 | connect(mCurrentRocketChatAccount->receiveTypingNotificationManager(), &ReceiveTypingNotificationManager::clearNotification, this, &RuqolaMainWindow::slotClearNotification); | ||
110 | connect(mCurrentRocketChatAccount, &RocketChatAccount::missingChannelPassword, this, &RuqolaMainWindow::slotMissingChannelPassword); | 107 | connect(mCurrentRocketChatAccount, &RocketChatAccount::missingChannelPassword, this, &RuqolaMainWindow::slotMissingChannelPassword); | ||
111 | connect(mCurrentRocketChatAccount, &RocketChatAccount::publicSettingChanged, this, &RuqolaMainWindow::updateActions); | 108 | connect(mCurrentRocketChatAccount, &RocketChatAccount::publicSettingChanged, this, &RuqolaMainWindow::updateActions); | ||
112 | connect(mCurrentRocketChatAccount, &RocketChatAccount::serverVersionChanged, this, &RuqolaMainWindow::updateActions); | 109 | connect(mCurrentRocketChatAccount, &RocketChatAccount::serverVersionChanged, this, &RuqolaMainWindow::updateActions); | ||
113 | connect(mCurrentRocketChatAccount, &RocketChatAccount::raiseWindow, this, &RuqolaMainWindow::slotRaiseWindow); | 110 | connect(mCurrentRocketChatAccount, &RocketChatAccount::raiseWindow, this, &RuqolaMainWindow::slotRaiseWindow); | ||
114 | 111 | | |||
115 | updateActions(); | 112 | updateActions(); | ||
116 | changeActionStatus(false); //Disable actions when switching. | 113 | changeActionStatus(false); //Disable actions when switching. | ||
117 | slotClearNotification(); //Clear notification when we switch too. | 114 | slotClearNotification(); //Clear notification when we switch too. | ||
118 | mMainWidget->setCurrentRocketChatAccount(mCurrentRocketChatAccount); | 115 | mMainWidget->setCurrentRocketChatAccount(mCurrentRocketChatAccount, showLastRoom); | ||
119 | } | 116 | } | ||
120 | 117 | | |||
121 | void RuqolaMainWindow::slotRaiseWindow() | 118 | void RuqolaMainWindow::slotRaiseWindow() | ||
122 | { | 119 | { | ||
123 | show(); | 120 | show(); | ||
124 | raise(); | 121 | raise(); | ||
125 | activateWindow(); | 122 | activateWindow(); | ||
126 | } | 123 | } | ||
▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | 221 | if (dlg->exec()) { | |||
227 | mCurrentRocketChatAccount->createNewChannel(info.channelName, info.readOnly, info.privateChannel, info.usersName.join(QLatin1Char(',')), info.encryptedRoom, info.password, info.broadCast); | 224 | mCurrentRocketChatAccount->createNewChannel(info.channelName, info.readOnly, info.privateChannel, info.usersName.join(QLatin1Char(',')), info.encryptedRoom, info.password, info.broadCast); | ||
228 | } | 225 | } | ||
229 | delete dlg; | 226 | delete dlg; | ||
230 | } | 227 | } | ||
231 | 228 | | |||
232 | void RuqolaMainWindow::slotConfigure() | 229 | void RuqolaMainWindow::slotConfigure() | ||
233 | { | 230 | { | ||
234 | QPointer<ConfigureSettingsDialog> dlg = new ConfigureSettingsDialog(this); | 231 | QPointer<ConfigureSettingsDialog> dlg = new ConfigureSettingsDialog(this); | ||
235 | if (dlg->exec()) { | 232 | dlg->exec(); | ||
236 | mAccountOverviewWidget->updateButtons(); | | |||
237 | } | | |||
238 | delete dlg; | 233 | delete dlg; | ||
239 | } | 234 | } | ||
240 | 235 | | |||
241 | void RuqolaMainWindow::slotAddAccount() | 236 | void RuqolaMainWindow::slotAddAccount() | ||
242 | { | 237 | { | ||
243 | QPointer<CreateNewAccountDialog> dlg = new CreateNewAccountDialog(this); | 238 | QPointer<CreateNewAccountDialog> dlg = new CreateNewAccountDialog(this); | ||
244 | const QStringList lst = Ruqola::self()->accountManager()->accountsName(); | 239 | const QStringList lst = Ruqola::self()->accountManager()->accountsName(); | ||
245 | dlg->setExistingAccountName(lst); | 240 | dlg->setExistingAccountName(lst); | ||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |