summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnne Jan Brouwer <annejan@noprotocol.com>2015-05-18 09:45:34 +0200
committerAnne Jan Brouwer <annejan@noprotocol.com>2015-05-18 09:45:34 +0200
commitafc6c3148f6edf462410b8694164d3abccf2c264 (patch)
treed0ac2994cac11087a279ca63614f6d6265d40b84
parent2355ad37bd09a62012f6fb3249743eefeb27fd82 (diff)
Revert "Profile UI mostly done"
-rw-r--r--dialog.cpp93
-rw-r--r--dialog.h4
-rw-r--r--dialog.ui30
-rw-r--r--mainwindow.cpp35
-rw-r--r--mainwindow.h2
5 files changed, 15 insertions, 149 deletions
diff --git a/dialog.cpp b/dialog.cpp
index b24c6fd0..93685f09 100644
--- a/dialog.cpp
+++ b/dialog.cpp
@@ -1,7 +1,5 @@
#include "dialog.h"
#include "ui_dialog.h"
-#include <QDebug>
-#include <QMessageBox>
/**
* @brief Dialog::Dialog
@@ -12,8 +10,6 @@ Dialog::Dialog(QWidget *parent) :
ui(new Ui::Dialog)
{
ui->setupUi(this);
- ui->profileTable->verticalHeader()->hide();
- ui->profileTable->horizontalHeader()->setStretchLastSection(true);
}
/**
@@ -356,25 +352,18 @@ void Dialog::addGPGId(bool addGPGId)
/**
* @brief Dialog::setProfiles
* @param profiles
- * @param profile
*/
void Dialog::setProfiles(QHash<QString, QString> profiles, QString profile)
{
- ui->profileTable->setRowCount(profiles.count());
QHashIterator<QString, QString> i(profiles);
- int n = 0;
while (i.hasNext()) {
i.next();
- if (!i.value().isEmpty()) {
- ui->profileTable->setItem(n, 0, new QTableWidgetItem(i.key()));
- ui->profileTable->setItem(n, 1, new QTableWidgetItem(i.value()));
- //qDebug() << "naam:" + i.key();
- if (i.key() == profile) {
- ui->profileName->setText(i.key());
- ui->storePath->setText(i.value());
- }
+ // TODO
+ //ui->profileTable->
+ if (i.key() == profile) {
+ ui->profileName->setText(i.key());
+ ui->storePath->setText(i.value());
}
- n++;
}
}
@@ -385,76 +374,6 @@ void Dialog::setProfiles(QHash<QString, QString> profiles, QString profile)
QHash<QString, QString> Dialog::getProfiles()
{
QHash<QString, QString> profiles;
- for (int i = 0; i < ui->profileTable->rowCount(); i++) {
- QString path = ui->profileTable->item(i, 1)->text();
- if (!path.isEmpty()) {
- profiles.insert(ui->profileTable->item(i, 0)->text(),
- path);
- }
- }
+ profiles.insert(ui->profileName->text(), ui->storePath->text());
return profiles;
}
-
-/**
- * @brief Dialog::on_addButton_clicked
- */
-void Dialog::on_addButton_clicked()
-{
- QString name = ui->profileName->text();
- int n = 0;
- bool newItem = true;
- QAbstractItemModel *model = ui->profileTable->model();
- QModelIndexList matches = model->match( model->index(0,0), Qt::DisplayRole, name);
- foreach(const QModelIndex &index, matches)
- {
- QTableWidgetItem *item = ui->profileTable->item(index.row(), index.column());
- n = item->row();
- qDebug() << "overwrite:" << item->text();
- newItem = false;
- }
- if (newItem) {
- n = ui->profileTable->rowCount();
- ui->profileTable->insertRow(n);
- }
- ui->profileTable->setItem(n, 0, new QTableWidgetItem(name));
- ui->profileTable->setItem(n, 1, new QTableWidgetItem(ui->storePath->text()));
- //qDebug() << ui->profileName->text();
- ui->profileTable->selectRow(n);
- if (ui->profileTable->rowCount() < 1) {
- ui->deleteButton->setEnabled(true);
- }
-}
-
-/**
- * @brief Dialog::on_profileTable_currentItemChanged
- * @param current
- */
-void Dialog::on_profileTable_currentItemChanged(QTableWidgetItem *current)
-{
- if (current == 0) {
- return;
- }
- int n = current->row();
- ui->profileName->setText(ui->profileTable->item(n, 0)->text());
- ui->storePath->setText(ui->profileTable->item(n, 1)->text());
-}
-
-/**
- * @brief Dialog::on_deleteButton_clicked
- */
-void Dialog::on_deleteButton_clicked()
-{
- QList<QTableWidgetItem*> selected = ui->profileTable->selectedItems();
- if (selected.count() == 0) {
- QMessageBox::warning(this, tr("No profile selected"),
- tr("No profile selected to delete"));
- return;
- }
- for (int i = 0; i < selected.size(); ++i) {
- QTableWidgetItem* item = selected.at(i);
- ui->profileTable->removeRow(item->row());
- }
- if (ui->profileTable->rowCount() < 1) {
- ui->deleteButton->setEnabled(false);
- }
-}
diff --git a/dialog.h b/dialog.h
index 4fd68406..ec2b4905 100644
--- a/dialog.h
+++ b/dialog.h
@@ -3,7 +3,6 @@
#include <QDialog>
#include <QFileDialog>
-#include <QTableWidgetItem>
namespace Ui {
class Dialog;
@@ -50,9 +49,6 @@ private slots:
void on_toolButtonStore_clicked();
void on_checkBoxClipboard_clicked();
void on_checkBoxAutoclear_clicked();
- void on_addButton_clicked();
- void on_profileTable_currentItemChanged(QTableWidgetItem*);
- void on_deleteButton_clicked();
private:
QScopedPointer<Ui::Dialog> ui;
diff --git a/dialog.ui b/dialog.ui
index 8b90f56c..3ddbd01b 100644
--- a/dialog.ui
+++ b/dialog.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>660</width>
- <height>490</height>
+ <height>446</height>
</rect>
</property>
<property name="windowTitle">
@@ -146,21 +146,6 @@
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTableWidget" name="profileTable">
- <property name="editTriggers">
- <set>QAbstractItemView::NoEditTriggers</set>
- </property>
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="selectionMode">
- <enum>QAbstractItemView::SingleSelection</enum>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectRows</enum>
- </property>
- <property name="sortingEnabled">
- <bool>true</bool>
- </property>
<column>
<property name="text">
<string>Name</string>
@@ -203,22 +188,17 @@
</widget>
</item>
<item row="0" column="0">
- <widget class="QToolButton" name="addButton">
+ <widget class="QToolButton" name="toolButton">
<property name="text">
- <string>Add/Edit</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QToolButton" name="deleteButton">
- <property name="text">
- <string>Delete</string>
+ <string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
+ <zorder>labelStorePath</zorder>
+ <zorder></zorder>
<zorder>profileTable</zorder>
<zorder></zorder>
</widget>
diff --git a/mainwindow.cpp b/mainwindow.cpp
index e22f02ef..d02ae98f 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -32,8 +32,7 @@ MainWindow::MainWindow(QWidget *parent) :
enableUiElements(true);
wrapperRunning = false;
execQueue = new QQueue<execQueueItem>;
- ui->statusBar->showMessage(tr("Welcome to QtPass %1").arg(VERSION), 2000);
- startupPhase = true;
+ ui->statusBar->showMessage(tr("Welcome to QtPass ") + VERSION, 2000);
}
/**
@@ -226,7 +225,6 @@ void MainWindow::checkConfig() {
//QMessageBox::information(this, "env", env.join("\n"));
ui->lineEdit->setFocus();
- startupPhase = false;
}
/**
@@ -449,7 +447,7 @@ void MainWindow::readyRead(bool finished = false) {
output.replace(QRegExp("((http|https|ftp)\\://[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\\-\\._\\?\\,\\'/\\\\+&amp;%\\$#\\=~])*)"), "<a href=\"\\1\">\\1</a>");
output.replace(QRegExp("\n"), "<br />");
- if (!ui->textBrowser->toPlainText().isEmpty()) {
+ if (ui->textBrowser->toPlainText() != "") {
output = ui->textBrowser->toHtml() + output;
}
ui->textBrowser->setHtml(output);
@@ -931,47 +929,22 @@ void MainWindow::setText(QString text)
*/
void MainWindow::updateProfileBox()
{
- qDebug() << profiles.size();
if (profiles.isEmpty()) {
ui->profileBox->setVisible(false);
} else {
ui->profileBox->setVisible(true);
if (profiles.size() < 2) {
ui->profileBox->setEnabled(false);
- } else {
- ui->profileBox->setEnabled(true);
}
ui->profileBox->clear();
QHashIterator<QString, QString> i(profiles);
while (i.hasNext()) {
i.next();
- if (!i.key().isEmpty()) {
- ui->profileBox->addItem(i.key());
- }
+ ui->profileBox->addItem(i.key());
}
}
- int index = ui->profileBox->findText(profile);
+ int index = ui->profileBox->findData(profile);
if ( index != -1 ) { // -1 for not found
ui->profileBox->setCurrentIndex(index);
}
}
-
-/**
- * @brief MainWindow::on_profileBox_currentIndexChanged
- * @param name
- */
-void MainWindow::on_profileBox_currentIndexChanged(QString name)
-{
- if (startupPhase || name == profile) {
- return;
- }
- profile = name;
-
- passStore = profiles[name];
- ui->statusBar->showMessage(tr("Profile changed to %1").arg(name), 2000);
-
- QSettings &settings(getSettings());
-
- settings.setValue("profile", profile);
- settings.setValue("passStore", passStore);
-}
diff --git a/mainwindow.h b/mainwindow.h
index 4c5f920d..fd61dc6d 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -59,7 +59,6 @@ private slots:
void on_editButton_clicked();
void on_usersButton_clicked();
void messageAvailable(QString message);
- void on_profileBox_currentIndexChanged(QString);
private:
QScopedPointer<QSettings> settings;
@@ -93,7 +92,6 @@ private:
QHash<QString, QString> profiles;
QQueue<execQueueItem> *execQueue;
QString profile;
- bool startupPhase;
void updateText();
void executePass(QString, QString = QString());
void executeWrapper(QString, QString, QString = QString());