GnuCashew ~ Web Application compatible with GnuCash sql data files.
GCW
Loading...
Searching...
No Matches
MainWidget.cpp
Go to the documentation of this file.
1#line 2 "src/Gui/MainWidget.cpp"
2
3#include <Wt/WDialog.h>
4#include <Wt/WComboBox.h>
5#include <Wt/WPushButton.h>
6#include <Wt/WVBoxLayout.h>
7#include <Wt/Json/Serializer.h>
8
9#include "../define.h"
10#include "../GnuCashew.h"
11#include "MainWidget.h"
13#include "LanguagePicker.h"
14
16: public Wt::WPushButton
17{
18 public:
19
20 PushButton( const Wt::WString & _text )
21 : Wt::WPushButton( _text )
22 {
23 setStyleClass( "btn-xs" );
24 setAttributeValue( "style", "margin-left:3px;margin-right:3px" );
25 }
26
27};
28
31{
32 addStyleClass( "MainWidget" );
33
34 auto lw = setLayout( std::make_unique< Wt::WVBoxLayout >() );
35 lw-> setSpacing( 0 );
36
37 m_navBar = lw-> addWidget( std::make_unique< Wt::WNavigationBar >() );
38 m_navBar-> addStyleClass( "NavBar" );
39
40 m_toolBar = lw-> addWidget( std::make_unique< Wt::WToolBar >() );
41 m_toolBar-> addStyleClass( "ToolBar" );
42
43 m_centralWidget = lw-> addWidget( std::make_unique< GCW::Gui::CentralWidget >(), 1 );
44
45 m_statusBar = lw-> addWidget( std::make_unique< Wt::WContainerWidget >() );
46 m_statusBar-> addStyleClass( "StatusBar" );
47
48} // endGCW::MainWidget::MainWidget()
49
50auto
52load()-> void
53{
55
56 /*
57 ** Set up the navbar
58 */
59 auto link = Wt::WLink( TR8("gcw_gui.doxygen_link") );
60 link.setTarget( Wt::LinkTarget::NewWindow );
61 navBar()-> setResponsive( true );
62 navBar()-> addStyleClass( "navbar-light bg-light" );
63 navBar()-> setTitle( "GCW", link );
64
65 /*
66 ** install the main menu
67 */
68 {
69 auto w_ = std::make_unique< GCW::Gui::MainMenu >( this );
70 m_mainMenu = w_.get();
71 navBar()-> addMenu( std::move( w_ ) );
72 }
73
74 /*
75 ** install the site language selector
76 */
77 navBar()-> addWidget( std::make_unique< LanguagePicker >(), Wt::AlignmentFlag::Right );
78
79 /*
80 ** plop all the buttons down
81 */
82 toolBar()-> addButton( std::make_unique< PushButton >( TR( "gcw.MainWidget.tb.save" ) ) );
83 toolBar()-> addButton( std::make_unique< PushButton >( TR( "gcw.MainWidget.tb.close" ) ) );
84 toolBar()-> addButton( std::make_unique< PushButton >( TR( "gcw.MainWidget.tb.newInvoice" ) ) );
85 toolBar()-> addButton( std::make_unique< PushButton >( TR( "gcw.MainWidget.tb.open" ) ) );
86
87 {
88 auto b = std::make_unique< PushButton >( TR( "gcw.MainWidget.tb.edit" ) );
89 auto e = b.get();
90 toolBar()-> addButton( std::move(b) );
91 e-> clicked().connect( [=](){ openSelectedAccount(); });
92 }
93
94 toolBar()-> addButton( std::make_unique< PushButton >( TR( "gcw.MainWidget.tb.new" ) ) );
95 toolBar()-> addButton( std::make_unique< PushButton >( TR( "gcw.MainWidget.tb.delete" ) ) );
96
97 {
98 auto b = std::make_unique< PushButton >( "devtest" );
99 auto e = b.get();
100 toolBar()-> addButton( std::move(b) );
101 e-> clicked().connect( [=](){ test(); });
102 }
103
104 statusBar()-> addNew< Wt::WText >( "status bar" );
105
106} // endload()-> void
107
108auto
110open_properties()-> void
111{
112 if( !GCW::app()-> gnucashew_session().isOpen() )
113 return;
114
115 auto dialog = addChild( std::make_unique< Wt::WDialog >( TR( "gcw.PropertiesWidget.titleBar" ) ) );
116 dialog-> rejectWhenEscapePressed( true );
117 dialog-> contents()-> addNew< GCW::Gui::FilePropertiesWidget >();
118 dialog-> show();
119 dialog->
120 finished().connect( [=]()
121 {
122 removeChild( dialog );
123 });
124
125} // endopen_properties()
126
127auto
129open_aboutWidget()-> void
130{
131 auto templt = std::make_unique< Wt::WTemplate >( TR( "gcw.AboutWidget.about" ) );
132 templt-> bindString( "version", "none" );
133 templt-> bindString( "buildid", "none" );
134 templt-> bindString( "finance", "none (yet)" );
135
136 auto dialog = addChild( std::make_unique< Wt::WDialog >( TR( "gcw.AboutWidget.titleBar" ) ) );
137 dialog-> rejectWhenEscapePressed( true );
138 dialog-> contents()-> addWidget( std::move( templt ) );
139 dialog-> show();
140 dialog->
141 finished().connect( [=]()
142 {
143 removeChild( dialog );
144 });
145
146} // endopen_properties()
147
148auto
150openSelectedAccount()-> void
151{
152 centralWidget()-> activateAccountsTreeView();
153 centralWidget()-> accountsTreeView()-> editSelectedAccount();
154
155} // endopenSelectedAccount()
156
157auto
159setBasicLedger()-> void
160{
161 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
162
163}
164
165auto
167setAutosplit()-> void
168{
169 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
170
171}
172
173auto
175setTransaction()-> void
176{
177 std::cout << __FILE__ << ":" << __LINE__ << " " << std::endl;
178
179}
180
181auto
183setDoubleLine()-> void
184{
185 if( auto accountRegister = centralWidget()-> currentAccountRegister() )
186 {
187 auto doubleLine = m_mainMenu-> menuItem( TR( "gcw.MainWidget.mu.view.doubleline" ) );
188
189 accountRegister-> setDoubleLine( doubleLine-> isChecked() );
190 }
191
192} // endsetDoubleLine()-> void
193
194
195auto
197{
198 auto model = std::make_shared< Wt::WStandardItemModel >();
199 for( int row = 0; row< 3; row++ )
200 {
201 std::vector< std::unique_ptr< Wt::WStandardItem > > rowset;
202 for( int col = 0; col< 3; col++ )
203 {
204 auto item = std::make_unique< Wt::WStandardItem >( Wt::WString("row{1} col{2}").arg( row ).arg( col) );
205 rowset.push_back( std::move( item ) );
206 }
207
208 model-> appendRow( std::move( rowset ) );
209 }
210
211 auto tableView = std::make_unique< Wt::WTableView >();
212 tableView-> setSelectionBehavior ( Wt::SelectionBehavior::Items );
213// tableView-> setSelectionBehavior ( Wt::SelectionBehavior::Rows );
214// tableView-> setSelectionMode ( Wt::SelectionMode::Single );
215 tableView-> setSelectionMode ( Wt::SelectionMode::Extended );
216 tableView-> setColumnResizeEnabled ( false );
217 tableView-> setAlternatingRowColors ( true );
218 tableView-> setModel ( model );
219
220 Wt::WDialog dialog( "test" );
221 dialog.contents()-> addWidget( std::move( tableView ) );
222 dialog.rejectWhenEscapePressed( true );
223 dialog.setClosable( true );
224 dialog.exec();
225
226} // endtest_tableview()-> void
227
228auto
230test()-> void
231{
233
234} // endtest()
235
236
237
238
239
240
241
242
static std::unique_ptr< GCW::Gui::BillPay::PaymentWidgetDialog > dialog
auto test_tableview() -> void
Wt::WToolBar * m_toolBar
Definition MainWidget.h:58
auto setTransaction() -> void
auto open_aboutWidget() -> void
auto test() -> void
auto openSelectedAccount() -> void
auto open_properties() -> void
auto setDoubleLine() -> void
auto setBasicLedger() -> void
CentralWidget * m_centralWidget
Definition MainWidget.h:60
Wt::WContainerWidget * m_statusBar
Definition MainWidget.h:59
auto setAutosplit() -> void
Wt::WNavigationBar * m_navBar
Definition MainWidget.h:56
auto load() -> void
PushButton(const Wt::WString &_text)
Widget * addNew(Args &&...args)
void setLayout(std::unique_ptr< WLayout > layout)
virtual void addWidget(std::unique_ptr< WWidget > widget)
virtual void load() override
virtual void setAttributeValue(const std::string &name, const WString &value) override
virtual void setStyleClass(const WString &styleClass) override
virtual void addStyleClass(const WString &styleClass, bool force=false) override
#define TR8(X)
Definition define.h:18
#define TR(X)
Definition define.h:17
App * app()
Definition App.cpp:75