mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #145 from dubslow/master
Add tooltips to user-provided text (helps to accommodate too-long names)
This commit is contained in:
commit
aab7448384
5
core.cpp
5
core.cpp
|
@ -664,9 +664,9 @@ void Core::setStatus(Status status)
|
|||
void Core::onFileTransferFinished(ToxFile file)
|
||||
{
|
||||
if (file.direction == file.SENDING)
|
||||
emit fileUploadFinished(QString(file.fileName));
|
||||
emit fileUploadFinished(file.filePath);
|
||||
else
|
||||
emit fileDownloadFinished(QString(file.fileName));
|
||||
emit fileDownloadFinished(file.filePath);
|
||||
}
|
||||
|
||||
void Core::bootstrapDht()
|
||||
|
@ -952,6 +952,7 @@ void Core::sendAllFileData(Core *core, ToxFile* file)
|
|||
removeFileFromQueue(true, file->friendId, file->fileNum);
|
||||
return;
|
||||
}
|
||||
qDebug() << "chunkSize: " << chunkSize;
|
||||
chunkSize = std::min(chunkSize, file->filesize);
|
||||
uint8_t* data = new uint8_t[chunkSize];
|
||||
file->file->seek(file->bytesSent);
|
||||
|
|
|
@ -36,12 +36,14 @@ Friend::~Friend()
|
|||
void Friend::setName(QString name)
|
||||
{
|
||||
widget->name.setText(name);
|
||||
widget->name.setToolTip(name); // for overlength names
|
||||
chatForm->setName(name);
|
||||
}
|
||||
|
||||
void Friend::setStatusMessage(QString message)
|
||||
{
|
||||
widget->statusMessage.setText(message);
|
||||
widget->statusMessage.setToolTip(message); // for overlength messsages
|
||||
chatForm->setStatusMessage(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
QT += core gui network multimedia multimediawidgets
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = toxgui
|
||||
TARGET = qtox
|
||||
TEMPLATE = app
|
||||
FORMS += widget.ui
|
||||
CONFIG += c++11
|
|
@ -2697,7 +2697,7 @@ QSplitter:handle{
|
|||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>(button inactive currently)</string>
|
||||
<string>View completed file transfers</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <QFileDialog>
|
||||
#include <QPixmap>
|
||||
#include <QPainter>
|
||||
#include <QMessageBox>
|
||||
|
||||
FileTransfertWidget::FileTransfertWidget(ToxFile File)
|
||||
: lastUpdate{QDateTime::currentDateTime()}, lastBytesSent{0},
|
||||
|
@ -265,11 +266,40 @@ void FileTransfertWidget::rejectRecvRequest()
|
|||
onFileTransferCancelled(friendId, fileNum, direction);
|
||||
}
|
||||
|
||||
// for whatever the fuck reason, QFileInfo::isWritable() always fails for files that don't exist
|
||||
// which makes it useless for our case
|
||||
// since QDir doesn't have an isWritable(), the only option I can think of is to make/delete the file
|
||||
// surely this is a common problem that has a qt-implemented solution?
|
||||
bool isWritable(QString& path)
|
||||
{
|
||||
QFile file(path);
|
||||
bool exists = file.exists();
|
||||
bool out = file.open(QIODevice::WriteOnly);
|
||||
file.close();
|
||||
if (!exists)
|
||||
file.remove();
|
||||
return out;
|
||||
}
|
||||
|
||||
void FileTransfertWidget::acceptRecvRequest()
|
||||
{
|
||||
QString path = QFileDialog::getSaveFileName(0,tr("Save a file","Title of the file saving dialog"),QDir::currentPath()+'/'+filename->text());
|
||||
QString path;
|
||||
while (true)
|
||||
{
|
||||
path = QFileDialog::getSaveFileName(0,tr("Save a file","Title of the file saving dialog"),QDir::currentPath()+'/'+filename->text());
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
else
|
||||
{
|
||||
//bool savable = QFileInfo(path).isWritable();
|
||||
//qDebug() << path << " is writable: " << savable;
|
||||
//qDebug() << "/home/bill/bliss.pdf writable: " << QFileInfo("/home/bill/bliss.pdf").isWritable();
|
||||
if (isWritable(path))
|
||||
break;
|
||||
else
|
||||
QMessageBox::warning(0, tr("Location not writable","Title of permissions popup"), tr("You do not have permission to write that location. Choose another, or cancel the save dialog.", "text of permissions popup"));
|
||||
}
|
||||
}
|
||||
|
||||
savePath = path;
|
||||
|
||||
|
|
|
@ -207,11 +207,13 @@ void ChatForm::show(Ui::Widget &ui)
|
|||
void ChatForm::setName(QString newName)
|
||||
{
|
||||
name->setText(newName);
|
||||
name->setToolTip(newName); // for overlength names
|
||||
}
|
||||
|
||||
void ChatForm::setStatusMessage(QString newMessage)
|
||||
{
|
||||
statusMessage->setText(newMessage);
|
||||
statusMessage->setToolTip(newMessage); // for overlength messsages
|
||||
}
|
||||
|
||||
void ChatForm::onSendTriggered()
|
||||
|
|
|
@ -27,18 +27,25 @@ FilesForm::FilesForm()
|
|||
head->setLayout(&headLayout);
|
||||
headLayout.addWidget(&headLabel);
|
||||
|
||||
main.addTab(&recvd, tr("Downloads"));
|
||||
main.addTab(&sent, tr("Uploads"));
|
||||
recvd = new QListWidget;
|
||||
sent = new QListWidget;
|
||||
|
||||
connect(&sent, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(onUploadFileActivated(QListWidgetItem*)));
|
||||
connect(&recvd, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(onDownloadFileActivated(QListWidgetItem*)));
|
||||
main.addTab(recvd, tr("Downloads"));
|
||||
main.addTab(sent, tr("Uploads"));
|
||||
|
||||
connect(sent, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(onFileActivated(QListWidgetItem*)));
|
||||
connect(recvd, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(onFileActivated(QListWidgetItem*)));
|
||||
|
||||
}
|
||||
|
||||
FilesForm::~FilesForm()
|
||||
{
|
||||
//delete head;
|
||||
// having this line caused a SIGABRT because free() received an invalid pointer
|
||||
#if 0
|
||||
delete recvd; // docs claim this will clean up children
|
||||
delete sent;
|
||||
delete head;
|
||||
#endif
|
||||
// having these lines caused a SIGABRT because free() received an invalid pointer
|
||||
// but since this is only called on program shutdown anyways,
|
||||
// I'm not too bummed about removing it
|
||||
}
|
||||
|
@ -53,14 +60,16 @@ void FilesForm::show(Ui::Widget& ui)
|
|||
|
||||
void FilesForm::onFileDownloadComplete(const QString& path)
|
||||
{
|
||||
QListWidgetItem* tmp = new QListWidgetItem(QIcon(":/ui/acceptFileButton/default.png"), path);
|
||||
recvd.addItem(tmp);
|
||||
ListWidgetItem* tmp = new ListWidgetItem(QIcon(":/ui/acceptFileButton/default.png"), QFileInfo(path).fileName());
|
||||
tmp->path = path;
|
||||
recvd->addItem(tmp);
|
||||
}
|
||||
|
||||
void FilesForm::onFileUploadComplete(const QString& path)
|
||||
{
|
||||
QListWidgetItem* tmp = new QListWidgetItem(QIcon(":/ui/acceptFileButton/default.png"), path);
|
||||
sent.addItem(tmp);
|
||||
ListWidgetItem* tmp = new ListWidgetItem(QIcon(":/ui/acceptFileButton/default.png"), QFileInfo(path).fileName());
|
||||
tmp->path = path;
|
||||
sent->addItem(tmp);
|
||||
}
|
||||
|
||||
// sadly, the ToxFile struct in core only has the file name, not the file path...
|
||||
|
@ -68,16 +77,10 @@ void FilesForm::onFileUploadComplete(const QString& path)
|
|||
// whenever they're not saved anywhere custom, thanks to the hack)
|
||||
// I could do some digging around, but for now I'm tired and others already
|
||||
// might know it without me needing to dig, so...
|
||||
void FilesForm::onDownloadFileActivated(QListWidgetItem* item)
|
||||
void FilesForm::onFileActivated(QListWidgetItem* item)
|
||||
{
|
||||
QUrl url = QUrl::fromLocalFile("./" + item->text());
|
||||
qDebug() << "Opening '" << url << "'";
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
||||
void FilesForm::onUploadFileActivated(QListWidgetItem* item)
|
||||
{
|
||||
QUrl url = QUrl::fromLocalFile(item->text());
|
||||
ListWidgetItem* tmp = dynamic_cast<ListWidgetItem*> (item);
|
||||
QUrl url = QUrl::fromLocalFile(tmp->path);
|
||||
qDebug() << "Opening '" << url << "'";
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
|
||||
class FilesForm : public QObject
|
||||
{
|
||||
|
@ -43,8 +44,7 @@ public slots:
|
|||
void onFileUploadComplete(const QString& path);
|
||||
|
||||
private slots:
|
||||
void onDownloadFileActivated(QListWidgetItem* item);
|
||||
void onUploadFileActivated(QListWidgetItem* item);
|
||||
void onFileActivated(QListWidgetItem* item);
|
||||
|
||||
private:
|
||||
QWidget* head;
|
||||
|
@ -55,10 +55,15 @@ private:
|
|||
I should really look into the new fangled list thingy, to deactivate
|
||||
specific items in the list */
|
||||
QTabWidget main;
|
||||
QListWidget sent, recvd;
|
||||
QListWidget* sent, * recvd;
|
||||
|
||||
};
|
||||
|
||||
#include "ui_widget.h"
|
||||
class ListWidgetItem : public QListWidgetItem
|
||||
{
|
||||
using QListWidgetItem::QListWidgetItem;
|
||||
public:
|
||||
QString path;
|
||||
};
|
||||
|
||||
#endif // FILESFORM_H
|
||||
|
|
|
@ -424,6 +424,7 @@ void Widget::onUsernameChanged()
|
|||
{
|
||||
const QString newUsername = settingsForm.name.text();
|
||||
ui->nameLabel->setText(newUsername);
|
||||
ui->nameLabel->setToolTip(newUsername); // for overlength names
|
||||
settingsForm.name.setText(newUsername);
|
||||
core->setUsername(newUsername);
|
||||
}
|
||||
|
@ -431,6 +432,7 @@ void Widget::onUsernameChanged()
|
|||
void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUsername)
|
||||
{
|
||||
ui->nameLabel->setText(oldUsername); // restore old username until Core tells us to set it
|
||||
ui->nameLabel->setToolTip(oldUsername); // for overlength names
|
||||
settingsForm.name.setText(oldUsername);
|
||||
core->setUsername(newUsername);
|
||||
}
|
||||
|
@ -438,6 +440,7 @@ void Widget::onUsernameChanged(const QString& newUsername, const QString& oldUse
|
|||
void Widget::setUsername(const QString& username)
|
||||
{
|
||||
ui->nameLabel->setText(username);
|
||||
ui->nameLabel->setToolTip(username); // for overlength names
|
||||
settingsForm.name.setText(username);
|
||||
}
|
||||
|
||||
|
@ -445,6 +448,7 @@ void Widget::onStatusMessageChanged()
|
|||
{
|
||||
const QString newStatusMessage = settingsForm.statusText.text();
|
||||
ui->statusLabel->setText(newStatusMessage);
|
||||
ui->statusLabel->setToolTip(newStatusMessage); // for overlength messsages
|
||||
settingsForm.statusText.setText(newStatusMessage);
|
||||
core->setStatusMessage(newStatusMessage);
|
||||
}
|
||||
|
@ -452,6 +456,7 @@ void Widget::onStatusMessageChanged()
|
|||
void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QString& oldStatusMessage)
|
||||
{
|
||||
ui->statusLabel->setText(oldStatusMessage); // restore old status message until Core tells us to set it
|
||||
ui->statusLabel->setToolTip(oldStatusMessage); // for overlength messsages
|
||||
settingsForm.statusText.setText(oldStatusMessage);
|
||||
core->setStatusMessage(newStatusMessage);
|
||||
}
|
||||
|
@ -459,6 +464,7 @@ void Widget::onStatusMessageChanged(const QString& newStatusMessage, const QStri
|
|||
void Widget::setStatusMessage(const QString &statusMessage)
|
||||
{
|
||||
ui->statusLabel->setText(statusMessage);
|
||||
ui->statusLabel->setToolTip(statusMessage); // for overlength messsages
|
||||
settingsForm.statusText.setText(statusMessage);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user