"Fossies" - the Fresh Open Source Software Archive 
Member "seafile-client-7.0.4/src/filebrowser/sharedlink-dialog.cpp" (19 Nov 2019, 2155 Bytes) of package /linux/www/seafile-client-7.0.4.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "sharedlink-dialog.cpp" see the
Fossies "Dox" file reference documentation.
1 #include "sharedlink-dialog.h"
2
3 #include <QtGlobal>
4 #include <QtWidgets>
5 #include "utils/utils-mac.h"
6
7 SharedLinkDialog::SharedLinkDialog(const QString &text, QWidget *parent)
8 : text_(text)
9 {
10 setWindowTitle(tr("Share Link"));
11 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
12 setWindowIcon(QIcon(":/images/seafile.png"));
13 QVBoxLayout *layout = new QVBoxLayout;
14
15 QLabel *label = new QLabel(tr("Share link:"));
16 layout->addWidget(label);
17 layout->setSpacing(5);
18 layout->setContentsMargins(9, 9, 9, 9);
19
20 editor_ = new QLineEdit;
21 editor_->setText(text_);
22 editor_->selectAll();
23 editor_->setReadOnly(true);
24 layout->addWidget(editor_);
25
26 QHBoxLayout *hlayout = new QHBoxLayout;
27
28 QCheckBox *is_download_checked = new QCheckBox(tr("Direct Download"));
29 connect(is_download_checked, SIGNAL(stateChanged(int)),
30 this, SLOT(onDownloadStateChanged(int)));
31 hlayout->addWidget(is_download_checked);
32
33 QWidget *spacer = new QWidget;
34 spacer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
35 hlayout->addWidget(spacer);
36
37 QWidget *spacer2 = new QWidget;
38 spacer2->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
39 hlayout->addWidget(spacer2);
40
41 QPushButton *copy_to = new QPushButton(tr("Copy to clipboard"));
42 hlayout->addWidget(copy_to);
43 connect(copy_to, SIGNAL(clicked()), this, SLOT(onCopyText()));
44
45 QPushButton *ok = new QPushButton(tr("OK"));
46 hlayout->addWidget(ok);
47 connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
48
49 layout->addLayout(hlayout);
50
51 setLayout(layout);
52
53 setMinimumWidth(300);
54 setMaximumWidth(400);
55 }
56
57 void SharedLinkDialog::onCopyText()
58 {
59 // for mac, qt copys many minedatas beside public.utf8-plain-text
60 // e.g. public.vcard, which we don't want to use
61 #ifndef Q_OS_MAC
62 QApplication::clipboard()->setText(editor_->text());
63 #else
64 utils::mac::copyTextToPasteboard(editor_->text());
65 #endif
66 }
67
68 void SharedLinkDialog::onDownloadStateChanged(int state)
69 {
70 if (state == Qt::Checked)
71 editor_->setText(text_ + "?dl=1");
72 else
73 editor_->setText(text_);
74 }