CertificateDialog::CertificateDialog(QList<QSslCertificate> certificates, QWidget *parent) : Dialog(parent), m_certificates(certificates), m_ui(new Ui::CertificateDialog) { m_ui->setupUi(this); m_ui->buttonBox->button(QDialogButtonBox::Save)->setText(tr("Export…")); if (certificates.isEmpty()) { setWindowTitle(tr("Invalid Certificate")); return; } setWindowTitle(tr("View Certificate for %1").arg(certificates.first().subjectInfo(QSslCertificate::CommonName).join(QLatin1String(", ")))); QStandardItemModel *chainModel(new QStandardItemModel(this)); QStandardItem *certificateItem(nullptr); for (int i = (certificates.count() - 1); i >= 0; --i) { QStandardItem *parentCertificateItem(certificateItem); certificateItem = new QStandardItem(certificates.at(i).subjectInfo(QSslCertificate::Organization).value(0, tr("Unknown"))); certificateItem->setData(i, Qt::UserRole); if (parentCertificateItem) { parentCertificateItem->appendRow(certificateItem); } else { chainModel->appendRow(certificateItem); } } m_ui->chainItemView->setViewMode(ItemViewWidget::TreeViewMode); m_ui->chainItemView->setModel(chainModel); m_ui->chainItemView->expandAll(); m_ui->chainItemView->setCurrentIndex(chainModel->index(0, 0)); m_ui->detailsItemView->setViewMode(ItemViewWidget::TreeViewMode); m_ui->detailsItemView->setModel(new QStandardItemModel(this)); updateCertificate(); connect(m_ui->chainItemView, SIGNAL(needsActionsUpdate()), this, SLOT(updateCertificate())); connect(m_ui->detailsItemView, SIGNAL(needsActionsUpdate()), this, SLOT(updateValue())); connect(m_ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked(bool)), this, SLOT(exportCertificate())); }
KeyboardProfileDialog::KeyboardProfileDialog(const QString &profile, const QHash<QString, KeyboardProfile> &profiles, QWidget *parent) : Dialog(parent), m_profile(profile), m_isModified(profiles[profile].isModified), m_ui(new Ui::KeyboardProfileDialog) { m_ui->setupUi(this); QStandardItemModel *model(new QStandardItemModel(this)); const QVector<ActionsManager::ActionDefinition> definitions(ActionsManager::getActionDefinitions()); for (int i = 0; i < definitions.count(); ++i) { QStandardItem *item(new QStandardItem(definitions.at(i).icon, QCoreApplication::translate("actions", (definitions.at(i).description.isEmpty() ? definitions.at(i).text : definitions.at(i).description).toUtf8().constData()))); item->setData(definitions.at(i).identifier, Qt::UserRole); item->setToolTip(ActionsManager::getActionName(definitions.at(i).identifier)); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren); if (profiles[profile].shortcuts.contains(definitions.at(i).identifier)) { QStringList shortcuts; for (int j = 0; j < profiles[profile].shortcuts[definitions.at(i).identifier].count(); ++j) { shortcuts.append(profiles[profile].shortcuts[definitions.at(i).identifier].at(j).toString()); } item->setData(shortcuts.join(QLatin1Char(' ')), (Qt::UserRole + 1)); } model->appendRow(item); } model->setHorizontalHeaderLabels(QStringList({tr("Action")})); model->sort(0); m_ui->actionsViewWidget->setModel(model); m_ui->shortcutsViewWidget->setModel(new QStandardItemModel(this)); m_ui->shortcutsViewWidget->setItemDelegate(new KeyboardShortcutDelegate(this)); m_ui->titleLineEdit->setText(profiles[profile].title); m_ui->descriptionLineEdit->setText(profiles[profile].description); m_ui->versionLineEdit->setText(profiles[profile].version); m_ui->authorLineEdit->setText(profiles[profile].author); connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), m_ui->actionsViewWidget, SLOT(setFilterString(QString))); connect(m_ui->actionsViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActionsActions())); connect(m_ui->shortcutsViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateShortcutsActions())); connect(m_ui->addShortcutButton, SIGNAL(clicked()), this, SLOT(addShortcut())); connect(m_ui->removeShortcutButton, SIGNAL(clicked()), this, SLOT(removeShortcut())); }
NotesContentsWidget::NotesContentsWidget(Window *window) : ContentsWidget(window), m_ui(new Ui::NotesContentsWidget) { m_ui->setupUi(this); QMenu *addMenu(new QMenu(m_ui->addButton)); addMenu->addAction(ThemesManager::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder())); addMenu->addAction(tr("Add Note"), this, SLOT(addNote())); addMenu->addAction(tr("Add Separator"), this, SLOT(addSeparator())); m_ui->addButton->setMenu(addMenu); m_ui->notesViewWidget->setViewMode(ItemViewWidget::TreeViewMode); m_ui->notesViewWidget->setModel(NotesManager::getModel()); m_ui->notesViewWidget->setExpanded(NotesManager::getModel()->getRootItem()->index(), true); m_ui->notesViewWidget->setFilterRoles(QSet<int>({BookmarksModel::UrlRole, BookmarksModel::TitleRole, BookmarksModel::DescriptionRole, BookmarksModel::KeywordRole})); m_ui->notesViewWidget->viewport()->installEventFilter(this); m_ui->notesViewWidget->viewport()->setMouseTracking(true); m_ui->filterLineEdit->installEventFilter(this); m_ui->textEdit->setPlaceholderText(tr("Add note…")); if (!window) { m_ui->actionsWidget->hide(); } connect(NotesManager::getModel(), SIGNAL(modelReset()), this, SLOT(updateActions())); connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeNote())); connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addNote())); connect(m_ui->textEdit, SIGNAL(textChanged()), this, SLOT(updateText())); connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), m_ui->notesViewWidget, SLOT(setFilterString(QString))); connect(m_ui->notesViewWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openUrl(QModelIndex))); connect(m_ui->notesViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_ui->notesViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions())); }
void CookiesContentsWidget::populateCookies() { CookieJar *cookieJar = qobject_cast<CookieJar*>(NetworkManagerFactory::getCookieJar()); const QList<QNetworkCookie> cookies = cookieJar->getCookies(); for (int i = 0; i < cookies.count(); ++i) { addCookie(cookies.at(i)); } m_model->sort(0); m_ui->cookiesViewWidget->setViewMode(ItemViewWidget::TreeViewMode); m_ui->cookiesViewWidget->setModel(m_model); m_isLoading = false; emit loadingStateChanged(WindowsManager::FinishedLoadingState); connect(cookieJar, SIGNAL(cookieAdded(QNetworkCookie)), this, SLOT(addCookie(QNetworkCookie))); connect(cookieJar, SIGNAL(cookieRemoved(QNetworkCookie)), this, SLOT(removeCookie(QNetworkCookie))); connect(m_model, SIGNAL(modelReset()), this, SLOT(updateActions())); connect(m_ui->cookiesViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions())); }
UserAgentsManagerDialog::UserAgentsManagerDialog(QList<UserAgentInformation> userAgents, QWidget *parent) : Dialog(parent), m_ui(new Ui::UserAgentsManagerDialog) { m_ui->setupUi(this); m_ui->moveDownButton->setIcon(ThemesManager::getIcon(QLatin1String("arrow-down"))); m_ui->moveUpButton->setIcon(ThemesManager::getIcon(QLatin1String("arrow-up"))); QStandardItemModel *model(new QStandardItemModel(this)); model->setHorizontalHeaderLabels(QStringList({tr("Title"), tr("Value")})); for (int i = 0; i < userAgents.count(); ++i) { QList<QStandardItem*> items({new QStandardItem(userAgents.at(i).getTitle()), new QStandardItem(userAgents.at(i).value)}); items[0]->setData(userAgents.at(i).identifier, Qt::UserRole); items[0]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsEditable); items[1]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsEditable); model->appendRow(items); } m_ui->userAgentsView->setModel(model); connect(m_ui->userAgentsView, SIGNAL(canMoveDownChanged(bool)), m_ui->moveDownButton, SLOT(setEnabled(bool))); connect(m_ui->userAgentsView, SIGNAL(canMoveUpChanged(bool)), m_ui->moveUpButton, SLOT(setEnabled(bool))); connect(m_ui->userAgentsView, SIGNAL(needsActionsUpdate()), this, SLOT(updateUserAgentActions())); connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addUserAgent())); connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(removeUserAgent())); connect(m_ui->moveDownButton, SIGNAL(clicked()), m_ui->userAgentsView, SLOT(moveDownRow())); connect(m_ui->moveUpButton, SIGNAL(clicked()), m_ui->userAgentsView, SLOT(moveUpRow())); }
PreferencesSearchPageWidget::PreferencesSearchPageWidget(QWidget *parent) : QWidget(parent), m_defaultSearchEngine(SettingsManager::getValue(QLatin1String("Search/DefaultSearchEngine")).toString()), m_ui(new Ui::PreferencesSearchPageWidget) { m_ui->setupUi(this); QStandardItemModel *searchEnginesModel(new QStandardItemModel(this)); searchEnginesModel->setHorizontalHeaderLabels(QStringList({tr("Name"), tr("Keyword")})); const QStringList searchEngines(SearchEnginesManager::getSearchEngines()); for (int i = 0; i < searchEngines.count(); ++i) { const SearchEnginesManager::SearchEngineDefinition searchEngine(SearchEnginesManager::getSearchEngine(searchEngines.at(i))); if (searchEngine.identifier.isEmpty()) { continue; } m_searchEngines[searchEngine.identifier] = qMakePair(false, searchEngine); QList<QStandardItem*> items({new QStandardItem(searchEngine.icon, searchEngine.title), new QStandardItem(searchEngine.keyword)}); items[0]->setData(searchEngine.identifier, Qt::UserRole); items[0]->setToolTip(searchEngine.description); items[0]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDragEnabled); items[1]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsDragEnabled); searchEnginesModel->appendRow(items); } m_ui->searchViewWidget->setModel(searchEnginesModel); m_ui->searchViewWidget->setItemDelegateForColumn(1, new SearchKeywordDelegate(this)); m_ui->searchSuggestionsCheckBox->setChecked(SettingsManager::getValue(QLatin1String("Search/SearchEnginesSuggestions")).toBool()); QMenu *addSearchMenu(new QMenu(m_ui->addSearchButton)); addSearchMenu->addAction(tr("New…")); addSearchMenu->addAction(tr("Readd"))->setMenu(new QMenu(m_ui->addSearchButton)); m_ui->addSearchButton->setMenu(addSearchMenu); m_ui->moveDownSearchButton->setIcon(ThemesManager::getIcon(QLatin1String("arrow-down"))); m_ui->moveUpSearchButton->setIcon(ThemesManager::getIcon(QLatin1String("arrow-up"))); updateReaddSearchMenu(); connect(m_ui->searchFilterLineEdit, SIGNAL(textChanged(QString)), m_ui->searchViewWidget, SLOT(setFilterString(QString))); connect(m_ui->searchViewWidget, SIGNAL(canMoveDownChanged(bool)), m_ui->moveDownSearchButton, SLOT(setEnabled(bool))); connect(m_ui->searchViewWidget, SIGNAL(canMoveUpChanged(bool)), m_ui->moveUpSearchButton, SLOT(setEnabled(bool))); connect(m_ui->searchViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateSearchActions())); connect(m_ui->searchViewWidget, SIGNAL(modified()), this, SIGNAL(settingsModified())); connect(m_ui->addSearchButton->menu()->actions().at(0), SIGNAL(triggered()), this, SLOT(addSearchEngine())); connect(m_ui->addSearchButton->menu()->actions().at(1)->menu(), SIGNAL(triggered(QAction*)), this, SLOT(readdSearchEngine(QAction*))); connect(m_ui->editSearchButton, SIGNAL(clicked()), this, SLOT(editSearchEngine())); connect(m_ui->removeSearchButton, SIGNAL(clicked()), this, SLOT(removeSearchEngine())); connect(m_ui->moveDownSearchButton, SIGNAL(clicked()), m_ui->searchViewWidget, SLOT(moveDownRow())); connect(m_ui->moveUpSearchButton, SIGNAL(clicked()), m_ui->searchViewWidget, SLOT(moveUpRow())); }
void TableViewWidget::notifySelectionChanged() { if (m_model) { emit canMoveUpChanged(canMoveUp()); emit canMoveDownChanged(canMoveDown()); emit needsActionsUpdate(); } }
CookiesExceptionsDialog::CookiesExceptionsDialog(const QStringList &acceptedHosts, const QStringList &rejectedHosts, QWidget *parent) : Dialog(parent), m_ui(new Ui::CookiesExceptionsDialog) { m_ui->setupUi(this); QStandardItemModel *acceptedHostsModel(new QStandardItemModel(this)); for (int i = 0; i < acceptedHosts.count(); ++i) { if (!acceptedHosts.at(i).isEmpty()) { acceptedHostsModel->appendRow(new QStandardItem(acceptedHosts.at(i))); } } m_ui->acceptedHostsItemView->setModel(acceptedHostsModel); QStandardItemModel *rejectedHostsModel(new QStandardItemModel(this)); for (int i = 0; i < rejectedHosts.count(); ++i) { if (!rejectedHosts.at(i).isEmpty()) { rejectedHostsModel->appendRow(new QStandardItem(rejectedHosts.at(i))); } } m_ui->rejectedHostsItemView->setModel(rejectedHostsModel); updateAcceptedHostsActions(); updateRejectedHostsActions(); connect(m_ui->acceptedHostsItemView, SIGNAL(needsActionsUpdate()), this, SLOT(updateAcceptedHostsActions())); connect(m_ui->addAcceptedHostsButton, SIGNAL(clicked()), this, SLOT(addAcceptedHost())); connect(m_ui->editAcceptedHostsButton, SIGNAL(clicked()), this, SLOT(editAcceptedHost())); connect(m_ui->removeAcceptedHostsButton, SIGNAL(clicked()), this, SLOT(removeAcceptedHost())); connect(m_ui->rejectedHostsItemView, SIGNAL(needsActionsUpdate()), this, SLOT(updateRejectedHostsActions())); connect(m_ui->addRejectedHostsButton, SIGNAL(clicked()), this, SLOT(addRejectedHost())); connect(m_ui->editRejectedHostsButton, SIGNAL(clicked()), this, SLOT(editRejectedHost())); connect(m_ui->removeRejectedHostsButton, SIGNAL(clicked()), this, SLOT(removeRejectedHost())); }
void ItemViewWidget::notifySelectionChanged() { if (m_model) { m_previousIndex = m_currentIndex; m_currentIndex = getIndex(getCurrentRow()); emit canMoveUpChanged(canMoveUp()); emit canMoveDownChanged(canMoveDown()); emit needsActionsUpdate(); } }
SessionsManagerDialog::SessionsManagerDialog(QWidget *parent) : Dialog(parent), m_ui(new Ui::SessionsManagerDialog) { m_ui->setupUi(this); m_ui->openInExistingWindowCheckBox->setChecked(SettingsManager::getValue(SettingsManager::Sessions_OpenInExistingWindowOption).toBool()); const QStringList sessions(SessionsManager::getSessions()); QMultiHash<QString, SessionInformation> information; for (int i = 0; i < sessions.count(); ++i) { const SessionInformation session(SessionsManager::getSession(sessions.at(i))); information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session); } QStandardItemModel *model(new QStandardItemModel(this)); model->setHorizontalHeaderLabels(QStringList({tr("Title"), tr("Identifier"), tr("Windows")})); const QList<SessionInformation> sorted(information.values()); const QString currentSession(SessionsManager::getCurrentSession()); int row(0); for (int i = 0; i < sorted.count(); ++i) { int windows(0); for (int j = 0; j < sorted.at(i).windows.count(); ++j) { windows += sorted.at(i).windows.at(j).windows.count(); } if (sorted.at(i).path == currentSession) { row = i; } QList<QStandardItem*> items({new QStandardItem(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : sorted.at(i).title), new QStandardItem(sorted.at(i).path), new QStandardItem(tr("%n window(s) (%1)", "", sorted.at(i).windows.count()).arg(tr("%n tab(s)", "", windows)))}); items[0]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); items[1]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); items[2]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); model->appendRow(items); } m_ui->sessionsViewWidget->setModel(model); connect(m_ui->openButton, SIGNAL(clicked()), this, SLOT(openSession())); connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteSession())); connect(m_ui->sessionsViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions())); m_ui->sessionsViewWidget->setCurrentIndex(m_ui->sessionsViewWidget->getIndex(row, 0)); }
TransfersContentsWidget::TransfersContentsWidget(Window *window) : ContentsWidget(window), m_model(new QStandardItemModel(this)), m_isLoading(false), m_ui(new Ui::TransfersContentsWidget) { m_ui->setupUi(this); QStringList labels; labels << QString() << tr("Filename") << tr("Size") << tr("Progress") << tr("Time") << tr("Speed") << tr("Started") << tr("Finished"); m_model->setHorizontalHeaderLabels(labels); m_ui->transfersViewWidget->setModel(m_model); m_ui->transfersViewWidget->header()->setTextElideMode(Qt::ElideRight); m_ui->transfersViewWidget->header()->resizeSection(0, 30); m_ui->transfersViewWidget->header()->setSectionResizeMode(0, QHeaderView::Fixed); m_ui->transfersViewWidget->header()->setSectionResizeMode(1, QHeaderView::Stretch); m_ui->transfersViewWidget->setItemDelegate(new ItemDelegate(this)); m_ui->transfersViewWidget->setItemDelegateForColumn(3, new ProgressBarDelegate(this)); m_ui->transfersViewWidget->installEventFilter(this); m_ui->stopResumeButton->setIcon(Utils::getIcon(QLatin1String("task-ongoing"))); m_ui->redownloadButton->setIcon(Utils::getIcon(QLatin1String("view-refresh"))); m_ui->downloadLineEdit->installEventFilter(this); const QList<Transfer*> transfers = TransfersManager::getTransfers(); for (int i = 0; i < transfers.count(); ++i) { addTransfer(transfers.at(i)); } if (!window) { m_ui->detailsWidget->hide(); } connect(TransfersManager::getInstance(), SIGNAL(transferStarted(Transfer*)), this, SLOT(addTransfer(Transfer*))); connect(TransfersManager::getInstance(), SIGNAL(transferRemoved(Transfer*)), this, SLOT(removeTransfer(Transfer*))); connect(TransfersManager::getInstance(), SIGNAL(transferChanged(Transfer*)), this, SLOT(updateTransfer(Transfer*))); connect(m_model, SIGNAL(modelReset()), this, SLOT(updateActions())); connect(m_ui->transfersViewWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openTransfer(QModelIndex))); connect(m_ui->transfersViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_ui->transfersViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions())); connect(m_ui->downloadLineEdit, SIGNAL(returnPressed()), this, SLOT(startQuickTransfer())); connect(m_ui->stopResumeButton, SIGNAL(clicked()), this, SLOT(stopResumeTransfer())); connect(m_ui->redownloadButton, SIGNAL(clicked()), this, SLOT(redownloadTransfer())); }
ContentBlockingDialog::ContentBlockingDialog(QWidget *parent) : Dialog(parent), m_ui(new Ui::ContentBlockingDialog) { m_ui->setupUi(this); const QSettings profilesSettings(SessionsManager::getWritableDataPath(QLatin1String("contentBlocking.ini")), QSettings::IniFormat); const QStringList globalProfiles = SettingsManager::getValue(QLatin1String("Content/BlockingProfiles")).toStringList(); const QVector<ContentBlockingInformation> profiles = ContentBlockingManager::getProfiles(); QStandardItemModel *model = new QStandardItemModel(this); QStringList labels; labels << tr("Title") << tr("Update Interval") << tr("Last Update"); model->setHorizontalHeaderLabels(labels); for (int i = 0; i < profiles.count(); ++i) { QList<QStandardItem*> items; items.append(new QStandardItem(profiles.at(i).title)); items[0]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); items[0]->setData(profiles.at(i).name, Qt::UserRole); items[0]->setData(profiles.at(i).updateUrl, (Qt::UserRole + 1)); items[0]->setCheckable(true); items[0]->setCheckState(globalProfiles.contains(profiles.at(i).name) ? Qt::Checked : Qt::Unchecked); items.append(new QStandardItem(profilesSettings.value(profiles.at(i).name + QLatin1String("/updateInterval")).toString())); items[1]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); items.append(new QStandardItem(Utils::formatDateTime(profilesSettings.value(profiles.at(i).name + QLatin1String("/lastUpdate")).toDateTime()))); items[2]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); model->appendRow(items); } m_ui->profilesViewWidget->setModel(model); m_ui->profilesViewWidget->setItemDelegate(new OptionDelegate(true, this)); m_ui->profilesViewWidget->setItemDelegateForColumn(1, new ContentBlockingIntervalDelegate(this)); connect(ContentBlockingManager::getInstance(), SIGNAL(profileModified(QString)), this, SLOT(profileModified(QString))); connect(m_ui->profilesViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions())); connect(m_ui->updateButton, SIGNAL(clicked(bool)), this, SLOT(updateProfile())); connect(m_ui->confirmButtonBox, SIGNAL(accepted()), this, SLOT(save())); connect(m_ui->confirmButtonBox, SIGNAL(rejected()), this, SLOT(close())); }
BookmarksContentsWidget::BookmarksContentsWidget(Window *window) : ContentsWidget(window), m_ui(new Ui::BookmarksContentsWidget) { m_ui->setupUi(this); QMenu *addMenu(new QMenu(m_ui->addButton)); addMenu->addAction(ThemesManager::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder())); addMenu->addAction(tr("Add Bookmark"), this, SLOT(addBookmark())); addMenu->addAction(tr("Add Separator"), this, SLOT(addSeparator())); QSet<int> filterRoles; filterRoles << BookmarksModel::UrlRole << BookmarksModel::TitleRole << BookmarksModel::DescriptionRole << BookmarksModel::KeywordRole; QList<QPair<QString, int> > rolesMapping; rolesMapping << qMakePair(tr("Title"), BookmarksModel::TitleRole) << qMakePair(tr("Address"), BookmarksModel::UrlRole) << qMakePair(tr("Description"), BookmarksModel::DescriptionRole) << qMakePair(tr("Keyword"), BookmarksModel::KeywordRole) << qMakePair(tr("Added"), BookmarksModel::TimeAddedRole) << qMakePair(tr("Modified"), BookmarksModel::TimeModifiedRole) << qMakePair(tr("Visited"), BookmarksModel::TimeVisitedRole) << qMakePair(tr("Visits"), BookmarksModel::VisitsRole); ProxyModel *model(new ProxyModel(BookmarksManager::getModel(), rolesMapping, this)); m_ui->addButton->setMenu(addMenu); m_ui->bookmarksViewWidget->setViewMode(ItemViewWidget::TreeViewMode); m_ui->bookmarksViewWidget->setModel(model); m_ui->bookmarksViewWidget->setExpanded(m_ui->bookmarksViewWidget->model()->index(0, 0), true); m_ui->bookmarksViewWidget->setFilterRoles(filterRoles); m_ui->bookmarksViewWidget->installEventFilter(this); m_ui->bookmarksViewWidget->viewport()->installEventFilter(this); m_ui->bookmarksViewWidget->viewport()->setMouseTracking(true); m_ui->filterLineEdit->installEventFilter(this); if (!window) { m_ui->detailsWidget->hide(); } connect(BookmarksManager::getModel(), SIGNAL(modelReset()), this, SLOT(updateActions())); connect(m_ui->propertiesButton, SIGNAL(clicked()), this, SLOT(bookmarkProperties())); connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeBookmark())); connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addBookmark())); connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), m_ui->bookmarksViewWidget, SLOT(setFilterString(QString))); connect(m_ui->bookmarksViewWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openBookmark(QModelIndex))); connect(m_ui->bookmarksViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_ui->bookmarksViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions())); }
BookmarksContentsWidget::BookmarksContentsWidget(Window *window) : ContentsWidget(window), m_ui(new Ui::BookmarksContentsWidget) { m_ui->setupUi(this); QMenu *addMenu = new QMenu(m_ui->addButton); addMenu->addAction(Utils::getIcon(QLatin1String("inode-directory")), tr("Add Folder"), this, SLOT(addFolder())); addMenu->addAction(tr("Add Bookmark"), this, SLOT(addBookmark())); addMenu->addAction(tr("Add Separator"), this, SLOT(addSeparator())); QSet<int> filterRoles; filterRoles << BookmarksModel::UrlRole << BookmarksModel::TitleRole << BookmarksModel::DescriptionRole << BookmarksModel::KeywordRole; m_ui->addButton->setMenu(addMenu); m_ui->bookmarksViewWidget->setViewMode(ItemViewWidget::TreeViewMode); m_ui->bookmarksViewWidget->setModel(BookmarksManager::getModel()); m_ui->bookmarksViewWidget->setItemDelegate(new ItemDelegate(this)); m_ui->bookmarksViewWidget->setExpanded(BookmarksManager::getModel()->getRootItem()->index(), true); m_ui->bookmarksViewWidget->setFilterRoles(filterRoles); m_ui->bookmarksViewWidget->installEventFilter(this); m_ui->bookmarksViewWidget->viewport()->installEventFilter(this); m_ui->bookmarksViewWidget->viewport()->setMouseTracking(true); m_ui->filterLineEdit->installEventFilter(this); if (!window) { m_ui->detailsWidget->hide(); } connect(BookmarksManager::getModel(), SIGNAL(modelReset()), this, SLOT(updateActions())); connect(m_ui->propertiesButton, SIGNAL(clicked()), this, SLOT(bookmarkProperties())); connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(removeBookmark())); connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addBookmark())); connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), m_ui->bookmarksViewWidget, SLOT(setFilterString(QString))); connect(m_ui->bookmarksViewWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openBookmark(QModelIndex))); connect(m_ui->bookmarksViewWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(m_ui->bookmarksViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions())); }
UserAgentsManagerDialog::UserAgentsManagerDialog(QList<UserAgentInformation> userAgents, QWidget *parent) : QDialog(parent), m_ui(new Ui::UserAgentsManagerDialog) { m_ui->setupUi(this); m_ui->moveDownButton->setIcon(Utils::getIcon(QLatin1String("arrow-down"))); m_ui->moveUpButton->setIcon(Utils::getIcon(QLatin1String("arrow-up"))); QStringList labels; labels << tr("Title") << tr("Value"); QStandardItemModel *model = new QStandardItemModel(this); model->setHorizontalHeaderLabels(labels); for (int i = 0; i < userAgents.count(); ++i) { const QString title = userAgents.at(i).title; QList<QStandardItem*> items; items.append(new QStandardItem(title.isEmpty() ? tr("(Untitled)") : title)); items[0]->setData(userAgents.at(i).identifier, Qt::UserRole); items[0]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled); items.append(new QStandardItem(userAgents.at(i).value)); items[1]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled); model->appendRow(items); } m_ui->userAgentsView->setModel(model); m_ui->userAgentsView->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); connect(m_ui->userAgentsView, SIGNAL(canMoveDownChanged(bool)), m_ui->moveDownButton, SLOT(setEnabled(bool))); connect(m_ui->userAgentsView, SIGNAL(canMoveUpChanged(bool)), m_ui->moveUpButton, SLOT(setEnabled(bool))); connect(m_ui->userAgentsView, SIGNAL(needsActionsUpdate()), this, SLOT(updateUserAgentActions())); connect(m_ui->addButton, SIGNAL(clicked()), this, SLOT(addUserAgent())); connect(m_ui->editButton, SIGNAL(clicked()), this, SLOT(editUserAgent())); connect(m_ui->removeButton, SIGNAL(clicked()), this, SLOT(removeUserAgent())); connect(m_ui->moveDownButton, SIGNAL(clicked()), m_ui->userAgentsView, SLOT(moveDownRow())); connect(m_ui->moveUpButton, SIGNAL(clicked()), m_ui->userAgentsView, SLOT(moveUpRow())); }
ContentBlockingDialog::ContentBlockingDialog(QWidget *parent) : Dialog(parent), m_ui(new Ui::ContentBlockingDialog) { m_ui->setupUi(this); const QStringList globalProfiles(SettingsManager::getValue(SettingsManager::ContentBlocking_ProfilesOption).toStringList()); m_ui->profilesViewWidget->setModel(ContentBlockingManager::createModel(this, globalProfiles)); m_ui->profilesViewWidget->setItemDelegateForColumn(1, new ContentBlockingIntervalDelegate(this)); m_ui->profilesViewWidget->setViewMode(ItemViewWidget::TreeViewMode); m_ui->profilesViewWidget->header()->setSectionResizeMode(0, QHeaderView::Stretch); m_ui->profilesViewWidget->expandAll(); m_ui->cosmeticFiltersComboBox->addItem(tr("All"), QLatin1String("all")); m_ui->cosmeticFiltersComboBox->addItem(tr("Domain specific only"), QLatin1String("domainOnly")); m_ui->cosmeticFiltersComboBox->addItem(tr("None"), QLatin1String("none")); const int cosmeticFiltersIndex(m_ui->cosmeticFiltersComboBox->findData(SettingsManager::getValue(SettingsManager::ContentBlocking_CosmeticFiltersModeOption).toString())); m_ui->cosmeticFiltersComboBox->setCurrentIndex((cosmeticFiltersIndex < 0) ? 0 : cosmeticFiltersIndex); m_ui->enableCustomRulesCheckBox->setChecked(globalProfiles.contains(QLatin1String("custom"))); QStandardItemModel *customRulesModel(new QStandardItemModel(this)); QFile file(SessionsManager::getWritableDataPath("contentBlocking/custom.txt")); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream stream(&file); if (stream.readLine().trimmed().startsWith(QLatin1String("[Adblock Plus"), Qt::CaseInsensitive)) { while (!stream.atEnd()) { customRulesModel->appendRow(new QStandardItem(stream.readLine().trimmed())); } } else { Console::addMessage(QCoreApplication::translate("main", "Failed to load custom rules: invalid adblock header"), Console::OtherCategory, Console::ErrorLevel, file.fileName()); } file.close(); } m_ui->customRulesViewWidget->setModel(customRulesModel); m_ui->enableWildcardsCheckBox->setChecked(SettingsManager::getValue(SettingsManager::ContentBlocking_EnableWildcardsOption).toBool()); connect(ContentBlockingManager::getInstance(), SIGNAL(profileModified(QString)), this, SLOT(updateProfile(QString))); connect(m_ui->profilesViewWidget->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(updateProfilesActions())); connect(m_ui->updateProfileButton, SIGNAL(clicked(bool)), this, SLOT(updateProfile())); connect(m_ui->addProfileButton, SIGNAL(clicked(bool)), this, SLOT(addProfile())); connect(m_ui->editProfileButton, SIGNAL(clicked(bool)), this, SLOT(editProfile())); connect(m_ui->confirmButtonBox, SIGNAL(accepted()), this, SLOT(save())); connect(m_ui->confirmButtonBox, SIGNAL(rejected()), this, SLOT(close())); connect(m_ui->enableCustomRulesCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateRulesActions())); connect(m_ui->customRulesViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateRulesActions())); connect(m_ui->addRuleButton, SIGNAL(clicked(bool)), this, SLOT(addRule())); connect(m_ui->editRuleButton, SIGNAL(clicked(bool)), this, SLOT(editRule())); connect(m_ui->removeRuleButton, SIGNAL(clicked(bool)), this, SLOT(removeRule())); updateRulesActions(); }