From 4eb6ba5d23857a1148db56add4f3620d6e74a5b5 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sun, 2 Oct 2011 00:08:43 +1000 Subject: [PATCH] Select last used profile by default --- main.cpp | 1 + profileselect.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/main.cpp b/main.cpp index 55401fb7..435c6109 100644 --- a/main.cpp +++ b/main.cpp @@ -114,5 +114,6 @@ int main(int argc, char *argv[]) MainWindow w; mainwin=&w; w.show(); + return a.exec(); } diff --git a/profileselect.cpp b/profileselect.cpp index c9254b7d..80444194 100644 --- a/profileselect.cpp +++ b/profileselect.cpp @@ -24,6 +24,7 @@ ProfileSelect::ProfileSelect(QWidget *parent) : int i=0; + int sel=-1; for (QHash::iterator p=Profiles::profiles.begin();p!=Profiles::profiles.end();p++) { //str.append(p.key()); Profile &profile=**p; @@ -31,6 +32,9 @@ ProfileSelect::ProfileSelect(QWidget *parent) : // if (!profile["FirstName"].toString().isEmpty()) // name+=" ("+profile["FirstName"].toString()+" "+profile["LastName"].toString()+")"; QStandardItem *item=new QStandardItem(*new QIcon(":/icons/moon.png"),name); + if (pref.Exists("Profile") && (name==pref["Profile"].toString())) { + sel=i; + } item->setData(p.key()); item->setEditable(false); item->setFont(QFont("Sans Serif",18,QFont::Bold,false)); @@ -40,6 +44,7 @@ ProfileSelect::ProfileSelect(QWidget *parent) : ui->listView->setModel(model); ui->listView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->listView->setSelectionMode(QAbstractItemView::SingleSelection); + if (sel>=0) ui->listView->setCurrentIndex(model->item(sel)->index()); m_tries=0; }