Skip to content

Commit

Permalink
Introduce Core::Application
Browse files Browse the repository at this point in the history
Not it is responsible for creating a main window.
  • Loading branch information
trollixx committed Jan 12, 2015
1 parent d948441 commit 86971e9
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
22 changes: 22 additions & 0 deletions src/core/application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "application.h"

#include "ui/mainwindow.h"

using namespace Zeal;
using namespace Zeal::Core;

Application::Application(const QString &query, QObject *parent) :
QObject(parent),
m_mainWindow(new MainWindow())
{
if (!query.isEmpty())
m_mainWindow->bringToFrontAndSearch(query);
else if (!m_mainWindow->startHidden())
m_mainWindow->show();
}

Application::~Application()
{

}

29 changes: 29 additions & 0 deletions src/core/application.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef APPLICATION_H
#define APPLICATION_H

#include <QObject>

class MainWindow;

namespace Zeal {
namespace Core {

class Application : public QObject
{
Q_OBJECT
public:
explicit Application(const QString &query = QString(), QObject *parent = nullptr);
~Application() override;

signals:

public slots:

private:
MainWindow *m_mainWindow;
};

} // namespace Core
} // namespace Zeal

#endif // APPLICATION_H
2 changes: 2 additions & 0 deletions src/core/core.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
HEADERS += $$files($$PWD/*.h)
SOURCES += $$files($$PWD/*.cpp)
9 changes: 2 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "core/application.h"
#include "ui/mainwindow.h"

#include <QApplication>
Expand Down Expand Up @@ -107,13 +108,7 @@ int main(int argc, char *argv[])
searchPaths << QStringLiteral("./icons");
QDir::setSearchPaths(QStringLiteral("icons"), searchPaths);

QScopedPointer<MainWindow> mainWindow(new MainWindow());

if (!mainWindow->startHidden())
mainWindow->show();

if (!clParams.query.isEmpty())
mainWindow->bringToFrontAndSearch(clParams.query);
QScopedPointer<Zeal::Core::Application> app(new Zeal::Core::Application());

return qapp.exec();
}
1 change: 1 addition & 0 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ DEFINES += ZEAL_VERSION=\\\"20140215\\\"
SOURCES += \
main.cpp

include(core/core.pri)
include(registry/registry.pri)
include(ui/ui.pri)

Expand Down

0 comments on commit 86971e9

Please sign in to comment.