Changeset View
Changeset View
Standalone View
Standalone View
krusader/Synchronizer/synchronizergui.cpp
Show All 14 Lines | |||||
15 | * GNU General Public License for more details. * | 15 | * GNU General Public License for more details. * | ||
16 | * * | 16 | * * | ||
17 | * You should have received a copy of the GNU General Public License * | 17 | * You should have received a copy of the GNU General Public License * | ||
18 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | 18 | * along with Krusader. If not, see [http://www.gnu.org/licenses/]. * | ||
19 | *****************************************************************************/ | 19 | *****************************************************************************/ | ||
20 | 20 | | |||
21 | #include "synchronizergui.h" | 21 | #include "synchronizergui.h" | ||
22 | #include "../krglobal.h" | 22 | #include "../krglobal.h" | ||
23 | #include "../filelisticon.h" | ||||
23 | #include "../defaults.h" | 24 | #include "../defaults.h" | ||
24 | #include "../krusaderview.h" | 25 | #include "../krusaderview.h" | ||
25 | #include "../Panel/listpanel.h" | 26 | #include "../Panel/listpanel.h" | ||
26 | #include "../Panel/panelfunc.h" | 27 | #include "../Panel/panelfunc.h" | ||
27 | #include "../FileSystem/krpermhandler.h" | 28 | #include "../FileSystem/krpermhandler.h" | ||
28 | #include "../KViewer/krviewer.h" | 29 | #include "../KViewer/krviewer.h" | ||
29 | #include "../Dialogs/krspwidgets.h" | 30 | #include "../Dialogs/krspwidgets.h" | ||
30 | #include "../FileSystem/krquery.h" | 31 | #include "../FileSystem/krquery.h" | ||
31 | #include "../krservices.h" | 32 | #include "../krservices.h" | ||
32 | #include "../krslots.h" | 33 | #include "../krslots.h" | ||
33 | #include "../kicons.h" | | |||
34 | #include "synchronizedialog.h" | 34 | #include "synchronizedialog.h" | ||
35 | #include "feedtolistboxdialog.h" | 35 | #include "feedtolistboxdialog.h" | ||
36 | #include "synchronizercolors.h" | 36 | #include "synchronizercolors.h" | ||
37 | 37 | | |||
38 | // QtCore | 38 | // QtCore | ||
39 | #include <QEventLoop> | 39 | #include <QEventLoop> | ||
40 | #include <QRegExp> | 40 | #include <QRegExp> | ||
41 | #include <QMimeData> | 41 | #include <QMimeData> | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 91 | while ((currentItem = synchronizer->getItemAt(ndx++)) != 0) { | |||
108 | } | 108 | } | ||
109 | } | 109 | } | ||
110 | 110 | | |||
111 | if (urls.count() == 0) | 111 | if (urls.count() == 0) | ||
112 | return; | 112 | return; | ||
113 | 113 | | |||
114 | QDrag *drag = new QDrag(this); | 114 | QDrag *drag = new QDrag(this); | ||
115 | QMimeData *mimeData = new QMimeData; | 115 | QMimeData *mimeData = new QMimeData; | ||
116 | mimeData->setImageData(FL_LOADICON(isLeft ? "arrow-left-double" : "arrow-right-double")); | 116 | mimeData->setImageData(FileListIcon(isLeft ? "arrow-left-double" : "arrow-right-double").pixmap()); | ||
117 | mimeData->setUrls(urls); | 117 | mimeData->setUrls(urls); | ||
118 | drag->setMimeData(mimeData); | 118 | drag->setMimeData(mimeData); | ||
119 | drag->start(); | 119 | drag->start(); | ||
120 | } | 120 | } | ||
121 | }; | 121 | }; | ||
122 | 122 | | |||
123 | 123 | | |||
124 | SynchronizerGUI::SynchronizerGUI(QWidget* parent, QUrl leftURL, QUrl rightURL, QStringList selList) : | 124 | SynchronizerGUI::SynchronizerGUI(QWidget* parent, QUrl leftURL, QUrl rightURL, QStringList selList) : | ||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | 137 | { | |||
286 | showOptionsLayout->setContentsMargins(11, 11, 11, 11); | 286 | showOptionsLayout->setContentsMargins(11, 11, 11, 11); | ||
287 | 287 | | |||
288 | bool checked; | 288 | bool checked; | ||
289 | QString description; | 289 | QString description; | ||
290 | 290 | | |||
291 | checked = group.readEntry("LeftToRight Button", _BtnLeftToRight); | 291 | checked = group.readEntry("LeftToRight Button", _BtnLeftToRight); | ||
292 | description = i18n("Show files marked to <i>Copy from left to right</i>."); | 292 | description = i18n("Show files marked to <i>Copy from left to right</i>."); | ||
293 | btnLeftToRight = | 293 | btnLeftToRight = | ||
294 | createButton(showOptions, "arrow-right", checked, Qt::CTRL + Qt::Key_L, description); | 294 | createButton(showOptions, "arrow-right", checked, Qt::CTRL + Qt::Key_L, description); | ||
martinkostolny: We can use text fallback:
`createButton(showOptions, "arrow-right", checked, Qt::CTRL + Qt… | |||||
295 | showOptionsLayout->addWidget(btnLeftToRight, 0, 0); | 295 | showOptionsLayout->addWidget(btnLeftToRight, 0, 0); | ||
296 | 296 | | |||
297 | checked = group.readEntry("Equals Button", _BtnEquals); | 297 | checked = group.readEntry("Equals Button", _BtnEquals); | ||
298 | description = i18n("Show files considered to be identical."); | 298 | description = i18n("Show files considered to be identical."); | ||
299 | btnEquals = | 299 | btnEquals = | ||
300 | createButton(showOptions, "equals", checked, Qt::CTRL + Qt::Key_E, description, "="); | 300 | createButton(showOptions, "equals", checked, Qt::CTRL + Qt::Key_E, description, "="); | ||
301 | showOptionsLayout->addWidget(btnEquals, 0, 1); | 301 | showOptionsLayout->addWidget(btnEquals, 0, 1); | ||
302 | 302 | | |||
303 | checked = group.readEntry("Differents Button", _BtnDifferents); | 303 | checked = group.readEntry("Differents Button", _BtnDifferents); | ||
304 | description = i18n("Show excluded files."); | 304 | description = i18n("Show excluded files."); | ||
305 | btnDifferents = | 305 | btnDifferents = | ||
306 | createButton(showOptions, "unequals", checked, Qt::CTRL + Qt::Key_D, description, "!="); | 306 | createButton(showOptions, "unequals", checked, Qt::CTRL + Qt::Key_D, description, "!="); | ||
307 | showOptionsLayout->addWidget(btnDifferents, 0, 2); | 307 | showOptionsLayout->addWidget(btnDifferents, 0, 2); | ||
308 | 308 | | |||
309 | checked = group.readEntry("RightToLeft Button", _BtnRightToLeft); | 309 | checked = group.readEntry("RightToLeft Button", _BtnRightToLeft); | ||
310 | description = i18n("Show files marked to <i>Copy from right to left</i>."); | 310 | description = i18n("Show files marked to <i>Copy from right to left</i>."); | ||
311 | btnRightToLeft = | 311 | btnRightToLeft = | ||
312 | createButton(showOptions, "arrow-left", checked, Qt::CTRL + Qt::Key_R, description); | 312 | createButton(showOptions, "arrow-left", checked, Qt::CTRL + Qt::Key_R, description); | ||
We can use text fallback: martinkostolny: We can use text fallback:
`createButton(showOptions, "arrow-left", checked, Qt::CTRL + Qt… | |||||
313 | showOptionsLayout->addWidget(btnRightToLeft, 0, 3); | 313 | showOptionsLayout->addWidget(btnRightToLeft, 0, 3); | ||
314 | 314 | | |||
315 | checked = group.readEntry("Deletable Button", _BtnDeletable); | 315 | checked = group.readEntry("Deletable Button", _BtnDeletable); | ||
316 | description = i18n("Show files marked to delete."); | 316 | description = i18n("Show files marked to delete."); | ||
317 | btnDeletable = | 317 | btnDeletable = | ||
318 | createButton(showOptions, "user-trash", checked, Qt::CTRL + Qt::Key_T, description); | 318 | createButton(showOptions, "user-trash", checked, Qt::CTRL + Qt::Key_T, description); | ||
319 | showOptionsLayout->addWidget(btnDeletable, 0, 4); | 319 | showOptionsLayout->addWidget(btnDeletable, 0, 4); | ||
320 | 320 | | |||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | |||||
464 | buttons->setContentsMargins(0, 0, 0, 0); | 464 | buttons->setContentsMargins(0, 0, 0, 0); | ||
465 | 465 | | |||
466 | profileManager = new ProfileManager("SynchronizerProfile", this); | 466 | profileManager = new ProfileManager("SynchronizerProfile", this); | ||
467 | profileManager->setShortcut(Qt::CTRL + Qt::Key_P); | 467 | profileManager->setShortcut(Qt::CTRL + Qt::Key_P); | ||
468 | profileManager->setWhatsThis(i18n("Profile manager (Ctrl+P).")); | 468 | profileManager->setWhatsThis(i18n("Profile manager (Ctrl+P).")); | ||
469 | buttons->addWidget(profileManager); | 469 | buttons->addWidget(profileManager); | ||
470 | 470 | | |||
471 | btnSwapSides = new QPushButton(this); | 471 | btnSwapSides = new QPushButton(this); | ||
472 | btnSwapSides->setIcon(QIcon::fromTheme("document-swap")); | 472 | btnSwapSides->setIcon(Icon("document-swap")); | ||
473 | btnSwapSides->setShortcut(Qt::CTRL + Qt::Key_S); | 473 | btnSwapSides->setShortcut(Qt::CTRL + Qt::Key_S); | ||
474 | btnSwapSides->setWhatsThis(i18n("Swap sides (Ctrl+S).")); | 474 | btnSwapSides->setWhatsThis(i18n("Swap sides (Ctrl+S).")); | ||
475 | buttons->addWidget(btnSwapSides); | 475 | buttons->addWidget(btnSwapSides); | ||
476 | 476 | | |||
477 | statusLabel = new QLabel(this); | 477 | statusLabel = new QLabel(this); | ||
478 | buttons->addWidget(statusLabel); | 478 | buttons->addWidget(statusLabel); | ||
479 | 479 | | |||
480 | QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); | 480 | QSpacerItem* spacer = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); | ||
481 | buttons->addItem(spacer); | 481 | buttons->addItem(spacer); | ||
482 | 482 | | |||
483 | btnCompareDirs = new QPushButton(this); | 483 | btnCompareDirs = new QPushButton(this); | ||
484 | btnCompareDirs->setText(i18n("Compare")); | 484 | btnCompareDirs->setText(i18n("Compare")); | ||
485 | btnCompareDirs->setIcon(QIcon::fromTheme("kr_comparedirs")); | 485 | btnCompareDirs->setIcon(Icon("kr_comparedirs")); | ||
486 | btnCompareDirs->setDefault(true); | 486 | btnCompareDirs->setDefault(true); | ||
487 | buttons->addWidget(btnCompareDirs); | 487 | buttons->addWidget(btnCompareDirs); | ||
488 | 488 | | |||
489 | btnScrollResults = new QPushButton(this); | 489 | btnScrollResults = new QPushButton(this); | ||
490 | btnScrollResults->setCheckable(true); | 490 | btnScrollResults->setCheckable(true); | ||
491 | btnScrollResults->setChecked(group.readEntry("Scroll Results", _ScrollResults)); | 491 | btnScrollResults->setChecked(group.readEntry("Scroll Results", _ScrollResults)); | ||
492 | btnScrollResults->hide(); | 492 | btnScrollResults->hide(); | ||
493 | if (btnScrollResults->isChecked()) | 493 | if (btnScrollResults->isChecked()) | ||
494 | btnScrollResults->setText(i18n("Quiet")); | 494 | btnScrollResults->setText(i18n("Quiet")); | ||
495 | else | 495 | else | ||
496 | btnScrollResults->setText(i18n("Scroll Results")); | 496 | btnScrollResults->setText(i18n("Scroll Results")); | ||
497 | buttons->addWidget(btnScrollResults); | 497 | buttons->addWidget(btnScrollResults); | ||
498 | 498 | | |||
499 | btnStopComparing = new QPushButton(this); | 499 | btnStopComparing = new QPushButton(this); | ||
500 | btnStopComparing->setText(i18n("Stop")); | 500 | btnStopComparing->setText(i18n("Stop")); | ||
501 | btnStopComparing->setIcon(QIcon::fromTheme("process-stop")); | 501 | btnStopComparing->setIcon(Icon("process-stop")); | ||
502 | btnStopComparing->setEnabled(false); | 502 | btnStopComparing->setEnabled(false); | ||
503 | buttons->addWidget(btnStopComparing); | 503 | buttons->addWidget(btnStopComparing); | ||
504 | 504 | | |||
505 | btnFeedToListBox = new QPushButton(this); | 505 | btnFeedToListBox = new QPushButton(this); | ||
506 | btnFeedToListBox->setText(i18n("Feed to listbox")); | 506 | btnFeedToListBox->setText(i18n("Feed to listbox")); | ||
507 | btnFeedToListBox->setIcon(QIcon::fromTheme("list-add")); | 507 | btnFeedToListBox->setIcon(Icon("list-add")); | ||
508 | btnFeedToListBox->setEnabled(false); | 508 | btnFeedToListBox->setEnabled(false); | ||
509 | btnFeedToListBox->hide(); | 509 | btnFeedToListBox->hide(); | ||
510 | buttons->addWidget(btnFeedToListBox); | 510 | buttons->addWidget(btnFeedToListBox); | ||
511 | 511 | | |||
512 | btnSynchronize = new QPushButton(this); | 512 | btnSynchronize = new QPushButton(this); | ||
513 | btnSynchronize->setText(i18n("Synchronize")); | 513 | btnSynchronize->setText(i18n("Synchronize")); | ||
514 | btnSynchronize->setIcon(QIcon::fromTheme("folder-sync")); | 514 | btnSynchronize->setIcon(Icon("folder-sync")); | ||
515 | btnSynchronize->setEnabled(false); | 515 | btnSynchronize->setEnabled(false); | ||
516 | buttons->addWidget(btnSynchronize); | 516 | buttons->addWidget(btnSynchronize); | ||
517 | 517 | | |||
518 | QPushButton *btnCloseSync = new QPushButton(this); | 518 | QPushButton *btnCloseSync = new QPushButton(this); | ||
519 | btnCloseSync->setText(i18n("Close")); | 519 | btnCloseSync->setText(i18n("Close")); | ||
520 | btnCloseSync->setIcon(QIcon::fromTheme("dialog-close")); | 520 | btnCloseSync->setIcon(Icon("dialog-close")); | ||
521 | buttons->addWidget(btnCloseSync); | 521 | buttons->addWidget(btnCloseSync); | ||
522 | 522 | | |||
523 | synchGrid->addLayout(buttons, 1, 0); | 523 | synchGrid->addLayout(buttons, 1, 0); | ||
524 | 524 | | |||
525 | /* =============================== Connect table ================================ */ | 525 | /* =============================== Connect table ================================ */ | ||
526 | 526 | | |||
527 | connect(syncList, SIGNAL(itemRightClicked(QTreeWidgetItem*,QPoint,int)), | 527 | connect(syncList, SIGNAL(itemRightClicked(QTreeWidgetItem*,QPoint,int)), | ||
528 | this, SLOT(rightMouseClicked(QTreeWidgetItem*,QPoint))); | 528 | this, SLOT(rightMouseClicked(QTreeWidgetItem*,QPoint))); | ||
▲ Show 20 Lines • Show All 585 Lines • ▼ Show 20 Line(s) | 1113 | listItem = new SyncViewItem(item, textColor, baseColor, dirItem, dirItem->lastItem(), leftName, | |||
1114 | leftSize, leftDate, Synchronizer::getTaskTypeName(item->task()), | 1114 | leftSize, leftDate, Synchronizer::getTaskTypeName(item->task()), | ||
1115 | rightDate, rightSize, rightName); | 1115 | rightDate, rightSize, rightName); | ||
1116 | 1116 | | |||
1117 | dirItem->setLastItem(listItem); | 1117 | dirItem->setLastItem(listItem); | ||
1118 | } | 1118 | } | ||
1119 | } | 1119 | } | ||
1120 | 1120 | | |||
1121 | if (listItem) { | 1121 | if (listItem) { | ||
1122 | listItem->setIcon(0, QIcon::fromTheme(isDir ? "folder" : "document-new")); | 1122 | listItem->setIcon(0, Icon(isDir ? "folder" : "document-new")); | ||
1123 | if (!item->isMarked()) | 1123 | if (!item->isMarked()) | ||
1124 | listItem->setHidden(true); | 1124 | listItem->setHidden(true); | ||
1125 | else | 1125 | else | ||
1126 | syncList->scrollTo(syncList->indexOf(listItem)); | 1126 | syncList->scrollTo(syncList->indexOf(listItem)); | ||
1127 | } | 1127 | } | ||
1128 | } | 1128 | } | ||
1129 | 1129 | | |||
1130 | void SynchronizerGUI::markChanged(SynchronizerFileItem *item, bool ensureVisible) | 1130 | void SynchronizerGUI::markChanged(SynchronizerFileItem *item, bool ensureVisible) | ||
▲ Show 20 Lines • Show All 428 Lines • ▼ Show 20 Line(s) | 1545 | { | |||
1559 | } | 1559 | } | ||
1560 | } | 1560 | } | ||
1561 | 1561 | | |||
1562 | QPushButton *SynchronizerGUI::createButton(QWidget *parent, const QString &iconName, bool checked, | 1562 | QPushButton *SynchronizerGUI::createButton(QWidget *parent, const QString &iconName, bool checked, | ||
1563 | const QKeySequence &shortCut, const QString &description, | 1563 | const QKeySequence &shortCut, const QString &description, | ||
1564 | const QString &text, bool textAndIcon) | 1564 | const QString &text, bool textAndIcon) | ||
1565 | { | 1565 | { | ||
1566 | QPushButton *button = new QPushButton(parent); | 1566 | QPushButton *button = new QPushButton(parent); | ||
1567 | if (!text.isEmpty() && (textAndIcon || !QIcon::hasThemeIcon(iconName))) | 1567 | bool iconExists = Icon::exists(iconName); | ||
1568 | if (!text.isEmpty() && (textAndIcon || !iconExists)) { | ||||
1568 | button->setText(text); | 1569 | button->setText(text); | ||
1569 | button->setIcon(QIcon::fromTheme(iconName)); | 1570 | } | ||
1571 | if (iconExists) { | ||||
1572 | button->setIcon(Icon(iconName)); | ||||
1573 | } | ||||
1570 | button->setCheckable(true); | 1574 | button->setCheckable(true); | ||
1571 | button->setChecked(checked); | 1575 | button->setChecked(checked); | ||
1572 | button->setShortcut(shortCut); | 1576 | button->setShortcut(shortCut); | ||
1573 | const QString infoText = | 1577 | const QString infoText = | ||
1574 | QString("%1 (%2)").arg(description, shortCut.toString(QKeySequence::NativeText)); | 1578 | QString("%1 (%2)").arg(description, shortCut.toString(QKeySequence::NativeText)); | ||
1575 | button->setWhatsThis(infoText); | 1579 | button->setWhatsThis(infoText); | ||
1576 | button->setToolTip(infoText); | 1580 | button->setToolTip(infoText); | ||
1577 | return button; | 1581 | return button; | ||
Show All 25 Lines | 1598 | if (item) { | |||
1603 | } | 1607 | } | ||
1604 | } | 1608 | } | ||
1605 | } | 1609 | } | ||
1606 | 1610 | | |||
1607 | if (urls.count() == 0) | 1611 | if (urls.count() == 0) | ||
1608 | return; | 1612 | return; | ||
1609 | 1613 | | |||
1610 | QMimeData *mimeData = new QMimeData; | 1614 | QMimeData *mimeData = new QMimeData; | ||
1611 | mimeData->setImageData(FL_LOADICON(isLeft ? "arrow-left-double" : "arrow-right-double")); | 1615 | mimeData->setImageData(FileListIcon(isLeft ? "arrow-left-double" : "arrow-right-double").pixmap()); | ||
1612 | mimeData->setUrls(urls); | 1616 | mimeData->setUrls(urls); | ||
1613 | 1617 | | |||
1614 | QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); | 1618 | QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); | ||
1615 | } | 1619 | } | ||
1616 | 1620 | | |||
1617 | QString SynchronizerGUI::dirLabel() | 1621 | QString SynchronizerGUI::dirLabel() | ||
1618 | { | 1622 | { | ||
1619 | //HACK add <> brackets AFTER translating - otherwise KUIT thinks it's a tag | 1623 | //HACK add <> brackets AFTER translating - otherwise KUIT thinks it's a tag | ||
1620 | static QString label = QString("<") + | 1624 | static QString label = QString("<") + | ||
1621 | i18nc("Show the string 'DIR' instead of file size in detailed view (for folders)", "DIR") + '>'; | 1625 | i18nc("Show the string 'DIR' instead of file size in detailed view (for folders)", "DIR") + '>'; | ||
1622 | return label; | 1626 | return label; | ||
1623 | } | 1627 | } | ||
1624 | 1628 | |
We can use text fallback:
createButton(showOptions, "arrow-right", checked, Qt::CTRL + Qt::Key_L, description, ">");