~sachinr/xpad/xpad-qt

« back to all changes in this revision

Viewing changes to src/app.cpp

  • Committer: Sachin Raut
  • Date: 2013-09-19 16:29:31 UTC
  • Revision ID: great.sachin@gmail.com-20130919162931-rkup975f66xjsgvr
pad saving with 0 based files
added persistency to pads.
changed icon and saved pads path.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
App::App():trayIcon(new QSystemTrayIcon), padGroup(new PadGroup())
9
9
{
10
 
    // create tray icon
11
 
    trayIcon->setIcon(QIcon("/home/sachin/icon.png"));
 
10
    iconPath = "/home/sachin/.xpad-qt/xpad.png";
 
11
    padDirectory = "/home/sachin/.xpad-qt/pads";
 
12
 
 
13
    // init tray icon
 
14
    trayIcon->setIcon(QIcon(iconPath));
12
15
    trayIcon->setVisible(true);
13
16
    trayIcon->show();
14
17
 
15
 
    // test - create pad to avoid going to tray every time just to create
16
 
    padGroup->CreateNewPad();
 
18
    // init pad group
 
19
    padGroup->SetDirectory(padDirectory);
17
20
}
18
21
 
19
22
void App::CreateTrayMenu()
26
29
    trayIconMenu->addAction(new_pad_action);
27
30
 
28
31
    // add menu items for all pads
 
32
    int counter = 0;
29
33
    for(auto pad : padGroup->GetPads())
30
34
    {
31
 
        auto padaction = new QAction("Pad", NULL);
 
35
        auto padaction = new QAction(QString("&%1").arg(counter++), NULL);
32
36
        trayIcon->connect(padaction, &QAction::triggered, pad, &Pad::show);
33
37
        trayIconMenu->addAction(padaction);
34
38
    }
36
40
    // quit menu
37
41
    auto quitAction = new QAction("&Quit", NULL);
38
42
    trayIcon->connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
39
 
    //todo - not working, should work
 
43
    //todo - not working, should work according to new syntax
40
44
    //trayIcon->connect(quitAction, SIGNAL(triggered()), qApp, &QApplication::quit);
41
45
    trayIconMenu->addAction(quitAction);
42
46
 
43
47
    trayIcon->setContextMenu(trayIconMenu);
44
48
}
45
49
 
 
50
// new pad action slot
46
51
void App::newPadRequested()
47
52
{
48
53
    padGroup->CreateNewPad();
 
54
    // recreate tray menu - can we optimize?
49
55
    CreateTrayMenu();
50
56
}
51
57
 
 
58
// load saved pads
 
59
void App::LoadPads()
 
60
{
 
61
    padGroup->LoadPads();
 
62
}
 
63
 
52
64
void App::HideTray()
53
65
{
54
66
    trayIcon->hide();