From 2998d9d3d5dfc825904b53393e9ae12e7cd5b72b Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 21 Apr 2015 15:44:54 +0200 Subject: Moved Console to client. It's part of the demo application. --- common/CMakeLists.txt | 3 +- common/console.cpp | 80 ------------------------------------------ common/console.h | 49 -------------------------- examples/client/CMakeLists.txt | 2 +- examples/client/console.cpp | 76 +++++++++++++++++++++++++++++++++++++++ examples/client/console.h | 42 ++++++++++++++++++++++ examples/client/main.cpp | 6 ++-- synchronizer/listener.cpp | 1 - 8 files changed, 123 insertions(+), 136 deletions(-) delete mode 100644 common/console.cpp delete mode 100644 common/console.h create mode 100644 examples/client/console.cpp create mode 100644 examples/client/console.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index c18d98a..f6847a7 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -28,7 +28,6 @@ set(command_SRCS entitybuffer.cpp clientapi.cpp commands.cpp - console.cpp facade.cpp pipeline.cpp domainadaptor.cpp @@ -44,6 +43,6 @@ set(command_SRCS add_library(${PROJECT_NAME} SHARED ${command_SRCS}) generate_export_header(${PROJECT_NAME} BASE_NAME Akonadi2Common EXPORT_FILE_NAME akonadi2common_export.h) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX) -qt5_use_modules(${PROJECT_NAME} Widgets Network) +qt5_use_modules(${PROJECT_NAME} Network) target_link_libraries(${PROJECT_NAME} ${storage_LIBS} akonadi2async) install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/common/console.cpp b/common/console.cpp deleted file mode 100644 index 97a6e88..0000000 --- a/common/console.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2014 Aaron Seigo - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) version 3, or any - * later version accepted by the membership of KDE e.V. (or its - * successor approved by the membership of KDE e.V.), which shall - * act as a proxy defined in Section 6 of version 3 of the license. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "console.h" - -#include -#include -#include -#include - -namespace Akonadi2 -{ - -static Console *s_console = 0; - -Console *Console::main() -{ - if (!s_console) { - s_console = new Console(QString()); - } - return s_console; -} - -Console::Console(const QString &title) - : QWidget(0) -{ - if (!s_console) { - s_console = this; - } - - resize(1000, 1500); - - QVBoxLayout *topLayout = new QVBoxLayout(this); - - QLabel *titleLabel = new QLabel(this); - titleLabel->setText(title); - QFont font = titleLabel->font(); - font.setWeight(QFont::Bold); - titleLabel->setFont(font); - titleLabel->setAlignment(Qt::AlignCenter); - - QFont consoleFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); - consoleFont.setPointSize(7); - m_textDisplay = new QTextBrowser(this); - m_textDisplay->document()->setDefaultFont(consoleFont); - topLayout->addWidget(titleLabel); - topLayout->addWidget(m_textDisplay, 10); - - show(); - m_timestamper.start(); -} - -Console::~Console() -{ - -} - -void Console::log(const QString &message) -{ - m_textDisplay->append(QString::number(m_timestamper.elapsed()).rightJustified(6) + ": " + message); -} - -} // namespace Akonadi2 diff --git a/common/console.h b/common/console.h deleted file mode 100644 index edfc8e5..0000000 --- a/common/console.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2014 Aaron Seigo - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) version 3, or any - * later version accepted by the membership of KDE e.V. (or its - * successor approved by the membership of KDE e.V.), which shall - * act as a proxy defined in Section 6 of version 3 of the license. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#pragma once - -#include - -#include -#include - -class QTextBrowser; - -namespace Akonadi2 -{ - -class AKONADI2COMMON_EXPORT Console : public QWidget -{ - Q_OBJECT -public: - static Console *main(); - Console(const QString &title); - ~Console(); - - void log(const QString &message); - -private: - QTextBrowser *m_textDisplay; - QTime m_timestamper; - static Console *s_output; -}; - -} // namespace Akonadi2 diff --git a/examples/client/CMakeLists.txt b/examples/client/CMakeLists.txt index 3555b3e..97b5ad2 100644 --- a/examples/client/CMakeLists.txt +++ b/examples/client/CMakeLists.txt @@ -2,7 +2,7 @@ project(akonadi2_client) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) -add_executable(${PROJECT_NAME} main.cpp) +add_executable(${PROJECT_NAME} main.cpp console.cpp) target_link_libraries(${PROJECT_NAME} akonadi2common) qt5_use_modules(${PROJECT_NAME} Widgets Network) install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/examples/client/console.cpp b/examples/client/console.cpp new file mode 100644 index 0000000..8b4f1a5 --- /dev/null +++ b/examples/client/console.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2014 Aaron Seigo + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#include "console.h" + +#include +#include +#include +#include + +static Console *s_console = 0; + +Console *Console::main() +{ + if (!s_console) { + s_console = new Console(QString()); + } + return s_console; +} + +Console::Console(const QString &title) + : QWidget(0) +{ + if (!s_console) { + s_console = this; + } + + resize(1000, 1500); + + QVBoxLayout *topLayout = new QVBoxLayout(this); + + QLabel *titleLabel = new QLabel(this); + titleLabel->setText(title); + QFont font = titleLabel->font(); + font.setWeight(QFont::Bold); + titleLabel->setFont(font); + titleLabel->setAlignment(Qt::AlignCenter); + + QFont consoleFont = QFontDatabase::systemFont(QFontDatabase::FixedFont); + consoleFont.setPointSize(7); + m_textDisplay = new QTextBrowser(this); + m_textDisplay->document()->setDefaultFont(consoleFont); + topLayout->addWidget(titleLabel); + topLayout->addWidget(m_textDisplay, 10); + + show(); + m_timestamper.start(); +} + +Console::~Console() +{ + +} + +void Console::log(const QString &message) +{ + m_textDisplay->append(QString::number(m_timestamper.elapsed()).rightJustified(6) + ": " + message); +} + diff --git a/examples/client/console.h b/examples/client/console.h new file mode 100644 index 0000000..a6fef01 --- /dev/null +++ b/examples/client/console.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2014 Aaron Seigo + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) version 3, or any + * later version accepted by the membership of KDE e.V. (or its + * successor approved by the membership of KDE e.V.), which shall + * act as a proxy defined in Section 6 of version 3 of the license. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + */ + +#pragma once + +#include +#include + +class QTextBrowser; + +class Console : public QWidget +{ + Q_OBJECT +public: + static Console *main(); + Console(const QString &title); + ~Console(); + + void log(const QString &message); + +private: + QTextBrowser *m_textDisplay; + QTime m_timestamper; + static Console *s_output; +}; diff --git a/examples/client/main.cpp b/examples/client/main.cpp index b4cb081..5cd6141 100644 --- a/examples/client/main.cpp +++ b/examples/client/main.cpp @@ -21,15 +21,15 @@ #include #include "common/commands.h" -#include "common/console.h" #include "common/resourceaccess.h" +#include "console.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); - new Akonadi2::Console("Akonadi2 Client"); - Akonadi2::Console::main()->log(QString("PID: %1").arg(QCoreApplication::applicationPid())); + new Console("Akonadi2 Client"); + Console::main()->log(QString("PID: %1").arg(QCoreApplication::applicationPid())); QCommandLineParser cliOptions; cliOptions.addPositionalArgument(QObject::tr("[resource]"), diff --git a/synchronizer/listener.cpp b/synchronizer/listener.cpp index c68bd9a..e930a02 100644 --- a/synchronizer/listener.cpp +++ b/synchronizer/listener.cpp @@ -20,7 +20,6 @@ #include "listener.h" #include "common/clientapi.h" -#include "common/console.h" #include "common/commands.h" #include "common/resource.h" #include "common/log.h" -- cgit v1.2.3