VirtualBox

Changeset 43514 in vbox


Ignore:
Timestamp:
Oct 2, 2012 3:08:33 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
81097
Message:

FE/Qt: VM group feature UI: Cleanup part 1.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooser.cpp

    r43444 r43514  
    2626#include "UIGChooserModel.h"
    2727#include "UIGChooserView.h"
    28 #include "UIVirtualBoxEventHandler.h"
    2928#include "VBoxGlobal.h"
    3029
     
    3635    , m_pStatusBar(0)
    3736{
    38     /* Fix palette: */
    39     setAutoFillBackground(true);
    40     QPalette pal = palette();
    41     pal.setColor(QPalette::Window, QColor(240, 240, 240));
    42     setPalette(pal);
     37    /* Prepare palette: */
     38    preparePalette();
    4339
    44     /* Create main-layout: */
    45     m_pMainLayout = new QVBoxLayout(this);
    46     m_pMainLayout->setContentsMargins(0, 0, 2, 0);
    47     m_pMainLayout->setSpacing(0);
     40    /* Prepare layout: */
     41    prepareLayout();
    4842
    49     /* Create chooser-model: */
    50     m_pChooserModel = new UIGChooserModel(this);
     43    /* Prepare model: */
     44    prepareModel();
    5145
    52     /* Create chooser-view: */
    53     m_pChooserView = new UIGChooserView(this);
    54     m_pChooserView->setFrameShape(QFrame::NoFrame);
    55     m_pChooserView->setFrameShadow(QFrame::Plain);
    56     m_pChooserView->setScene(m_pChooserModel->scene());
    57     m_pChooserView->show();
    58     setFocusProxy(m_pChooserView);
    59 
    60     /* Add tool-bar into layout: */
    61     m_pMainLayout->addWidget(m_pChooserView);
     46    /* Prepare view: */
     47    prepareView();
    6248
    6349    /* Prepare connections: */
    6450    prepareConnections();
    6551
    66     /* Prepare model: */
    67     m_pChooserModel->prepare();
    68 
    69     /* Load last selected item: */
    70     m_pChooserModel->setCurrentItemDefinition(vboxGlobal().virtualBox().GetExtraData(GUI_LastItemSelected));
     52    /* Load: */
     53    load();
    7154}
    7255
    7356UIGChooser::~UIGChooser()
    7457{
    75     /* Save last selected item: */
    76     vboxGlobal().virtualBox().SetExtraData(GUI_LastItemSelected, m_pChooserModel->currentItemDefinition());
    77 
    78     /* Cleanup model: */
    79     m_pChooserModel->cleanup();
    80 }
    81 
    82 void UIGChooser::setCurrentItem(int iCurrentItemIndex)
    83 {
    84     m_pChooserModel->setCurrentItem(iCurrentItemIndex);
     58    /* Save: */
     59    save();
    8560}
    8661
     
    11388    /* Connect new status-bar: */
    11489    m_pStatusBar = pStatusBar;
    115     connect(m_pChooserModel, SIGNAL(sigClearStatusMessage()), m_pStatusBar, SLOT(clearMessage()));
    116     connect(m_pChooserModel, SIGNAL(sigShowStatusMessage(const QString&)), m_pStatusBar, SLOT(showMessage(const QString&)));
     90    connect(m_pChooserModel, SIGNAL(sigClearStatusMessage()),
     91            m_pStatusBar, SLOT(clearMessage()));
     92    connect(m_pChooserModel, SIGNAL(sigShowStatusMessage(const QString&)),
     93            m_pStatusBar, SLOT(showMessage(const QString&)));
    11794}
    11895
     
    12299}
    123100
     101void UIGChooser::preparePalette()
     102{
     103    /* Setup palette: */
     104    setAutoFillBackground(true);
     105    QPalette pal = palette();
     106    pal.setColor(QPalette::Window, QColor(240, 240, 240));
     107    setPalette(pal);
     108}
     109
     110void UIGChooser::prepareLayout()
     111{
     112    /* Setup main-layout: */
     113    m_pMainLayout = new QVBoxLayout(this);
     114    m_pMainLayout->setContentsMargins(0, 0, 2, 0);
     115    m_pMainLayout->setSpacing(0);
     116}
     117
     118void UIGChooser::prepareModel()
     119{
     120    /* Setup chooser-model: */
     121    m_pChooserModel = new UIGChooserModel(this);
     122}
     123
     124void UIGChooser::prepareView()
     125{
     126    /* Setup chooser-view: */
     127    m_pChooserView = new UIGChooserView(this);
     128    m_pChooserView->setScene(m_pChooserModel->scene());
     129    m_pChooserView->show();
     130    setFocusProxy(m_pChooserView);
     131    m_pMainLayout->addWidget(m_pChooserView);
     132}
     133
    124134void UIGChooser::prepareConnections()
    125135{
    126     /* Chooser-model connections: */
     136    /* Setup chooser-model connections: */
    127137    connect(m_pChooserModel, SIGNAL(sigRootItemResized(const QSizeF&, int)),
    128138            m_pChooserView, SLOT(sltHandleRootItemResized(const QSizeF&, int)));
    129     connect(m_pChooserModel, SIGNAL(sigSelectionChanged()), this, SIGNAL(sigSelectionChanged()));
    130     connect(m_pChooserModel, SIGNAL(sigSlidingStarted()), this, SIGNAL(sigSlidingStarted()));
    131     connect(m_pChooserModel, SIGNAL(sigToggleStarted()), this, SIGNAL(sigToggleStarted()));
    132     connect(m_pChooserModel, SIGNAL(sigToggleFinished()), this, SIGNAL(sigToggleFinished()));
    133     connect(m_pChooserModel, SIGNAL(sigGroupSavingStateChanged()), this, SIGNAL(sigGroupSavingStateChanged()));
    134     connect(m_pChooserModel, SIGNAL(sigFocusChanged(UIGChooserItem*)), m_pChooserView, SLOT(sltFocusChanged(UIGChooserItem*)));
     139    connect(m_pChooserModel, SIGNAL(sigFocusChanged(UIGChooserItem*)),
     140            m_pChooserView, SLOT(sltFocusChanged(UIGChooserItem*)));
    135141
    136     /* Chooser-view connections: */
    137     connect(m_pChooserView, SIGNAL(sigResized()), m_pChooserModel, SLOT(sltHandleViewResized()));
    138 
    139     /* Global connections: */
    140     connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), m_pChooserModel, SLOT(sltMachineStateChanged(QString, KMachineState)));
    141     connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), m_pChooserModel, SLOT(sltMachineDataChanged(QString)));
    142     connect(gVBoxEvents, SIGNAL(sigMachineRegistered(QString, bool)), m_pChooserModel, SLOT(sltMachineRegistered(QString, bool)));
    143     connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)), m_pChooserModel, SLOT(sltSessionStateChanged(QString, KSessionState)));
    144     connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)), m_pChooserModel, SLOT(sltSnapshotChanged(QString, QString)));
     142    /* Setup chooser-view connections: */
     143    connect(m_pChooserView, SIGNAL(sigResized()),
     144            m_pChooserModel, SLOT(sltHandleViewResized()));
    145145}
    146146
     147void UIGChooser::load()
     148{
     149    /* Prepare model: */
     150    m_pChooserModel->prepare();
     151
     152    /* Load last selected item: */
     153    m_pChooserModel->setCurrentItemDefinition(vboxGlobal().virtualBox().GetExtraData(GUI_LastItemSelected));
     154}
     155
     156void UIGChooser::save()
     157{
     158    /* Save last selected item: */
     159    vboxGlobal().virtualBox().SetExtraData(GUI_LastItemSelected, m_pChooserModel->currentItemDefinition());
     160
     161    /* Cleanup model: */
     162    m_pChooserModel->cleanup();
     163}
     164
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooser.h

    r43444 r43514  
    4343    void sigSelectionChanged();
    4444
    45     /* Notifier: Sliding start: */
     45    /* Notifier: Sliding stuff: */
    4646    void sigSlidingStarted();
    4747
     
    5050    void sigToggleFinished();
    5151
    52     /* Notifier: Group saving stuff: */
     52    /* Notifier: Group-saving stuff: */
    5353    void sigGroupSavingStateChanged();
    5454
     
    5959    ~UIGChooser();
    6060
    61     /* API: Current item stuff: */
    62     void setCurrentItem(int iCurrentItemIndex);
     61    /* API: Current-item stuff: */
    6362    UIVMItem* currentItem() const;
    6463    QList<UIVMItem*> currentItems() const;
     
    6665    bool isAllItemsOfOneGroupSelected() const;
    6766
    68     /* API: Status bar stuff: */
     67    /* API: Status-bar stuff: */
    6968    void setStatusBar(QStatusBar *pStatusBar);
    7069
    71     /* API: Group saving stuff: */
     70    /* API: Group-saving stuff: */
    7271    bool isGroupSavingInProgress() const;
    7372
    7473private:
    7574
    76     /* Helpers: */
     75    /* Helpers: Prepare stuff: */
     76    void preparePalette();
     77    void prepareLayout();
     78    void prepareModel();
     79    void prepareView();
    7780    void prepareConnections();
     81    void load();
     82
     83    /* Helper: Cleanup stuff: */
     84    void save();
    7885
    7986    /* Variables: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp

    r43461 r43514  
    4141#include "UIWizardNewVM.h"
    4242#include "UISelectorWindow.h"
     43#include "UIVirtualBoxEventHandler.h"
    4344
    4445/* COM includes: */
     
    8384    prepareHandlers();
    8485
     86    /* Prepare connections: */
     87    prepareConnections();
     88
    8589    /* Prepare release logging: */
    86     char szLogFile[RTPATH_MAX];
    87     const char *pszLogFile = NULL;
    88     com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile));
    89     RTPathAppend(szLogFile, sizeof(szLogFile), "selectorwindow.log");
    90     pszLogFile = szLogFile;
    91     /* Create release logger, to file: */
    92     char szError[RTPATH_MAX + 128];
    93     com::VBoxLogRelCreate("GUI VM Selector Window",
    94                           pszLogFile,
    95                           RTLOGFLAGS_PREFIX_TIME_PROG,
    96                           "all",
    97                           "VBOX_GUI_SELECTORWINDOW_RELEASE_LOG",
    98                           RTLOGDEST_FILE,
    99                           UINT32_MAX,
    100                           1,
    101                           60 * 60,
    102                           _1M,
    103                           szError,
    104                           sizeof(szError));
     90    prepareReleaseLogging();
    10591}
    10692
     
    11821168    m_pMouseHandler = new UIGChooserHandlerMouse(this);
    11831169    m_pKeyboardHandler = new UIGChooserHandlerKeyboard(this);
     1170}
     1171
     1172void UIGChooserModel::prepareConnections()
     1173{
     1174    /* Setup parent connections: */
     1175    connect(this, SIGNAL(sigSelectionChanged()),
     1176            parent(), SIGNAL(sigSelectionChanged()));
     1177    connect(this, SIGNAL(sigSlidingStarted()),
     1178            parent(), SIGNAL(sigSlidingStarted()));
     1179    connect(this, SIGNAL(sigToggleStarted()),
     1180            parent(), SIGNAL(sigToggleStarted()));
     1181    connect(this, SIGNAL(sigToggleFinished()),
     1182            parent(), SIGNAL(sigToggleFinished()));
     1183    connect(this, SIGNAL(sigGroupSavingStateChanged()),
     1184            parent(), SIGNAL(sigGroupSavingStateChanged()));
     1185
     1186    /* Setup global connections: */
     1187    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)),
     1188            this, SLOT(sltMachineStateChanged(QString, KMachineState)));
     1189    connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)),
     1190            this, SLOT(sltMachineDataChanged(QString)));
     1191    connect(gVBoxEvents, SIGNAL(sigMachineRegistered(QString, bool)),
     1192            this, SLOT(sltMachineRegistered(QString, bool)));
     1193    connect(gVBoxEvents, SIGNAL(sigSessionStateChange(QString, KSessionState)),
     1194            this, SLOT(sltSessionStateChanged(QString, KSessionState)));
     1195    connect(gVBoxEvents, SIGNAL(sigSnapshotChange(QString, QString)),
     1196            this, SLOT(sltSnapshotChanged(QString, QString)));
     1197}
     1198
     1199void UIGChooserModel::prepareReleaseLogging()
     1200{
     1201    /* Prepare release logging: */
     1202    char szLogFile[RTPATH_MAX];
     1203    const char *pszLogFile = NULL;
     1204    com::GetVBoxUserHomeDirectory(szLogFile, sizeof(szLogFile));
     1205    RTPathAppend(szLogFile, sizeof(szLogFile), "selectorwindow.log");
     1206    pszLogFile = szLogFile;
     1207    /* Create release logger, to file: */
     1208    char szError[RTPATH_MAX + 128];
     1209    com::VBoxLogRelCreate("GUI VM Selector Window",
     1210                          pszLogFile,
     1211                          RTLOGFLAGS_PREFIX_TIME_PROG,
     1212                          "all",
     1213                          "VBOX_GUI_SELECTORWINDOW_RELEASE_LOG",
     1214                          RTLOGDEST_FILE,
     1215                          UINT32_MAX,
     1216                          1,
     1217                          60 * 60,
     1218                          _1M,
     1219                          szError,
     1220                          sizeof(szError));
    11841221}
    11851222
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h

    r43444 r43514  
    228228    enum SelectorModelData
    229229    {
    230         /* Layout hints: */
     230        /* Layout margin: */
    231231        SelectorModelData_Margin
    232232    };
     
    241241    void prepareContextMenu();
    242242    void prepareHandlers();
     243    void prepareConnections();
     244    void prepareReleaseLogging();
    243245    void prepareGroupTree();
    244246
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserView.cpp

    r42873 r43514  
    3333    setPalette(pal);
    3434
    35     /* Scrollbars policy: */
     35    /* Setup frame: */
     36    setFrameShape(QFrame::NoFrame);
     37    setFrameShadow(QFrame::Plain);
     38
     39    /* Setup scroll-bars policy: */
    3640    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    3741
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette