Changeset 2996 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Jun 2, 2007 12:36:48 PM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/include/VBoxSelectorWnd.h
r2981 r2996 72 72 void vmDiscard(); 73 73 void vmRefresh(); 74 void vmShowLogs (bool);74 void vmShowLogs(); 75 75 76 76 void refreshVMList(); -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxSelectorWnd.cpp
r2983 r2996 420 420 vmShowLogsAction->setIconSet (VBoxGlobal::iconSet ( 421 421 "show_logs_16px.png", "show_logs_disabled_16px.png")); 422 vmShowLogsAction->setToggleAction (true);423 422 424 423 helpContentsAction = new QAction (this, "helpContentsAction"); … … 576 575 connect (vmDiscardAction, SIGNAL (activated()), this, SLOT (vmDiscard())); 577 576 connect (vmRefreshAction, SIGNAL (activated()), this, SLOT (vmRefresh())); 578 connect (vmShowLogsAction, SIGNAL ( toggled (bool)), this, SLOT (vmShowLogs (bool)));577 connect (vmShowLogsAction, SIGNAL (activated()), this, SLOT (vmShowLogs())); 579 578 580 579 connect (helpContentsAction, SIGNAL (activated()), this, SLOT(showHelpContents())); … … 927 926 } 928 927 929 void VBoxSelectorWnd::vmShowLogs (bool aOn) 930 { 931 if (aOn) 932 { 933 VBoxVMLogViewer *logViewer = new VBoxVMLogViewer (this, 934 "logViewer", WType_TopLevel | WDestructiveClose); 935 VBoxVMListBoxItem *item = (VBoxVMListBoxItem *) vmListBox->selectedItem(); 936 CMachine machine = item->machine(); 937 logViewer->setup (machine, vmShowLogsAction); 938 logViewer->show(); 939 } 928 void VBoxSelectorWnd::vmShowLogs() 929 { 930 VBoxVMListBoxItem *item = (VBoxVMListBoxItem *) vmListBox->selectedItem(); 931 CMachine machine = item->machine(); 932 VBoxVMLogViewer::createLogViewer (machine); 940 933 } 941 934 -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMLogViewer.ui
r2988 r2996 37 37 <property name="name"> 38 38 <cstring>unnamed</cstring> 39 </property> 40 <property name="margin"> 41 <number>10</number> 39 42 </property> 40 43 <property name="spacing"> … … 159 162 </forwards> 160 163 <variables> 164 <variable access="private">static VBoxVMLogViewer *mSelf;</variable> 165 <variable access="private">bool mFirstRun;</variable> 161 166 <variable access="private">bool mIsPolished;</variable> 162 167 <variable access="private">QSizeGrip *mSizeGrip;</variable> 163 168 <variable access="private">CMachine mMachine;</variable> 164 <variable access="private">QAction *mAction;</variable>165 169 <variable access="private">QTabWidget *mLogList;</variable> 166 170 <variable access="private">QStringList mLogFilesList;</variable> … … 169 173 <slots> 170 174 <slot access="pritave">refresh()</slot> 171 <slot access="private">suicide (bool)</slot>172 175 <slot access="private">save()</slot> 173 176 </slots> 174 177 <functions> 178 <function specifier="static">createLogViewer( CMachine& )</function> 175 179 <function access="private">init()</function> 176 180 <function access="private">destroy()</function> 181 <function>setup( CMachine & )</function> 182 <function returnType="const CMachine&">machine()</function> 177 183 <function access="pritave">languageChangeImp()</function> 178 184 <function access="pritave" returnType="QPushButton*">searchDefaultButton()</function> … … 182 188 <function access="protected">showEvent( QShowEvent* )</function> 183 189 <function access="protected">resizeEvent( QResizeEvent* )</function> 184 <function>setup( CMachine &, QAction* )</function>185 190 <function access="pritave">loadLogFile( const QString & )</function> 186 191 <function access="pritave" returnType="QTextBrowser*">createLogPage( const QString & )</function> -
trunk/src/VBox/Frontends/VirtualBox/ui/VBoxVMLogViewer.ui.h
r2988 r2996 31 31 32 32 33 VBoxVMLogViewer *VBoxVMLogViewer::mSelf = 0; 34 void VBoxVMLogViewer::createLogViewer (CMachine &aMachine) 35 { 36 if (!mSelf) 37 { 38 /* creating new log viewer if there is no one existing */ 39 mSelf = new VBoxVMLogViewer (0, "VBoxVMLogViewer", 40 WType_TopLevel | WDestructiveClose); 41 } 42 43 if (mSelf->machine() != aMachine) 44 { 45 /* re-read new machine data if the machine was changed or 46 * the log-viewer is opened for the first time */ 47 mSelf->setup (aMachine); 48 } 49 50 mSelf->show(); 51 mSelf->setWindowState (mSelf->windowState() & ~WindowMinimized); 52 mSelf->setActiveWindow(); 53 } 54 55 33 56 void VBoxVMLogViewer::init() 34 57 { 58 /* prepare dialog to first run */ 59 mFirstRun = true; 60 35 61 /* dialog initially is not polished */ 36 62 mIsPolished = false; … … 63 89 void VBoxVMLogViewer::destroy() 64 90 { 65 /* switch the related toggle action off */ 66 mAction->setOn (false); 91 mSelf = 0; 92 } 93 94 95 void VBoxVMLogViewer::setup (CMachine &aMachine) 96 { 97 /* saving related machine */ 98 mMachine = aMachine; 99 100 /* reading log files */ 101 refresh(); 102 103 /* loading language constants */ 104 languageChangeImp(); 105 } 106 107 108 const CMachine& VBoxVMLogViewer::machine() 109 { 110 return mMachine; 67 111 } 68 112 … … 200 244 201 245 202 void VBoxVMLogViewer::setup (CMachine &aMachine, QAction *aAction)203 {204 /* saving predefined variables */205 mMachine = aMachine;206 mAction = aAction;207 208 /* setup self-destruction handler */209 connect (mAction, SIGNAL (toggled (bool)), this, SLOT (suicide (bool)));210 211 /* reading log files */212 refresh();213 214 /* loading language constants */215 languageChangeImp();216 }217 218 219 246 void VBoxVMLogViewer::refresh() 220 247 { … … 247 274 QTextBrowser *dummyLog = createLogPage ("VBox.log"); 248 275 dummyLog->setTextFormat (Qt::RichText); 276 dummyLog->setWordWrap (QTextEdit::WidgetWidth); 249 277 dummyLog->setText (tr ("<p>No log files found. Press the <b>Refresh</b> " 250 278 "button to rescan the log folder <nobr><b>%1</b></nobr>.</p>") … … 252 280 } 253 281 282 /* restore previous tab-widget margin which was reseted when 283 * the tab widget's children was removed */ 284 mLogList->setMargin (10); 285 254 286 /* show the first tab widget's page after the refresh */ 255 287 mLogList->showPage (mLogList->page(0)); 288 289 /* enable/disable save button & tab widget according log presence */ 256 290 mSaveButton->setEnabled (isAnyLogPresent); 291 mLogList->setEnabled (isAnyLogPresent); 292 293 if (mFirstRun) 294 { 295 /* resize the whole log-viewer to fit 80 symbols in text-browser for 296 * the first time started */ 297 QTextBrowser *firstPage = static_cast<QTextBrowser*> (mLogList->page(0)); 298 int fullWidth = firstPage->fontMetrics().width (QChar ('x')) * 80 + 299 firstPage->verticalScrollBar()->width() + 300 firstPage->frameWidth() * 2 + 301 1 * 2 /* some one-pixel margin */ + 302 mLogList->margin() * 2 + 303 centralWidget()->layout()->margin() * 2; 304 resize (fullWidth, height()); 305 mFirstRun = false; 306 } 257 307 } 258 308 … … 280 330 font.setFamily ("Courier New,courier"); 281 331 logViewer->setFont (font); 332 logViewer->setWordWrap (QTextEdit::NoWrap); 333 logViewer->setVScrollBarMode (QScrollView::AlwaysOn); 282 334 mLogList->addTab (logViewer, aName); 283 335 return logViewer; … … 285 337 286 338 287 void VBoxVMLogViewer::suicide (bool aNo)288 {289 if (!aNo) close();290 }291 292 293 339 void VBoxVMLogViewer::save() 294 340 { 295 341 /* prepare "save as" dialog */ 296 QDate date = QDate::currentDate();297 QTime time = QTime::currentTime();298 QString d efaultFileName = QString ("%1-%2-%3-%4-%5-%6-%7.log")299 .arg (mMachine.GetName())300 .arg (date.year()).arg (date.month()).arg (date.day())301 .arg ( time.hour()).arg (time.minute()).arg (time.second());302 QString defaultFullName = QDir::convertSeparators (QDir::home().absPath() + "/" +303 defaultFileName);342 QDate fullDate = QDate::currentDate(); 343 QTime fullTime = QTime::currentTime(); 344 QString date = fullDate.toString ("yyyy-MM-dd"); 345 QString time = fullTime.toString ("hh-mm-ss"); 346 QString defaultFileName = QString ("%1-%2-%3.log") 347 .arg (mMachine.GetName()).arg (date).arg (time); 348 QString defaultFullName = QDir::convertSeparators (QDir::home().absPath() + 349 "/" + defaultFileName); 304 350 305 351 QString newFileName = QFileDialog::getSaveFileName (defaultFullName,
Note:
See TracChangeset
for help on using the changeset viewer.