mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
docs(persistence): Added leading stars
This commit is contained in:
parent
1332abed11
commit
902828fcc2
|
@ -30,9 +30,9 @@
|
||||||
#include <QSqlError>
|
#include <QSqlError>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@var static TOX_PASS_KEY EncryptedDb::decryptionKey
|
* @var static TOX_PASS_KEY EncryptedDb::decryptionKey
|
||||||
@note When importing, the decryption key may not be the same as the profile key
|
* @note When importing, the decryption key may not be the same as the profile key
|
||||||
*/
|
*/
|
||||||
|
|
||||||
qint64 EncryptedDb::encryptedChunkSize = 4096;
|
qint64 EncryptedDb::encryptedChunkSize = 4096;
|
||||||
qint64 EncryptedDb::plainChunkSize = EncryptedDb::encryptedChunkSize - TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
|
qint64 EncryptedDb::plainChunkSize = EncryptedDb::encryptedChunkSize - TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
|
||||||
|
|
|
@ -15,59 +15,59 @@
|
||||||
#include <sqlcipher/sqlite3.h>
|
#include <sqlcipher/sqlite3.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class RawDatabase
|
* @class RawDatabase
|
||||||
@brief Implements a low level RAII interface to a SQLCipher (SQlite3) database.
|
* @brief Implements a low level RAII interface to a SQLCipher (SQlite3) database.
|
||||||
|
*
|
||||||
Thread-safe, does all database operations on a worker thread.
|
* Thread-safe, does all database operations on a worker thread.
|
||||||
The queries must not contain transaction commands (BEGIN/COMMIT/...) or the behavior is undefined.
|
* The queries must not contain transaction commands (BEGIN/COMMIT/...) or the behavior is undefined.
|
||||||
|
*
|
||||||
@var QMutex RawDatabase::transactionsMutex;
|
* @var QMutex RawDatabase::transactionsMutex;
|
||||||
@brief Protects pendingTransactions
|
* @brief Protects pendingTransactions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class Query
|
* @class Query
|
||||||
@brief A query to be executed by the database.
|
* @brief A query to be executed by the database.
|
||||||
|
*
|
||||||
Can be composed of one or more SQL statements in the query,
|
* Can be composed of one or more SQL statements in the query,
|
||||||
optional BLOB parameters to be bound, and callbacks fired when the query is executed
|
* optional BLOB parameters to be bound, and callbacks fired when the query is executed
|
||||||
Calling any database method from a query callback is undefined behavior.
|
* Calling any database method from a query callback is undefined behavior.
|
||||||
|
*
|
||||||
@var QByteArray RawDatabase::Query::query
|
* @var QByteArray RawDatabase::Query::query
|
||||||
@brief UTF-8 query string
|
* @brief UTF-8 query string
|
||||||
|
*
|
||||||
@var QVector<QByteArray> RawDatabase::Query::blobs
|
* @var QVector<QByteArray> RawDatabase::Query::blobs
|
||||||
@brief Bound data blobs
|
* @brief Bound data blobs
|
||||||
|
*
|
||||||
@var std::function<void(int64_t)> RawDatabase::Query::insertCallback
|
* @var std::function<void(int64_t)> RawDatabase::Query::insertCallback
|
||||||
@brief Called after execution with the last insert rowid
|
* @brief Called after execution with the last insert rowid
|
||||||
|
*
|
||||||
@var std::function<void(const QVector<QVariant>&)> RawDatabase::Query::rowCallback
|
* @var std::function<void(const QVector<QVariant>&)> RawDatabase::Query::rowCallback
|
||||||
@brief Called during execution for each row
|
* @brief Called during execution for each row
|
||||||
|
*
|
||||||
@var QVector<sqlite3_stmt*> RawDatabase::Query::statements
|
* @var QVector<sqlite3_stmt*> RawDatabase::Query::statements
|
||||||
@brief Statements to be compiled from the query
|
* @brief Statements to be compiled from the query
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@struct Transaction
|
* @struct Transaction
|
||||||
@brief SQL transactions to be processed.
|
* @brief SQL transactions to be processed.
|
||||||
|
*
|
||||||
A transaction is made of queries, which can have bound BLOBs.
|
* A transaction is made of queries, which can have bound BLOBs.
|
||||||
|
*
|
||||||
@var std::atomic_bool* RawDatabase::Transaction::success = nullptr;
|
* @var std::atomic_bool* RawDatabase::Transaction::success = nullptr;
|
||||||
@brief If not a nullptr, the result of the transaction will be set
|
* @brief If not a nullptr, the result of the transaction will be set
|
||||||
|
*
|
||||||
@var std::atomic_bool* RawDatabase::Transaction::done = nullptr;
|
* @var std::atomic_bool* RawDatabase::Transaction::done = nullptr;
|
||||||
@brief If not a nullptr, will be set to true when the transaction has been executed
|
* @brief If not a nullptr, will be set to true when the transaction has been executed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Tries to open a database.
|
* @brief Tries to open a database.
|
||||||
@param path Path to database.
|
* @param path Path to database.
|
||||||
@param password If empty, the database will be opened unencrypted.
|
* @param password If empty, the database will be opened unencrypted.
|
||||||
Otherwise we will use toxencryptsave to derive a key and encrypt the database.
|
* Otherwise we will use toxencryptsave to derive a key and encrypt the database.
|
||||||
*/
|
*/
|
||||||
RawDatabase::RawDatabase(const QString &path, const QString& password)
|
RawDatabase::RawDatabase(const QString &path, const QString& password)
|
||||||
: workerThread{new QThread}, path{path}, currentHexKey{deriveKey(password)}
|
: workerThread{new QThread}, path{path}, currentHexKey{deriveKey(password)}
|
||||||
{
|
{
|
||||||
|
@ -88,11 +88,11 @@ RawDatabase::~RawDatabase()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Tries to open the database with the given (possibly empty) key.
|
* @brief Tries to open the database with the given (possibly empty) key.
|
||||||
@param path Path to database.
|
* @param path Path to database.
|
||||||
@param hexKey Hex representation of the key in string.
|
* @param hexKey Hex representation of the key in string.
|
||||||
@return True if success, false otherwise.
|
* @return True if success, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool RawDatabase::open(const QString& path, const QString &hexKey)
|
bool RawDatabase::open(const QString& path, const QString &hexKey)
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() != workerThread.get())
|
if (QThread::currentThread() != workerThread.get())
|
||||||
|
@ -136,8 +136,8 @@ bool RawDatabase::open(const QString& path, const QString &hexKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Close the database and free its associated resources.
|
* @brief Close the database and free its associated resources.
|
||||||
*/
|
*/
|
||||||
void RawDatabase::close()
|
void RawDatabase::close()
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() != workerThread.get())
|
if (QThread::currentThread() != workerThread.get())
|
||||||
|
@ -153,9 +153,9 @@ void RawDatabase::close()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Checks, that the database is open.
|
* @brief Checks, that the database is open.
|
||||||
@return True if the database was opened successfully.
|
* @return True if the database was opened successfully.
|
||||||
*/
|
*/
|
||||||
bool RawDatabase::isOpen()
|
bool RawDatabase::isOpen()
|
||||||
{
|
{
|
||||||
// We don't need thread safety since only the ctor/dtor can write this pointer
|
// We don't need thread safety since only the ctor/dtor can write this pointer
|
||||||
|
@ -163,30 +163,30 @@ bool RawDatabase::isOpen()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Executes a SQL transaction synchronously.
|
* @brief Executes a SQL transaction synchronously.
|
||||||
@param statement Statement to execute.
|
* @param statement Statement to execute.
|
||||||
@return Whether the transaction was successful.
|
* @return Whether the transaction was successful.
|
||||||
*/
|
*/
|
||||||
bool RawDatabase::execNow(const QString& statement)
|
bool RawDatabase::execNow(const QString& statement)
|
||||||
{
|
{
|
||||||
return execNow(Query{statement});
|
return execNow(Query{statement});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Executes a SQL transaction synchronously.
|
* @brief Executes a SQL transaction synchronously.
|
||||||
@param statement Statement to execute.
|
* @param statement Statement to execute.
|
||||||
@return Whether the transaction was successful.
|
* @return Whether the transaction was successful.
|
||||||
*/
|
*/
|
||||||
bool RawDatabase::execNow(const RawDatabase::Query &statement)
|
bool RawDatabase::execNow(const RawDatabase::Query &statement)
|
||||||
{
|
{
|
||||||
return execNow(QVector<Query>{statement});
|
return execNow(QVector<Query>{statement});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Executes a SQL transaction synchronously.
|
* @brief Executes a SQL transaction synchronously.
|
||||||
@param statements List of statements to execute.
|
* @param statements List of statements to execute.
|
||||||
@return Whether the transaction was successful.
|
* @return Whether the transaction was successful.
|
||||||
*/
|
*/
|
||||||
bool RawDatabase::execNow(const QVector<RawDatabase::Query> &statements)
|
bool RawDatabase::execNow(const QVector<RawDatabase::Query> &statements)
|
||||||
{
|
{
|
||||||
if (!sqlite)
|
if (!sqlite)
|
||||||
|
@ -217,9 +217,9 @@ bool RawDatabase::execNow(const QVector<RawDatabase::Query> &statements)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Executes a SQL transaction asynchronously.
|
* @brief Executes a SQL transaction asynchronously.
|
||||||
@param statement Statement to execute.
|
* @param statement Statement to execute.
|
||||||
*/
|
*/
|
||||||
void RawDatabase::execLater(const QString &statement)
|
void RawDatabase::execLater(const QString &statement)
|
||||||
{
|
{
|
||||||
execLater(Query{statement});
|
execLater(Query{statement});
|
||||||
|
@ -249,19 +249,19 @@ void RawDatabase::execLater(const QVector<RawDatabase::Query> &statements)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Waits until all the pending transactions are executed.
|
* @brief Waits until all the pending transactions are executed.
|
||||||
*/
|
*/
|
||||||
void RawDatabase::sync()
|
void RawDatabase::sync()
|
||||||
{
|
{
|
||||||
QMetaObject::invokeMethod(this, "process", Qt::BlockingQueuedConnection);
|
QMetaObject::invokeMethod(this, "process", Qt::BlockingQueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Changes the database password, encrypting or decrypting if necessary.
|
* @brief Changes the database password, encrypting or decrypting if necessary.
|
||||||
@param password If password is empty, the database will be decrypted.
|
* @param password If password is empty, the database will be decrypted.
|
||||||
@return True if success, false otherwise.
|
* @return True if success, false otherwise.
|
||||||
@note Will process all transactions before changing the password.
|
* @note Will process all transactions before changing the password.
|
||||||
*/
|
*/
|
||||||
bool RawDatabase::setPassword(const QString& password)
|
bool RawDatabase::setPassword(const QString& password)
|
||||||
{
|
{
|
||||||
if (!sqlite)
|
if (!sqlite)
|
||||||
|
@ -356,12 +356,12 @@ bool RawDatabase::setPassword(const QString& password)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Moves the database file on disk to match the new path.
|
* @brief Moves the database file on disk to match the new path.
|
||||||
@param newPath Path to move database file.
|
* @param newPath Path to move database file.
|
||||||
@return True if success, false otherwise.
|
* @return True if success, false otherwise.
|
||||||
|
*
|
||||||
@note Will process all transactions before renaming
|
* @note Will process all transactions before renaming
|
||||||
*/
|
*/
|
||||||
bool RawDatabase::rename(const QString &newPath)
|
bool RawDatabase::rename(const QString &newPath)
|
||||||
{
|
{
|
||||||
if (!sqlite)
|
if (!sqlite)
|
||||||
|
@ -394,10 +394,10 @@ bool RawDatabase::rename(const QString &newPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Deletes the on disk database file after closing it.
|
* @brief Deletes the on disk database file after closing it.
|
||||||
@note Will process all transactions before deletings.
|
* @note Will process all transactions before deletings.
|
||||||
@return True if success, false otherwise.
|
* @return True if success, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool RawDatabase::remove()
|
bool RawDatabase::remove()
|
||||||
{
|
{
|
||||||
if (!sqlite)
|
if (!sqlite)
|
||||||
|
@ -419,10 +419,10 @@ bool RawDatabase::remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Derives a 256bit key from the password and returns it hex-encoded
|
* @brief Derives a 256bit key from the password and returns it hex-encoded
|
||||||
@param password Password to decrypt database
|
* @param password Password to decrypt database
|
||||||
@return String representation of key
|
* @return String representation of key
|
||||||
*/
|
*/
|
||||||
QString RawDatabase::deriveKey(const QString &password)
|
QString RawDatabase::deriveKey(const QString &password)
|
||||||
{
|
{
|
||||||
if (password.isEmpty())
|
if (password.isEmpty())
|
||||||
|
@ -439,11 +439,11 @@ QString RawDatabase::deriveKey(const QString &password)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Implements the actual processing of pending transactions.
|
* @brief Implements the actual processing of pending transactions.
|
||||||
Unqueues, compiles, binds and executes queries, then notifies of results
|
* Unqueues, compiles, binds and executes queries, then notifies of results
|
||||||
|
*
|
||||||
@warning MUST only be called from the worker thread
|
* @warning MUST only be called from the worker thread
|
||||||
*/
|
*/
|
||||||
void RawDatabase::process()
|
void RawDatabase::process()
|
||||||
{
|
{
|
||||||
assert(QThread::currentThread() == workerThread.get());
|
assert(QThread::currentThread() == workerThread.get());
|
||||||
|
@ -578,11 +578,11 @@ void RawDatabase::process()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Extracts a variant from one column of a result row depending on the column type.
|
* @brief Extracts a variant from one column of a result row depending on the column type.
|
||||||
@param stmt Statement to execute.
|
* @param stmt Statement to execute.
|
||||||
@param col Number of column to extract.
|
* @param col Number of column to extract.
|
||||||
@return Extracted data.
|
* @return Extracted data.
|
||||||
*/
|
*/
|
||||||
QVariant RawDatabase::extractData(sqlite3_stmt *stmt, int col)
|
QVariant RawDatabase::extractData(sqlite3_stmt *stmt, int col)
|
||||||
{
|
{
|
||||||
int type = sqlite3_column_type(stmt, col);
|
int type = sqlite3_column_type(stmt, col);
|
||||||
|
|
|
@ -9,19 +9,19 @@
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class History
|
* @class History
|
||||||
@brief Interacts with the profile database to save the chat history.
|
* @brief Interacts with the profile database to save the chat history.
|
||||||
|
*
|
||||||
@var QHash<QString, int64_t> History::peers
|
* @var QHash<QString, int64_t> History::peers
|
||||||
@brief Maps friend public keys to unique IDs by index.
|
* @brief Maps friend public keys to unique IDs by index.
|
||||||
Caches mappings to speed up message saving.
|
* Caches mappings to speed up message saving.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Opens the profile database and prepares to work with the history.
|
* @brief Opens the profile database and prepares to work with the history.
|
||||||
@param profileName Profile name to load.
|
* @param profileName Profile name to load.
|
||||||
@param password If empty, the database will be opened unencrypted.
|
* @param password If empty, the database will be opened unencrypted.
|
||||||
*/
|
*/
|
||||||
History::History(const QString &profileName, const QString &password)
|
History::History(const QString &profileName, const QString &password)
|
||||||
: db{getDbPath(profileName), password}
|
: db{getDbPath(profileName), password}
|
||||||
{
|
{
|
||||||
|
@ -29,11 +29,11 @@ History::History(const QString &profileName, const QString &password)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Opens the profile database, and import from the old database.
|
* @brief Opens the profile database, and import from the old database.
|
||||||
@param profileName Profile name to load.
|
* @param profileName Profile name to load.
|
||||||
@param password If empty, the database will be opened unencrypted.
|
* @param password If empty, the database will be opened unencrypted.
|
||||||
@param oldHistory Old history to import.
|
* @param oldHistory Old history to import.
|
||||||
*/
|
*/
|
||||||
History::History(const QString &profileName, const QString &password, const HistoryKeeper &oldHistory)
|
History::History(const QString &profileName, const QString &password, const HistoryKeeper &oldHistory)
|
||||||
: History{profileName, password}
|
: History{profileName, password}
|
||||||
{
|
{
|
||||||
|
@ -48,44 +48,44 @@ History::~History()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Checks if the database was opened successfully
|
* @brief Checks if the database was opened successfully
|
||||||
@return True if database if opened, false otherwise.
|
* @return True if database if opened, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool History::isValid()
|
bool History::isValid()
|
||||||
{
|
{
|
||||||
return db.isOpen();
|
return db.isOpen();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Changes the database password, will encrypt or decrypt if necessary.
|
* @brief Changes the database password, will encrypt or decrypt if necessary.
|
||||||
@param password Password to set.
|
* @param password Password to set.
|
||||||
*/
|
*/
|
||||||
void History::setPassword(const QString& password)
|
void History::setPassword(const QString& password)
|
||||||
{
|
{
|
||||||
db.setPassword(password);
|
db.setPassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Moves the database file on disk to match the new name.
|
* @brief Moves the database file on disk to match the new name.
|
||||||
@param newName New name.
|
* @param newName New name.
|
||||||
*/
|
*/
|
||||||
void History::rename(const QString &newName)
|
void History::rename(const QString &newName)
|
||||||
{
|
{
|
||||||
db.rename(getDbPath(newName));
|
db.rename(getDbPath(newName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Deletes the on-disk database file.
|
* @brief Deletes the on-disk database file.
|
||||||
@return True if success, false otherwise.
|
* @return True if success, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool History::remove()
|
bool History::remove()
|
||||||
{
|
{
|
||||||
return db.remove();
|
return db.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Erases all the chat history from the database.
|
* @brief Erases all the chat history from the database.
|
||||||
*/
|
*/
|
||||||
void History::eraseHistory()
|
void History::eraseHistory()
|
||||||
{
|
{
|
||||||
db.execNow("DELETE FROM faux_offline_pending;"
|
db.execNow("DELETE FROM faux_offline_pending;"
|
||||||
|
@ -96,9 +96,9 @@ void History::eraseHistory()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Erases the chat history with one friend.
|
* @brief Erases the chat history with one friend.
|
||||||
@param friendPk Friend public key to erase.
|
* @param friendPk Friend public key to erase.
|
||||||
*/
|
*/
|
||||||
void History::removeFriendHistory(const QString &friendPk)
|
void History::removeFriendHistory(const QString &friendPk)
|
||||||
{
|
{
|
||||||
if (!peers.contains(friendPk))
|
if (!peers.contains(friendPk))
|
||||||
|
@ -125,15 +125,15 @@ void History::removeFriendHistory(const QString &friendPk)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Generate query to insert new message in database
|
* @brief Generate query to insert new message in database
|
||||||
@param friendPk Friend publick key to save.
|
* @param friendPk Friend publick key to save.
|
||||||
@param message Message to save.
|
* @param message Message to save.
|
||||||
@param sender Sender to save.
|
* @param sender Sender to save.
|
||||||
@param time Time of message sending.
|
* @param time Time of message sending.
|
||||||
@param isSent True if message was already sent.
|
* @param isSent True if message was already sent.
|
||||||
@param dispName Name, which should be displayed.
|
* @param dispName Name, which should be displayed.
|
||||||
@param insertIdCallback Function, called after query execution.
|
* @param insertIdCallback Function, called after query execution.
|
||||||
*/
|
*/
|
||||||
QVector<RawDatabase::Query> History::generateNewMessageQueries(const QString &friendPk, const QString &message,
|
QVector<RawDatabase::Query> History::generateNewMessageQueries(const QString &friendPk, const QString &message,
|
||||||
const QString &sender, const QDateTime &time, bool isSent, QString dispName,
|
const QString &sender, const QDateTime &time, bool isSent, QString dispName,
|
||||||
std::function<void(int64_t)> insertIdCallback)
|
std::function<void(int64_t)> insertIdCallback)
|
||||||
|
@ -193,15 +193,15 @@ QVector<RawDatabase::Query> History::generateNewMessageQueries(const QString &fr
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Saves a chat message in the database.
|
* @brief Saves a chat message in the database.
|
||||||
@param friendPk Friend publick key to save.
|
* @param friendPk Friend publick key to save.
|
||||||
@param message Message to save.
|
* @param message Message to save.
|
||||||
@param sender Sender to save.
|
* @param sender Sender to save.
|
||||||
@param time Time of message sending.
|
* @param time Time of message sending.
|
||||||
@param isSent True if message was already sent.
|
* @param isSent True if message was already sent.
|
||||||
@param dispName Name, which should be displayed.
|
* @param dispName Name, which should be displayed.
|
||||||
@param insertIdCallback Function, called after query execution.
|
* @param insertIdCallback Function, called after query execution.
|
||||||
*/
|
*/
|
||||||
void History::addNewMessage(const QString &friendPk, const QString &message, const QString &sender,
|
void History::addNewMessage(const QString &friendPk, const QString &message, const QString &sender,
|
||||||
const QDateTime &time, bool isSent, QString dispName, std::function<void(int64_t)> insertIdCallback)
|
const QDateTime &time, bool isSent, QString dispName, std::function<void(int64_t)> insertIdCallback)
|
||||||
{
|
{
|
||||||
|
@ -209,12 +209,12 @@ void History::addNewMessage(const QString &friendPk, const QString &message, con
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Fetches chat messages from the database.
|
* @brief Fetches chat messages from the database.
|
||||||
@param friendPk Friend publick key to fetch.
|
* @param friendPk Friend publick key to fetch.
|
||||||
@param from Start of period to fetch.
|
* @param from Start of period to fetch.
|
||||||
@param to End of period to fetch.
|
* @param to End of period to fetch.
|
||||||
@return List of messages.
|
* @return List of messages.
|
||||||
*/
|
*/
|
||||||
QList<History::HistMessage> History::getChatHistory(const QString &friendPk, const QDateTime &from, const QDateTime &to)
|
QList<History::HistMessage> History::getChatHistory(const QString &friendPk, const QDateTime &from, const QDateTime &to)
|
||||||
{
|
{
|
||||||
QList<HistMessage> messages;
|
QList<HistMessage> messages;
|
||||||
|
@ -245,29 +245,29 @@ QList<History::HistMessage> History::getChatHistory(const QString &friendPk, con
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Marks a message as sent.
|
* @brief Marks a message as sent.
|
||||||
Removing message from the faux-offline pending messages list.
|
* Removing message from the faux-offline pending messages list.
|
||||||
|
*
|
||||||
@param id Message ID.
|
* @param id Message ID.
|
||||||
*/
|
*/
|
||||||
void History::markAsSent(qint64 id)
|
void History::markAsSent(qint64 id)
|
||||||
{
|
{
|
||||||
db.execLater(QString("DELETE FROM faux_offline_pending WHERE id=%1;").arg(id));
|
db.execLater(QString("DELETE FROM faux_offline_pending WHERE id=%1;").arg(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Retrieves the path to the database file for a given profile.
|
* @brief Retrieves the path to the database file for a given profile.
|
||||||
@param profileName Profile name.
|
* @param profileName Profile name.
|
||||||
@return Path to database.
|
* @return Path to database.
|
||||||
*/
|
*/
|
||||||
QString History::getDbPath(const QString &profileName)
|
QString History::getDbPath(const QString &profileName)
|
||||||
{
|
{
|
||||||
return Settings::getInstance().getSettingsDirPath() + profileName + ".db";
|
return Settings::getInstance().getSettingsDirPath() + profileName + ".db";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Makes sure the history tables are created
|
* @brief Makes sure the history tables are created
|
||||||
*/
|
*/
|
||||||
void History::init()
|
void History::init()
|
||||||
{
|
{
|
||||||
if (!isValid())
|
if (!isValid())
|
||||||
|
@ -292,9 +292,9 @@ void History::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Imports messages from the old history file.
|
* @brief Imports messages from the old history file.
|
||||||
@param oldHistory Old history to import.
|
* @param oldHistory Old history to import.
|
||||||
*/
|
*/
|
||||||
void History::import(const HistoryKeeper &oldHistory)
|
void History::import(const HistoryKeeper &oldHistory)
|
||||||
{
|
{
|
||||||
if (!isValid())
|
if (!isValid())
|
||||||
|
|
|
@ -36,18 +36,18 @@
|
||||||
#include "src/persistence/db/encrypteddb.h"
|
#include "src/persistence/db/encrypteddb.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class HistoryKeeper
|
* @class HistoryKeeper
|
||||||
@brief THIS IS A LEGACY CLASS KEPT FOR BACKWARDS COMPATIBILITY
|
* @brief THIS IS A LEGACY CLASS KEPT FOR BACKWARDS COMPATIBILITY
|
||||||
@deprecated See the History class instead
|
* @deprecated See the History class instead
|
||||||
@warning DO NOT USE!
|
* @warning DO NOT USE!
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static HistoryKeeper *historyInstance = nullptr;
|
static HistoryKeeper *historyInstance = nullptr;
|
||||||
QMutex HistoryKeeper::historyMutex;
|
QMutex HistoryKeeper::historyMutex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Returns the singleton instance.
|
* @brief Returns the singleton instance.
|
||||||
*/
|
*/
|
||||||
HistoryKeeper *HistoryKeeper::getInstance(const Profile& profile)
|
HistoryKeeper *HistoryKeeper::getInstance(const Profile& profile)
|
||||||
{
|
{
|
||||||
historyMutex.lock();
|
historyMutex.lock();
|
||||||
|
|
|
@ -27,12 +27,12 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@var static const int OfflineMsgEngine::offlineTimeout
|
* @var static const int OfflineMsgEngine::offlineTimeout
|
||||||
@brief timeout after which faux offline messages get to be re-sent.
|
* @brief timeout after which faux offline messages get to be re-sent.
|
||||||
Originally was 2s, but since that was causing lots of duplicated
|
* Originally was 2s, but since that was causing lots of duplicated
|
||||||
messages on receiving end, make qTox be more lazy about re-sending
|
* messages on receiving end, make qTox be more lazy about re-sending
|
||||||
should be 20s.
|
* should be 20s.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
const int OfflineMsgEngine::offlineTimeout = 20000;
|
const int OfflineMsgEngine::offlineTimeout = 20000;
|
||||||
|
|
|
@ -36,19 +36,19 @@
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class Profile
|
* @class Profile
|
||||||
@brief Manages user profiles.
|
* @brief Manages user profiles.
|
||||||
|
*
|
||||||
@var bool Profile::newProfile
|
* @var bool Profile::newProfile
|
||||||
@brief True if this is a newly created profile, with no .tox save file yet.
|
* @brief True if this is a newly created profile, with no .tox save file yet.
|
||||||
|
*
|
||||||
@var bool Profile::isRemoved
|
* @var bool Profile::isRemoved
|
||||||
@brief True if the profile has been removed by remove().
|
* @brief True if the profile has been removed by remove().
|
||||||
|
*
|
||||||
@var static constexpr int Profile::encryptHeaderSize = 8
|
* @var static constexpr int Profile::encryptHeaderSize = 8
|
||||||
@brief How much data we need to read to check if the file is encrypted.
|
* @brief How much data we need to read to check if the file is encrypted.
|
||||||
@note Must be >= TOX_ENC_SAVE_MAGIC_LENGTH (8), which isn't publicly defined.
|
* @note Must be >= TOX_ENC_SAVE_MAGIC_LENGTH (8), which isn't publicly defined.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QVector<QString> Profile::profiles;
|
QVector<QString> Profile::profiles;
|
||||||
|
|
||||||
|
@ -81,13 +81,13 @@ Profile::Profile(QString name, const QString &password, bool isNewProfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Locks and loads an existing profile and creates the associate Core* instance.
|
* @brief Locks and loads an existing profile and creates the associate Core* instance.
|
||||||
@param name Profile name.
|
* @param name Profile name.
|
||||||
@param password Profile password.
|
* @param password Profile password.
|
||||||
@return Returns a nullptr on error. Profile pointer otherwise.
|
* @return Returns a nullptr on error. Profile pointer otherwise.
|
||||||
|
*
|
||||||
@example If the profile is already in use return nullptr.
|
* @example If the profile is already in use return nullptr.
|
||||||
*/
|
*/
|
||||||
Profile* Profile::loadProfile(QString name, const QString &password)
|
Profile* Profile::loadProfile(QString name, const QString &password)
|
||||||
{
|
{
|
||||||
if (ProfileLocker::hasLock())
|
if (ProfileLocker::hasLock())
|
||||||
|
@ -166,13 +166,13 @@ Profile* Profile::loadProfile(QString name, const QString &password)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Creates a new profile and the associated Core* instance.
|
* @brief Creates a new profile and the associated Core* instance.
|
||||||
@param name Username.
|
* @param name Username.
|
||||||
@param password If password is not empty, the profile will be encrypted.
|
* @param password If password is not empty, the profile will be encrypted.
|
||||||
@return Returns a nullptr on error. Profile pointer otherwise.
|
* @return Returns a nullptr on error. Profile pointer otherwise.
|
||||||
|
*
|
||||||
@example If the profile is already in use return nullptr.
|
* @example If the profile is already in use return nullptr.
|
||||||
*/
|
*/
|
||||||
Profile* Profile::createProfile(QString name, QString password)
|
Profile* Profile::createProfile(QString name, QString password)
|
||||||
{
|
{
|
||||||
if (ProfileLocker::hasLock())
|
if (ProfileLocker::hasLock())
|
||||||
|
@ -214,10 +214,10 @@ Profile::~Profile()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Lists all the files in the config dir with a given extension
|
* @brief Lists all the files in the config dir with a given extension
|
||||||
@param extension Raw extension, e.g. "jpeg" not ".jpeg".
|
* @param extension Raw extension, e.g. "jpeg" not ".jpeg".
|
||||||
@return Vector of filenames.
|
* @return Vector of filenames.
|
||||||
*/
|
*/
|
||||||
QVector<QString> Profile::getFilesByExt(QString extension)
|
QVector<QString> Profile::getFilesByExt(QString extension)
|
||||||
{
|
{
|
||||||
QDir dir(Settings::getInstance().getSettingsDirPath());
|
QDir dir(Settings::getInstance().getSettingsDirPath());
|
||||||
|
@ -232,9 +232,9 @@ QVector<QString> Profile::getFilesByExt(QString extension)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Scan for profile, automatically importing them if needed.
|
* @brief Scan for profile, automatically importing them if needed.
|
||||||
@warning NOT thread-safe.
|
* @warning NOT thread-safe.
|
||||||
*/
|
*/
|
||||||
void Profile::scanProfiles()
|
void Profile::scanProfiles()
|
||||||
{
|
{
|
||||||
profiles.clear();
|
profiles.clear();
|
||||||
|
@ -263,8 +263,8 @@ QString Profile::getName() const
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Starts the Core thread
|
* @brief Starts the Core thread
|
||||||
*/
|
*/
|
||||||
void Profile::startCore()
|
void Profile::startCore()
|
||||||
{
|
{
|
||||||
coreThread->start();
|
coreThread->start();
|
||||||
|
@ -276,9 +276,9 @@ bool Profile::isNewProfile()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Loads the profile's .tox save from file, unencrypted
|
* @brief Loads the profile's .tox save from file, unencrypted
|
||||||
@return Byte array of loaded profile save.
|
* @return Byte array of loaded profile save.
|
||||||
*/
|
*/
|
||||||
QByteArray Profile::loadToxSave()
|
QByteArray Profile::loadToxSave()
|
||||||
{
|
{
|
||||||
assert(!isRemoved);
|
assert(!isRemoved);
|
||||||
|
@ -338,9 +338,9 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Saves the profile's .tox save, encrypted if needed.
|
* @brief Saves the profile's .tox save, encrypted if needed.
|
||||||
@warning Invalid on deleted profiles.
|
* @warning Invalid on deleted profiles.
|
||||||
*/
|
*/
|
||||||
void Profile::saveToxSave()
|
void Profile::saveToxSave()
|
||||||
{
|
{
|
||||||
assert(core->isReady());
|
assert(core->isReady());
|
||||||
|
@ -350,10 +350,10 @@ void Profile::saveToxSave()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Write the .tox save, encrypted if needed.
|
* @brief Write the .tox save, encrypted if needed.
|
||||||
@param data Byte array of profile save.
|
* @param data Byte array of profile save.
|
||||||
@warning Invalid on deleted profiles.
|
* @warning Invalid on deleted profiles.
|
||||||
*/
|
*/
|
||||||
void Profile::saveToxSave(QByteArray data)
|
void Profile::saveToxSave(QByteArray data)
|
||||||
{
|
{
|
||||||
assert(!isRemoved);
|
assert(!isRemoved);
|
||||||
|
@ -397,11 +397,11 @@ void Profile::saveToxSave(QByteArray data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Gets the path of the avatar file cached by this profile and corresponding to this owner ID.
|
* @brief Gets the path of the avatar file cached by this profile and corresponding to this owner ID.
|
||||||
@param ownerId Path to avatar of friend with this ID will returned.
|
* @param ownerId Path to avatar of friend with this ID will returned.
|
||||||
@param forceUnencrypted If true, return the path to the plaintext file even if this is an encrypted profile.
|
* @param forceUnencrypted If true, return the path to the plaintext file even if this is an encrypted profile.
|
||||||
@return Path to the avatar.
|
* @return Path to the avatar.
|
||||||
*/
|
*/
|
||||||
QString Profile::avatarPath(const QString &ownerId, bool forceUnencrypted)
|
QString Profile::avatarPath(const QString &ownerId, bool forceUnencrypted)
|
||||||
{
|
{
|
||||||
if (password.isEmpty() || forceUnencrypted)
|
if (password.isEmpty() || forceUnencrypted)
|
||||||
|
@ -420,19 +420,19 @@ QString Profile::avatarPath(const QString &ownerId, bool forceUnencrypted)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get our avatar from cache.
|
* @brief Get our avatar from cache.
|
||||||
@return Avatar as QPixmap.
|
* @return Avatar as QPixmap.
|
||||||
*/
|
*/
|
||||||
QPixmap Profile::loadAvatar()
|
QPixmap Profile::loadAvatar()
|
||||||
{
|
{
|
||||||
return loadAvatar(core->getSelfId().publicKey);
|
return loadAvatar(core->getSelfId().publicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get a contact's avatar from cache.
|
* @brief Get a contact's avatar from cache.
|
||||||
@param ownerId Friend ID to load avatar.
|
* @param ownerId Friend ID to load avatar.
|
||||||
@return Avatar as QPixmap.
|
* @return Avatar as QPixmap.
|
||||||
*/
|
*/
|
||||||
QPixmap Profile::loadAvatar(const QString &ownerId)
|
QPixmap Profile::loadAvatar(const QString &ownerId)
|
||||||
{
|
{
|
||||||
QPixmap pic;
|
QPixmap pic;
|
||||||
|
@ -441,21 +441,21 @@ QPixmap Profile::loadAvatar(const QString &ownerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get a contact's avatar from cache
|
* @brief Get a contact's avatar from cache
|
||||||
@param ownerId Friend ID to load avatar.
|
* @param ownerId Friend ID to load avatar.
|
||||||
@return Avatar as QByteArray.
|
* @return Avatar as QByteArray.
|
||||||
*/
|
*/
|
||||||
QByteArray Profile::loadAvatarData(const QString &ownerId)
|
QByteArray Profile::loadAvatarData(const QString &ownerId)
|
||||||
{
|
{
|
||||||
return loadAvatarData(ownerId, password);
|
return loadAvatarData(ownerId, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get a contact's avatar from cache, with a specified profile password.
|
* @brief Get a contact's avatar from cache, with a specified profile password.
|
||||||
@param ownerId Friend ID to load avatar.
|
* @param ownerId Friend ID to load avatar.
|
||||||
@param password Profile password to decrypt data.
|
* @param password Profile password to decrypt data.
|
||||||
@return Avatar as QByteArray.
|
* @return Avatar as QByteArray.
|
||||||
*/
|
*/
|
||||||
QByteArray Profile::loadAvatarData(const QString &ownerId, const QString &password)
|
QByteArray Profile::loadAvatarData(const QString &ownerId, const QString &password)
|
||||||
{
|
{
|
||||||
QString path = avatarPath(ownerId);
|
QString path = avatarPath(ownerId);
|
||||||
|
@ -484,10 +484,10 @@ QByteArray Profile::loadAvatarData(const QString &ownerId, const QString &passwo
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Save an avatar to cache.
|
* @brief Save an avatar to cache.
|
||||||
@param pic Picture to save.
|
* @param pic Picture to save.
|
||||||
@param ownerId ID of avatar owner.
|
* @param ownerId ID of avatar owner.
|
||||||
*/
|
*/
|
||||||
void Profile::saveAvatar(QByteArray pic, const QString &ownerId)
|
void Profile::saveAvatar(QByteArray pic, const QString &ownerId)
|
||||||
{
|
{
|
||||||
if (!password.isEmpty() && !pic.isEmpty())
|
if (!password.isEmpty() && !pic.isEmpty())
|
||||||
|
@ -513,10 +513,10 @@ void Profile::saveAvatar(QByteArray pic, const QString &ownerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get the tox hash of a cached avatar.
|
* @brief Get the tox hash of a cached avatar.
|
||||||
@param ownerId Friend ID to get hash.
|
* @param ownerId Friend ID to get hash.
|
||||||
@return Avatar tox hash.
|
* @return Avatar tox hash.
|
||||||
*/
|
*/
|
||||||
QByteArray Profile::getAvatarHash(const QString &ownerId)
|
QByteArray Profile::getAvatarHash(const QString &ownerId)
|
||||||
{
|
{
|
||||||
QByteArray pic = loadAvatarData(ownerId);
|
QByteArray pic = loadAvatarData(ownerId);
|
||||||
|
@ -526,35 +526,35 @@ QByteArray Profile::getAvatarHash(const QString &ownerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Removes our own avatar.
|
* @brief Removes our own avatar.
|
||||||
*/
|
*/
|
||||||
void Profile::removeAvatar()
|
void Profile::removeAvatar()
|
||||||
{
|
{
|
||||||
removeAvatar(core->getSelfId().publicKey);
|
removeAvatar(core->getSelfId().publicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Checks that the history is enabled in the settings, and loaded successfully for this profile.
|
* @brief Checks that the history is enabled in the settings, and loaded successfully for this profile.
|
||||||
@return True if enabled, false otherwise.
|
* @return True if enabled, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool Profile::isHistoryEnabled()
|
bool Profile::isHistoryEnabled()
|
||||||
{
|
{
|
||||||
return Settings::getInstance().getEnableLogging() && history;
|
return Settings::getInstance().getEnableLogging() && history;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get chat history.
|
* @brief Get chat history.
|
||||||
@return May return a nullptr if the history failed to load.
|
* @return May return a nullptr if the history failed to load.
|
||||||
*/
|
*/
|
||||||
History *Profile::getHistory()
|
History *Profile::getHistory()
|
||||||
{
|
{
|
||||||
return history.get();
|
return history.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Removes a cached avatar.
|
* @brief Removes a cached avatar.
|
||||||
@param ownerId Friend ID whose avater to delete.
|
* @param ownerId Friend ID whose avater to delete.
|
||||||
*/
|
*/
|
||||||
void Profile::removeAvatar(const QString &ownerId)
|
void Profile::removeAvatar(const QString &ownerId)
|
||||||
{
|
{
|
||||||
QFile::remove(avatarPath(ownerId));
|
QFile::remove(avatarPath(ownerId));
|
||||||
|
@ -569,20 +569,20 @@ bool Profile::exists(QString name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Checks, if profile has a password.
|
* @brief Checks, if profile has a password.
|
||||||
@return True if we have a password set (doesn't check the actual file on disk).
|
* @return True if we have a password set (doesn't check the actual file on disk).
|
||||||
*/
|
*/
|
||||||
bool Profile::isEncrypted() const
|
bool Profile::isEncrypted() const
|
||||||
{
|
{
|
||||||
return !password.isEmpty();
|
return !password.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Checks if profile is encrypted.
|
* @brief Checks if profile is encrypted.
|
||||||
@note Checks the actual file on disk.
|
* @note Checks the actual file on disk.
|
||||||
@param name Profile name.
|
* @param name Profile name.
|
||||||
@return True if profile is encrypted, false otherwise.
|
* @return True if profile is encrypted, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool Profile::isEncrypted(QString name)
|
bool Profile::isEncrypted(QString name)
|
||||||
{
|
{
|
||||||
uint8_t data[encryptHeaderSize] = {0};
|
uint8_t data[encryptHeaderSize] = {0};
|
||||||
|
@ -601,11 +601,11 @@ bool Profile::isEncrypted(QString name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Removes the profile permanently.
|
* @brief Removes the profile permanently.
|
||||||
Updates the profiles vector.
|
* Updates the profiles vector.
|
||||||
@return Vector of filenames that could not be removed.
|
* @return Vector of filenames that could not be removed.
|
||||||
@warning It is invalid to call loadToxSave or saveToxSave on a deleted profile.
|
* @warning It is invalid to call loadToxSave or saveToxSave on a deleted profile.
|
||||||
*/
|
*/
|
||||||
QVector<QString> Profile::remove()
|
QVector<QString> Profile::remove()
|
||||||
{
|
{
|
||||||
if (isRemoved)
|
if (isRemoved)
|
||||||
|
@ -670,10 +670,10 @@ QVector<QString> Profile::remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Tries to rename the profile.
|
* @brief Tries to rename the profile.
|
||||||
@param newName New name for the profile.
|
* @param newName New name for the profile.
|
||||||
@return False on error, true otherwise.
|
* @return False on error, true otherwise.
|
||||||
*/
|
*/
|
||||||
bool Profile::rename(QString newName)
|
bool Profile::rename(QString newName)
|
||||||
{
|
{
|
||||||
QString path = Settings::getInstance().getSettingsDirPath() + name,
|
QString path = Settings::getInstance().getSettingsDirPath() + name,
|
||||||
|
@ -697,9 +697,9 @@ bool Profile::rename(QString newName)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Checks whether the password is valid.
|
* @brief Checks whether the password is valid.
|
||||||
@return True, if password is valid, false otherwise.
|
* @return True, if password is valid, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool Profile::checkPassword()
|
bool Profile::checkPassword()
|
||||||
{
|
{
|
||||||
if (isRemoved)
|
if (isRemoved)
|
||||||
|
@ -719,8 +719,8 @@ const TOX_PASS_KEY& Profile::getPasskey() const
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Delete core and restart a new one
|
* @brief Delete core and restart a new one
|
||||||
*/
|
*/
|
||||||
void Profile::restartCore()
|
void Profile::restartCore()
|
||||||
{
|
{
|
||||||
GUI::setEnabled(false); // Core::reset re-enables it
|
GUI::setEnabled(false); // Core::reset re-enables it
|
||||||
|
@ -730,9 +730,9 @@ void Profile::restartCore()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Changes the encryption password and re-saves everything with it
|
* @brief Changes the encryption password and re-saves everything with it
|
||||||
@param newPassword Password for encryption.
|
* @param newPassword Password for encryption.
|
||||||
*/
|
*/
|
||||||
void Profile::setPassword(const QString &newPassword)
|
void Profile::setPassword(const QString &newPassword)
|
||||||
{
|
{
|
||||||
QByteArray avatar = loadAvatarData(core->getSelfId().publicKey);
|
QByteArray avatar = loadAvatarData(core->getSelfId().publicKey);
|
||||||
|
|
|
@ -24,12 +24,12 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class ProfileLocker
|
* @class ProfileLocker
|
||||||
@brief Locks a Tox profile so that multiple instances can not use the same profile.
|
* @brief Locks a Tox profile so that multiple instances can not use the same profile.
|
||||||
Only one lock can be acquired at the same time, which means
|
* Only one lock can be acquired at the same time, which means
|
||||||
that there is little need for manually unlocking.
|
* that there is little need for manually unlocking.
|
||||||
The current lock will expire if you exit or acquire a new one.
|
* The current lock will expire if you exit or acquire a new one.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -42,13 +42,13 @@ QString ProfileLocker::lockPathFromName(const QString& name)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Checks if a profile is currently locked by *another* instance.
|
* @brief Checks if a profile is currently locked by *another* instance.
|
||||||
If we own the lock, we consider it lockable.
|
* If we own the lock, we consider it lockable.
|
||||||
There is no guarantee that the result will still be valid by the
|
* There is no guarantee that the result will still be valid by the
|
||||||
time it is returned, this is provided on a best effort basis.
|
* time it is returned, this is provided on a best effort basis.
|
||||||
@param profile Profile name to check.
|
* @param profile Profile name to check.
|
||||||
@return True, if profile locked, false otherwise.
|
* @return True, if profile locked, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool ProfileLocker::isLockable(QString profile)
|
bool ProfileLocker::isLockable(QString profile)
|
||||||
{
|
{
|
||||||
// If we already have the lock, it's definitely lockable
|
// If we already have the lock, it's definitely lockable
|
||||||
|
@ -60,10 +60,10 @@ bool ProfileLocker::isLockable(QString profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Tries to acquire the lock on a profile, will not block.
|
* @brief Tries to acquire the lock on a profile, will not block.
|
||||||
@param profile Profile to lock.
|
* @param profile Profile to lock.
|
||||||
@return Returns true if we already own the lock.
|
* @return Returns true if we already own the lock.
|
||||||
*/
|
*/
|
||||||
bool ProfileLocker::lock(QString profile)
|
bool ProfileLocker::lock(QString profile)
|
||||||
{
|
{
|
||||||
if (lockfile && curLockName == profile)
|
if (lockfile && curLockName == profile)
|
||||||
|
@ -84,8 +84,8 @@ bool ProfileLocker::lock(QString profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Releases the lock on the current profile.
|
* @brief Releases the lock on the current profile.
|
||||||
*/
|
*/
|
||||||
void ProfileLocker::unlock()
|
void ProfileLocker::unlock()
|
||||||
{
|
{
|
||||||
if (!lockfile)
|
if (!lockfile)
|
||||||
|
@ -98,11 +98,11 @@ void ProfileLocker::unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Check that we actually own the lock.
|
* @brief Check that we actually own the lock.
|
||||||
In case the file was deleted on disk, restore it.
|
* In case the file was deleted on disk, restore it.
|
||||||
If we can't get a lock, exit qTox immediately.
|
* If we can't get a lock, exit qTox immediately.
|
||||||
If we never had a lock in the first place, exit immediately.
|
* If we never had a lock in the first place, exit immediately.
|
||||||
*/
|
*/
|
||||||
void ProfileLocker::assertLock()
|
void ProfileLocker::assertLock()
|
||||||
{
|
{
|
||||||
if (!lockfile)
|
if (!lockfile)
|
||||||
|
@ -128,8 +128,8 @@ void ProfileLocker::assertLock()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Print an error then exit immediately.
|
* @brief Print an error then exit immediately.
|
||||||
*/
|
*/
|
||||||
void ProfileLocker::deathByBrokenLock()
|
void ProfileLocker::deathByBrokenLock()
|
||||||
{
|
{
|
||||||
qCritical() << "Lock is *BROKEN*, exiting immediately";
|
qCritical() << "Lock is *BROKEN*, exiting immediately";
|
||||||
|
@ -137,18 +137,18 @@ void ProfileLocker::deathByBrokenLock()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Chacks, that profile locked.
|
* @brief Chacks, that profile locked.
|
||||||
@return Returns true if we're currently holding a lock.
|
* @return Returns true if we're currently holding a lock.
|
||||||
*/
|
*/
|
||||||
bool ProfileLocker::hasLock()
|
bool ProfileLocker::hasLock()
|
||||||
{
|
{
|
||||||
return lockfile.operator bool();
|
return lockfile.operator bool();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get current locked profile name.
|
* @brief Get current locked profile name.
|
||||||
@return Return the name of the currently loaded profile, a null string if there is none.
|
* @return Return the name of the currently loaded profile, a null string if there is none.
|
||||||
*/
|
*/
|
||||||
QString ProfileLocker::getCurLockName()
|
QString ProfileLocker::getCurLockName()
|
||||||
{
|
{
|
||||||
if (lockfile)
|
if (lockfile)
|
||||||
|
|
|
@ -20,10 +20,10 @@
|
||||||
#include "src/persistence/serialize.h"
|
#include "src/persistence/serialize.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@file serialize.cpp
|
* @file serialize.cpp
|
||||||
Most of functions in this file are unsafe unless otherwise specified.
|
* Most of functions in this file are unsafe unless otherwise specified.
|
||||||
@warning Do not use them on untrusted data (e.g. check a signature first).
|
* @warning Do not use them on untrusted data (e.g. check a signature first).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QString dataToString(QByteArray data)
|
QString dataToString(QByteArray data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,15 +48,15 @@
|
||||||
#include <QNetworkProxy>
|
#include <QNetworkProxy>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@var QHash<QString, QByteArray> Settings::widgetSettings
|
* @var QHash<QString, QByteArray> Settings::widgetSettings
|
||||||
@brief Assume all widgets have unique names
|
* @brief Assume all widgets have unique names
|
||||||
@warning Don't use it to save every single thing you want to save, use it
|
* @warning Don't use it to save every single thing you want to save, use it
|
||||||
for some general purpose widgets, such as MainWindows or Splitters,
|
* for some general purpose widgets, such as MainWindows or Splitters,
|
||||||
which have widget->saveX() and widget->loadX() methods.
|
* which have widget->saveX() and widget->loadX() methods.
|
||||||
|
*
|
||||||
@var QString Settings::toxmeInfo
|
* @var QString Settings::toxmeInfo
|
||||||
@brief Toxme info like name@server
|
* @brief Toxme info like name@server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const QString Settings::globalSettingsFile = "qtox.ini";
|
const QString Settings::globalSettingsFile = "qtox.ini";
|
||||||
Settings* Settings::settings{nullptr};
|
Settings* Settings::settings{nullptr};
|
||||||
|
@ -83,8 +83,8 @@ Settings::~Settings()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Returns the singleton instance.
|
* @brief Returns the singleton instance.
|
||||||
*/
|
*/
|
||||||
Settings& Settings::getInstance()
|
Settings& Settings::getInstance()
|
||||||
{
|
{
|
||||||
if (!settings)
|
if (!settings)
|
||||||
|
@ -392,8 +392,8 @@ void Settings::loadPersonal(Profile* profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Asynchronous, saves the global settings.
|
* @brief Asynchronous, saves the global settings.
|
||||||
*/
|
*/
|
||||||
void Settings::saveGlobal()
|
void Settings::saveGlobal()
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() != settingsThread)
|
if (QThread::currentThread() != settingsThread)
|
||||||
|
@ -514,17 +514,17 @@ void Settings::saveGlobal()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Asynchronous, saves the current profile.
|
* @brief Asynchronous, saves the current profile.
|
||||||
*/
|
*/
|
||||||
void Settings::savePersonal()
|
void Settings::savePersonal()
|
||||||
{
|
{
|
||||||
savePersonal(Nexus::getProfile());
|
savePersonal(Nexus::getProfile());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Asynchronous, saves the profile.
|
* @brief Asynchronous, saves the profile.
|
||||||
@param profile Profile to save.
|
* @param profile Profile to save.
|
||||||
*/
|
*/
|
||||||
void Settings::savePersonal(Profile* profile)
|
void Settings::savePersonal(Profile* profile)
|
||||||
{
|
{
|
||||||
if (!profile)
|
if (!profile)
|
||||||
|
@ -623,9 +623,9 @@ uint32_t Settings::makeProfileId(const QString& profile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get path to directory, where the settings files are stored.
|
* @brief Get path to directory, where the settings files are stored.
|
||||||
@return Path to settings directory, ends with a directory separator.
|
* @return Path to settings directory, ends with a directory separator.
|
||||||
*/
|
*/
|
||||||
QString Settings::getSettingsDirPath() const
|
QString Settings::getSettingsDirPath() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
@ -646,9 +646,9 @@ QString Settings::getSettingsDirPath() const
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get path to directory, where the application data are stored.
|
* @brief Get path to directory, where the application data are stored.
|
||||||
@return Path to application data, ends with a directory separator.
|
* @return Path to application data, ends with a directory separator.
|
||||||
*/
|
*/
|
||||||
QString Settings::getAppDataDirPath() const
|
QString Settings::getAppDataDirPath() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
@ -671,9 +671,9 @@ QString Settings::getAppDataDirPath() const
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get path to directory, where the application cache are stored.
|
* @brief Get path to directory, where the application cache are stored.
|
||||||
@return Path to application cache, ends with a directory separator.
|
* @return Path to application cache, ends with a directory separator.
|
||||||
*/
|
*/
|
||||||
QString Settings::getAppCacheDirPath() const
|
QString Settings::getAppCacheDirPath() const
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&bigLock};
|
QMutexLocker locker{&bigLock};
|
||||||
|
@ -2201,10 +2201,10 @@ void Settings::setAutoLogin(bool state)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Write a default personal .ini settings file for a profile.
|
* @brief Write a default personal .ini settings file for a profile.
|
||||||
@param basename Filename without extension to save settings.
|
* @param basename Filename without extension to save settings.
|
||||||
@example If basename is "profile", settings will be saved in profile.ini
|
* @example If basename is "profile", settings will be saved in profile.ini
|
||||||
*/
|
*/
|
||||||
void Settings::createPersonal(QString basename)
|
void Settings::createPersonal(QString basename)
|
||||||
{
|
{
|
||||||
QString path = getSettingsDirPath() + QDir::separator() + basename + ".ini";
|
QString path = getSettingsDirPath() + QDir::separator() + basename + ".ini";
|
||||||
|
@ -2222,8 +2222,8 @@ void Settings::createPersonal(QString basename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Creates a path to the settings dir, if it doesn't already exist
|
* @brief Creates a path to the settings dir, if it doesn't already exist
|
||||||
*/
|
*/
|
||||||
void Settings::createSettingsDir()
|
void Settings::createSettingsDir()
|
||||||
{
|
{
|
||||||
QString dir = Settings::getSettingsDirPath();
|
QString dir = Settings::getSettingsDirPath();
|
||||||
|
@ -2233,8 +2233,8 @@ void Settings::createSettingsDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Waits for all asynchronous operations to complete
|
* @brief Waits for all asynchronous operations to complete
|
||||||
*/
|
*/
|
||||||
void Settings::sync()
|
void Settings::sync()
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() != settingsThread)
|
if (QThread::currentThread() != settingsThread)
|
||||||
|
|
|
@ -29,34 +29,34 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class SettingsSerializer
|
* @class SettingsSerializer
|
||||||
@brief Serializes a QSettings's data in an (optionally) encrypted binary format.
|
* @brief Serializes a QSettings's data in an (optionally) encrypted binary format.
|
||||||
SettingsSerializer can detect regular .ini files and serialized ones,
|
* SettingsSerializer can detect regular .ini files and serialized ones,
|
||||||
it will read both regular and serialized .ini, but only save in serialized format.
|
* it will read both regular and serialized .ini, but only save in serialized format.
|
||||||
The file is encrypted with the current profile's password, if any.
|
* The file is encrypted with the current profile's password, if any.
|
||||||
The file is only written to disk if save() is called, the destructor does not save to disk
|
* The file is only written to disk if save() is called, the destructor does not save to disk
|
||||||
All member functions are reentrant, but not thread safe.
|
* All member functions are reentrant, but not thread safe.
|
||||||
|
*
|
||||||
@enum SettingsSerializer::RecordTag
|
* @enum SettingsSerializer::RecordTag
|
||||||
@var Value
|
* @var Value
|
||||||
Followed by a QString key then a QVariant value
|
* Followed by a QString key then a QVariant value
|
||||||
@var GroupStart
|
* @var GroupStart
|
||||||
Followed by a QString group name
|
* Followed by a QString group name
|
||||||
@var ArrayStart
|
* @var ArrayStart
|
||||||
Followed by a QString array name and a vuint array size
|
* Followed by a QString array name and a vuint array size
|
||||||
@var ArrayValue
|
* @var ArrayValue
|
||||||
Followed by a vuint array index, a QString key then a QVariant value
|
* Followed by a vuint array index, a QString key then a QVariant value
|
||||||
@var ArrayEnd
|
* @var ArrayEnd
|
||||||
Not followed by any data
|
* Not followed by any data
|
||||||
*/
|
*/
|
||||||
enum class RecordTag : uint8_t
|
enum class RecordTag : uint8_t
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@var static const char magic[];
|
* @var static const char magic[];
|
||||||
@brief Little endian ASCII "QTOX" magic
|
* @brief Little endian ASCII "QTOX" magic
|
||||||
*/
|
*/
|
||||||
const char SettingsSerializer::magic[] = {0x51,0x54,0x4F,0x58};
|
const char SettingsSerializer::magic[] = {0x51,0x54,0x4F,0x58};
|
||||||
|
|
||||||
QDataStream& writeStream(QDataStream& dataStream, const SettingsSerializer::RecordTag& tag)
|
QDataStream& writeStream(QDataStream& dataStream, const SettingsSerializer::RecordTag& tag)
|
||||||
|
@ -241,10 +241,10 @@ SettingsSerializer::Value* SettingsSerializer::findValue(const QString& key)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Checks if the file is serialized settings.
|
* @brief Checks if the file is serialized settings.
|
||||||
@param filePath Path to file to check.
|
* @param filePath Path to file to check.
|
||||||
@return False on error, true otherwise.
|
* @return False on error, true otherwise.
|
||||||
*/
|
*/
|
||||||
bool SettingsSerializer::isSerializedFormat(QString filePath)
|
bool SettingsSerializer::isSerializedFormat(QString filePath)
|
||||||
{
|
{
|
||||||
QFile f(filePath);
|
QFile f(filePath);
|
||||||
|
@ -257,8 +257,8 @@ bool SettingsSerializer::isSerializedFormat(QString filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Loads the settings from file.
|
* @brief Loads the settings from file.
|
||||||
*/
|
*/
|
||||||
void SettingsSerializer::load()
|
void SettingsSerializer::load()
|
||||||
{
|
{
|
||||||
if (isSerializedFormat(path))
|
if (isSerializedFormat(path))
|
||||||
|
@ -268,8 +268,8 @@ void SettingsSerializer::load()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Saves the current settings back to file
|
* @brief Saves the current settings back to file
|
||||||
*/
|
*/
|
||||||
void SettingsSerializer::save()
|
void SettingsSerializer::save()
|
||||||
{
|
{
|
||||||
QSaveFile f(path);
|
QSaveFile f(path);
|
||||||
|
@ -600,9 +600,9 @@ void SettingsSerializer::readIni()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Remove group.
|
* @brief Remove group.
|
||||||
@note The group must be empty.
|
* @note The group must be empty.
|
||||||
@param group ID of group to remove.
|
* @param group ID of group to remove.
|
||||||
*/
|
*/
|
||||||
void SettingsSerializer::removeGroup(int group)
|
void SettingsSerializer::removeGroup(int group)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,21 +36,21 @@
|
||||||
#include <QtConcurrent/QtConcurrentRun>
|
#include <QtConcurrent/QtConcurrentRun>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class SmileyPack
|
* @class SmileyPack
|
||||||
@brief Maps emoticons to smileys.
|
* @brief Maps emoticons to smileys.
|
||||||
|
*
|
||||||
@var QHash<QString, QString> SmileyPack::filenameTable
|
* @var QHash<QString, QString> SmileyPack::filenameTable
|
||||||
@brief Matches an emoticon to its corresponding smiley ie. ":)" -> "happy.png"
|
* @brief Matches an emoticon to its corresponding smiley ie. ":)" -> "happy.png"
|
||||||
|
*
|
||||||
@var QHash<QString, QIcon> SmileyPack::iconCache
|
* @var QHash<QString, QIcon> SmileyPack::iconCache
|
||||||
@brief representation of a smiley ie. "happy.png" -> data
|
* @brief representation of a smiley ie. "happy.png" -> data
|
||||||
|
*
|
||||||
@var QList<QStringList> SmileyPack::emoticons
|
* @var QList<QStringList> SmileyPack::emoticons
|
||||||
@brief {{ ":)", ":-)" }, {":(", ...}, ... }
|
* @brief {{ ":)", ":-)" }, {":(", ...}, ... }
|
||||||
|
*
|
||||||
@var QString SmileyPack::path
|
* @var QString SmileyPack::path
|
||||||
@brief directory containing the cfg and image files
|
* @brief directory containing the cfg and image files
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SmileyPack::SmileyPack()
|
SmileyPack::SmileyPack()
|
||||||
{
|
{
|
||||||
|
@ -60,8 +60,8 @@ SmileyPack::SmileyPack()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Returns the singleton instance.
|
* @brief Returns the singleton instance.
|
||||||
*/
|
*/
|
||||||
SmileyPack& SmileyPack::getInstance()
|
SmileyPack& SmileyPack::getInstance()
|
||||||
{
|
{
|
||||||
static SmileyPack smileyPack;
|
static SmileyPack smileyPack;
|
||||||
|
@ -113,11 +113,11 @@ bool SmileyPack::isValid(const QString &filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Load smile pack
|
* @brief Load smile pack
|
||||||
@note The caller must lock loadingMutex and should run it in a thread
|
* @note The caller must lock loadingMutex and should run it in a thread
|
||||||
@param filename Filename of smilepack.
|
* @param filename Filename of smilepack.
|
||||||
@return False if cannot open file, true otherwise.
|
* @return False if cannot open file, true otherwise.
|
||||||
*/
|
*/
|
||||||
bool SmileyPack::load(const QString& filename)
|
bool SmileyPack::load(const QString& filename)
|
||||||
{
|
{
|
||||||
// discard old data
|
// discard old data
|
||||||
|
|
|
@ -35,11 +35,11 @@ bool toxSaveEventHandler(const QByteArray& eventData)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Import new profile.
|
* @brief Import new profile.
|
||||||
@note Will wait until the core is ready first.
|
* @note Will wait until the core is ready first.
|
||||||
@param path Path to .tox file.
|
* @param path Path to .tox file.
|
||||||
@return True if import success, false, otherwise.
|
* @return True if import success, false, otherwise.
|
||||||
*/
|
*/
|
||||||
bool handleToxSave(const QString& path)
|
bool handleToxSave(const QString& path)
|
||||||
{
|
{
|
||||||
Core* core = Core::getInstance();
|
Core* core = Core::getInstance();
|
||||||
|
|
|
@ -89,8 +89,8 @@ void AboutUser::onSelectDirClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Called when user clicks the bottom OK button, save all settings
|
* @brief Called when user clicks the bottom OK button, save all settings
|
||||||
*/
|
*/
|
||||||
void AboutUser::onAcceptedClicked()
|
void AboutUser::onAcceptedClicked()
|
||||||
{
|
{
|
||||||
ToxId toxId = ToxId(ui->publicKey->text());
|
ToxId toxId = ToxId(ui->publicKey->text());
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@var QString AddFriendForm::lastUsername
|
* @var QString AddFriendForm::lastUsername
|
||||||
@brief Cached username so we can retranslate the invite message
|
* @brief Cached username so we can retranslate the invite message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
AddFriendForm::AddFriendForm()
|
AddFriendForm::AddFriendForm()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ void ChatForm::SendMessageStr(QString msg)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/// TODO: Make faux-offline messaging work partially with the history disabled
|
/// @todo Make faux-offline messaging work partially with the history disabled
|
||||||
ma->markAsSent(QDateTime::currentDateTime());
|
ma->markAsSent(QDateTime::currentDateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
#include "src/core/toxid.h"
|
#include "src/core/toxid.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Spacing in px inserted when the author of the last message changes
|
* Spacing in px inserted when the author of the last message changes
|
||||||
@note Why the hell is this a thing? surely the different font is enough?
|
* @note Why the hell is this a thing? surely the different font is enough?
|
||||||
*/
|
*/
|
||||||
#define AUTHOR_CHANGE_SPACING 5
|
#define AUTHOR_CHANGE_SPACING 5
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
|
|
@ -38,12 +38,12 @@
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@var QList<QLabel*> GroupChatForm::peerLabels
|
* @var QList<QLabel*> GroupChatForm::peerLabels
|
||||||
@brief Maps peernumbers to the QLabels in namesListLayout.
|
* @brief Maps peernumbers to the QLabels in namesListLayout.
|
||||||
|
*
|
||||||
@var QMap<int, QTimer*> GroupChatForm::peerAudioTimers
|
* @var QMap<int, QTimer*> GroupChatForm::peerAudioTimers
|
||||||
@brief Timeout = peer stopped sending audio.
|
* @brief Timeout = peer stopped sending audio.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GroupChatForm::GroupChatForm(Group* chatGroup)
|
GroupChatForm::GroupChatForm(Group* chatGroup)
|
||||||
: group(chatGroup), inCall{false}
|
: group(chatGroup), inCall{false}
|
||||||
|
|
|
@ -267,10 +267,10 @@ GeneralForm::GeneralForm(SettingsWidget *myParent)
|
||||||
connect(bodyUI->cbDontGroupWindows, &QCheckBox::stateChanged, this, &GeneralForm::onDontGroupWindowsChanged);
|
connect(bodyUI->cbDontGroupWindows, &QCheckBox::stateChanged, this, &GeneralForm::onDontGroupWindowsChanged);
|
||||||
connect(bodyUI->cbGroupchatPosition, &QCheckBox::stateChanged, this, &GeneralForm::onGroupchatPositionChanged);
|
connect(bodyUI->cbGroupchatPosition, &QCheckBox::stateChanged, this, &GeneralForm::onGroupchatPositionChanged);
|
||||||
|
|
||||||
// prevent stealing mouse wheel scroll
|
/// prevent stealing mouse wheel scroll
|
||||||
// scrolling event won't be transmitted to comboboxes or qspinboxes when scrolling
|
/// scrolling event won't be transmitted to comboboxes or qspinboxes when scrolling
|
||||||
// you can scroll through general settings without accidentially changing theme/skin/icons etc.
|
/// you can scroll through general settings without accidentially changing theme/skin/icons etc.
|
||||||
// @see GeneralForm::eventFilter(QObject *o, QEvent *e) at the bottom of this file for more
|
/// @see GeneralForm::eventFilter(QObject *o, QEvent *e) at the bottom of this file for more
|
||||||
for (QComboBox *cb : findChildren<QComboBox*>())
|
for (QComboBox *cb : findChildren<QComboBox*>())
|
||||||
{
|
{
|
||||||
cb->installEventFilter(this);
|
cb->installEventFilter(this);
|
||||||
|
|
|
@ -20,13 +20,6 @@
|
||||||
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
along with qTox. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
@file tabcompleter.h
|
|
||||||
@file tabcompleter.cpp
|
|
||||||
These files were taken from the Quassel IRC client source (src/uisupport), and
|
|
||||||
was greatly simplified for use in qTox.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "tabcompleter.h"
|
#include "tabcompleter.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
@ -36,6 +29,13 @@ was greatly simplified for use in qTox.
|
||||||
#include "src/group.h"
|
#include "src/group.h"
|
||||||
#include "src/widget/tool/chattextedit.h"
|
#include "src/widget/tool/chattextedit.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file tabcompleter.h
|
||||||
|
* @file tabcompleter.cpp
|
||||||
|
* These files were taken from the Quassel IRC client source (src/uisupport), and
|
||||||
|
* was greatly simplified for use in qTox.
|
||||||
|
*/
|
||||||
|
|
||||||
const QString TabCompleter::nickSuffix = QString(": ");
|
const QString TabCompleter::nickSuffix = QString(": ");
|
||||||
|
|
||||||
TabCompleter::TabCompleter(ChatTextEdit* msgEdit, Group* group)
|
TabCompleter::TabCompleter(ChatTextEdit* msgEdit, Group* group)
|
||||||
|
|
|
@ -33,15 +33,15 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class GUI
|
* @class GUI
|
||||||
@brief Abstracts the GUI from the target backend (DesktopGUI, ...)
|
* @brief Abstracts the GUI from the target backend (DesktopGUI, ...)
|
||||||
|
*
|
||||||
All the functions exposed here are thread-safe.
|
* All the functions exposed here are thread-safe.
|
||||||
Prefer calling this class to calling a GUI backend directly.
|
* Prefer calling this class to calling a GUI backend directly.
|
||||||
|
*
|
||||||
@fn void GUI::resized()
|
* @fn void GUI::resized()
|
||||||
@brief Emitted when the GUI is resized on supported platforms.
|
* @brief Emitted when the GUI is resized on supported platforms.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GUI::GUI(QObject *parent) :
|
GUI::GUI(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent)
|
||||||
|
@ -52,8 +52,8 @@ GUI::GUI(QObject *parent) :
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Returns the singleton instance.
|
* @brief Returns the singleton instance.
|
||||||
*/
|
*/
|
||||||
GUI& GUI::getInstance()
|
GUI& GUI::getInstance()
|
||||||
{
|
{
|
||||||
static GUI gui;
|
static GUI gui;
|
||||||
|
@ -63,8 +63,8 @@ GUI& GUI::getInstance()
|
||||||
// Implementation of the public clean interface
|
// Implementation of the public clean interface
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Clear the GUI's contact list.
|
* @brief Clear the GUI's contact list.
|
||||||
*/
|
*/
|
||||||
void GUI::clearContacts()
|
void GUI::clearContacts()
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() == qApp->thread())
|
if (QThread::currentThread() == qApp->thread())
|
||||||
|
@ -74,10 +74,10 @@ void GUI::clearContacts()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Will enable or disable the GUI.
|
* @brief Will enable or disable the GUI.
|
||||||
@note A disabled GUI can't be interacted with by the user.
|
* @note A disabled GUI can't be interacted with by the user.
|
||||||
@param state Enable/disable GUI.
|
* @param state Enable/disable GUI.
|
||||||
*/
|
*/
|
||||||
void GUI::setEnabled(bool state)
|
void GUI::setEnabled(bool state)
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() == qApp->thread())
|
if (QThread::currentThread() == qApp->thread())
|
||||||
|
@ -92,11 +92,11 @@ void GUI::setEnabled(bool state)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Change the title of the main window.
|
* @brief Change the title of the main window.
|
||||||
@param title Titile to set.
|
* @param title Titile to set.
|
||||||
|
*
|
||||||
This is usually always visible to the user.
|
* This is usually always visible to the user.
|
||||||
*/
|
*/
|
||||||
void GUI::setWindowTitle(const QString& title)
|
void GUI::setWindowTitle(const QString& title)
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() == qApp->thread())
|
if (QThread::currentThread() == qApp->thread())
|
||||||
|
@ -111,8 +111,8 @@ void GUI::setWindowTitle(const QString& title)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Reloads the application theme and redraw the window.
|
* @brief Reloads the application theme and redraw the window.
|
||||||
*/
|
*/
|
||||||
void GUI::reloadTheme()
|
void GUI::reloadTheme()
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() == qApp->thread())
|
if (QThread::currentThread() == qApp->thread())
|
||||||
|
@ -126,8 +126,8 @@ void GUI::reloadTheme()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Optionally switches to a view of the qTox update being downloaded.
|
* @brief Optionally switches to a view of the qTox update being downloaded.
|
||||||
*/
|
*/
|
||||||
void GUI::showUpdateDownloadProgress()
|
void GUI::showUpdateDownloadProgress()
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() == qApp->thread())
|
if (QThread::currentThread() == qApp->thread())
|
||||||
|
@ -141,10 +141,10 @@ void GUI::showUpdateDownloadProgress()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Show some text to the user.
|
* @brief Show some text to the user.
|
||||||
@param title Title of information window.
|
* @param title Title of information window.
|
||||||
@param msg Text in information window.
|
* @param msg Text in information window.
|
||||||
*/
|
*/
|
||||||
void GUI::showInfo(const QString& title, const QString& msg)
|
void GUI::showInfo(const QString& title, const QString& msg)
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() == qApp->thread())
|
if (QThread::currentThread() == qApp->thread())
|
||||||
|
@ -159,10 +159,10 @@ void GUI::showInfo(const QString& title, const QString& msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Show a warning to the user
|
* @brief Show a warning to the user
|
||||||
@param title Title of warning window.
|
* @param title Title of warning window.
|
||||||
@param msg Text in warning window.
|
* @param msg Text in warning window.
|
||||||
*/
|
*/
|
||||||
void GUI::showWarning(const QString& title, const QString& msg)
|
void GUI::showWarning(const QString& title, const QString& msg)
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() == qApp->thread())
|
if (QThread::currentThread() == qApp->thread())
|
||||||
|
@ -177,10 +177,10 @@ void GUI::showWarning(const QString& title, const QString& msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Show an error to the user.
|
* @brief Show an error to the user.
|
||||||
@param title Title of error window.
|
* @param title Title of error window.
|
||||||
@param msg Text in error window.
|
* @param msg Text in error window.
|
||||||
*/
|
*/
|
||||||
void GUI::showError(const QString& title, const QString& msg)
|
void GUI::showError(const QString& title, const QString& msg)
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() == qApp->thread())
|
if (QThread::currentThread() == qApp->thread())
|
||||||
|
@ -200,14 +200,14 @@ void GUI::showError(const QString& title, const QString& msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Asks the user a question with Ok/Cancel or Yes/No buttons.
|
* @brief Asks the user a question with Ok/Cancel or Yes/No buttons.
|
||||||
@param title Title of question window.
|
* @param title Title of question window.
|
||||||
@param msg Text in question window.
|
* @param msg Text in question window.
|
||||||
@param defaultAns If is true, default was positive answer. Negative otherwise.
|
* @param defaultAns If is true, default was positive answer. Negative otherwise.
|
||||||
@param warning If is true, we will use a special warning style.
|
* @param warning If is true, we will use a special warning style.
|
||||||
@param yesno Show "Yes" and "No" buttons.
|
* @param yesno Show "Yes" and "No" buttons.
|
||||||
@return True if the answer is positive, false otherwise.
|
* @return True if the answer is positive, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool GUI::askQuestion(const QString& title, const QString& msg,
|
bool GUI::askQuestion(const QString& title, const QString& msg,
|
||||||
bool defaultAns, bool warning,
|
bool defaultAns, bool warning,
|
||||||
bool yesno)
|
bool yesno)
|
||||||
|
@ -229,17 +229,17 @@ bool GUI::askQuestion(const QString& title, const QString& msg,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Asks the user a question.
|
* @brief Asks the user a question.
|
||||||
|
*
|
||||||
The text for the displayed buttons can be specified.
|
* The text for the displayed buttons can be specified.
|
||||||
@param title Title of question window.
|
* @param title Title of question window.
|
||||||
@param msg Text in question window.
|
* @param msg Text in question window.
|
||||||
@param button1 Text of positive button.
|
* @param button1 Text of positive button.
|
||||||
@param button2 Text of negative button.
|
* @param button2 Text of negative button.
|
||||||
@param defaultAns If is true, default was positive answer. Negative otherwise.
|
* @param defaultAns If is true, default was positive answer. Negative otherwise.
|
||||||
@param warning If is true, we will use a special warning style.
|
* @param warning If is true, we will use a special warning style.
|
||||||
@return True if the answer is positive, false otherwise.
|
* @return True if the answer is positive, false otherwise.
|
||||||
*/
|
*/
|
||||||
bool GUI::askQuestion(const QString& title, const QString& msg,
|
bool GUI::askQuestion(const QString& title, const QString& msg,
|
||||||
const QString& button1, const QString& button2,
|
const QString& button1, const QString& button2,
|
||||||
bool defaultAns, bool warning)
|
bool defaultAns, bool warning)
|
||||||
|
@ -260,20 +260,20 @@ bool GUI::askQuestion(const QString& title, const QString& msg,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Asks the user to input text and returns the answer.
|
* @brief Asks the user to input text and returns the answer.
|
||||||
|
*
|
||||||
The interface is equivalent to QInputDialog::getItem()
|
* The interface is equivalent to QInputDialog::getItem()
|
||||||
@param parent Is the dialog's parent widget
|
* @param parent Is the dialog's parent widget
|
||||||
@param title Is the text which is displayed in the title bar of the dialog.
|
* @param title Is the text which is displayed in the title bar of the dialog.
|
||||||
@param label Is the text which is shown to the user (it should say what should be entered).
|
* @param label Is the text which is shown to the user (it should say what should be entered).
|
||||||
@param items Is the string list which is inserted into the combobox.
|
* @param items Is the string list which is inserted into the combobox.
|
||||||
@param current Is the number of the item which should be the current item.
|
* @param current Is the number of the item which should be the current item.
|
||||||
@param editable If is true the user can enter their own text, otherwise the user may only select one of the existing items.
|
* @param editable If is true the user can enter their own text, otherwise the user may only select one of the existing items.
|
||||||
@param ok If is nonnull will be set to true if the user pressed OK and to false if the user pressed Cancel.
|
* @param ok If is nonnull will be set to true if the user pressed OK and to false if the user pressed Cancel.
|
||||||
@param flags The dialog will uses to widget flags.
|
* @param flags The dialog will uses to widget flags.
|
||||||
@param hints Is the input method hints that will be used if the combobox is editable and an input method is active.
|
* @param hints Is the input method hints that will be used if the combobox is editable and an input method is active.
|
||||||
@return This function returns the text of the current item, or if editable is true, the current text of the combobox.
|
* @return This function returns the text of the current item, or if editable is true, the current text of the combobox.
|
||||||
*/
|
*/
|
||||||
QString GUI::itemInputDialog(QWidget * parent, const QString & title,
|
QString GUI::itemInputDialog(QWidget * parent, const QString & title,
|
||||||
const QString & label, const QStringList & items,
|
const QString & label, const QStringList & items,
|
||||||
int current, bool editable, bool * ok,
|
int current, bool editable, bool * ok,
|
||||||
|
@ -298,11 +298,11 @@ QString GUI::itemInputDialog(QWidget * parent, const QString & title,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Asks the user to answer a password.
|
* @brief Asks the user to answer a password.
|
||||||
@param cancel Is the text on the cancel button.
|
* @param cancel Is the text on the cancel button.
|
||||||
@param body Is descriptive text that will be shown to the user.
|
* @param body Is descriptive text that will be shown to the user.
|
||||||
@return Entered password.
|
* @return Entered password.
|
||||||
*/
|
*/
|
||||||
QString GUI::passwordDialog(const QString& cancel, const QString& body)
|
QString GUI::passwordDialog(const QString& cancel, const QString& body)
|
||||||
{
|
{
|
||||||
if (QThread::currentThread() == qApp->thread())
|
if (QThread::currentThread() == qApp->thread())
|
||||||
|
@ -468,9 +468,9 @@ QString GUI::_passwordDialog(const QString& cancel, const QString& body)
|
||||||
// Other
|
// Other
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get the main widget.
|
* @brief Get the main widget.
|
||||||
@return The main QWidget* of the application
|
* @return The main QWidget* of the application
|
||||||
*/
|
*/
|
||||||
QWidget* GUI::getMainWidget()
|
QWidget* GUI::getMainWidget()
|
||||||
{
|
{
|
||||||
QWidget* maingui{nullptr};
|
QWidget* maingui{nullptr};
|
||||||
|
|
|
@ -72,8 +72,8 @@ LoginScreen::~LoginScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Resets the UI, clears all fields.
|
* @brief Resets the UI, clears all fields.
|
||||||
*/
|
*/
|
||||||
void LoginScreen::reset()
|
void LoginScreen::reset()
|
||||||
{
|
{
|
||||||
ui->newUsername->clear();
|
ui->newUsername->clear();
|
||||||
|
|
|
@ -21,9 +21,9 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@var QPixmap* MaskablePixmapWidget::renderTarget
|
* @var QPixmap* MaskablePixmapWidget::renderTarget
|
||||||
@brief pointer to dynamically call the constructor.
|
* @brief pointer to dynamically call the constructor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MaskablePixmapWidget::MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName)
|
MaskablePixmapWidget::MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
|
|
@ -67,16 +67,16 @@ void NotificationScrollArea::trackWidget(GenericChatroomWidget* widget)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Delete notification bar from visible elements on scroll area
|
* @brief Delete notification bar from visible elements on scroll area
|
||||||
*/
|
*/
|
||||||
void NotificationScrollArea::updateVisualTracking() {
|
void NotificationScrollArea::updateVisualTracking() {
|
||||||
updateTracking(nullptr);
|
updateTracking(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Delete notification bar from visible elements and widget on scroll area
|
* @brief Delete notification bar from visible elements and widget on scroll area
|
||||||
@param widget Chatroom widget to remove from tracked widgets
|
* @param widget Chatroom widget to remove from tracked widgets
|
||||||
*/
|
*/
|
||||||
void NotificationScrollArea::updateTracking(GenericChatroomWidget *widget)
|
void NotificationScrollArea::updateTracking(GenericChatroomWidget *widget)
|
||||||
{
|
{
|
||||||
QHash<GenericChatroomWidget*, Visibility>::iterator i = trackedWidgets.begin();
|
QHash<GenericChatroomWidget*, Visibility>::iterator i = trackedWidgets.begin();
|
||||||
|
|
|
@ -32,9 +32,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@file qrwidget.cpp
|
* @file qrwidget.cpp
|
||||||
@link https://stackoverflow.com/questions/21400254/how-to-draw-a-qr-code-with-qt-in-native-c-c
|
* @link https://stackoverflow.com/questions/21400254/how-to-draw-a-qr-code-with-qt-in-native-c-c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QRWidget::QRWidget(QWidget *parent) : QWidget(parent), data("0")
|
QRWidget::QRWidget(QWidget *parent) : QWidget(parent), data("0")
|
||||||
//Note: The encoding fails with empty string so I just default to something else.
|
//Note: The encoding fails with empty string so I just default to something else.
|
||||||
|
@ -63,10 +63,10 @@ QImage* QRWidget::getImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QRWidget::saveImage
|
* @brief QRWidget::saveImage
|
||||||
@param path Full path to the file with extension.
|
* @param path Full path to the file with extension.
|
||||||
@return indicate if saving was successful.
|
* @return indicate if saving was successful.
|
||||||
*/
|
*/
|
||||||
bool QRWidget::saveImage(QString path)
|
bool QRWidget::saveImage(QString path)
|
||||||
{
|
{
|
||||||
return image->save(path, 0, 75); //0 - image format same as file extension, 75-quality, png file is ~6.3kb
|
return image->save(path, 0, 75); //0 - image format same as file extension, 75-quality, png file is ~6.3kb
|
||||||
|
|
|
@ -32,29 +32,29 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@enum Style::Font
|
* @enum Style::Font
|
||||||
|
*
|
||||||
@var ExtraBig
|
* @var ExtraBig
|
||||||
@brief [SystemDefault + 2]px, bold
|
* @brief [SystemDefault + 2]px, bold
|
||||||
|
*
|
||||||
@var Big
|
* @var Big
|
||||||
@brief [SystemDefault]px
|
* @brief [SystemDefault]px
|
||||||
|
*
|
||||||
@var BigBold
|
* @var BigBold
|
||||||
@brief [SystemDefault]px, bold
|
* @brief [SystemDefault]px, bold
|
||||||
|
*
|
||||||
@var Medium
|
* @var Medium
|
||||||
@brief [SystemDefault - 1]px
|
* @brief [SystemDefault - 1]px
|
||||||
|
*
|
||||||
@var MediumBold
|
* @var MediumBold
|
||||||
@brief [SystemDefault - 1]px, bold
|
* @brief [SystemDefault - 1]px, bold
|
||||||
|
*
|
||||||
@var Small
|
* @var Small
|
||||||
@brief [SystemDefault - 2]px
|
* @brief [SystemDefault - 2]px
|
||||||
|
*
|
||||||
@var SmallLight
|
* @var SmallLight
|
||||||
@brief [SystemDefault - 2]px, light
|
* @brief [SystemDefault - 2]px, light
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// helper functions
|
// helper functions
|
||||||
QFont appFont(int pixelSize, int weight)
|
QFont appFont(int pixelSize, int weight)
|
||||||
|
@ -207,11 +207,11 @@ void Style::setThemeColor(int color)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Set theme color.
|
* @brief Set theme color.
|
||||||
@param color Color to set.
|
* @param color Color to set.
|
||||||
|
*
|
||||||
Pass an invalid QColor to reset to defaults.
|
* Pass an invalid QColor to reset to defaults.
|
||||||
*/
|
*/
|
||||||
void Style::setThemeColor(const QColor &color)
|
void Style::setThemeColor(const QColor &color)
|
||||||
{
|
{
|
||||||
if (!color.isValid())
|
if (!color.isValid())
|
||||||
|
@ -237,8 +237,8 @@ void Style::setThemeColor(const QColor &color)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Reloads some CCS
|
* @brief Reloads some CCS
|
||||||
*/
|
*/
|
||||||
void Style::applyTheme()
|
void Style::applyTheme()
|
||||||
{
|
{
|
||||||
GUI::reloadTheme();
|
GUI::reloadTheme();
|
||||||
|
|
|
@ -32,24 +32,24 @@
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@class CallConfirmWidget
|
* @class CallConfirmWidget
|
||||||
@brief This is a widget with dialog buttons to accept/reject a call
|
* @brief This is a widget with dialog buttons to accept/reject a call
|
||||||
|
*
|
||||||
It tracks the position of another widget called the anchor
|
* It tracks the position of another widget called the anchor
|
||||||
and looks like a bubble at the bottom of that widget.
|
* and looks like a bubble at the bottom of that widget.
|
||||||
|
*
|
||||||
@var const QWidget* CallConfirmWidget::anchor
|
* @var const QWidget* CallConfirmWidget::anchor
|
||||||
@brief The widget we're going to be tracking
|
* @brief The widget we're going to be tracking
|
||||||
|
*
|
||||||
@var const Friend& CallConfirmWidget::f
|
* @var const Friend& CallConfirmWidget::f
|
||||||
@brief The friend on whose chat form we should appear
|
* @brief The friend on whose chat form we should appear
|
||||||
|
*
|
||||||
@var const int CallConfirmWidget::roundedFactor
|
* @var const int CallConfirmWidget::roundedFactor
|
||||||
@brief By how much are the corners of the main rect rounded
|
* @brief By how much are the corners of the main rect rounded
|
||||||
|
*
|
||||||
@var const qreal CallConfirmWidget::rectRatio
|
* @var const qreal CallConfirmWidget::rectRatio
|
||||||
@brief Used to correct the rounding factors on non-square rects
|
* @brief Used to correct the rounding factors on non-square rects
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor, const Friend& f) :
|
CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor, const Friend& f) :
|
||||||
QWidget(), anchor(Anchor), f(f),
|
QWidget(), anchor(Anchor), f(f),
|
||||||
|
@ -96,8 +96,8 @@ CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor, const Friend& f) :
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Recalculate our positions to track the anchor
|
* @brief Recalculate our positions to track the anchor
|
||||||
*/
|
*/
|
||||||
void CallConfirmWidget::reposition()
|
void CallConfirmWidget::reposition()
|
||||||
{
|
{
|
||||||
if (parentWidget())
|
if (parentWidget())
|
||||||
|
|
|
@ -152,9 +152,9 @@ void CroppingLabel::showTextEdit()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Get original full text.
|
* @brief Get original full text.
|
||||||
@return The un-cropped text.
|
* @return The un-cropped text.
|
||||||
*/
|
*/
|
||||||
QString CroppingLabel::fullText()
|
QString CroppingLabel::fullText()
|
||||||
{
|
{
|
||||||
return origText;
|
return origText;
|
||||||
|
|
|
@ -188,9 +188,9 @@ void ScreenshotGrabber::chooseHelperTooltipText(QRect rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@internal
|
* @internal
|
||||||
@brief Align the tooltip centered at top of screen with the mouse cursor.
|
* @brief Align the tooltip centered at top of screen with the mouse cursor.
|
||||||
*/
|
*/
|
||||||
void ScreenshotGrabber::adjustTooltipPosition()
|
void ScreenshotGrabber::adjustTooltipPosition()
|
||||||
{
|
{
|
||||||
QRect recGL = QGuiApplication::primaryScreen()->virtualGeometry();
|
QRect recGL = QGuiApplication::primaryScreen()->virtualGeometry();
|
||||||
|
|
|
@ -34,8 +34,8 @@ QVector<Translator::Callback> Translator::callbacks;
|
||||||
QMutex Translator::lock;
|
QMutex Translator::lock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Loads the translations according to the settings or locale.
|
* @brief Loads the translations according to the settings or locale.
|
||||||
*/
|
*/
|
||||||
void Translator::translate()
|
void Translator::translate()
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&lock};
|
QMutexLocker locker{&lock};
|
||||||
|
@ -91,9 +91,9 @@ void Translator::translate()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Register a function to be called when the UI needs to be retranslated.
|
* @brief Register a function to be called when the UI needs to be retranslated.
|
||||||
@param f Function, wich will called.
|
* @param f Function, wich will called.
|
||||||
@param owner Widget to retanslate.
|
* @param owner Widget to retanslate.
|
||||||
*/
|
*/
|
||||||
void Translator::registerHandler(std::function<void()> f, void *owner)
|
void Translator::registerHandler(std::function<void()> f, void *owner)
|
||||||
{
|
{
|
||||||
|
@ -102,9 +102,9 @@ void Translator::registerHandler(std::function<void()> f, void *owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Unregisters all handlers of an owner.
|
* @brief Unregisters all handlers of an owner.
|
||||||
@param owner Owner to unregister.
|
* @param owner Owner to unregister.
|
||||||
*/
|
*/
|
||||||
void Translator::unregister(void *owner)
|
void Translator::unregister(void *owner)
|
||||||
{
|
{
|
||||||
QMutexLocker locker{&lock};
|
QMutexLocker locker{&lock};
|
||||||
|
|
|
@ -539,8 +539,8 @@ Widget::~Widget()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Returns the singleton instance.
|
* @brief Returns the singleton instance.
|
||||||
*/
|
*/
|
||||||
Widget* Widget::getInstance()
|
Widget* Widget::getInstance()
|
||||||
{
|
{
|
||||||
if (!instance)
|
if (!instance)
|
||||||
|
@ -550,8 +550,8 @@ Widget* Widget::getInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Switches to the About settings page.
|
* @brief Switches to the About settings page.
|
||||||
*/
|
*/
|
||||||
void Widget::showUpdateDownloadProgress()
|
void Widget::showUpdateDownloadProgress()
|
||||||
{
|
{
|
||||||
settingsWidget->showAbout();
|
settingsWidget->showAbout();
|
||||||
|
@ -1711,8 +1711,8 @@ void Widget::onEmptyGroupCreated(int groupId)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief Used to reset the blinking icon.
|
* @brief Used to reset the blinking icon.
|
||||||
*/
|
*/
|
||||||
void Widget::resetIcon() {
|
void Widget::resetIcon() {
|
||||||
eventIcon = false;
|
eventIcon = false;
|
||||||
eventFlag = false;
|
eventFlag = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user