commit de36fe2a4ef9a670f6c164ccc36653d53e6689ab Author: blue Date: Fri Mar 29 17:54:34 2019 +0300 initial diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..1765da5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.0) +project(squawk) + +# Find includes in corresponding build directories +set(CMAKE_INCLUDE_CURRENT_DIR ON) +# Instruct CMake to run moc automatically when needed. +set(CMAKE_AUTOMOC ON) +# Instruct CMake to create code from Qt designer ui files +set(CMAKE_AUTOUIC ON) + +find_package(Qt5Widgets CONFIG REQUIRED) +set(squawk_SRC + main.cpp +) + +# Tell CMake to create the helloworld executable +add_executable(squawk ${squawk_SRC}) +target_link_libraries(squawk Qt5::Widgets) + +add_subdirectory(ui) +add_subdirectory(core) + +target_link_libraries(squawk squawkUI) +target_link_libraries(squawk squawkCORE) + +# Install the executable +install(TARGETS squawk DESTINATION bin) diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt new file mode 100644 index 0000000..4f99ee0 --- /dev/null +++ b/core/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.0) +project(squawkCORE) + +# Instruct CMake to run moc automatically when needed. +set(CMAKE_AUTOMOC ON) + +find_package(Qt5Widgets CONFIG REQUIRED) +find_package(Qt5Network CONFIG REQUIRED) + +set(squawkCORE_SRC + squawk.cpp + account.cpp +) + +# Tell CMake to create the helloworld executable +add_library(squawkCORE ${squawkCORE_SRC}) + +# Use the Widgets module from Qt 5. +target_link_libraries(squawkCORE Qt5::Core) +target_link_libraries(squawkCORE Qt5::Network) +target_link_libraries(squawkCORE qxmpp) + +# Install the executable +install(TARGETS squawkCORE DESTINATION lib) diff --git a/core/account.cpp b/core/account.cpp new file mode 100644 index 0000000..e26e702 --- /dev/null +++ b/core/account.cpp @@ -0,0 +1,17 @@ +#include "account.h" + +using namespace Core; + +Account::Account(const QString& p_jid, const QString& p_password, QObject* parent): + QObject(parent), + jid(p_jid), + password(p_password), + client() +{ + +} + +Account::~Account() +{ + +} diff --git a/core/account.h b/core/account.h new file mode 100644 index 0000000..2766d87 --- /dev/null +++ b/core/account.h @@ -0,0 +1,25 @@ +#ifndef CORE_ACCOUNT_H +#define CORE_ACCOUNT_H + +#include + +#include + +namespace Core +{ + +class Account : public QObject +{ +public: + Account(const QString& p_jid, const QString& p_password, QObject* parent = 0); + ~Account(); + +private: + QString jid; + QString password; + QXmppClient client; +}; + +} + +#endif // CORE_ACCOUNT_H diff --git a/core/squawk.cpp b/core/squawk.cpp new file mode 100644 index 0000000..e681769 --- /dev/null +++ b/core/squawk.cpp @@ -0,0 +1,15 @@ +#include "squawk.h" + +using namespace Core; + +Squawk::Squawk(QObject* parent): + QObject(parent), + accounts() +{ + +} + +Squawk::~Squawk() +{ + +} diff --git a/core/squawk.h b/core/squawk.h new file mode 100644 index 0000000..cd56bf2 --- /dev/null +++ b/core/squawk.h @@ -0,0 +1,27 @@ +#ifndef CORE_SQUAWK_H +#define CORE_SQUAWK_H + +#include +#include + +#include "account.h" + +namespace Core +{ +class Squawk : public QObject +{ + Q_OBJECT + +public: + Squawk(QObject* parent = 0); + ~Squawk(); + +private: + typedef std::deque Accounts; + + Accounts accounts; +}; + +} + +#endif // CORE_SQUAWK_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..8b905c4 --- /dev/null +++ b/main.cpp @@ -0,0 +1,24 @@ +#include "ui/squawk.h" +#include "core/squawk.h" +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Squawk w; + w.show(); + + Core::Squawk* squawk = new Core::Squawk(); + QThread* coreThread = new QThread(); + squawk->moveToThread(coreThread); + + QObject::connect(coreThread, SIGNAL(finished()), squawk, SLOT(deleteLater())); + //QObject::connect(this, &Controller::operate, worker, &Worker::doWork); + //QObject::connect(worker, &Worker::resultReady, this, &Controller::handleResults); + coreThread->start(); + + return app.exec(); +} + diff --git a/ui/CMakeLists.txt b/ui/CMakeLists.txt new file mode 100644 index 0000000..4dccfc3 --- /dev/null +++ b/ui/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.0) +project(squawkUI) + +# Instruct CMake to run moc automatically when needed. +set(CMAKE_AUTOMOC ON) +# Instruct CMake to create code from Qt designer ui files +set(CMAKE_AUTOUIC ON) + +# Find the QtWidgets library +find_package(Qt5Widgets CONFIG REQUIRED) + +set(squawkUI_SRC + squawk.cpp + accounts.cpp +) + +# Tell CMake to create the helloworld executable +add_library(squawkUI ${squawkUI_SRC}) + +# Use the Widgets module from Qt 5. +target_link_libraries(squawkUI Qt5::Widgets) + +# Install the executable +install(TARGETS squawkUI DESTINATION lib) diff --git a/ui/accounts.cpp b/ui/accounts.cpp new file mode 100644 index 0000000..d348f98 --- /dev/null +++ b/ui/accounts.cpp @@ -0,0 +1,10 @@ +#include "accounts.h" +#include "ui_accounts.h" + +Accounts::Accounts(QWidget *parent) : + m_ui(new Ui::Accounts) +{ + m_ui->setupUi(this); +} + +Accounts::~Accounts() = default; diff --git a/ui/accounts.h b/ui/accounts.h new file mode 100644 index 0000000..95dc125 --- /dev/null +++ b/ui/accounts.h @@ -0,0 +1,26 @@ +#ifndef ACCOUNTS_H +#define ACCOUNTS_H + +#include +#include + +namespace Ui +{ +class Accounts; +} + +/** + * @todo write docs + */ +class Accounts : public QWidget +{ + Q_OBJECT +public: + explicit Accounts(QWidget *parent = nullptr); + ~Accounts() override; + +private: + QScopedPointer m_ui; +}; + +#endif // ACCOUNTS_H diff --git a/ui/accounts.ui b/ui/accounts.ui new file mode 100644 index 0000000..3440a56 --- /dev/null +++ b/ui/accounts.ui @@ -0,0 +1,73 @@ + + + Accounts + + + + 0 + 0 + 768 + 235 + + + + Accounts + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Add + + + + + + + Edit + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Delete + + + + + + + + + + + diff --git a/ui/squawk.cpp b/ui/squawk.cpp new file mode 100644 index 0000000..0f70fce --- /dev/null +++ b/ui/squawk.cpp @@ -0,0 +1,43 @@ +#include "squawk.h" +#include "ui_squawk.h" + +Squawk::Squawk(QWidget *parent) : + QMainWindow(parent), + m_ui(new Ui::Squawk), + accounts(0) +{ + m_ui->setupUi(this); + + connect(m_ui->actionAccounts, SIGNAL(triggered()), this, SLOT(onAccounts())); +} + +Squawk::~Squawk() { + +} + +void Squawk::onAccounts() +{ + if (accounts == 0) { + accounts = new Accounts(this); + accounts->setAttribute(Qt::WA_DeleteOnClose); + connect(accounts, SIGNAL(destroyed(QObject*)), this, SLOT(onAccountsClosed(QObject*))); + accounts->show(); + } else { + accounts->focusWidget(); + } +} + +void Squawk::closeEvent(QCloseEvent* event) +{ + if (accounts != 0) { + accounts->close(); + } + + QMainWindow::closeEvent(event); +} + + +void Squawk::onAccountsClosed(QObject* parent) +{ + accounts = 0; +} diff --git a/ui/squawk.h b/ui/squawk.h new file mode 100644 index 0000000..41b9d3f --- /dev/null +++ b/ui/squawk.h @@ -0,0 +1,35 @@ +#ifndef SQUAWK_H +#define SQUAWK_H + +#include +#include +#include + +#include "accounts.h" + +namespace Ui { +class Squawk; +} + +class Squawk : public QMainWindow +{ + Q_OBJECT + +public: + explicit Squawk(QWidget *parent = nullptr); + ~Squawk() override; + +private: + QScopedPointer m_ui; + + Accounts* accounts; + +protected: + void closeEvent(QCloseEvent * event) override; + +private slots: + void onAccounts(); + void onAccountsClosed(QObject* parent = 0); +}; + +#endif // SQUAWK_H diff --git a/ui/squawk.ui b/ui/squawk.ui new file mode 100644 index 0000000..30f1219 --- /dev/null +++ b/ui/squawk.ui @@ -0,0 +1,51 @@ + + + Squawk + + + + 0 + 0 + 400 + 300 + + + + squawk + + + + + + 0 + 0 + 400 + 27 + + + + + Settings + + + + + + + + TopToolBarArea + + + true + + + + + + Accounts + + + + + +