void SLineEdit::contextMenuEvent(QContextMenuEvent *event) { bool selection = hasSelectedText(); bool ro = isReadOnly(); QMenu menu(this); if (selection && !ro) menu.addAction(SCHAT_ICON(EditCut), tr("Cut"), this, SLOT(cut())); if (selection) menu.addAction(SCHAT_ICON(EditCopy), tr("Copy"), this, SLOT(cut())); if (!ro && !QApplication::clipboard()->text().isEmpty()) menu.addAction(SCHAT_ICON(EditPaste), tr("Paste"), this, SLOT(paste())); if (selection && !ro) menu.addAction(SCHAT_ICON(Remove), tr("Delete"), this, SLOT(deleteSelected())); if (!menu.isEmpty()) menu.addSeparator(); if (!text().isEmpty() && text() != selectedText()) menu.addAction(SCHAT_ICON(EditSelectAll), tr("Select All"), this, SLOT(selectAll())); if (!menu.isEmpty()) menu.exec(event->globalPos()); }
ProfilePage::ProfilePage(QWidget *parent) : SettingsPage(SCHAT_ICON(Profile), LS("profile"), parent) { m_profileLabel = new QLabel(this); m_nickLabel = new QLabel(this); m_nickEdit = new NickEdit(this); m_genderLabel = new QLabel(this); m_genderField = new GenderField(this); m_layout = new ProfileLayout(this); QGridLayout *profileLay = new QGridLayout(); profileLay->addWidget(m_nickLabel, 0, 0); profileLay->addWidget(m_nickEdit, 0, 1, 1, 2); profileLay->addWidget(m_genderLabel, 1, 0); profileLay->addWidget(m_genderField, 1, 1); profileLay->addWidget(m_layout->button(), 1, 2); profileLay->setContentsMargins(10, 0, 3, 0); m_mainLayout = new QVBoxLayout(); m_mainLayout->addWidget(m_profileLabel); m_mainLayout->addLayout(profileLay); m_mainLayout->addWidget(m_layout); setupLayout(); retranslateUi(); }
SettingsTab::SettingsTab(const QUrl &url, TabWidget *parent) : AbstractTab(SETTINGS_TAB, LS(SETTINGS_TAB), parent) { m_contents = new QListWidget(this); m_contents->setSpacing(1); m_contents->setFrameShape(QFrame::NoFrame); m_pages = new QStackedWidget(this); QGridLayout *mainLay = new QGridLayout(this); mainLay->addWidget(m_contents, 0, 0); mainLay->addWidget(m_pages, 0, 1); mainLay->setMargin(0); mainLay->setSpacing(0); mainLay->setColumnStretch(0, 1); mainLay->setColumnStretch(1, 4); QMapIterator<int, SettingsPageCreator *> i(SettingsTabHook::i()->pages()); while (i.hasNext()) { i.next(); addPage(i.value()->page(this)); } m_contents->setCurrentRow(0); setIcon(SCHAT_ICON(Gear)); setText(tr("Preferences")); connect(m_contents, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(pageChanged(QListWidgetItem*,QListWidgetItem*))); openUrl(url); }
AlertsWidget::AlertsWidget(QWidget *parent) : QWidget(parent) { m_combo = new QComboBox(this); m_sound = new QCheckBox(tr("Play sound"), this); m_toolBar = new QToolBar(this); m_toolBar->setIconSize(QSize(16, 16)); m_file = new QComboBox(this); m_file->addItems(ChatAlerts::sounds()); m_toolBar->addWidget(m_file); m_control = m_toolBar->addAction(QIcon(LS(":/images/play.png")), tr("Play"), this, SLOT(play())); m_add = m_toolBar->addAction(SCHAT_ICON(Add), tr("Add sounds"), this, SLOT(add())); m_popup = new QCheckBox(tr("Show popup window"), this); m_tray = new QCheckBox(tr("Show notification in tray"), this); QGridLayout *options = new QGridLayout(); options->addWidget(m_sound, 0, 0); options->addWidget(m_toolBar, 0, 1, 2, 1, Qt::AlignTop | Qt::AlignRight); options->addWidget(m_popup, 1, 0); options->addWidget(m_tray, 2, 0, 1, 2); options->setColumnStretch(0, 1); QVBoxLayout *layout = new QVBoxLayout(this); layout->addWidget(m_combo); layout->addLayout(options); layout->setMargin(0); QList<AlertType*> types = ChatAlerts::types(); foreach (AlertType *type, types) { m_combo->addItem(type->icon(), type->name(), type->type()); }
/*! * Контекстное меню. */ void SendWidget::contextMenuEvent(QContextMenuEvent *event) { QWidget::contextMenuEvent(event); QAction *a = m_toolBar->actionAt(event->pos()); if (!a) return; QString name = a->data().toString(); if (name.isEmpty()) return; ToolBarAction action = m_names.value(name); if (!action) return; QMenu menu(this); QStringList available = this->available(); QAction *remove = 0; if (!available.isEmpty()) { QMenu *addMenu = menu.addMenu(SCHAT_ICON(Add), tr("Add")); foreach (const QString &name, available) { ToolBarAction action = m_names.value(name); if (action) { QAction *a = addMenu->addAction(action->icon(), action->title()); a->setData(name); } }
/*! * Загрузка списка серверов в виджет. */ void NetworkComboBox::load() { addItem(SCHAT_ICON(Add), tr("Add"), m_tmpId); QList<Network> items = ChatCore::networks()->items(); foreach (Network item, items) { addItem(icon(item->provider()), item->name(), item->id()); }
QAction *HistoryChatView::removeAction(const QVariant &data) { if (!m_remove) { m_remove = new QAction(SCHAT_ICON(Remove), tr("Remove message"), this); connect(m_remove, SIGNAL(triggered()), SLOT(remove())); } m_remove->setData(data); return m_remove; }
TrayIcon::TrayIcon(QObject *parent) : QSystemTrayIcon(parent) , m_alertIcon(0) { m_self = this; m_staticAlerts = ChatCore::settings()->value(LS("Labs/StaticTrayAlerts")).toBool(); m_menu = new QMenu(); m_timer = new QBasicTimer(); m_show = m_menu->addAction(SCHAT_ICON(About), tr("Show Simple Chat")); QFont font = m_show->font(); font.setBold(true); m_show->setFont(font); m_menu->addSeparator(); m_menu->addMenu(StatusMenu::i()); m_menu->addSeparator(); m_settings = m_menu->addAction(SCHAT_ICON(Gear), tr("Preferences...")); m_about = m_menu->addAction(SCHAT_ICON(About), tr("About...")); m_menu->addSeparator(); m_quit = m_menu->addAction(SCHAT_ICON(Quit), tr("Quit")); setContextMenu(m_menu); connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); connect(StatusMenu::i(), SIGNAL(updated()), SLOT(reload())); connect(m_menu, SIGNAL(triggered(QAction*)), SLOT(triggered(QAction*))); connect(ChatAlerts::i(), SIGNAL(alert(bool)), SLOT(alert(bool))); connect(ChatCore::settings(), SIGNAL(changed(QString,QVariant)), SLOT(changed(QString,QVariant))); connect(ChatAlerts::i(), SIGNAL(countChanged(int,int,QByteArray)), SLOT(reload())); reload(); QTimer::singleShot(0, this, SLOT(show())); QTimer::singleShot(1000, this, SLOT(show())); }
void SpellChecker::contextMenu(QMenu *menu, const QPoint &pos) { menu->addSeparator(); QTextCursor cursor = m_textEdit->cursorForPosition(pos); m_position = cursor.position(); cursor.select(QTextCursor::WordUnderCursor); QString word = cursor.selectedText(); if (word.isEmpty() || SpellBackend::instance()->isCorrect(word)) return; suggestionsMenu(word, menu); menu->addAction(SCHAT_ICON(Add), tr("Add to dictionary"), this, SLOT(addToPersonalDict())); }
/*! * Обновление состояния в зависимости от статуса пользователя и подключения. */ void TrayIcon::reload() { int status = ChatClient::channel()->status().value(); if (ChatClient::state() != ChatClient::Online || ChatAlerts::total()) status = -1; m_icon = SCHAT_ICON(SmallLogo); if (status != -1) m_icon = ChatIcons::icon(m_icon, ChatIcons::overlay(status)); if (ChatAlerts::total()) m_icon = AlertsPixmap::icon(m_icon, ChatAlerts::total()); if (!m_timer->isActive()) setIcon(m_icon); }
SendButton::SendButton(QWidget *parent) : QToolButton(parent) { m_history = new QMenu(this); setAutoRaise(true); setIcon(SCHAT_ICON(Send)); setPopupMode(QToolButton::MenuButtonPopup); setMenu(m_history); connect(m_history, SIGNAL(aboutToShow()), SLOT(showMenu())); connect(this, SIGNAL(clicked()), SendWidget::i()->input(), SLOT(send())); connect(SendWidget::i()->input(), SIGNAL(send(QString)), SLOT(clear())); connect(SendWidget::i()->input(), SIGNAL(reloaded()), SLOT(clear())); retranslateUi(); }
NetworkPage::NetworkPage(QWidget *parent) : SettingsPage(SCHAT_ICON(Globe), LS("network"), parent) { m_networkLabel = new QLabel(this); m_network = new NetworkWidget(this); QVBoxLayout *networkLay = new QVBoxLayout(); networkLay->addWidget(m_network); networkLay->setContentsMargins(10, 0, 3, 0); m_mainLayout = new QVBoxLayout(); m_mainLayout->addWidget(m_networkLabel); m_mainLayout->addLayout(networkLay); setupLayout(); retranslateUi(); }
AlertsPage::AlertsPage(QWidget *parent) : SettingsPage(SCHAT_ICON(Bell), LS("alerts"), parent) { m_label = new QLabel(this); m_alertsWidget = new AlertsWidget(this); QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(m_alertsWidget); layout->setContentsMargins(10, 0, 3, 0); m_mainLayout = new QVBoxLayout(); m_mainLayout->addWidget(m_label); m_mainLayout->addLayout(layout); setupLayout(); retranslateUi(); }
ListTab::ListTab(TabWidget *parent) : AbstractTab(LIST_TAB, LS(LIST_TAB), parent) { QString url = QApplication::applicationDirPath() + LS("/styles/Channels/index.html"); if (QFile::exists(url)) url = QUrl::fromLocalFile(url).toString(); else url = LS("qrc:/html/Channels/index.html"); m_view = new ChannelsView(this); m_view->setUrl(url); QVBoxLayout *mainLay = new QVBoxLayout(this); mainLay->addWidget(m_view); mainLay->setMargin(0); mainLay->setSpacing(0); setIcon(SCHAT_ICON(Channels)); retranslateUi(); }
LocalePage::LocalePage(QWidget *parent) : SettingsPage(SCHAT_ICON(Locale), LS("locale"), parent) { m_localeLabel = new QLabel(this); m_language = new LanguageField(this); m_language->setMinimumWidth(m_language->width() + 20); QHBoxLayout *languageLay = new QHBoxLayout(); languageLay->addWidget(m_language); languageLay->addStretch(); languageLay->setContentsMargins(10, 0, 3, 0); m_mainLayout = new QVBoxLayout(); m_mainLayout->addWidget(m_localeLabel); m_mainLayout->addLayout(languageLay); setupLayout(); retranslateUi(); }
/*! * Смена иконки в трее на иконку уведомления. */ void TrayIcon::startAlert() { if (m_alertIcon) return; show(); m_alertIcon = 1; if (m_staticAlerts) { if (m_timer->isActive()) m_timer->stop(); return; } setIcon(AlertsPixmap::icon(SCHAT_ICON(MessageActive), ChatAlerts::total())); if (!m_timer->isActive()) m_timer->start(666, this); }
void ChatView::contextMenu(QMenu *menu, const QWebHitTestResult &result) { menu->addSeparator(); const QUrl url = result.linkUrl(); if (url.scheme() == LS("chat") && url.host() == LS("channel")) Hooks::ChannelMenu::bind(menu, ChatUrls::channel(url), Hooks::ChatViewScope); else Hooks::ChannelMenu::bind(menu, ChatClient::channels()->get(m_id), Hooks::ChatViewScope); menu->addSeparator(); QMenu *display = menu->addMenu(SCHAT_ICON(Gear), tr("Display")); display->addAction(m_seconds); display->addAction(m_service); developerMenu(display); display->removeAction(pageAction(QWebPage::Reload)); menu->addAction(m_autoscroll); menu->addSeparator(); ClientChannel channel = ChatClient::channels()->get(id()); if (channel && channel->data().value(LS("page")) == 1) menu->addAction(m_reload); else menu->addAction(m_clear); if (!result.isContentEditable()) { menu->removeAction(pageAction(QWebPage::SelectAll)); menu->addAction(pageAction(QWebPage::SelectAll)); } menu->removeAction(pageAction(QWebPage::Reload)); menu->removeAction(pageAction(QWebPage::InspectElement)); connect(menu, SIGNAL(triggered(QAction*)), SLOT(menuTriggered(QAction*))); ChatViewHooks::contextMenu(this, menu, result); }
PluginsPage::PluginsPage(QWidget *parent) : SettingsPage(SCHAT_ICON(Plugin), LS("plugins"), parent) , m_widget(0) { m_label = new QLabel(this); m_view = new PluginsView(this); m_pluginName = new QLabel(this); m_pluginName->hide(); m_mainLayout = new QVBoxLayout(this); m_mainLayout->addWidget(m_label); m_mainLayout->addWidget(m_view); m_mainLayout->addWidget(m_pluginName); m_mainLayout->setStretch(0, 0); m_mainLayout->setStretch(1, 1); QMargins margins = m_mainLayout->contentsMargins(); margins.setBottom(0); m_mainLayout->setContentsMargins(margins); connect(m_view, SIGNAL(settings(QString)), SLOT(settings(QString))); retranslateUi(); }
QIcon SendAction::icon() const { return SCHAT_ICON(Send); }
WelcomeTab::WelcomeTab(TabWidget *parent) : AbstractTab(WELCOME_TAB, LS(WELCOME_TAB), parent) , m_languageBox(0) , m_languageLabel(0) { QWidget *widget = new QWidget(this); m_networkLabel = new QLabel(this); m_network = new NetworkWidget(this, NetworkWidget::BigButton | NetworkWidget::ExtraLayout); QGridLayout *networkLay = new QGridLayout; networkLay->addWidget(m_network, 0, 0, 1, 2); networkLay->setContentsMargins(20, 0, 3, 6); networkLay->setColumnStretch(0, 1); QGridLayout *languageLay = 0; if (!ChatCore::networks()->items().size()) { m_languageLabel = new QLabel(this); m_languageBox = new LanguageField(this); languageLay = new QGridLayout; languageLay->addWidget(m_languageBox); languageLay->setContentsMargins(20, 0, 3, 6); } m_profileLabel = new QLabel(this); m_nickLabel = new QLabel(this); m_nickEdit = new NickEdit(this); m_genderLabel = new QLabel(this); m_genderField = new GenderField(this); QGridLayout *profileLay = new QGridLayout; profileLay->addWidget(m_nickLabel, 0, 0); profileLay->addWidget(m_nickEdit, 0, 1); profileLay->addWidget(m_genderLabel, 1, 0); profileLay->addWidget(m_genderField, 1, 1); profileLay->setContentsMargins(20, 0, 3, 6); QGridLayout *mainLay = new QGridLayout(widget); mainLay->addWidget(m_networkLabel, 0, 0); if (m_languageLabel) mainLay->addWidget(m_languageLabel, 0, 1); mainLay->addLayout(networkLay, 1, 0); if (languageLay) mainLay->addLayout(languageLay, 1, 1, Qt::AlignTop); mainLay->addWidget(m_profileLabel, 2, 0); mainLay->addLayout(profileLay, 3, 0); mainLay->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 4, 0); QScrollArea *scroll = new QScrollArea(this); scroll->setWidget(widget); scroll->setWidgetResizable(true); scroll->setFrameShape(QFrame::NoFrame); QVBoxLayout *scrollLay = new QVBoxLayout(this); scrollLay->setMargin(0); scrollLay->addWidget(scroll); setIcon(SCHAT_ICON(SmallLogo)); retranslateUi(); }