void YourAccounts::createGui() { QVBoxLayout *mainLayout = new QVBoxLayout(this); QHBoxLayout *contentLayout = new QHBoxLayout(); mainLayout->addItem(contentLayout); AccountsView = new QListView(this); AccountsView->setMinimumWidth(150); contentLayout->addWidget(AccountsView); MyAccountsModel = m_injectedFactory->makeInjected<AccountsModel>(m_accountManager, AccountsView); auto *chain = new ModelChain{this}; auto accountProxyModel = new AccountsProxyModel(chain); chain->setBaseModel(MyAccountsModel); accountProxyModel->addFilter(new HaveProtocolFilter(accountProxyModel)); chain->addProxyModel(accountProxyModel); QAction *separator = new QAction(this); separator->setSeparator(true); AddExistingAccountAction = new QAction(m_iconsManager->iconByPath(KaduIcon("contact-new")), tr("Add existing account"), this); CreateNewAccountAction = new QAction(m_iconsManager->iconByPath(KaduIcon("system-users")), tr("Create new account"), this); ActionListModel *actionsModel = new ActionListModel(this); actionsModel->appendAction(separator); actionsModel->appendAction(AddExistingAccountAction); actionsModel->appendAction(CreateNewAccountAction); QList<QAbstractItemModel *> models; models.append(chain->lastModel()); models.append(actionsModel); ActionFilterProxyModel *proxyModel = new ActionFilterProxyModel(this); proxyModel->setSourceModel(MergedProxyModelFactory::createInstance(models, this)); proxyModel->setModel(chain->lastModel()); proxyModel->addHideWhenModelEmpty(separator); AccountsView->setModel(proxyModel); AccountsView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); AccountsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); AccountsView->setIconSize(QSize(32, 32)); connect(AccountsView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(accountSelectionChanged(const QItemSelection &, const QItemSelection &))); QDialogButtonBox *buttons = new QDialogButtonBox(Qt::Horizontal, this); mainLayout->addWidget(buttons); QPushButton *cancelButton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogCloseButton), tr("Close"), this); connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(close())); buttons->addButton(cancelButton, QDialogButtonBox::RejectRole); MainStack = new QStackedWidget(this); contentLayout->addWidget(MainStack, 100); createAccountWidget(); createEditAccountWidget(); }
void EditTalkableAction::setBuddyActionTitleAndIcon(Action *action) { const Buddy &buddy = actionBuddy(action->context()); if (buddy.isAnonymous() && 1 == action->context()->buddies().count()) { action->setIcon(KaduIcon("contact-new")); action->setText(QCoreApplication::translate("KaduWindowActions", "Add Buddy...")); } else { action->setIcon(KaduIcon("x-office-address-book")); action->setText(QCoreApplication::translate("KaduWindowActions", "View Buddy Properties")); } }
void UrlOpener::openEmail(const QByteArray &email) { QString client; bool useDefaultEMailClient = m_configuration->deprecatedApi()->readBoolEntry("Chat", "UseDefaultEMailClient", true); if (!useDefaultEMailClient) client = m_configuration->deprecatedApi()->readEntry("Chat", "MailClient"); QByteArray urlForDesktopServices; QByteArray urlForApplication; if (email.startsWith("mailto:")) { urlForDesktopServices = email; urlForApplication = email; urlForApplication.remove(0, 7); } else { urlForDesktopServices = "mailto:" + email; urlForApplication = email; } if (!openUrl(urlForDesktopServices, urlForApplication, client)) MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-error")), QCoreApplication::translate("@default", QT_TR_NOOP("Kadu")), QCoreApplication::translate("@default", QT_TR_NOOP("Could not spawn Mail client process. Check if the Mail client is functional"))); }
void HistoryMessagesTab::clearTalkableHistory() { if (!Storage) return; Q_ASSERT(TalkableTree->selectionModel()); const QModelIndexList &selectedIndexes = TalkableTree->selectionModel()->selectedIndexes(); QList<Talkable> talkables; MessageDialog *dialog = MessageDialog::create( m_iconsManager->iconByPath(KaduIcon("dialog-question")), tr("Kadu"), tr("Do you really want to delete history?")); dialog->addButton(QMessageBox::Yes, tr("Delete history")); dialog->addButton(QMessageBox::No, tr("Cancel")); if (!dialog->ask()) return; for (auto const &selectedIndex : selectedIndexes) { Talkable talkable = selectedIndex.data(TalkableRole).value<Talkable>(); if (!talkable.isEmpty()) Storage->deleteMessages(talkable); } updateData(); displayTalkable(Talkable(), true); }
KaduIcon AccountStatusContainer::statusIcon(const Status &status) { if (Account->ProtocolHandler) return Account->ProtocolHandler->statusIcon(status); else return KaduIcon(); }
LeaveChatAction::LeaveChatAction(QObject *parent) : ActionDescription(parent) { setType(ActionDescription::TypeChat); setName("leaveChatAction"); setIcon(KaduIcon("kadu_icons/block-buddy")); setText(tr("Leave")); }
void GaduEditAccountWidget::showStatusToEveryoneToggled(bool toggled) { if (toggled) return; int count = 0; const QVector<Contact> &contacts = m_contactManager->contacts(account()); foreach (const Contact &contact, contacts) if (!contact.isAnonymous() && contact.ownerBuddy().isOfflineTo()) count++; if (!count) return; MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Status Visibility"), tr("You are going to reveal your status to several buddies which are currently not allowed to see it.\n" "Are you sure to allow them to know you are available?")); dialog->addButton(QMessageBox::Yes, tr("Make my status visible anyway")); dialog->addButton(QMessageBox::No, tr("Stay with private status")); dialog->setDefaultButton(QMessageBox::No); int decision = dialog->exec(); if (decision == QMessageBox::Yes) return; ShowStatusToEveryone->setChecked(false); }
void PasswordDialogWidget::init() { QIcon icon = m_iconsManager->iconByPath(KaduIcon("dialog-password")); Pixmap = icon.pixmap(icon.actualSize(QSize(64, 64))); createGui(); }
RecentChatsAction::RecentChatsAction(QObject *parent) : ActionDescription(parent) { setType(ActionDescription::TypeMainMenu); setName("openRecentChatsAction"); setIcon(KaduIcon("internet-group-chat")); setText(tr("Recent Chats")); }
PCSpeakerNotifier::PCSpeakerNotifier(QObject *parent) : QObject{parent}, Notifier{"PC Speaker", QT_TRANSLATE_NOOP("@default", "PC Speaker"), KaduIcon("audio-volume-low")}, #if defined(Q_OS_UNIX) xdisplay{}, #endif volume{} { }
SendFileAction::SendFileAction(QObject *parent) : // using C++ initializers breaks Qt's lupdate ActionDescription(parent) { setIcon(KaduIcon(QStringLiteral("document-send"))); setName(QStringLiteral("sendFileAction")); setText(tr("Send File...")); setType(ActionDescription::TypeUser); }
TalkableDelegateConfiguration::TalkableDelegateConfiguration(TalkableTreeView *listView) : ListView(listView), AlwaysShowIdentityName(false), ShowIdentityName(true), ShowMessagePixmap(true), UseConfigurationColors(false) { Q_ASSERT(ListView); DefaultAvatarSize = QSize(32, 32); MessagePixmap = KaduIcon("protocols/common/message").icon().pixmap(16, 16); configurationUpdated(); }
void TabsManager::makePopupMenu() { kdebugf(); Menu = new QMenu(); DetachTabMenuAction = Menu->addAction(m_iconsManager->iconByPath(KaduIcon("kadu_icons/tab-detach")), tr("Detach"), this, SLOT(onMenuActionDetach())); Menu->addAction(tr("Detach all"), this, SLOT(onMenuActionDetachAll())); Menu->addSeparator(); CloseTabMenuAction = Menu->addAction(m_iconsManager->iconByPath(KaduIcon("kadu_icons/tab-close")), tr("Close"), this, SLOT(onMenuActionClose())); CloseOtherTabsMenuAction = Menu->addAction(tr("Close other tabs"), this, SLOT(onMenuActionCloseAllButActive())); CloseOtherTabsMenuAction->setEnabled(TabDialog->count() > 1); ReopenClosedTabMenuAction = Menu->addAction(tr("Reopen closed tab"), this, SLOT(reopenClosedChat())); ReopenClosedTabMenuAction->setEnabled(false); if (m_configuration->deprecatedApi()->readBoolEntry("Tabs", "OldStyleClosing")) Menu->addAction(tr("Close all"), this, SLOT(onMenuActionCloseAll())); kdebugf2(); }
SoundMuteAction::SoundMuteAction(QObject *parent) : // using C++ initializers breaks Qt's lupdate ActionDescription(parent) { setCheckable(true); setIcon(KaduIcon("audio-volume-high")); setName("muteSoundsAction"); setText(tr("Play Sounds")); setType(ActionDescription::TypeGlobal); }
void ShowHistoryAction::init() { setType(ActionDescription::TypeUser); setName("showHistoryAction"); setIcon(KaduIcon("kadu_icons/history")); setText(tr("View Chat History")); setShortcut("kadu_viewhistory"); configurationUpdated(); }
KaduIcon StatusTypeManager::statusIcon(const QString &protocol, const Status &status) { const StatusTypeData & statusTypeData = this->statusTypeData(status.type()); QString iconName = QString("protocols/%1/%2%3") .arg(protocol) .arg(statusTypeData.iconName()) .arg(status.description().isEmpty() ? QString() : QLatin1String("_d")); return KaduIcon(iconName, "16x16"); }
void UrlOpener::openUrl(const QByteArray &url) { QString browser; bool useDefaultWebBrowser = m_configuration->deprecatedApi()->readBoolEntry("Chat", "UseDefaultWebBrowser", true); if (!useDefaultWebBrowser) browser = m_configuration->deprecatedApi()->readEntry("Chat", "WebBrowser"); if (!openUrl(url, url, browser)) MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-error")), QCoreApplication::translate("@default", QT_TR_NOOP("Kadu")), QCoreApplication::translate("@default", QT_TR_NOOP("Could not spawn Web browser process. Check if the Web browser is functional"))); }
EditTalkableAction::EditTalkableAction(QObject *parent) : ActionDescription(parent) { // TODO: TypeChat | TypeUser or TypeTalkables setType(TypeGlobal); setName("editUserAction"); setIcon(KaduIcon("x-office-address-book")); setText(tr("View Buddy Properties")); registerAction(); }
void HistoryMessagesTab::showTalkablePopupMenu() { QScopedPointer<QMenu> menu(new QMenu()); MenuInventory::instance()->menu("buddy-list")->attachToMenu(menu.data()); MenuInventory::instance()->menu("buddy-list")->applyTo(menu.data(), TalkableTree->actionContext()); menu->addSeparator(); menu->addAction(KaduIcon("kadu_icons/clear-history").icon(), ClearHistoryMenuItemTitle, this, SLOT(clearTalkableHistory())); menu->exec(QCursor::pos()); }
void BuddyDeleteWindow::createGui() { QVBoxLayout *mainLayout = new QVBoxLayout(this); QWidget *topWidget = new QWidget(this); mainLayout->addWidget(topWidget); QHBoxLayout *topLayout = new QHBoxLayout(topWidget); QLabel *iconLabel = new QLabel(topWidget); iconLabel->setPixmap(m_iconsManager->iconByPath(KaduIcon("dialog-warning")).pixmap(32, 32)); topLayout->addWidget(iconLabel, 0, Qt::AlignTop); QWidget *contentWidget = new QWidget(topWidget); topLayout->addWidget(contentWidget); QVBoxLayout *contentLayout = new QVBoxLayout(contentWidget); QLabel *messageLabel = new QLabel( tr("The following buddies will be deleted:<br/>%1.<br/>Are you sure?").arg(getBuddiesNames()), contentWidget); messageLabel->setTextFormat(Qt::RichText); messageLabel->setWordWrap(true); contentLayout->addWidget(messageLabel); QLabel *additionalDataLabel = new QLabel(tr("Please select additional data that will be removed:"), contentWidget); contentLayout->addWidget(additionalDataLabel); AdditionalDataListView = new QListWidget(contentWidget); contentLayout->addWidget(AdditionalDataListView); connect( AdditionalDataListView, SIGNAL(itemPressed(QListWidgetItem *)), this, SLOT(additionalDataListViewItemPressed(QListWidgetItem *))); connect( AdditionalDataListView, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(additionalDataListViewItemClicked(QListWidgetItem *))); fillAdditionalDataListView(); QPushButton *deleteButton = new QPushButton(tr("Delete")); QPushButton *cancelButton = new QPushButton(qApp->style()->standardIcon(QStyle::SP_DialogCancelButton), tr("Cancel")); cancelButton->setDefault(true); QDialogButtonBox *buttons = new QDialogButtonBox(this); buttons->addButton(deleteButton, QDialogButtonBox::DestructiveRole); buttons->addButton(cancelButton, QDialogButtonBox::RejectRole); mainLayout->addWidget(buttons); connect(deleteButton, SIGNAL(clicked(bool)), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked(bool)), this, SLOT(reject())); }
void HistoryMessagesTab::createGui() { TimelinePopupMenu = new QMenu(this); TimelinePopupMenu->addAction(KaduIcon("kadu_icons/clear-history").icon(), tr("&Remove entries"), this, SLOT(removeEntries())); QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(2); Splitter = new QSplitter(Qt::Horizontal, this); FilteredView = new FilteredTreeView(FilteredTreeView::FilterAtTop, Splitter); FilteredView->filterWidget()->setAutoVisibility(false); FilteredView->filterWidget()->setLabel(tr("Filter") + ":"); TalkableTree = new TalkableTreeView(FilteredView); TalkableTree->setAlternatingRowColors(true); TalkableTree->setContextMenuEnabled(true); TalkableTree->setContextMenuPolicy(Qt::CustomContextMenu); TalkableTree->setUseConfigurationColors(true); TalkableTree->delegateConfiguration().setShowMessagePixmap(false); QString style; style.append("QTreeView::branch:has-siblings:!adjoins-item { border-image: none; image: none }"); style.append("QTreeView::branch:has-siblings:adjoins-item { border-image: none; image: none }"); style.append("QTreeView::branch:has-childres:!has-siblings:adjoins-item { border-image: none; image: none }"); TalkableTree->setStyleSheet(style); TalkableTree->viewport()->setStyleSheet(style); connect(TalkableTree, SIGNAL(currentChanged(Talkable)), this, SLOT(currentTalkableChanged(Talkable))); connect(TalkableTree, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showTalkablePopupMenu())); FilteredView->setView(TalkableTree); TimelineView = new TimelineChatMessagesView(Splitter); TimelineView->searchBar()->setAutoVisibility(false); TimelineView->searchBar()->setSearchWidget(this); TimelineView->timeline()->setContextMenuPolicy(Qt::CustomContextMenu); connect(TimelineView->timeline(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showTimelinePopupMenu())); connect(timelineView(), SIGNAL(currentDateChanged()), this, SLOT(currentDateChanged())); QList<int> sizes; sizes.append(150); sizes.append(300); Splitter->setSizes(sizes); layout->addWidget(Splitter); setFocusProxy(FilteredView->filterWidget()); }
void HistoryWindow::init() { setWindowRole("kadu-history"); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("History")); setWindowIcon(m_iconsManager->iconByPath(KaduIcon("kadu_icons/history"))); createGui(); new WindowGeometryManager(new ConfigFileVariantWrapper(m_configuration, "History", "HistoryWindowGeometry"), QRect(200, 200, 750, 500), this); connect(m_history, SIGNAL(storageChanged(HistoryStorage*)), this, SLOT(storageChanged(HistoryStorage*))); }
QString FileTransferManager::getSaveFileName(QString fileName, QString remoteFileName, QWidget *parent) { auto haveFileName = !fileName.isEmpty(); // auto resumeTransfer = haveFileName; while (true) { if (fileName.isEmpty()) fileName = QFileDialog::getSaveFileName(parent, tr("Select file location"), m_configuration->deprecatedApi()->readEntry(QStringLiteral("Network"), QStringLiteral("LastDownloadDirectory")) + remoteFileName, QString(), 0, QFileDialog::DontConfirmOverwrite); if (fileName.isEmpty()) return fileName; m_configuration->deprecatedApi()->writeEntry(QStringLiteral("Network"), QStringLiteral("LastDownloadDirectory"), QFileInfo(fileName).absolutePath() + '/'); auto info = QFileInfo{fileName}; if (!haveFileName && info.exists()) { auto question = tr("File %1 already exists.").arg(fileName); switch (QMessageBox::question(parent, tr("Save file"), question, tr("Overwrite"), //tr("Resume"), tr("Select another file"), 0, 2)) { case 0: //resumeTransfer = false; break; case 1: //resumeTransfer = true; //break; //case 2: fileName = QString{}; haveFileName = false; continue; } } if (info.exists() && !info.isWritable()) { MessageDialog::show(m_iconsManager->iconByPath(KaduIcon(QStringLiteral("dialog-warning"))), tr("Kadu"), tr("Could not open file. Select another one.")); fileName.clear(); continue; } return fileName; } }
void FacebookDepreceatedMessage::showIfNotSeen() { auto depreceatedMessageSeen = m_configuration->deprecatedApi()->readBoolEntry("JabberProtocol", "FacebookDepreceatedMessageSeen", false); if (depreceatedMessageSeen) return; m_configuration->deprecatedApi()->writeEntry("JabberProtocol", "FacebookDepreceatedMessageSeen", true); auto message = tr( "Facebook XMPP support is disabled since 01.05.2015. This means Kadu will be no longer able to connect to " "Facebook accounts. You can leave your Facebook accounts configured for chat history or you can remove them from " "Kadu using Your Account dialog" ); MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-information")), tr("Kadu - Facebook"), message); }
void PluginListWidgetItemDelegate::slotAboutClicked() { auto const index = focusedIndex(); auto const model = index.model(); auto info = QString{}; info += tr("Plugin name: %1").arg(model->data(index, PluginModel::NameRole).toString()) + "\n"; auto pluginMetadata = model->data(index, PluginModel::MetadataRole).value<PluginMetadata>(); info += tr("Author: %1").arg(pluginMetadata.author()) + "\n"; info += tr("Version: %1").arg(pluginMetadata.version()) + "\n"; info += tr("Description: %1").arg(pluginMetadata.description()) + "\n"; info += tr("Dependencies: %1").arg(pluginMetadata.dependencies().join(", ")) + "\n"; info += tr("Provides: %1").arg(pluginMetadata.provides()); MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-information")), tr("Plugin information"), info, QMessageBox::Ok, itemView()); }
void GaduEditAccountWidget::removeAccount() { MessageDialog *dialog = MessageDialog::create(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Confrim Account Removal"), tr("Are you sure do you want to remove account %1 (%2)?") .arg(account().accountIdentity().name()) .arg(account().id())); dialog->addButton(QMessageBox::Yes, tr("Remove account")); dialog->addButton(QMessageBox::Cancel, tr("Cancel")); dialog->setDefaultButton(QMessageBox::Cancel); int decision = dialog->exec(); if (decision == QMessageBox::Yes) { m_accountManager->removeAccountAndBuddies(account()); deleteLater(); } }
ConnectionErrorNotification::ConnectionErrorNotification(Account account, const QString &errorServer, const QString &errorMessage) : Notification(account, Chat::null, "ConnectionError", KaduIcon("dialog-error")), ErrorServer(errorServer), ErrorMessage(errorMessage) { setTitle(tr("Connection error")); setText(Qt::escape(tr("Connection error on account: %1 (%2)").arg(account.id()).arg(account.accountIdentity().name()))); if (!ErrorMessage.isEmpty()) { if (ErrorServer.isEmpty()) setDetails(Qt::escape(ErrorMessage)); else setDetails(Qt::escape(QString("%1 (%2)").arg(ErrorMessage).arg(ErrorServer))); } addCallback("connection-ignore-errors"); }
HistoryWindow::HistoryWindow(History *history, QWidget *parent) : QWidget(parent), m_history{history}, CurrentTab(-1) { setWindowRole("kadu-history"); setAttribute(Qt::WA_DeleteOnClose); setWindowTitle(tr("History")); setWindowIcon(KaduIcon("kadu_icons/history").icon()); createGui(); new WindowGeometryManager(new ConfigFileVariantWrapper("History", "HistoryWindowGeometry"), QRect(200, 200, 750, 500), this); connect(m_history, SIGNAL(storageChanged(HistoryStorage*)), this, SLOT(storageChanged(HistoryStorage*))); }
void StatusWindow::clearDescriptionsHistory() { MessageDialog *dialog = MessageDialog::create( m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Clear Descriptions History"), tr("Do you really want to clear the descriptions history?"), this); dialog->addButton(QMessageBox::Yes, tr("Clear history")); dialog->addButton(QMessageBox::No, tr("Cancel")); if (!dialog->ask()) return; m_descriptionManager->clearDescriptions(); DescriptionSelect->setModel(m_descriptionManager->model()); DescriptionSelect->setCurrentIndex(-1); DescriptionSelect->setEnabled(false); ClearDescriptionsHistoryButton->setEnabled(false); }
void SmsDialog::sendSms() { kdebugf(); SmsSender *sender; if (m_configuration->deprecatedApi()->readBoolEntry("SMS", "BuiltInApp")) { int gatewayIndex = ProviderComboBox->currentIndex(); QString gatewayId = ProviderComboBox->itemData(gatewayIndex, Qt::UserRole).toString(); sender = m_pluginInjectedFactory->makeInjected<SmsInternalSender>(m_smsGatewayManager, m_smsScriptsManager, RecipientEdit->text(), m_smsGatewayManager->byId(gatewayId), this); } else { if (m_configuration->deprecatedApi()->readEntry("SMS", "SmsApp").isEmpty()) { MessageDialog::show(m_iconsManager->iconByPath(KaduIcon("dialog-warning")), tr("Kadu"), tr("SMS application was not specified. Visit the configuration section"), QMessageBox::Ok, this); kdebugm(KDEBUG_WARNING, "SMS application NOT specified. Exit.\n"); return; } sender = m_pluginInjectedFactory->makeInjected<SmsExternalSender>(RecipientEdit->text(), this); } connect(sender, SIGNAL(gatewayAssigned(QString, QString)), this, SLOT(gatewayAssigned(QString, QString))); sender->setSignature(SignatureEdit->text()); auto window = m_pluginInjectedFactory->makeInjected<ProgressWindow>(tr("Sending SMS...")); window->setCancellable(true); window->show(); connect(window, SIGNAL(canceled()), sender, SLOT(cancel())); connect(sender, SIGNAL(canceled()), window, SLOT(reject())); connect(sender, SIGNAL(progress(QString,QString)), window, SLOT(addProgressEntry(QString,QString))); connect(sender, SIGNAL(finished(bool,QString,QString)), window, SLOT(progressFinished(bool,QString,QString))); if (SaveInHistoryCheckBox->isChecked()) connect(sender, SIGNAL(smsSent(QString,QString)), this, SLOT(saveSmsInHistory(QString,QString))); sender->sendMessage(ContentEdit->toPlainText()); kdebugf2(); }