Changeset 43514 in vbox
- Timestamp:
- Oct 2, 2012 3:08:33 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 81097
- 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 26 26 #include "UIGChooserModel.h" 27 27 #include "UIGChooserView.h" 28 #include "UIVirtualBoxEventHandler.h"29 28 #include "VBoxGlobal.h" 30 29 … … 36 35 , m_pStatusBar(0) 37 36 { 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(); 43 39 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(); 48 42 49 /* Create chooser-model: */50 m_pChooserModel = new UIGChooserModel(this);43 /* Prepare model: */ 44 prepareModel(); 51 45 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(); 62 48 63 49 /* Prepare connections: */ 64 50 prepareConnections(); 65 51 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(); 71 54 } 72 55 73 56 UIGChooser::~UIGChooser() 74 57 { 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(); 85 60 } 86 61 … … 113 88 /* Connect new status-bar: */ 114 89 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&))); 117 94 } 118 95 … … 122 99 } 123 100 101 void 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 110 void 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 118 void UIGChooser::prepareModel() 119 { 120 /* Setup chooser-model: */ 121 m_pChooserModel = new UIGChooserModel(this); 122 } 123 124 void 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 124 134 void UIGChooser::prepareConnections() 125 135 { 126 /* Chooser-model connections: */136 /* Setup chooser-model connections: */ 127 137 connect(m_pChooserModel, SIGNAL(sigRootItemResized(const QSizeF&, int)), 128 138 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*))); 135 141 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())); 145 145 } 146 146 147 void 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 156 void 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 43 43 void sigSelectionChanged(); 44 44 45 /* Notifier: Sliding st art: */45 /* Notifier: Sliding stuff: */ 46 46 void sigSlidingStarted(); 47 47 … … 50 50 void sigToggleFinished(); 51 51 52 /* Notifier: Group 52 /* Notifier: Group-saving stuff: */ 53 53 void sigGroupSavingStateChanged(); 54 54 … … 59 59 ~UIGChooser(); 60 60 61 /* API: Current item stuff: */ 62 void setCurrentItem(int iCurrentItemIndex); 61 /* API: Current-item stuff: */ 63 62 UIVMItem* currentItem() const; 64 63 QList<UIVMItem*> currentItems() const; … … 66 65 bool isAllItemsOfOneGroupSelected() const; 67 66 68 /* API: Status 67 /* API: Status-bar stuff: */ 69 68 void setStatusBar(QStatusBar *pStatusBar); 70 69 71 /* API: Group 70 /* API: Group-saving stuff: */ 72 71 bool isGroupSavingInProgress() const; 73 72 74 73 private: 75 74 76 /* Helpers: */ 75 /* Helpers: Prepare stuff: */ 76 void preparePalette(); 77 void prepareLayout(); 78 void prepareModel(); 79 void prepareView(); 77 80 void prepareConnections(); 81 void load(); 82 83 /* Helper: Cleanup stuff: */ 84 void save(); 78 85 79 86 /* Variables: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.cpp
r43461 r43514 41 41 #include "UIWizardNewVM.h" 42 42 #include "UISelectorWindow.h" 43 #include "UIVirtualBoxEventHandler.h" 43 44 44 45 /* COM includes: */ … … 83 84 prepareHandlers(); 84 85 86 /* Prepare connections: */ 87 prepareConnections(); 88 85 89 /* 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(); 105 91 } 106 92 … … 1182 1168 m_pMouseHandler = new UIGChooserHandlerMouse(this); 1183 1169 m_pKeyboardHandler = new UIGChooserHandlerKeyboard(this); 1170 } 1171 1172 void 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 1199 void 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)); 1184 1221 } 1185 1222 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserModel.h
r43444 r43514 228 228 enum SelectorModelData 229 229 { 230 /* Layout hints: */230 /* Layout margin: */ 231 231 SelectorModelData_Margin 232 232 }; … … 241 241 void prepareContextMenu(); 242 242 void prepareHandlers(); 243 void prepareConnections(); 244 void prepareReleaseLogging(); 243 245 void prepareGroupTree(); 244 246 -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserView.cpp
r42873 r43514 33 33 setPalette(pal); 34 34 35 /* Scrollbars policy: */ 35 /* Setup frame: */ 36 setFrameShape(QFrame::NoFrame); 37 setFrameShadow(QFrame::Plain); 38 39 /* Setup scroll-bars policy: */ 36 40 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 37 41
Note:
See TracChangeset
for help on using the changeset viewer.