Skip to content

Commit

Permalink
Merge branch 'drawpile:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
AwesomeQubic authored Dec 2, 2023
2 parents ebb5021 + 275ee01 commit a6ca0a3
Show file tree
Hide file tree
Showing 27 changed files with 848 additions and 311 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ Unreleased Version 2.2.0-pre
* Fix: Don't hide dock titlebars when pressing shift when a text field is in focus, since that might hide a field you're currently typing in. Thanks Trite for reporting.
* Fix: Disable Hold Shift to Arrange by default, since it's not needed most of the time.
* Fix: Don't claim every username is taken when connecting to a server with the old login flow doesn't allow guest logins, instead tell the user that they need an account. Thanks Meru for reporting.
* Fix: Give checkbox outlines more contrast, since they're virtually invisible in most themes. This is a patch to Qt.
* Fix: Change italic to bold text, since the former is not readable in Chinese script.
* Fix: Make keep aspect ratio checkbox in resize dialog keep the current aspect ratio, not the original one.
* Fix: Don't act like keep aspect ratio is checked when resizing from a selection. Thanks Meru for reporting.
* Fix: Make onion skin color partially transparent by default so that they don't turn into solid blocks on colored stuff. Thanks BulletPepper for reporting.
* Fix: Clarify the host dialog by adding additional messages that explain common sources of confusion, such as the title being required, the password being necessary to host a private session and "host on this computer" requiring port forwarding.
* Fix: Prevent jittering pixels on the canvas at certain zooms and rotations. Thanks Bluestrings, Meru and taiyu for reporting this. Also thanks Meru for actually finding the solution and contributing this fix.

2023-11-12 Version 2.2.0-beta.10
* Fix: Don't deadlock on first startup. Thanks to Hail, lowontrash, FARBOL234, Dorokinyo and hamlin for reporting.
Expand Down
10 changes: 1 addition & 9 deletions src/desktop/dialogs/resizedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ void ResizeDialog::setBounds(const QRect &rect)
{
auto rectIn = rect.intersected({{0,0}, m_ui->resizer->originalSize()});

m_aspectratio = rectIn.width() / float(rectIn.height());

m_ui->width->setValue(rectIn.width());
m_ui->height->setValue(rectIn.height());

Expand Down Expand Up @@ -100,13 +98,7 @@ void ResizeDialog::heightChanged(int newHeight)
void ResizeDialog::toggleAspectRatio(bool keep)
{
if(keep) {
m_aspectratio = m_oldsize.width() / float(m_oldsize.height());

if(m_lastchanged==0)
widthChanged(m_ui->width->value());
else
heightChanged(m_ui->height->value());

m_aspectratio = float(m_ui->width->value()) / float(m_ui->height->value());
} else {
m_aspectratio = 0;
}
Expand Down
131 changes: 120 additions & 11 deletions src/desktop/dialogs/startdialog/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
#include <QButtonGroup>
#include <QCheckBox>
#include <QComboBox>
#include <QDesktopServices>
#include <QFormLayout>
#include <QFrame>
#include <QGridLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPalette>
#include <QPushButton>
#include <QRadioButton>
#include <QRandomGenerator>
#include <QScrollArea>
#include <QVBoxLayout>

namespace dialogs {
Expand All @@ -24,9 +28,76 @@ namespace startdialog {
Host::Host(QWidget *parent)
: Page{parent}
{
QVBoxLayout *layout = new QVBoxLayout{this};
QVBoxLayout *widgetLayout = new QVBoxLayout;
widgetLayout->setContentsMargins(0, 0, 0, 0);
setLayout(widgetLayout);

m_notes = new QWidget;
m_notes->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
widgetLayout->addWidget(m_notes);

QVBoxLayout *notesLayout = new QVBoxLayout;
notesLayout->setContentsMargins(0, 0, 0, 0);
m_notes->setLayout(notesLayout);

QHBoxLayout *iconLayout = new QHBoxLayout;
iconLayout->setContentsMargins(0, 0, 0, 0);
notesLayout->addLayout(iconLayout);

iconLayout->addWidget(
utils::makeIconLabel(QIcon::fromTheme("dialog-warning"), m_notes));

QVBoxLayout *labelsLayout = new QVBoxLayout;
labelsLayout->setContentsMargins(0, 0, 0, 0);
iconLayout->addLayout(labelsLayout);

m_titleNote = new QLabel;
m_titleNote->setWordWrap(true);
m_titleNote->setTextFormat(Qt::PlainText);
m_titleNote->setText(tr("A session title is required."));
labelsLayout->addWidget(m_titleNote);

m_passwordNote = new QLabel;
m_passwordNote->setWordWrap(true);
m_passwordNote->setTextFormat(Qt::RichText);
m_passwordNote->setText(
tr("Without a password set, anyone can join your session! If you want "
"to host a private session, choose a password or "
"<a href=\"#\">generate one</a>."));
connect(
m_passwordNote, &QLabel::linkActivated, this, &Host::generatePassword);
labelsLayout->addWidget(m_passwordNote);

m_localHostNote = new QLabel;
m_localHostNote->setWordWrap(true);
m_localHostNote->setTextFormat(Qt::RichText);
m_localHostNote->setText(
tr("Hosting on your computer requires additional setup! "
"<a href=\"#\">Click here for instructions.</a>"));
connect(m_localHostNote, &QLabel::linkActivated, this, [] {
QDesktopServices::openUrl(
QStringLiteral("https://drawpile.net/localhosthelp"));
});
labelsLayout->addWidget(m_localHostNote);

utils::addFormSpacer(notesLayout);
notesLayout->addWidget(utils::makeSeparator());

QScrollArea *scrollArea = new QScrollArea;
scrollArea->setFrameStyle(QFrame::NoFrame);
utils::initKineticScrolling(scrollArea);
widgetLayout->addWidget(scrollArea);

QWidget *scroll = new QWidget;
scroll->setContentsMargins(0, 0, 0, 0);
scrollArea->setWidget(scroll);
scrollArea->setWidgetResizable(true);

QVBoxLayout *layout = new QVBoxLayout;
layout->setAlignment(Qt::AlignTop);
layout->setContentsMargins(0, 0, 0, 0);
scroll->setLayout(layout);
utils::addFormSpacer(layout);

QFormLayout *generalSection = utils::addFormSection(layout);
m_titleEdit = new QLineEdit;
Expand All @@ -37,20 +108,41 @@ Host::Host(QWidget *parent)
connect(
m_titleEdit, &QLineEdit::textChanged, this, &Host::updateHostEnabled);

QHBoxLayout *passwordLayout = new QHBoxLayout;
passwordLayout->setContentsMargins(0, 0, 0, 0);

m_passwordEdit = new QLineEdit;
m_passwordEdit->setEchoMode(QLineEdit::Password);
m_passwordEdit->setToolTip(
tr("Optional. If left blank, no password will be needed "
"to join this session."));
generalSection->addRow(tr("Password:"), m_passwordEdit);
connect(
m_passwordEdit, &QLineEdit::textChanged, this,
&Host::updateHostEnabled);
passwordLayout->addWidget(m_passwordEdit, 1);

QPushButton *generatePasswordButton = new QPushButton(tr("Generate"));
generatePasswordButton->setToolTip(tr("Generates a random password."));
connect(
generatePasswordButton, &QAbstractButton::clicked, this,
&Host::generatePassword);
passwordLayout->addWidget(generatePasswordButton);

generalSection->addRow(tr("Password:"), passwordLayout);

m_nsfmBox = new QCheckBox{tr("Not suitable for minors (NSFM)")};
m_nsfmBox->setToolTip(
tr("Marks the session as having age-restricted content."));
layout->addWidget(m_nsfmBox);
generalSection->addRow(nullptr, m_nsfmBox);

utils::addFormSeparator(layout);

QHBoxLayout *remoteLayout = new QHBoxLayout;
layout->addLayout(remoteLayout);

QRadioButton *useRemoteRadio = new QRadioButton{tr("Host at:")};
useRemoteRadio->setToolTip(tr("Use an external dedicated server"));
remoteLayout->addWidget(useRemoteRadio);

QRadioButton *useLocalRadio = new QRadioButton{tr("Host on this computer")};
useLocalRadio->setToolTip(tr("Use Drawpile's built-in server"));
layout->addWidget(useLocalRadio);
Expand All @@ -68,13 +160,6 @@ Host::Host(QWidget *parent)
utils::addFormSpacer(layout);
#endif

QHBoxLayout *remoteLayout = new QHBoxLayout;
layout->addLayout(remoteLayout);

QRadioButton *useRemoteRadio = new QRadioButton{tr("Host at:")};
useRemoteRadio->setToolTip(tr("Use an external dedicated server"));
remoteLayout->addWidget(useRemoteRadio);

m_useGroup = new QButtonGroup{this};
m_useGroup->addButton(useLocalRadio, USE_LOCAL);
m_useGroup->addButton(useRemoteRadio, USE_REMOTE);
Expand Down Expand Up @@ -124,6 +209,7 @@ Host::Host(QWidget *parent)

desktop::settings::Settings &settings = dpApp().settings();
settings.bindLastSessionTitle(m_titleEdit);
settings.bindLastSessionPassword(m_passwordEdit);
settings.bindLastIdAlias(m_idAliasEdit);
settings.bindLastAnnounce(m_announceBox);

Expand Down Expand Up @@ -188,9 +274,32 @@ void Host::setHostEnabled(bool enabled)

void Host::updateHostEnabled()
{
utils::ScopedUpdateDisabler disabler(this);
bool missingTitle = m_titleEdit->text().trimmed().isEmpty();
bool isPublic = m_passwordEdit->text().isEmpty();
bool isLocal = m_useGroup->checkedId() == USE_LOCAL;
m_titleNote->setVisible(missingTitle);
m_passwordNote->setVisible(isPublic);
m_localHostNote->setVisible(isLocal);
m_notes->setVisible(missingTitle || isPublic || isLocal);
emit enableHost(canHost());
}

void Host::generatePassword()
{
// Passwords are just a mechanism to facilitate invite-only sessions.
// They're not secret and are meant to be shared with anyone who wants to
// join the session, so we don't need cryptographic security for them.
QString characters = QStringLiteral("abcdefghijklmnopqrstuvwxyz0123456789");
QString password;
int length = QRandomGenerator::global()->bounded(8, 12);
for(int i = 0; i < length; ++i) {
password.append(characters[QRandomGenerator::global()->bounded(
0, characters.length())]);
}
dpApp().settings().setLastSessionPassword(password);
}

void Host::updateNsfmBasedOnTitle()
{
bool nsfmTitle = parentalcontrols::isNsfmTitle(m_titleEdit->text());
Expand Down
5 changes: 5 additions & 0 deletions src/desktop/dialogs/startdialog/host.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public slots:
const QString &remoteAddress);

private slots:
void generatePassword();
void updateNsfmBasedOnTitle();
void updateListServers();
void updateRemoteHosts();
Expand All @@ -53,6 +54,10 @@ private slots:

QString getRemoteAddress() const;

QWidget *m_notes;
QLabel *m_titleNote;
QLabel *m_passwordNote;
QLabel *m_localHostNote;
QLineEdit *m_titleEdit;
QLineEdit *m_passwordEdit;
QCheckBox *m_nsfmBox;
Expand Down
51 changes: 38 additions & 13 deletions src/desktop/i18n/drawpile_ar_EG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -857,12 +857,12 @@ to 64x64 pixels.</source>
</message>
<message>
<location line="+29"/>
<source>You&apos;re hosting a session locally. If others can&apos;t join your session, take a look at &lt;a href=&quot;https://drawpile.net/help/hosting/&quot;&gt;the help page on hosting&lt;/a&gt;.</source>
<source>You&apos;re hosting a session locally. If others can&apos;t join your session, take a look at &lt;a href=&quot;https://drawpile.net/localhosthelp&quot;&gt;the help page on hosting&lt;/a&gt;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+45"/>
<source>You&apos;re hosting a session locally, so Drawpile has to find your externally visible IP address to give you an invite link. For more information, check out &lt;a href=&quot;https://drawpile.net/help/hosting/&quot;&gt;the help page on hosting&lt;/a&gt;.</source>
<source>You&apos;re hosting a session locally, so Drawpile has to find your externally visible IP address to give you an invite link. For more information, check out &lt;a href=&quot;https://drawpile.net/localhosthelp&quot;&gt;the help page on hosting&lt;/a&gt;.</source>
<translation type="unfinished"></translation>
</message>
<message>
Expand Down Expand Up @@ -6017,7 +6017,7 @@ Values above 0.5 may not be noticeable.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+46"/>
<location line="+44"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -7880,7 +7880,7 @@ Values above 0.5 may not be noticeable.</source>
<context>
<name>dialogs::startdialog::Host</name>
<message>
<location filename="../dialogs/startdialog/host.cpp" line="+34"/>
<location filename="../dialogs/startdialog/host.cpp" line="+105"/>
<source>The title is shown in the application title bar and in the session selection dialog</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -7890,17 +7890,27 @@ Values above 0.5 may not be noticeable.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="+9"/>
<source>Optional. If left blank, no password will be needed to join this session.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+2"/>
<location line="+7"/>
<source>Generate</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1"/>
<source>Generates a random password.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<source>Password:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+16"/>
<location line="+23"/>
<source>The built-in server is not available on Android.</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -7910,7 +7920,7 @@ Values above 0.5 may not be noticeable.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+36"/>
<location line="+29"/>
<source>Enable advanced options</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -7925,7 +7935,22 @@ Values above 0.5 may not be noticeable.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-60"/>
<location line="-135"/>
<source>A session title is required.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<source>Without a password set, anyone can join your session! If you want to host a private session, choose a password or &lt;a href=&quot;#&quot;&gt;generate one&lt;/a&gt;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+11"/>
<source>Hosting on your computer requires additional setup! &lt;a href=&quot;#&quot;&gt;Click here for instructions.&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+57"/>
<source>Not suitable for minors (NSFM)</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -7945,7 +7970,7 @@ Values above 0.5 may not be noticeable.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="-61"/>
<location line="-54"/>
<source>Host on this computer</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -7955,7 +7980,7 @@ Values above 0.5 may not be noticeable.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+19"/>
<location line="-5"/>
<source>Host at:</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -8080,12 +8105,12 @@ Values above 0.5 may not be noticeable.</source>
</message>
<message>
<location line="+13"/>
<source>The download page for Drawpile %1 should have opened in your browser. If not, please visit &lt;em&gt;drawpile.net&lt;/em&gt; manually.</source>
<source>The download page for Drawpile %1 should have opened in your browser. If not, please visit &lt;strong&gt;drawpile.net&lt;/strong&gt; manually.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<source>The download page for Drawpile %1 could not be opened, please visit &lt;em&gt;drawpile.net&lt;/em&gt; manually.</source>
<source>The download page for Drawpile %1 could not be opened, please visit &lt;strong&gt;drawpile.net&lt;/strong&gt; manually.</source>
<translation type="unfinished"></translation>
</message>
</context>
Expand Down
Loading

0 comments on commit a6ca0a3

Please sign in to comment.