1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #2137 from agilob:tox_core_version

better, more flexible about page, versions section
      hide toxcore version
      fix uri parsing and tox URI detection, closes #2118
      fix uri detection, puts dots between toxcore versions
This commit is contained in:
Zetok Zalbavar 2015-08-29 23:47:29 +01:00
commit 0c6c28bfbb
No known key found for this signature in database
GPG Key ID: C953D3880212068A
5 changed files with 99 additions and 26 deletions

View File

@ -179,8 +179,13 @@ QString ChatMessage::detectAnchors(const QString &str)
{
QString out = str;
// detect urls
QRegExp exp("(?:\\b)(www\\.|http[s]?:\\/\\/|ftp:\\/\\/|tox:\\/\\/|tox:)\\S+");
// detect URIs
QRegExp exp("("
"(?:\\b)(www\\.|http[s]?|ftp)://" // (protocol)://(printable - non-special character)
// http://ONEORMOREALHPA-DIGIT
"\\w+\\S+)" // any other character, lets domains and other
"|(^tox:[@\\w]+$)"); // starts with `tox` then : and only alpha-digits till the end
// also accepts tox:agilob@net as simplified TOX ID
int offset = 0;
while ((offset = exp.indexIn(out, offset)) != -1)
{

View File

@ -57,7 +57,7 @@ bool handleToxURI(const QString &toxURI)
qApp->processEvents();
QString toxaddr;
if (toxURI.startsWith("tox://"))
if (toxURI.startsWith("tox:"))
toxaddr = toxURI.mid(6);
else
toxaddr = toxURI.mid(4);
@ -66,11 +66,13 @@ bool handleToxURI(const QString &toxURI)
if (toxid.isEmpty())
{
QMessageBox::warning(0, "qTox", toxaddr+" is not a valid Tox address.");
QMessageBox::warning(0, "qTox", toxaddr + " is not a valid Tox address.");
}
else
{
ToxURIDialog dialog(0, toxaddr, QObject::tr("%1 here! Tox me maybe?","Default message in Tox URI friend requests. Write something appropriate!").arg(Nexus::getCore()->getUsername()));
ToxURIDialog dialog(0, toxaddr, QObject::tr("%1 here! Tox me maybe?",
"Default message in Tox URI friend requests. Write something appropriate!")
.arg(Nexus::getCore()->getUsername()));
if (dialog.exec() == QDialog::Accepted)
Core::getInstance()->requestFriendship(toxid, dialog.getRequestMessage());
}
@ -81,7 +83,7 @@ ToxURIDialog::ToxURIDialog(QWidget *parent, const QString &userId, const QString
QDialog(parent)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowTitle(tr("Add a friend","Title of the window to add a friend through Tox URI"));
setWindowTitle(tr("Add a friend", "Title of the window to add a friend through Tox URI"));
QLabel *friendsLabel = new QLabel(tr("Do you want to add %1 as a friend?").arg(userId), this);
QLabel *userIdLabel = new QLabel(tr("User ID:"), this);
@ -93,8 +95,8 @@ ToxURIDialog::ToxURIDialog(QWidget *parent, const QString &userId, const QString
QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this);
buttonBox->addButton(tr("Send","Send a friend request"), QDialogButtonBox::AcceptRole);
buttonBox->addButton(tr("Cancel","Don't send a friend request"), QDialogButtonBox::RejectRole);
buttonBox->addButton(tr("Send", "Send a friend request"), QDialogButtonBox::AcceptRole);
buttonBox->addButton(tr("Cancel", "Don't send a friend request"), QDialogButtonBox::RejectRole);
connect(buttonBox, &QDialogButtonBox::accepted, this, &FriendRequestDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &FriendRequestDialog::reject);

View File

@ -21,21 +21,35 @@
#include "aboutform.h"
#include "src/widget/translator.h"
#include "tox/tox.h"
AboutForm::AboutForm() :
GenericForm(QPixmap(":/img/settings/general.png"))
{
bodyUI = new Ui::AboutSettings;
bodyUI->setupUi(this);
//to-do: when we finally have stable releases: build-in a way to tell
//nightly builds from stable releases.
bodyUI->label_4->setText(bodyUI->label_4->text().replace("GIT_VERSION", QString(GIT_VERSION)));
replaceVersions();
if (QString(GIT_VERSION).indexOf(" ") > -1)
bodyUI->label_4->setOpenExternalLinks(false);
bodyUI->gitVersion->setOpenExternalLinks(false);
Translator::registerHandler(std::bind(&AboutForm::retranslateUi, this), this);
}
//to-do: when we finally have stable releases: build-in a way to tell
//nightly builds from stable releases.
void AboutForm::replaceVersions()
{
bodyUI->gitVersion->setText(bodyUI->gitVersion->text().replace("$GIT_VERSION", QString(GIT_VERSION)));
bodyUI->toxCoreVersion->setText(
bodyUI->toxCoreVersion->text().replace("$TOXCOREVERSION",
QString::number(TOX_VERSION_MAJOR) + "." +
QString::number(TOX_VERSION_MINOR) + "." +
QString::number(TOX_VERSION_PATCH)));
//TODO show when toxcore supports versioning #2086
bodyUI->toxCoreVersion->hide();
}
AboutForm::~AboutForm()
{
Translator::unregister(this);
@ -45,5 +59,5 @@ AboutForm::~AboutForm()
void AboutForm::retranslateUi()
{
bodyUI->retranslateUi(this);
bodyUI->label_4->setText(bodyUI->label_4->text().replace("GIT_VERSION", QString(GIT_VERSION)));
replaceVersions();
}

View File

@ -42,6 +42,7 @@ private slots:
private:
void retranslateUi();
void replaceVersions();
private:
Ui::AboutSettings* bodyUI;

View File

@ -29,9 +29,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-54</y>
<width>492</width>
<height>508</height>
<y>0</y>
<width>494</width>
<height>554</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1,0,0">
@ -52,9 +52,9 @@
<property name="title">
<string>Version</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="youareusing">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@ -70,7 +70,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;You are using a qTox nightly build.&lt;/p&gt;&lt;p&gt;Commit hash: &lt;a href=&quot;https://github.com/tux3/qTox/commit/GIT_VERSION&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;GIT_VERSION&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>You are using a qTox nightly build.</string>
</property>
<property name="indent">
<number>-1</number>
@ -83,6 +83,57 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="gitVersion">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
</font>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="text">
<string>Commit hash: &lt;a href=&quot;https://github.com/tux3/qTox/commit/$GIT_VERSION&quot;&gt;$GIT_VERSION&lt;/a&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="toxCoreVersion">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Sans Serif</family>
</font>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="text">
<string>ToxCore version: $TOXCOREVERSION</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -125,12 +176,12 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; color:#000000;&quot;&gt;Copyright © 2014-2015 by The qTox Project&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;qTox is a Qt-based graphical interface for Tox.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;qTox is libre software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt;&quot;&gt;qTox is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;You should have received a copy of the GNU General Public License along with this program. If not, see &lt;/span&gt;&lt;a href=&quot;https://www.gnu.org/copyleft/gpl.html&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt; text-decoration: underline; color:#007af4;&quot;&gt;https://www.gnu.org/copyleft/gpl.html&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Oxygen-Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif'; color:#000000;&quot;&gt;Copyright © 2014-2015 by The qTox Project&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu';&quot;&gt;qTox is a Qt-based graphical interface for Tox.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif';&quot;&gt;qTox is libre software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Sans Serif';&quot;&gt;qTox is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. &lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu';&quot;&gt;You should have received a copy of the GNU General Public License along with this program. If not, see &lt;/span&gt;&lt;a href=&quot;https://www.gnu.org/copyleft/gpl.html&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; text-decoration: underline; color:#007af4;&quot;&gt;https://www.gnu.org/copyleft/gpl.html&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Ubuntu';&quot;&gt;.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="searchPaths">
<stringlist/>