source: src-qt4/pc-controlpanel/deinfo.cpp @ ffbf59c

releng/10.0.1releng/10.0.2
Last change on this file since ffbf59c was ffbf59c, checked in by yurkis <yurkis@…>, 6 months ago

Reworked pc controlpanel for using libpcbsd-utils for DE detection

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/**************************************************************************
2*   Copyright (C) 2011 by Yuri Momotyuk                                   *
3*   yurkis@gmail.com                                                      *
4*                                                                         *
5*   Permission is hereby granted, free of charge, to any person obtaining *
6*   a copy of this software and associated documentation files (the       *
7*   "Software"), to deal in the Software without restriction, including   *
8*   without limitation the rights to use, copy, modify, merge, publish,   *
9*   distribute, sublicense, and/or sell copies of the Software, and to    *
10*   permit persons to whom the Software is furnished to do so, subject to *
11*   the following conditions:                                             *
12*                                                                         *
13*   The above copyright notice and this permission notice shall be        *
14*   included in all copies or substantial portions of the Software.       *
15*                                                                         *
16*   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
17*   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
18*   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
19*   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
20*   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
21*   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
22*   OTHER DEALINGS IN THE SOFTWARE.                                       *
23***************************************************************************/
24
25#include "deinfo.h"
26
27///////////////////////////////////////////////////////////////////////////////
28#define TRY_GET_VALUE_STR(val_name, field)\
29if (Str.contains(val_name)){\
30                            Entry.field = Str.replace(val_name,"").trimmed();\
31                                          continue;}\
32
33#define TRY_GET_VALUE_BOOL(val_name, field, true_val)\
34if (Str.contains(val_name)){\
35                            Entry.field = Str.replace(val_name,"").trimmed().toLower() == QString(true_val).toLower();\
36                                          continue;}\
37
38///////////////////////////////////////////////////////////////////////////////
39int CDEList::refresh(/*bool isAll*/)
40{
41    mvDE.clear();
42
43    mvDE = pcbsd::Utils::installedDesktops();
44
45    return mvDE.size();
46}
47
48///////////////////////////////////////////////////////////////////////////////
49pcbsd::DesktopEnvironmentInfo* CDEList::active()
50{
51    for(int i =0; i<mvDE.size(); i++)
52    {
53        if (mvDE[i].isActive)
54            return &mvDE[i];
55    }
56    return NULL;
57}
58
59///////////////////////////////////////////////////////////////////////////////
60pcbsd::DesktopEnvironmentInfo* CDEList::byName(QString Name)
61{
62    for (int i =0; i<mvDE.size(); i++)
63    {
64        if (!mvDE[i].Name.compare(Name.trimmed(), Qt::CaseInsensitive))
65            return &mvDE[i];
66    }
67    return NULL;
68}
69
70///////////////////////////////////////////////////////////////////////////////
71CSingleDEList& CSingleDEList::getRef()
72{
73    static CSingleDEList instance;
74    return instance;
75}
Note: See TracBrowser for help on using the repository browser.