Add simple view for showing ignore patterns
This commit is contained in:
parent
a309926839
commit
9e4208fc0d
|
@ -524,12 +524,20 @@ void SyncthingApplet::showDirectoryErrors(const QString &dirId)
|
|||
|
||||
void SyncthingApplet::browseRemoteFiles(const QString &dirId)
|
||||
{
|
||||
auto row = 0;
|
||||
auto *const dir = m_connection.findDirInfo(dirId, row);
|
||||
if (!dir) {
|
||||
return;
|
||||
if (auto row = 0; auto *const dir = m_connection.findDirInfo(dirId, row)) {
|
||||
showCenteredDialog(QtGui::browseRemoteFilesDialog(m_connection, *dir));
|
||||
}
|
||||
auto *const dlg = QtGui::browseRemoteFilesDialog(m_connection, *dir);
|
||||
}
|
||||
|
||||
void SyncthingApplet::showIgnorePatterns(const QString &dirId)
|
||||
{
|
||||
if (auto row = 0; auto *const dir = m_connection.findDirInfo(dirId, row)) {
|
||||
showCenteredDialog(QtGui::ignorePatternsDialog(m_connection, *dir));
|
||||
}
|
||||
}
|
||||
|
||||
void SyncthingApplet::showCenteredDialog(QWidget *dlg)
|
||||
{
|
||||
dlg->resize(600, 500);
|
||||
centerWidget(dlg);
|
||||
dlg->show();
|
||||
|
|
|
@ -149,6 +149,7 @@ public Q_SLOTS:
|
|||
void showInternalErrorsDialog();
|
||||
void showDirectoryErrors(const QString &dirId);
|
||||
void browseRemoteFiles(const QString &dirId);
|
||||
void showIgnorePatterns(const QString &dirId);
|
||||
void copyToClipboard(const QString &text);
|
||||
void updateStatusIconAndTooltip();
|
||||
void saveSettings();
|
||||
|
@ -207,6 +208,8 @@ private Q_SLOTS:
|
|||
void concludeWizard(const QString &errorMessage = QString());
|
||||
|
||||
private:
|
||||
void showCenteredDialog(QWidget *dlg);
|
||||
|
||||
Plasma::Theme m_theme;
|
||||
QString m_faUrl;
|
||||
QPalette m_palette;
|
||||
|
|
|
@ -189,6 +189,14 @@ ColumnLayout {
|
|||
"browseRemoteFiles", "dirId_")
|
||||
visible: plasmoid.wipFeaturesEnabled
|
||||
}
|
||||
PlasmaExtras.MenuItem {
|
||||
id: showIgnorePatternsItem
|
||||
text: qsTr("Show ignore patterns")
|
||||
icon: "selection-symbolic"
|
||||
onClicked: directoryView.triggerNativeActionWithCurrentItemData(
|
||||
"showIgnorePatterns", "dirId_")
|
||||
visible: plasmoid.wipFeaturesEnabled
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "./otherdialogs.h"
|
||||
#include "./textviewdialog.h"
|
||||
|
||||
#include <syncthingconnector/syncthingconnection.h>
|
||||
#include <syncthingconnector/syncthingdir.h>
|
||||
|
@ -15,8 +16,10 @@
|
|||
#include <QIcon>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QNetworkReply>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QTextBrowser>
|
||||
#include <QTreeView>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
@ -125,4 +128,24 @@ QDialog *browseRemoteFilesDialog(Data::SyncthingConnection &connection, const Da
|
|||
return dlg;
|
||||
}
|
||||
|
||||
TextViewDialog *ignorePatternsDialog(Data::SyncthingConnection &connection, const Data::SyncthingDir &dir, QWidget *parent)
|
||||
{
|
||||
auto *const dlg
|
||||
= new TextViewDialog(QCoreApplication::translate("QtGui::OtherDialogs", "Ignore patterns of folder \"%1\"").arg(dir.displayName()), parent);
|
||||
dlg->browser()->setText(QStringLiteral("Loading…"));
|
||||
auto res = connection.ignores(dir.id, [dlg](Data::SyncthingIgnores &&ignores, QString &&errorMessage) {
|
||||
auto *const browser = dlg->browser();
|
||||
browser->clear();
|
||||
if (!errorMessage.isEmpty()) {
|
||||
browser->setText(errorMessage);
|
||||
return;
|
||||
}
|
||||
for (const auto &ignore : ignores.ignore) {
|
||||
browser->append(ignore);
|
||||
}
|
||||
});
|
||||
QObject::connect(dlg, &QObject::destroyed, res.reply, &QNetworkReply::deleteLater);
|
||||
return dlg;
|
||||
}
|
||||
|
||||
} // namespace QtGui
|
||||
|
|
|
@ -14,11 +14,15 @@ struct SyncthingDir;
|
|||
} // namespace Data
|
||||
|
||||
namespace QtGui {
|
||||
class TextViewDialog;
|
||||
|
||||
SYNCTHINGWIDGETS_EXPORT QDialog *ownDeviceIdDialog(Data::SyncthingConnection &connection);
|
||||
SYNCTHINGWIDGETS_EXPORT QWidget *ownDeviceIdWidget(Data::SyncthingConnection &connection, int size, QWidget *parent = nullptr);
|
||||
SYNCTHINGWIDGETS_EXPORT QDialog *browseRemoteFilesDialog(
|
||||
Data::SyncthingConnection &connection, const Data::SyncthingDir &dir, QWidget *parent = nullptr);
|
||||
SYNCTHINGWIDGETS_EXPORT TextViewDialog *ignorePatternsDialog(
|
||||
Data::SyncthingConnection &connection, const Data::SyncthingDir &dir, QWidget *parent = nullptr);
|
||||
|
||||
} // namespace QtGui
|
||||
|
||||
#endif // SYNCTHINGWIDGETS_OTHERDIALOGS_H
|
||||
|
|
|
@ -89,6 +89,7 @@ set(REQUIRED_ICONS
|
|||
preferences-other
|
||||
process-stop
|
||||
qtcreator
|
||||
selection-symbolic
|
||||
system-run
|
||||
system-search
|
||||
system-file-manager
|
||||
|
|
|
@ -108,6 +108,8 @@ void DirView::showContextMenu(const QPoint &position)
|
|||
QIcon(QStringLiteral(":/icons/hicolor/scalable/places/document-open-remote.svg"))),
|
||||
tr("Browse remote files")),
|
||||
&QAction::triggered, triggerActionForSelectedRow(this, &DirView::browseRemoteFiles));
|
||||
connect(menu.addAction(QIcon::fromTheme(QStringLiteral("selection-symbolic")), tr("Show ignore patterns")), &QAction::triggered,
|
||||
triggerActionForSelectedRow(this, &DirView::showIgnorePatterns));
|
||||
}
|
||||
}
|
||||
showViewMenu(position, *this, menu);
|
||||
|
|
|
@ -24,6 +24,7 @@ Q_SIGNALS:
|
|||
void scanDir(const Data::SyncthingDir &dir);
|
||||
void pauseResumeDir(const Data::SyncthingDir &dir);
|
||||
void browseRemoteFiles(const Data::SyncthingDir &dir);
|
||||
void showIgnorePatterns(const Data::SyncthingDir &dir);
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
|
|
|
@ -204,6 +204,7 @@ TrayWidget::TrayWidget(TrayMenu *parent)
|
|||
connect(m_ui->dirsTreeView, &DirView::pauseResumeDir, this, &TrayWidget::pauseResumeDir);
|
||||
connect(m_ui->devsTreeView, &DevView::pauseResumeDev, this, &TrayWidget::pauseResumeDev);
|
||||
connect(m_ui->dirsTreeView, &DirView::browseRemoteFiles, this, &TrayWidget::browseRemoteFiles);
|
||||
connect(m_ui->dirsTreeView, &DirView::showIgnorePatterns, this, &TrayWidget::showIgnorePatterns);
|
||||
connect(m_ui->downloadsTreeView, &DownloadView::openDir, this, &TrayWidget::openDir);
|
||||
connect(m_ui->downloadsTreeView, &DownloadView::openItemDir, this, &TrayWidget::openItemDir);
|
||||
connect(m_ui->recentChangesTreeView, &QTreeView::customContextMenuRequested, this, &TrayWidget::showRecentChangesContextMenu);
|
||||
|
@ -711,10 +712,12 @@ void TrayWidget::pauseResumeDir(const SyncthingDir &dir)
|
|||
|
||||
void TrayWidget::browseRemoteFiles(const Data::SyncthingDir &dir)
|
||||
{
|
||||
auto *const dlg = browseRemoteFilesDialog(m_connection, dir, this);
|
||||
dlg->resize(600, 500);
|
||||
centerWidget(dlg);
|
||||
dlg->show();
|
||||
showCenteredDialog(browseRemoteFilesDialog(m_connection, dir, this), QSize(600, 500));
|
||||
}
|
||||
|
||||
void TrayWidget::showIgnorePatterns(const Data::SyncthingDir &dir)
|
||||
{
|
||||
showCenteredDialog(ignorePatternsDialog(m_connection, dir, this), QSize(600, 500));
|
||||
}
|
||||
|
||||
void TrayWidget::showRecentChangesContextMenu(const QPoint &position)
|
||||
|
@ -963,6 +966,16 @@ void TrayWidget::showDialog(QWidget *dlg, bool maximized)
|
|||
dlg->activateWindow();
|
||||
}
|
||||
|
||||
void TrayWidget::showCenteredDialog(QWidget *dlg, const QSize &size)
|
||||
{
|
||||
if (m_menu && m_menu->windowType() != TrayMenu::WindowType::NormalWindow) {
|
||||
m_menu->close();
|
||||
}
|
||||
dlg->resize(size);
|
||||
centerWidget(dlg);
|
||||
dlg->show();
|
||||
}
|
||||
|
||||
void TrayWidget::setBrightColorsOfModelsAccordingToPalette()
|
||||
{
|
||||
auto &qtSettings = Settings::values().qt;
|
||||
|
|
|
@ -96,6 +96,7 @@ private Q_SLOTS:
|
|||
void pauseResumeDev(const Data::SyncthingDev &dev);
|
||||
void pauseResumeDir(const Data::SyncthingDir &dir);
|
||||
void browseRemoteFiles(const Data::SyncthingDir &dir);
|
||||
void showIgnorePatterns(const Data::SyncthingDir &dir);
|
||||
void showRecentChangesContextMenu(const QPoint &position);
|
||||
void changeStatus();
|
||||
void updateTraffic();
|
||||
|
@ -115,6 +116,7 @@ private Q_SLOTS:
|
|||
void handleConnectionSelected(QAction *connectionAction);
|
||||
void concludeWizard(const QString &errorMessage = QString());
|
||||
void showDialog(QWidget *dlg, bool maximized = false);
|
||||
void showCenteredDialog(QWidget *dlg, const QSize &size);
|
||||
void setBrightColorsOfModelsAccordingToPalette();
|
||||
void setLabelPixmaps();
|
||||
void setTrafficPixmaps(bool recompute = false);
|
||||
|
|
Loading…
Reference in New Issue