From 84e5c2610ab0347127645e277f08dd83e11383fd Mon Sep 17 00:00:00 2001 From: graffy76 Date: Fri, 16 Aug 2013 18:00:23 -0500 Subject: [PATCH] Implemented combobox for game file selection --- apps/launcher/datafilespage.cpp | 2 +- apps/opencs/view/doc/filedialog.cpp | 20 +++++++------- apps/opencs/view/doc/filedialog.hpp | 2 +- .../fileorderlist/utils/profilescombobox.cpp | 16 +++++++++++ .../fileorderlist/utils/profilescombobox.hpp | 5 +++- files/ui/datafilespage.ui | 27 +++---------------- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index add3dea40..1fafd5922 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -101,7 +101,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews())); - connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); + //connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter())); diff --git a/apps/opencs/view/doc/filedialog.cpp b/apps/opencs/view/doc/filedialog.cpp index 02421a788..b06c97008 100644 --- a/apps/opencs/view/doc/filedialog.cpp +++ b/apps/opencs/view/doc/filedialog.cpp @@ -41,6 +41,8 @@ FileDialog::FileDialog(QWidget *parent) : QCheckBox checkBox; unsigned int height = checkBox.sizeHint().height() + 4; + masterView->setModel(mMastersProxyModel); + mastersTable->setModel(mMastersProxyModel); mastersTable->setObjectName("MastersTable"); mastersTable->setContextMenuPolicy(Qt::CustomContextMenu); @@ -83,12 +85,12 @@ FileDialog::FileDialog(QWidget *parent) : mNameLabel = new QLabel(tr("File Name:"), this); QRegExpValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9\\s]*$")); - mNameLineEdit = new LineEdit(this); - mNameLineEdit->setValidator(validator); + //mNameLineEdit = new LineEdit(this); + //mNameLineEdit->setValidator(validator); nameLayout->addSpacerItem(spacer); nameLayout->addWidget(mNameLabel); - nameLayout->addWidget(mNameLineEdit); + //nameLayout->addWidget(mNameLineEdit); mButtonBox = new QDialogButtonBox(this); @@ -109,9 +111,9 @@ FileDialog::FileDialog(QWidget *parent) : connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews())); connect(mDataFilesModel, SIGNAL(checkedItemsChanged(QStringList)), this, SLOT(updateOpenButton(QStringList))); - connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString))); + //connect(mNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString))); - connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); + //connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(pluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(mastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); @@ -223,7 +225,7 @@ QStringList FileDialog::checkedItemsPaths() QString FileDialog::fileName() { - return mNameLineEdit->text(); + //return mNameLineEdit->text(); } void FileDialog::openFile() @@ -231,7 +233,7 @@ void FileDialog::openFile() setWindowTitle(tr("Open")); mNameLabel->hide(); - mNameLineEdit->hide(); + //mNameLineEdit->hide(); mCreateButton->hide(); mButtonBox->removeButton(mCreateButton); @@ -249,8 +251,8 @@ void FileDialog::newFile() setWindowTitle(tr("New")); mNameLabel->show(); - mNameLineEdit->clear(); - mNameLineEdit->show(); + //mNameLineEdit->clear(); + //mNameLineEdit->show(); mCreateButton->show(); mButtonBox->setStandardButtons(QDialogButtonBox::Cancel); diff --git a/apps/opencs/view/doc/filedialog.hpp b/apps/opencs/view/doc/filedialog.hpp index b21618d5d..4c3fe9ffa 100644 --- a/apps/opencs/view/doc/filedialog.hpp +++ b/apps/opencs/view/doc/filedialog.hpp @@ -51,7 +51,7 @@ private slots: private: QLabel *mNameLabel; - LineEdit *mNameLineEdit; + //LineEdit *mNameLineEdit; QPushButton *mCreateButton; QDialogButtonBox *mButtonBox; diff --git a/components/fileorderlist/utils/profilescombobox.cpp b/components/fileorderlist/utils/profilescombobox.cpp index c3ff953ae..9346276da 100644 --- a/components/fileorderlist/utils/profilescombobox.cpp +++ b/components/fileorderlist/utils/profilescombobox.cpp @@ -90,3 +90,19 @@ void ProfilesComboBox::slotIndexChanged(int index) emit(profileChanged(mOldProfile, currentText())); mOldProfile = itemText(index); } + +void ProfilesComboBox::paintEvent(QPaintEvent *) +{ + QStylePainter painter(this); + painter.setPen(palette().color(QPalette::Text)); + + // draw the combobox frame, focusrect and selected etc. + QStyleOptionComboBox opt; + initStyleOption(&opt); + painter.drawComplexControl(QStyle::CC_ComboBox, opt); + + // draw the icon and text + if (!opt.editable && currentIndex() == -1) // <<< we adjust the text displayed when nothing is selected + opt.currentText = tr("Select a game file..."); + painter.drawControl(QStyle::CE_ComboBoxLabel, opt); +} diff --git a/components/fileorderlist/utils/profilescombobox.hpp b/components/fileorderlist/utils/profilescombobox.hpp index 08ead9a7a..55913d7fe 100644 --- a/components/fileorderlist/utils/profilescombobox.hpp +++ b/components/fileorderlist/utils/profilescombobox.hpp @@ -2,7 +2,7 @@ #define PROFILESCOMBOBOX_HPP #include - +#include class QString; class QRegExpValidator; @@ -25,6 +25,9 @@ private slots: private: QString mOldProfile; QRegExpValidator *mValidator; + +protected: + void paintEvent(QPaintEvent *); }; #endif // PROFILESCOMBOBOX_HPP diff --git a/files/ui/datafilespage.ui b/files/ui/datafilespage.ui index 041a9576d..342e4d9e9 100644 --- a/files/ui/datafilespage.ui +++ b/files/ui/datafilespage.ui @@ -14,28 +14,12 @@ - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Filter: + + + false - - - @@ -151,11 +135,6 @@ - - LineEdit - QLineEdit -
components/fileorderlist/utils/lineedit.hpp
-
ProfilesComboBox QComboBox