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

Merge branch 'master' of https://github.com/tux3/qTox into profiles

This commit is contained in:
Bill Winslow 2014-07-23 02:50:10 -05:00
commit 8aa451bb5b
3 changed files with 50 additions and 3 deletions

View File

@ -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());
if (path.isEmpty())
return;
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;

View File

@ -190,6 +190,8 @@ Widget::Widget(QWidget *parent) :
ui->pbClose->setMouseTracking(true);
ui->statusHead->setMouseTracking(true);
ui->friendList->viewport()->installEventFilter(this);
QList<int> currentSizes = ui->centralWidget->sizes();
currentSizes[0] = 225;
ui->centralWidget->setSizes(currentSizes);
@ -1220,3 +1222,17 @@ void Widget::setStatusBusy()
{
core->setStatus(Status::Busy);
}
bool Widget::eventFilter(QObject *, QEvent *event)
{
if (event->type() == QEvent::Wheel)
{
QWheelEvent * whlEvnt = static_cast< QWheelEvent * >( event );
if (whlEvnt->angleDelta().x() != 0)
{
event->accept();
return true;
}
}
return false;
}

View File

@ -151,6 +151,7 @@ private:
SelfCamView* camview;
Camera* camera;
bool notify(QObject *receiver, QEvent *event);
bool eventFilter(QObject *, QEvent *event);
};
#endif // WIDGET_H