diff --git a/src/Colors.cpp b/src/Colors.cpp index 27390302d..930d60185 100644 --- a/src/Colors.cpp +++ b/src/Colors.cpp @@ -108,6 +108,38 @@ void GCColor::setupColors() copyArray(init, ColorList); } +// default settings for fonts etc +struct Appearance defaultAppearance[] ={ + + // small screens include netbooks and old vga 800x600, 1024x768 + { 1024, 768, 8,8,8,8,8,8, 800, 600 }, + + // medium screen size includes typical 16:9 pc formats and TV screens + { 1280, 800, 8,8,8,8,8,8, 800, 600}, + + // high resolution screens + { 1650, 1080, 11,11,11,11,11,11, 1024,650 }, + + // very big panels, incl. e.g. mac 27" + { 9999, 9999, 11,11,11,11,11,11, 1280,700 }, + + { 0,0,0,0,0,0,0,0,0,0 }, +}; + +struct Appearance +GCColor::defaultSizes(int width, int height) +{ + for (int i=0; defaultAppearance[i].maxheight; i++) { + + if (height > defaultAppearance[i].maxheight && width > defaultAppearance[i].maxwidth) + continue; + + else return defaultAppearance[i]; + + } + return defaultAppearance[0]; // shouldn't get here +} + GCColor::GCColor(MainWindow *main) : QObject(main) { setupColors(); diff --git a/src/Colors.h b/src/Colors.h index d3211d969..550183594 100644 --- a/src/Colors.h +++ b/src/Colors.h @@ -26,6 +26,27 @@ class MainWindow; +// set appearace defaults based upon screen size +struct Appearance { + + // this applies up to the following geometry + int maxheight, + maxwidth; + + // font size + int defaultFont, + titleFont, + markerFont, + labelFont, + calendarFont, + popupFont; + + // screen dimension + int width, + height; +}; + +extern Appearance defaultAppearance[]; struct Colors { QString name, @@ -46,6 +67,7 @@ class GCColor : public QObject static const Colors *defaultColorSet(); static void resetColors(); static QColor invert(QColor); + static struct Appearance defaultSizes(int width, int height); public slots: void readConfig(); diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 942ec973d..1b2373632 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -123,6 +123,7 @@ #include "TrainDB.h" QList mainwindows; // keep track of all the MainWindows we have open +QDesktopWidget *desktop = NULL; MainWindow::MainWindow(const QDir &home) : home(home), session(0), isclean(false), ismultisave(false), @@ -130,6 +131,7 @@ MainWindow::MainWindow(const QDir &home) : ride(NULL), workout(NULL) { + if (desktop == NULL) desktop = QApplication::desktop(); static const QIcon hideIcon(":images/toolbar/main/hideside.png"); static const QIcon rhideIcon(":images/toolbar/main/hiderside.png"); static const QIcon showIcon(":images/toolbar/main/showside.png"); @@ -159,11 +161,38 @@ MainWindow::MainWindow(const QDir &home) : setAttribute(Qt::WA_DeleteOnClose); + // need to restore geometry before setUnifiedToolBar.. on Mac appsettings->setValue(GC_SETTINGS_LAST, home.dirName()); QVariant geom = appsettings->value(this, GC_SETTINGS_MAIN_GEOM); - if (geom == QVariant()) resize(640, 480); - else setGeometry(geom.toRect()); + if (geom == QVariant()) { + + // first run -- lets set some sensible defaults... + // lets put it in the middle of screen 1 + QRect size = desktop->availableGeometry(); + struct Appearance app = GCColor::defaultSizes(size.height(), size.width()); + + // center on the available screen (minus toolbar/sidebar) + move((size.width()-size.x())/2 - app.width/2, + (size.height()-size.y())/2 - app.height/2); + + // set to the right default + resize(app.width, app.height); + + // set all the default font sizes + appsettings->setValue(GC_FONT_DEFAULT_SIZE, app.defaultFont); + appsettings->setValue(GC_FONT_TITLES_SIZE, app.titleFont); + appsettings->setValue(GC_FONT_CHARTMARKERS_SIZE, app.markerFont); + appsettings->setValue(GC_FONT_CHARTLABELS_SIZE, app.labelFont); + appsettings->setValue(GC_FONT_CALENDAR_SIZE, app.calendarFont); + appsettings->setValue(GC_FONT_POPUP_SIZE, app.popupFont); + + // set the default fontsize + QFont font; + font.setPointSize(app.defaultFont); + QApplication::setFont(font); + + } else setGeometry(geom.toRect()); #ifdef Q_OS_MAC // MAC NATIVE TOOLBAR diff --git a/src/MainWindow.h b/src/MainWindow.h index 5453d600f..d7edf9273 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -76,6 +76,7 @@ class BlankStateDiaryPage; class BlankStateTrainPage; extern QList mainwindows; // keep track of all the MainWindows we have open +extern QDesktopWidget *desktop; // how many screens / res etc class MainWindow : public QMainWindow {