Commit fdc7f9b8 authored by Andreas Traczyk's avatar Andreas Traczyk

debug: adds LRCInstance, responds to debugMessageReceived

Change-Id: If4f48ab8b23c705042db3230044e3875f88bfcca
parent 6792e27d
......@@ -29,7 +29,7 @@ BUILD=$${BUILD}
TARGET = Ring
TEMPLATE = app
QMAKE_CXXFLAGS += -std=c++11
QMAKE_CXXFLAGS += -std=c++14
contains(BUILD, Debug) {
QMAKE_STRIP = echo
......@@ -123,7 +123,8 @@ HEADERS += mainwindow.h \
deleteaccountdialog.h \
bannedcontactswidget.h \
photoboothwidget.h \
deletecontactdialog.h
deletecontactdialog.h \
lrcinstance.h
contains(DEFINES, URI_PROTOCOL) {
HEADERS += shmclient.h
......
/**************************************************************************
| Copyright (C) 2015-2018 by Savoir-faire Linux |
| Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation; either version 3 of the License, or |
| (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program. If not, see <http://www.gnu.org/licenses/>. |
**************************************************************************/
#pragma once
#ifdef _MSC_VER
#undef ERROR
#endif
#include "api/lrc.h"
#include "api/account.h"
#include "api/newaccountmodel.h"
#include "api/newcallmodel.h"
#include "api/behaviorcontroller.h"
#include "api/conversation.h"
#include "api/contactmodel.h"
#include "api/contact.h"
#include "api/datatransfermodel.h"
class LRCInstance {
public:
static void init() {
instance();
};
static lrc::api::Lrc& getAPI() {
return *(instance().lrc_);
};
static void connectivityChanged() {
instance().lrc_->connectivityChanged();
};
static const lrc::api::NewAccountModel& accountModel() {
return instance().lrc_->getAccountModel();
};
static const lrc::api::BehaviorController& behaviorController() {
return instance().lrc_->getBehaviorController();
};
static const lrc::api::DataTransferModel& dataTransferModel() {
return instance().lrc_->getDataTransferModel();
};
static bool isConnected() {
return instance().lrc_->isConnected();
};
private:
std::unique_ptr<lrc::api::Lrc> lrc_;
static LRCInstance& instance() {
static LRCInstance instance_;
return instance_;
}
LRCInstance() {
lrc_ = std::make_unique<lrc::api::Lrc>();
};
};
\ No newline at end of file
......@@ -27,6 +27,7 @@
#include "media/file.h"
#include "globalinstances.h"
#include "pixbufmanipulator.h"
#include "lrcinstance.h"
#include <QThread>
#include <QTranslator>
......@@ -53,6 +54,15 @@ void
Console()
{
#ifdef Q_OS_WIN
#ifdef _MSC_VER
// Print debug to output window if using VS
QObject::connect(
&LRCInstance::behaviorController(),
&lrc::api::BehaviorController::debugMessageReceived,
[](const std::string& message) {
OutputDebugStringA((message + "\n").c_str());
});
#else
AllocConsole();
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
......@@ -64,6 +74,7 @@ Console()
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coordInfo);
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),ENABLE_QUICK_EDIT_MODE| ENABLE_EXTENDED_FLAGS);
#endif
#endif
}
int
......@@ -78,6 +89,12 @@ main(int argc, char *argv[])
auto startMinimized = false;
QString uri = "";
#ifdef _MSC_VER
gnutls_global_init();
#endif
LRCInstance::init();
for (auto string : QCoreApplication::arguments()) {
if (string == "-m" || string == "--minimized")
startMinimized = true;
......@@ -164,10 +181,6 @@ main(int argc, char *argv[])
QFontDatabase::addApplicationFont(":/images/FontAwesome.otf");
#ifdef _MSC_VER
gnutls_global_init();
#endif
if (not MainWindow::instance().init()) {
return 1;
}
......
......@@ -107,7 +107,6 @@ MainWindow::MainWindow(QWidget* parent) :
Q_UNUSED(online)
AccountModel::instance().slotConnectivityChanged();
});
}
MainWindow::~MainWindow()
......@@ -214,19 +213,19 @@ MainWindow::closeEvent(QCloseEvent* event)
this->hide();
event->ignore();
} else {
settings.setValue(SettingsKey::geometry, saveGeometry());
settings.setValue(SettingsKey::geometry, saveGeometry());
settings.setValue(SettingsKey::windowState, saveState());
}
QMainWindow::closeEvent(event);
}
void
MainWindow::readSettingsFromRegistry()
{
QSettings settings;
restoreGeometry(settings.value(SettingsKey::geometry).toByteArray());
restoreState(settings.value(SettingsKey::windowState).toByteArray());
void
MainWindow::readSettingsFromRegistry()
{
QSettings settings;
restoreGeometry(settings.value(SettingsKey::geometry).toByteArray());
restoreState(settings.value(SettingsKey::windowState).toByteArray());
if (not settings.contains(SettingsKey::enableNotifications)) {
settings.setValue(SettingsKey::enableNotifications, true);
}
}
}
\ No newline at end of file
......@@ -65,7 +65,7 @@ private:
~MainWindow();
void readSettingsFromRegistry();
Ui::MainWindow* ui;
QNetworkConfigurationManager netManager_;
};
......@@ -25,8 +25,9 @@ isEmpty(QMAKE_LRELEASE) {
QMAKE_LRELEASE = lrelease
}
SOURCES += main.cpp\
mainwindow.cpp \
SOURCES +=
main.cpp\
mainwindow.cpp \
callwidget.cpp \
configurationwidget.cpp \
navwidget.cpp \
......@@ -67,7 +68,8 @@ SOURCES += main.cpp\
photoboothwidget.cpp \
deletecontactdialog.cpp
HEADERS += mainwindow.h \
HEADERS +=
mainwindow.h \
callwidget.h \
configurationwidget.h \
navwidget.h \
......@@ -108,14 +110,16 @@ HEADERS += mainwindow.h \
deleteaccountdialog.h \
bannedcontactswidget.h \
photoboothwidget.h \
deletecontactdialog.h
deletecontactdialog.h \
lrcinstance.h
contains(DEFINES, URI_PROTOCOL) {
HEADERS += shmclient.h
SOURCES += shmclient.cpp
}
FORMS += mainwindow.ui \
FORMS +=
mainwindow.ui \
callwidget.ui \
configurationwidget.ui \
accountdetails.ui \
......
......@@ -87,8 +87,8 @@ Global
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.Release|x64.Build.0 = Release|x64
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.Release|x86.ActiveCfg = Release|Win32
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.Release|x86.Build.0 = Release|Win32
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.ReleaseLib_win32|x64.ActiveCfg = ReleaseLib|x64
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.ReleaseLib_win32|x64.Build.0 = ReleaseLib|x64
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.ReleaseLib_win32|x64.ActiveCfg = ReleaseLib_win32|x64
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.ReleaseLib_win32|x64.Build.0 = ReleaseLib_win32|x64
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.ReleaseLib_win32|x86.ActiveCfg = ReleaseLib|Win32
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.ReleaseLib_win32|x86.Build.0 = ReleaseLib|Win32
{79F8DE42-595D-49D9-A66F-55244FD9DCC3}.ReleaseLib|x64.ActiveCfg = ReleaseLib_win32|x64
......
......@@ -296,6 +296,7 @@
</QtMoc>
<QtMoc Include="photoboothwidget.h">
</QtMoc>
<ClInclude Include="lrcinstance.h" />
<ClInclude Include="pixbufmanipulator.h" />
<QtMoc Include="qualitydialog.h">
</QtMoc>
......
......@@ -761,4 +761,9 @@
<ItemGroup>
<ResourceCompile Include="ico.rc" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="lrcinstance.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment