Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
preferences.cpp
1 //This program is free software: you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation, either version 3 of the License, or
4 //(at your option) any later version.
5 
6 //This program is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
10 
11 #include "preferences.hpp"
12 #include "ui_preferences.h"
13 
14 using namespace Huggle;
15 
16 Preferences::Preferences(QWidget *parent) : QDialog(parent), ui(new Ui::Preferences)
17 {
18  ui->setupUi(this);
19  // headers
20  ui->tableWidget->setColumnCount(4);
21  QStringList header;
22  /// \todo LOCALIZE ME
23  header << "Name" << "Author" << "Description" << "Status" << "Version";
24  ui->tableWidget->setHorizontalHeaderLabels(header);
25  ui->tableWidget->verticalHeader()->setVisible(false);
26  ui->tableWidget->horizontalHeader()->setSelectionBehavior(QAbstractItemView::SelectRows);
27  ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
28 #if QT_VERSION >= 0x050000
29 // Qt5 code
30  ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
31 #else
32 // Qt4 code
33  ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
34 #endif
35  ui->tableWidget->setShowGrid(false);
36  int c = 0;
37  while (c < HuggleQueueFilter::Filters.count())
38  {
39  ui->listWidget->addItem(HuggleQueueFilter::Filters.at(c)->QueueName);
40  c++;
41  }
42  this->Disable();
43  // options
44  ui->checkBox_5->setChecked(Configuration::EnforceManualSoftwareRollback);
45  ui->checkBox_2->setChecked(Configuration::WarnUserSpaceRoll);
46  ui->checkBox->setChecked(Configuration::AutomaticallyResolveConflicts);
47  ui->checkBox_12->setChecked(Configuration::UsingIRC);
48 }
49 
50 void Huggle::Preferences::on_listWidget_itemSelectionChanged()
51 {
52  if (ui->listWidget->currentRow() == 0)
53  {
54  this->Disable();
55  } else
56  {
57  this->EnableQueues();
58  }
59  HuggleQueueFilter *f = HuggleQueueFilter::Filters.at(ui->listWidget->currentRow());
60  ui->checkBox_7->setChecked(f->getIgnoreBots());
61  ui->lineEdit->setText(f->QueueName);
62 }
63 
64 Preferences::~Preferences()
65 {
66  delete ui;
67 }
68 
69 void Preferences::Disable()
70 {
71  ui->checkBox_6->setEnabled(false);
72  ui->checkBox_7->setEnabled(false);
73  ui->checkBox_8->setEnabled(false);
74  ui->checkBox_9->setEnabled(false);
75  ui->checkBox_10->setEnabled(false);
76  ui->pushButton_4->setEnabled(false);
77  ui->pushButton_5->setEnabled(false);
78  ui->pushButton_6->setEnabled(false);
79  ui->lineEdit->setEnabled(false);
80 }
81 
82 void Preferences::EnableQueues()
83 {
84  ui->lineEdit->setEnabled(true);
85  ui->checkBox_6->setEnabled(true);
86  ui->checkBox_7->setEnabled(true);
87  ui->checkBox_8->setEnabled(true);
88  ui->checkBox_9->setEnabled(true);
89  ui->checkBox_10->setEnabled(true);
90  ui->pushButton_4->setEnabled(true);
91  ui->pushButton_5->setEnabled(true);
92  ui->pushButton_6->setEnabled(true);
93 }
94 
95 void Preferences::on_pushButton_clicked()
96 {
97  this->hide();
98 }
99 
100 void Huggle::Preferences::on_pushButton_2_clicked()
101 {
102  Configuration::AutomaticallyResolveConflicts = ui->checkBox->isChecked();
103  Configuration::WarnUserSpaceRoll = ui->checkBox_2->isChecked();
104  Configuration::UsingIRC = ui->checkBox_12->isChecked();
105  Configuration::EnforceManualSoftwareRollback = ui->checkBox_5->isChecked();
107  this->hide();
108 }
Preferences(QWidget *parent=0)
Definition: preferences.cpp:16
Filter that can be applied to edit queue.
static bool WarnUserSpaceRoll
Warn you in case you want to revert a user page.
static bool UsingIRC
Whether IRC is being used.
Preferences window.
Definition: preferences.hpp:29
static bool AutomaticallyResolveConflicts
Resolve edit conflict without asking user.
static void SaveConfig()
Save the local configuration to file.
static bool EnforceManualSoftwareRollback
If this is true huggle will always use software rollback even if user has the rollback privileges...