Changeset View
Changeset View
Standalone View
Standalone View
src/kcms/kio/useragentdlg.cpp
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 56 | : KCModule (parent), | |||
---|---|---|---|---|---|
57 | m_userAgentInfo (nullptr), | 57 | m_userAgentInfo (nullptr), | ||
58 | m_config (nullptr) | 58 | m_config (nullptr) | ||
59 | { | 59 | { | ||
60 | ui.setupUi (this); | 60 | ui.setupUi (this); | ||
61 | ui.newButton->setIcon (QIcon::fromTheme(QStringLiteral("list-add"))); | 61 | ui.newButton->setIcon (QIcon::fromTheme(QStringLiteral("list-add"))); | ||
62 | ui.changeButton->setIcon (QIcon::fromTheme(QStringLiteral("edit-rename"))); | 62 | ui.changeButton->setIcon (QIcon::fromTheme(QStringLiteral("edit-rename"))); | ||
63 | ui.deleteButton->setIcon (QIcon::fromTheme(QStringLiteral("list-remove"))); | 63 | ui.deleteButton->setIcon (QIcon::fromTheme(QStringLiteral("list-remove"))); | ||
64 | ui.deleteAllButton->setIcon (QIcon::fromTheme(QStringLiteral("edit-delete"))); | 64 | ui.deleteAllButton->setIcon (QIcon::fromTheme(QStringLiteral("edit-delete"))); | ||
65 | | ||||
66 | connect(ui.newButton, &QAbstractButton::clicked, this, &UserAgentDlg::newSitePolicy); | ||||
67 | connect(ui.changeButton, &QAbstractButton::clicked, | ||||
68 | this, [this]() { changeSitePolicy(ui.sitePolicyTreeWidget->currentItem()); }); | ||||
69 | connect(ui.deleteButton, &QAbstractButton::clicked, this, &UserAgentDlg::deleteSitePolicies); | ||||
70 | connect(ui.deleteAllButton, &QAbstractButton::clicked, this, &UserAgentDlg::deleteAllSitePolicies); | ||||
71 | | ||||
72 | connect(ui.sendUACheckBox, &QAbstractButton::clicked, this, [this]() { configChanged(); }); | ||||
73 | connect(ui.osNameCheckBox, &QAbstractButton::clicked, this, [this]() { changeDefaultUAModifiers(); }); | ||||
74 | connect(ui.osVersionCheckBox, &QAbstractButton::clicked, this, [this]() { changeDefaultUAModifiers(); }); | ||||
75 | connect(ui.processorTypeCheckBox, &QAbstractButton::clicked, this, [this]() { changeDefaultUAModifiers(); }); | ||||
76 | connect(ui.languageCheckBox, &QAbstractButton::clicked, this, [this]() { changeDefaultUAModifiers(); }); | ||||
77 | | ||||
78 | connect(ui.sitePolicyTreeWidget, &QTreeWidget::itemSelectionChanged, this, &UserAgentDlg::updateButtons); | ||||
79 | connect(ui.sitePolicyTreeWidget, &QTreeWidget::itemDoubleClicked, this, &UserAgentDlg::changeSitePolicy); | ||||
65 | } | 80 | } | ||
66 | 81 | | |||
67 | UserAgentDlg::~UserAgentDlg() | 82 | UserAgentDlg::~UserAgentDlg() | ||
68 | { | 83 | { | ||
69 | delete m_userAgentInfo; | 84 | delete m_userAgentInfo; | ||
70 | delete m_config; | 85 | delete m_config; | ||
71 | } | 86 | } | ||
72 | 87 | | |||
73 | void UserAgentDlg::on_sendUACheckBox_clicked() | 88 | void UserAgentDlg::newSitePolicy() | ||
74 | { | | |||
75 | configChanged(); | | |||
76 | } | | |||
77 | | ||||
78 | void UserAgentDlg::on_newButton_clicked() | | |||
79 | { | 89 | { | ||
80 | const QPointer<UserAgentSelectorDlg> pdlg (new UserAgentSelectorDlg (m_userAgentInfo, this)); | 90 | const QPointer<UserAgentSelectorDlg> pdlg (new UserAgentSelectorDlg (m_userAgentInfo, this)); | ||
81 | pdlg->setWindowTitle(i18nc ("@title:window", "Add Identification")); | 91 | pdlg->setWindowTitle(i18nc ("@title:window", "Add Identification")); | ||
82 | 92 | | |||
83 | if (pdlg->exec() == QDialog::Accepted && pdlg) { | 93 | if (pdlg->exec() == QDialog::Accepted && pdlg) { | ||
84 | if (!handleDuplicate (pdlg->siteName(), pdlg->identity(), pdlg->alias())) { | 94 | if (!handleDuplicate (pdlg->siteName(), pdlg->identity(), pdlg->alias())) { | ||
85 | QTreeWidgetItem* item = new QTreeWidgetItem (ui.sitePolicyTreeWidget); | 95 | QTreeWidgetItem* item = new QTreeWidgetItem (ui.sitePolicyTreeWidget); | ||
86 | item->setText (0, pdlg->siteName()); | 96 | item->setText (0, pdlg->siteName()); | ||
87 | item->setText (1, pdlg->identity()); | 97 | item->setText (1, pdlg->identity()); | ||
88 | item->setText (2, pdlg->alias()); | 98 | item->setText (2, pdlg->alias()); | ||
89 | ui.sitePolicyTreeWidget->setCurrentItem (item); | 99 | ui.sitePolicyTreeWidget->setCurrentItem (item); | ||
90 | configChanged(); | 100 | configChanged(); | ||
91 | } | 101 | } | ||
92 | } | 102 | } | ||
93 | delete pdlg; | 103 | delete pdlg; | ||
94 | } | 104 | } | ||
95 | 105 | | |||
96 | void UserAgentDlg::on_changeButton_clicked() | 106 | void UserAgentDlg::deleteSitePolicies() | ||
97 | { | | |||
98 | on_sitePolicyTreeWidget_itemDoubleClicked (ui.sitePolicyTreeWidget->currentItem(), -1); | | |||
99 | } | | |||
100 | | ||||
101 | void UserAgentDlg::on_deleteButton_clicked() | | |||
102 | { | 107 | { | ||
103 | SiteList selectedItems = ui.sitePolicyTreeWidget->selectedItems(); | 108 | SiteList selectedItems = ui.sitePolicyTreeWidget->selectedItems(); | ||
104 | SiteListIterator endIt = selectedItems.end(); | 109 | SiteListIterator endIt = selectedItems.end(); | ||
105 | 110 | | |||
106 | for (SiteListIterator it = selectedItems.begin(); it != endIt; ++it) | 111 | for (SiteListIterator it = selectedItems.begin(); it != endIt; ++it) | ||
107 | delete (*it); | 112 | delete (*it); | ||
108 | 113 | | |||
109 | updateButtons(); | 114 | updateButtons(); | ||
110 | configChanged(); | 115 | configChanged(); | ||
111 | } | 116 | } | ||
112 | 117 | | |||
113 | void UserAgentDlg::on_deleteAllButton_clicked() | 118 | void UserAgentDlg::deleteAllSitePolicies() | ||
114 | { | 119 | { | ||
115 | ui.sitePolicyTreeWidget->clear(); | 120 | ui.sitePolicyTreeWidget->clear(); | ||
116 | updateButtons(); | 121 | updateButtons(); | ||
117 | configChanged(); | 122 | configChanged(); | ||
118 | } | 123 | } | ||
119 | 124 | | |||
120 | void UserAgentDlg::on_osNameCheckBox_clicked() | 125 | void UserAgentDlg::changeSitePolicy(QTreeWidgetItem* item) | ||
121 | { | | |||
122 | changeDefaultUAModifiers(); | | |||
123 | } | | |||
124 | | ||||
125 | void UserAgentDlg::on_osVersionCheckBox_clicked() | | |||
126 | { | | |||
127 | changeDefaultUAModifiers(); | | |||
128 | } | | |||
129 | | ||||
130 | void UserAgentDlg::on_processorTypeCheckBox_clicked() | | |||
131 | { | | |||
132 | changeDefaultUAModifiers(); | | |||
133 | } | | |||
134 | | ||||
135 | void UserAgentDlg::on_languageCheckBox_clicked() | | |||
136 | { | | |||
137 | changeDefaultUAModifiers(); | | |||
138 | } | | |||
139 | | ||||
140 | void UserAgentDlg::on_sitePolicyTreeWidget_itemDoubleClicked (QTreeWidgetItem* item, int) | | |||
141 | { | 126 | { | ||
142 | if (item) { | 127 | if (item) { | ||
143 | // Store the current site name... | 128 | // Store the current site name... | ||
144 | const QString currentSiteName = item->text (0); | 129 | const QString currentSiteName = item->text (0); | ||
145 | 130 | | |||
146 | UserAgentSelectorDlg pdlg (m_userAgentInfo, this); | 131 | UserAgentSelectorDlg pdlg (m_userAgentInfo, this); | ||
147 | pdlg.setWindowTitle (i18nc ("@title:window", "Modify Identification")); | 132 | pdlg.setWindowTitle (i18nc ("@title:window", "Modify Identification")); | ||
148 | pdlg.setSiteName (currentSiteName); | 133 | pdlg.setSiteName (currentSiteName); | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 206 | { | |||
222 | const int selectedItemCount = ui.sitePolicyTreeWidget->selectedItems().count(); | 207 | const int selectedItemCount = ui.sitePolicyTreeWidget->selectedItems().count(); | ||
223 | const bool hasItems = ui.sitePolicyTreeWidget->topLevelItemCount() > 0; | 208 | const bool hasItems = ui.sitePolicyTreeWidget->topLevelItemCount() > 0; | ||
224 | 209 | | |||
225 | ui.changeButton->setEnabled ( (hasItems && selectedItemCount == 1)); | 210 | ui.changeButton->setEnabled ( (hasItems && selectedItemCount == 1)); | ||
226 | ui.deleteButton->setEnabled ( (hasItems && selectedItemCount > 0)); | 211 | ui.deleteButton->setEnabled ( (hasItems && selectedItemCount > 0)); | ||
227 | ui.deleteAllButton->setEnabled (hasItems); | 212 | ui.deleteAllButton->setEnabled (hasItems); | ||
228 | } | 213 | } | ||
229 | 214 | | |||
230 | void UserAgentDlg::on_sitePolicyTreeWidget_itemSelectionChanged() | | |||
231 | { | | |||
232 | updateButtons(); | | |||
233 | } | | |||
234 | | ||||
235 | void UserAgentDlg::load() | 215 | void UserAgentDlg::load() | ||
236 | { | 216 | { | ||
237 | ui.sitePolicyTreeWidget->clear(); | 217 | ui.sitePolicyTreeWidget->clear(); | ||
238 | 218 | | |||
239 | if (!m_config) | 219 | if (!m_config) | ||
240 | m_config = new KConfig (QStringLiteral("kio_httprc"), KConfig::NoGlobals); | 220 | m_config = new KConfig (QStringLiteral("kio_httprc"), KConfig::NoGlobals); | ||
241 | else | 221 | else | ||
242 | m_config->reparseConfiguration(); | 222 | m_config->reparseConfiguration(); | ||
▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines |