~ubuntu-branches/ubuntu/utopic/robojournal/utopic

« back to all changes in this revision

Viewing changes to firstrun.cpp

  • Committer: Package Import Robot
  • Author(s): Ritesh Raj Sarraf
  • Date: 2013-10-22 11:50:46 UTC
  • mfrom: (1.2.1) (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20131022115046-gl6s110no2x4buoc
Tags: 0.4.2-1
* [b62d8ee] Imported Upstream version 0.4.2
* [344ee28] Update patches
* [3366262] Fix Vcs Links
* Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of RoboJournal.
3
 
    Copyright (c) 2012 by Will Kraft <pwizard@gmail.com>.
4
 
 
5
 
 
6
 
    RoboJournal is free software: you can redistribute it and/or modify
7
 
    it under the terms of the GNU General Public License as published by
8
 
    the Free Software Foundation, either version 3 of the License, or
9
 
    (at your option) any later version.
10
 
 
11
 
    RoboJournal is distributed in the hope that it will be useful,
12
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
    GNU General Public License for more details.
15
 
 
16
 
    You should have received a copy of the GNU General Public License
17
 
    along with RoboJournal.  If not, see <http://www.gnu.org/licenses/>.
18
 
  */
19
 
 
20
 
 
21
 
#include "firstrun.h"
22
 
#include "ui_firstrun.h"
23
 
#include "buffer.h"
24
 
#include "journalcreator.h"
25
 
#include "ui_journalcreator.h"
26
 
#include "config.h"
27
 
#include "ui_config.h"
28
 
#include "configmanager.h"
29
 
#include <iostream>
30
 
 
31
 
 
32
 
FirstRun::FirstRun(QWidget *parent) :
33
 
    QDialog(parent),
34
 
    ui(new Ui::FirstRun)
35
 
{
36
 
    using namespace std;
37
 
    ui->setupUi(this);
38
 
 
39
 
    int width=this->width();
40
 
    int height=this->height();
41
 
    this->setMaximumSize(width,height);
42
 
    this->setMinimumSize(width,height);
43
 
 
44
 
    cout << "OUTPUT: Configuration not set. (or manual reconfiguration requested) Starting first-run tool..." << endl;
45
 
 
46
 
    // make the new journal option default
47
 
    ui->NewJournal->setChecked(true);
48
 
 
49
 
    // hide question mark button in title bar when running on Windows
50
 
    this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
51
 
 
52
 
}
53
 
 
54
 
FirstRun::~FirstRun()
55
 
{
56
 
    delete ui;
57
 
}
58
 
 
59
 
 
60
 
 
61
 
 
62
 
void FirstRun::Launcher(){
63
 
 
64
 
    this->close();
65
 
 
66
 
    if(ui->NewJournal->isChecked()){
67
 
        JournalCreator j;
68
 
        j.exec();
69
 
    }
70
 
    else{
71
 
        // Get rid of first run flag
72
 
        Buffer::firstrun=false;
73
 
 
74
 
        // create a basic config, doesn't matter what it says right now. We just need to have a config file present
75
 
        ConfigManager m;
76
 
        m.RebuildConfig();
77
 
 
78
 
        // and let the user change the database information
79
 
        Config c;
80
 
        c.ManualConfig();
81
 
        c.exec();
82
 
    }
83
 
}
84
 
 
85
 
void FirstRun::on_buttonBox_accepted()
86
 
{
87
 
    Launcher();
88
 
}
89
 
 
90
 
void FirstRun::on_buttonBox_rejected()
91
 
{
92
 
    if(Buffer::firstrun){
93
 
        exit(0);
94
 
    }
95
 
    else{
96
 
        this->close();
97
 
    }
98
 
}