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

Merge pull request #3495

Diadlo (5):
      style(widget): Style fixes
      style(audio, video): Style fixes
      style(chatlog, persistence): Style fixes
      style(platform): Style fixes
      style(core): Style fixes
This commit is contained in:
sudden6 2016-07-13 21:23:26 +02:00
commit c76d139172
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
42 changed files with 229 additions and 218 deletions

View File

@ -131,5 +131,7 @@
<file>ui/loginScreen/loginScreen.css</file>
<file>img/others/logout-icon.svg</file>
<file>img/caps_lock.svg</file>
<file>ui/contentDialog/contentDialog.css</file>
<file>ui/tooliconsZone/tooliconsZone.css</file>
</qresource>
</RCC>

View File

@ -582,15 +582,6 @@ void Audio::doCapture()
emit frameAvailable(buf, AUDIO_FRAME_SAMPLE_COUNT, AUDIO_CHANNELS, AUDIO_SAMPLE_RATE);
}
/**
Returns true if the input device is open and suscribed to
*/
bool Audio::isInputReady() const
{
QMutexLocker locker(&audioLock);
return alInDev && inSubscriptions;
}
/**
Returns true if the output device is open
*/

View File

@ -63,21 +63,24 @@ public:
qreal minInputGain() const;
void setMinInputGain(qreal dB);
qreal maxInputGain() const;
void setMaxInputGain(qreal dB);
qreal inputGain() const;
void setInputGain(qreal dB);
void reinitInput(const QString& inDevDesc);
bool reinitOutput(const QString& outDevDesc);
bool isInputReady() const;
bool isOutputReady() const;
static QStringList outDeviceNames();
static QStringList inDeviceNames();
void subscribeOutput(ALuint& sid);
void unsubscribeOutput(ALuint& sid);
void subscribeInput();
void unsubscribeInput();

View File

@ -69,20 +69,29 @@ ChatLog::ChatLog(QWidget* parent)
copyAction->setIcon(QIcon::fromTheme("edit-copy"));
copyAction->setShortcut(QKeySequence::Copy);
copyAction->setEnabled(false);
connect(copyAction, &QAction::triggered, this, [this]() { copySelectedText(); });
connect(copyAction, &QAction::triggered, this, [this]()
{
copySelectedText();
});
addAction(copyAction);
#ifdef Q_OS_LINUX
// Ctrl+Insert shortcut
QShortcut* copyCtrlInsShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Insert), this);
connect(copyCtrlInsShortcut, &QShortcut::activated, this, [this]() { copySelectedText(); });
connect(copyCtrlInsShortcut, &QShortcut::activated, this, [this]()
{
copySelectedText();
});
#endif
// select all action (ie. Ctrl+A)
selectAllAction = new QAction(this);
selectAllAction->setIcon(QIcon::fromTheme("edit-select-all"));
selectAllAction->setShortcut(QKeySequence::SelectAll);
connect(selectAllAction, &QAction::triggered, this, [this]() { selectAll(); });
connect(selectAllAction, &QAction::triggered, this, [this]()
{
selectAll();
});
addAction(selectAllAction);
// This timer is used to scroll the view while the user is

View File

@ -618,7 +618,7 @@ int Core::sendAction(uint32_t friendId, const QString &action)
void Core::sendTyping(uint32_t friendId, bool typing)
{
bool ret = tox_self_set_typing(tox, friendId, typing, nullptr);
if (ret == false)
if (!ret)
emit failedToSetTyping(typing);
}
@ -656,9 +656,9 @@ void Core::changeGroupTitle(int groupId, const QString& title)
emit groupTitleChanged(groupId, getUsername(), title);
}
void Core::sendFile(uint32_t friendId, QString Filename, QString FilePath, long long filesize)
void Core::sendFile(uint32_t friendId, QString filename, QString filePath, long long filesize)
{
CoreFile::sendFile(this, friendId, Filename, FilePath, filesize);
CoreFile::sendFile(this, friendId, filename, filePath, filesize);
}
void Core::sendAvatarFile(uint32_t friendId, const QByteArray& data)
@ -701,15 +701,14 @@ void Core::removeFriend(uint32_t friendId, bool fake)
if (!isReady() || fake)
return;
if (tox_friend_delete(tox, friendId, nullptr) == false)
if (!tox_friend_delete(tox, friendId, nullptr))
{
emit failedToRemoveFriend(friendId);
return;
}
else
{
profile.saveToxSave();
emit friendRemoved(friendId);
}
profile.saveToxSave();
emit friendRemoved(friendId);
}
void Core::removeGroup(int groupId, bool fake)
@ -741,16 +740,15 @@ void Core::setUsername(const QString& username)
CString cUsername(username);
if (tox_self_set_name(tox, cUsername.data(), cUsername.size(), nullptr) == false)
if (!tox_self_set_name(tox, cUsername.data(), cUsername.size(), nullptr))
{
emit failedToSetUsername(username);
return;
}
else
{
emit usernameSet(username);
if (ready)
profile.saveToxSave();
}
emit usernameSet(username);
if (ready)
profile.saveToxSave();
}
void Core::setAvatar(const QByteArray& data)
@ -817,16 +815,15 @@ void Core::setStatusMessage(const QString& message)
CString cMessage(message);
if (tox_self_set_status_message(tox, cMessage.data(), cMessage.size(), nullptr) == false)
if (!tox_self_set_status_message(tox, cMessage.data(), cMessage.size(), nullptr))
{
emit failedToSetStatusMessage(message);
return;
}
else
{
if (ready)
profile.saveToxSave();
emit statusMessageSet(message);
}
if (ready)
profile.saveToxSave();
emit statusMessageSet(message);
}
void Core::setStatus(Status status)
@ -1188,7 +1185,7 @@ QString Core::getPeerName(const ToxId& id) const
return name;
uint8_t* cname = new uint8_t[nameSize<TOX_MAX_NAME_LENGTH ? TOX_MAX_NAME_LENGTH : nameSize];
if (tox_friend_get_name(tox, friendId, cname, nullptr) == false)
if (!tox_friend_get_name(tox, friendId, cname, nullptr))
{
qWarning() << "getPeerName: Can't get name of friend "+QString().setNum(friendId);
delete[] cname;

View File

@ -115,7 +115,7 @@ public slots:
int sendAction(uint32_t friendId, const QString& action);
void sendTyping(uint32_t friendId, bool typing);
void sendFile(uint32_t friendId, QString Filename, QString FilePath, long long filesize);
void sendFile(uint32_t friendId, QString filename, QString filePath, long long filesize);
void sendAvatarFile(uint32_t friendId, const QByteArray& data);
void cancelFileSend(uint32_t friendId, uint32_t fileNum);
void cancelFileRecv(uint32_t friendId, uint32_t fileNum);

View File

@ -171,7 +171,7 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
}
qDebug() << QString("Starting call with %1").arg(friendNum);
if(calls.contains(friendNum))
if (calls.contains(friendNum))
{
qWarning() << QString("Can't start call with %1, we're already in this call!").arg(friendNum);
return false;
@ -545,12 +545,13 @@ void CoreAV::stateCallback(ToxAV* toxav, uint32_t friendNum, uint32_t state, voi
return;
}
if(!self->calls.contains(friendNum))
if (!self->calls.contains(friendNum))
{
qWarning() << QString("stateCallback called, but call %1 is already dead").arg(friendNum);
self->threadSwitchLock.clear(std::memory_order_release);
return;
}
ToxFriendCall& call = self->calls[friendNum];
if (state & TOXAV_FRIEND_CALL_STATE_ERROR)

View File

@ -77,7 +77,6 @@ void CoreFile::sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& d
qWarning() << "sendAvatarFile: Can't create the Tox file sender, error"<<err;
return;
}
//qDebug() << QString("sendAvatarFile: Created file sender %1 with friend %2").arg(fileNum).arg(friendId);
ToxFile file{fileNum, friendId, "", "", ToxFile::SENDING};
file.filesize = filesize;
@ -89,22 +88,22 @@ void CoreFile::sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& d
addFile(friendId, fileNum, file);
}
void CoreFile::sendFile(Core* core, uint32_t friendId, QString Filename, QString FilePath, long long filesize)
void CoreFile::sendFile(Core* core, uint32_t friendId, QString filename, QString filePath, long long filesize)
{
QMutexLocker mlocker(&fileSendMutex);
QByteArray fileName = Filename.toUtf8();
QByteArray fileName = filename.toUtf8();
uint32_t fileNum = tox_file_send(core->tox, friendId, TOX_FILE_KIND_DATA, filesize, nullptr,
(uint8_t*)fileName.data(), fileName.size(), nullptr);
if (fileNum == std::numeric_limits<uint32_t>::max())
{
qWarning() << "sendFile: Can't create the Tox file sender";
emit core->fileSendFailed(friendId, Filename);
emit core->fileSendFailed(friendId, filename);
return;
}
qDebug() << QString("sendFile: Created file sender %1 with friend %2").arg(fileNum).arg(friendId);
ToxFile file{fileNum, friendId, fileName, FilePath, ToxFile::SENDING};
ToxFile file{fileNum, friendId, fileName, filePath, ToxFile::SENDING};
file.filesize = filesize;
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
tox_file_get_file_id(core->tox, friendId, fileNum, (uint8_t*)file.resumeFileId.data(), nullptr);
@ -350,7 +349,6 @@ void CoreFile::onFileControlCallback(Tox*, uint32_t friendId, uint32_t fileId,
void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId,
uint64_t pos, size_t length, void* core)
{
//qDebug() << "File data req of "<<length<<" at "<<pos<<" for file "<<friendId<<':'<<fileId;
ToxFile* file = findFile(friendId, fileId);
if (!file)
@ -362,7 +360,6 @@ void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId,
// If we reached EOF, ack and cleanup the transfer
if (!length)
{
//qDebug("onFileDataCallback: File sending completed");
if (file->fileKind != TOX_FILE_KIND_AVATAR)
{
emit static_cast<Core*>(core)->fileTransferFinished(*file);
@ -408,9 +405,6 @@ void CoreFile::onFileDataCallback(Tox *tox, uint32_t friendId, uint32_t fileId,
void CoreFile::onFileRecvChunkCallback(Tox *tox, uint32_t friendId, uint32_t fileId, uint64_t position,
const uint8_t *data, size_t length, void *_core)
{
//qDebug() << QString("Received chunk for %1:%2 pos %3 size %4")
// .arg(friendId).arg(fileId).arg(position).arg(length);
Core* core = static_cast<Core*>(_core);
ToxFile* file = findFile(friendId, fileId);
if (!file)

View File

@ -46,7 +46,7 @@ private:
// Internal file sending APIs, used by Core. Public API in core.h
private:
static void sendFile(Core *core, uint32_t friendId, QString Filename, QString FilePath, long long filesize);
static void sendFile(Core *core, uint32_t friendId, QString filename, QString filePath, long long filesize);
static void sendAvatarFile(Core* core, uint32_t friendId, const QByteArray& data);
static void pauseResumeFileSend(Core* core, uint32_t friendId, uint32_t fileId);
static void pauseResumeFileRecv(Core* core, uint32_t friendId, uint32_t fileId);

View File

@ -6,9 +6,9 @@
#define TOX_HEX_ID_LENGTH 2*TOX_ADDRESS_SIZE
ToxFile::ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString FilePath, FileDirection Direction)
: fileKind{TOX_FILE_KIND_DATA}, fileNum(FileNum), friendId(FriendId), fileName{FileName},
filePath{FilePath}, file{new QFile(filePath)}, bytesSent{0}, filesize{0},
ToxFile::ToxFile(uint32_t fileNum, uint32_t friendId, QByteArray filename, QString filePath, FileDirection Direction)
: fileKind{TOX_FILE_KIND_DATA}, fileNum(fileNum), friendId(friendId), fileName{filename},
filePath{filePath}, file{new QFile(filePath)}, bytesSent{0}, filesize{0},
status{STOPPED}, direction{Direction}
{
}

View File

@ -36,7 +36,7 @@ struct ToxFile
};
ToxFile()=default;
ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString FilePath, FileDirection Direction);
ToxFile(uint32_t FileNum, uint32_t FriendId, QByteArray FileName, QString filePath, FileDirection Direction);
~ToxFile(){}
bool operator==(const ToxFile& other) const;

View File

@ -31,11 +31,11 @@
#include "src/group.h"
Friend::Friend(uint32_t FriendId, const ToxId &UserId)
: userName{Core::getInstance()->getPeerName(UserId)},
userID{UserId}, friendId{FriendId}
: userName{Core::getInstance()->getPeerName(UserId)}
, userID(UserId), friendId(FriendId)
, hasNewEvents(0), friendStatus(Status::Offline)
{
hasNewEvents = 0;
friendStatus = Status::Offline;
if (userName.size() == 0)
userName = UserId.publicKey;

View File

@ -189,14 +189,13 @@ void Nexus::showMainGUI()
connect(core, &Core::groupNamelistChanged, widget, &Widget::onGroupNamelistChanged);
connect(core, &Core::groupTitleChanged, widget, &Widget::onGroupTitleChanged);
connect(core, &Core::groupPeerAudioPlaying, widget, &Widget::onGroupPeerAudioPlaying);
connect(core, &Core::emptyGroupCreated, widget, &Widget::onEmptyGroupCreated);
connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged);
connect(core, &Core::emptyGroupCreated, widget, &Widget::onEmptyGroupCreated);
connect(core, &Core::friendTypingChanged, widget, &Widget::onFriendTypingChanged);
connect(core, &Core::messageSentResult, widget, &Widget::onMessageSendResult);
connect(core, &Core::groupSentResult, widget, &Widget::onGroupSendResult);
connect(core, &Core::messageSentResult, widget, &Widget::onMessageSendResult);
connect(core, &Core::groupSentResult, widget, &Widget::onGroupSendResult);
connect(widget, &Widget::statusSet, core, &Core::setStatus);
connect(widget, &Widget::friendRequested, core, &Core::requestFriendship);
connect(widget, &Widget::statusSet, core, &Core::setStatus);
connect(widget, &Widget::friendRequested, core, &Core::requestFriendship);
connect(widget, &Widget::friendRequestAccepted, core, &Core::acceptFriendRequest);
profile->startCore();
@ -221,6 +220,7 @@ Core* Nexus::getCore()
Nexus& nexus = getInstance();
if (!nexus.profile)
return nullptr;
return nexus.profile->getCore();
}

View File

@ -328,7 +328,7 @@ void Profile::saveToxSave(QByteArray data)
saveFile.write(data);
// check if everything got written
if(saveFile.flush())
if (saveFile.flush())
{
saveFile.commit();
newProfile = false;
@ -511,23 +511,23 @@ QVector<QString> Profile::remove()
QVector<QString> ret;
if(!profileMain.remove() && profileMain.exists())
if (!profileMain.remove() && profileMain.exists())
{
ret.push_back(profileMain.fileName());
qWarning() << "Could not remove file " << profileMain.fileName();
}
if(!profileConfig.remove() && profileConfig.exists())
if (!profileConfig.remove() && profileConfig.exists())
{
ret.push_back(profileConfig.fileName());
qWarning() << "Could not remove file " << profileConfig.fileName();
}
if(!historyLegacyUnencrypted.remove() && historyLegacyUnencrypted.exists())
if (!historyLegacyUnencrypted.remove() && historyLegacyUnencrypted.exists())
{
ret.push_back(historyLegacyUnencrypted.fileName());
qWarning() << "Could not remove file " << historyLegacyUnencrypted.fileName();
}
if(!historyLegacyEncrypted.remove() && historyLegacyEncrypted.exists())
if (!historyLegacyEncrypted.remove() && historyLegacyEncrypted.exists())
{
ret.push_back(historyLegacyEncrypted.fileName());
qWarning() << "Could not remove file " << historyLegacyUnencrypted.fileName();
@ -535,7 +535,7 @@ QVector<QString> Profile::remove()
if (history)
{
if(!history->remove() && QFile::exists(History::getDbPath(name)))
if (!history->remove() && QFile::exists(History::getDbPath(name)))
{
ret.push_back(History::getDbPath(name));
qWarning() << "Could not remove file " << History::getDbPath(name);

View File

@ -283,7 +283,7 @@ void SettingsSerializer::save()
f.write(data);
// check if everything got written
if(f.flush())
if (f.flush())
{
f.commit();
}
@ -412,10 +412,10 @@ void SettingsSerializer::readIni()
// Add all keys
if (!s.group().isEmpty())
beginGroup(s.group());
for (QString k : s.childKeys())
{
setValue(k, s.value(k));
//qDebug() << "Read key "<<k<<" in group "<<group<<":\""<<groups[group]<<"\"";
}
// Add all groups
@ -492,7 +492,6 @@ void SettingsSerializer::readIni()
groupsToKill.append(v.group);
arrays.append(a);
values.removeAt(i);
//qDebug() << "Found array"<<a.name<<"in group"<<a.group<<"size"<<a.size;
}
// Associate each array's values with the array
@ -514,7 +513,6 @@ void SettingsSerializer::readIni()
if (!ok)
continue;
groupsToKill.append(g);
//qDebug() << "Found element"<<groupArrayIndex<<"of array"<<a.name;
if (groupArrayIndex > a.size)
a.size = groupArrayIndex;
@ -530,7 +528,6 @@ void SettingsSerializer::readIni()
v.array = ai;
v.arrayIndex = groupArrayIndex;
a.values.append(vi);
//qDebug() << "Found key"<<v.key<<"at index"<<groupArrayIndex<<"of array"<<a.name;
}
}
}
@ -541,7 +538,7 @@ void SettingsSerializer::readIni()
{
if (groupSizes[g])
continue;
//qDebug() << "Removing spurious array group"<<g<<groupSizes[g];
removeGroup(g);
}

View File

@ -36,16 +36,8 @@ bool Platform::setAutorun(bool on)
autoRun.setValue("Label","chat.tox.qtox.autorun");
autoRun.setValue("Program", qtoxDir);
if (on)
{
autoRun.setValue("RunAtLoad",true);
state = true;
}
else
{
autoRun.setValue("RunAtLoad",false);
state = false;
}
state = on;
autoRun.setValue("RunAtLoad", state);
}
bool Platform::getAutorun()

View File

@ -97,7 +97,7 @@ static QVector<unsigned short> getDeviceModeFramerates(int fd, unsigned w, unsig
vfve.height = h;
vfve.width = w;
while(!ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &vfve)) {
while (!ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &vfve)) {
int rate;
switch (vfve.type) {
case V4L2_FRMSIZE_TYPE_DISCRETE:
@ -128,13 +128,15 @@ QVector<VideoMode> v4l2::getDeviceModes(QString devName)
v4l2_fmtdesc vfd{};
vfd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
while(!ioctl(fd, VIDIOC_ENUM_FMT, &vfd)) {
while (!ioctl(fd, VIDIOC_ENUM_FMT, &vfd))
{
vfd.index++;
v4l2_frmsizeenum vfse{};
vfse.pixel_format = vfd.pixelformat;
while(!ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &vfse)) {
while (!ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &vfse))
{
VideoMode mode;
mode.pixel_format = vfse.pixel_format;
switch (vfse.type) {
@ -150,6 +152,7 @@ QVector<VideoMode> v4l2::getDeviceModes(QString devName)
default:
continue;
}
QVector<unsigned short> rates = getDeviceModeFramerates(fd, mode.width, mode.height, vfd.pixelformat);
for (unsigned short rate : rates)
{

View File

@ -95,25 +95,24 @@ void osx::migrateProfiles()
+ "Library" + QDir::separator() + "Application Support" + QDir::separator() + "Tox");
QDir dir;
if (checkDir.exists() && checkDir.isDir())
{
qDebug() << "OS X: Old settings directory detected migrating to default";
if( !dir.rename(oldPath, newPath) )
{
qDebug() << "OS X: Profile migration failed. ~/Library/Application Support/Tox already exists. Using alternate migration method.";
QString OSXMigrater = "../Resources/OSX-Migrater.sh" ;
QProcess::execute(OSXMigrater);
QMessageBox MigrateProfile;
MigrateProfile.setIcon(QMessageBox::Information);
MigrateProfile.setWindowModality(Qt::ApplicationModal);
MigrateProfile.setText("Alternate profile migration method used.");
MigrateProfile.setInformativeText("It has been detected that your profiles \nwhere migrated to the new settings directory; \nusing the alternate migration method. \n\nA backup can be found in your: \n/Users/[USER]/.Tox-Backup[DATE-TIME] \n\nJust in case. \r\n");
MigrateProfile.exec();
}
}
else
if (!checkDir.exists() || !checkDir.isDir())
{
qDebug() << "OS X: Old settings directory not detected";
return;
}
qDebug() << "OS X: Old settings directory detected migrating to default";
if (!dir.rename(oldPath, newPath))
{
qDebug() << "OS X: Profile migration failed. ~/Library/Application Support/Tox already exists. Using alternate migration method.";
QString OSXMigrater = "../Resources/OSX-Migrater.sh" ;
QProcess::execute(OSXMigrater);
QMessageBox MigrateProfile;
MigrateProfile.setIcon(QMessageBox::Information);
MigrateProfile.setWindowModality(Qt::ApplicationModal);
MigrateProfile.setText("Alternate profile migration method used.");
MigrateProfile.setInformativeText("It has been detected that your profiles \nwhere migrated to the new settings directory; \nusing the alternate migration method. \n\nA backup can be found in your: \n/Users/[USER]/.Tox-Backup[DATE-TIME] \n\nJust in case. \r\n");
MigrateProfile.exec();
}
}
// End migrateProfiles() compatibility code

View File

@ -194,13 +194,14 @@ CameraDevice* CameraDevice::open(QString devName, VideoMode mode)
#endif
else if (mode)
{
qWarning() << "Video mode-setting not implemented for input "<<iformat->name;
(void)mode;
qWarning() << "Video mode-setting not implemented for input " << iformat->name;
Q_UNUSED(mode);
}
CameraDevice* dev = open(devName, &options);
if (options)
av_dict_free(&options);
return dev;
}
@ -367,6 +368,8 @@ QVector<VideoMode> CameraDevice::getScreenModes()
QVector<VideoMode> CameraDevice::getVideoModes(QString devName)
{
Q_UNUSED(devName);
if (!iformat);
else if (isScreen(devName))
return getScreenModes();
@ -385,7 +388,6 @@ QVector<VideoMode> CameraDevice::getVideoModes(QString devName)
else
qWarning() << "Video mode listing not implemented for input "<<iformat->name;
(void)devName;
return {};
}

View File

@ -137,8 +137,9 @@ CameraSource::~CameraSource()
if (device)
{
for(int i = 0; i < subscriptions; i++)
for (int i = 0; i < subscriptions; i++)
device->close();
device = nullptr;
}
@ -241,7 +242,7 @@ bool CameraSource::openDevice()
// Find the first video stream
for (unsigned i = 0; i < device->context->nb_streams; i++)
{
if(device->context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
if (device->context->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO)
{
videoStreamIndex = i;
break;
@ -257,7 +258,7 @@ bool CameraSource::openDevice()
// Get a pointer to the codec context for the video stream
cctxOrig = device->context->streams[videoStreamIndex]->codec;
codec = avcodec_find_decoder(cctxOrig->codec_id);
if(!codec)
if (!codec)
{
qWarning() << "Codec not found";
return false;
@ -265,7 +266,7 @@ bool CameraSource::openDevice()
// Copy context, since we apparently aren't allowed to use the original
cctx = avcodec_alloc_context3(codec);
if(avcodec_copy_context(cctx, cctxOrig) != 0)
if (avcodec_copy_context(cctx, cctxOrig) != 0)
{
qWarning() << "Can't copy context";
return false;
@ -274,7 +275,7 @@ bool CameraSource::openDevice()
cctx->refcounted_frames = 1;
// Open codec
if(avcodec_open2(cctx, codec, nullptr)<0)
if (avcodec_open2(cctx, codec, nullptr)<0)
{
qWarning() << "Can't open codec";
avcodec_free_context(&cctx);

View File

@ -254,52 +254,25 @@ void CategoryWidget::onCompactChanged(bool _compact)
topLayout->setSpacing(0);
topLayout->setMargin(0);
(void)_compact;
Q_UNUSED(_compact);
setCompact(true);
if (true)
{
nameLabel->minimizeMaximumWidth();
nameLabel->minimizeMaximumWidth();
mainLayout = nullptr;
mainLayout = nullptr;
container->setFixedHeight(25);
container->setLayout(topLayout);
container->setFixedHeight(25);
container->setLayout(topLayout);
topLayout->addSpacing(18);
topLayout->addWidget(&statusPic);
topLayout->addSpacing(5);
topLayout->addWidget(nameLabel, 100);
topLayout->addWidget(lineFrame, 1);
topLayout->addSpacing(5);
topLayout->addWidget(statusLabel);
topLayout->addSpacing(5);
topLayout->activate();
}
/*else
{
nameLabel->setMaximumWidth(QWIDGETSIZE_MAX);
mainLayout = new QVBoxLayout();
mainLayout->setSpacing(0);
mainLayout->setContentsMargins(20, 0, 20, 0);
container->setFixedHeight(25);
container->setLayout(mainLayout);
topLayout->addWidget(&statusPic);
topLayout->addSpacing(10);
topLayout->addWidget(nameLabel, 1);
topLayout->addSpacing(5);
topLayout->addWidget(statusLabel);
topLayout->activate();
mainLayout->addStretch();
mainLayout->addLayout(topLayout);
mainLayout->addWidget(lineFrame);
mainLayout->addStretch();
mainLayout->activate();
}*/
topLayout->addSpacing(18);
topLayout->addWidget(&statusPic);
topLayout->addSpacing(5);
topLayout->addWidget(nameLabel, 100);
topLayout->addWidget(lineFrame, 1);
topLayout->addSpacing(5);
topLayout->addWidget(statusLabel);
topLayout->addSpacing(5);
topLayout->activate();
Style::repolish(this);
}

View File

@ -59,7 +59,7 @@ ContentDialog::ContentDialog(SettingsWidget* settingsWidget, QWidget* parent)
boxLayout->setSpacing(0);
splitter = new QSplitter(this);
setStyleSheet("QSplitter{color: rgb(255, 255, 255);background-color: rgb(255, 255, 255);alternate-background-color: rgb(255, 255, 255);border-color: rgb(255, 255, 255);gridline-color: rgb(255, 255, 255);selection-color: rgb(255, 255, 255);selection-background-color: rgb(255, 255, 255);}QSplitter:handle{color: rgb(255, 255, 255);background-color: rgb(255, 255, 255);}");
setStyleSheet(Style::getStylesheet(":/ui/contentDialog/contentDialog.css"));
splitter->setHandleWidth(6);
QWidget *friendWidget = new QWidget();
@ -455,7 +455,7 @@ void ContentDialog::updateTitleAndStatusIcon(const QString& username)
setWindowTitle(displayWidget->getTitle() + QStringLiteral(" - ") + username);
// it's null when it's a groupchat
if(displayWidget->getFriend() == nullptr)
if (displayWidget->getFriend() == nullptr)
{
setWindowIcon(QIcon(":/img/group.svg"));
return;
@ -611,7 +611,7 @@ void ContentDialog::moveEvent(QMoveEvent* event)
void ContentDialog::keyPressEvent(QKeyEvent* event)
{
if(event->key() != Qt::Key_Escape)
if (event->key() != Qt::Key_Escape)
QDialog::keyPressEvent(event); // Ignore escape keyboard shortcut.
}

View File

@ -133,13 +133,12 @@ void AddFriendForm::setMode(Mode mode)
bool AddFriendForm::addFriendRequest(const QString &friendAddress, const QString &message)
{
if(Settings::getInstance().addFriendRequest(friendAddress, message))
if (Settings::getInstance().addFriendRequest(friendAddress, message))
{
addFriendRequestWidget(friendAddress, message);
if(isShown())
{
if (isShown())
onCurrentChanged(tabWidget->currentIndex());
}
return true;
}
return false;
@ -197,13 +196,14 @@ void AddFriendForm::onIdChanged(const QString &id)
QString toxIdText(tr("Tox ID", "Tox ID of the person you're sending a friend request to"));
QString toxIdComment(tr("either 76 hexadecimal characters or name@example.com", "Tox ID format description"));
if(isValidId)
if (isValidId)
{
toxIdLabel.setText(toxIdText +
QStringLiteral(" (") +
toxIdComment +
QStringLiteral(")"));
} else
}
else
{
toxIdLabel.setText(toxIdText +
QStringLiteral(" <font color='red'>(") +

View File

@ -119,7 +119,7 @@ ChatForm::ChatForm(Friend* chatFriend)
connect(this, &ChatForm::chatAreaCleared, getOfflineMsgEngine(), &OfflineMsgEngine::removeAllReceipts);
connect(statusMessageLabel, &CroppingLabel::customContextMenuRequested, this, [&](const QPoint& pos)
{
if(!statusMessageLabel->text().isEmpty())
if (!statusMessageLabel->text().isEmpty())
{
QWidget* sender = static_cast<QWidget*>(this->sender());
@ -580,7 +580,7 @@ void ChatForm::onEnableCallButtons()
void ChatForm::onMicMuteToggle()
{
if (audioInputFlag == true)
if (audioInputFlag)
{
coreav->micMuteToggle(f->getFriendID());
if (micButton->objectName() == "red")
@ -600,7 +600,7 @@ void ChatForm::onMicMuteToggle()
void ChatForm::onVolMuteToggle()
{
if (audioOutputFlag == true)
if (audioOutputFlag)
{
coreav->volMuteToggle(f->getFriendID());
if (volButton->objectName() == "red")

View File

@ -92,6 +92,12 @@ private slots:
private:
void retranslateUi();
void showOutgoingCall(bool video);
void startCounter();
void stopCounter();
QString secondsToDHMS(quint32 duration);
void enableCallButtons();
void disableCallButtons();
void SendMessageStr(QString msg);
protected:
virtual GenericNetCamView* createNetcam() final override;
@ -117,14 +123,8 @@ private:
ScreenshotGrabber* screenshotGrabber;
QHash<uint, FileTransferInstance*> ftransWidgets;
void startCounter();
void stopCounter();
QString secondsToDHMS(quint32 duration);
CallConfirmWidget *callConfirm;
void enableCallButtons();
void disableCallButtons();
bool isTyping;
void SendMessageStr(QString msg);
};
#endif // CHATFORM_H

View File

@ -243,7 +243,7 @@ void GenericChatForm::showFileMenu()
void GenericChatForm::hideFileMenu()
{
if(fileFlyout->isShown() || fileFlyout->isBeingShown())
if (fileFlyout->isShown() || fileFlyout->isBeingShown())
fileFlyout->animateHide();
}
@ -470,17 +470,13 @@ QString GenericChatForm::resolveToxId(const ToxId &id)
{
Friend *f = FriendList::findFriend(id);
if (f)
{
return f->getDisplayedName();
}
else
for (Group *it : GroupList::getAllGroups())
{
for (auto it : GroupList::getAllGroups())
{
QString res = it->resolveToxId(id);
if (res.size())
return res;
}
QString res = it->resolveToxId(id);
if (res.size())
return res;
}
return QString();

View File

@ -220,7 +220,7 @@ void GroupChatForm::onUserListChanged()
if (peersCount > 1 && group->isAvGroupchat())
{
// don't set button to green if call running
if(!inCall)
if (!inCall)
{
callButton->setEnabled(true);
callButton->setObjectName("green");
@ -285,7 +285,7 @@ void GroupChatForm::dropEvent(QDropEvent *ev)
void GroupChatForm::onMicMuteToggle()
{
if (audioInputFlag == true)
if (audioInputFlag)
{
if (micButton->objectName() == "red")
{
@ -306,7 +306,7 @@ void GroupChatForm::onMicMuteToggle()
void GroupChatForm::onVolMuteToggle()
{
if (audioOutputFlag == true)
if (audioOutputFlag)
{
if (volButton->objectName() == "red")
{

View File

@ -186,10 +186,9 @@ void GroupInviteForm::deleteInviteButtons(QWidget* widget)
void GroupInviteForm::retranslateUi()
{
headLabel->setText(tr("Groups"));
if(createButton)
{
if (createButton)
createButton->setText(tr("Create new group"));
}
inviteBox->setTitle(tr("Group invites"));
for (QPushButton* acceptButton : acceptButtons)

View File

@ -370,11 +370,11 @@ void ProfileForm::onDeleteClicked()
QVector<QString> manualDeleteFiles = nexus.getProfile()->remove();
if(!manualDeleteFiles.empty())
if (!manualDeleteFiles.empty())
{
QString message = tr("The following files could not be deleted:", "deletion failed text part 1") + "\n\n";
for(auto& file : manualDeleteFiles)
for (auto& file : manualDeleteFiles)
{
message = message + file + "\n";
}

View File

@ -45,7 +45,10 @@ signals:
void clicked();
protected:
virtual void mouseReleaseEvent(QMouseEvent*) final override {emit clicked();}
virtual void mouseReleaseEvent(QMouseEvent*) final override
{
emit clicked();
}
};
class ProfileForm : public QWidget

View File

@ -35,7 +35,10 @@ class AboutForm : public GenericForm
public:
AboutForm();
~AboutForm();
virtual QString getFormName() final override {return tr("About");}
virtual QString getFormName() final override
{
return tr("About");
}
protected:

View File

@ -34,7 +34,10 @@ class AdvancedForm : public GenericForm
public:
AdvancedForm();
~AdvancedForm();
virtual QString getFormName() final override {return tr("Advanced");}
virtual QString getFormName() final override
{
return tr("Advanced");
}
protected:
bool eventFilter(QObject *o, QEvent *e) final override;

View File

@ -212,10 +212,10 @@ void AVForm::selectBestModes(QVector<VideoMode> &allVideoModes)
qDebug("width: %d, height: %d, FPS: %f, pixel format: %s", mode.width, mode.height, mode.FPS, pixelFormat.toStdString().c_str());
// PS3-Cam protection, everything above 60fps makes no sense
if(mode.FPS > 60)
if (mode.FPS > 60)
continue;
for(auto iter = idealModes.begin(); iter != idealModes.end(); ++iter)
for (auto iter = idealModes.begin(); iter != idealModes.end(); ++iter)
{
int res = iter->first;
VideoMode idealMode = iter->second;

View File

@ -34,7 +34,10 @@ class GeneralForm : public GenericForm
public:
explicit GeneralForm(SettingsWidget *parent);
~GeneralForm();
virtual QString getFormName() final override {return tr("General");}
virtual QString getFormName() final override
{
return tr("General");
}
private slots:
void onEnableIPv6Updated();

View File

@ -28,7 +28,10 @@ public:
virtual ~GenericForm() {}
virtual QString getFormName() = 0;
QPixmap getFormIcon() {return formIcon;}
QPixmap getFormIcon()
{
return formIcon;
}
protected:
QPixmap formIcon;

View File

@ -32,7 +32,10 @@ class PrivacyForm : public GenericForm
public:
PrivacyForm();
~PrivacyForm();
virtual QString getFormName() final override {return tr("Privacy");}
virtual QString getFormName() final override
{
return tr("Privacy");
}
private slots:
void onEnableLoggingUpdated();

View File

@ -183,14 +183,10 @@ void GenericChatroomWidget::reloadTheme()
void GenericChatroomWidget::mouseReleaseEvent(QMouseEvent* event)
{
if(event->button() == Qt::LeftButton)
{
if (event->button() == Qt::LeftButton)
emit chatroomWidgetClicked(this);
}
else
{
event->ignore();
}
}
void GenericChatroomWidget::enterEvent(QEvent*)

View File

@ -40,7 +40,7 @@ LoginScreen::LoginScreen(QWidget *parent) :
ui->setupUi(this);
// permanently disables maximize button https://github.com/tux3/qTox/issues/1973
this->setWindowFlags(windowFlags() &! Qt::WindowMaximizeButtonHint);
this->setWindowFlags(windowFlags() & ~Qt::WindowMaximizeButtonHint);
this->setFixedSize(this->size());
connect(&quitShortcut, &QShortcut::activated, this, &LoginScreen::close);
@ -271,9 +271,9 @@ void LoginScreen::retranslateUi()
void LoginScreen::onImportProfile()
{
ProfileImporter *pi = new ProfileImporter(this);
if(pi->importProfile() == true)
{
if (pi->importProfile())
reset();
}
delete pi;
}

View File

@ -203,9 +203,8 @@ void ScreenGrabberChooserRectItem::mousePressHandle(int x, int y, QGraphicsScene
Q_UNUSED(x);
Q_UNUSED(y);
if(event->button() == Qt::LeftButton)
if (event->button() == Qt::LeftButton)
this->state = HandleResizing;
}
void ScreenGrabberChooserRectItem::mouseMoveHandle(int x, int y, QGraphicsSceneMouseEvent* event)
@ -221,13 +220,13 @@ void ScreenGrabberChooserRectItem::mouseMoveHandle(int x, int y, QGraphicsSceneM
bool increaseX = ((x < 0) == (delta.x() < 0));
bool increaseY = ((y < 0) == (delta.y() < 0));
if((delta.x() < 0 && increaseX) || (delta.x() >= 0 && !increaseX))
if ((delta.x() < 0 && increaseX) || (delta.x() >= 0 && !increaseX))
{
moveBy(delta.x(), 0);
delta.rx() *= -1;
}
if((delta.y() < 0 && increaseY) || (delta.y() >= 0 && !increaseY))
if ((delta.y() < 0 && increaseY) || (delta.y() >= 0 && !increaseY))
{
moveBy(0, delta.y());
delta.ry() *= -1;

View File

@ -563,7 +563,7 @@ void Widget::moveEvent(QMoveEvent *event)
void Widget::closeEvent(QCloseEvent *event)
{
if (Settings::getInstance().getShowSystemTray() && Settings::getInstance().getCloseToTray() == true)
if (Settings::getInstance().getShowSystemTray() && Settings::getInstance().getCloseToTray())
{
event->ignore();
this->hide();
@ -1020,7 +1020,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
f->setStatus(status);
f->getFriendWidget()->updateStatusLight();
if(f->getFriendWidget()->isActive())
if (f->getFriendWidget()->isActive())
setWindowTitle(f->getFriendWidget()->getTitle());
ContentDialog::updateFriendStatus(friendId);
@ -1342,7 +1342,7 @@ bool Widget::newMessageAlert(QWidget* currentWindow, bool isActive, bool sound,
void Widget::onFriendRequestReceived(const QString& userId, const QString& message)
{
if(addFriendForm->addFriendRequest(userId, message))
if (addFriendForm->addFriendRequest(userId, message))
{
friendRequestsUpdate();
newMessageAlert(window(), isActiveWindow(), true, true);
@ -1981,7 +1981,7 @@ void Widget::clearAllReceipts()
void Widget::reloadTheme()
{
QString statusPanelStyle = Style::getStylesheet(":/ui/window/statusPanel.css");
ui->tooliconsZone->setStyleSheet(Style::resolve("QPushButton{background-color:@themeDark;border:none;}QPushButton:hover{background-color:@themeMediumDark;border:none;}QPushButton:checked{background-color:@themeMedium;border:none;}QPushButton:pressed{background-color:@themeMediumLight;border:none;}"));
ui->tooliconsZone->setStyleSheet(Style::getStylesheet(":/ui/tooliconsZone/tooliconsZone.css"));
ui->statusPanel->setStyleSheet(statusPanelStyle);
ui->statusHead->setStyleSheet(statusPanelStyle);
ui->friendList->setStyleSheet(Style::getStylesheet(":/ui/friendList/friendList.css"));

View File

@ -0,0 +1,16 @@
QSplitter
{
color: white;
background-color: white;
alternate-background-color: white;
border-color: white;
gridline-color: white;
selection-color: white;
selection-background-color: white;
}
QSplitter:handle
{
color: white;
background-color: white;
}

View File

@ -0,0 +1,23 @@
QPushButton
{
background-color: @themeDark;
border: none;
}
QPushButton:hover
{
background-color: @themeMediumDark;
border: none;
}
QPushButton:checked
{
background-color: @themeMedium;
border: none;
}
QPushButton:pressed
{
background-color: @themeMediumLight;
border: none;
}