diff --git a/Graphs/glcommon.cpp b/Graphs/glcommon.cpp index 1ad3bf53..02b723d2 100644 --- a/Graphs/glcommon.cpp +++ b/Graphs/glcommon.cpp @@ -12,65 +12,18 @@ #include bool _font_init=false; -//FontManager * font_manager; -//VertexBuffer *vbuffer=NULL; -//TextMarkup *markup=NULL; QFont * defaultfont; QFont * mediumfont; QFont * bigfont; -/*GLText::GLText(const QString & text, int x, int y, float angle, QColor color, QFont * font) -{ -} -void GLText::Draw() -{ -} */ - // Must be called from a thread inside the application. void InitFonts() { if (!_font_init) { - /*#if defined(__WXMSW__) - static bool glewinit_called=false; - if (!glewinit_called) { - glewInit(); // Dont forget this nasty little sucker.. :) - glewinit_called=true; - } - #endif */ - //wxString glvendor=wxString((char *)glGetString(GL_VENDOR),wxConvUTF8); - //wxString glrenderer=wxString((char *)glGetString(GL_RENDERER),wxConvUTF8); - //wxString glversion=wxString((char *)glGetString(GL_VERSION),wxConvUTF8); - //wxLogDebug(wxT("GLInfo: ")+glvendor+wxT(" ")+glrenderer+wxT(" ")+glversion); - // Despite the stupid warning, this does NOT always evaluate as true. Too lazy to put it in #ifdefs - /*if (!glGenBuffers) { - wxMessageBox(wxT("Sorry, your computers graphics card drivers are too old to run this program.\n")+glvendor+wxT(" may have an update.\n")+glrenderer+wxT("\n")+glversion,_("Welcome to..."),wxOK,NULL); - exit(-1); - } */ - - //font_manager=new FontManager(); - //vbuffer=new VertexBuffer((char *)"v3i:t2f:c4f"); - //defaultfont=font_manager->GetFromFilename(pref.Get("{home}{sep}FreeSans.ttf"),12); - //bigfont=font_manager->GetFromFilename(pref.Get("{home}{sep}FreeSans.ttf"),32); - //markup=new TextMarkup(); - //markup->SetForegroundColor(QColor("light green")); - - //glBindTexture( GL_TEXTURE_2D, font_manager->m_atlas->m_texid ); - -/* QString fontfile=pref.Get("{home}{sep}FreeSans.ttf"); - QFile f(fontfile); - if (!f.exists(fontfile)) { - f.open(QIODevice::WriteOnly); - if (!f.write((char *)FreeSans_ttf,FreeSans_length)) { - qWarning("Couldn't Write Font file.. Sorry.. need it to run"); - return; - } - f.close(); - } */ - - defaultfont=new QFont("Helvetica",10);//new QFont(QApplication::font()); - bigfont=new QFont("Helvetica",35); - mediumfont=new QFont("Helvetica",18); + defaultfont=new QFont("FreeSans",10); + bigfont=new QFont("FreeSans",35); + mediumfont=new QFont("FreeSans",18); _font_init=true; } @@ -80,9 +33,6 @@ void DoneFonts() if (_font_init) { delete bigfont; delete mediumfont; - //delete font_manager; - // delete vbuffer; - //delete markup; _font_init=false; } } @@ -94,52 +44,6 @@ void GetTextExtent(QString text, float & width, float & height, QFont *font) width=fm.width(text); //fm.width(text); height=fm.xHeight()+2; //fm.ascent(); } -/*{ - - TextureGlyph *glyph; - height=width=0; - - for (unsigned i=0;iGetGlyph((wchar_t)text[i].unicode()); - if (glyph->m_height > height) height=glyph->m_height; - width+=glyph->m_advance_x; - } -}*/ - // The actual raw font drawing routine.. -/*void DrawText2(QString text, float x, float y,QFont *font) -{ - Pen pen; - pen.x=x; - pen.y=y; - - TextureGlyph *glyph; - glyph=font->GetGlyph((wchar_t)text[0].unicode()); - if (!glyph) return; - //assert(vbuffer!=NULL); - - //vbuffer->Clear(); - - glEnable( GL_BLEND ); - glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); - glEnable( GL_TEXTURE_2D ); - glColor4f(0,0,0,1); - - glyph->Render(markup,&pen); -// glyph->AddToVertexBuffer(vbuffer, markup, &pen); - for (unsigned j=1; jGetGlyph(text[j].unicode()); - pen.x += glyph->GetKerning(text[j-1].unicode()); - glyph->Render(markup,&pen); - - // glyph->AddToVertexBuffer(vbuffer, markup, &pen); - } - //glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - //vbuffer->Render(GL_TRIANGLES, (char *)"vtc" ); - glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - -} */ - void DrawText(gGraphWindow & wid, QString text, float x, float y, float angle, QColor color,QFont *font) { //QFontMetrics fm(*font); @@ -160,13 +64,6 @@ void DrawText(gGraphWindow & wid, QString text, float x, float y, float angle, Q } QPainter painter(&wid); - //painter.setMatrixEnabled(true); - //painter.setWindow(0,0,wid.GetScrX(),wid.GetScrY()); - //painter.begin(); - //QMatrix matrix; - //matrix.rotate(angle); - //painter.setMatrix(matrix,true); - //float w,h; GetTextExtent(text, w, h, font); painter.translate(floor(x),floor(y)); @@ -176,17 +73,7 @@ void DrawText(gGraphWindow & wid, QString text, float x, float y, float angle, Q painter.drawText(floor(-w/2.0),floor(-h/2.0),text); painter.translate(floor(-x),floor(-y)); painter.end(); -/* glPushMatrix(); - glEnable(GL_DEPTH_TEST); - //glEnable(GL_TEXTURE_2D); - glTranslatef(floor(x),floor(y),0); - glRotatef(angle, 0.0f, 0.0f, 1.0f); - wid.renderText(floor(-w/2.0),floor(-h/2.0),text,*font); - //DrawText2(text,floor(-w/2.0),floor(-h/2.0),font); - glTranslatef(floor(-x),floor(-y),0); - //glDisable(GL_TEXTURE_2D); - glPopMatrix(); */ glDisable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); @@ -195,7 +82,6 @@ void DrawText(gGraphWindow & wid, QString text, float x, float y, float angle, Q void RoundedRectangle(int x,int y,int w,int h,int radius,const QColor color) { - //glDisable(GL_TEXTURE_2D); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); diff --git a/Graphs/glcommon.h b/Graphs/glcommon.h index 6b2ce994..3d4865d7 100644 --- a/Graphs/glcommon.h +++ b/Graphs/glcommon.h @@ -11,8 +11,6 @@ #include #include #include "Graphs/graphwindow.h" -//#include "FreeTypeGL/font-manager.h" -//#include "FreeTypeGL/texture-font.h" void InitFonts(); void DoneFonts(); @@ -21,22 +19,9 @@ extern QFont * defaultfont; extern QFont * mediumfont; extern QFont * bigfont; -/*class GLText -{ -public: - GLText(const QString & text, int x, int y, float angle=0.0, QColor color=QColor("black"), QFont * font=defaultfont); - void Draw(); - QString m_text; - QFont m_font; - QColor m_color; - int m_x; - int m_y; - float m_angle; -};*/ class gGraphWindow; void GetTextExtent(QString text, float & width, float & height, QFont *font=defaultfont); -//void DrawText2(QString text, float x, float y,TextureFont *font=defaultfont); // The actual raw font drawing routine.. void DrawText(gGraphWindow & wid, QString text, float x, float y, float angle=0, QColor color=QColor("black"),QFont *font=defaultfont); void LinedRoundedRectangle(int x,int y,int w,int h,int radius,int lw,QColor color); diff --git a/SleepLib/machine.cpp b/SleepLib/machine.cpp index 012f26ff..a100072b 100644 --- a/SleepLib/machine.cpp +++ b/SleepLib/machine.cpp @@ -12,6 +12,7 @@ #include #include #include + extern QProgressBar * qprogress; map MachLastCode; @@ -371,7 +372,10 @@ bool Machine::Load() sessfiles[sessid][ext]=fi.canonicalFilePath(); } + int size=sessfiles.size(); + int cnt=0; for (s=sessfiles.begin(); s!=sessfiles.end(); s++) { + if (qprogress) qprogress->setValue((float(++cnt)/float(size)*100.0)); Session *sess=new Session(this,s->first); if (sess->LoadSummary(s->second[0])) { sess->SetEventFile(s->second[1]); diff --git a/SleepLib/profiles.cpp b/SleepLib/profiles.cpp index 28465abb..9823081e 100644 --- a/SleepLib/profiles.cpp +++ b/SleepLib/profiles.cpp @@ -187,8 +187,9 @@ void Profile::AddDay(QDate date,Day *day,MachineType mt) { Day * Profile::GetDay(QDate date,MachineType type) { Day *day=NULL; - if (profile->daylist.find(date)!=profile->daylist.end()) { - for (vector::iterator di=profile->daylist[date].begin();di!=profile->daylist[date].end();di++) { + // profile-> why did I d that?? + if (daylist.find(date)!=daylist.end()) { + for (vector::iterator di=daylist[date].begin();di!=daylist[date].end();di++) { if (type==MT_UNKNOWN) { // Who cares.. We just want to know there is data available. day=(*di); break; @@ -313,7 +314,9 @@ Profile *Create(QString name,QString realname,QString password) Profile *Get() { - return profile; + // username lookup + //getUserName() + return profiles[getUserName()];; } diff --git a/daily.cpp b/daily.cpp index 2be811da..56b40f4e 100644 --- a/daily.cpp +++ b/daily.cpp @@ -41,9 +41,9 @@ Daily::Daily(QWidget *parent,QGLContext *context) : gSplitter=new QSplitter(Qt::Vertical,ui->scrollArea); gSplitter->setStyleSheet("QSplitter::handle { background-color: 'dark grey'; }"); - - gSplitter->setChildrenCollapsible(false); - gSplitter->setHandleWidth(3); + gSplitter->setChildrenCollapsible(true); + gSplitter->setHandleWidth(1); + //gSplitter->handle ui->graphSizer->addWidget(gSplitter); //QPalette pal; diff --git a/main.cpp b/main.cpp index fa051369..6bd7c8ba 100644 --- a/main.cpp +++ b/main.cpp @@ -20,25 +20,15 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); + a.setApplicationName("SleepyHead"); QFontDatabase::addApplicationFont(":/fonts/freesans.ttf"); a.setFont(QFont("FreeSans")); PRS1Loader::Register(); CMS50Loader::Register(); ZEOLoader::Register(); - Profiles::Scan(); - //loader_progress->Show(); - pref["AppName"]="SleepyHead"; - //pref["Version"]=wxString(AutoVersion::_FULLVERSION_STRING,wxConvUTF8); - pref["Profile"]=getUserName(); - pref["LinkGraphMovement"]=true; - pref["fruitsalad"]=true; - - profile=Profiles::Get(pref["Profile"].toString()); - - profile->LoadMachineData(); /*Machine *m=new Machine(profile,0); m->SetClass("Journal"); diff --git a/mainwindow.cpp b/mainwindow.cpp index ab921039..e097a850 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "mainwindow.h" #include "ui_mainwindow.h" #include "daily.h" @@ -25,6 +26,7 @@ MainWindow::MainWindow(QWidget *parent) : { ui->setupUi(this); this->setWindowTitle("SleepyHead v0.8."+subversion); + QGLFormat fmt; fmt.setDepth(false); fmt.setDirectRendering(true); @@ -34,21 +36,26 @@ MainWindow::MainWindow(QWidget *parent) : fmt.setDefaultFormat(fmt); shared_context=new QGLContext(fmt); - daily=new Daily(ui->tabWidget,shared_context); - overview=new Overview(ui->tabWidget,shared_context); - ui->tabWidget->addTab(daily,"Daily"); - ui->tabWidget->addTab(overview,"Overview"); - //ui->tabWidget->setCurrentWidget(daily); qprogress=new QProgressBar(this); qprogress->setMaximum(100); - qstatus=new QLabel("Ready",this); - + qstatus=new QLabel("",this); + qprogress->hide(); ui->statusbar->addPermanentWidget(qstatus); ui->statusbar->addPermanentWidget(qprogress); - qprogress->hide(); - //on_homeButton_clicked(); + daily=NULL; + overview=NULL; + Profiles::Scan(); + //loader_progress->Show(); + + //pref["Version"]=wxString(AutoVersion::_FULLVERSION_STRING,wxConvUTF8); + pref["AppName"]="SleepyHead"; + pref["Profile"]=getUserName(); + pref["LinkGraphMovement"]=true; + pref["fruitsalad"]=true; + + first_load=true; } MainWindow::~MainWindow() @@ -66,6 +73,24 @@ MainWindow::~MainWindow() Profiles::Done(); } +void MainWindow::Startup() +{ + + qstatus->setText("Loading Data"); + qprogress->show(); + + Profile *profile=Profiles::Get(pref["Profile"].toString()); + profile->LoadMachineData(); + + daily=new Daily(ui->tabWidget,shared_context); + overview=new Overview(ui->tabWidget,shared_context); + ui->tabWidget->addTab(daily,"Daily"); + ui->tabWidget->addTab(overview,"Overview"); + + qprogress->hide(); + qstatus->setText("Ready"); +} + void MainWindow::on_action_Import_Data_triggered() { QStringList dirNames; @@ -76,7 +101,7 @@ void MainWindow::on_action_Import_Data_triggered() if (qfd.exec()) { qprogress->setValue(0); qprogress->show(); - qstatus->setText("Busy"); + qstatus->setText("Importing Data"); dirNames=qfd.selectedFiles(); for (int i=0;iImport(dirNames[i]); @@ -167,14 +192,22 @@ void MainWindow::on_overviewButton_clicked() void MainWindow::on_webView_loadFinished(bool arg1) { qprogress->hide(); - qstatus->setText("Ready"); + if (first_load) { + QTimer::singleShot(0,this,SLOT(Startup())); + first_load=false; + } else { + qstatus->setText("Ready"); + } + } void MainWindow::on_webView_loadStarted() { - qprogress->reset(); - qprogress->show(); - qstatus->setText("Loading"); + if (!first_load) { + qstatus->setText("Loading"); + qprogress->reset(); + qprogress->show(); + } } void MainWindow::on_webView_loadProgress(int progress) diff --git a/mainwindow.h b/mainwindow.h index 6ad62282..028aa153 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -60,11 +60,14 @@ private slots: void on_action_About_triggered(); + void Startup(); + private: Ui::MainWindow *ui; Daily * daily; Overview * overview; QGLContext *shared_context; + bool first_load; }; #endif // MAINWINDOW_H