forked from gpospelov/qt-mvvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Placeholders for GroupProperty example
- Loading branch information
Showing
9 changed files
with
153 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
project(groupproperty_example VERSION 0.0.1 LANGUAGES CXX) | ||
|
||
find_package(MVVM REQUIRED) | ||
|
||
set(executable_name groupproperty) | ||
add_subdirectory(grouppropertycore) | ||
add_executable(${executable_name} main.cpp) | ||
|
||
target_link_libraries(${executable_name} grouppropertycore Qt5::Widgets) | ||
target_include_directories(${executable_name} PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Example "groupproperty". | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
set(library_name grouppropertycore) | ||
|
||
set(CMAKE_AUTOMOC ON) | ||
|
||
add_library(${library_name} STATIC "") | ||
target_link_libraries(${library_name} PRIVATE MVVM::View) | ||
|
||
target_sources(${library_name} PRIVATE | ||
mainwindow.cpp | ||
mainwindow.h | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// ************************************************************************** // | ||
// | ||
// Model-view-view-model framework for large GUI applications | ||
// | ||
//! @license GNU General Public License v3 or higher (see COPYING) | ||
//! @authors see AUTHORS | ||
// | ||
// ************************************************************************** // | ||
|
||
#include "mainwindow.h" | ||
#include <QCoreApplication> | ||
#include <QSettings> | ||
|
||
namespace { | ||
const QString main_window_group = "MainWindow"; | ||
const QString size_key = "size"; | ||
const QString pos_key = "pos"; | ||
} // namespace | ||
|
||
namespace GroupProperty { | ||
|
||
MainWindow::MainWindow() | ||
{ | ||
setCentralWidget(new QWidget); | ||
initApplication(); | ||
} | ||
|
||
MainWindow::~MainWindow() = default; | ||
|
||
void MainWindow::closeEvent(QCloseEvent* event) | ||
{ | ||
writeSettings(); | ||
QMainWindow::closeEvent(event); | ||
} | ||
|
||
void MainWindow::initApplication() | ||
{ | ||
QCoreApplication::setApplicationName("groupproperty"); | ||
QCoreApplication::setApplicationVersion("0.1"); | ||
QCoreApplication::setOrganizationName("qt-mvvm"); | ||
|
||
QSettings settings; | ||
if (settings.childGroups().contains(main_window_group)) { | ||
settings.beginGroup(main_window_group); | ||
resize(settings.value(size_key, QSize(400, 400)).toSize()); | ||
move(settings.value(pos_key, QPoint(200, 200)).toPoint()); | ||
settings.endGroup(); | ||
} | ||
} | ||
|
||
void MainWindow::writeSettings() | ||
{ | ||
QSettings settings; | ||
settings.beginGroup(main_window_group); | ||
settings.setValue(size_key, size()); | ||
settings.setValue(pos_key, pos()); | ||
settings.endGroup(); | ||
} | ||
|
||
} // namespace GroupProperty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// ************************************************************************** // | ||
// | ||
// Model-view-view-model framework for large GUI applications | ||
// | ||
//! @license GNU General Public License v3 or higher (see COPYING) | ||
//! @authors see AUTHORS | ||
// | ||
// ************************************************************************** // | ||
|
||
#ifndef PLOTGRAPHSCORE_MAINWINDOW_H | ||
#define PLOTGRAPHSCORE_MAINWINDOW_H | ||
|
||
#include <QMainWindow> | ||
#include <memory> | ||
|
||
namespace GroupProperty { | ||
|
||
//! The main window of this application. | ||
|
||
class MainWindow : public QMainWindow { | ||
Q_OBJECT | ||
|
||
public: | ||
MainWindow(); | ||
~MainWindow(); | ||
|
||
protected: | ||
void closeEvent(QCloseEvent* event); | ||
|
||
private: | ||
void initApplication(); | ||
void writeSettings(); | ||
}; | ||
|
||
} // namespace PlotGraphs | ||
|
||
#endif // PLOTGRAPHSCORE_MAINWINDOW_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// ************************************************************************** // | ||
// | ||
// Model-view-view-model framework for large GUI applications | ||
// | ||
//! @license GNU General Public License v3 or higher (see COPYING) | ||
//! @authors see AUTHORS | ||
// | ||
// ************************************************************************** // | ||
|
||
#include "grouppropertycore/mainwindow.h" | ||
#include <QApplication> | ||
#include <QLocale> | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); | ||
|
||
QApplication app(argc, argv); | ||
|
||
GroupProperty::MainWindow win; | ||
win.show(); | ||
|
||
return app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters