Guest User

extrabuttons.diff

a guest
Sep 24th, 2017
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.90 KB | None | 0 0
  1. diff -U 3 -H -d -r -N -- "a/src/dolphinmainwindow.cpp" "b/src/dolphinmainwindow.cpp"
  2. --- "a/src/dolphinmainwindow.cpp" 2017-09-02 12:25:44.000000000 +0300
  3. +++ "b/src/dolphinmainwindow.cpp" 2017-09-24 22:01:39.355116440 +0300
  4. @@ -799,6 +799,348 @@
  5. }
  6. }
  7.  
  8. +// 10 Extra buttons
  9. +void DolphinMainWindow::extraButton00()
  10. +{
  11. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  12. +
  13. + QString dir(QDir::homePath());
  14. +
  15. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  16. + KJobWidgets::setWindow(statJob, this);
  17. + statJob->exec();
  18. + QUrl url = statJob->mostLocalUrl();
  19. +
  20. + if (url.isLocalFile()) {
  21. + dir = url.toLocalFile();
  22. + }
  23. +
  24. + QUrl dirUrl = dir;
  25. +
  26. + QString selectedUrls = "";
  27. + int i = 0;
  28. + foreach (const KFileItem& item, list) {
  29. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  30. + selectedUrls.append(" ");
  31. + i++;
  32. + }
  33. +
  34. + QString command(QStringLiteral("myextrabuttons \""));
  35. + command.append('0');
  36. + command.append("\" \"");
  37. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  38. + command.append("\" \"");
  39. + command.append(selectedUrls);
  40. + command.append('\"');
  41. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  42. +}
  43. +void DolphinMainWindow::extraButton01()
  44. +{
  45. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  46. +
  47. + QString dir(QDir::homePath());
  48. +
  49. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  50. + KJobWidgets::setWindow(statJob, this);
  51. + statJob->exec();
  52. + QUrl url = statJob->mostLocalUrl();
  53. +
  54. + if (url.isLocalFile()) {
  55. + dir = url.toLocalFile();
  56. + }
  57. +
  58. + QUrl dirUrl = dir;
  59. +
  60. + QString selectedUrls = "";
  61. + int i = 0;
  62. + foreach (const KFileItem& item, list) {
  63. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  64. + selectedUrls.append(" ");
  65. + i++;
  66. + }
  67. +
  68. + QString command(QStringLiteral("myextrabuttons \""));
  69. + command.append('1');
  70. + command.append("\" \"");
  71. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  72. + command.append("\" \"");
  73. + command.append(selectedUrls);
  74. + command.append('\"');
  75. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  76. +}
  77. +void DolphinMainWindow::extraButton02()
  78. +{
  79. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  80. +
  81. + QString dir(QDir::homePath());
  82. +
  83. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  84. + KJobWidgets::setWindow(statJob, this);
  85. + statJob->exec();
  86. + QUrl url = statJob->mostLocalUrl();
  87. +
  88. + if (url.isLocalFile()) {
  89. + dir = url.toLocalFile();
  90. + }
  91. +
  92. + QUrl dirUrl = dir;
  93. +
  94. + QString selectedUrls = "";
  95. + int i = 0;
  96. + foreach (const KFileItem& item, list) {
  97. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  98. + selectedUrls.append(" ");
  99. + i++;
  100. + }
  101. +
  102. + QString command(QStringLiteral("myextrabuttons \""));
  103. + command.append('2');
  104. + command.append("\" \"");
  105. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  106. + command.append("\" \"");
  107. + command.append(selectedUrls);
  108. + command.append('\"');
  109. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  110. +}
  111. +void DolphinMainWindow::extraButton03()
  112. +{
  113. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  114. +
  115. + QString dir(QDir::homePath());
  116. +
  117. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  118. + KJobWidgets::setWindow(statJob, this);
  119. + statJob->exec();
  120. + QUrl url = statJob->mostLocalUrl();
  121. +
  122. + if (url.isLocalFile()) {
  123. + dir = url.toLocalFile();
  124. + }
  125. +
  126. + QUrl dirUrl = dir;
  127. +
  128. + QString selectedUrls = "";
  129. + int i = 0;
  130. + foreach (const KFileItem& item, list) {
  131. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  132. + selectedUrls.append(" ");
  133. + i++;
  134. + }
  135. +
  136. + QString command(QStringLiteral("myextrabuttons \""));
  137. + command.append('3');
  138. + command.append("\" \"");
  139. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  140. + command.append("\" \"");
  141. + command.append(selectedUrls);
  142. + command.append('\"');
  143. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  144. +}
  145. +void DolphinMainWindow::extraButton04()
  146. +{
  147. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  148. +
  149. + QString dir(QDir::homePath());
  150. +
  151. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  152. + KJobWidgets::setWindow(statJob, this);
  153. + statJob->exec();
  154. + QUrl url = statJob->mostLocalUrl();
  155. +
  156. + if (url.isLocalFile()) {
  157. + dir = url.toLocalFile();
  158. + }
  159. +
  160. + QUrl dirUrl = dir;
  161. +
  162. + QString selectedUrls = "";
  163. + int i = 0;
  164. + foreach (const KFileItem& item, list) {
  165. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  166. + selectedUrls.append(" ");
  167. + i++;
  168. + }
  169. +
  170. + QString command(QStringLiteral("myextrabuttons \""));
  171. + command.append('4');
  172. + command.append("\" \"");
  173. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  174. + command.append("\" \"");
  175. + command.append(selectedUrls);
  176. + command.append('\"');
  177. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  178. +}
  179. +void DolphinMainWindow::extraButton05()
  180. +{
  181. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  182. +
  183. + QString dir(QDir::homePath());
  184. +
  185. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  186. + KJobWidgets::setWindow(statJob, this);
  187. + statJob->exec();
  188. + QUrl url = statJob->mostLocalUrl();
  189. +
  190. + if (url.isLocalFile()) {
  191. + dir = url.toLocalFile();
  192. + }
  193. +
  194. + QUrl dirUrl = dir;
  195. +
  196. + QString selectedUrls = "";
  197. + int i = 0;
  198. + foreach (const KFileItem& item, list) {
  199. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  200. + selectedUrls.append(" ");
  201. + i++;
  202. + }
  203. +
  204. + QString command(QStringLiteral("myextrabuttons \""));
  205. + command.append('5');
  206. + command.append("\" \"");
  207. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  208. + command.append("\" \"");
  209. + command.append(selectedUrls);
  210. + command.append('\"');
  211. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  212. +}
  213. +void DolphinMainWindow::extraButton06()
  214. +{
  215. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  216. +
  217. + QString dir(QDir::homePath());
  218. +
  219. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  220. + KJobWidgets::setWindow(statJob, this);
  221. + statJob->exec();
  222. + QUrl url = statJob->mostLocalUrl();
  223. +
  224. + if (url.isLocalFile()) {
  225. + dir = url.toLocalFile();
  226. + }
  227. +
  228. + QUrl dirUrl = dir;
  229. +
  230. + QString selectedUrls = "";
  231. + int i = 0;
  232. + foreach (const KFileItem& item, list) {
  233. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  234. + selectedUrls.append(" ");
  235. + i++;
  236. + }
  237. +
  238. + QString command(QStringLiteral("myextrabuttons \""));
  239. + command.append('6');
  240. + command.append("\" \"");
  241. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  242. + command.append("\" \"");
  243. + command.append(selectedUrls);
  244. + command.append('\"');
  245. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  246. +}
  247. +void DolphinMainWindow::extraButton07()
  248. +{
  249. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  250. +
  251. + QString dir(QDir::homePath());
  252. +
  253. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  254. + KJobWidgets::setWindow(statJob, this);
  255. + statJob->exec();
  256. + QUrl url = statJob->mostLocalUrl();
  257. +
  258. + if (url.isLocalFile()) {
  259. + dir = url.toLocalFile();
  260. + }
  261. +
  262. + QUrl dirUrl = dir;
  263. +
  264. + QString selectedUrls = "";
  265. + int i = 0;
  266. + foreach (const KFileItem& item, list) {
  267. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  268. + selectedUrls.append(" ");
  269. + i++;
  270. + }
  271. +
  272. + QString command(QStringLiteral("myextrabuttons \""));
  273. + command.append('7');
  274. + command.append("\" \"");
  275. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  276. + command.append("\" \"");
  277. + command.append(selectedUrls);
  278. + command.append('\"');
  279. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  280. +}
  281. +void DolphinMainWindow::extraButton08()
  282. +{
  283. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  284. +
  285. + QString dir(QDir::homePath());
  286. +
  287. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  288. + KJobWidgets::setWindow(statJob, this);
  289. + statJob->exec();
  290. + QUrl url = statJob->mostLocalUrl();
  291. +
  292. + if (url.isLocalFile()) {
  293. + dir = url.toLocalFile();
  294. + }
  295. +
  296. + QUrl dirUrl = dir;
  297. +
  298. + QString selectedUrls = "";
  299. + int i = 0;
  300. + foreach (const KFileItem& item, list) {
  301. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  302. + selectedUrls.append(" ");
  303. + i++;
  304. + }
  305. +
  306. + QString command(QStringLiteral("myextrabuttons \""));
  307. + command.append('8');
  308. + command.append("\" \"");
  309. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  310. + command.append("\" \"");
  311. + command.append(selectedUrls);
  312. + command.append('\"');
  313. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  314. +}
  315. +void DolphinMainWindow::extraButton09()
  316. +{
  317. + const KFileItemList& list = m_activeViewContainer->view()->selectedItems();
  318. +
  319. + QString dir(QDir::homePath());
  320. +
  321. + KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
  322. + KJobWidgets::setWindow(statJob, this);
  323. + statJob->exec();
  324. + QUrl url = statJob->mostLocalUrl();
  325. +
  326. + if (url.isLocalFile()) {
  327. + dir = url.toLocalFile();
  328. + }
  329. +
  330. + QUrl dirUrl = dir;
  331. +
  332. + QString selectedUrls = "";
  333. + int i = 0;
  334. + foreach (const KFileItem& item, list) {
  335. + selectedUrls.append(list.at(i).url().toDisplayString(QUrl::PreferLocalFile));
  336. + selectedUrls.append(" ");
  337. + i++;
  338. + }
  339. +
  340. + QString command(QStringLiteral("myextrabuttons \""));
  341. + command.append('9');
  342. + command.append("\" \"");
  343. + command.append(dirUrl.toDisplayString(QUrl::PreferLocalFile));
  344. + command.append("\" \"");
  345. + command.append(selectedUrls);
  346. + command.append('\"');
  347. + KRun::runCommand(command, QStringLiteral("My Extra Buttons"), QStringLiteral("myextrabuttons"), this);
  348. +}
  349. +
  350. void DolphinMainWindow::updateControlMenu()
  351. {
  352. QMenu* menu = qobject_cast<QMenu*>(sender());
  353. @@ -1132,6 +1474,57 @@
  354. connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
  355. }
  356.  
  357. + // setup '10 Extra Buttons'
  358. + QAction* extraButton00 = actionCollection()->addAction(QStringLiteral("extra_button00"));
  359. + extraButton00->setText(i18nc("@action:inmenu Tools", "Button00"));
  360. + extraButton00->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  361. + connect(extraButton00, &QAction::triggered, this, &DolphinMainWindow::extraButton00);
  362. +
  363. + QAction* extraButton01 = actionCollection()->addAction(QStringLiteral("extra_button01"));
  364. + extraButton01->setText(i18nc("@action:inmenu Tools", "Button01"));
  365. + extraButton01->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  366. + connect(extraButton01, &QAction::triggered, this, &DolphinMainWindow::extraButton01);
  367. +
  368. + QAction* extraButton02 = actionCollection()->addAction(QStringLiteral("extra_button02"));
  369. + extraButton02->setText(i18nc("@action:inmenu Tools", "Button02"));
  370. + extraButton02->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  371. + connect(extraButton02, &QAction::triggered, this, &DolphinMainWindow::extraButton02);
  372. +
  373. + QAction* extraButton03 = actionCollection()->addAction(QStringLiteral("extra_button03"));
  374. + extraButton03->setText(i18nc("@action:inmenu Tools", "Button03"));
  375. + extraButton03->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  376. + connect(extraButton03, &QAction::triggered, this, &DolphinMainWindow::extraButton03);
  377. +
  378. + QAction* extraButton04 = actionCollection()->addAction(QStringLiteral("extra_button04"));
  379. + extraButton04->setText(i18nc("@action:inmenu Tools", "Button04"));
  380. + extraButton04->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  381. + connect(extraButton04, &QAction::triggered, this, &DolphinMainWindow::extraButton04);
  382. +
  383. + QAction* extraButton05 = actionCollection()->addAction(QStringLiteral("extra_button05"));
  384. + extraButton05->setText(i18nc("@action:inmenu Tools", "Button05"));
  385. + extraButton05->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  386. + connect(extraButton05, &QAction::triggered, this, &DolphinMainWindow::extraButton05);
  387. +
  388. + QAction* extraButton06 = actionCollection()->addAction(QStringLiteral("extra_button06"));
  389. + extraButton06->setText(i18nc("@action:inmenu Tools", "Button06"));
  390. + extraButton06->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  391. + connect(extraButton06, &QAction::triggered, this, &DolphinMainWindow::extraButton06);
  392. +
  393. + QAction* extraButton07 = actionCollection()->addAction(QStringLiteral("extra_button07"));
  394. + extraButton07->setText(i18nc("@action:inmenu Tools", "Button07"));
  395. + extraButton07->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  396. + connect(extraButton07, &QAction::triggered, this, &DolphinMainWindow::extraButton07);
  397. +
  398. + QAction* extraButton08 = actionCollection()->addAction(QStringLiteral("extra_button08"));
  399. + extraButton08->setText(i18nc("@action:inmenu Tools", "Button08"));
  400. + extraButton08->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  401. + connect(extraButton08, &QAction::triggered, this, &DolphinMainWindow::extraButton08);
  402. +
  403. + QAction* extraButton09 = actionCollection()->addAction(QStringLiteral("extra_button09"));
  404. + extraButton09->setText(i18nc("@action:inmenu Tools", "Button09"));
  405. + extraButton09->setIcon(QIcon::fromTheme(QStringLiteral("emblem-question")));
  406. + connect(extraButton09, &QAction::triggered, this, &DolphinMainWindow::extraButton09);
  407. +
  408. // setup 'Settings' menu
  409. KToggleAction* showMenuBar = KStandardAction::showMenubar(0, 0, actionCollection());
  410. connect(showMenuBar, &KToggleAction::triggered, // Fixes #286822
  411. diff -U 3 -H -d -r -N -- "a/src/dolphinmainwindow.h" "b/src/dolphinmainwindow.h"
  412. --- "a/src/dolphinmainwindow.h" 2017-09-02 12:25:44.000000000 +0300
  413. +++ "b/src/dolphinmainwindow.h" 2017-09-24 22:02:32.698450013 +0300
  414. @@ -425,6 +425,18 @@
  415. */
  416. void slotDirectoryLoadingCompleted();
  417.  
  418. + /** 10 Extra buttons */
  419. + void extraButton00();
  420. + void extraButton01();
  421. + void extraButton02();
  422. + void extraButton03();
  423. + void extraButton04();
  424. + void extraButton05();
  425. + void extraButton06();
  426. + void extraButton07();
  427. + void extraButton08();
  428. + void extraButton09();
  429. +
  430. private:
  431. void setupActions();
  432. void setupDockWidgets();
Advertisement
Add Comment
Please, Sign In to add comment